@@ -73,9 +73,8 @@ public class ERC721x: IERC721x {
73
73
if self . _hasReadProperties {
74
74
return
75
75
}
76
- let contract = self . contract
77
76
guard contract. contract. address != nil else { return }
78
- self . transaction. callOnBlock = . latest
77
+ transaction. callOnBlock = . latest
79
78
80
79
guard let tokenIdPromise = try await contract. createReadOperation ( " tokenId " , parameters: [ ] as [ AnyObject ] , extraData: Data ( ) ) ? . callContractMethod ( ) else { return }
81
80
@@ -86,24 +85,21 @@ public class ERC721x: IERC721x {
86
85
}
87
86
88
87
public func getBalance( account: EthereumAddress ) async throws -> BigUInt {
89
- let contract = self . contract
90
- self . transaction. callOnBlock = . latest
88
+ transaction. callOnBlock = . latest
91
89
let result = try await contract. createReadOperation ( " balanceOf " , parameters: [ account] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
92
90
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
93
91
return res
94
92
}
95
93
96
94
public func getOwner( tokenId: BigUInt ) async throws -> EthereumAddress {
97
- let contract = self . contract
98
- self . transaction. callOnBlock = . latest
95
+ transaction. callOnBlock = . latest
99
96
let result = try await contract. createReadOperation ( " ownerOf " , parameters: [ tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
100
97
guard let res = result [ " 0 " ] as? EthereumAddress else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
101
98
return res
102
99
}
103
100
104
101
public func getApproved( tokenId: BigUInt ) async throws -> EthereumAddress {
105
- let contract = self . contract
106
- self . transaction. callOnBlock = . latest
102
+ transaction. callOnBlock = . latest
107
103
let result = try await contract. createReadOperation ( " getApproved " , parameters: [ tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
108
104
guard let res = result [ " 0 " ] as? EthereumAddress else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
109
105
return res
@@ -146,88 +142,77 @@ public class ERC721x: IERC721x {
146
142
}
147
143
148
144
public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress ) async throws -> Bool {
149
- let contract = self . contract
150
- self . transaction. callOnBlock = . latest
145
+ transaction. callOnBlock = . latest
151
146
let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
152
147
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
153
148
return res
154
149
}
155
150
156
151
public func supportsInterface( interfaceID: String ) async throws -> Bool {
157
- let contract = self . contract
158
- self . transaction. callOnBlock = . latest
152
+ transaction. callOnBlock = . latest
159
153
let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
160
154
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
161
155
return res
162
156
}
163
157
164
158
public func totalSupply( ) async throws -> BigUInt {
165
- let contract = self . contract
166
- self . transaction. callOnBlock = . latest
159
+ transaction. callOnBlock = . latest
167
160
let result = try await contract. createReadOperation ( " totalSupply " , parameters: [ AnyObject] ( ) , extraData: Data ( ) ) !. callContractMethod ( )
168
161
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
169
162
return res
170
163
}
171
164
172
165
public func tokenByIndex( index: BigUInt ) async throws -> BigUInt {
173
- let contract = self . contract
174
- self . transaction. callOnBlock = . latest
166
+ transaction. callOnBlock = . latest
175
167
let result = try await contract. createReadOperation ( " tokenByIndex " , parameters: [ index] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
176
168
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
177
169
return res
178
170
}
179
171
180
172
public func tokenOfOwnerByIndex( owner: EthereumAddress , index: BigUInt ) async throws -> BigUInt {
181
- let contract = self . contract
182
- self . transaction. callOnBlock = . latest
173
+ transaction. callOnBlock = . latest
183
174
let result = try await contract. createReadOperation ( " tokenOfOwnerByIndex " , parameters: [ owner, index] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
184
175
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
185
176
return res
186
177
}
187
178
188
179
public func name( ) async throws -> String {
189
- let contract = self . contract
190
- self . transaction. callOnBlock = . latest
180
+ transaction. callOnBlock = . latest
191
181
let result = try await contract. createReadOperation ( " name " , parameters: [ AnyObject] ( ) , extraData: Data ( ) ) !. callContractMethod ( )
192
182
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
193
183
return res
194
184
}
195
185
196
186
public func symbol( ) async throws -> String {
197
- let contract = self . contract
198
- self . transaction. callOnBlock = . latest
187
+ transaction. callOnBlock = . latest
199
188
let result = try await contract. createReadOperation ( " symbol " , parameters: [ AnyObject] ( ) , extraData: Data ( ) ) !. callContractMethod ( )
200
189
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
201
190
return res
202
191
}
203
192
204
193
public func tokenURI( tokenId: BigUInt ) async throws -> String {
205
- let contract = self . contract
206
- self . transaction. callOnBlock = . latest
194
+ transaction. callOnBlock = . latest
207
195
let result = try await contract. createReadOperation ( " tokenURI " , parameters: [ tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
208
196
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
209
197
return res
210
198
}
211
199
212
200
func implementsERC721X( ) async throws -> Bool {
213
- let contract = self . contract
214
- self . transaction. callOnBlock = . latest
201
+ transaction. callOnBlock = . latest
215
202
let result = try await contract. createReadOperation ( " implementsERC721X " , parameters: [ ] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
216
203
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
217
204
return res
218
205
}
219
206
220
207
func getBalance( account: EthereumAddress , tokenId: BigUInt ) async throws -> BigUInt {
221
- let contract = self . contract
222
- self . transaction. callOnBlock = . latest
208
+ transaction. callOnBlock = . latest
223
209
let result = try await contract. createReadOperation ( " balanceOf " , parameters: [ account, tokenId] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
224
210
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
225
211
return res
226
212
}
227
213
228
214
func tokensOwned( account: EthereumAddress ) async throws -> ( [ BigUInt ] , [ BigUInt ] ) {
229
- let contract = self . contract
230
- self . transaction. callOnBlock = . latest
215
+ transaction. callOnBlock = . latest
231
216
let result = try await contract. createReadOperation ( " tokensOwned " , parameters: [ account] as [ AnyObject ] , extraData: Data ( ) ) !. callContractMethod ( )
232
217
guard let res = result [ " 0 " ] as? ( [ BigUInt ] , [ BigUInt ] ) else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
233
218
return res
0 commit comments