@@ -88,7 +88,6 @@ public class ERC721: IERC721 {
88
88
if self . _hasReadProperties {
89
89
return
90
90
}
91
- let contract = self . contract
92
91
guard contract. contract. address != nil else { return }
93
92
self . transaction. callOnBlock = . latest
94
93
@@ -103,24 +102,22 @@ public class ERC721: IERC721 {
103
102
}
104
103
105
104
public func getBalance( account: EthereumAddress ) async throws -> BigUInt {
106
- let contract = self . contract
107
- self . transaction. callOnBlock = . latest
105
+ transaction. callOnBlock = . latest
108
106
let result = try await contract. createReadOperation ( " balanceOf " , parameters: [ account] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
109
107
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
110
108
return res
111
109
}
112
110
113
111
public func getOwner( tokenId: BigUInt ) async throws -> EthereumAddress {
114
- let contract = self . contract
115
- self . transaction. callOnBlock = . latest
112
+ transaction. callOnBlock = . latest
116
113
let result = try await contract. createReadOperation ( " ownerOf " , parameters: [ tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
117
114
guard let res = result [ " 0 " ] as? EthereumAddress else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
118
115
return res
119
116
}
120
117
121
118
public func getApproved( tokenId: BigUInt ) async throws -> EthereumAddress {
122
119
let contract = self . contract
123
- self . transaction. callOnBlock = . latest
120
+ transaction. callOnBlock = . latest
124
121
let result = try await contract. createReadOperation ( " getApproved " , parameters: [ tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
125
122
guard let res = result [ " 0 " ] as? EthereumAddress else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
126
123
return res
@@ -163,15 +160,13 @@ public class ERC721: IERC721 {
163
160
}
164
161
165
162
public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress ) async throws -> Bool {
166
- let contract = self . contract
167
- self . transaction. callOnBlock = . latest
163
+ transaction. callOnBlock = . latest
168
164
let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
169
165
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
170
166
return res
171
167
}
172
168
173
169
public func supportsInterface( interfaceID: String ) async throws -> Bool {
174
- let contract = self . contract
175
170
transaction. callOnBlock = . latest
176
171
let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
177
172
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
@@ -197,24 +192,21 @@ extension ERC721 {
197
192
extension ERC721 : IERC721Enumerable {
198
193
199
194
public func totalSupply( ) async throws -> BigUInt {
200
- let contract = self . contract
201
- self . transaction. callOnBlock = . latest
195
+ transaction. callOnBlock = . latest
202
196
let result = try await contract. createReadOperation ( " totalSupply " , parameters: [ AnyObject] ( ) , extraData: Data ( ) ) !. callContractMethod ( )
203
197
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
204
198
return res
205
199
}
206
200
207
201
public func tokenByIndex( index: BigUInt ) async throws -> BigUInt {
208
- let contract = self . contract
209
- self . transaction. callOnBlock = . latest
202
+ transaction. callOnBlock = . latest
210
203
let result = try await contract. createReadOperation ( " tokenByIndex " , parameters: [ index] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
211
204
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
212
205
return res
213
206
}
214
207
215
208
public func tokenOfOwnerByIndex( owner: EthereumAddress , index: BigUInt ) async throws -> BigUInt {
216
- let contract = self . contract
217
- self . transaction. callOnBlock = . latest
209
+ transaction. callOnBlock = . latest
218
210
let result = try await contract. createReadOperation ( " tokenOfOwnerByIndex " , parameters: [ owner, index] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
219
211
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
220
212
return res
@@ -228,24 +220,21 @@ extension ERC721: IERC721Enumerable {
228
220
extension ERC721 : IERC721Metadata {
229
221
230
222
public func name( ) async throws -> String {
231
- let contract = self . contract
232
- self . transaction. callOnBlock = . latest
223
+ transaction. callOnBlock = . latest
233
224
let result = try await contract. createReadOperation ( " name " , parameters: [ AnyObject] ( ) , extraData: Data ( ) ) !. callContractMethod ( )
234
225
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
235
226
return res
236
227
}
237
228
238
229
public func symbol( ) async throws -> String {
239
- let contract = self . contract
240
- self . transaction. callOnBlock = . latest
230
+ transaction. callOnBlock = . latest
241
231
let result = try await contract. createReadOperation ( " symbol " , parameters: [ AnyObject] ( ) , extraData: Data ( ) ) !. callContractMethod ( )
242
232
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
243
233
return res
244
234
}
245
235
246
236
public func tokenURI( tokenId: BigUInt ) async throws -> String {
247
- let contract = self . contract
248
- self . transaction. callOnBlock = . latest
237
+ transaction. callOnBlock = . latest
249
238
let result = try await contract. createReadOperation ( " tokenURI " , parameters: [ tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
250
239
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
251
240
return res
0 commit comments