@ensdomains/ensjs 3.0.0-beta.1 → 3.0.0-beta.3
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/clients/decorators/subgraph.js.map +1 -1
- package/dist/cjs/contracts/consts.js +52 -1
- package/dist/cjs/contracts/consts.js.map +1 -1
- package/dist/cjs/dns.js +3 -3
- package/dist/cjs/dns.js.map +1 -1
- package/dist/cjs/errors/subgraph.js.map +1 -1
- package/dist/cjs/errors/utils.js +15 -18
- package/dist/cjs/errors/utils.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +3 -3
- package/dist/cjs/functions/dns/{prepareDnsImport.js.map → getDnsImportData.js.map} +1 -1
- package/dist/cjs/functions/dns/importDnsName.js +7 -7
- package/dist/cjs/functions/dns/importDnsName.js.map +1 -1
- package/dist/cjs/functions/public/_getContentHash.js +1 -1
- package/dist/cjs/functions/public/getSupportedInterfaces.js +1 -1
- package/dist/cjs/functions/public/getSupportedInterfaces.js.map +1 -1
- package/dist/cjs/functions/public/getWrapperData.js.map +1 -1
- package/dist/cjs/functions/subgraph/filters.js +3 -0
- package/dist/cjs/functions/subgraph/filters.js.map +1 -0
- package/dist/cjs/functions/subgraph/getNameHistory.js +1 -1
- package/dist/cjs/functions/subgraph/getNamesForAddress.js +140 -182
- package/dist/cjs/functions/subgraph/getNamesForAddress.js.map +1 -1
- package/dist/cjs/functions/subgraph/getSubnames.js +95 -108
- package/dist/cjs/functions/subgraph/getSubnames.js.map +1 -1
- package/dist/cjs/functions/subgraph/types.js +3 -0
- package/dist/cjs/functions/subgraph/types.js.map +1 -0
- package/dist/cjs/functions/subgraph/utils.js.map +1 -1
- package/dist/cjs/functions/wallet/createSubname.js +1 -1
- package/dist/cjs/functions/wallet/createSubname.js.map +1 -1
- package/dist/cjs/functions/wallet/setChildFuses.js +1 -1
- package/dist/cjs/functions/wallet/setChildFuses.js.map +1 -1
- package/dist/cjs/functions/wallet/setFuses.js +1 -1
- package/dist/cjs/functions/wallet/setFuses.js.map +1 -1
- package/dist/cjs/functions/wallet/wrapName.js +3 -1
- package/dist/cjs/functions/wallet/wrapName.js.map +1 -1
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/contentHash.js +54 -131
- package/dist/cjs/utils/contentHash.js.map +1 -1
- package/dist/cjs/utils/encoders/encodeSetContentHash.js +1 -4
- package/dist/cjs/utils/encoders/encodeSetContentHash.js.map +1 -1
- package/dist/cjs/utils/format.js +1 -5
- package/dist/cjs/utils/format.js.map +1 -1
- package/dist/cjs/utils/fuses.js +181 -200
- package/dist/cjs/utils/fuses.js.map +1 -1
- package/dist/cjs/utils/index.js +4 -7
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/registerHelpers.js +3 -1
- package/dist/cjs/utils/registerHelpers.js.map +1 -1
- package/dist/esm/clients/decorators/subgraph.js.map +1 -1
- package/dist/esm/contracts/consts.js +52 -1
- package/dist/esm/contracts/consts.js.map +1 -1
- package/dist/esm/dns.js +1 -1
- package/dist/esm/dns.js.map +1 -1
- package/dist/esm/errors/subgraph.js.map +1 -1
- package/dist/esm/errors/utils.js +13 -16
- package/dist/esm/errors/utils.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +9 -10
- package/dist/esm/functions/dns/getDnsImportData.js.map +1 -0
- package/dist/esm/functions/dns/importDnsName.js +12 -12
- package/dist/esm/functions/dns/importDnsName.js.map +1 -1
- package/dist/esm/functions/public/_getContentHash.js +2 -2
- package/dist/esm/functions/public/getSupportedInterfaces.js +2 -2
- package/dist/esm/functions/public/getSupportedInterfaces.js.map +1 -1
- package/dist/esm/functions/public/getWrapperData.js.map +1 -1
- package/dist/esm/functions/subgraph/filters.js +2 -0
- package/dist/esm/functions/subgraph/filters.js.map +1 -0
- package/dist/esm/functions/subgraph/getNameHistory.js +2 -2
- package/dist/esm/functions/subgraph/getNamesForAddress.js +144 -183
- package/dist/esm/functions/subgraph/getNamesForAddress.js.map +1 -1
- package/dist/esm/functions/subgraph/getSubnames.js +101 -111
- package/dist/esm/functions/subgraph/getSubnames.js.map +1 -1
- package/dist/esm/functions/subgraph/types.js +2 -0
- package/dist/esm/functions/subgraph/types.js.map +1 -0
- package/dist/esm/functions/subgraph/utils.js.map +1 -1
- package/dist/esm/functions/wallet/createSubname.js +1 -1
- package/dist/esm/functions/wallet/createSubname.js.map +1 -1
- package/dist/esm/functions/wallet/setChildFuses.js +1 -1
- package/dist/esm/functions/wallet/setChildFuses.js.map +1 -1
- package/dist/esm/functions/wallet/setFuses.js +2 -2
- package/dist/esm/functions/wallet/setFuses.js.map +1 -1
- package/dist/esm/functions/wallet/wrapName.js +4 -2
- package/dist/esm/functions/wallet/wrapName.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/contentHash.js +51 -128
- package/dist/esm/utils/contentHash.js.map +1 -1
- package/dist/esm/utils/encoders/encodeSetContentHash.js +2 -5
- package/dist/esm/utils/encoders/encodeSetContentHash.js.map +1 -1
- package/dist/esm/utils/format.js +0 -2
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/fuses.js +180 -201
- package/dist/esm/utils/fuses.js.map +1 -1
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/registerHelpers.js +4 -2
- package/dist/esm/utils/registerHelpers.js.map +1 -1
- package/dist/types/clients/decorators/subgraph.d.ts +1 -1
- package/dist/types/clients/decorators/subgraph.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +12 -12
- package/dist/types/clients/public.d.ts +1 -1
- package/dist/types/clients/subgraph.d.ts +1 -1
- package/dist/types/clients/wallet.d.ts +43 -79
- package/dist/types/clients/wallet.d.ts.map +1 -1
- package/dist/types/contracts/consts.d.ts +51 -2
- package/dist/types/contracts/consts.d.ts.map +1 -1
- package/dist/types/dns.d.ts +1 -1
- package/dist/types/dns.d.ts.map +1 -1
- package/dist/types/errors/subgraph.d.ts +4 -4
- package/dist/types/errors/subgraph.d.ts.map +1 -1
- package/dist/types/errors/utils.d.ts +10 -13
- package/dist/types/errors/utils.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/functions/dns/{prepareDnsImport.d.ts → getDnsImportData.d.ts} +11 -12
- package/dist/types/functions/dns/{prepareDnsImport.d.ts.map → getDnsImportData.d.ts.map} +1 -1
- package/dist/types/functions/dns/importDnsName.d.ts +36 -36
- package/dist/types/functions/dns/importDnsName.d.ts.map +1 -1
- package/dist/types/functions/public/getSupportedInterfaces.d.ts +19 -4
- package/dist/types/functions/public/getSupportedInterfaces.d.ts.map +1 -1
- package/dist/types/functions/public/getWrapperData.d.ts +2 -2
- package/dist/types/functions/public/getWrapperData.d.ts.map +1 -1
- package/dist/types/functions/subgraph/filters.d.ts +693 -0
- package/dist/types/functions/subgraph/filters.d.ts.map +1 -0
- package/dist/types/functions/subgraph/getNamesForAddress.d.ts +2 -0
- package/dist/types/functions/subgraph/getNamesForAddress.d.ts.map +1 -1
- package/dist/types/functions/subgraph/getSubnames.d.ts +3 -1
- package/dist/types/functions/subgraph/getSubnames.d.ts.map +1 -1
- package/dist/types/functions/subgraph/types.d.ts +13 -0
- package/dist/types/functions/subgraph/types.d.ts.map +1 -0
- package/dist/types/functions/subgraph/utils.d.ts +2 -2
- package/dist/types/functions/subgraph/utils.d.ts.map +1 -1
- package/dist/types/functions/wallet/commitName.d.ts +25 -25
- package/dist/types/functions/wallet/createSubname.d.ts +28 -28
- package/dist/types/functions/wallet/createSubname.d.ts.map +1 -1
- package/dist/types/functions/wallet/deleteSubname.d.ts +25 -25
- package/dist/types/functions/wallet/registerName.d.ts +24 -24
- package/dist/types/functions/wallet/renewNames.d.ts +24 -24
- package/dist/types/functions/wallet/setAbiRecord.d.ts +25 -25
- package/dist/types/functions/wallet/setAddressRecord.d.ts +25 -25
- package/dist/types/functions/wallet/setChildFuses.d.ts +27 -27
- package/dist/types/functions/wallet/setChildFuses.d.ts.map +1 -1
- package/dist/types/functions/wallet/setContentHashRecord.d.ts +25 -25
- package/dist/types/functions/wallet/setFuses.d.ts +27 -27
- package/dist/types/functions/wallet/setFuses.d.ts.map +1 -1
- package/dist/types/functions/wallet/setPrimaryName.d.ts +25 -25
- package/dist/types/functions/wallet/setRecords.d.ts +25 -25
- package/dist/types/functions/wallet/setResolver.d.ts +25 -25
- package/dist/types/functions/wallet/setTextRecord.d.ts +25 -25
- package/dist/types/functions/wallet/transferName.d.ts +25 -25
- package/dist/types/functions/wallet/unwrapName.d.ts +25 -25
- package/dist/types/functions/wallet/wrapName.d.ts +27 -27
- package/dist/types/functions/wallet/wrapName.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/contentHash.d.ts +7 -11
- package/dist/types/utils/contentHash.d.ts.map +1 -1
- package/dist/types/utils/encoders/encodeSetContentHash.d.ts.map +1 -1
- package/dist/types/utils/format.d.ts +0 -2
- package/dist/types/utils/format.d.ts.map +1 -1
- package/dist/types/utils/fuses.d.ts +164 -125
- package/dist/types/utils/fuses.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/registerHelpers.d.ts +2 -2
- package/dist/types/utils/registerHelpers.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/clients/decorators/subgraph.ts +1 -0
- package/src/contracts/consts.ts +57 -12
- package/src/dns.ts +5 -5
- package/src/errors/subgraph.ts +4 -4
- package/src/errors/utils.ts +21 -18
- package/src/errors/version.ts +1 -1
- package/src/functions/dns/{prepareDnsImport.ts → getDnsImportData.ts} +12 -13
- package/src/functions/dns/importDnsName.ts +20 -15
- package/src/functions/public/_getContentHash.ts +2 -2
- package/src/functions/public/getSupportedInterfaces.ts +48 -10
- package/src/functions/public/getWrapperData.ts +2 -2
- package/src/functions/subgraph/filters.ts +702 -0
- package/src/functions/subgraph/getNameHistory.ts +2 -2
- package/src/functions/subgraph/getNamesForAddress.ts +170 -186
- package/src/functions/subgraph/getSubnames.ts +121 -113
- package/src/functions/subgraph/types.ts +13 -0
- package/src/functions/subgraph/utils.ts +2 -2
- package/src/functions/wallet/createSubname.ts +4 -4
- package/src/functions/wallet/setChildFuses.ts +3 -3
- package/src/functions/wallet/setFuses.ts +6 -3
- package/src/functions/wallet/wrapName.ts +8 -3
- package/src/index.ts +0 -1
- package/src/utils/contentHash.ts +59 -113
- package/src/utils/encoders/encodeSetContentHash.ts +2 -4
- package/src/utils/format.ts +0 -6
- package/src/utils/fuses.ts +308 -308
- package/src/utils/index.ts +4 -5
- package/src/utils/registerHelpers.ts +5 -3
- package/dist/esm/functions/dns/prepareDnsImport.js.map +0 -1
- package/src/@types/@ensdomains/content-hash.d.ts +0 -1
- package/src/functions/dns/getDnsOwner.test.ts +0 -195
- package/src/functions/dns/importDnsName.test.ts +0 -117
- package/src/functions/dns/prepareDnsImport.test.ts +0 -115
- package/src/functions/public/batch.test.ts +0 -67
- package/src/functions/public/ccip.test.ts +0 -78
- package/src/functions/public/getAbiRecord.test.ts +0 -174
- package/src/functions/public/getAddressRecord.test.ts +0 -83
- package/src/functions/public/getAvailable.test.ts +0 -17
- package/src/functions/public/getContentHashRecord.test.ts +0 -28
- package/src/functions/public/getExpiry.test.ts +0 -48
- package/src/functions/public/getName.test.ts +0 -66
- package/src/functions/public/getOwner.test.ts +0 -87
- package/src/functions/public/getPrice.test.ts +0 -45
- package/src/functions/public/getRecords.test.ts +0 -49
- package/src/functions/public/getResolver.test.ts +0 -12
- package/src/functions/public/getTextRecord.test.ts +0 -20
- package/src/functions/public/getWrapperData.test.ts +0 -79
- package/src/functions/public/getWrapperName.test.ts +0 -19
- package/src/functions/subgraph/client.test.ts +0 -170
- package/src/functions/subgraph/getDecodedName.test.ts +0 -31
- package/src/functions/subgraph/getNameHistory.test.ts +0 -39
- package/src/functions/subgraph/getNamesForAddress.test.ts +0 -244
- package/src/functions/subgraph/getSubgraphRecords.test.ts +0 -74
- package/src/functions/subgraph/getSubgraphRegistrant.test.ts +0 -34
- package/src/functions/subgraph/getSubnames.test.ts +0 -202
- package/src/functions/wallet/commitName.test.ts +0 -58
- package/src/functions/wallet/createSubname.test.ts +0 -73
- package/src/functions/wallet/deleteSubname.test.ts +0 -150
- package/src/functions/wallet/registerName.test.ts +0 -81
- package/src/functions/wallet/renewNames.test.ts +0 -92
- package/src/functions/wallet/setAbiRecord.test.ts +0 -156
- package/src/functions/wallet/setAddressRecord.test.ts +0 -121
- package/src/functions/wallet/setChildFuses.test.ts +0 -97
- package/src/functions/wallet/setContentHashRecord.test.ts +0 -69
- package/src/functions/wallet/setFuses.test.ts +0 -287
- package/src/functions/wallet/setPrimaryName.test.ts +0 -71
- package/src/functions/wallet/setRecords.test.ts +0 -127
- package/src/functions/wallet/setResolver.test.ts +0 -114
- package/src/functions/wallet/setTextRecord.test.ts +0 -67
- package/src/functions/wallet/transferName.test.ts +0 -201
- package/src/functions/wallet/unwrapName.test.ts +0 -93
- package/src/functions/wallet/wrapName.test.ts +0 -195
- package/src/utils/generateRecordCallArray.test.ts +0 -84
- package/src/utils/labels.test.ts +0 -163
- package/src/utils/makeLabelNodeAndParent.test.ts +0 -11
- package/src/utils/makeSafeSecondsDate.test.ts +0 -14
- package/src/utils/normalise.test.ts +0 -35
- package/src/utils/ownerFromContract.test.ts +0 -52
- package/src/utils/registerHelpers.test.ts +0 -159
- package/src/utils/validation.test.ts +0 -170
- package/src/utils/wrapper.test.ts +0 -46
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
2
|
-
import getAbiRecord from './getAbiRecord.js'
|
|
3
|
-
|
|
4
|
-
const dummyABI = [
|
|
5
|
-
{
|
|
6
|
-
type: 'event',
|
|
7
|
-
anonymous: false,
|
|
8
|
-
name: 'ABIChanged',
|
|
9
|
-
inputs: [
|
|
10
|
-
{
|
|
11
|
-
type: 'bytes32',
|
|
12
|
-
indexed: true,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: 'uint256',
|
|
16
|
-
indexed: true,
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
type: 'event',
|
|
22
|
-
anonymous: false,
|
|
23
|
-
name: 'VersionChanged',
|
|
24
|
-
inputs: [
|
|
25
|
-
{
|
|
26
|
-
type: 'bytes32',
|
|
27
|
-
indexed: true,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: 'uint64',
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: 'function',
|
|
36
|
-
name: 'ABI',
|
|
37
|
-
constant: true,
|
|
38
|
-
stateMutability: 'view',
|
|
39
|
-
payable: false,
|
|
40
|
-
inputs: [
|
|
41
|
-
{
|
|
42
|
-
type: 'bytes32',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: 'uint256',
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
outputs: [
|
|
49
|
-
{
|
|
50
|
-
type: 'uint256',
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: 'bytes',
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'function',
|
|
59
|
-
name: 'clearRecords',
|
|
60
|
-
constant: false,
|
|
61
|
-
payable: false,
|
|
62
|
-
inputs: [
|
|
63
|
-
{
|
|
64
|
-
type: 'bytes32',
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
outputs: [],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: 'function',
|
|
71
|
-
name: 'recordVersions',
|
|
72
|
-
constant: true,
|
|
73
|
-
stateMutability: 'view',
|
|
74
|
-
payable: false,
|
|
75
|
-
inputs: [
|
|
76
|
-
{
|
|
77
|
-
type: 'bytes32',
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
outputs: [
|
|
81
|
-
{
|
|
82
|
-
type: 'uint64',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
type: 'function',
|
|
88
|
-
name: 'setABI',
|
|
89
|
-
constant: false,
|
|
90
|
-
payable: false,
|
|
91
|
-
inputs: [
|
|
92
|
-
{
|
|
93
|
-
type: 'bytes32',
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
type: 'uint256',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
type: 'bytes',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
outputs: [],
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
type: 'function',
|
|
106
|
-
name: 'supportsInterface',
|
|
107
|
-
constant: true,
|
|
108
|
-
stateMutability: 'view',
|
|
109
|
-
payable: false,
|
|
110
|
-
inputs: [
|
|
111
|
-
{
|
|
112
|
-
type: 'bytes4',
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
outputs: [
|
|
116
|
-
{
|
|
117
|
-
type: 'bool',
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
]
|
|
122
|
-
|
|
123
|
-
describe('getAbiRecord()', () => {
|
|
124
|
-
it('should return object for type 1 abi', async () => {
|
|
125
|
-
const result = await getAbiRecord(publicClient, {
|
|
126
|
-
name: 'with-type-1-abi.eth',
|
|
127
|
-
})
|
|
128
|
-
expect(result).toBeTruthy()
|
|
129
|
-
if (result) {
|
|
130
|
-
expect(result.contentType).toBe(1)
|
|
131
|
-
expect(result.decoded).toBe(true)
|
|
132
|
-
expect(result.abi).toMatchObject(dummyABI)
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
it('should return object for type 2 ABI', async () => {
|
|
136
|
-
const result = await getAbiRecord(publicClient, {
|
|
137
|
-
name: 'with-type-2-abi.eth',
|
|
138
|
-
})
|
|
139
|
-
expect(result).toBeTruthy()
|
|
140
|
-
if (result) {
|
|
141
|
-
expect(result.contentType).toBe(2)
|
|
142
|
-
expect(result.decoded).toBe(true)
|
|
143
|
-
expect(result.abi).toMatchObject(dummyABI)
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
it('should return object for type 4 ABI', async () => {
|
|
147
|
-
const result = await getAbiRecord(publicClient, {
|
|
148
|
-
name: 'with-type-4-abi.eth',
|
|
149
|
-
})
|
|
150
|
-
expect(result).toBeTruthy()
|
|
151
|
-
if (result) {
|
|
152
|
-
expect(result.contentType).toBe(4)
|
|
153
|
-
expect(result.decoded).toBe(true)
|
|
154
|
-
expect(result.abi).toMatchObject(dummyABI)
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
it('should return unresolved URI for type 8 ABI', async () => {
|
|
158
|
-
const result = await getAbiRecord(publicClient, {
|
|
159
|
-
name: 'with-type-8-abi.eth',
|
|
160
|
-
})
|
|
161
|
-
expect(result).toBeTruthy()
|
|
162
|
-
if (result) {
|
|
163
|
-
expect(result.contentType).toBe(8)
|
|
164
|
-
expect(result.decoded).toBe(true)
|
|
165
|
-
expect(result.abi).toBe('https://example.com')
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
it('should return undefined if unsupported contentType', async () => {
|
|
169
|
-
const result = await getAbiRecord(publicClient, {
|
|
170
|
-
name: 'with-type-256-abi.eth',
|
|
171
|
-
})
|
|
172
|
-
expect(result).toBeNull()
|
|
173
|
-
})
|
|
174
|
-
})
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { createPublicClient, http } from 'viem'
|
|
2
|
-
import { mainnet } from 'viem/chains'
|
|
3
|
-
import { addEnsContracts } from '../../contracts/addEnsContracts.js'
|
|
4
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
5
|
-
import getAddressRecord from './getAddressRecord.js'
|
|
6
|
-
|
|
7
|
-
const mainnetPublicClient = createPublicClient({
|
|
8
|
-
chain: addEnsContracts(mainnet),
|
|
9
|
-
transport: http('https://web3.ens.domains/v1/mainnet'),
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
describe('getAddressRecord()', () => {
|
|
13
|
-
it('returns the ETH record when no coin is provided', async () => {
|
|
14
|
-
const result = await getAddressRecord(publicClient, {
|
|
15
|
-
name: 'with-profile.eth',
|
|
16
|
-
})
|
|
17
|
-
expect(result).toMatchInlineSnapshot(`
|
|
18
|
-
{
|
|
19
|
-
"id": 60,
|
|
20
|
-
"name": "ETH",
|
|
21
|
-
"value": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
22
|
-
}
|
|
23
|
-
`)
|
|
24
|
-
})
|
|
25
|
-
it('should return the correct address based on a coin ID input as a number', async () => {
|
|
26
|
-
const result = await getAddressRecord(publicClient, {
|
|
27
|
-
name: 'with-profile.eth',
|
|
28
|
-
coin: 61,
|
|
29
|
-
})
|
|
30
|
-
expect(result).toMatchInlineSnapshot(`
|
|
31
|
-
{
|
|
32
|
-
"id": 61,
|
|
33
|
-
"name": "ETC_LEGACY",
|
|
34
|
-
"value": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
35
|
-
}
|
|
36
|
-
`)
|
|
37
|
-
})
|
|
38
|
-
it('should return the correct address based on a coin ID input as a string', async () => {
|
|
39
|
-
const result = await getAddressRecord(publicClient, {
|
|
40
|
-
name: 'with-profile.eth',
|
|
41
|
-
coin: '61',
|
|
42
|
-
})
|
|
43
|
-
expect(result).toMatchInlineSnapshot(`
|
|
44
|
-
{
|
|
45
|
-
"id": 61,
|
|
46
|
-
"name": "ETC_LEGACY",
|
|
47
|
-
"value": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
48
|
-
}
|
|
49
|
-
`)
|
|
50
|
-
})
|
|
51
|
-
it('should return the correct address based on a coin name', async () => {
|
|
52
|
-
const result = await getAddressRecord(publicClient, {
|
|
53
|
-
name: 'with-profile.eth',
|
|
54
|
-
coin: 'ETC_LEGACY',
|
|
55
|
-
})
|
|
56
|
-
expect(result).toMatchInlineSnapshot(`
|
|
57
|
-
{
|
|
58
|
-
"id": 61,
|
|
59
|
-
"name": "ETC_LEGACY",
|
|
60
|
-
"value": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
61
|
-
}
|
|
62
|
-
`)
|
|
63
|
-
})
|
|
64
|
-
it('should return null for a non-existent coin', async () => {
|
|
65
|
-
const result = await getAddressRecord(publicClient, {
|
|
66
|
-
name: 'with-profile.eth',
|
|
67
|
-
coin: 'BNB',
|
|
68
|
-
})
|
|
69
|
-
expect(result).toBeNull()
|
|
70
|
-
})
|
|
71
|
-
it('should return value for label > 255 bytes', async () => {
|
|
72
|
-
const result = await getAddressRecord(mainnetPublicClient, {
|
|
73
|
-
name: `696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969696969.eth`,
|
|
74
|
-
})
|
|
75
|
-
expect(result).toMatchInlineSnapshot(`
|
|
76
|
-
{
|
|
77
|
-
"id": 60,
|
|
78
|
-
"name": "ETH",
|
|
79
|
-
"value": "0xde9ba5F62D6047C4a9cCF24455AA733cCC5B8F41",
|
|
80
|
-
}
|
|
81
|
-
`)
|
|
82
|
-
})
|
|
83
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
2
|
-
import getAvailable from './getAvailable.js'
|
|
3
|
-
|
|
4
|
-
describe('getAvailable', () => {
|
|
5
|
-
it('should return false for a name that is unavailable', async () => {
|
|
6
|
-
const result = await getAvailable(publicClient, { name: 'test123.eth' })
|
|
7
|
-
expect(typeof result).toBe('boolean')
|
|
8
|
-
expect(result).toBe(false)
|
|
9
|
-
})
|
|
10
|
-
it('should return true for a name that is available', async () => {
|
|
11
|
-
const result = await getAvailable(publicClient, {
|
|
12
|
-
name: 'available-name.eth',
|
|
13
|
-
})
|
|
14
|
-
expect(typeof result).toBe('boolean')
|
|
15
|
-
expect(result).toBe(true)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
2
|
-
import getContentHashRecord from './getContentHashRecord.js'
|
|
3
|
-
|
|
4
|
-
describe('getContentHashRecord', () => {
|
|
5
|
-
it('should return null for a non-existent name', async () => {
|
|
6
|
-
const result = await getContentHashRecord(publicClient, {
|
|
7
|
-
name: 'test123123cool.eth',
|
|
8
|
-
})
|
|
9
|
-
expect(result).toBeNull()
|
|
10
|
-
})
|
|
11
|
-
it('should return null for a name with no contenthash record', async () => {
|
|
12
|
-
const result = await getContentHashRecord(publicClient, {
|
|
13
|
-
name: 'with-profile.eth',
|
|
14
|
-
})
|
|
15
|
-
expect(result).toBeNull()
|
|
16
|
-
})
|
|
17
|
-
it('should return the contenthash for a name with the record set', async () => {
|
|
18
|
-
const result = await getContentHashRecord(publicClient, {
|
|
19
|
-
name: 'with-contenthash.eth',
|
|
20
|
-
})
|
|
21
|
-
expect(result).toMatchInlineSnapshot(`
|
|
22
|
-
{
|
|
23
|
-
"decoded": "bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y",
|
|
24
|
-
"protocolType": "ipfs",
|
|
25
|
-
}
|
|
26
|
-
`)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
2
|
-
import getExpiry from './getExpiry.js'
|
|
3
|
-
|
|
4
|
-
describe('getExpiry', () => {
|
|
5
|
-
it('should get the expiry for a .eth name with no other args', async () => {
|
|
6
|
-
const result = await getExpiry(publicClient, { name: 'with-profile.eth' })
|
|
7
|
-
expect(result).toBeTruthy()
|
|
8
|
-
if (result) {
|
|
9
|
-
const { expiry, gracePeriod, status } = result
|
|
10
|
-
expect(expiry.date).toBeInstanceOf(Date)
|
|
11
|
-
expect(typeof expiry.value).toBe('bigint')
|
|
12
|
-
expect(gracePeriod).toBe(7776000)
|
|
13
|
-
expect(status).toBe('active')
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
it('should get the expiry for a wrapped name', async () => {
|
|
17
|
-
const result = await getExpiry(publicClient, {
|
|
18
|
-
name: 'wrapped.eth',
|
|
19
|
-
contract: 'nameWrapper',
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
expect(result).toBeTruthy()
|
|
23
|
-
if (result) {
|
|
24
|
-
const { expiry, gracePeriod, status } = result
|
|
25
|
-
expect(expiry.date).toBeInstanceOf(Date)
|
|
26
|
-
expect(typeof expiry.value).toBe('bigint')
|
|
27
|
-
expect(gracePeriod).toBe(0)
|
|
28
|
-
expect(status).toBe('active')
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
it('should return null for a non .eth name if not wrapped', async () => {
|
|
32
|
-
const result = await getExpiry(publicClient, {
|
|
33
|
-
name: 'sub.with-profile.eth',
|
|
34
|
-
})
|
|
35
|
-
expect(result).toBeNull()
|
|
36
|
-
})
|
|
37
|
-
it('should throw an error for a non .eth name if registrar is specified', async () => {
|
|
38
|
-
try {
|
|
39
|
-
await getExpiry(publicClient, {
|
|
40
|
-
name: 'sub.with-profile.eth',
|
|
41
|
-
contract: 'registrar',
|
|
42
|
-
})
|
|
43
|
-
expect(false).toBeTruthy()
|
|
44
|
-
} catch {
|
|
45
|
-
expect(true).toBeTruthy()
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
})
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from 'viem'
|
|
2
|
-
import {
|
|
3
|
-
deploymentAddresses,
|
|
4
|
-
publicClient,
|
|
5
|
-
testClient,
|
|
6
|
-
waitForTransaction,
|
|
7
|
-
walletClient,
|
|
8
|
-
} from '../../tests/addTestContracts.js'
|
|
9
|
-
import setPrimaryName from '../wallet/setPrimaryName.js'
|
|
10
|
-
import getName from './getName.js'
|
|
11
|
-
|
|
12
|
-
let snapshot: Hex
|
|
13
|
-
let accounts: Address[]
|
|
14
|
-
|
|
15
|
-
beforeAll(async () => {
|
|
16
|
-
accounts = await walletClient.getAddresses()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
beforeEach(async () => {
|
|
20
|
-
snapshot = await testClient.snapshot()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
afterEach(async () => {
|
|
24
|
-
await testClient.revert({ id: snapshot })
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
describe('getName', () => {
|
|
28
|
-
it('should get a primary name from an address', async () => {
|
|
29
|
-
const result = await getName(publicClient, {
|
|
30
|
-
address: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
|
|
31
|
-
})
|
|
32
|
-
expect(result).toMatchInlineSnapshot(`
|
|
33
|
-
{
|
|
34
|
-
"match": true,
|
|
35
|
-
"name": "with-profile.eth",
|
|
36
|
-
"resolverAddress": "${deploymentAddresses.LegacyPublicResolver}",
|
|
37
|
-
"reverseResolverAddress": "${deploymentAddresses.PublicResolver}",
|
|
38
|
-
}
|
|
39
|
-
`)
|
|
40
|
-
})
|
|
41
|
-
it('should return null for an address with no primary name', async () => {
|
|
42
|
-
const result = await getName(publicClient, {
|
|
43
|
-
address: '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0',
|
|
44
|
-
})
|
|
45
|
-
expect(result).toBeNull()
|
|
46
|
-
})
|
|
47
|
-
it('should return with a false match for a name with no forward resolution', async () => {
|
|
48
|
-
const tx = await setPrimaryName(walletClient, {
|
|
49
|
-
name: 'with-profile.eth',
|
|
50
|
-
account: accounts[0],
|
|
51
|
-
})
|
|
52
|
-
await waitForTransaction(tx)
|
|
53
|
-
|
|
54
|
-
const result = await getName(publicClient, {
|
|
55
|
-
address: accounts[0],
|
|
56
|
-
})
|
|
57
|
-
expect(result).toMatchInlineSnapshot(`
|
|
58
|
-
{
|
|
59
|
-
"match": false,
|
|
60
|
-
"name": "with-profile.eth",
|
|
61
|
-
"resolverAddress": "${deploymentAddresses.LegacyPublicResolver}",
|
|
62
|
-
"reverseResolverAddress": "${deploymentAddresses.PublicResolver}",
|
|
63
|
-
}
|
|
64
|
-
`)
|
|
65
|
-
})
|
|
66
|
-
})
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deploymentAddresses,
|
|
3
|
-
publicClient,
|
|
4
|
-
} from '../../tests/addTestContracts.js'
|
|
5
|
-
import getOwner from './getOwner.js'
|
|
6
|
-
|
|
7
|
-
describe('getOwner', () => {
|
|
8
|
-
it('should return correct ownership level and values for a wrapped .eth name', async () => {
|
|
9
|
-
const result = await getOwner(publicClient, { name: 'wrapped.eth' })
|
|
10
|
-
expect(result).toMatchInlineSnapshot(`
|
|
11
|
-
{
|
|
12
|
-
"owner": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
13
|
-
"ownershipLevel": "nameWrapper",
|
|
14
|
-
}
|
|
15
|
-
`)
|
|
16
|
-
})
|
|
17
|
-
it('should return correct ownership level and values for an expired wrapped .eth name', async () => {
|
|
18
|
-
const result = await getOwner(publicClient, { name: 'expired-wrapped.eth' })
|
|
19
|
-
expect(result).toMatchInlineSnapshot(`
|
|
20
|
-
{
|
|
21
|
-
"owner": "${deploymentAddresses.NameWrapper}",
|
|
22
|
-
"ownershipLevel": "registrar",
|
|
23
|
-
"registrant": null,
|
|
24
|
-
}
|
|
25
|
-
`)
|
|
26
|
-
// expect(result).toEqual({
|
|
27
|
-
// ownershipLevel: 'nameWrapper',
|
|
28
|
-
// owner: '0x0000000000000000000000000000000000000000',
|
|
29
|
-
// expired: true,
|
|
30
|
-
// })
|
|
31
|
-
})
|
|
32
|
-
it('should return correct ownership level and values for an unwrapped .eth name', async () => {
|
|
33
|
-
const result = await getOwner(publicClient, { name: 'test123.eth' })
|
|
34
|
-
expect(result).toMatchInlineSnapshot(`
|
|
35
|
-
{
|
|
36
|
-
"owner": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
37
|
-
"ownershipLevel": "registrar",
|
|
38
|
-
"registrant": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
39
|
-
}
|
|
40
|
-
`)
|
|
41
|
-
})
|
|
42
|
-
it('should return correct ownership level and values for an expired unwrapped .eth name', async () => {
|
|
43
|
-
const result = await getOwner(publicClient, { name: 'expired.eth' })
|
|
44
|
-
expect(result).toMatchInlineSnapshot(`
|
|
45
|
-
{
|
|
46
|
-
"owner": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
47
|
-
"ownershipLevel": "registrar",
|
|
48
|
-
"registrant": null,
|
|
49
|
-
}
|
|
50
|
-
`)
|
|
51
|
-
})
|
|
52
|
-
describe('subname', () => {
|
|
53
|
-
it('should return correct ownership level and values for a unwrapped name', async () => {
|
|
54
|
-
const result = await getOwner(publicClient, {
|
|
55
|
-
name: 'test.with-subnames.eth',
|
|
56
|
-
})
|
|
57
|
-
expect(result).toMatchInlineSnapshot(`
|
|
58
|
-
{
|
|
59
|
-
"owner": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
60
|
-
"ownershipLevel": "registry",
|
|
61
|
-
}
|
|
62
|
-
`)
|
|
63
|
-
})
|
|
64
|
-
it('should return correct ownership level and values for a wrapped name', async () => {
|
|
65
|
-
const result = await getOwner(publicClient, {
|
|
66
|
-
name: 'test.wrapped-with-subnames.eth',
|
|
67
|
-
})
|
|
68
|
-
expect(result).toMatchInlineSnapshot(`
|
|
69
|
-
{
|
|
70
|
-
"owner": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
71
|
-
"ownershipLevel": "nameWrapper",
|
|
72
|
-
}
|
|
73
|
-
`)
|
|
74
|
-
})
|
|
75
|
-
it('should return correct ownership level and values for an expired wrapped name', async () => {
|
|
76
|
-
const result = await getOwner(publicClient, {
|
|
77
|
-
name: 'test.expired-wrapped.eth',
|
|
78
|
-
})
|
|
79
|
-
expect(result).toMatchInlineSnapshot(`
|
|
80
|
-
{
|
|
81
|
-
"owner": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
82
|
-
"ownershipLevel": "nameWrapper",
|
|
83
|
-
}
|
|
84
|
-
`)
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
2
|
-
import getPrice from './getPrice.js'
|
|
3
|
-
|
|
4
|
-
const yearCost = BigInt('8561643835626')
|
|
5
|
-
|
|
6
|
-
describe('getPrice', () => {
|
|
7
|
-
it('should return a base and premium price for a name', async () => {
|
|
8
|
-
const result = await getPrice(publicClient, {
|
|
9
|
-
nameOrNames: 'test123.eth',
|
|
10
|
-
duration: 86400,
|
|
11
|
-
})
|
|
12
|
-
expect(result).toBeTruthy()
|
|
13
|
-
if (result) {
|
|
14
|
-
const { base, premium } = result
|
|
15
|
-
expect(base).toBe(yearCost)
|
|
16
|
-
expect(premium).toBe(0n)
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('should return a base and premium price for an array of names', async () => {
|
|
21
|
-
const result = await getPrice(publicClient, {
|
|
22
|
-
nameOrNames: ['test123.eth', 'to-be-renewed.eth'],
|
|
23
|
-
duration: 86400,
|
|
24
|
-
})
|
|
25
|
-
expect(result).toBeTruthy()
|
|
26
|
-
if (result) {
|
|
27
|
-
const { base, premium } = result
|
|
28
|
-
expect(base).toBe(yearCost * 2n)
|
|
29
|
-
expect(premium).toBe(0n)
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should allow labels as inputs', async () => {
|
|
34
|
-
const result = await getPrice(publicClient, {
|
|
35
|
-
nameOrNames: 'test123',
|
|
36
|
-
duration: 86400,
|
|
37
|
-
})
|
|
38
|
-
expect(result).toBeTruthy()
|
|
39
|
-
if (result) {
|
|
40
|
-
const { base, premium } = result
|
|
41
|
-
expect(base).toBe(yearCost)
|
|
42
|
-
expect(premium).toBe(0n)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deploymentAddresses,
|
|
3
|
-
publicClient,
|
|
4
|
-
} from '../../tests/addTestContracts.js'
|
|
5
|
-
import getRecords from './getRecords.js'
|
|
6
|
-
|
|
7
|
-
describe('getRecords()', () => {
|
|
8
|
-
it('works', async () => {
|
|
9
|
-
const result = await getRecords(publicClient, {
|
|
10
|
-
name: 'with-profile.eth',
|
|
11
|
-
records: {
|
|
12
|
-
texts: ['description', 'url'],
|
|
13
|
-
coins: ['60', 'ETC_LEGACY', '0'],
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
expect(result).toMatchInlineSnapshot(`
|
|
17
|
-
{
|
|
18
|
-
"coins": [
|
|
19
|
-
{
|
|
20
|
-
"id": 60,
|
|
21
|
-
"name": "ETH",
|
|
22
|
-
"value": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"id": 61,
|
|
26
|
-
"name": "ETC_LEGACY",
|
|
27
|
-
"value": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"id": 0,
|
|
31
|
-
"name": "BTC",
|
|
32
|
-
"value": "bc1qjqg9slurvjukfl92wp58y94480fvh4uc2pwa6n",
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
"resolverAddress": "${deploymentAddresses.LegacyPublicResolver}",
|
|
36
|
-
"texts": [
|
|
37
|
-
{
|
|
38
|
-
"key": "description",
|
|
39
|
-
"value": "Hello2",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"key": "url",
|
|
43
|
-
"value": "twitter.com",
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
}
|
|
47
|
-
`)
|
|
48
|
-
})
|
|
49
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deploymentAddresses,
|
|
3
|
-
publicClient,
|
|
4
|
-
} from '../../tests/addTestContracts.js'
|
|
5
|
-
import getResolver from './getResolver.js'
|
|
6
|
-
|
|
7
|
-
describe('getResolver', () => {
|
|
8
|
-
it('should find the resolver for a name with a resolver', async () => {
|
|
9
|
-
const result = await getResolver(publicClient, { name: 'with-profile.eth' })
|
|
10
|
-
expect(result).toBe(deploymentAddresses.LegacyPublicResolver)
|
|
11
|
-
})
|
|
12
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { publicClient } from '../../tests/addTestContracts.js'
|
|
2
|
-
import getTextRecord from './getTextRecord.js'
|
|
3
|
-
|
|
4
|
-
describe('getTextRecord()', () => {
|
|
5
|
-
it('should return a record from a key', async () => {
|
|
6
|
-
const result = await getTextRecord(publicClient, {
|
|
7
|
-
name: 'with-profile.eth',
|
|
8
|
-
key: 'description',
|
|
9
|
-
})
|
|
10
|
-
expect(result).toBe('Hello2')
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should return null for a non-existent key', async () => {
|
|
14
|
-
const result = await getTextRecord(publicClient, {
|
|
15
|
-
name: 'with-profile.eth',
|
|
16
|
-
key: 'thiskeydoesntexist',
|
|
17
|
-
})
|
|
18
|
-
expect(result).toBeNull()
|
|
19
|
-
})
|
|
20
|
-
})
|