@ensdomains/ensjs 3.0.0-alpha.1 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cjs/GqlManager.d.ts +3 -0
- package/dist/cjs/GqlManager.js +62 -2
- package/dist/cjs/contracts/baseRegistrar.d.ts +1 -1
- package/dist/cjs/contracts/index.d.ts +3 -3
- package/dist/cjs/contracts/multicall.d.ts +1 -1
- package/dist/cjs/contracts/registry.d.ts +1 -1
- package/dist/cjs/functions/burnFuses.d.ts +3 -2
- package/dist/cjs/functions/burnFuses.js +4 -8
- package/dist/cjs/functions/createSubname.d.ts +3 -5
- package/dist/cjs/functions/createSubname.js +7 -8
- package/dist/cjs/functions/deleteSubname.d.ts +3 -3
- package/dist/cjs/functions/deleteSubname.js +6 -2
- package/dist/cjs/functions/getDNSOwner.d.ts +7 -0
- package/dist/cjs/functions/getDNSOwner.js +81 -0
- package/dist/cjs/functions/getExpiry.d.ts +9 -2
- package/dist/cjs/functions/getExpiry.js +52 -7
- package/dist/cjs/functions/getFuses.d.ts +2 -3
- package/dist/cjs/functions/getFuses.js +6 -14
- package/dist/cjs/functions/getHistory.d.ts +0 -30
- package/dist/cjs/functions/getHistory.js +3 -99
- package/dist/cjs/functions/getName.d.ts +2 -2
- package/dist/cjs/functions/getName.js +1 -1
- package/dist/cjs/functions/getOwner.js +7 -6
- package/dist/cjs/functions/getProfile.d.ts +4 -1
- package/dist/cjs/functions/getProfile.js +102 -24
- package/dist/cjs/functions/getRecords.d.ts +1 -0
- package/dist/cjs/functions/getSpecificRecord.js +30 -6
- package/dist/cjs/functions/getSubnames.d.ts +1 -1
- package/dist/cjs/functions/getSubnames.js +7 -7
- package/dist/cjs/functions/setName.d.ts +4 -3
- package/dist/cjs/functions/setName.js +5 -10
- package/dist/cjs/functions/setRecord.d.ts +18 -0
- package/dist/cjs/functions/setRecord.js +27 -0
- package/dist/cjs/functions/setRecords.d.ts +4 -2
- package/dist/cjs/functions/setRecords.js +14 -12
- package/dist/cjs/functions/setResolver.d.ts +4 -4
- package/dist/cjs/functions/setResolver.js +6 -12
- package/dist/cjs/functions/transferName.d.ts +4 -3
- package/dist/cjs/functions/transferName.js +9 -13
- package/dist/cjs/functions/transferSubname.d.ts +13 -3
- package/dist/cjs/functions/transferSubname.js +7 -8
- package/dist/cjs/functions/unwrapName.d.ts +4 -3
- package/dist/cjs/functions/unwrapName.js +5 -9
- package/dist/cjs/functions/wrapName.d.ts +7 -3
- package/dist/cjs/functions/wrapName.js +38 -36
- package/dist/cjs/generated/BaseRegistrarImplementation.d.ts +222 -201
- package/dist/cjs/generated/DNSRegistrar.d.ts +68 -64
- package/dist/cjs/generated/DNSSECImpl.d.ts +111 -111
- package/dist/cjs/generated/DefaultReverseResolver.d.ts +17 -17
- package/dist/cjs/generated/ENSRegistry.d.ts +126 -111
- package/dist/cjs/generated/ETHRegistrarController.d.ts +111 -109
- package/dist/cjs/generated/Multicall.d.ts +60 -60
- package/dist/cjs/generated/NameWrapper.d.ts +493 -354
- package/dist/cjs/generated/P256SHA256Algorithm.d.ts +11 -7
- package/dist/cjs/generated/PublicResolver.d.ts +259 -235
- package/dist/cjs/generated/RSASHA1Algorithm.d.ts +11 -7
- package/dist/cjs/generated/RSASHA256Algorithm.d.ts +11 -7
- package/dist/cjs/generated/ReverseRegistrar.d.ts +112 -103
- package/dist/cjs/generated/Root.d.ts +77 -77
- package/dist/cjs/generated/SHA1Digest.d.ts +7 -7
- package/dist/cjs/generated/SHA1NSEC3Digest.d.ts +11 -7
- package/dist/cjs/generated/SHA256Digest.d.ts +7 -7
- package/dist/cjs/generated/StaticMetadataService.d.ts +7 -7
- package/dist/cjs/generated/TLDPublicSuffixList.d.ts +7 -7
- package/dist/cjs/generated/UniversalResolver.d.ts +31 -31
- package/dist/cjs/generated/common.d.ts +1 -0
- package/dist/cjs/generated/factories/DNSRegistrar__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/DNSRegistrar__factory.js +3 -26
- package/dist/cjs/generated/factories/DNSSECImpl__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/DNSSECImpl__factory.js +3 -26
- package/dist/cjs/generated/factories/ETHRegistrarController__factory.js +14 -4
- package/dist/cjs/generated/factories/NameWrapper__factory.js +210 -79
- package/dist/cjs/generated/factories/P256SHA256Algorithm__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/P256SHA256Algorithm__factory.js +3 -26
- package/dist/cjs/generated/factories/RSASHA1Algorithm__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/RSASHA1Algorithm__factory.js +3 -26
- package/dist/cjs/generated/factories/RSASHA256Algorithm__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/RSASHA256Algorithm__factory.js +3 -26
- package/dist/cjs/generated/factories/SHA1Digest__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/SHA1Digest__factory.js +3 -26
- package/dist/cjs/generated/factories/SHA1NSEC3Digest__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/SHA1NSEC3Digest__factory.js +3 -26
- package/dist/cjs/generated/factories/SHA256Digest__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/SHA256Digest__factory.js +3 -26
- package/dist/cjs/generated/factories/TLDPublicSuffixList__factory.d.ts +3 -15
- package/dist/cjs/generated/factories/TLDPublicSuffixList__factory.js +3 -26
- package/dist/cjs/generated/factories/index.d.ts +14 -0
- package/dist/cjs/generated/factories/index.js +29 -1
- package/dist/cjs/generated/index.d.ts +29 -1
- package/dist/cjs/generated/index.js +31 -3
- package/dist/cjs/index.d.ts +62 -84
- package/dist/cjs/index.js +44 -21
- package/dist/cjs/utils/labels.js +5 -4
- package/dist/cjs/utils/makeHashIndexes.js +2 -2
- package/dist/cjs/utils/normalise.d.ts +1 -0
- package/dist/cjs/utils/normalise.js +27 -1
- package/dist/cjs/utils/recordHelpers.d.ts +3 -0
- package/dist/cjs/utils/recordHelpers.js +42 -15
- package/dist/cjs/utils/registerHelpers.js +3 -4
- package/dist/cjs/utils/wrapperExpiry.d.ts +5 -0
- package/dist/cjs/utils/wrapperExpiry.js +30 -0
- package/dist/cjs/utils/writeTx.d.ts +4 -0
- package/dist/cjs/utils/writeTx.js +3 -0
- package/dist/esm/GqlManager.d.ts +3 -0
- package/dist/esm/GqlManager.js +58 -2
- package/dist/esm/contracts/baseRegistrar.d.ts +1 -1
- package/dist/esm/contracts/index.d.ts +3 -3
- package/dist/esm/contracts/multicall.d.ts +1 -1
- package/dist/esm/contracts/registry.d.ts +1 -1
- package/dist/esm/functions/burnFuses.d.ts +3 -2
- package/dist/esm/functions/burnFuses.js +4 -8
- package/dist/esm/functions/createSubname.d.ts +3 -5
- package/dist/esm/functions/createSubname.js +7 -8
- package/dist/esm/functions/deleteSubname.d.ts +3 -3
- package/dist/esm/functions/deleteSubname.js +6 -2
- package/dist/esm/functions/getDNSOwner.d.ts +7 -0
- package/dist/esm/functions/getDNSOwner.js +51 -0
- package/dist/esm/functions/getExpiry.d.ts +9 -2
- package/dist/esm/functions/getExpiry.js +52 -7
- package/dist/esm/functions/getFuses.d.ts +2 -3
- package/dist/esm/functions/getFuses.js +7 -15
- package/dist/esm/functions/getHistory.d.ts +0 -30
- package/dist/esm/functions/getHistory.js +2 -96
- package/dist/esm/functions/getName.d.ts +2 -2
- package/dist/esm/functions/getName.js +1 -1
- package/dist/esm/functions/getOwner.js +7 -6
- package/dist/esm/functions/getProfile.d.ts +4 -1
- package/dist/esm/functions/getProfile.js +102 -24
- package/dist/esm/functions/getRecords.d.ts +1 -0
- package/dist/esm/functions/getSpecificRecord.js +30 -6
- package/dist/esm/functions/getSubnames.d.ts +1 -1
- package/dist/esm/functions/getSubnames.js +4 -4
- package/dist/esm/functions/setName.d.ts +4 -3
- package/dist/esm/functions/setName.js +5 -10
- package/dist/esm/functions/setRecord.d.ts +18 -0
- package/dist/esm/functions/setRecord.js +24 -0
- package/dist/esm/functions/setRecords.d.ts +4 -2
- package/dist/esm/functions/setRecords.js +14 -12
- package/dist/esm/functions/setResolver.d.ts +4 -4
- package/dist/esm/functions/setResolver.js +6 -12
- package/dist/esm/functions/transferName.d.ts +4 -3
- package/dist/esm/functions/transferName.js +9 -13
- package/dist/esm/functions/transferSubname.d.ts +13 -3
- package/dist/esm/functions/transferSubname.js +7 -8
- package/dist/esm/functions/unwrapName.d.ts +4 -3
- package/dist/esm/functions/unwrapName.js +5 -9
- package/dist/esm/functions/wrapName.d.ts +7 -3
- package/dist/esm/functions/wrapName.js +38 -36
- package/dist/esm/generated/BaseRegistrarImplementation.d.ts +222 -201
- package/dist/esm/generated/DNSRegistrar.d.ts +68 -64
- package/dist/esm/generated/DNSSECImpl.d.ts +111 -111
- package/dist/esm/generated/DefaultReverseResolver.d.ts +17 -17
- package/dist/esm/generated/ENSRegistry.d.ts +126 -111
- package/dist/esm/generated/ETHRegistrarController.d.ts +111 -109
- package/dist/esm/generated/Multicall.d.ts +60 -60
- package/dist/esm/generated/NameWrapper.d.ts +493 -354
- package/dist/esm/generated/P256SHA256Algorithm.d.ts +11 -7
- package/dist/esm/generated/PublicResolver.d.ts +259 -235
- package/dist/esm/generated/RSASHA1Algorithm.d.ts +11 -7
- package/dist/esm/generated/RSASHA256Algorithm.d.ts +11 -7
- package/dist/esm/generated/ReverseRegistrar.d.ts +112 -103
- package/dist/esm/generated/Root.d.ts +77 -77
- package/dist/esm/generated/SHA1Digest.d.ts +7 -7
- package/dist/esm/generated/SHA1NSEC3Digest.d.ts +11 -7
- package/dist/esm/generated/SHA256Digest.d.ts +7 -7
- package/dist/esm/generated/StaticMetadataService.d.ts +7 -7
- package/dist/esm/generated/TLDPublicSuffixList.d.ts +7 -7
- package/dist/esm/generated/UniversalResolver.d.ts +31 -31
- package/dist/esm/generated/common.d.ts +1 -0
- package/dist/esm/generated/factories/DNSRegistrar__factory.d.ts +3 -15
- package/dist/esm/generated/factories/DNSRegistrar__factory.js +2 -25
- package/dist/esm/generated/factories/DNSSECImpl__factory.d.ts +3 -15
- package/dist/esm/generated/factories/DNSSECImpl__factory.js +2 -25
- package/dist/esm/generated/factories/ETHRegistrarController__factory.js +14 -4
- package/dist/esm/generated/factories/NameWrapper__factory.js +210 -79
- package/dist/esm/generated/factories/P256SHA256Algorithm__factory.d.ts +3 -15
- package/dist/esm/generated/factories/P256SHA256Algorithm__factory.js +2 -25
- package/dist/esm/generated/factories/RSASHA1Algorithm__factory.d.ts +3 -15
- package/dist/esm/generated/factories/RSASHA1Algorithm__factory.js +2 -25
- package/dist/esm/generated/factories/RSASHA256Algorithm__factory.d.ts +3 -15
- package/dist/esm/generated/factories/RSASHA256Algorithm__factory.js +2 -25
- package/dist/esm/generated/factories/SHA1Digest__factory.d.ts +3 -15
- package/dist/esm/generated/factories/SHA1Digest__factory.js +2 -25
- package/dist/esm/generated/factories/SHA1NSEC3Digest__factory.d.ts +3 -15
- package/dist/esm/generated/factories/SHA1NSEC3Digest__factory.js +2 -25
- package/dist/esm/generated/factories/SHA256Digest__factory.d.ts +3 -15
- package/dist/esm/generated/factories/SHA256Digest__factory.js +2 -25
- package/dist/esm/generated/factories/TLDPublicSuffixList__factory.d.ts +3 -15
- package/dist/esm/generated/factories/TLDPublicSuffixList__factory.js +2 -25
- package/dist/esm/generated/factories/index.d.ts +14 -0
- package/dist/esm/generated/factories/index.js +14 -0
- package/dist/esm/generated/index.d.ts +29 -1
- package/dist/esm/generated/index.js +15 -1
- package/dist/esm/index.d.ts +62 -84
- package/dist/esm/index.js +44 -21
- package/dist/esm/utils/labels.js +5 -4
- package/dist/esm/utils/makeHashIndexes.js +2 -2
- package/dist/esm/utils/normalise.d.ts +1 -0
- package/dist/esm/utils/normalise.js +25 -0
- package/dist/esm/utils/recordHelpers.d.ts +3 -0
- package/dist/esm/utils/recordHelpers.js +40 -14
- package/dist/esm/utils/registerHelpers.js +3 -4
- package/dist/esm/utils/wrapperExpiry.d.ts +5 -0
- package/dist/esm/utils/wrapperExpiry.js +26 -0
- package/dist/esm/utils/writeTx.d.ts +4 -0
- package/dist/esm/utils/writeTx.js +1 -0
- package/package.json +24 -14
- package/src/@types/dns-packet/index.d.ts +114 -0
- package/src/ABIs/Multicall.json +452 -0
- package/src/GqlManager.test.ts +170 -0
- package/src/GqlManager.ts +67 -2
- package/src/contracts/index.ts +1 -1
- package/src/{tests → functions}/batch.test.ts +7 -7
- package/src/{tests → functions}/batchWrappers.test.ts +6 -6
- package/src/{tests → functions}/burnFuses.test.ts +12 -15
- package/src/functions/burnFuses.ts +9 -11
- package/src/{tests → functions}/createSubname.test.ts +9 -17
- package/src/functions/createSubname.ts +20 -14
- package/src/{tests → functions}/deleteSubname.test.ts +12 -31
- package/src/functions/deleteSubname.ts +10 -12
- package/src/functions/getDNSOwner.test.ts +118 -0
- package/src/functions/getDNSOwner.ts +61 -0
- package/src/functions/getExpiry.test.ts +59 -0
- package/src/functions/getExpiry.ts +87 -9
- package/src/{tests → functions}/getFuses.test.ts +16 -37
- package/src/functions/getFuses.ts +12 -17
- package/src/functions/getHistory.test.ts +29 -0
- package/src/functions/getHistory.ts +2 -127
- package/src/{tests → functions}/getName.test.ts +6 -6
- package/src/functions/getName.ts +1 -1
- package/src/{tests → functions}/getNames.test.ts +98 -69
- package/src/{tests → functions}/getOwner.test.ts +21 -24
- package/src/functions/getOwner.ts +7 -7
- package/src/functions/getProfile.test.ts +143 -0
- package/src/functions/getProfile.ts +151 -24
- package/src/functions/getRecords.ts +1 -0
- package/src/functions/getResolver.test.ts +15 -0
- package/src/{tests → functions}/getSpecificRecord.test.ts +17 -14
- package/src/functions/getSpecificRecord.ts +38 -12
- package/src/functions/getSubnames.test.ts +35 -0
- package/src/functions/getSubnames.ts +76 -67
- package/src/{tests → functions}/makeCommitment.test.ts +2 -2
- package/src/functions/normalise.test.ts +22 -0
- package/src/{tests → functions}/setName.test.ts +11 -11
- package/src/functions/setName.ts +15 -17
- package/src/functions/setRecord.test.ts +103 -0
- package/src/functions/setRecord.ts +63 -0
- package/src/{tests → functions}/setRecords.test.ts +16 -13
- package/src/functions/setRecords.ts +22 -16
- package/src/{tests → functions}/setResolver.test.ts +13 -19
- package/src/functions/setResolver.ts +15 -20
- package/src/{tests → functions}/transferName.test.ts +20 -35
- package/src/functions/transferName.ts +19 -22
- package/src/{tests → functions}/transferSubname.test.ts +14 -33
- package/src/functions/transferSubname.ts +39 -13
- package/src/{tests → functions}/unwrapName.test.ts +16 -30
- package/src/functions/unwrapName.ts +20 -15
- package/src/functions/wrapName.test.ts +142 -0
- package/src/functions/wrapName.ts +63 -49
- package/src/generated/BaseRegistrarImplementation.ts +382 -296
- package/src/generated/DNSRegistrar.ts +103 -89
- package/src/generated/DNSSECImpl.ts +180 -149
- package/src/generated/DefaultReverseResolver.ts +37 -21
- package/src/generated/ENSRegistry.ts +257 -184
- package/src/generated/ETHRegistrarController.ts +252 -191
- package/src/generated/Multicall.ts +73 -57
- package/src/generated/NameWrapper.ts +979 -649
- package/src/generated/P256SHA256Algorithm.ts +21 -16
- package/src/generated/PublicResolver.ts +452 -362
- package/src/generated/RSASHA1Algorithm.ts +21 -16
- package/src/generated/RSASHA256Algorithm.ts +21 -16
- package/src/generated/ReverseRegistrar.ts +193 -141
- package/src/generated/Root.ts +146 -86
- package/src/generated/SHA1Digest.ts +12 -11
- package/src/generated/SHA1NSEC3Digest.ts +21 -16
- package/src/generated/SHA256Digest.ts +12 -11
- package/src/generated/StaticMetadataService.ts +22 -6
- package/src/generated/TLDPublicSuffixList.ts +10 -6
- package/src/generated/UniversalResolver.ts +44 -40
- package/src/generated/common.ts +2 -0
- package/src/generated/factories/DNSRegistrar__factory.ts +4 -56
- package/src/generated/factories/DNSSECImpl__factory.ts +4 -49
- package/src/generated/factories/ETHRegistrarController__factory.ts +14 -4
- package/src/generated/factories/NameWrapper__factory.ts +210 -79
- package/src/generated/factories/P256SHA256Algorithm__factory.ts +4 -40
- package/src/generated/factories/RSASHA1Algorithm__factory.ts +4 -40
- package/src/generated/factories/RSASHA256Algorithm__factory.ts +4 -40
- package/src/generated/factories/SHA1Digest__factory.ts +4 -40
- package/src/generated/factories/SHA1NSEC3Digest__factory.ts +4 -40
- package/src/generated/factories/SHA256Digest__factory.ts +4 -40
- package/src/generated/factories/TLDPublicSuffixList__factory.ts +4 -40
- package/src/generated/factories/index.ts +14 -0
- package/src/generated/index.ts +29 -1
- package/src/index.ts +117 -47
- package/src/tests/populateTransaction.test.ts +40 -0
- package/src/tests/setup.ts +17 -13
- package/src/tests/signerInjection.test.ts +46 -0
- package/src/tests/withProvider.test.ts +3 -3
- package/src/utils/labels.ts +6 -4
- package/src/utils/makeHashIndexes.ts +4 -4
- package/src/utils/normalise.ts +29 -0
- package/src/utils/recordHelpers.ts +52 -18
- package/src/utils/registerHelpers.ts +3 -4
- package/src/utils/wrapperExpiry.ts +31 -0
- package/src/utils/writeTx.ts +6 -0
- package/dist/cjs/contracts/doNotCallOnChainUniversalResolverProxy.d.ts +0 -3
- package/dist/cjs/contracts/doNotCallOnChainUniversalResolverProxy.js +0 -4
- package/dist/cjs/generated/DoNotCallOnChainUniversalResolverProxy.d.ts +0 -144
- package/dist/cjs/generated/DoNotCallOnChainUniversalResolverProxy.js +0 -2
- package/dist/cjs/generated/factories/DoNotCallOnChainUniversalResolverProxy__factory.d.ts +0 -56
- package/dist/cjs/generated/factories/DoNotCallOnChainUniversalResolverProxy__factory.js +0 -171
- package/dist/esm/contracts/doNotCallOnChainUniversalResolverProxy.d.ts +0 -3
- package/dist/esm/contracts/doNotCallOnChainUniversalResolverProxy.js +0 -2
- package/dist/esm/generated/DoNotCallOnChainUniversalResolverProxy.d.ts +0 -144
- package/dist/esm/generated/DoNotCallOnChainUniversalResolverProxy.js +0 -1
- package/dist/esm/generated/factories/DoNotCallOnChainUniversalResolverProxy__factory.d.ts +0 -56
- package/dist/esm/generated/factories/DoNotCallOnChainUniversalResolverProxy__factory.js +0 -167
- package/src/ABIs/ETHRegistrarController.json +0 -494
- package/src/ABIs/NameWrapper.json +0 -1183
- package/src/ABIs/PublicResolver.json +0 -875
- package/src/ABIs/ReverseRegistrar.json +0 -323
- package/src/ABIs/StaticMetadataService.json +0 -32
- package/src/ABIs/UniversalResolver.json +0 -187
- package/src/contracts/doNotCallOnChainUniversalResolverProxy.ts +0 -5
- package/src/generated/DoNotCallOnChainUniversalResolverProxy.ts +0 -285
- package/src/generated/factories/DoNotCallOnChainUniversalResolverProxy__factory.ts +0 -186
- package/src/tests/getExpiry.test.ts +0 -37
- package/src/tests/getHistory.test.ts +0 -101
- package/src/tests/getProfile.test.ts +0 -102
- package/src/tests/getResolver.test.ts +0 -19
- package/src/tests/getSubnames.test.ts +0 -31
- package/src/tests/wrapName.test.ts +0 -67
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ethers } from 'ethers'
|
|
2
|
+
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
4
|
+
|
|
5
|
+
let ENSInstance: ENS
|
|
6
|
+
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
7
|
+
let provider: ethers.providers.JsonRpcProvider
|
|
8
|
+
let accounts: string[]
|
|
9
|
+
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
;({ ENSInstance, revert, provider } = await setup())
|
|
12
|
+
accounts = await provider.listAccounts()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterAll(async () => {
|
|
16
|
+
await revert()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('getExpiry', () => {
|
|
20
|
+
it('should get the expiry for a .eth name with no other args', async () => {
|
|
21
|
+
const result = await ENSInstance.getExpiry('with-profile.eth')
|
|
22
|
+
expect(result).toBeTruthy()
|
|
23
|
+
if (result) {
|
|
24
|
+
const { expiry, gracePeriod } = result
|
|
25
|
+
expect(expiry).toBeInstanceOf(Date)
|
|
26
|
+
expect(gracePeriod).toBe(7776000000)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
it('should get the expiry for a wrapped name', async () => {
|
|
30
|
+
const result = await ENSInstance.getExpiry('wrapped.eth', {
|
|
31
|
+
contract: 'nameWrapper',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
expect(result).toBeTruthy()
|
|
35
|
+
if (result) {
|
|
36
|
+
const { expiry, gracePeriod } = result
|
|
37
|
+
expect(expiry).toBeInstanceOf(Date)
|
|
38
|
+
expect(gracePeriod).toBe(null)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
it('should throw an error for a non .eth name if not wrapped', async () => {
|
|
42
|
+
try {
|
|
43
|
+
await ENSInstance.getExpiry('sub.with-profile.eth')
|
|
44
|
+
expect(false).toBeTruthy()
|
|
45
|
+
} catch {
|
|
46
|
+
expect(true).toBeTruthy()
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
it('should throw an error for a non .eth name if registrar is specified', async () => {
|
|
50
|
+
try {
|
|
51
|
+
await ENSInstance.getExpiry('sub.with-profile.eth', {
|
|
52
|
+
contract: 'registrar',
|
|
53
|
+
})
|
|
54
|
+
expect(false).toBeTruthy()
|
|
55
|
+
} catch {
|
|
56
|
+
expect(true).toBeTruthy()
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers'
|
|
2
2
|
import { solidityKeccak256 } from 'ethers/lib/utils'
|
|
3
3
|
import { ENSArgs } from '..'
|
|
4
|
+
import { namehash } from '../utils/normalise'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
{ contracts, multicallWrapper }: ENSArgs<'contracts' | 'multicallWrapper'>,
|
|
7
|
-
name: string,
|
|
8
|
-
) => {
|
|
9
|
-
const baseRegistrar = await contracts?.getBaseRegistrar()!
|
|
6
|
+
type ContractOption = 'registrar' | 'nameWrapper'
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
type Args = {
|
|
9
|
+
contract?: ContractOption
|
|
10
|
+
}
|
|
12
11
|
|
|
12
|
+
const getRegistrarExpiry = async (
|
|
13
|
+
{ contracts, multicallWrapper }: ENSArgs<'contracts' | 'multicallWrapper'>,
|
|
14
|
+
labels: string[],
|
|
15
|
+
) => {
|
|
13
16
|
if (labels.length > 2 || labels[1] !== 'eth') {
|
|
14
|
-
throw new Error('Only .eth names have expiry dates')
|
|
17
|
+
throw new Error('Only .eth names have expiry dates on the registrar')
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
const baseRegistrar = await contracts?.getBaseRegistrar()!
|
|
21
|
+
|
|
17
22
|
const expiryCall = baseRegistrar.interface.encodeFunctionData('nameExpires', [
|
|
18
23
|
solidityKeccak256(['string'], [labels[0]]),
|
|
19
24
|
])
|
|
@@ -32,11 +37,49 @@ const raw = async (
|
|
|
32
37
|
])
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
const
|
|
40
|
+
const getWrapperExpiry = async (
|
|
41
|
+
{ contracts }: ENSArgs<'contracts'>,
|
|
42
|
+
labels: string[],
|
|
43
|
+
) => {
|
|
44
|
+
const nameWrapper = await contracts?.getNameWrapper()!
|
|
45
|
+
const expiryCall = nameWrapper.interface.encodeFunctionData('getData', [
|
|
46
|
+
namehash(labels.join('.')),
|
|
47
|
+
])
|
|
48
|
+
return {
|
|
49
|
+
to: nameWrapper.address,
|
|
50
|
+
data: expiryCall,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const getContractToUse = (
|
|
55
|
+
contract: ContractOption | undefined,
|
|
56
|
+
labels: string[],
|
|
57
|
+
) => {
|
|
58
|
+
if (contract) return contract
|
|
59
|
+
if (labels.length === 2 && labels[1] === 'eth') {
|
|
60
|
+
return 'registrar'
|
|
61
|
+
}
|
|
62
|
+
return 'nameWrapper'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const raw = async (
|
|
66
|
+
ensArgs: ENSArgs<'contracts' | 'multicallWrapper'>,
|
|
67
|
+
name: string,
|
|
68
|
+
{ contract }: Args = {},
|
|
69
|
+
) => {
|
|
70
|
+
const labels = name.split('.')
|
|
71
|
+
|
|
72
|
+
const contractToUse = getContractToUse(contract, labels)
|
|
73
|
+
|
|
74
|
+
return contractToUse === 'nameWrapper'
|
|
75
|
+
? getWrapperExpiry(ensArgs, labels)
|
|
76
|
+
: getRegistrarExpiry(ensArgs, labels)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const decodeRegistrarExpiry = async (
|
|
36
80
|
{ contracts, multicallWrapper }: ENSArgs<'contracts' | 'multicallWrapper'>,
|
|
37
81
|
data: string,
|
|
38
82
|
) => {
|
|
39
|
-
if (data === null) return
|
|
40
83
|
const result = await multicallWrapper.decode(data)
|
|
41
84
|
const baseRegistrar = await contracts?.getBaseRegistrar()!
|
|
42
85
|
try {
|
|
@@ -57,6 +100,41 @@ const decode = async (
|
|
|
57
100
|
}
|
|
58
101
|
}
|
|
59
102
|
|
|
103
|
+
const decodeWrapperExpiry = async (
|
|
104
|
+
{ contracts }: ENSArgs<'contracts'>,
|
|
105
|
+
data: string,
|
|
106
|
+
) => {
|
|
107
|
+
const nameWrapper = await contracts?.getNameWrapper()!
|
|
108
|
+
try {
|
|
109
|
+
const [_owner, _fuses, expiry] = nameWrapper.interface.decodeFunctionResult(
|
|
110
|
+
'getData',
|
|
111
|
+
data,
|
|
112
|
+
)
|
|
113
|
+
return {
|
|
114
|
+
expiry: new Date(expiry * 1000),
|
|
115
|
+
gracePeriod: null,
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const decode = async (
|
|
123
|
+
ensArgs: ENSArgs<'contracts' | 'multicallWrapper'>,
|
|
124
|
+
data: string,
|
|
125
|
+
name: string,
|
|
126
|
+
{ contract }: Args = {},
|
|
127
|
+
) => {
|
|
128
|
+
if (data === null) return
|
|
129
|
+
|
|
130
|
+
const labels = name.split('.')
|
|
131
|
+
const contractToUse = getContractToUse(contract, labels)
|
|
132
|
+
|
|
133
|
+
return contractToUse === 'nameWrapper'
|
|
134
|
+
? decodeWrapperExpiry(ensArgs, data)
|
|
135
|
+
: decodeRegistrarExpiry(ensArgs, data)
|
|
136
|
+
}
|
|
137
|
+
|
|
60
138
|
export default {
|
|
61
139
|
raw,
|
|
62
140
|
decode,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
-
import setup from '
|
|
3
|
+
import setup from '../tests/setup'
|
|
4
4
|
|
|
5
5
|
let ENSInstance: ENS
|
|
6
6
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -12,8 +12,6 @@ let withWrappedSnapshot: any
|
|
|
12
12
|
beforeAll(async () => {
|
|
13
13
|
;({ ENSInstance, revert, provider, createSnapshot } = await setup())
|
|
14
14
|
accounts = await provider.listAccounts()
|
|
15
|
-
const tx = await ENSInstance.wrapName('parthtejpal.eth', accounts[0])
|
|
16
|
-
await tx.wait()
|
|
17
15
|
|
|
18
16
|
withWrappedSnapshot = await createSnapshot()
|
|
19
17
|
})
|
|
@@ -29,19 +27,12 @@ afterAll(async () => {
|
|
|
29
27
|
|
|
30
28
|
describe('getFuses', () => {
|
|
31
29
|
it('should return null for an unwrapped name', async () => {
|
|
32
|
-
const result = await ENSInstance.getFuses('
|
|
30
|
+
const result = await ENSInstance.getFuses('with-profile.eth')
|
|
33
31
|
expect(result).toBeUndefined()
|
|
34
32
|
})
|
|
35
33
|
it('should return with canDoEverything set to true for a name with no fuses burned', async () => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
name: 'test.parthtejpal.eth',
|
|
39
|
-
owner: accounts[0],
|
|
40
|
-
options: { addressOrIndex: 0 },
|
|
41
|
-
})
|
|
42
|
-
await tx.wait()
|
|
43
|
-
|
|
44
|
-
const result = await ENSInstance.getFuses('test.parthtejpal.eth')
|
|
34
|
+
const nameWrapper = await ENSInstance.contracts!.getNameWrapper()!
|
|
35
|
+
const result = await ENSInstance.getFuses('test.wrapped-with-subnames.eth')
|
|
45
36
|
expect(result).toBeTruthy()
|
|
46
37
|
if (result) {
|
|
47
38
|
expect(result.fuseObj.canDoEverything).toBe(true)
|
|
@@ -55,13 +46,17 @@ describe('getFuses', () => {
|
|
|
55
46
|
}
|
|
56
47
|
})
|
|
57
48
|
it('should return with other correct fuses', async () => {
|
|
58
|
-
const tx = await ENSInstance.burnFuses('
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
const tx = await ENSInstance.burnFuses('wrapped.eth', {
|
|
50
|
+
fusesToBurn: {
|
|
51
|
+
cannotUnwrap: true,
|
|
52
|
+
cannotSetTtl: true,
|
|
53
|
+
cannotCreateSubdomain: true,
|
|
54
|
+
},
|
|
55
|
+
addressOrIndex: 1,
|
|
62
56
|
})
|
|
63
57
|
await tx.wait()
|
|
64
|
-
|
|
58
|
+
|
|
59
|
+
const result = await ENSInstance.getFuses('wrapped.eth')
|
|
65
60
|
expect(result).toBeTruthy()
|
|
66
61
|
if (result) {
|
|
67
62
|
expect(result.fuseObj).toMatchObject({
|
|
@@ -77,27 +72,11 @@ describe('getFuses', () => {
|
|
|
77
72
|
expect(result.rawFuses.toHexString()).toBe('0x71')
|
|
78
73
|
}
|
|
79
74
|
})
|
|
80
|
-
it('should return correct
|
|
81
|
-
const result = await ENSInstance.getFuses('
|
|
82
|
-
expect(result).toBeTruthy()
|
|
83
|
-
if (result) {
|
|
84
|
-
expect(result.vulnerability).toBe('Safe')
|
|
85
|
-
expect(result.vulnerableNode).toBeNull()
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
it('should return correct vulnerability data for a vulnerable node', async () => {
|
|
89
|
-
const tx = await ENSInstance.createSubname({
|
|
90
|
-
name: 'test.parthtejpal.eth',
|
|
91
|
-
owner: accounts[0],
|
|
92
|
-
contract: 'nameWrapper',
|
|
93
|
-
})
|
|
94
|
-
await tx.wait()
|
|
95
|
-
|
|
96
|
-
const result = await ENSInstance.getFuses('test.parthtejpal.eth')
|
|
75
|
+
it('should return correct expiry', async () => {
|
|
76
|
+
const result = await ENSInstance.getFuses('wrapped.eth')
|
|
97
77
|
expect(result).toBeTruthy()
|
|
98
78
|
if (result) {
|
|
99
|
-
expect(result.
|
|
100
|
-
expect(result.vulnerableNode).toBe('parthtejpal.eth')
|
|
79
|
+
expect(result.expiryDate).toBeInstanceOf(Date)
|
|
101
80
|
}
|
|
102
81
|
})
|
|
103
82
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { BigNumber
|
|
1
|
+
import { BigNumber } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
3
|
import { testable as fuseEnums } from '../utils/fuses'
|
|
4
|
+
import { namehash } from '../utils/normalise'
|
|
4
5
|
|
|
5
6
|
const NameSafety = [
|
|
6
7
|
'Safe',
|
|
@@ -15,7 +16,7 @@ const raw = async ({ contracts }: ENSArgs<'contracts'>, name: string) => {
|
|
|
15
16
|
return {
|
|
16
17
|
to: nameWrapper.address,
|
|
17
18
|
data: nameWrapper.interface.encodeFunctionData('getFuses', [
|
|
18
|
-
|
|
19
|
+
namehash(name),
|
|
19
20
|
]),
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -27,8 +28,12 @@ const decode = async (
|
|
|
27
28
|
) => {
|
|
28
29
|
const nameWrapper = await contracts?.getNameWrapper()!
|
|
29
30
|
try {
|
|
30
|
-
const [
|
|
31
|
-
|
|
31
|
+
const [_fuses, expiry] = nameWrapper.interface.decodeFunctionResult(
|
|
32
|
+
'getFuses',
|
|
33
|
+
data,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const fuses = BigNumber.from(_fuses)
|
|
32
37
|
|
|
33
38
|
const fuseObj = Object.fromEntries(
|
|
34
39
|
Object.keys(fuseEnums).map((fuseEnum) => [
|
|
@@ -47,22 +52,12 @@ const decode = async (
|
|
|
47
52
|
fuseObj.canDoEverything = false
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
if (utils.hexStripZeros(vulnerableNode) !== '0x') {
|
|
52
|
-
name.split('.').forEach((label, index, arr) => {
|
|
53
|
-
const node = arr.slice(index).join('.')
|
|
54
|
-
const nodehash = utils.namehash(node)
|
|
55
|
-
if (nodehash === vulnerableNode) {
|
|
56
|
-
returnVulnerableNode = node
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
|
55
|
+
const expiryDate = new Date(expiry * 1000)
|
|
60
56
|
|
|
61
57
|
return {
|
|
62
58
|
fuseObj,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
rawFuses: fuses as BigNumber,
|
|
59
|
+
expiryDate,
|
|
60
|
+
rawFuses: fuses,
|
|
66
61
|
}
|
|
67
62
|
} catch {
|
|
68
63
|
return
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ENS } from '..'
|
|
2
|
+
import setup from '../tests/setup'
|
|
3
|
+
|
|
4
|
+
let ENSInstance: ENS
|
|
5
|
+
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
6
|
+
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
;({ ENSInstance, revert } = await setup())
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
afterAll(async () => {
|
|
12
|
+
await revert()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
describe('getHistory', () => {
|
|
16
|
+
it('should return null for a non-existent name', async () => {
|
|
17
|
+
const result = await ENSInstance.getHistory('test123123cool.eth')
|
|
18
|
+
expect(result).toBeUndefined()
|
|
19
|
+
})
|
|
20
|
+
it('should return the history of a name', async () => {
|
|
21
|
+
const result = await ENSInstance.getHistory('with-profile.eth')
|
|
22
|
+
expect(result).toBeTruthy()
|
|
23
|
+
if (result) {
|
|
24
|
+
expect(result).toHaveProperty('domain')
|
|
25
|
+
expect(result).toHaveProperty('resolver')
|
|
26
|
+
expect(result).toHaveProperty('registration')
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -2,7 +2,6 @@ import { formatsByCoinType } from '@ensdomains/address-encoder'
|
|
|
2
2
|
import { ethers } from 'ethers'
|
|
3
3
|
import { ENSArgs } from '..'
|
|
4
4
|
import { decodeContenthash } from '../utils/contentHash'
|
|
5
|
-
import { makeOtherIndexes } from '../utils/makeHashIndexes'
|
|
6
5
|
|
|
7
6
|
type DomainEvent = 'NewOwner' | 'NewResolver' | 'Transfer' | 'NewTTL'
|
|
8
7
|
type RegistrationEvent = 'NameRegistered' | 'NameRenewed' | 'NameTransferred'
|
|
@@ -63,7 +62,7 @@ const eventFormat: Record<
|
|
|
63
62
|
NameChanged: (args: any) => ({ name: args.name }),
|
|
64
63
|
AbiChanged: (args: any) => ({ contentType: args.contentType }),
|
|
65
64
|
PubkeyChanged: (args: any) => ({ x: args.x, y: args.y }),
|
|
66
|
-
TextChanged: (args: any) => ({ key: args.key }),
|
|
65
|
+
TextChanged: (args: any) => ({ key: args.key, value: args.value }),
|
|
67
66
|
ContenthashChanged: (args: any) => ({ hash: decodeContenthash(args.hash) }),
|
|
68
67
|
InterfaceChanged: (args: any) => ({
|
|
69
68
|
interfaceId: args.interfaceId,
|
|
@@ -86,37 +85,6 @@ const mapEvents = (eventArray: any[], type: EventTypes) =>
|
|
|
86
85
|
data: eventFormat[type][event.__typename](event),
|
|
87
86
|
}))
|
|
88
87
|
|
|
89
|
-
const mapResultDetailDecode =
|
|
90
|
-
(publicResolver: ethers.Contract) => (result: any) => {
|
|
91
|
-
const hashIndexes = makeOtherIndexes(result.input, '10f13a8c')
|
|
92
|
-
const abiLengths = hashIndexes.map((x: number) => ({
|
|
93
|
-
index: x,
|
|
94
|
-
length:
|
|
95
|
-
x === 0
|
|
96
|
-
? ethers.utils.hexDataLength(result.input)
|
|
97
|
-
: parseInt(ethers.utils.hexDataSlice(result.input, x - 32, x), 16),
|
|
98
|
-
}))
|
|
99
|
-
const ABIs = abiLengths.map(({ index, length }) =>
|
|
100
|
-
ethers.utils.hexDataSlice(result.input, index, index + length),
|
|
101
|
-
)
|
|
102
|
-
return ABIs.map((abi: string) => {
|
|
103
|
-
try {
|
|
104
|
-
return publicResolver.interface.decodeFunctionData(
|
|
105
|
-
'setText(bytes32,string,string)',
|
|
106
|
-
abi,
|
|
107
|
-
)
|
|
108
|
-
} catch {
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const expandDecode = (prev: any, curr: any) => {
|
|
115
|
-
if (!curr) return [...prev, { value: null }]
|
|
116
|
-
if (!curr.length) return [...prev, curr]
|
|
117
|
-
return [...prev, ...curr]
|
|
118
|
-
}
|
|
119
|
-
|
|
120
88
|
export async function getHistory(
|
|
121
89
|
{ gqlInstance }: ENSArgs<'gqlInstance'>,
|
|
122
90
|
name: string,
|
|
@@ -200,6 +168,7 @@ export async function getHistory(
|
|
|
200
168
|
}
|
|
201
169
|
...on TextChanged {
|
|
202
170
|
key
|
|
171
|
+
value
|
|
203
172
|
}
|
|
204
173
|
...on ContenthashChanged {
|
|
205
174
|
hash
|
|
@@ -251,97 +220,3 @@ export async function getHistory(
|
|
|
251
220
|
resolver: resolverHistory,
|
|
252
221
|
}
|
|
253
222
|
}
|
|
254
|
-
|
|
255
|
-
export async function getHistoryWithDetail(
|
|
256
|
-
{
|
|
257
|
-
contracts,
|
|
258
|
-
gqlInstance,
|
|
259
|
-
provider,
|
|
260
|
-
}: ENSArgs<'contracts' | 'gqlInstance' | 'provider'>,
|
|
261
|
-
name: string,
|
|
262
|
-
) {
|
|
263
|
-
const historyRes = await getHistory({ gqlInstance }, name)
|
|
264
|
-
|
|
265
|
-
if (!historyRes) return
|
|
266
|
-
|
|
267
|
-
const { domain, registration, resolver: resolverHistory } = historyRes
|
|
268
|
-
|
|
269
|
-
const textEvents = resolverHistory.filter(
|
|
270
|
-
(event) => event.type === 'TextChanged',
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
const transactions = textEvents.reduce((prev, curr) => {
|
|
274
|
-
if (prev.includes(curr.transactionHash)) {
|
|
275
|
-
return prev
|
|
276
|
-
}
|
|
277
|
-
return [...prev, curr.transactionHash]
|
|
278
|
-
}, [] as string[])
|
|
279
|
-
|
|
280
|
-
const publicResolver = await contracts?.getPublicResolver()!
|
|
281
|
-
|
|
282
|
-
const fetchResult = (
|
|
283
|
-
await ethers.utils.fetchJson(
|
|
284
|
-
provider!.connection,
|
|
285
|
-
JSON.stringify(
|
|
286
|
-
transactions.map((tx, i) => ({
|
|
287
|
-
jsonrpc: '2.0',
|
|
288
|
-
id: i,
|
|
289
|
-
method: 'eth_getTransactionByHash',
|
|
290
|
-
params: [tx],
|
|
291
|
-
})),
|
|
292
|
-
),
|
|
293
|
-
)
|
|
294
|
-
)
|
|
295
|
-
.map((result: any) => result.result)
|
|
296
|
-
.map(mapResultDetailDecode(publicResolver))
|
|
297
|
-
.reduce(expandDecode, [])
|
|
298
|
-
|
|
299
|
-
const detailedResolverHistory = resolverHistory.map((event) => {
|
|
300
|
-
if (event.type !== 'TextChanged') return event
|
|
301
|
-
const { id } = event
|
|
302
|
-
const matchedTextInx = textEvents.findIndex((x) => x.id === id)
|
|
303
|
-
return {
|
|
304
|
-
...event,
|
|
305
|
-
data: {
|
|
306
|
-
...event.data,
|
|
307
|
-
value: fetchResult[matchedTextInx] && fetchResult[matchedTextInx].value,
|
|
308
|
-
},
|
|
309
|
-
}
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
return {
|
|
313
|
-
domain,
|
|
314
|
-
registration,
|
|
315
|
-
resolver: detailedResolverHistory,
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export async function getHistoryDetailForTransactionHash(
|
|
320
|
-
{ contracts, provider }: ENSArgs<'contracts' | 'provider'>,
|
|
321
|
-
hash: string,
|
|
322
|
-
indexInTransaction?: number,
|
|
323
|
-
) {
|
|
324
|
-
const publicResolver = await contracts?.getPublicResolver()!
|
|
325
|
-
const transaction = await provider!.getTransaction(hash)
|
|
326
|
-
if (!transaction) return
|
|
327
|
-
const result = mapResultDetailDecode(publicResolver)({
|
|
328
|
-
input: transaction.data,
|
|
329
|
-
})
|
|
330
|
-
if (!result || !result.length) return
|
|
331
|
-
if (typeof indexInTransaction === 'number') {
|
|
332
|
-
if (indexInTransaction + 1 > result.length) return
|
|
333
|
-
const resultItem = result[indexInTransaction]
|
|
334
|
-
if (
|
|
335
|
-
!resultItem ||
|
|
336
|
-
!resultItem.key ||
|
|
337
|
-
(!resultItem.value && resultItem.value !== '')
|
|
338
|
-
)
|
|
339
|
-
return
|
|
340
|
-
return { key: resultItem.key, value: resultItem.value }
|
|
341
|
-
}
|
|
342
|
-
return result.map((item: any) => {
|
|
343
|
-
if (!item.key) return
|
|
344
|
-
if (!item.value && item.value !== '') return { key: item.key, value: null }
|
|
345
|
-
return { key: item.key, value: item.value }
|
|
346
|
-
})
|
|
347
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
-
import setup from '
|
|
3
|
+
import setup from '../tests/setup'
|
|
4
4
|
|
|
5
5
|
let ENSInstance: ENS
|
|
6
6
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -19,11 +19,11 @@ afterAll(async () => {
|
|
|
19
19
|
describe('getName', () => {
|
|
20
20
|
it('should get a primary name from an address', async () => {
|
|
21
21
|
const result = await ENSInstance.getName(
|
|
22
|
-
'
|
|
22
|
+
'0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
|
|
23
23
|
)
|
|
24
24
|
expect(result).toBeTruthy()
|
|
25
25
|
if (result) {
|
|
26
|
-
expect(result.name).toBe('
|
|
26
|
+
expect(result.name).toBe('with-profile.eth')
|
|
27
27
|
expect(result.match).toBeTruthy()
|
|
28
28
|
}
|
|
29
29
|
})
|
|
@@ -31,16 +31,16 @@ describe('getName', () => {
|
|
|
31
31
|
const result = await ENSInstance.getName(
|
|
32
32
|
'0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0',
|
|
33
33
|
)
|
|
34
|
-
expect(result).toBeUndefined()
|
|
34
|
+
expect(result?.name).toBeUndefined()
|
|
35
35
|
})
|
|
36
36
|
it('should return with a false match for a name with no forward resolution', async () => {
|
|
37
|
-
const tx = await ENSInstance.setName('
|
|
37
|
+
const tx = await ENSInstance.setName('with-profile.eth')
|
|
38
38
|
await tx?.wait()
|
|
39
39
|
|
|
40
40
|
const result = await ENSInstance.getName(accounts[0])
|
|
41
41
|
expect(result).toBeTruthy()
|
|
42
42
|
if (result) {
|
|
43
|
-
expect(result.name).toBe('
|
|
43
|
+
expect(result.name).toBe('with-profile.eth')
|
|
44
44
|
expect(result.match).toBeFalsy()
|
|
45
45
|
}
|
|
46
46
|
})
|