Skip to content

Commit 96b6462

Browse files
committed
Clean up
1 parent 8f05fe3 commit 96b6462

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public class ERC721: IERC721 {
8888
if self._hasReadProperties {
8989
return
9090
}
91-
let contract = self.contract
9291
guard contract.contract.address != nil else {return}
9392
self.transaction.callOnBlock = .latest
9493

@@ -103,24 +102,22 @@ public class ERC721: IERC721 {
103102
}
104103

105104
public func getBalance(account: EthereumAddress) async throws -> BigUInt {
106-
let contract = self.contract
107-
self.transaction.callOnBlock = .latest
105+
transaction.callOnBlock = .latest
108106
let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod()
109107
guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
110108
return res
111109
}
112110

113111
public func getOwner(tokenId: BigUInt) async throws -> EthereumAddress {
114-
let contract = self.contract
115-
self.transaction.callOnBlock = .latest
112+
transaction.callOnBlock = .latest
116113
let result = try await contract.createReadOperation("ownerOf", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod()
117114
guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
118115
return res
119116
}
120117

121118
public func getApproved(tokenId: BigUInt) async throws -> EthereumAddress {
122119
let contract = self.contract
123-
self.transaction.callOnBlock = .latest
120+
transaction.callOnBlock = .latest
124121
let result = try await contract.createReadOperation("getApproved", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod()
125122
guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
126123
return res
@@ -163,15 +160,13 @@ public class ERC721: IERC721 {
163160
}
164161

165162
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
168164
let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user] as [AnyObject], extraData: Data() )!.callContractMethod()
169165
guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
170166
return res
171167
}
172168

173169
public func supportsInterface(interfaceID: String) async throws -> Bool {
174-
let contract = self.contract
175170
transaction.callOnBlock = .latest
176171
let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod()
177172
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 {
197192
extension ERC721: IERC721Enumerable {
198193

199194
public func totalSupply() async throws -> BigUInt {
200-
let contract = self.contract
201-
self.transaction.callOnBlock = .latest
195+
transaction.callOnBlock = .latest
202196
let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod()
203197
guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
204198
return res
205199
}
206200

207201
public func tokenByIndex(index: BigUInt) async throws -> BigUInt {
208-
let contract = self.contract
209-
self.transaction.callOnBlock = .latest
202+
transaction.callOnBlock = .latest
210203
let result = try await contract.createReadOperation("tokenByIndex", parameters: [index] as [AnyObject], extraData: Data() )!.callContractMethod()
211204
guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
212205
return res
213206
}
214207

215208
public func tokenOfOwnerByIndex(owner: EthereumAddress, index: BigUInt) async throws -> BigUInt {
216-
let contract = self.contract
217-
self.transaction.callOnBlock = .latest
209+
transaction.callOnBlock = .latest
218210
let result = try await contract.createReadOperation("tokenOfOwnerByIndex", parameters: [owner, index] as [AnyObject], extraData: Data() )!.callContractMethod()
219211
guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
220212
return res
@@ -228,24 +220,21 @@ extension ERC721: IERC721Enumerable {
228220
extension ERC721: IERC721Metadata {
229221

230222
public func name() async throws -> String {
231-
let contract = self.contract
232-
self.transaction.callOnBlock = .latest
223+
transaction.callOnBlock = .latest
233224
let result = try await contract.createReadOperation("name", parameters: [AnyObject](), extraData: Data() )!.callContractMethod()
234225
guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
235226
return res
236227
}
237228

238229
public func symbol() async throws -> String {
239-
let contract = self.contract
240-
self.transaction.callOnBlock = .latest
230+
transaction.callOnBlock = .latest
241231
let result = try await contract.createReadOperation("symbol", parameters: [AnyObject](), extraData: Data() )!.callContractMethod()
242232
guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
243233
return res
244234
}
245235

246236
public func tokenURI(tokenId: BigUInt) async throws -> String {
247-
let contract = self.contract
248-
self.transaction.callOnBlock = .latest
237+
transaction.callOnBlock = .latest
249238
let result = try await contract.createReadOperation("tokenURI", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod()
250239
guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
251240
return res

0 commit comments

Comments
 (0)