@@ -49,7 +49,7 @@ protocol IERC721Enumerable {
49
49
50
50
// This namespace contains functions to work with ERC721 tokens.
51
51
// can be imperatively read and saved
52
- public class ERC721 : IERC721 , IERC721Enumerable , IERC721Metadata {
52
+ public class ERC721 : IERC721 {
53
53
54
54
@available ( * , deprecated, renamed: " transactionOptions " )
55
55
public var options : Web3Options = . init( )
@@ -134,24 +134,6 @@ public class ERC721: IERC721, IERC721Enumerable, IERC721Metadata {
134
134
return res
135
135
}
136
136
137
- public func tokenByIndex( index: BigUInt ) throws -> BigUInt {
138
- let contract = self . contract
139
- var transactionOptions = TransactionOptions ( )
140
- transactionOptions. callOnBlock = . latest
141
- let result = try contract. read ( " tokenByIndex " , parameters: [ index] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. call ( transactionOptions: transactionOptions)
142
- guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
143
- return res
144
- }
145
-
146
- public func tokenOfOwnerByIndex( owner: EthereumAddress , index: BigUInt ) throws -> BigUInt {
147
- let contract = self . contract
148
- var transactionOptions = TransactionOptions ( )
149
- transactionOptions. callOnBlock = . latest
150
- let result = try contract. read ( " tokenOfOwnerByIndex " , parameters: [ owner, index] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. call ( transactionOptions: transactionOptions)
151
- guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
152
- return res
153
- }
154
-
155
137
public func transfer( from: EthereumAddress , to: EthereumAddress , tokenId: BigUInt ) throws -> WriteTransaction {
156
138
let contract = self . contract
157
139
var basicOptions = TransactionOptions ( )
@@ -199,6 +181,10 @@ public class ERC721: IERC721, IERC721Enumerable, IERC721Metadata {
199
181
return res
200
182
}
201
183
184
+ }
185
+
186
+ extension ERC721 : IERC721Enumerable {
187
+
202
188
public func totalSupply( ) throws -> BigUInt {
203
189
let contract = self . contract
204
190
var transactionOptions = TransactionOptions ( )
@@ -208,6 +194,28 @@ public class ERC721: IERC721, IERC721Enumerable, IERC721Metadata {
208
194
return res
209
195
}
210
196
197
+ public func tokenByIndex( index: BigUInt ) throws -> BigUInt {
198
+ let contract = self . contract
199
+ var transactionOptions = TransactionOptions ( )
200
+ transactionOptions. callOnBlock = . latest
201
+ let result = try contract. read ( " tokenByIndex " , parameters: [ index] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. call ( transactionOptions: transactionOptions)
202
+ guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
203
+ return res
204
+ }
205
+
206
+ public func tokenOfOwnerByIndex( owner: EthereumAddress , index: BigUInt ) throws -> BigUInt {
207
+ let contract = self . contract
208
+ var transactionOptions = TransactionOptions ( )
209
+ transactionOptions. callOnBlock = . latest
210
+ let result = try contract. read ( " tokenOfOwnerByIndex " , parameters: [ owner, index] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. call ( transactionOptions: transactionOptions)
211
+ guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
212
+ return res
213
+ }
214
+
215
+ }
216
+
217
+ extension ERC721 : IERC721Metadata {
218
+
211
219
public func name( ) throws -> String {
212
220
let contract = self . contract
213
221
var transactionOptions = TransactionOptions ( )
@@ -234,4 +242,5 @@ public class ERC721: IERC721, IERC721Enumerable, IERC721Metadata {
234
242
guard let res = result [ " 0 " ] as? String else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
235
243
return res
236
244
}
245
+
237
246
}
0 commit comments