@ensdomains/ensjs 2.1.0 → 3.0.0-alpha.11
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/LICENSE +21 -0
- package/README.md +651 -99
- package/dist/cjs/GqlManager.d.ts +9 -0
- package/dist/cjs/GqlManager.js +102 -0
- package/dist/cjs/contracts/baseRegistrar.d.ts +3 -0
- package/dist/cjs/contracts/baseRegistrar.js +4 -0
- package/dist/cjs/contracts/ethRegistrarController.d.ts +3 -0
- package/dist/cjs/contracts/ethRegistrarController.js +4 -0
- package/dist/cjs/contracts/getContractAddress.d.ts +3 -0
- package/dist/cjs/contracts/getContractAddress.js +46 -0
- package/dist/cjs/contracts/index.d.ts +16 -0
- package/dist/cjs/contracts/index.js +37 -0
- package/dist/cjs/contracts/multicall.d.ts +3 -0
- package/dist/cjs/contracts/multicall.js +22 -0
- package/dist/cjs/contracts/nameWrapper.d.ts +3 -0
- package/dist/cjs/contracts/nameWrapper.js +4 -0
- package/dist/cjs/contracts/publicResolver.d.ts +3 -0
- package/dist/cjs/contracts/publicResolver.js +4 -0
- package/dist/cjs/contracts/registry.d.ts +3 -0
- package/dist/cjs/contracts/registry.js +4 -0
- package/dist/cjs/contracts/reverseRegistrar.d.ts +3 -0
- package/dist/cjs/contracts/reverseRegistrar.js +4 -0
- package/dist/cjs/contracts/types.d.ts +2 -0
- package/dist/cjs/contracts/types.js +2 -0
- package/dist/cjs/contracts/universalResolver.d.ts +3 -0
- package/dist/cjs/contracts/universalResolver.js +4 -0
- package/dist/cjs/functions/batch.d.ts +9 -0
- package/dist/cjs/functions/batch.js +21 -0
- package/dist/cjs/functions/batchWrappers.d.ts +29 -0
- package/dist/cjs/functions/batchWrappers.js +71 -0
- package/dist/cjs/functions/burnFuses.d.ts +5 -0
- package/dist/cjs/functions/burnFuses.js +14 -0
- package/dist/cjs/functions/createSubname.d.ts +17 -0
- package/dist/cjs/functions/createSubname.js +42 -0
- package/dist/cjs/functions/deleteSubname.d.ts +4 -0
- package/dist/cjs/functions/deleteSubname.js +10 -0
- package/dist/cjs/functions/getDNSOwner.d.ts +7 -0
- package/dist/cjs/functions/getDNSOwner.js +81 -0
- package/dist/cjs/functions/getExpiry.d.ts +19 -0
- package/dist/cjs/functions/getExpiry.js +90 -0
- package/dist/cjs/functions/getFuses.d.ts +16 -0
- package/dist/cjs/functions/getFuses.js +53 -0
- package/dist/cjs/functions/getHistory.d.ts +54 -0
- package/dist/cjs/functions/getHistory.js +279 -0
- package/dist/cjs/functions/getName.d.ts +19 -0
- package/dist/cjs/functions/getName.js +34 -0
- package/dist/cjs/functions/getNames.d.ts +40 -0
- package/dist/cjs/functions/getNames.js +222 -0
- package/dist/cjs/functions/getOwner.d.ts +14 -0
- package/dist/cjs/functions/getOwner.js +140 -0
- package/dist/cjs/functions/getPrice.d.ts +13 -0
- package/dist/cjs/functions/getPrice.js +50 -0
- package/dist/cjs/functions/getProfile.d.ts +33 -0
- package/dist/cjs/functions/getProfile.js +346 -0
- package/dist/cjs/functions/getRecords.d.ts +33 -0
- package/dist/cjs/functions/getRecords.js +11 -0
- package/dist/cjs/functions/getResolver.d.ts +9 -0
- package/dist/cjs/functions/getResolver.js +24 -0
- package/dist/cjs/functions/getSpecificRecord.d.ts +73 -0
- package/dist/cjs/functions/getSpecificRecord.js +275 -0
- package/dist/cjs/functions/getSubnames.d.ts +26 -0
- package/dist/cjs/functions/getSubnames.js +154 -0
- package/dist/cjs/functions/initialGetters.d.ts +11 -0
- package/dist/cjs/functions/initialGetters.js +40 -0
- package/dist/cjs/functions/setName.d.ts +5 -0
- package/dist/cjs/functions/setName.js +12 -0
- package/dist/cjs/functions/setRecord.d.ts +18 -0
- package/dist/cjs/functions/setRecord.js +27 -0
- package/dist/cjs/functions/setRecords.d.ts +6 -0
- package/dist/cjs/functions/setRecords.js +24 -0
- package/dist/cjs/functions/setResolver.d.ts +5 -0
- package/dist/cjs/functions/setResolver.js +22 -0
- package/dist/cjs/functions/transferName.d.ts +6 -0
- package/dist/cjs/functions/transferName.js +29 -0
- package/dist/cjs/functions/transferSubname.d.ts +15 -0
- package/dist/cjs/functions/transferSubname.js +26 -0
- package/dist/cjs/functions/unwrapName.d.ts +5 -0
- package/dist/cjs/functions/unwrapName.js +23 -0
- package/dist/cjs/functions/wrapName.d.ts +10 -0
- package/dist/cjs/functions/wrapName.js +66 -0
- package/dist/cjs/generated/BaseRegistrarImplementation.d.ts +508 -0
- package/dist/cjs/generated/BaseRegistrarImplementation.js +2 -0
- package/dist/cjs/generated/DNSRegistrar.d.ts +224 -0
- package/dist/cjs/generated/DNSRegistrar.js +2 -0
- package/dist/cjs/generated/DNSSECImpl.d.ts +402 -0
- package/dist/cjs/generated/DNSSECImpl.js +2 -0
- package/dist/cjs/generated/DefaultReverseResolver.d.ts +66 -0
- package/dist/cjs/generated/DefaultReverseResolver.js +2 -0
- package/dist/cjs/generated/ENSRegistry.d.ts +274 -0
- package/dist/cjs/generated/ENSRegistry.js +2 -0
- package/dist/cjs/generated/ETHRegistrarController.d.ts +321 -0
- package/dist/cjs/generated/ETHRegistrarController.js +2 -0
- package/dist/cjs/generated/Multicall.d.ts +292 -0
- package/dist/cjs/generated/Multicall.js +2 -0
- package/dist/cjs/generated/NameWrapper.d.ts +814 -0
- package/dist/cjs/generated/NameWrapper.js +2 -0
- package/dist/cjs/generated/P256SHA256Algorithm.d.ts +76 -0
- package/dist/cjs/generated/P256SHA256Algorithm.js +2 -0
- package/dist/cjs/generated/PublicResolver.d.ts +566 -0
- package/dist/cjs/generated/PublicResolver.js +2 -0
- package/dist/cjs/generated/RSASHA1Algorithm.d.ts +46 -0
- package/dist/cjs/generated/RSASHA1Algorithm.js +2 -0
- package/dist/cjs/generated/RSASHA256Algorithm.d.ts +46 -0
- package/dist/cjs/generated/RSASHA256Algorithm.js +2 -0
- package/dist/cjs/generated/ReverseRegistrar.d.ts +268 -0
- package/dist/cjs/generated/ReverseRegistrar.js +2 -0
- package/dist/cjs/generated/Root.d.ts +173 -0
- package/dist/cjs/generated/Root.js +2 -0
- package/dist/cjs/generated/SHA1Digest.d.ts +67 -0
- package/dist/cjs/generated/SHA1Digest.js +2 -0
- package/dist/cjs/generated/SHA1NSEC3Digest.d.ts +76 -0
- package/dist/cjs/generated/SHA1NSEC3Digest.js +2 -0
- package/dist/cjs/generated/SHA256Digest.d.ts +67 -0
- package/dist/cjs/generated/SHA256Digest.js +2 -0
- package/dist/cjs/generated/StaticMetadataService.d.ts +42 -0
- package/dist/cjs/generated/StaticMetadataService.js +2 -0
- package/dist/cjs/generated/TLDPublicSuffixList.d.ts +42 -0
- package/dist/cjs/generated/TLDPublicSuffixList.js +2 -0
- package/dist/cjs/generated/UniversalResolver.d.ts +82 -0
- package/dist/cjs/generated/UniversalResolver.js +2 -0
- package/dist/cjs/generated/common.d.ts +22 -0
- package/dist/cjs/generated/common.js +2 -0
- package/dist/cjs/generated/factories/BaseRegistrarImplementation__factory.d.ts +52 -0
- package/dist/cjs/generated/factories/BaseRegistrarImplementation__factory.js +770 -0
- package/dist/cjs/generated/factories/DNSRegistrar__factory.d.ts +67 -0
- package/dist/cjs/generated/factories/DNSRegistrar__factory.js +273 -0
- package/dist/cjs/generated/factories/DNSSECImpl__factory.d.ts +56 -0
- package/dist/cjs/generated/factories/DNSSECImpl__factory.js +478 -0
- package/dist/cjs/generated/factories/DefaultReverseResolver__factory.d.ts +36 -0
- package/dist/cjs/generated/factories/DefaultReverseResolver__factory.js +87 -0
- package/dist/cjs/generated/factories/ENSRegistry__factory.d.ts +52 -0
- package/dist/cjs/generated/factories/ENSRegistry__factory.js +439 -0
- package/dist/cjs/generated/factories/ETHRegistrarController__factory.d.ts +66 -0
- package/dist/cjs/generated/factories/ETHRegistrarController__factory.js +521 -0
- package/dist/cjs/generated/factories/Multicall__factory.d.ts +42 -0
- package/dist/cjs/generated/factories/Multicall__factory.js +457 -0
- package/dist/cjs/generated/factories/NameWrapper__factory.d.ts +57 -0
- package/dist/cjs/generated/factories/NameWrapper__factory.js +1331 -0
- package/dist/cjs/generated/factories/P256SHA256Algorithm__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/P256SHA256Algorithm__factory.js +48 -0
- package/dist/cjs/generated/factories/PublicResolver__factory.d.ts +46 -0
- package/dist/cjs/generated/factories/PublicResolver__factory.js +892 -0
- package/dist/cjs/generated/factories/RSASHA1Algorithm__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/RSASHA1Algorithm__factory.js +48 -0
- package/dist/cjs/generated/factories/RSASHA256Algorithm__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/RSASHA256Algorithm__factory.js +48 -0
- package/dist/cjs/generated/factories/ReverseRegistrar__factory.d.ts +46 -0
- package/dist/cjs/generated/factories/ReverseRegistrar__factory.js +340 -0
- package/dist/cjs/generated/factories/Root__factory.d.ts +52 -0
- package/dist/cjs/generated/factories/Root__factory.js +243 -0
- package/dist/cjs/generated/factories/SHA1Digest__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/SHA1Digest__factory.js +43 -0
- package/dist/cjs/generated/factories/SHA1NSEC3Digest__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/SHA1NSEC3Digest__factory.js +48 -0
- package/dist/cjs/generated/factories/SHA256Digest__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/SHA256Digest__factory.js +43 -0
- package/dist/cjs/generated/factories/StaticMetadataService__factory.d.ts +32 -0
- package/dist/cjs/generated/factories/StaticMetadataService__factory.js +49 -0
- package/dist/cjs/generated/factories/TLDPublicSuffixList__factory.d.ts +22 -0
- package/dist/cjs/generated/factories/TLDPublicSuffixList__factory.js +38 -0
- package/dist/cjs/generated/factories/UniversalResolver__factory.d.ts +42 -0
- package/dist/cjs/generated/factories/UniversalResolver__factory.js +204 -0
- package/dist/cjs/generated/factories/index.d.ts +20 -0
- package/dist/cjs/generated/factories/index.js +46 -0
- package/dist/cjs/generated/index.d.ts +41 -0
- package/dist/cjs/generated/index.js +67 -0
- package/dist/cjs/index.d.ts +478 -0
- package/dist/cjs/index.js +248 -0
- package/dist/cjs/utils/contentHash.d.ts +28 -0
- package/dist/cjs/utils/contentHash.js +164 -0
- package/dist/cjs/utils/createReverseNode.d.ts +2 -0
- package/dist/cjs/utils/createReverseNode.js +3 -0
- package/dist/cjs/utils/format.d.ts +3 -0
- package/dist/cjs/utils/format.js +9 -0
- package/dist/cjs/utils/fuses.d.ts +20 -0
- package/dist/cjs/utils/fuses.js +24 -0
- package/dist/cjs/utils/generateFuseInput.d.ts +3 -0
- package/dist/cjs/utils/generateFuseInput.js +19 -0
- package/dist/cjs/utils/hexEncodedName.d.ts +1 -0
- package/dist/cjs/utils/hexEncodedName.js +9 -0
- package/dist/cjs/utils/labels.d.ts +14 -0
- package/dist/cjs/utils/labels.js +113 -0
- package/dist/cjs/utils/makeHashIndexes.d.ts +2 -0
- package/dist/cjs/utils/makeHashIndexes.js +8 -0
- package/dist/cjs/utils/normalise.d.ts +2 -0
- package/dist/cjs/utils/normalise.js +35 -0
- package/dist/cjs/utils/recordHelpers.d.ts +16 -0
- package/dist/cjs/utils/recordHelpers.js +71 -0
- package/dist/cjs/utils/registerHelpers.d.ts +26 -0
- package/dist/cjs/utils/registerHelpers.js +52 -0
- package/dist/cjs/utils/singleCall.d.ts +9 -0
- package/dist/cjs/utils/singleCall.js +7 -0
- package/dist/cjs/utils/validation.d.ts +8 -0
- package/dist/cjs/utils/validation.js +73 -0
- 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 +9 -0
- package/dist/esm/GqlManager.js +74 -0
- package/dist/esm/contracts/baseRegistrar.d.ts +3 -0
- package/dist/esm/contracts/baseRegistrar.js +2 -0
- package/dist/esm/contracts/ethRegistrarController.d.ts +3 -0
- package/dist/esm/contracts/ethRegistrarController.js +2 -0
- package/dist/esm/contracts/getContractAddress.d.ts +3 -0
- package/dist/esm/contracts/getContractAddress.js +42 -0
- package/dist/esm/contracts/index.d.ts +16 -0
- package/dist/esm/contracts/index.js +29 -0
- package/dist/esm/contracts/multicall.d.ts +3 -0
- package/dist/esm/contracts/multicall.js +20 -0
- package/dist/esm/contracts/nameWrapper.d.ts +3 -0
- package/dist/esm/contracts/nameWrapper.js +2 -0
- package/dist/esm/contracts/publicResolver.d.ts +3 -0
- package/dist/esm/contracts/publicResolver.js +2 -0
- package/dist/esm/contracts/registry.d.ts +3 -0
- package/dist/esm/contracts/registry.js +2 -0
- package/dist/esm/contracts/reverseRegistrar.d.ts +3 -0
- package/dist/esm/contracts/reverseRegistrar.js +2 -0
- package/dist/esm/contracts/types.d.ts +2 -0
- package/dist/esm/contracts/types.js +1 -0
- package/dist/esm/contracts/universalResolver.d.ts +3 -0
- package/dist/esm/contracts/universalResolver.js +2 -0
- package/dist/esm/functions/batch.d.ts +9 -0
- package/dist/esm/functions/batch.js +19 -0
- package/dist/esm/functions/batchWrappers.d.ts +29 -0
- package/dist/esm/functions/batchWrappers.js +68 -0
- package/dist/esm/functions/burnFuses.d.ts +5 -0
- package/dist/esm/functions/burnFuses.js +8 -0
- package/dist/esm/functions/createSubname.d.ts +17 -0
- package/dist/esm/functions/createSubname.js +36 -0
- package/dist/esm/functions/deleteSubname.d.ts +4 -0
- package/dist/esm/functions/deleteSubname.js +7 -0
- package/dist/esm/functions/getDNSOwner.d.ts +7 -0
- package/dist/esm/functions/getDNSOwner.js +51 -0
- package/dist/esm/functions/getExpiry.d.ts +19 -0
- package/dist/esm/functions/getExpiry.js +88 -0
- package/dist/esm/functions/getFuses.d.ts +16 -0
- package/dist/esm/functions/getFuses.js +51 -0
- package/dist/esm/functions/getHistory.d.ts +54 -0
- package/dist/esm/functions/getHistory.js +273 -0
- package/dist/esm/functions/getName.d.ts +19 -0
- package/dist/esm/functions/getName.js +32 -0
- package/dist/esm/functions/getNames.d.ts +40 -0
- package/dist/esm/functions/getNames.js +220 -0
- package/dist/esm/functions/getOwner.d.ts +14 -0
- package/dist/esm/functions/getOwner.js +138 -0
- package/dist/esm/functions/getPrice.d.ts +13 -0
- package/dist/esm/functions/getPrice.js +48 -0
- package/dist/esm/functions/getProfile.d.ts +33 -0
- package/dist/esm/functions/getProfile.js +343 -0
- package/dist/esm/functions/getRecords.d.ts +33 -0
- package/dist/esm/functions/getRecords.js +8 -0
- package/dist/esm/functions/getResolver.d.ts +9 -0
- package/dist/esm/functions/getResolver.js +22 -0
- package/dist/esm/functions/getSpecificRecord.d.ts +73 -0
- package/dist/esm/functions/getSpecificRecord.js +272 -0
- package/dist/esm/functions/getSubnames.d.ts +26 -0
- package/dist/esm/functions/getSubnames.js +152 -0
- package/dist/esm/functions/initialGetters.d.ts +11 -0
- package/dist/esm/functions/initialGetters.js +11 -0
- package/dist/esm/functions/setName.d.ts +5 -0
- package/dist/esm/functions/setName.js +9 -0
- package/dist/esm/functions/setRecord.d.ts +18 -0
- package/dist/esm/functions/setRecord.js +24 -0
- package/dist/esm/functions/setRecords.d.ts +6 -0
- package/dist/esm/functions/setRecords.js +21 -0
- package/dist/esm/functions/setResolver.d.ts +5 -0
- package/dist/esm/functions/setResolver.js +19 -0
- package/dist/esm/functions/transferName.d.ts +6 -0
- package/dist/esm/functions/transferName.js +26 -0
- package/dist/esm/functions/transferSubname.d.ts +15 -0
- package/dist/esm/functions/transferSubname.js +23 -0
- package/dist/esm/functions/unwrapName.d.ts +5 -0
- package/dist/esm/functions/unwrapName.js +20 -0
- package/dist/esm/functions/wrapName.d.ts +10 -0
- package/dist/esm/functions/wrapName.js +60 -0
- package/dist/esm/generated/BaseRegistrarImplementation.d.ts +508 -0
- package/dist/esm/generated/BaseRegistrarImplementation.js +1 -0
- package/dist/esm/generated/DNSRegistrar.d.ts +224 -0
- package/dist/esm/generated/DNSRegistrar.js +1 -0
- package/dist/esm/generated/DNSSECImpl.d.ts +402 -0
- package/dist/esm/generated/DNSSECImpl.js +1 -0
- package/dist/esm/generated/DefaultReverseResolver.d.ts +66 -0
- package/dist/esm/generated/DefaultReverseResolver.js +1 -0
- package/dist/esm/generated/ENSRegistry.d.ts +274 -0
- package/dist/esm/generated/ENSRegistry.js +1 -0
- package/dist/esm/generated/ETHRegistrarController.d.ts +321 -0
- package/dist/esm/generated/ETHRegistrarController.js +1 -0
- package/dist/esm/generated/Multicall.d.ts +292 -0
- package/dist/esm/generated/Multicall.js +1 -0
- package/dist/esm/generated/NameWrapper.d.ts +814 -0
- package/dist/esm/generated/NameWrapper.js +1 -0
- package/dist/esm/generated/P256SHA256Algorithm.d.ts +76 -0
- package/dist/esm/generated/P256SHA256Algorithm.js +1 -0
- package/dist/esm/generated/PublicResolver.d.ts +566 -0
- package/dist/esm/generated/PublicResolver.js +1 -0
- package/dist/esm/generated/RSASHA1Algorithm.d.ts +46 -0
- package/dist/esm/generated/RSASHA1Algorithm.js +1 -0
- package/dist/esm/generated/RSASHA256Algorithm.d.ts +46 -0
- package/dist/esm/generated/RSASHA256Algorithm.js +1 -0
- package/dist/esm/generated/ReverseRegistrar.d.ts +268 -0
- package/dist/esm/generated/ReverseRegistrar.js +1 -0
- package/dist/esm/generated/Root.d.ts +173 -0
- package/dist/esm/generated/Root.js +1 -0
- package/dist/esm/generated/SHA1Digest.d.ts +67 -0
- package/dist/esm/generated/SHA1Digest.js +1 -0
- package/dist/esm/generated/SHA1NSEC3Digest.d.ts +76 -0
- package/dist/esm/generated/SHA1NSEC3Digest.js +1 -0
- package/dist/esm/generated/SHA256Digest.d.ts +67 -0
- package/dist/esm/generated/SHA256Digest.js +1 -0
- package/dist/esm/generated/StaticMetadataService.d.ts +42 -0
- package/dist/esm/generated/StaticMetadataService.js +1 -0
- package/dist/esm/generated/TLDPublicSuffixList.d.ts +42 -0
- package/dist/esm/generated/TLDPublicSuffixList.js +1 -0
- package/dist/esm/generated/UniversalResolver.d.ts +82 -0
- package/dist/esm/generated/UniversalResolver.js +1 -0
- package/dist/esm/generated/common.d.ts +22 -0
- package/dist/esm/generated/common.js +1 -0
- package/dist/esm/generated/factories/BaseRegistrarImplementation__factory.d.ts +52 -0
- package/dist/esm/generated/factories/BaseRegistrarImplementation__factory.js +766 -0
- package/dist/esm/generated/factories/DNSRegistrar__factory.d.ts +67 -0
- package/dist/esm/generated/factories/DNSRegistrar__factory.js +269 -0
- package/dist/esm/generated/factories/DNSSECImpl__factory.d.ts +56 -0
- package/dist/esm/generated/factories/DNSSECImpl__factory.js +474 -0
- package/dist/esm/generated/factories/DefaultReverseResolver__factory.d.ts +36 -0
- package/dist/esm/generated/factories/DefaultReverseResolver__factory.js +83 -0
- package/dist/esm/generated/factories/ENSRegistry__factory.d.ts +52 -0
- package/dist/esm/generated/factories/ENSRegistry__factory.js +435 -0
- package/dist/esm/generated/factories/ETHRegistrarController__factory.d.ts +66 -0
- package/dist/esm/generated/factories/ETHRegistrarController__factory.js +517 -0
- package/dist/esm/generated/factories/Multicall__factory.d.ts +42 -0
- package/dist/esm/generated/factories/Multicall__factory.js +453 -0
- package/dist/esm/generated/factories/NameWrapper__factory.d.ts +57 -0
- package/dist/esm/generated/factories/NameWrapper__factory.js +1327 -0
- package/dist/esm/generated/factories/P256SHA256Algorithm__factory.d.ts +22 -0
- package/dist/esm/generated/factories/P256SHA256Algorithm__factory.js +44 -0
- package/dist/esm/generated/factories/PublicResolver__factory.d.ts +46 -0
- package/dist/esm/generated/factories/PublicResolver__factory.js +888 -0
- package/dist/esm/generated/factories/RSASHA1Algorithm__factory.d.ts +22 -0
- package/dist/esm/generated/factories/RSASHA1Algorithm__factory.js +44 -0
- package/dist/esm/generated/factories/RSASHA256Algorithm__factory.d.ts +22 -0
- package/dist/esm/generated/factories/RSASHA256Algorithm__factory.js +44 -0
- package/dist/esm/generated/factories/ReverseRegistrar__factory.d.ts +46 -0
- package/dist/esm/generated/factories/ReverseRegistrar__factory.js +336 -0
- package/dist/esm/generated/factories/Root__factory.d.ts +52 -0
- package/dist/esm/generated/factories/Root__factory.js +239 -0
- package/dist/esm/generated/factories/SHA1Digest__factory.d.ts +22 -0
- package/dist/esm/generated/factories/SHA1Digest__factory.js +39 -0
- package/dist/esm/generated/factories/SHA1NSEC3Digest__factory.d.ts +22 -0
- package/dist/esm/generated/factories/SHA1NSEC3Digest__factory.js +44 -0
- package/dist/esm/generated/factories/SHA256Digest__factory.d.ts +22 -0
- package/dist/esm/generated/factories/SHA256Digest__factory.js +39 -0
- package/dist/esm/generated/factories/StaticMetadataService__factory.d.ts +32 -0
- package/dist/esm/generated/factories/StaticMetadataService__factory.js +45 -0
- package/dist/esm/generated/factories/TLDPublicSuffixList__factory.d.ts +22 -0
- package/dist/esm/generated/factories/TLDPublicSuffixList__factory.js +34 -0
- package/dist/esm/generated/factories/UniversalResolver__factory.d.ts +42 -0
- package/dist/esm/generated/factories/UniversalResolver__factory.js +200 -0
- package/dist/esm/generated/factories/index.d.ts +20 -0
- package/dist/esm/generated/factories/index.js +23 -0
- package/dist/esm/generated/index.d.ts +41 -0
- package/dist/esm/generated/index.js +21 -0
- package/dist/esm/index.d.ts +478 -0
- package/dist/esm/index.js +213 -0
- package/dist/esm/utils/contentHash.d.ts +28 -0
- package/dist/esm/utils/contentHash.js +153 -0
- package/dist/esm/utils/createReverseNode.d.ts +2 -0
- package/dist/esm/utils/createReverseNode.js +1 -0
- package/dist/esm/utils/format.d.ts +3 -0
- package/dist/esm/utils/format.js +3 -0
- package/dist/esm/utils/fuses.d.ts +20 -0
- package/dist/esm/utils/fuses.js +21 -0
- package/dist/esm/utils/generateFuseInput.d.ts +3 -0
- package/dist/esm/utils/generateFuseInput.js +14 -0
- package/dist/esm/utils/hexEncodedName.d.ts +1 -0
- package/dist/esm/utils/hexEncodedName.js +2 -0
- package/dist/esm/utils/labels.d.ts +14 -0
- package/dist/esm/utils/labels.js +96 -0
- package/dist/esm/utils/makeHashIndexes.d.ts +2 -0
- package/dist/esm/utils/makeHashIndexes.js +3 -0
- package/dist/esm/utils/normalise.d.ts +2 -0
- package/dist/esm/utils/normalise.js +27 -0
- package/dist/esm/utils/recordHelpers.d.ts +16 -0
- package/dist/esm/utils/recordHelpers.js +65 -0
- package/dist/esm/utils/registerHelpers.d.ts +26 -0
- package/dist/esm/utils/registerHelpers.js +43 -0
- package/dist/esm/utils/singleCall.d.ts +9 -0
- package/dist/esm/utils/singleCall.js +5 -0
- package/dist/esm/utils/validation.d.ts +8 -0
- package/dist/esm/utils/validation.js +67 -0
- 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 +81 -49
- package/src/@types/@ensdomains/content-hash.d.ts +1 -0
- package/src/@types/@ensdomains/ens-contracts.d.ts +1 -0
- package/src/@types/FuseOptions.d.ts +9 -0
- package/src/@types/dns-packet/index.d.ts +114 -0
- package/src/@types/dns-packet.d.ts +1 -0
- package/src/@types/idna-uts46-hx.d.ts +1 -0
- package/src/ABIs/Multicall.json +452 -0
- package/src/GqlManager.test.ts +170 -0
- package/src/GqlManager.ts +83 -0
- package/src/contracts/baseRegistrar.ts +5 -0
- package/src/contracts/ethRegistrarController.ts +5 -0
- package/src/contracts/getContractAddress.ts +52 -0
- package/src/contracts/index.ts +68 -0
- package/src/contracts/multicall.ts +24 -0
- package/src/contracts/nameWrapper.ts +5 -0
- package/src/contracts/publicResolver.ts +5 -0
- package/src/contracts/registry.ts +5 -0
- package/src/contracts/reverseRegistrar.ts +5 -0
- package/src/contracts/types.ts +11 -0
- package/src/contracts/universalResolver.ts +5 -0
- package/src/functions/batch.test.ts +36 -0
- package/src/functions/batch.ts +36 -0
- package/src/functions/batchWrappers.test.ts +31 -0
- package/src/functions/batchWrappers.ts +91 -0
- package/src/functions/burnFuses.test.ts +40 -0
- package/src/functions/burnFuses.ts +21 -0
- package/src/functions/createSubname.test.ts +51 -0
- package/src/functions/createSubname.ts +88 -0
- package/src/functions/deleteSubname.test.ts +53 -0
- package/src/functions/deleteSubname.ts +17 -0
- 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 +141 -0
- package/src/functions/getFuses.test.ts +82 -0
- package/src/functions/getFuses.ts +70 -0
- package/src/functions/getHistory.test.ts +113 -0
- package/src/functions/getHistory.ts +347 -0
- package/src/functions/getName.test.ts +47 -0
- package/src/functions/getName.ts +41 -0
- package/src/functions/getNames.test.ts +276 -0
- package/src/functions/getNames.ts +275 -0
- package/src/functions/getOwner.test.ts +58 -0
- package/src/functions/getOwner.ts +202 -0
- package/src/functions/getPrice.ts +71 -0
- package/src/functions/getProfile.test.ts +143 -0
- package/src/functions/getProfile.ts +606 -0
- package/src/functions/getRecords.ts +23 -0
- package/src/functions/getResolver.test.ts +15 -0
- package/src/functions/getResolver.ts +32 -0
- package/src/functions/getSpecificRecord.test.ts +79 -0
- package/src/functions/getSpecificRecord.ts +371 -0
- package/src/functions/getSubnames.test.ts +35 -0
- package/src/functions/getSubnames.ts +197 -0
- package/src/functions/initialGetters.ts +11 -0
- package/src/functions/makeCommitment.test.ts +23 -0
- package/src/functions/normalise.test.ts +22 -0
- package/src/functions/setName.test.ts +58 -0
- package/src/functions/setName.ts +32 -0
- package/src/functions/setRecord.test.ts +103 -0
- package/src/functions/setRecord.ts +63 -0
- package/src/functions/setRecords.test.ts +61 -0
- package/src/functions/setRecords.ts +44 -0
- package/src/functions/setResolver.test.ts +54 -0
- package/src/functions/setResolver.ts +35 -0
- package/src/functions/transferName.test.ts +65 -0
- package/src/functions/transferName.ts +53 -0
- package/src/functions/transferSubname.test.ts +55 -0
- package/src/functions/transferSubname.ts +63 -0
- package/src/functions/unwrapName.test.ts +53 -0
- package/src/functions/unwrapName.ts +43 -0
- package/src/functions/wrapName.test.ts +142 -0
- package/src/functions/wrapName.ts +142 -0
- package/src/generated/BaseRegistrarImplementation.ts +1208 -0
- package/src/generated/DNSRegistrar.ts +459 -0
- package/src/generated/DNSSECImpl.ts +801 -0
- package/src/generated/DefaultReverseResolver.ts +153 -0
- package/src/generated/ENSRegistry.ts +691 -0
- package/src/generated/ETHRegistrarController.ts +804 -0
- package/src/generated/Multicall.ts +598 -0
- package/src/generated/NameWrapper.ts +2024 -0
- package/src/generated/P256SHA256Algorithm.ts +144 -0
- package/src/generated/PublicResolver.ts +1416 -0
- package/src/generated/RSASHA1Algorithm.ts +114 -0
- package/src/generated/RSASHA256Algorithm.ts +114 -0
- package/src/generated/ReverseRegistrar.ts +608 -0
- package/src/generated/Root.ts +437 -0
- package/src/generated/SHA1Digest.ts +130 -0
- package/src/generated/SHA1NSEC3Digest.ts +145 -0
- package/src/generated/SHA256Digest.ts +130 -0
- package/src/generated/StaticMetadataService.ts +101 -0
- package/src/generated/TLDPublicSuffixList.ts +103 -0
- package/src/generated/UniversalResolver.ts +264 -0
- package/src/generated/common.ts +46 -0
- package/src/generated/factories/BaseRegistrarImplementation__factory.ts +781 -0
- package/src/generated/factories/DNSRegistrar__factory.ts +277 -0
- package/src/generated/factories/DNSSECImpl__factory.ts +482 -0
- package/src/generated/factories/DefaultReverseResolver__factory.ts +98 -0
- package/src/generated/factories/ENSRegistry__factory.ts +443 -0
- package/src/generated/factories/ETHRegistrarController__factory.ts +532 -0
- package/src/generated/factories/Multicall__factory.ts +461 -0
- package/src/generated/factories/NameWrapper__factory.ts +1335 -0
- package/src/generated/factories/P256SHA256Algorithm__factory.ts +55 -0
- package/src/generated/factories/PublicResolver__factory.ts +899 -0
- package/src/generated/factories/RSASHA1Algorithm__factory.ts +55 -0
- package/src/generated/factories/RSASHA256Algorithm__factory.ts +55 -0
- package/src/generated/factories/ReverseRegistrar__factory.ts +347 -0
- package/src/generated/factories/Root__factory.ts +244 -0
- package/src/generated/factories/SHA1Digest__factory.ts +47 -0
- package/src/generated/factories/SHA1NSEC3Digest__factory.ts +55 -0
- package/src/generated/factories/SHA256Digest__factory.ts +47 -0
- package/src/generated/factories/StaticMetadataService__factory.ts +60 -0
- package/src/generated/factories/TLDPublicSuffixList__factory.ts +45 -0
- package/src/generated/factories/UniversalResolver__factory.ts +211 -0
- package/src/generated/factories/index.ts +23 -0
- package/src/generated/index.ts +44 -0
- package/src/index.ts +596 -0
- package/src/tests/populateTransaction.test.ts +40 -0
- package/src/tests/setup.ts +58 -0
- package/src/tests/signerInjection.test.ts +46 -0
- package/src/tests/withProvider.test.ts +28 -0
- package/src/utils/contentHash.ts +151 -0
- package/src/utils/createReverseNode.ts +2 -0
- package/src/utils/format.ts +8 -0
- package/src/utils/fuses.ts +23 -0
- package/src/utils/generateFuseInput.ts +18 -0
- package/src/utils/hexEncodedName.ts +4 -0
- package/src/utils/labels.ts +121 -0
- package/src/utils/makeHashIndexes.ts +9 -0
- package/src/utils/normalise.ts +33 -0
- package/src/utils/recordHelpers.ts +106 -0
- package/src/utils/registerHelpers.ts +87 -0
- package/src/utils/singleCall.ts +16 -0
- package/src/utils/validation.ts +73 -0
- package/src/utils/wrapperExpiry.ts +31 -0
- package/src/utils/writeTx.ts +6 -0
- package/dist/constants/interfaces.js +0 -13
- package/dist/index.js +0 -1135
- package/dist/utils/contents.js +0 -126
- package/dist/utils/index.js +0 -192
- package/dist/utils/labelhash.js +0 -55
- package/dist/utils/namehash.js +0 -39
- package/dist/utils/records.js +0 -56
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import ContractManager from './contracts';
|
|
2
|
+
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
3
|
+
import GqlManager from './GqlManager';
|
|
4
|
+
import singleCall from './utils/singleCall';
|
|
5
|
+
import writeTx from './utils/writeTx';
|
|
6
|
+
const graphURIEndpoints = {
|
|
7
|
+
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
8
|
+
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
9
|
+
4: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensrinkeby',
|
|
10
|
+
5: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensgoerli',
|
|
11
|
+
};
|
|
12
|
+
export class ENS {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.getContractAddress = _getContractAddress;
|
|
15
|
+
this.gqlInstance = new GqlManager();
|
|
16
|
+
/**
|
|
17
|
+
* Checks for an initial provider and if it exists, sets it as the provider
|
|
18
|
+
* @returns {Promise<void>} - A promise that resolves when the provider is checked, and set if needed
|
|
19
|
+
*/
|
|
20
|
+
this.checkInitialProvider = async () => {
|
|
21
|
+
if (!this.initialProvider) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await this.setProvider(this.initialProvider);
|
|
25
|
+
return;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Creates an object of ENS properties from an array
|
|
29
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
30
|
+
* @returns {Object} - An object of ENS properties
|
|
31
|
+
*/
|
|
32
|
+
this.forwardDependenciesFromArray = (dependencies) =>
|
|
33
|
+
// Creates an object from entries of the array
|
|
34
|
+
Object.fromEntries(
|
|
35
|
+
// Maps over dependencies and create arrays for each, e.g. ['contracts', contractObj]
|
|
36
|
+
dependencies.map((dep) => [dep, this[dep]]));
|
|
37
|
+
/**
|
|
38
|
+
* Creates a wrapper for a function to be dynamically imported, with the correct dependencies passed in
|
|
39
|
+
* @param {string} path - The path of the exported function
|
|
40
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
41
|
+
* @param {string} exportName - The export name of the target function
|
|
42
|
+
* @param {string} subFunc - The type of function being imported
|
|
43
|
+
* @returns {Function} - The generated wrapped function
|
|
44
|
+
*/
|
|
45
|
+
this.importGenerator = (path, dependencies, exportName = 'default', subFunc, passthrough) => {
|
|
46
|
+
// if batch is specified, create batch func
|
|
47
|
+
if (subFunc === 'batch') {
|
|
48
|
+
return (...args) => ({ args, ...passthrough });
|
|
49
|
+
}
|
|
50
|
+
const thisRef = this;
|
|
51
|
+
const mainFunc = async function (...args) {
|
|
52
|
+
// check the initial provider and set if it exists
|
|
53
|
+
await thisRef.checkInitialProvider();
|
|
54
|
+
// import the module dynamically
|
|
55
|
+
const mod = await import(
|
|
56
|
+
/* webpackMode: "lazy", webpackChunkName: "[request]", webpackPreload: true, webpackExclude: /.*\.ts$/ */
|
|
57
|
+
`./functions/${path}`);
|
|
58
|
+
// if combine isn't specified, run normally
|
|
59
|
+
// otherwise, create a function from the raw and decode functions
|
|
60
|
+
if (subFunc !== 'combine') {
|
|
61
|
+
const writeable = subFunc === 'write' || subFunc === 'populateTransaction';
|
|
62
|
+
// get the function to call
|
|
63
|
+
const func = subFunc && !writeable ? mod[exportName][subFunc] : mod[exportName];
|
|
64
|
+
// get the dependencies to forward to the function as the first arg
|
|
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
|
+
}
|
|
80
|
+
// return the function with the dependencies forwarded
|
|
81
|
+
return func(dependenciesToForward, ...args);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// get the dependencies to forward from raw and decode functions
|
|
85
|
+
const dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
|
|
86
|
+
// return singleCall function with dependencies forwarded
|
|
87
|
+
return singleCall(thisRef.provider, dependenciesToForward, mod[exportName], ...args);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// if subfunc is combine, add raw and decode property methods to the function
|
|
91
|
+
if (subFunc === 'combine') {
|
|
92
|
+
mainFunc.raw = this.importGenerator(path, dependencies, exportName, 'raw');
|
|
93
|
+
mainFunc.decode = this.importGenerator(path, dependencies, exportName, 'decode');
|
|
94
|
+
mainFunc.batch = this.importGenerator(path, dependencies, exportName, 'batch', { raw: mainFunc.raw, decode: mainFunc.decode });
|
|
95
|
+
}
|
|
96
|
+
else if (subFunc === 'write') {
|
|
97
|
+
mainFunc.populateTransaction = this.importGenerator(path, dependencies, exportName, 'populateTransaction');
|
|
98
|
+
}
|
|
99
|
+
return mainFunc;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Generates a normal wrapped function
|
|
103
|
+
* @param {string} path - The path of the exported function
|
|
104
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
105
|
+
* @param {string} exportName - The export name of the target function
|
|
106
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
107
|
+
*/
|
|
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');
|
|
117
|
+
/**
|
|
118
|
+
* Generates a wrapped function from raw and decode exports
|
|
119
|
+
* @param {string} path - The path of the exported function
|
|
120
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
121
|
+
* @param {string} exportName - The export name of the target function
|
|
122
|
+
* @returns {GeneratedRawFunction} - The generated wrapped function
|
|
123
|
+
*/
|
|
124
|
+
this.generateRawFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName, 'combine');
|
|
125
|
+
/**
|
|
126
|
+
* Sets the provider for the ENS class
|
|
127
|
+
* @param {ethers.providers.JsonRpcProvider} provider - The provider to set
|
|
128
|
+
* @returns {Promise<void>} - A promise that resolves when the provider is set
|
|
129
|
+
*/
|
|
130
|
+
this.setProvider = async (provider) => {
|
|
131
|
+
this.provider = provider;
|
|
132
|
+
const network = (await this.provider.getNetwork()).chainId;
|
|
133
|
+
if (this.options && this.options.graphURI) {
|
|
134
|
+
this.graphURI = this.options.graphURI;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.graphURI = graphURIEndpoints[network];
|
|
138
|
+
}
|
|
139
|
+
await this.gqlInstance.setUrl(this.graphURI);
|
|
140
|
+
this.contracts = new ContractManager(this.provider, this.getContractAddress(String(network)));
|
|
141
|
+
return;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new ENS instance with a different provider, ideally should be used individually with any given function
|
|
145
|
+
* @param {ethers.providers.JsonRpcProvider} provider - The provider to use
|
|
146
|
+
* @returns {ENS} - A new ENS instance with the given provider
|
|
147
|
+
*/
|
|
148
|
+
this.withProvider = (provider) => {
|
|
149
|
+
const newENS = new ENS(this.options);
|
|
150
|
+
newENS.initialProvider = provider;
|
|
151
|
+
return newENS;
|
|
152
|
+
};
|
|
153
|
+
this.batch = this.generateRawFunction('initialGetters', ['multicallWrapper'], 'batch');
|
|
154
|
+
this.getProfile = this.generateFunction('initialGetters', [
|
|
155
|
+
'contracts',
|
|
156
|
+
'gqlInstance',
|
|
157
|
+
'getName',
|
|
158
|
+
'resolverMulticallWrapper',
|
|
159
|
+
'multicallWrapper',
|
|
160
|
+
'_getAddr',
|
|
161
|
+
'_getContentHash',
|
|
162
|
+
'_getText',
|
|
163
|
+
], 'getProfile');
|
|
164
|
+
this.getRecords = this.generateFunction('initialGetters', ['getProfile'], 'getRecords');
|
|
165
|
+
this.getName = this.generateRawFunction('initialGetters', ['contracts'], 'getName');
|
|
166
|
+
this.getResolver = this.generateRawFunction('getResolver', ['contracts']);
|
|
167
|
+
this.getFuses = this.generateRawFunction('getFuses', [
|
|
168
|
+
'contracts',
|
|
169
|
+
]);
|
|
170
|
+
this.getHistory = this.generateFunction('getHistory', ['gqlInstance'], 'getHistory');
|
|
171
|
+
this.getHistoryWithDetail = this.generateFunction('getHistory', ['contracts', 'gqlInstance', 'provider'], 'getHistoryWithDetail');
|
|
172
|
+
this.getHistoryDetailForTransactionHash = this.generateFunction('getHistory', ['contracts', 'provider'], 'getHistoryDetailForTransactionHash');
|
|
173
|
+
this.getContentHash = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getContentHash');
|
|
174
|
+
this._getContentHash = this.generateRawFunction('initialGetters', ['contracts'], '_getContentHash');
|
|
175
|
+
this.getAddr = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getAddr');
|
|
176
|
+
this._getAddr = this.generateRawFunction('initialGetters', ['contracts'], '_getAddr');
|
|
177
|
+
this.getText = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getText');
|
|
178
|
+
this._getText = this.generateRawFunction('initialGetters', ['contracts'], '_getText');
|
|
179
|
+
this.getOwner = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getOwner');
|
|
180
|
+
this.getExpiry = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getExpiry');
|
|
181
|
+
this.getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
182
|
+
this.getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
183
|
+
this.getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
184
|
+
this.universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
185
|
+
this.resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
186
|
+
this.multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
187
|
+
this.setName = this.generateWriteFunction('setName', [
|
|
188
|
+
'contracts',
|
|
189
|
+
]);
|
|
190
|
+
this.setRecords = this.generateWriteFunction('setRecords', ['contracts', 'provider', 'getResolver']);
|
|
191
|
+
this.setRecord = this.generateWriteFunction('setRecord', [
|
|
192
|
+
'contracts',
|
|
193
|
+
'provider',
|
|
194
|
+
'getResolver',
|
|
195
|
+
]);
|
|
196
|
+
this.setResolver = this.generateWriteFunction('setResolver', ['contracts']);
|
|
197
|
+
this.transferName = this.generateWriteFunction('transferName', ['contracts']);
|
|
198
|
+
this.wrapName = this.generateWriteFunction('wrapName', [
|
|
199
|
+
'contracts',
|
|
200
|
+
'getExpiry',
|
|
201
|
+
]);
|
|
202
|
+
this.unwrapName = this.generateWriteFunction('unwrapName', ['contracts']);
|
|
203
|
+
this.burnFuses = this.generateWriteFunction('burnFuses', [
|
|
204
|
+
'contracts',
|
|
205
|
+
]);
|
|
206
|
+
this.createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
207
|
+
this.deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
208
|
+
this.transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
209
|
+
this.getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
210
|
+
this.options = options;
|
|
211
|
+
this.getContractAddress = options?.getContractAddress || _getContractAddress;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare type DecodedContentHash = {
|
|
2
|
+
protocolType?: any;
|
|
3
|
+
decoded?: any;
|
|
4
|
+
error?: any;
|
|
5
|
+
};
|
|
6
|
+
export declare function decodeContenthash(encoded: any): {
|
|
7
|
+
protocolType?: undefined;
|
|
8
|
+
decoded?: undefined;
|
|
9
|
+
error?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
protocolType: null;
|
|
12
|
+
decoded: any;
|
|
13
|
+
error?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
protocolType: string | undefined;
|
|
16
|
+
decoded: any;
|
|
17
|
+
error: any;
|
|
18
|
+
};
|
|
19
|
+
export declare function validateContent(encoded: any): any;
|
|
20
|
+
export declare function isValidContenthash(encoded: any): boolean | undefined;
|
|
21
|
+
export declare function getProtocolType(encoded: any): {
|
|
22
|
+
protocolType: string | undefined;
|
|
23
|
+
decoded: string | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
export declare function encodeContenthash(text: string): {
|
|
26
|
+
encoded: string | boolean;
|
|
27
|
+
error: string | undefined;
|
|
28
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import contentHash from '@ensdomains/content-hash';
|
|
2
|
+
import { utils } from 'ethers';
|
|
3
|
+
const supportedCodecs = [
|
|
4
|
+
'ipns-ns',
|
|
5
|
+
'ipfs-ns',
|
|
6
|
+
'swarm-ns',
|
|
7
|
+
'onion',
|
|
8
|
+
'onion3',
|
|
9
|
+
'skynet-ns',
|
|
10
|
+
'arweave-ns',
|
|
11
|
+
];
|
|
12
|
+
function matchProtocol(text) {
|
|
13
|
+
return (text.match(/^(ipfs|sia|ipns|bzz|onion|onion3|arweave):\/\/(.*)/) ||
|
|
14
|
+
text.match(/\/(ipfs)\/(.*)/) ||
|
|
15
|
+
text.match(/\/(ipns)\/(.*)/));
|
|
16
|
+
}
|
|
17
|
+
export function decodeContenthash(encoded) {
|
|
18
|
+
let decoded, protocolType, error;
|
|
19
|
+
if (!encoded || encoded === '0x') {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
if (encoded.error) {
|
|
23
|
+
return { protocolType: null, decoded: encoded.error };
|
|
24
|
+
}
|
|
25
|
+
else if (encoded === false) {
|
|
26
|
+
return { protocolType: null, decoded: 'invalid value' };
|
|
27
|
+
}
|
|
28
|
+
if (encoded) {
|
|
29
|
+
try {
|
|
30
|
+
decoded = contentHash.decode(encoded);
|
|
31
|
+
const codec = contentHash.getCodec(encoded);
|
|
32
|
+
if (codec === 'ipfs-ns') {
|
|
33
|
+
protocolType = 'ipfs';
|
|
34
|
+
}
|
|
35
|
+
else if (codec === 'ipns-ns') {
|
|
36
|
+
protocolType = 'ipns';
|
|
37
|
+
}
|
|
38
|
+
else if (codec === 'swarm-ns') {
|
|
39
|
+
protocolType = 'bzz';
|
|
40
|
+
}
|
|
41
|
+
else if (codec === 'onion') {
|
|
42
|
+
protocolType = 'onion';
|
|
43
|
+
}
|
|
44
|
+
else if (codec === 'onion3') {
|
|
45
|
+
protocolType = 'onion3';
|
|
46
|
+
}
|
|
47
|
+
else if (codec === 'skynet-ns') {
|
|
48
|
+
protocolType = 'sia';
|
|
49
|
+
}
|
|
50
|
+
else if (codec === 'arweave-ns') {
|
|
51
|
+
protocolType = 'arweave';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
decoded = encoded;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
error = e.message;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { protocolType, decoded, error };
|
|
62
|
+
}
|
|
63
|
+
export function validateContent(encoded) {
|
|
64
|
+
return (contentHash.isHashOfType(encoded, contentHash.Types.ipfs) ||
|
|
65
|
+
contentHash.isHashOfType(encoded, contentHash.Types.swarm));
|
|
66
|
+
}
|
|
67
|
+
export function isValidContenthash(encoded) {
|
|
68
|
+
try {
|
|
69
|
+
const codec = contentHash.getCodec(encoded);
|
|
70
|
+
return utils.isHexString(encoded) && supportedCodecs.includes(codec);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.log(e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function getProtocolType(encoded) {
|
|
77
|
+
let protocolType, decoded;
|
|
78
|
+
try {
|
|
79
|
+
let matched = matchProtocol(encoded);
|
|
80
|
+
if (matched) {
|
|
81
|
+
protocolType = matched[1];
|
|
82
|
+
decoded = matched[2];
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
protocolType,
|
|
86
|
+
decoded,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.log(e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function encodeContenthash(text) {
|
|
94
|
+
let content = text;
|
|
95
|
+
let contentType;
|
|
96
|
+
let encoded = false;
|
|
97
|
+
let error;
|
|
98
|
+
if (!!text) {
|
|
99
|
+
let matched = matchProtocol(text);
|
|
100
|
+
if (matched) {
|
|
101
|
+
contentType = matched[1];
|
|
102
|
+
content = matched[2];
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
if (contentType === 'ipfs') {
|
|
106
|
+
if (content.length >= 4) {
|
|
107
|
+
encoded = '0x' + contentHash.encode('ipfs-ns', content);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (contentType === 'ipns') {
|
|
111
|
+
encoded = '0x' + contentHash.encode('ipns-ns', content);
|
|
112
|
+
}
|
|
113
|
+
else if (contentType === 'bzz') {
|
|
114
|
+
if (content.length >= 4) {
|
|
115
|
+
encoded = '0x' + contentHash.fromSwarm(content);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (contentType === 'onion') {
|
|
119
|
+
if (content.length == 16) {
|
|
120
|
+
encoded = '0x' + contentHash.encode('onion', content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else if (contentType === 'onion3') {
|
|
124
|
+
if (content.length == 56) {
|
|
125
|
+
encoded = '0x' + contentHash.encode('onion3', content);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (contentType === 'sia') {
|
|
129
|
+
if (content.length == 46) {
|
|
130
|
+
encoded = '0x' + contentHash.encode('skynet-ns', content);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (contentType === 'arweave') {
|
|
134
|
+
if (content.length == 43) {
|
|
135
|
+
encoded = '0x' + contentHash.encode('arweave-ns', content);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
console.warn('Unsupported protocol or invalid value', {
|
|
140
|
+
contentType,
|
|
141
|
+
text,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
const errorMessage = 'Error encoding content hash';
|
|
147
|
+
console.warn(errorMessage, { text, encoded });
|
|
148
|
+
error = errorMessage;
|
|
149
|
+
//throw 'Error encoding content hash'
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return { encoded, error };
|
|
153
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (address) => address.toLowerCase().substring(2) + '.addr.reverse';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const testable: {
|
|
2
|
+
CANNOT_UNWRAP: number;
|
|
3
|
+
CANNOT_BURN_FUSES: number;
|
|
4
|
+
CANNOT_TRANSFER: number;
|
|
5
|
+
CANNOT_SET_RESOLVER: number;
|
|
6
|
+
CANNOT_SET_TTL: number;
|
|
7
|
+
CANNOT_CREATE_SUBDOMAIN: number;
|
|
8
|
+
PARENT_CANNOT_CONTROL: number;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: {
|
|
11
|
+
CAN_DO_EVERYTHING: number;
|
|
12
|
+
CANNOT_UNWRAP: number;
|
|
13
|
+
CANNOT_BURN_FUSES: number;
|
|
14
|
+
CANNOT_TRANSFER: number;
|
|
15
|
+
CANNOT_SET_RESOLVER: number;
|
|
16
|
+
CANNOT_SET_TTL: number;
|
|
17
|
+
CANNOT_CREATE_SUBDOMAIN: number;
|
|
18
|
+
PARENT_CANNOT_CONTROL: number;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const CANNOT_UNWRAP = 1;
|
|
2
|
+
const CANNOT_BURN_FUSES = 2;
|
|
3
|
+
const CANNOT_TRANSFER = 4;
|
|
4
|
+
const CANNOT_SET_RESOLVER = 8;
|
|
5
|
+
const CANNOT_SET_TTL = 16;
|
|
6
|
+
const CANNOT_CREATE_SUBDOMAIN = 32;
|
|
7
|
+
const PARENT_CANNOT_CONTROL = 64;
|
|
8
|
+
const CAN_DO_EVERYTHING = 0;
|
|
9
|
+
export const testable = {
|
|
10
|
+
CANNOT_UNWRAP,
|
|
11
|
+
CANNOT_BURN_FUSES,
|
|
12
|
+
CANNOT_TRANSFER,
|
|
13
|
+
CANNOT_SET_RESOLVER,
|
|
14
|
+
CANNOT_SET_TTL,
|
|
15
|
+
CANNOT_CREATE_SUBDOMAIN,
|
|
16
|
+
PARENT_CANNOT_CONTROL,
|
|
17
|
+
};
|
|
18
|
+
export default {
|
|
19
|
+
...testable,
|
|
20
|
+
CAN_DO_EVERYTHING,
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import fuses from './fuses';
|
|
3
|
+
export default (fuseOptions) => {
|
|
4
|
+
const fuseKeys = Object.keys(fuseOptions)
|
|
5
|
+
.filter((opt) => fuseOptions[opt] === true)
|
|
6
|
+
.map((opt) => opt
|
|
7
|
+
.split(/(?=[A-Z])/)
|
|
8
|
+
.join('_')
|
|
9
|
+
.toUpperCase());
|
|
10
|
+
const bigNumberFuses = fuseKeys.reduce((prev, curr) => {
|
|
11
|
+
return prev.or(fuses[curr]);
|
|
12
|
+
}, ethers.BigNumber.from(0));
|
|
13
|
+
return bigNumberFuses.toHexString();
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hexEncodeName: (name: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const labelhash: (input: string) => string;
|
|
2
|
+
export declare const keccakFromString: (input: string) => string;
|
|
3
|
+
export declare function decodeLabelhash(hash: string): string;
|
|
4
|
+
export declare function encodeLabelhash(hash: string): string;
|
|
5
|
+
export declare function isEncodedLabelhash(hash: string): boolean;
|
|
6
|
+
export declare function saveLabel(label: string): string;
|
|
7
|
+
export declare function saveName(name: string): void;
|
|
8
|
+
export declare function checkLabel(hash: string): string | undefined;
|
|
9
|
+
export declare function encodeLabel(label: any): any;
|
|
10
|
+
export declare function parseName(name: string): string;
|
|
11
|
+
export declare function checkIsDecrypted(string: string | string[]): boolean;
|
|
12
|
+
export declare function decryptName(name: string): string;
|
|
13
|
+
export declare const truncateUndecryptedName: (name: string) => string;
|
|
14
|
+
export declare function checkLocalStorageSize(): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { solidityKeccak256 } from 'ethers/lib/utils';
|
|
2
|
+
import { truncateFormat } from './format';
|
|
3
|
+
const hasLocalStorage = typeof localStorage !== 'undefined';
|
|
4
|
+
export const labelhash = (input) => solidityKeccak256(['string'], [input]);
|
|
5
|
+
export const keccakFromString = (input) => labelhash(input);
|
|
6
|
+
export function decodeLabelhash(hash) {
|
|
7
|
+
if (!(hash.startsWith('[') && hash.endsWith(']'))) {
|
|
8
|
+
throw Error('Expected encoded labelhash to start and end with square brackets');
|
|
9
|
+
}
|
|
10
|
+
if (hash.length !== 66) {
|
|
11
|
+
throw Error('Expected encoded labelhash to have a length of 66');
|
|
12
|
+
}
|
|
13
|
+
return `0x${hash.slice(1, -1)}`;
|
|
14
|
+
}
|
|
15
|
+
export function encodeLabelhash(hash) {
|
|
16
|
+
if (!hash.startsWith('0x')) {
|
|
17
|
+
throw new Error('Expected label hash to start with 0x');
|
|
18
|
+
}
|
|
19
|
+
if (hash.length !== 66) {
|
|
20
|
+
throw new Error('Expected label hash to have a length of 66');
|
|
21
|
+
}
|
|
22
|
+
return `[${hash.slice(2)}]`;
|
|
23
|
+
}
|
|
24
|
+
export function isEncodedLabelhash(hash) {
|
|
25
|
+
return hash.startsWith('[') && hash.endsWith(']') && hash.length === 66;
|
|
26
|
+
}
|
|
27
|
+
function getLabels() {
|
|
28
|
+
return hasLocalStorage
|
|
29
|
+
? JSON.parse(localStorage.getItem('ensjs:labels')) || {}
|
|
30
|
+
: {};
|
|
31
|
+
}
|
|
32
|
+
function _saveLabel(hash, label) {
|
|
33
|
+
if (!hasLocalStorage)
|
|
34
|
+
return hash;
|
|
35
|
+
const labels = getLabels();
|
|
36
|
+
localStorage.setItem('ensjs:labels', JSON.stringify({
|
|
37
|
+
...labels,
|
|
38
|
+
[hash]: label,
|
|
39
|
+
}));
|
|
40
|
+
return hash;
|
|
41
|
+
}
|
|
42
|
+
export function saveLabel(label) {
|
|
43
|
+
const hash = `${labelhash(label.toLowerCase())}`;
|
|
44
|
+
return _saveLabel(hash, label);
|
|
45
|
+
}
|
|
46
|
+
export function saveName(name) {
|
|
47
|
+
const nameArray = name.split('.');
|
|
48
|
+
nameArray.forEach((label) => {
|
|
49
|
+
saveLabel(label);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// eslint-disable-next-line consistent-return
|
|
53
|
+
export function checkLabel(hash) {
|
|
54
|
+
const labels = getLabels();
|
|
55
|
+
if (isEncodedLabelhash(hash)) {
|
|
56
|
+
return labels[decodeLabelhash(hash)];
|
|
57
|
+
}
|
|
58
|
+
if (hash.startsWith('0x')) {
|
|
59
|
+
return labels[`${hash.slice(2)}`];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function encodeLabel(label) {
|
|
63
|
+
try {
|
|
64
|
+
return encodeLabelhash(label);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return label;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function parseName(name) {
|
|
71
|
+
const nameArray = name.split('.');
|
|
72
|
+
return nameArray.map((label) => encodeLabel(label)).join('.');
|
|
73
|
+
}
|
|
74
|
+
export function checkIsDecrypted(string) {
|
|
75
|
+
return !string?.includes('[');
|
|
76
|
+
}
|
|
77
|
+
export function decryptName(name) {
|
|
78
|
+
return name
|
|
79
|
+
.split('.')
|
|
80
|
+
.map((label) => checkLabel(label) || label)
|
|
81
|
+
.join('.');
|
|
82
|
+
}
|
|
83
|
+
export const truncateUndecryptedName = (name) => truncateFormat(name);
|
|
84
|
+
export function checkLocalStorageSize() {
|
|
85
|
+
if (!hasLocalStorage)
|
|
86
|
+
return 'Empty (0 KB)';
|
|
87
|
+
let allStrings = '';
|
|
88
|
+
for (const key in window.localStorage) {
|
|
89
|
+
if (Object.prototype.hasOwnProperty.call(window.localStorage, key)) {
|
|
90
|
+
allStrings += window.localStorage[key];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return allStrings
|
|
94
|
+
? `${3 + (allStrings.length * 16) / (8 * 1024)} KB`
|
|
95
|
+
: 'Empty (0 KB)';
|
|
96
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { namehash } from './normalise';
|
|
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(namehash(name).substring(2))).map((x) => x.index / 2 - 1);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { concat, hexlify, keccak256, toUtf8Bytes } from 'ethers/lib/utils';
|
|
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);
|
|
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
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PublicResolver } from '../generated';
|
|
2
|
+
declare type RecordItem = {
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type RecordOptions = {
|
|
7
|
+
contentHash?: string;
|
|
8
|
+
texts?: RecordItem[];
|
|
9
|
+
coinTypes?: RecordItem[];
|
|
10
|
+
};
|
|
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;
|
|
15
|
+
export declare const generateRecordCallArray: (namehash: string, records: RecordOptions, resolver: PublicResolver) => string[];
|
|
16
|
+
export {};
|