@ensdomains/ensjs 3.0.0-alpha.39 → 3.0.0-alpha.40
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/dist/cjs/GqlManager.js +8 -5
- package/dist/cjs/contracts/factories.js +16 -0
- package/dist/cjs/contracts/getContractAddress.js +1 -1
- package/dist/cjs/contracts/index.js +24 -52
- package/dist/cjs/functions/createSubname.js +2 -2
- package/dist/cjs/functions/deleteSubname.js +2 -2
- package/dist/cjs/functions/getDNSOwner.js +2 -2
- package/dist/cjs/functions/getExpiry.js +2 -2
- package/dist/cjs/functions/getHistory.js +4 -3
- package/dist/cjs/functions/getNames.js +2 -1
- package/dist/cjs/functions/getOwner.js +10 -9
- package/dist/cjs/functions/getPrice.js +7 -6
- package/dist/cjs/functions/getProfile.js +15 -16
- package/dist/cjs/functions/getResolver.js +2 -2
- package/dist/cjs/functions/getSpecificRecord.js +3 -3
- package/dist/cjs/functions/getSubnames.js +2 -1
- package/dist/cjs/functions/getWrapperData.js +2 -2
- package/dist/cjs/functions/transferController.js +3 -3
- package/dist/cjs/functions/transferName.js +2 -2
- package/dist/cjs/functions/transferSubname.js +2 -2
- package/dist/cjs/functions/types.js +16 -0
- package/dist/cjs/functions/unwrapName.js +2 -2
- package/dist/cjs/functions/wrapName.js +4 -3
- package/dist/cjs/generated/factories/BaseRegistrarImplementation__factory.js +4 -3
- package/dist/cjs/generated/factories/BulkRenewal__factory.js +4 -3
- package/dist/cjs/generated/factories/DNSRegistrar__factory.js +4 -3
- package/dist/cjs/generated/factories/DNSSECImpl__factory.js +4 -3
- package/dist/cjs/generated/factories/DefaultReverseResolver__factory.js +4 -3
- package/dist/cjs/generated/factories/ENSRegistry__factory.js +4 -3
- package/dist/cjs/generated/factories/ETHRegistrarController__factory.js +4 -3
- package/dist/cjs/generated/factories/Multicall__factory.js +4 -3
- package/dist/cjs/generated/factories/NameWrapper__factory.js +4 -3
- package/dist/cjs/generated/factories/P256SHA256Algorithm__factory.js +4 -3
- package/dist/cjs/generated/factories/PublicResolver__factory.js +4 -3
- package/dist/cjs/generated/factories/RSASHA1Algorithm__factory.js +4 -3
- package/dist/cjs/generated/factories/RSASHA256Algorithm__factory.js +4 -3
- package/dist/cjs/generated/factories/ReverseRegistrar__factory.js +4 -3
- package/dist/cjs/generated/factories/Root__factory.js +4 -3
- package/dist/cjs/generated/factories/SHA1Digest__factory.js +4 -3
- package/dist/cjs/generated/factories/SHA1NSEC3Digest__factory.js +4 -3
- package/dist/cjs/generated/factories/SHA256Digest__factory.js +4 -3
- package/dist/cjs/generated/factories/StaticMetadataService__factory.js +4 -3
- package/dist/cjs/generated/factories/TLDPublicSuffixList__factory.js +4 -3
- package/dist/cjs/generated/factories/UniversalResolver__factory.js +4 -3
- package/dist/cjs/index.js +52 -75
- package/dist/cjs/static.js +85 -0
- package/dist/cjs/utils/ccip.js +22 -21
- package/dist/cjs/utils/contentHash.js +2 -2
- package/dist/cjs/utils/fuses.js +2 -2
- package/dist/cjs/utils/generateFuseInput.js +2 -2
- package/dist/cjs/utils/labels.js +2 -2
- package/dist/cjs/utils/normalise.js +6 -4
- package/dist/cjs/utils/registerHelpers.js +4 -3
- package/dist/cjs/utils/validation.js +2 -2
- package/dist/cjs/utils/wrapper.js +8 -8
- package/dist/esm/GqlManager.mjs +8 -5
- package/dist/esm/contracts/factories.mjs +0 -0
- package/dist/esm/contracts/getContractAddress.mjs +1 -1
- package/dist/esm/contracts/index.mjs +24 -46
- package/dist/esm/functions/createSubname.mjs +2 -2
- package/dist/esm/functions/deleteSubname.mjs +2 -2
- package/dist/esm/functions/getDNSOwner.mjs +1 -1
- package/dist/esm/functions/getExpiry.mjs +1 -1
- package/dist/esm/functions/getHistory.mjs +4 -3
- package/dist/esm/functions/getNames.mjs +2 -1
- package/dist/esm/functions/getOwner.mjs +9 -8
- package/dist/esm/functions/getPrice.mjs +6 -5
- package/dist/esm/functions/getProfile.mjs +14 -15
- package/dist/esm/functions/getResolver.mjs +2 -2
- package/dist/esm/functions/getSpecificRecord.mjs +3 -3
- package/dist/esm/functions/getSubnames.mjs +2 -1
- package/dist/esm/functions/getWrapperData.mjs +1 -1
- package/dist/esm/functions/transferController.mjs +3 -3
- package/dist/esm/functions/transferName.mjs +2 -2
- package/dist/esm/functions/transferSubname.mjs +2 -2
- package/dist/esm/functions/types.mjs +0 -0
- package/dist/esm/functions/unwrapName.mjs +2 -2
- package/dist/esm/functions/wrapName.mjs +4 -3
- package/dist/esm/generated/factories/BaseRegistrarImplementation__factory.mjs +3 -2
- package/dist/esm/generated/factories/BulkRenewal__factory.mjs +3 -2
- package/dist/esm/generated/factories/DNSRegistrar__factory.mjs +3 -2
- package/dist/esm/generated/factories/DNSSECImpl__factory.mjs +3 -2
- package/dist/esm/generated/factories/DefaultReverseResolver__factory.mjs +3 -2
- package/dist/esm/generated/factories/ENSRegistry__factory.mjs +3 -2
- package/dist/esm/generated/factories/ETHRegistrarController__factory.mjs +3 -2
- package/dist/esm/generated/factories/Multicall__factory.mjs +3 -2
- package/dist/esm/generated/factories/NameWrapper__factory.mjs +3 -2
- package/dist/esm/generated/factories/P256SHA256Algorithm__factory.mjs +3 -2
- package/dist/esm/generated/factories/PublicResolver__factory.mjs +3 -2
- package/dist/esm/generated/factories/RSASHA1Algorithm__factory.mjs +3 -2
- package/dist/esm/generated/factories/RSASHA256Algorithm__factory.mjs +3 -2
- package/dist/esm/generated/factories/ReverseRegistrar__factory.mjs +3 -2
- package/dist/esm/generated/factories/Root__factory.mjs +3 -2
- package/dist/esm/generated/factories/SHA1Digest__factory.mjs +3 -2
- package/dist/esm/generated/factories/SHA1NSEC3Digest__factory.mjs +3 -2
- package/dist/esm/generated/factories/SHA256Digest__factory.mjs +3 -2
- package/dist/esm/generated/factories/StaticMetadataService__factory.mjs +3 -2
- package/dist/esm/generated/factories/TLDPublicSuffixList__factory.mjs +3 -2
- package/dist/esm/generated/factories/UniversalResolver__factory.mjs +3 -2
- package/dist/esm/index.mjs +47 -71
- package/dist/esm/static.mjs +62 -0
- package/dist/esm/utils/ccip.mjs +4 -4
- package/dist/esm/utils/contentHash.mjs +2 -2
- package/dist/esm/utils/fuses.mjs +1 -1
- package/dist/esm/utils/generateFuseInput.mjs +2 -2
- package/dist/esm/utils/labels.mjs +1 -1
- package/dist/esm/utils/normalise.mjs +3 -1
- package/dist/esm/utils/registerHelpers.mjs +4 -3
- package/dist/esm/utils/validation.mjs +1 -1
- package/dist/esm/utils/wrapper.mjs +2 -2
- package/dist/types/GqlManager.d.ts +5 -3
- package/dist/types/contracts/baseRegistrar.d.ts +2 -2
- package/dist/types/contracts/bulkRenewal.d.ts +2 -2
- package/dist/types/contracts/dnsRegistrar.d.ts +2 -2
- package/dist/types/contracts/ethRegistrarController.d.ts +2 -2
- package/dist/types/contracts/factories.d.ts +45 -0
- package/dist/types/contracts/index.d.ts +32 -12
- package/dist/types/contracts/multicall.d.ts +2 -2
- package/dist/types/contracts/nameWrapper.d.ts +2 -2
- package/dist/types/contracts/publicResolver.d.ts +2 -2
- package/dist/types/contracts/registry.d.ts +2 -2
- package/dist/types/contracts/reverseRegistrar.d.ts +2 -2
- package/dist/types/contracts/types.d.ts +1 -1
- package/dist/types/contracts/universalResolver.d.ts +2 -2
- package/dist/types/functions/batchWrappers.d.ts +4 -4
- package/dist/types/functions/burnFuses.d.ts +1 -1
- package/dist/types/functions/commitName.d.ts +7 -7
- package/dist/types/functions/createSubname.d.ts +1 -2
- package/dist/types/functions/deleteSubname.d.ts +1 -2
- package/dist/types/functions/getPrice.d.ts +1 -1
- package/dist/types/functions/getRecords.d.ts +2 -2
- package/dist/types/functions/getWrapperData.d.ts +1 -1
- package/dist/types/functions/importDNSSECName.d.ts +1 -1
- package/dist/types/functions/registerName.d.ts +2 -2
- package/dist/types/functions/renewNames.d.ts +3 -3
- package/dist/types/functions/setName.d.ts +1 -1
- package/dist/types/functions/setRecords.d.ts +1 -1
- package/dist/types/functions/setResolver.d.ts +1 -1
- package/dist/types/functions/transferController.d.ts +1 -2
- package/dist/types/functions/transferName.d.ts +1 -2
- package/dist/types/functions/transferSubname.d.ts +1 -2
- package/dist/types/functions/types.d.ts +77 -0
- package/dist/types/functions/unwrapName.d.ts +1 -1
- package/dist/types/functions/wrapName.d.ts +1 -2
- package/dist/types/generated/BaseRegistrarImplementation.d.ts +128 -124
- package/dist/types/generated/BulkRenewal.d.ts +22 -18
- package/dist/types/generated/DNSRegistrar.d.ts +46 -42
- package/dist/types/generated/DNSSECImpl.d.ts +70 -66
- package/dist/types/generated/DefaultReverseResolver.d.ts +19 -15
- package/dist/types/generated/ENSRegistry.d.ts +64 -60
- package/dist/types/generated/ETHRegistrarController.d.ts +82 -78
- package/dist/types/generated/Multicall.d.ts +58 -54
- package/dist/types/generated/NameWrapper.d.ts +169 -165
- package/dist/types/generated/P256SHA256Algorithm.d.ts +13 -9
- package/dist/types/generated/PublicResolver.d.ts +153 -149
- package/dist/types/generated/RSASHA1Algorithm.d.ts +13 -9
- package/dist/types/generated/RSASHA256Algorithm.d.ts +13 -9
- package/dist/types/generated/ReverseRegistrar.d.ts +64 -60
- package/dist/types/generated/Root.d.ts +46 -42
- package/dist/types/generated/SHA1Digest.d.ts +13 -9
- package/dist/types/generated/SHA1NSEC3Digest.d.ts +13 -9
- package/dist/types/generated/SHA256Digest.d.ts +13 -9
- package/dist/types/generated/StaticMetadataService.d.ts +13 -9
- package/dist/types/generated/TLDPublicSuffixList.d.ts +13 -9
- package/dist/types/generated/UniversalResolver.d.ts +82 -78
- package/dist/types/generated/common.d.ts +3 -3
- package/dist/types/generated/factories/BaseRegistrarImplementation__factory.d.ts +3 -3
- package/dist/types/generated/factories/BulkRenewal__factory.d.ts +3 -3
- package/dist/types/generated/factories/DNSRegistrar__factory.d.ts +3 -3
- package/dist/types/generated/factories/DNSSECImpl__factory.d.ts +3 -3
- package/dist/types/generated/factories/DefaultReverseResolver__factory.d.ts +3 -3
- package/dist/types/generated/factories/ENSRegistry__factory.d.ts +3 -3
- package/dist/types/generated/factories/ETHRegistrarController__factory.d.ts +3 -3
- package/dist/types/generated/factories/Multicall__factory.d.ts +3 -3
- package/dist/types/generated/factories/NameWrapper__factory.d.ts +3 -3
- package/dist/types/generated/factories/P256SHA256Algorithm__factory.d.ts +3 -3
- package/dist/types/generated/factories/PublicResolver__factory.d.ts +3 -3
- package/dist/types/generated/factories/RSASHA1Algorithm__factory.d.ts +3 -3
- package/dist/types/generated/factories/RSASHA256Algorithm__factory.d.ts +3 -3
- package/dist/types/generated/factories/ReverseRegistrar__factory.d.ts +3 -3
- package/dist/types/generated/factories/Root__factory.d.ts +3 -3
- package/dist/types/generated/factories/SHA1Digest__factory.d.ts +3 -3
- package/dist/types/generated/factories/SHA1NSEC3Digest__factory.d.ts +3 -3
- package/dist/types/generated/factories/SHA256Digest__factory.d.ts +3 -3
- package/dist/types/generated/factories/StaticMetadataService__factory.d.ts +3 -3
- package/dist/types/generated/factories/TLDPublicSuffixList__factory.d.ts +3 -3
- package/dist/types/generated/factories/UniversalResolver__factory.d.ts +3 -3
- package/dist/types/index.d.ts +45 -59
- package/dist/types/static.d.ts +26 -0
- package/dist/types/utils/fuses.d.ts +1 -1
- package/dist/types/utils/registerHelpers.d.ts +1 -1
- package/dist/types/utils/singleCall.d.ts +2 -2
- package/dist/types/utils/wrapper.d.ts +1 -1
- package/dist/types/utils/writeTx.d.ts +8 -8
- package/package.json +33 -6
- package/src/GqlManager.ts +15 -7
- package/src/contracts/baseRegistrar.ts +2 -2
- package/src/contracts/bulkRenewal.ts +2 -2
- package/src/contracts/dnsRegistrar.ts +2 -2
- package/src/contracts/ethRegistrarController.ts +2 -2
- package/src/contracts/factories.ts +48 -0
- package/src/contracts/getContractAddress.ts +1 -1
- package/src/contracts/index.ts +71 -67
- package/src/contracts/multicall.ts +2 -2
- package/src/contracts/nameWrapper.ts +2 -2
- package/src/contracts/publicResolver.ts +2 -2
- package/src/contracts/registry.ts +2 -2
- package/src/contracts/reverseRegistrar.ts +2 -2
- package/src/contracts/types.ts +1 -1
- package/src/contracts/universalResolver.ts +2 -2
- package/src/functions/batchWrappers.ts +3 -3
- package/src/functions/createSubname.ts +3 -2
- package/src/functions/deleteSubname.ts +2 -2
- package/src/functions/getDNSOwner.ts +1 -1
- package/src/functions/getExpiry.ts +2 -2
- package/src/functions/getHistory.ts +4 -3
- package/src/functions/getNames.ts +2 -1
- package/src/functions/getOwner.test.ts +0 -47
- package/src/functions/getOwner.ts +13 -14
- package/src/functions/getPrice.ts +6 -5
- package/src/functions/getProfile.ts +15 -15
- package/src/functions/getResolver.ts +2 -6
- package/src/functions/getSpecificRecord.ts +4 -4
- package/src/functions/getSubnames.ts +2 -1
- package/src/functions/getWrapperData.ts +1 -1
- package/src/functions/registerName.ts +1 -1
- package/src/functions/renewNames.ts +1 -1
- package/src/functions/transferController.ts +4 -3
- package/src/functions/transferName.ts +2 -2
- package/src/functions/transferSubname.ts +2 -2
- package/src/functions/types.ts +94 -0
- package/src/functions/unwrapName.ts +3 -2
- package/src/functions/wrapName.ts +8 -5
- package/src/generated/BaseRegistrarImplementation.ts +580 -593
- package/src/generated/BulkRenewal.ts +95 -96
- package/src/generated/DNSRegistrar.ts +208 -208
- package/src/generated/DNSSECImpl.ts +322 -329
- package/src/generated/DefaultReverseResolver.ts +75 -75
- package/src/generated/ENSRegistry.ts +312 -316
- package/src/generated/ETHRegistrarController.ts +405 -412
- package/src/generated/Multicall.ts +320 -327
- package/src/generated/NameWrapper.ts +877 -884
- package/src/generated/P256SHA256Algorithm.ts +52 -52
- package/src/generated/PublicResolver.ts +698 -705
- package/src/generated/RSASHA1Algorithm.ts +52 -52
- package/src/generated/RSASHA256Algorithm.ts +52 -52
- package/src/generated/ReverseRegistrar.ts +305 -311
- package/src/generated/Root.ts +220 -226
- package/src/generated/SHA1Digest.ts +51 -51
- package/src/generated/SHA1NSEC3Digest.ts +52 -53
- package/src/generated/SHA256Digest.ts +51 -51
- package/src/generated/StaticMetadataService.ts +51 -52
- package/src/generated/TLDPublicSuffixList.ts +53 -53
- package/src/generated/UniversalResolver.ts +312 -313
- package/src/generated/common.ts +15 -15
- package/src/generated/factories/BaseRegistrarImplementation__factory.ts +340 -338
- package/src/generated/factories/BulkRenewal__factory.ts +51 -49
- package/src/generated/factories/DNSRegistrar__factory.ts +132 -130
- package/src/generated/factories/DNSSECImpl__factory.ts +231 -229
- package/src/generated/factories/DefaultReverseResolver__factory.ts +40 -38
- package/src/generated/factories/ENSRegistry__factory.ts +199 -197
- package/src/generated/factories/ETHRegistrarController__factory.ts +324 -322
- package/src/generated/factories/Multicall__factory.ts +226 -224
- package/src/generated/factories/NameWrapper__factory.ts +678 -676
- package/src/generated/factories/P256SHA256Algorithm__factory.ts +25 -23
- package/src/generated/factories/PublicResolver__factory.ts +455 -456
- package/src/generated/factories/RSASHA1Algorithm__factory.ts +25 -23
- package/src/generated/factories/RSASHA256Algorithm__factory.ts +25 -23
- package/src/generated/factories/ReverseRegistrar__factory.ts +167 -165
- package/src/generated/factories/Root__factory.ts +103 -101
- package/src/generated/factories/SHA1Digest__factory.ts +22 -20
- package/src/generated/factories/SHA1NSEC3Digest__factory.ts +25 -23
- package/src/generated/factories/SHA256Digest__factory.ts +22 -20
- package/src/generated/factories/StaticMetadataService__factory.ts +25 -23
- package/src/generated/factories/TLDPublicSuffixList__factory.ts +19 -17
- package/src/generated/factories/UniversalResolver__factory.ts +251 -249
- package/src/index.ts +139 -169
- package/src/static.ts +94 -0
- package/src/utils/ccip.ts +5 -4
- package/src/utils/contentHash.ts +2 -2
- package/src/utils/fuses.ts +1 -1
- package/src/utils/generateFuseInput.ts +2 -2
- package/src/utils/labels.ts +1 -1
- package/src/utils/normalise.ts +3 -1
- package/src/utils/registerHelpers.ts +5 -3
- package/src/utils/singleCall.ts +2 -2
- package/src/utils/validation.ts +1 -1
- package/src/utils/wrapper.ts +2 -2
- package/src/utils/writeTx.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -1,56 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ContractTransaction,
|
|
3
|
+
PopulatedTransaction,
|
|
4
|
+
} from '@ethersproject/contracts'
|
|
5
|
+
import type {
|
|
6
|
+
JsonRpcProvider,
|
|
7
|
+
JsonRpcSigner,
|
|
8
|
+
Provider,
|
|
9
|
+
} from '@ethersproject/providers'
|
|
3
10
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress'
|
|
4
11
|
import ContractManager from './contracts/index'
|
|
5
12
|
import { SupportedNetworkId } from './contracts/types'
|
|
6
|
-
import type
|
|
7
|
-
import type {
|
|
8
|
-
multicallWrapper,
|
|
9
|
-
resolverMulticallWrapper,
|
|
10
|
-
universalWrapper,
|
|
11
|
-
} from './functions/batchWrappers'
|
|
12
|
-
import type burnFuses from './functions/burnFuses'
|
|
13
|
-
import type commitName from './functions/commitName'
|
|
14
|
-
import type createSubname from './functions/createSubname'
|
|
15
|
-
import type deleteSubname from './functions/deleteSubname'
|
|
16
|
-
import type getAvailable from './functions/getAvailable'
|
|
17
|
-
import type getDNSOwner from './functions/getDNSOwner'
|
|
18
|
-
import type getExpiry from './functions/getExpiry'
|
|
19
|
-
import type { getHistory } from './functions/getHistory'
|
|
20
|
-
import type getName from './functions/getName'
|
|
21
|
-
import type getNames from './functions/getNames'
|
|
22
|
-
import type getOwner from './functions/getOwner'
|
|
23
|
-
import type getPrice from './functions/getPrice'
|
|
24
|
-
import type getProfile from './functions/getProfile'
|
|
25
|
-
import type getRecords from './functions/getRecords'
|
|
26
|
-
import type getResolver from './functions/getResolver'
|
|
27
|
-
import type {
|
|
28
|
-
getAddr,
|
|
29
|
-
getContentHash,
|
|
30
|
-
getText,
|
|
31
|
-
_getAddr,
|
|
32
|
-
_getContentHash,
|
|
33
|
-
_getText,
|
|
34
|
-
} from './functions/getSpecificRecord'
|
|
35
|
-
import type getSubnames from './functions/getSubnames'
|
|
36
|
-
import type getWrapperData from './functions/getWrapperData'
|
|
37
|
-
import type importDNSSECName from './functions/importDNSSECName'
|
|
38
|
-
import type registerName from './functions/registerName'
|
|
39
|
-
import type {
|
|
40
|
-
// eslint-disable-next-line import/no-named-default
|
|
41
|
-
default as renewNames,
|
|
42
|
-
renewNameWithData,
|
|
43
|
-
} from './functions/renewNames'
|
|
44
|
-
import type setName from './functions/setName'
|
|
45
|
-
import type setRecord from './functions/setRecord'
|
|
46
|
-
import type setRecords from './functions/setRecords'
|
|
47
|
-
import type setResolver from './functions/setResolver'
|
|
48
|
-
import type supportsTLD from './functions/supportsTLD'
|
|
49
|
-
import type transferController from './functions/transferController'
|
|
50
|
-
import type transferName from './functions/transferName'
|
|
51
|
-
import type transferSubname from './functions/transferSubname'
|
|
52
|
-
import type unwrapName from './functions/unwrapName'
|
|
53
|
-
import type wrapName from './functions/wrapName'
|
|
13
|
+
import type FunctionTypes from './functions/types'
|
|
54
14
|
import GqlManager from './GqlManager'
|
|
55
15
|
import singleCall from './utils/singleCall'
|
|
56
16
|
import writeTx from './utils/writeTx'
|
|
@@ -71,7 +31,7 @@ type ENSOptions = {
|
|
|
71
31
|
|
|
72
32
|
export type InternalENS = {
|
|
73
33
|
options?: ENSOptions
|
|
74
|
-
provider?:
|
|
34
|
+
provider?: Provider
|
|
75
35
|
signer: JsonRpcSigner
|
|
76
36
|
graphURI?: string | null
|
|
77
37
|
} & ENS
|
|
@@ -123,7 +83,7 @@ interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
|
123
83
|
}
|
|
124
84
|
|
|
125
85
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
126
|
-
const graphURIEndpoints: Record<string, string> = {
|
|
86
|
+
export const graphURIEndpoints: Record<string, string> = {
|
|
127
87
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
128
88
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
129
89
|
4: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensrinkeby',
|
|
@@ -181,16 +141,24 @@ interface GeneratedBatchFunction<F extends RawFunction>
|
|
|
181
141
|
batch: BatchFunction<F>
|
|
182
142
|
}
|
|
183
143
|
|
|
144
|
+
export type FunctionSubtype =
|
|
145
|
+
| 'raw'
|
|
146
|
+
| 'decode'
|
|
147
|
+
| 'combine'
|
|
148
|
+
| 'batch'
|
|
149
|
+
| 'write'
|
|
150
|
+
| 'populateTransaction'
|
|
151
|
+
|
|
184
152
|
export class ENS {
|
|
185
153
|
[x: string]: any
|
|
186
154
|
|
|
187
155
|
protected options?: ENSOptions
|
|
188
156
|
|
|
189
|
-
protected provider?:
|
|
157
|
+
protected provider?: JsonRpcProvider
|
|
190
158
|
|
|
191
159
|
protected graphURI?: string | null
|
|
192
160
|
|
|
193
|
-
protected initialProvider?:
|
|
161
|
+
protected initialProvider?: JsonRpcProvider
|
|
194
162
|
|
|
195
163
|
contracts?: ContractManager
|
|
196
164
|
|
|
@@ -219,7 +187,7 @@ export class ENS {
|
|
|
219
187
|
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
220
188
|
* @returns {Object} - An object of ENS properties
|
|
221
189
|
*/
|
|
222
|
-
|
|
190
|
+
protected forwardDependenciesFromArray = <F>(
|
|
223
191
|
dependencies: FunctionDeps<F>,
|
|
224
192
|
): object =>
|
|
225
193
|
// Creates an object from entries of the array
|
|
@@ -228,6 +196,30 @@ export class ENS {
|
|
|
228
196
|
dependencies.map((dep) => [dep, this[dep as keyof InternalENS]]),
|
|
229
197
|
)
|
|
230
198
|
|
|
199
|
+
// eslint-disable-next-line class-methods-use-this
|
|
200
|
+
protected getModule = async (path: string, exportName: string) => {
|
|
201
|
+
let mod = await import(
|
|
202
|
+
/* webpackMode: "lazy", webpackChunkName: "[request]", webpackPreload: true, webpackExclude: /.*\.ts$/ */
|
|
203
|
+
`./functions/${path}`
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
// if export is nested in default, use default
|
|
207
|
+
if (mod.default?.[exportName]) {
|
|
208
|
+
mod = mod.default
|
|
209
|
+
}
|
|
210
|
+
return mod
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// eslint-disable-next-line class-methods-use-this
|
|
214
|
+
protected getFunction = (
|
|
215
|
+
subFunc: FunctionSubtype | undefined,
|
|
216
|
+
writeable: boolean | undefined,
|
|
217
|
+
exportName: string,
|
|
218
|
+
mod: any,
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
220
|
+
_path: string,
|
|
221
|
+
) => (subFunc && !writeable ? mod[exportName][subFunc] : mod[exportName])
|
|
222
|
+
|
|
231
223
|
/**
|
|
232
224
|
* Creates a wrapper for a function to be dynamically imported, with the correct dependencies passed in
|
|
233
225
|
* @param {string} path - The path of the exported function
|
|
@@ -240,13 +232,7 @@ export class ENS {
|
|
|
240
232
|
path: string,
|
|
241
233
|
dependencies: FunctionDeps<F>,
|
|
242
234
|
exportName: string = 'default',
|
|
243
|
-
subFunc?:
|
|
244
|
-
| 'raw'
|
|
245
|
-
| 'decode'
|
|
246
|
-
| 'combine'
|
|
247
|
-
| 'batch'
|
|
248
|
-
| 'write'
|
|
249
|
-
| 'populateTransaction',
|
|
235
|
+
subFunc?: FunctionSubtype,
|
|
250
236
|
passthrough?: RawFunction,
|
|
251
237
|
): Function => {
|
|
252
238
|
// if batch is specified, create batch func
|
|
@@ -259,14 +245,7 @@ export class ENS {
|
|
|
259
245
|
// check the initial provider and set if it exists
|
|
260
246
|
await thisRef.checkInitialProvider()
|
|
261
247
|
// import the module dynamically
|
|
262
|
-
|
|
263
|
-
/* webpackMode: "lazy", webpackChunkName: "[request]", webpackPreload: true, webpackExclude: /.*\.ts$/ */
|
|
264
|
-
`./functions/${path}`
|
|
265
|
-
)
|
|
266
|
-
// if export is nested in default, use default
|
|
267
|
-
if (mod.default?.[exportName]) {
|
|
268
|
-
mod = mod.default
|
|
269
|
-
}
|
|
248
|
+
const mod = await thisRef.getModule(path, exportName)
|
|
270
249
|
|
|
271
250
|
// if combine isn't specified, run normally
|
|
272
251
|
// otherwise, create a function from the raw and decode functions
|
|
@@ -274,8 +253,13 @@ export class ENS {
|
|
|
274
253
|
const writeable =
|
|
275
254
|
subFunc === 'write' || subFunc === 'populateTransaction'
|
|
276
255
|
// get the function to call
|
|
277
|
-
const func =
|
|
278
|
-
subFunc
|
|
256
|
+
const func = thisRef.getFunction(
|
|
257
|
+
subFunc,
|
|
258
|
+
writeable,
|
|
259
|
+
exportName,
|
|
260
|
+
mod,
|
|
261
|
+
path,
|
|
262
|
+
)
|
|
279
263
|
// get the dependencies to forward to the function as the first arg
|
|
280
264
|
let dependenciesToForward =
|
|
281
265
|
thisRef.forwardDependenciesFromArray<F>(dependencies)
|
|
@@ -310,7 +294,7 @@ export class ENS {
|
|
|
310
294
|
return singleCall(
|
|
311
295
|
thisRef.provider!,
|
|
312
296
|
dependenciesToForward,
|
|
313
|
-
|
|
297
|
+
thisRef.getFunction(undefined, undefined, exportName, mod, path),
|
|
314
298
|
...args,
|
|
315
299
|
)
|
|
316
300
|
}
|
|
@@ -402,14 +386,14 @@ export class ENS {
|
|
|
402
386
|
|
|
403
387
|
/**
|
|
404
388
|
* Sets the provider for the ENS class
|
|
405
|
-
* @param {
|
|
389
|
+
* @param {JsonRpcProvider} provider - The provider to set
|
|
406
390
|
* @returns {Promise<void>} - A promise that resolves when the provider is set
|
|
407
391
|
*/
|
|
408
|
-
public setProvider = async (
|
|
409
|
-
provider: ethers.providers.JsonRpcProvider,
|
|
410
|
-
): Promise<void> => {
|
|
392
|
+
public setProvider = async (provider: JsonRpcProvider): Promise<void> => {
|
|
411
393
|
this.provider = provider
|
|
412
|
-
const network =
|
|
394
|
+
const network = this.staticNetwork
|
|
395
|
+
? this.provider._network.chainId
|
|
396
|
+
: (await this.provider.getNetwork()).chainId
|
|
413
397
|
if (this.options && this.options.graphURI) {
|
|
414
398
|
this.graphURI = this.options.graphURI
|
|
415
399
|
} else {
|
|
@@ -424,22 +408,22 @@ export class ENS {
|
|
|
424
408
|
|
|
425
409
|
/**
|
|
426
410
|
* Creates a new ENS instance with a different provider, ideally should be used individually with any given function
|
|
427
|
-
* @param {
|
|
411
|
+
* @param {JsonRpcProvider} provider - The provider to use
|
|
428
412
|
* @returns {ENS} - A new ENS instance with the given provider
|
|
429
413
|
*/
|
|
430
|
-
public withProvider = (provider:
|
|
414
|
+
public withProvider = (provider: JsonRpcProvider): ENS => {
|
|
431
415
|
const newENS = new ENS(this.options)
|
|
432
416
|
newENS.initialProvider = provider
|
|
433
417
|
return newENS
|
|
434
418
|
}
|
|
435
419
|
|
|
436
|
-
public batch = this.generateRawFunction<
|
|
420
|
+
public batch = this.generateRawFunction<FunctionTypes['batch']>(
|
|
437
421
|
'initialGetters',
|
|
438
422
|
['multicallWrapper'],
|
|
439
423
|
'batch',
|
|
440
|
-
) as GeneratedBatchFunction<
|
|
424
|
+
) as GeneratedBatchFunction<FunctionTypes['batch']>
|
|
441
425
|
|
|
442
|
-
public getProfile = this.generateFunction<
|
|
426
|
+
public getProfile = this.generateFunction<FunctionTypes['getProfile']>(
|
|
443
427
|
'initialGetters',
|
|
444
428
|
[
|
|
445
429
|
'contracts',
|
|
@@ -454,211 +438,197 @@ export class ENS {
|
|
|
454
438
|
'getProfile',
|
|
455
439
|
)
|
|
456
440
|
|
|
457
|
-
public getRecords = this.generateFunction<
|
|
441
|
+
public getRecords = this.generateFunction<FunctionTypes['getRecords']>(
|
|
458
442
|
'initialGetters',
|
|
459
443
|
['getProfile'],
|
|
460
444
|
'getRecords',
|
|
461
445
|
)
|
|
462
446
|
|
|
463
|
-
public getName = this.generateRawFunction<
|
|
447
|
+
public getName = this.generateRawFunction<FunctionTypes['getName']>(
|
|
464
448
|
'initialGetters',
|
|
465
449
|
['contracts'],
|
|
466
450
|
'getName',
|
|
467
451
|
)
|
|
468
452
|
|
|
469
|
-
public getResolver = this.generateRawFunction<
|
|
453
|
+
public getResolver = this.generateRawFunction<FunctionTypes['getResolver']>(
|
|
470
454
|
'getResolver',
|
|
471
455
|
['contracts'],
|
|
472
456
|
)
|
|
473
457
|
|
|
474
|
-
public getWrapperData = this.generateRawFunction<
|
|
475
|
-
'getWrapperData'
|
|
476
|
-
|
|
477
|
-
)
|
|
458
|
+
public getWrapperData = this.generateRawFunction<
|
|
459
|
+
FunctionTypes['getWrapperData']
|
|
460
|
+
>('getWrapperData', ['contracts'])
|
|
478
461
|
|
|
479
|
-
public getHistory = this.generateFunction<
|
|
462
|
+
public getHistory = this.generateFunction<FunctionTypes['getHistory']>(
|
|
480
463
|
'getHistory',
|
|
481
464
|
['gqlInstance'],
|
|
482
465
|
'getHistory',
|
|
483
466
|
)
|
|
484
467
|
|
|
485
|
-
public getContentHash = this.generateRawFunction<
|
|
486
|
-
'
|
|
487
|
-
|
|
488
|
-
'getContentHash',
|
|
489
|
-
)
|
|
468
|
+
public getContentHash = this.generateRawFunction<
|
|
469
|
+
FunctionTypes['getContentHash']
|
|
470
|
+
>('initialGetters', ['contracts', 'universalWrapper'], 'getContentHash')
|
|
490
471
|
|
|
491
|
-
public _getContentHash = this.generateRawFunction<
|
|
492
|
-
'
|
|
493
|
-
|
|
494
|
-
'_getContentHash',
|
|
495
|
-
)
|
|
472
|
+
public _getContentHash = this.generateRawFunction<
|
|
473
|
+
FunctionTypes['_getContentHash']
|
|
474
|
+
>('initialGetters', ['contracts'], '_getContentHash')
|
|
496
475
|
|
|
497
|
-
public getAddr = this.generateRawFunction<
|
|
476
|
+
public getAddr = this.generateRawFunction<FunctionTypes['getAddr']>(
|
|
498
477
|
'initialGetters',
|
|
499
478
|
['contracts', 'universalWrapper'],
|
|
500
479
|
'getAddr',
|
|
501
480
|
)
|
|
502
481
|
|
|
503
|
-
public _getAddr = this.generateRawFunction<
|
|
482
|
+
public _getAddr = this.generateRawFunction<FunctionTypes['_getAddr']>(
|
|
504
483
|
'initialGetters',
|
|
505
484
|
['contracts'],
|
|
506
485
|
'_getAddr',
|
|
507
486
|
)
|
|
508
487
|
|
|
509
|
-
public getText = this.generateRawFunction<
|
|
488
|
+
public getText = this.generateRawFunction<FunctionTypes['getText']>(
|
|
510
489
|
'initialGetters',
|
|
511
490
|
['contracts', 'universalWrapper'],
|
|
512
491
|
'getText',
|
|
513
492
|
)
|
|
514
493
|
|
|
515
|
-
public _getText = this.generateRawFunction<
|
|
494
|
+
public _getText = this.generateRawFunction<FunctionTypes['_getText']>(
|
|
516
495
|
'initialGetters',
|
|
517
496
|
['contracts'],
|
|
518
497
|
'_getText',
|
|
519
498
|
)
|
|
520
499
|
|
|
521
|
-
public getOwner = this.generateRawFunction<
|
|
500
|
+
public getOwner = this.generateRawFunction<FunctionTypes['getOwner']>(
|
|
522
501
|
'initialGetters',
|
|
523
502
|
['contracts', 'multicallWrapper', 'gqlInstance'],
|
|
524
503
|
'getOwner',
|
|
525
504
|
)
|
|
526
505
|
|
|
527
|
-
public getExpiry = this.generateRawFunction<
|
|
506
|
+
public getExpiry = this.generateRawFunction<FunctionTypes['getExpiry']>(
|
|
528
507
|
'initialGetters',
|
|
529
508
|
['contracts', 'multicallWrapper'],
|
|
530
509
|
'getExpiry',
|
|
531
510
|
)
|
|
532
511
|
|
|
533
|
-
public getSubnames = this.generateFunction<
|
|
512
|
+
public getSubnames = this.generateFunction<FunctionTypes['getSubnames']>(
|
|
534
513
|
'initialGetters',
|
|
535
514
|
['gqlInstance'],
|
|
536
515
|
'getSubnames',
|
|
537
516
|
)
|
|
538
517
|
|
|
539
|
-
public getNames = this.generateFunction<
|
|
518
|
+
public getNames = this.generateFunction<FunctionTypes['getNames']>(
|
|
540
519
|
'initialGetters',
|
|
541
520
|
['gqlInstance'],
|
|
542
521
|
'getNames',
|
|
543
522
|
)
|
|
544
523
|
|
|
545
|
-
public getPrice = this.generateRawFunction<
|
|
524
|
+
public getPrice = this.generateRawFunction<FunctionTypes['getPrice']>(
|
|
546
525
|
'initialGetters',
|
|
547
526
|
['contracts', 'multicallWrapper'],
|
|
548
527
|
'getPrice',
|
|
549
528
|
)
|
|
550
529
|
|
|
551
|
-
public getDNSOwner = this.generateFunction<
|
|
530
|
+
public getDNSOwner = this.generateFunction<FunctionTypes['getDNSOwner']>(
|
|
552
531
|
'getDNSOwner',
|
|
553
532
|
[],
|
|
554
533
|
)
|
|
555
534
|
|
|
556
|
-
public supportsTLD = this.generateFunction<
|
|
535
|
+
public supportsTLD = this.generateFunction<FunctionTypes['supportsTLD']>(
|
|
557
536
|
'initialGetters',
|
|
558
537
|
['getOwner', 'provider'],
|
|
559
538
|
'supportsTLD',
|
|
560
539
|
)
|
|
561
540
|
|
|
562
|
-
public getAvailable = this.generateRawFunction<
|
|
541
|
+
public getAvailable = this.generateRawFunction<FunctionTypes['getAvailable']>(
|
|
563
542
|
'getAvailable',
|
|
564
543
|
['contracts'],
|
|
565
544
|
)
|
|
566
545
|
|
|
567
|
-
public universalWrapper = this.generateRawFunction<
|
|
568
|
-
'
|
|
569
|
-
|
|
570
|
-
'universalWrapper',
|
|
571
|
-
)
|
|
546
|
+
public universalWrapper = this.generateRawFunction<
|
|
547
|
+
FunctionTypes['universalWrapper']
|
|
548
|
+
>('initialGetters', ['contracts'], 'universalWrapper')
|
|
572
549
|
|
|
573
550
|
public resolverMulticallWrapper = this.generateRawFunction<
|
|
574
|
-
|
|
551
|
+
FunctionTypes['resolverMulticallWrapper']
|
|
575
552
|
>('initialGetters', ['contracts'], 'resolverMulticallWrapper')
|
|
576
553
|
|
|
577
|
-
public multicallWrapper = this.generateRawFunction<
|
|
578
|
-
'
|
|
554
|
+
public multicallWrapper = this.generateRawFunction<
|
|
555
|
+
FunctionTypes['multicallWrapper']
|
|
556
|
+
>('initialGetters', ['contracts'], 'multicallWrapper')
|
|
557
|
+
|
|
558
|
+
public setName = this.generateWriteFunction<FunctionTypes['setName']>(
|
|
559
|
+
'setName',
|
|
579
560
|
['contracts'],
|
|
580
|
-
'multicallWrapper',
|
|
581
561
|
)
|
|
582
562
|
|
|
583
|
-
public
|
|
584
|
-
'contracts',
|
|
585
|
-
])
|
|
586
|
-
|
|
587
|
-
public setRecords = this.generateWriteFunction<typeof setRecords>(
|
|
563
|
+
public setRecords = this.generateWriteFunction<FunctionTypes['setRecords']>(
|
|
588
564
|
'setRecords',
|
|
589
565
|
['contracts', 'provider', 'getResolver'],
|
|
590
566
|
)
|
|
591
567
|
|
|
592
|
-
public setRecord = this.generateWriteFunction<
|
|
593
|
-
'
|
|
594
|
-
'provider',
|
|
595
|
-
|
|
596
|
-
])
|
|
568
|
+
public setRecord = this.generateWriteFunction<FunctionTypes['setRecord']>(
|
|
569
|
+
'setRecord',
|
|
570
|
+
['contracts', 'provider', 'getResolver'],
|
|
571
|
+
)
|
|
597
572
|
|
|
598
|
-
public setResolver = this.generateWriteFunction<
|
|
573
|
+
public setResolver = this.generateWriteFunction<FunctionTypes['setResolver']>(
|
|
599
574
|
'setResolver',
|
|
600
575
|
['contracts'],
|
|
601
576
|
)
|
|
602
577
|
|
|
603
|
-
public transferName = this.generateWriteFunction<
|
|
604
|
-
'transferName'
|
|
605
|
-
|
|
606
|
-
)
|
|
578
|
+
public transferName = this.generateWriteFunction<
|
|
579
|
+
FunctionTypes['transferName']
|
|
580
|
+
>('transferName', ['contracts'])
|
|
607
581
|
|
|
608
582
|
public transferController = this.generateWriteFunction<
|
|
609
|
-
|
|
583
|
+
FunctionTypes['transferController']
|
|
610
584
|
>('transferController', ['contracts'])
|
|
611
585
|
|
|
612
|
-
public wrapName = this.generateWriteFunction<
|
|
613
|
-
'
|
|
614
|
-
'getExpiry',
|
|
615
|
-
|
|
586
|
+
public wrapName = this.generateWriteFunction<FunctionTypes['wrapName']>(
|
|
587
|
+
'wrapName',
|
|
588
|
+
['contracts', 'getExpiry'],
|
|
589
|
+
)
|
|
616
590
|
|
|
617
|
-
public unwrapName = this.generateWriteFunction<
|
|
591
|
+
public unwrapName = this.generateWriteFunction<FunctionTypes['unwrapName']>(
|
|
618
592
|
'unwrapName',
|
|
619
593
|
['contracts'],
|
|
620
594
|
)
|
|
621
595
|
|
|
622
|
-
public burnFuses = this.generateWriteFunction<
|
|
623
|
-
'
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
public importDNSSECName = this.generateWriteFunction<typeof importDNSSECName>(
|
|
627
|
-
'importDNSSECName',
|
|
628
|
-
['contracts', 'provider', 'signer'],
|
|
596
|
+
public burnFuses = this.generateWriteFunction<FunctionTypes['burnFuses']>(
|
|
597
|
+
'burnFuses',
|
|
598
|
+
['contracts'],
|
|
629
599
|
)
|
|
630
600
|
|
|
631
|
-
public
|
|
632
|
-
'
|
|
633
|
-
|
|
634
|
-
)
|
|
601
|
+
public importDNSSECName = this.generateWriteFunction<
|
|
602
|
+
FunctionTypes['importDNSSECName']
|
|
603
|
+
>('importDNSSECName', ['contracts', 'provider', 'signer'])
|
|
635
604
|
|
|
636
|
-
public
|
|
637
|
-
'
|
|
638
|
-
|
|
639
|
-
)
|
|
605
|
+
public createSubname = this.generateWriteFunction<
|
|
606
|
+
FunctionTypes['createSubname']
|
|
607
|
+
>('createSubname', ['contracts', 'getExpiry'])
|
|
640
608
|
|
|
641
|
-
public
|
|
642
|
-
'
|
|
643
|
-
|
|
644
|
-
|
|
609
|
+
public deleteSubname = this.generateWriteFunction<
|
|
610
|
+
FunctionTypes['deleteSubname']
|
|
611
|
+
>('deleteSubname', ['contracts'])
|
|
612
|
+
|
|
613
|
+
public transferSubname = this.generateWriteFunction<
|
|
614
|
+
FunctionTypes['transferSubname']
|
|
615
|
+
>('transferSubname', ['contracts', 'getExpiry'])
|
|
645
616
|
|
|
646
|
-
public commitName = this.generateWriteFunction<
|
|
617
|
+
public commitName = this.generateWriteFunction<FunctionTypes['commitName']>(
|
|
647
618
|
'commitName',
|
|
648
619
|
['contracts'],
|
|
649
620
|
)
|
|
650
621
|
|
|
651
|
-
public registerName = this.generateWriteFunction<
|
|
652
|
-
'registerName'
|
|
653
|
-
|
|
654
|
-
)
|
|
622
|
+
public registerName = this.generateWriteFunction<
|
|
623
|
+
FunctionTypes['registerName']
|
|
624
|
+
>('registerName', ['contracts'])
|
|
655
625
|
|
|
656
|
-
public renewNames = this.generateWriteFunction<
|
|
626
|
+
public renewNames = this.generateWriteFunction<FunctionTypes['renewNames']>(
|
|
657
627
|
'renewNames',
|
|
658
628
|
['contracts'],
|
|
659
629
|
)
|
|
660
630
|
|
|
661
631
|
public renewNameWithData = this.generateWriteFunction<
|
|
662
|
-
|
|
632
|
+
FunctionTypes['renewNameWithData']
|
|
663
633
|
>('renewNames', ['contracts'], 'renewNameWithData')
|
|
664
634
|
}
|
package/src/static.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { StaticJsonRpcProvider } from '@ethersproject/providers/lib/url-json-rpc-provider'
|
|
2
|
+
import { gql, GraphQLClient } from 'graphql-request'
|
|
3
|
+
import { parse, print, visit } from 'graphql/language'
|
|
4
|
+
import traverse from 'traverse'
|
|
5
|
+
import ContractManager from './contracts/index'
|
|
6
|
+
import { SupportedNetworkId } from './contracts/types'
|
|
7
|
+
import { ENS, FunctionSubtype, graphURIEndpoints } from './index'
|
|
8
|
+
|
|
9
|
+
import type Factories from './contracts/factories'
|
|
10
|
+
import type FunctionTypes from './functions/types'
|
|
11
|
+
import { requestMiddleware, responseMiddleware } from './GqlManager'
|
|
12
|
+
|
|
13
|
+
type Options = ConstructorParameters<typeof ENS>[0] & {
|
|
14
|
+
functions: Partial<FunctionTypes>
|
|
15
|
+
contracts: Partial<Factories>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class StaticENS extends ENS {
|
|
19
|
+
private functions: Partial<FunctionTypes>
|
|
20
|
+
|
|
21
|
+
private contractsObject: Partial<Factories>
|
|
22
|
+
|
|
23
|
+
gqlInstance: {
|
|
24
|
+
client: GraphQLClient | { request: () => Promise<null> }
|
|
25
|
+
setUrl: () => Promise<void>
|
|
26
|
+
gql: typeof gql | ((query: TemplateStringsArray) => string)
|
|
27
|
+
} = {
|
|
28
|
+
client: { request: () => Promise.resolve(null) },
|
|
29
|
+
setUrl: () => Promise.resolve(),
|
|
30
|
+
gql: (query: TemplateStringsArray) => query.join(),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
provider: StaticJsonRpcProvider,
|
|
35
|
+
{ functions, contracts, ...options }: Options,
|
|
36
|
+
) {
|
|
37
|
+
super(options)
|
|
38
|
+
this.functions = functions
|
|
39
|
+
this.contractsObject = contracts
|
|
40
|
+
this.setStaticProvider(provider)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public setStaticProvider = (provider: StaticJsonRpcProvider) => {
|
|
44
|
+
this.provider = provider
|
|
45
|
+
const network = provider.network.chainId
|
|
46
|
+
if (this.options && this.options.graphURI) {
|
|
47
|
+
this.graphURI = this.options.graphURI
|
|
48
|
+
} else {
|
|
49
|
+
this.graphURI = graphURIEndpoints[network]
|
|
50
|
+
}
|
|
51
|
+
if (this.graphURI) {
|
|
52
|
+
const client = new GraphQLClient(this.graphURI, {
|
|
53
|
+
requestMiddleware: requestMiddleware(visit, parse, print),
|
|
54
|
+
responseMiddleware: responseMiddleware(traverse),
|
|
55
|
+
})
|
|
56
|
+
this.gqlInstance = {
|
|
57
|
+
client,
|
|
58
|
+
setUrl: () => Promise.resolve(),
|
|
59
|
+
gql,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
this.contracts = new ContractManager(
|
|
63
|
+
provider,
|
|
64
|
+
this.getContractAddress(String(network) as SupportedNetworkId),
|
|
65
|
+
(name) =>
|
|
66
|
+
Promise.resolve(this.contractsObject[name as keyof Factories] as any),
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public override setProvider = async (
|
|
71
|
+
provider: StaticJsonRpcProvider,
|
|
72
|
+
): Promise<void> => {
|
|
73
|
+
this.setStaticProvider(provider)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected override getModule = async () => this.functions
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line class-methods-use-this
|
|
79
|
+
protected override getFunction = (
|
|
80
|
+
subFunc: FunctionSubtype | undefined,
|
|
81
|
+
_writeable: boolean | undefined,
|
|
82
|
+
exportName: string,
|
|
83
|
+
mod: any,
|
|
84
|
+
path: string,
|
|
85
|
+
) => {
|
|
86
|
+
const base = mod[exportName === 'default' ? path : exportName]
|
|
87
|
+
if (subFunc === 'raw' || subFunc === 'decode') {
|
|
88
|
+
return base[subFunc]
|
|
89
|
+
}
|
|
90
|
+
return base
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default StaticENS
|
package/src/utils/ccip.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BigNumber, Transaction } from 'ethers'
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber/lib/bignumber'
|
|
3
2
|
import {
|
|
4
3
|
arrayify,
|
|
5
4
|
BytesLike,
|
|
6
5
|
hexConcat,
|
|
7
6
|
hexDataSlice,
|
|
8
|
-
|
|
9
|
-
} from '
|
|
7
|
+
} from '@ethersproject/bytes'
|
|
8
|
+
import type { BaseProvider, TransactionRequest } from '@ethersproject/providers'
|
|
9
|
+
import { toUtf8String } from '@ethersproject/strings/lib/utf8'
|
|
10
|
+
import type { Transaction } from '@ethersproject/transactions'
|
|
10
11
|
|
|
11
12
|
function bytesPad(value: Uint8Array): Uint8Array {
|
|
12
13
|
if (value.length % 32 === 0) {
|
package/src/utils/contentHash.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import contentHash from '@ensdomains/content-hash'
|
|
2
|
-
import {
|
|
2
|
+
import { isHexString } from '@ethersproject/bytes'
|
|
3
3
|
|
|
4
4
|
export type DecodedContentHash = {
|
|
5
5
|
protocolType?: any
|
|
@@ -76,7 +76,7 @@ export function validateContent(encoded: any) {
|
|
|
76
76
|
export function isValidContenthash(encoded: any) {
|
|
77
77
|
try {
|
|
78
78
|
const codec = contentHash.getCodec(encoded)
|
|
79
|
-
return
|
|
79
|
+
return isHexString(encoded) && supportedCodecs.includes(codec)
|
|
80
80
|
} catch (e) {
|
|
81
81
|
console.log(e)
|
|
82
82
|
}
|
package/src/utils/fuses.ts
CHANGED