@@ -35,7 +35,7 @@ public class ERC1155: IERC1155 {
35
35
private var _tokenId : BigUInt ? = nil
36
36
private var _hasReadProperties : Bool = false
37
37
38
- public var transactionOptions : CodableTransaction
38
+ public var transaction : CodableTransaction
39
39
public var web3 : web3
40
40
public var provider : Web3Provider
41
41
public var address : EthereumAddress
@@ -51,8 +51,8 @@ public class ERC1155: IERC1155 {
51
51
self . web3 = web3
52
52
self . provider = provider
53
53
self . address = address
54
- self . transactionOptions = transaction
55
- self . transactionOptions . to = address
54
+ self . transaction = transaction
55
+ self . transaction . to = address
56
56
self . abi = abi
57
57
}
58
58
@@ -70,8 +70,7 @@ public class ERC1155: IERC1155 {
70
70
}
71
71
let contract = self . contract
72
72
guard contract. contract. address != nil else { return }
73
- var transactionOptions = CodableTransaction . emptyTransaction
74
- transactionOptions. callOnBlock = . latest
73
+ self . transaction. callOnBlock = . latest
75
74
76
75
guard let tokenIdPromise = try await contract. createReadOperation ( " id " , parameters: [ ] as [ AnyObject ] , extraData: Data ( ) ) ? . callContractMethod ( ) else { return }
77
76
@@ -83,19 +82,17 @@ public class ERC1155: IERC1155 {
83
82
84
83
public func safeTransferFrom( from: EthereumAddress , to: EthereumAddress , originalOwner: EthereumAddress , id: BigUInt , value: BigUInt , data: [ UInt8 ] ) throws -> WriteOperation {
85
84
let contract = self . contract
86
- var basicOptions = CodableTransaction . emptyTransaction
87
- basicOptions. from = from
88
- basicOptions. to = self . address
85
+ self . transaction. from = from
86
+ self . transaction. to = self . address
89
87
90
88
let tx = contract. createWriteOperation ( " safeTransferFrom " , parameters: [ originalOwner, to, id, value, data] as [ AnyObject ] ) !
91
89
return tx
92
90
}
93
91
94
92
public func safeBatchTransferFrom( from: EthereumAddress , to: EthereumAddress , originalOwner: EthereumAddress , ids: [ BigUInt ] , values: [ BigUInt ] , data: [ UInt8 ] ) throws -> WriteOperation {
95
93
let contract = self . contract
96
- var basicOptions = CodableTransaction . emptyTransaction
97
- basicOptions. from = from
98
- basicOptions. to = self . address
94
+ self . transaction. from = from
95
+ self . transaction. to = self . address
99
96
100
97
let tx = contract
101
98
. createWriteOperation ( " safeBatchTransferFrom " , parameters: [ originalOwner, to, ids, values, data] as [ AnyObject ] ) !
@@ -104,8 +101,7 @@ public class ERC1155: IERC1155 {
104
101
105
102
public func balanceOf( account: EthereumAddress , id: BigUInt ) async throws -> BigUInt {
106
103
let contract = self . contract
107
- var transactionOptions = CodableTransaction . emptyTransaction
108
- transactionOptions. callOnBlock = . latest
104
+ self . transaction. callOnBlock = . latest
109
105
let result = try await contract
110
106
. createReadOperation ( " balanceOf " , parameters: [ account, id] as [ AnyObject ] , extraData: Data ( ) ) !
111
107
. callContractMethod ( )
@@ -123,28 +119,25 @@ public class ERC1155: IERC1155 {
123
119
124
120
public func setApprovalForAll( from: EthereumAddress , operator user: EthereumAddress , approved: Bool , scope: Data ) throws -> WriteOperation {
125
121
let contract = self . contract
126
- var basicOptions = CodableTransaction . emptyTransaction
127
- basicOptions. from = from
128
- basicOptions. to = self . address
122
+ self . transaction. from = from
123
+ self . transaction. to = self . address
129
124
130
125
let tx = contract. createWriteOperation ( " setApprovalForAll " , parameters: [ user, approved, scope] as [ AnyObject ] ) !
131
126
return tx
132
127
}
133
128
134
129
public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress , scope: Data ) async throws -> Bool {
135
130
let contract = self . contract
136
- var basicOptions = CodableTransaction . emptyTransaction
137
- basicOptions. callOnBlock = . latest
131
+ self . transaction. callOnBlock = . latest
138
132
let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user, scope] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
139
133
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
140
134
return res
141
135
}
142
136
143
137
public func supportsInterface( interfaceID: String ) async throws -> Bool {
144
138
let contract = self . contract
145
- var transactionOptions = CodableTransaction . emptyTransaction
146
- transactionOptions. callOnBlock = . latest
147
- transactionOptions. gasLimitPolicy = . manual( 30000 )
139
+ self . transaction. callOnBlock = . latest
140
+ self . transaction. gasLimitPolicy = . manual( 30000 )
148
141
let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
149
142
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
150
143
return res
0 commit comments