@@ -35,7 +35,7 @@ public class ERC1155: IERC1155 {
3535 private var _tokenId : BigUInt ? = nil
3636 private var _hasReadProperties : Bool = false
3737
38- public var transactionOptions : CodableTransaction
38+ public var transaction : CodableTransaction
3939 public var web3 : web3
4040 public var provider : Web3Provider
4141 public var address : EthereumAddress
@@ -51,8 +51,8 @@ public class ERC1155: IERC1155 {
5151 self . web3 = web3
5252 self . provider = provider
5353 self . address = address
54- self . transactionOptions = transaction
55- self . transactionOptions . to = address
54+ self . transaction = transaction
55+ self . transaction . to = address
5656 self . abi = abi
5757 }
5858
@@ -70,8 +70,7 @@ public class ERC1155: IERC1155 {
7070 }
7171 let contract = self . contract
7272 guard contract. contract. address != nil else { return }
73- var transactionOptions = CodableTransaction . emptyTransaction
74- transactionOptions. callOnBlock = . latest
73+ self . transaction. callOnBlock = . latest
7574
7675 guard let tokenIdPromise = try await contract. createReadOperation ( " id " , parameters: [ ] as [ AnyObject ] , extraData: Data ( ) ) ? . callContractMethod ( ) else { return }
7776
@@ -83,19 +82,17 @@ public class ERC1155: IERC1155 {
8382
8483 public func safeTransferFrom( from: EthereumAddress , to: EthereumAddress , originalOwner: EthereumAddress , id: BigUInt , value: BigUInt , data: [ UInt8 ] ) throws -> WriteOperation {
8584 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
8987
9088 let tx = contract. createWriteOperation ( " safeTransferFrom " , parameters: [ originalOwner, to, id, value, data] as [ AnyObject ] ) !
9189 return tx
9290 }
9391
9492 public func safeBatchTransferFrom( from: EthereumAddress , to: EthereumAddress , originalOwner: EthereumAddress , ids: [ BigUInt ] , values: [ BigUInt ] , data: [ UInt8 ] ) throws -> WriteOperation {
9593 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
9996
10097 let tx = contract
10198 . createWriteOperation ( " safeBatchTransferFrom " , parameters: [ originalOwner, to, ids, values, data] as [ AnyObject ] ) !
@@ -104,8 +101,7 @@ public class ERC1155: IERC1155 {
104101
105102 public func balanceOf( account: EthereumAddress , id: BigUInt ) async throws -> BigUInt {
106103 let contract = self . contract
107- var transactionOptions = CodableTransaction . emptyTransaction
108- transactionOptions. callOnBlock = . latest
104+ self . transaction. callOnBlock = . latest
109105 let result = try await contract
110106 . createReadOperation ( " balanceOf " , parameters: [ account, id] as [ AnyObject ] , extraData: Data ( ) ) !
111107 . callContractMethod ( )
@@ -123,28 +119,25 @@ public class ERC1155: IERC1155 {
123119
124120 public func setApprovalForAll( from: EthereumAddress , operator user: EthereumAddress , approved: Bool , scope: Data ) throws -> WriteOperation {
125121 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
129124
130125 let tx = contract. createWriteOperation ( " setApprovalForAll " , parameters: [ user, approved, scope] as [ AnyObject ] ) !
131126 return tx
132127 }
133128
134129 public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress , scope: Data ) async throws -> Bool {
135130 let contract = self . contract
136- var basicOptions = CodableTransaction . emptyTransaction
137- basicOptions. callOnBlock = . latest
131+ self . transaction. callOnBlock = . latest
138132 let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user, scope] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
139133 guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
140134 return res
141135 }
142136
143137 public func supportsInterface( interfaceID: String ) async throws -> Bool {
144138 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 )
148141 let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
149142 guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
150143 return res
0 commit comments