@@ -75,7 +75,7 @@ public struct ENS {
75
75
}
76
76
77
77
/*
78
- TODO: -
78
+ TODO:
79
79
*/
80
80
//
81
81
// public func setAddress(domain: String, address: EthereumAddress, options: Web3Options? = nil) {
@@ -138,12 +138,12 @@ public struct ResolverENS {
138
138
self . resolverAddress = resolverAddress
139
139
}
140
140
141
- mutating func supportsInterface( interfaceID: Data ) -> Result < Bool , Web3Error > {
141
+ mutating public func supportsInterface( interfaceID: Data ) -> Result < Bool , Web3Error > {
142
142
return supportsInterface ( interfaceID: interfaceID. toHexString ( ) )
143
143
}
144
144
145
145
//MARK: - returns true if the contract supports given interface
146
- mutating func supportsInterface( interfaceID: String ) -> Result < Bool , Web3Error > {
146
+ mutating public func supportsInterface( interfaceID: String ) -> Result < Bool , Web3Error > {
147
147
let options = Web3Options . defaultOptions ( )
148
148
guard let transaction = self . resolverContract. method ( " supportsInterface " , parameters: [ interfaceID as AnyObject ] , options: options) else { return Result . failure ( Web3Error . transactionSerializationError) }
149
149
let result = transaction. call ( options: options)
@@ -157,7 +157,7 @@ public struct ResolverENS {
157
157
}
158
158
159
159
//MARK: - returns address for the given domain at given resolver
160
- mutating func addr( forDomain domain: String ) -> Result < EthereumAddress , Web3Error > {
160
+ mutating public func addr( forDomain domain: String ) -> Result < EthereumAddress , Web3Error > {
161
161
guard let nameHash = NameHash . nameHash ( domain) else { return Result . failure ( Web3Error . dataError) }
162
162
let options = Web3Options . defaultOptions ( )
163
163
guard let transaction = self . resolverContract. method ( " addr " , parameters: [ nameHash as AnyObject ] , options: options) else { return Result . failure ( Web3Error . dataError) }
@@ -171,7 +171,7 @@ public struct ResolverENS {
171
171
}
172
172
173
173
//MARK: - returns corresponding ENS to the requested node
174
- mutating func name( node: String ) -> Result < String , Web3Error > {
174
+ mutating public func name( node: String ) -> Result < String , Web3Error > {
175
175
let options = Web3Options . defaultOptions ( )
176
176
guard let transaction = self . resolverContract. method ( " name " , parameters: [ node. lowercased ( ) as AnyObject ] , options: options) else { return Result . failure ( Web3Error . transactionSerializationError) }
177
177
let result = transaction. call ( options: options)
@@ -185,7 +185,7 @@ public struct ResolverENS {
185
185
}
186
186
187
187
//MARK: - returns ABI in the requested encodings
188
- mutating func ABI( node: String , contentType: BigUInt ) -> Result < ( BigUInt , Data ) , Web3Error > {
188
+ mutating public func ABI( node: String , contentType: BigUInt ) -> Result < ( BigUInt , Data ) , Web3Error > {
189
189
let options = Web3Options . defaultOptions ( )
190
190
guard let transaction = self . resolverContract. method ( " ABI " , parameters: [ node, contentType] as [ AnyObject ] , options: options) else { return Result . failure ( Web3Error . transactionSerializationError) }
191
191
let result = transaction. call ( options: options)
@@ -199,6 +199,23 @@ public struct ResolverENS {
199
199
}
200
200
}
201
201
202
- //TODO: - func pubkey()
202
+ mutating public func pubkey( node: String ) -> Result < Point , Web3Error > {
203
+ let options = Web3Options . defaultOptions ( )
204
+ guard let transaction = self . resolverContract. method ( " pubkey " , parameters: [ node as AnyObject ] , options: options) else { return Result . failure ( Web3Error . transactionSerializationError) }
205
+ let result = transaction. call ( options: options)
206
+ switch result {
207
+ case . success( let value) :
208
+ guard let x = value [ " x " ] as? String else { return Result . failure ( Web3Error . dataError) }
209
+ guard let y = value [ " y " ] as? String else { return Result . failure ( Web3Error . dataError) }
210
+ return Result ( Point ( x: x, y: y) )
211
+ case . failure( let error) :
212
+ return Result . failure ( error)
213
+ }
214
+ }
215
+ }
216
+
217
+ public struct Point {
218
+ let x : String
219
+ let y : String
203
220
}
204
221
0 commit comments