@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
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import { ContractTransaction, ethers, PopulatedTransaction } from 'ethers';
|
|
2
3
|
import ContractManager from './contracts';
|
|
3
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
4
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
|
+
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type createSubname from './functions/createSubname';
|
|
8
|
+
import type deleteSubname from './functions/deleteSubname';
|
|
9
|
+
import type setName from './functions/setName';
|
|
10
|
+
import type setRecord from './functions/setRecord';
|
|
11
|
+
import type setRecords from './functions/setRecords';
|
|
12
|
+
import type setResolver from './functions/setResolver';
|
|
13
|
+
import type transferName from './functions/transferName';
|
|
14
|
+
import type transferSubname from './functions/transferSubname';
|
|
15
|
+
import type unwrapName from './functions/unwrapName';
|
|
16
|
+
import type wrapName from './functions/wrapName';
|
|
5
17
|
import GqlManager from './GqlManager';
|
|
6
18
|
declare type ENSOptions = {
|
|
7
19
|
graphURI?: string | null;
|
|
@@ -10,6 +22,7 @@ declare type ENSOptions = {
|
|
|
10
22
|
export declare type InternalENS = {
|
|
11
23
|
options?: ENSOptions;
|
|
12
24
|
provider?: ethers.providers.Provider;
|
|
25
|
+
signer: JsonRpcSigner;
|
|
13
26
|
graphURI?: string | null;
|
|
14
27
|
} & ENS;
|
|
15
28
|
export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
@@ -17,6 +30,15 @@ export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
|
17
30
|
};
|
|
18
31
|
declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
19
32
|
declare type OmitFirstTwoArgs<F> = F extends (x: any, y: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
33
|
+
declare type WriteOptions = {
|
|
34
|
+
addressOrIndex?: string | number;
|
|
35
|
+
signer?: JsonRpcSigner;
|
|
36
|
+
};
|
|
37
|
+
declare type OptionalWriteOptions<F> = F extends (x: any, arg_0: infer Z, options?: infer P) => infer R ? (name: Z, options?: P & WriteOptions) => R : F extends (x: any, arg_0: infer Z, options: infer P) => infer R ? (name: Z, options: P & WriteOptions) => R : never;
|
|
38
|
+
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
39
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction>;
|
|
40
|
+
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
41
|
+
}
|
|
20
42
|
export declare type RawFunction = {
|
|
21
43
|
raw: (...args: any[]) => Promise<{
|
|
22
44
|
to: string;
|
|
@@ -77,6 +99,14 @@ export declare class ENS {
|
|
|
77
99
|
* @returns {OmitFirstArg} - The generated wrapped function
|
|
78
100
|
*/
|
|
79
101
|
private generateFunction;
|
|
102
|
+
/**
|
|
103
|
+
* Generates a write wrapped function
|
|
104
|
+
* @param {string} path - The path of the exported function
|
|
105
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
106
|
+
* @param {string} exportName - The export name of the target function
|
|
107
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
108
|
+
*/
|
|
109
|
+
private generateWriteFunction;
|
|
80
110
|
/**
|
|
81
111
|
* Generates a wrapped function from raw and decode exports
|
|
82
112
|
* @param {string} path - The path of the exported function
|
|
@@ -104,11 +134,13 @@ export declare class ENS {
|
|
|
104
134
|
}>;
|
|
105
135
|
decode: ({ multicallWrapper }: ENSArgs<"multicallWrapper">, data: string, ...items: BatchFunctionResult<RawFunction>[]) => Promise<any[] | undefined>;
|
|
106
136
|
}>;
|
|
107
|
-
getProfile: (nameOrAddress: string, options?: {
|
|
137
|
+
getProfile: (nameOrAddress: string, options?: ({
|
|
108
138
|
contentHash?: boolean | undefined;
|
|
109
139
|
texts?: boolean | string[] | undefined;
|
|
110
140
|
coinTypes?: boolean | string[] | undefined;
|
|
111
|
-
}
|
|
141
|
+
} & {
|
|
142
|
+
resolverAddress?: string | undefined;
|
|
143
|
+
}) | undefined) => Promise<{
|
|
112
144
|
isMigrated: boolean | null;
|
|
113
145
|
createdAt: string | null;
|
|
114
146
|
address?: string | undefined;
|
|
@@ -137,6 +169,7 @@ export declare class ENS {
|
|
|
137
169
|
contentHash?: boolean | undefined;
|
|
138
170
|
texts?: boolean | string[] | undefined;
|
|
139
171
|
coinTypes?: boolean | string[] | undefined;
|
|
172
|
+
resolverAddress?: string | undefined;
|
|
140
173
|
} | undefined) => Promise<{
|
|
141
174
|
isMigrated: boolean | null;
|
|
142
175
|
createdAt: string | null;
|
|
@@ -173,8 +206,8 @@ export declare class ENS {
|
|
|
173
206
|
reverseResolverAddress: any;
|
|
174
207
|
resolverAddress: any;
|
|
175
208
|
} | {
|
|
176
|
-
name:
|
|
177
|
-
match
|
|
209
|
+
name: undefined;
|
|
210
|
+
match?: undefined;
|
|
178
211
|
reverseResolverAddress?: undefined;
|
|
179
212
|
resolverAddress?: undefined;
|
|
180
213
|
} | undefined>;
|
|
@@ -193,10 +226,9 @@ export declare class ENS {
|
|
|
193
226
|
}>;
|
|
194
227
|
decode: ({ contracts }: ENSArgs<"contracts">, data: string, name: string) => Promise<{
|
|
195
228
|
fuseObj: {
|
|
196
|
-
[k: string]:
|
|
229
|
+
[k: string]: boolean;
|
|
197
230
|
};
|
|
198
|
-
|
|
199
|
-
vulnerableNode: null;
|
|
231
|
+
expiryDate: Date;
|
|
200
232
|
rawFuses: ethers.BigNumber;
|
|
201
233
|
} | undefined>;
|
|
202
234
|
}>;
|
|
@@ -223,36 +255,6 @@ export declare class ENS {
|
|
|
223
255
|
data: Record<string, any>;
|
|
224
256
|
}[];
|
|
225
257
|
} | undefined>;
|
|
226
|
-
getHistoryWithDetail: (name: string) => Promise<{
|
|
227
|
-
domain: {
|
|
228
|
-
type: any;
|
|
229
|
-
blockNumber: any;
|
|
230
|
-
transactionHash: any;
|
|
231
|
-
id: any;
|
|
232
|
-
data: Record<string, any>;
|
|
233
|
-
}[];
|
|
234
|
-
registration: {
|
|
235
|
-
type: any;
|
|
236
|
-
blockNumber: any;
|
|
237
|
-
transactionHash: any;
|
|
238
|
-
id: any;
|
|
239
|
-
data: Record<string, any>;
|
|
240
|
-
}[];
|
|
241
|
-
resolver: {
|
|
242
|
-
type: any;
|
|
243
|
-
blockNumber: any;
|
|
244
|
-
transactionHash: any;
|
|
245
|
-
id: any;
|
|
246
|
-
data: Record<string, any>;
|
|
247
|
-
}[];
|
|
248
|
-
} | undefined>;
|
|
249
|
-
getHistoryDetailForTransactionHash: (hash: string, indexInTransaction?: number | undefined) => Promise<({
|
|
250
|
-
key: any;
|
|
251
|
-
value: any;
|
|
252
|
-
} | undefined)[] | {
|
|
253
|
-
key: any;
|
|
254
|
-
value: any;
|
|
255
|
-
} | undefined>;
|
|
256
258
|
getContentHash: GeneratedRawFunction<{
|
|
257
259
|
raw: ({ contracts, universalWrapper }: ENSArgs<"contracts" | "universalWrapper">, name: string) => Promise<{
|
|
258
260
|
to: string;
|
|
@@ -337,11 +339,18 @@ export declare class ENS {
|
|
|
337
339
|
} | undefined>;
|
|
338
340
|
}>;
|
|
339
341
|
getExpiry: GeneratedRawFunction<{
|
|
340
|
-
raw: (
|
|
342
|
+
raw: (ensArgs: ENSArgs<"contracts" | "multicallWrapper">, name: string, { contract }?: {
|
|
343
|
+
contract?: ("nameWrapper" | "registrar") | undefined;
|
|
344
|
+
}) => Promise<{
|
|
341
345
|
to: string;
|
|
342
346
|
data: string;
|
|
343
347
|
}>;
|
|
344
|
-
decode: (
|
|
348
|
+
decode: (ensArgs: ENSArgs<"contracts" | "multicallWrapper">, data: string, name: string, { contract }?: {
|
|
349
|
+
contract?: ("nameWrapper" | "registrar") | undefined;
|
|
350
|
+
}) => Promise<{
|
|
351
|
+
expiry: Date;
|
|
352
|
+
gracePeriod: null;
|
|
353
|
+
} | {
|
|
345
354
|
expiry: Date | null;
|
|
346
355
|
gracePeriod: number;
|
|
347
356
|
} | undefined>;
|
|
@@ -352,7 +361,7 @@ export declare class ENS {
|
|
|
352
361
|
pageSize?: number | undefined;
|
|
353
362
|
orderDirection?: "asc" | "desc" | undefined;
|
|
354
363
|
orderBy?: "labelName" | "createdAt" | undefined;
|
|
355
|
-
lastSubnames
|
|
364
|
+
lastSubnames?: any[] | undefined;
|
|
356
365
|
isLargeQuery?: boolean | undefined;
|
|
357
366
|
}) => Promise<{
|
|
358
367
|
subnames: {
|
|
@@ -423,48 +432,17 @@ export declare class ENS {
|
|
|
423
432
|
}>;
|
|
424
433
|
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<any>;
|
|
425
434
|
}>;
|
|
426
|
-
setName:
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
439
|
-
unwrapName: (name: string, newController: string, newRegistrant?: string | undefined, options?: {
|
|
440
|
-
addressOrIndex?: string | number | undefined;
|
|
441
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
442
|
-
burnFuses: (name: string, fusesToBurn: import("./@types/FuseOptions").FuseOptions) => Promise<ethers.ContractTransaction>;
|
|
443
|
-
createSubname: (args_0: {
|
|
444
|
-
name: string;
|
|
445
|
-
owner: string;
|
|
446
|
-
resolverAddress?: string | undefined;
|
|
447
|
-
contract: "nameWrapper" | "registry";
|
|
448
|
-
options?: {
|
|
449
|
-
addressOrIndex?: string | number | undefined;
|
|
450
|
-
} | undefined;
|
|
451
|
-
} | ({
|
|
452
|
-
contract: "nameWrapper";
|
|
453
|
-
fuses?: import("./@types/FuseOptions").FuseOptions | undefined;
|
|
454
|
-
} & {
|
|
455
|
-
name: string;
|
|
456
|
-
owner: string;
|
|
457
|
-
resolverAddress?: string | undefined;
|
|
458
|
-
contract: "nameWrapper" | "registry";
|
|
459
|
-
options?: {
|
|
460
|
-
addressOrIndex?: string | number | undefined;
|
|
461
|
-
} | undefined;
|
|
462
|
-
})) => Promise<ethers.ContractTransaction>;
|
|
463
|
-
deleteSubname: (name: string, contract: "nameWrapper" | "registry", options?: {
|
|
464
|
-
addressOrIndex?: string | number | undefined;
|
|
465
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
466
|
-
transferSubname: (name: string, contract: "nameWrapper" | "registry", address: string, options?: {
|
|
467
|
-
addressOrIndex?: string | number | undefined;
|
|
468
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
435
|
+
setName: WriteFunction<typeof setName>;
|
|
436
|
+
setRecords: WriteFunction<typeof setRecords>;
|
|
437
|
+
setRecord: WriteFunction<typeof setRecord>;
|
|
438
|
+
setResolver: WriteFunction<typeof setResolver>;
|
|
439
|
+
transferName: WriteFunction<typeof transferName>;
|
|
440
|
+
wrapName: WriteFunction<typeof wrapName>;
|
|
441
|
+
unwrapName: WriteFunction<typeof unwrapName>;
|
|
442
|
+
burnFuses: WriteFunction<typeof burnFuses>;
|
|
443
|
+
createSubname: WriteFunction<typeof createSubname>;
|
|
444
|
+
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
445
|
+
transferSubname: WriteFunction<typeof transferSubname>;
|
|
446
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
469
447
|
}
|
|
470
448
|
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import ContractManager from './contracts';
|
|
|
2
2
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
3
3
|
import GqlManager from './GqlManager';
|
|
4
4
|
import singleCall from './utils/singleCall';
|
|
5
|
+
import writeTx from './utils/writeTx';
|
|
5
6
|
const graphURIEndpoints = {
|
|
6
7
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
7
8
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -52,15 +53,30 @@ export class ENS {
|
|
|
52
53
|
await thisRef.checkInitialProvider();
|
|
53
54
|
// import the module dynamically
|
|
54
55
|
const mod = await import(
|
|
55
|
-
/* webpackMode: "lazy", webpackChunkName: "[request]", webpackPreload: true */
|
|
56
|
+
/* webpackMode: "lazy", webpackChunkName: "[request]", webpackPreload: true, webpackExclude: /.*\.ts$/ */
|
|
56
57
|
`./functions/${path}`);
|
|
57
58
|
// if combine isn't specified, run normally
|
|
58
59
|
// otherwise, create a function from the raw and decode functions
|
|
59
60
|
if (subFunc !== 'combine') {
|
|
61
|
+
const writeable = subFunc === 'write' || subFunc === 'populateTransaction';
|
|
60
62
|
// get the function to call
|
|
61
|
-
const func = subFunc ? mod[exportName][subFunc] : mod[exportName];
|
|
63
|
+
const func = subFunc && !writeable ? mod[exportName][subFunc] : mod[exportName];
|
|
62
64
|
// get the dependencies to forward to the function as the first arg
|
|
63
|
-
|
|
65
|
+
let dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
|
|
66
|
+
// if func is write func, inject signer into dependencies
|
|
67
|
+
if (writeable) {
|
|
68
|
+
const options = (args[1] || {});
|
|
69
|
+
const signer = options.signer ||
|
|
70
|
+
thisRef.provider?.getSigner(options.addressOrIndex);
|
|
71
|
+
const populate = subFunc === 'populateTransaction';
|
|
72
|
+
if (!signer) {
|
|
73
|
+
throw new Error('No signer specified');
|
|
74
|
+
}
|
|
75
|
+
delete options.addressOrIndex;
|
|
76
|
+
delete options.signer;
|
|
77
|
+
dependenciesToForward = { ...dependenciesToForward, signer };
|
|
78
|
+
return func(dependenciesToForward, args[0], options).then(writeTx(signer, populate));
|
|
79
|
+
}
|
|
64
80
|
// return the function with the dependencies forwarded
|
|
65
81
|
return func(dependenciesToForward, ...args);
|
|
66
82
|
}
|
|
@@ -77,6 +93,9 @@ export class ENS {
|
|
|
77
93
|
mainFunc.decode = this.importGenerator(path, dependencies, exportName, 'decode');
|
|
78
94
|
mainFunc.batch = this.importGenerator(path, dependencies, exportName, 'batch', { raw: mainFunc.raw, decode: mainFunc.decode });
|
|
79
95
|
}
|
|
96
|
+
else if (subFunc === 'write') {
|
|
97
|
+
mainFunc.populateTransaction = this.importGenerator(path, dependencies, exportName, 'populateTransaction');
|
|
98
|
+
}
|
|
80
99
|
return mainFunc;
|
|
81
100
|
};
|
|
82
101
|
/**
|
|
@@ -87,6 +106,14 @@ export class ENS {
|
|
|
87
106
|
* @returns {OmitFirstArg} - The generated wrapped function
|
|
88
107
|
*/
|
|
89
108
|
this.generateFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName);
|
|
109
|
+
/**
|
|
110
|
+
* Generates a write wrapped function
|
|
111
|
+
* @param {string} path - The path of the exported function
|
|
112
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
113
|
+
* @param {string} exportName - The export name of the target function
|
|
114
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
115
|
+
*/
|
|
116
|
+
this.generateWriteFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName, 'write');
|
|
90
117
|
/**
|
|
91
118
|
* Generates a wrapped function from raw and decode exports
|
|
92
119
|
* @param {string} path - The path of the exported function
|
|
@@ -129,6 +156,7 @@ export class ENS {
|
|
|
129
156
|
'gqlInstance',
|
|
130
157
|
'getName',
|
|
131
158
|
'resolverMulticallWrapper',
|
|
159
|
+
'multicallWrapper',
|
|
132
160
|
'_getAddr',
|
|
133
161
|
'_getContentHash',
|
|
134
162
|
'_getText',
|
|
@@ -140,8 +168,6 @@ export class ENS {
|
|
|
140
168
|
'contracts',
|
|
141
169
|
]);
|
|
142
170
|
this.getHistory = this.generateFunction('getHistory', ['gqlInstance'], 'getHistory');
|
|
143
|
-
this.getHistoryWithDetail = this.generateFunction('getHistory', ['contracts', 'gqlInstance', 'provider'], 'getHistoryWithDetail');
|
|
144
|
-
this.getHistoryDetailForTransactionHash = this.generateFunction('getHistory', ['contracts', 'provider'], 'getHistoryDetailForTransactionHash');
|
|
145
171
|
this.getContentHash = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getContentHash');
|
|
146
172
|
this._getContentHash = this.generateRawFunction('initialGetters', ['contracts'], '_getContentHash');
|
|
147
173
|
this.getAddr = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getAddr');
|
|
@@ -156,32 +182,29 @@ export class ENS {
|
|
|
156
182
|
this.universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
157
183
|
this.resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
158
184
|
this.multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
159
|
-
this.setName = this.
|
|
185
|
+
this.setName = this.generateWriteFunction('setName', [
|
|
160
186
|
'contracts',
|
|
161
|
-
'provider',
|
|
162
187
|
]);
|
|
163
|
-
this.setRecords = this.
|
|
188
|
+
this.setRecords = this.generateWriteFunction('setRecords', ['contracts', 'provider', 'getResolver']);
|
|
189
|
+
this.setRecord = this.generateWriteFunction('setRecord', [
|
|
164
190
|
'contracts',
|
|
165
191
|
'provider',
|
|
166
192
|
'getResolver',
|
|
167
193
|
]);
|
|
168
|
-
this.setResolver = this.
|
|
169
|
-
this.transferName = this.
|
|
170
|
-
this.wrapName = this.
|
|
194
|
+
this.setResolver = this.generateWriteFunction('setResolver', ['contracts']);
|
|
195
|
+
this.transferName = this.generateWriteFunction('transferName', ['contracts']);
|
|
196
|
+
this.wrapName = this.generateWriteFunction('wrapName', [
|
|
171
197
|
'contracts',
|
|
172
|
-
'
|
|
198
|
+
'getExpiry',
|
|
173
199
|
]);
|
|
174
|
-
this.unwrapName = this.
|
|
200
|
+
this.unwrapName = this.generateWriteFunction('unwrapName', ['contracts']);
|
|
201
|
+
this.burnFuses = this.generateWriteFunction('burnFuses', [
|
|
175
202
|
'contracts',
|
|
176
|
-
'provider',
|
|
177
|
-
]);
|
|
178
|
-
this.burnFuses = this.generateFunction('burnFuses', [
|
|
179
|
-
'contracts',
|
|
180
|
-
'provider',
|
|
181
203
|
]);
|
|
182
|
-
this.createSubname = this.
|
|
183
|
-
this.deleteSubname = this.
|
|
184
|
-
this.transferSubname = this.
|
|
204
|
+
this.createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
205
|
+
this.deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
206
|
+
this.transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
207
|
+
this.getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
185
208
|
this.options = options;
|
|
186
209
|
this.getContractAddress = options?.getContractAddress || _getContractAddress;
|
|
187
210
|
}
|
package/dist/esm/utils/labels.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { solidityKeccak256 } from 'ethers/lib/utils';
|
|
2
2
|
import { truncateFormat } from './format';
|
|
3
|
+
const hasLocalStorage = typeof localStorage !== 'undefined';
|
|
3
4
|
export const labelhash = (input) => solidityKeccak256(['string'], [input]);
|
|
4
5
|
export const keccakFromString = (input) => labelhash(input);
|
|
5
6
|
export function decodeLabelhash(hash) {
|
|
@@ -9,7 +10,7 @@ export function decodeLabelhash(hash) {
|
|
|
9
10
|
if (hash.length !== 66) {
|
|
10
11
|
throw Error('Expected encoded labelhash to have a length of 66');
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return `0x${hash.slice(1, -1)}`;
|
|
13
14
|
}
|
|
14
15
|
export function encodeLabelhash(hash) {
|
|
15
16
|
if (!hash.startsWith('0x')) {
|
|
@@ -24,12 +25,12 @@ export function isEncodedLabelhash(hash) {
|
|
|
24
25
|
return hash.startsWith('[') && hash.endsWith(']') && hash.length === 66;
|
|
25
26
|
}
|
|
26
27
|
function getLabels() {
|
|
27
|
-
return
|
|
28
|
+
return hasLocalStorage
|
|
28
29
|
? JSON.parse(localStorage.getItem('ensjs:labels')) || {}
|
|
29
30
|
: {};
|
|
30
31
|
}
|
|
31
32
|
function _saveLabel(hash, label) {
|
|
32
|
-
if (!
|
|
33
|
+
if (!hasLocalStorage)
|
|
33
34
|
return hash;
|
|
34
35
|
const labels = getLabels();
|
|
35
36
|
localStorage.setItem('ensjs:labels', JSON.stringify({
|
|
@@ -81,7 +82,7 @@ export function decryptName(name) {
|
|
|
81
82
|
}
|
|
82
83
|
export const truncateUndecryptedName = (name) => truncateFormat(name);
|
|
83
84
|
export function checkLocalStorageSize() {
|
|
84
|
-
if (!
|
|
85
|
+
if (!hasLocalStorage)
|
|
85
86
|
return 'Empty (0 KB)';
|
|
86
87
|
let allStrings = '';
|
|
87
88
|
for (const key in window.localStorage) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { namehash } from './normalise';
|
|
2
2
|
export const makeOtherIndexes = (data, findStr) => Array.from(data.matchAll(findStr)).map((x) => x.index / 2 - 1);
|
|
3
|
-
export const makeNamehashIndexes = (data, name) => Array.from(data.matchAll(
|
|
3
|
+
export const makeNamehashIndexes = (data, name) => Array.from(data.matchAll(namehash(name).substring(2))).map((x) => x.index / 2 - 1);
|
|
@@ -1,2 +1,27 @@
|
|
|
1
|
+
import { concat, hexlify, keccak256, toUtf8Bytes } from 'ethers/lib/utils';
|
|
1
2
|
import uts46 from 'idna-uts46-hx/uts46bundle.js';
|
|
3
|
+
import { decodeLabelhash, isEncodedLabelhash } from './labels';
|
|
4
|
+
const zeros = new Uint8Array(32);
|
|
5
|
+
zeros.fill(0);
|
|
2
6
|
export const normalise = (name) => name ? uts46.toUnicode(name, { useStd3ASCII: true }) : name;
|
|
7
|
+
export const namehash = (name) => {
|
|
8
|
+
let result = zeros;
|
|
9
|
+
if (name) {
|
|
10
|
+
const labels = name.split('.');
|
|
11
|
+
for (var i = labels.length - 1; i >= 0; i--) {
|
|
12
|
+
let labelSha;
|
|
13
|
+
if (isEncodedLabelhash(labels[i])) {
|
|
14
|
+
labelSha = decodeLabelhash(labels[i]);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const normalised = normalise(labels[i]);
|
|
18
|
+
labelSha = keccak256(toUtf8Bytes(normalised));
|
|
19
|
+
}
|
|
20
|
+
result = keccak256(concat([result, labelSha]));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
result = hexlify(zeros);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
@@ -9,5 +9,8 @@ export declare type RecordOptions = {
|
|
|
9
9
|
coinTypes?: RecordItem[];
|
|
10
10
|
};
|
|
11
11
|
export declare const generateSetAddr: (namehash: string, coinType: string, address: string, resolver: PublicResolver) => string;
|
|
12
|
+
export declare type RecordTypes = 'contentHash' | 'text' | 'addr';
|
|
13
|
+
export declare type RecordInput<T extends RecordTypes> = T extends 'contentHash' ? string : RecordItem;
|
|
14
|
+
export declare function generateSingleRecordCall<T extends RecordTypes>(namehash: string, resolver: PublicResolver, type: T): (record: RecordInput<T>) => string;
|
|
12
15
|
export declare const generateRecordCallArray: (namehash: string, records: RecordOptions, resolver: PublicResolver) => string[];
|
|
13
16
|
export {};
|
|
@@ -12,28 +12,54 @@ export const generateSetAddr = (namehash, coinType, address, resolver) => {
|
|
|
12
12
|
const encodedAddress = coinTypeInstance.decoder(address);
|
|
13
13
|
return resolver?.interface.encodeFunctionData('setAddr(bytes32,uint256,bytes)', [namehash, inputCoinType, encodedAddress]);
|
|
14
14
|
};
|
|
15
|
+
export function generateSingleRecordCall(namehash, resolver, type) {
|
|
16
|
+
if (type === 'contentHash') {
|
|
17
|
+
return (_r) => {
|
|
18
|
+
const record = _r;
|
|
19
|
+
let _contentHash = '';
|
|
20
|
+
if (record !== _contentHash) {
|
|
21
|
+
const encoded = encodeContenthash(record);
|
|
22
|
+
if (encoded.error)
|
|
23
|
+
throw new Error(encoded.error);
|
|
24
|
+
_contentHash = encoded.encoded;
|
|
25
|
+
}
|
|
26
|
+
return resolver.interface.encodeFunctionData('setContenthash', [
|
|
27
|
+
namehash,
|
|
28
|
+
_contentHash,
|
|
29
|
+
]);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return (_r) => {
|
|
34
|
+
const record = _r;
|
|
35
|
+
if (type === 'text') {
|
|
36
|
+
return resolver.interface.encodeFunctionData('setText', [
|
|
37
|
+
namehash,
|
|
38
|
+
record.key,
|
|
39
|
+
record.value,
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return generateSetAddr(namehash, record.key, record.value, resolver);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
15
48
|
export const generateRecordCallArray = (namehash, records, resolver) => {
|
|
16
49
|
const calls = [];
|
|
17
50
|
if (records.contentHash) {
|
|
18
|
-
const
|
|
19
|
-
const data = resolver?.interface.encodeFunctionData('setContenthash', [namehash, contentHash]);
|
|
51
|
+
const data = generateSingleRecordCall(namehash, resolver, 'contentHash')(records.contentHash);
|
|
20
52
|
data && calls.push(data);
|
|
21
53
|
}
|
|
22
54
|
if (records.texts && records.texts.length > 0) {
|
|
23
|
-
records.texts
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
key,
|
|
27
|
-
value,
|
|
28
|
-
]);
|
|
29
|
-
data && calls.push(data);
|
|
30
|
-
});
|
|
55
|
+
records.texts
|
|
56
|
+
.map(generateSingleRecordCall(namehash, resolver, 'text'))
|
|
57
|
+
.forEach((call) => calls.push(call));
|
|
31
58
|
}
|
|
32
59
|
if (records.coinTypes && records.coinTypes.length > 0) {
|
|
33
|
-
records.coinTypes
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
60
|
+
records.coinTypes
|
|
61
|
+
.map(generateSingleRecordCall(namehash, resolver, 'addr'))
|
|
62
|
+
.forEach((call) => calls.push(call));
|
|
37
63
|
}
|
|
38
64
|
return calls;
|
|
39
65
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { utils } from 'ethers';
|
|
2
2
|
import generateFuseInput from './generateFuseInput';
|
|
3
3
|
import { labelhash } from './labels';
|
|
4
|
+
import { namehash } from './normalise';
|
|
4
5
|
import { generateRecordCallArray } from './recordHelpers';
|
|
5
6
|
export const randomSecret = () => {
|
|
6
7
|
const bytes = Buffer.allocUnsafe(32);
|
|
@@ -8,11 +9,9 @@ export const randomSecret = () => {
|
|
|
8
9
|
};
|
|
9
10
|
export const makeCommitment = ({ name, owner, duration, resolver, records, reverseRecord, fuses, }) => {
|
|
10
11
|
const label = labelhash(name.split('.')[0]);
|
|
11
|
-
const
|
|
12
|
+
const hash = namehash(name);
|
|
12
13
|
const resolverAddress = resolver.address;
|
|
13
|
-
const data = records
|
|
14
|
-
? generateRecordCallArray(namehash, records, resolver)
|
|
15
|
-
: [];
|
|
14
|
+
const data = records ? generateRecordCallArray(hash, records, resolver) : [];
|
|
16
15
|
const secret = randomSecret();
|
|
17
16
|
const fuseData = fuses ? generateFuseInput(fuses) : '0';
|
|
18
17
|
const commitment = _makeCommitment({
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { ENSArgs } from '..';
|
|
3
|
+
export declare type Expiry = string | number | Date | BigNumber;
|
|
4
|
+
export declare const MAX_EXPIRY: BigNumber;
|
|
5
|
+
export declare const makeExpiry: ({ getExpiry }: ENSArgs<'getExpiry'>, name: string, expiry?: Expiry | undefined) => Promise<BigNumber>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
export const MAX_EXPIRY = BigNumber.from(2).pow(64).sub(1);
|
|
3
|
+
export const makeExpiry = async ({ getExpiry }, name, expiry) => {
|
|
4
|
+
if (expiry) {
|
|
5
|
+
if (expiry instanceof Date) {
|
|
6
|
+
return BigNumber.from(expiry.getTime() / 1000);
|
|
7
|
+
}
|
|
8
|
+
else if (expiry instanceof BigNumber) {
|
|
9
|
+
return expiry;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return BigNumber.from(expiry);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (name.endsWith('.eth')) {
|
|
17
|
+
const expResponse = await getExpiry(name);
|
|
18
|
+
if (!expResponse?.expiry)
|
|
19
|
+
throw new Error("Couldn't get expiry for name, please provide one.");
|
|
20
|
+
return BigNumber.from(expResponse.expiry.getTime() / 1000);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return MAX_EXPIRY;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import type { PopulatedTransaction } from 'ethers';
|
|
3
|
+
declare const _default: (signer: JsonRpcSigner, populate: boolean) => (tx: PopulatedTransaction) => PopulatedTransaction | Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (signer, populate) => (tx) => populate ? tx : signer.sendTransaction(tx);
|