Commit 5af56ef 1 parent fa43d40 commit 5af56ef Copy full SHA for 5af56ef
File tree 2 files changed +16
-0
lines changed
Tests/ENSKitTests/EthereumContractTests
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ public struct ENSKit {
33
33
)
34
34
}
35
35
36
+ public func resolver( addr: String ) async throws -> ENSResolver ? {
37
+ let reversedDomain = addr. lowercased ( ) . replacingOccurrences ( of: " 0x " , with: " " ) + " .addr.reverse "
38
+ return try await resolver ( name: reversedDomain)
39
+ }
40
+
36
41
public func contenthash( name: String ) async -> URL ? {
37
42
if let resolver = try ? await resolver ( name: name) ,
38
43
let contenthash = try ? await resolver. contenthash ( ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,17 @@ final class RegistryContractTests: XCTestCase {
15
15
}
16
16
}
17
17
18
+ func testReverseResolver( ) async throws {
19
+ let contract = RegistryContract ( client: client)
20
+ let vitalik = Namehash . namehash ( " d8da6bf26964af9d7eed9e03e53415d37aa96045.addr.reverse " )
21
+ let result = try await contract. resolver ( namehash: vitalik)
22
+ if let ethResolver = result {
23
+ XCTAssertEqual ( ethResolver, try ! Address ( " 0x5fbb459c49bb06083c33109fa4f14810ec2cf358 " ) )
24
+ } else {
25
+ XCTFail ( )
26
+ }
27
+ }
28
+
18
29
func testResolverNoResult( ) async throws {
19
30
let contract = RegistryContract ( client: client)
20
31
let unsupported = Namehash . namehash ( " unsupportedENS " )
You can’t perform that action at this time.
0 commit comments