@ensdomains/ensjs 3.0.0-alpha.54 → 3.0.0-alpha.55
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.
|
@@ -42,7 +42,7 @@ const generateSetAddr = (namehash, coinType, address, resolver) => {
|
|
|
42
42
|
coinTypeInstance = import_address_encoder.formatsByName[coinType.toUpperCase()];
|
|
43
43
|
}
|
|
44
44
|
const inputCoinType = coinTypeInstance.coinType;
|
|
45
|
-
const encodedAddress = coinTypeInstance.decoder(address);
|
|
45
|
+
const encodedAddress = address !== "" ? coinTypeInstance.decoder(address) : "0x";
|
|
46
46
|
return resolver == null ? void 0 : resolver.interface.encodeFunctionData(
|
|
47
47
|
"setAddr(bytes32,uint256,bytes)",
|
|
48
48
|
[namehash, inputCoinType, encodedAddress]
|
|
@@ -11,7 +11,7 @@ var generateSetAddr = (namehash, coinType, address, resolver) => {
|
|
|
11
11
|
coinTypeInstance = formatsByName[coinType.toUpperCase()];
|
|
12
12
|
}
|
|
13
13
|
const inputCoinType = coinTypeInstance.coinType;
|
|
14
|
-
const encodedAddress = coinTypeInstance.decoder(address);
|
|
14
|
+
const encodedAddress = address !== "" ? coinTypeInstance.decoder(address) : "0x";
|
|
15
15
|
return resolver?.interface.encodeFunctionData(
|
|
16
16
|
"setAddr(bytes32,uint256,bytes)",
|
|
17
17
|
[namehash, inputCoinType, encodedAddress]
|
package/package.json
CHANGED
|
@@ -96,6 +96,55 @@ describe('setRecord', () => {
|
|
|
96
96
|
'0x42D63ae25990889E35F215bC95884039Ba354115'.toLowerCase(),
|
|
97
97
|
)
|
|
98
98
|
})
|
|
99
|
+
it('should allow an empty address record to be set', async () => {
|
|
100
|
+
const setRecord = await ensInstance.setRecord('test123.eth', {
|
|
101
|
+
type: 'addr',
|
|
102
|
+
record: {
|
|
103
|
+
key: 'BNB',
|
|
104
|
+
value: 'bnb1rrhqmj4fa28vlrnm89f6gjsgz3ya6h40ptckj0',
|
|
105
|
+
},
|
|
106
|
+
addressOrIndex: 1,
|
|
107
|
+
})
|
|
108
|
+
await setRecord.wait()
|
|
109
|
+
|
|
110
|
+
const universalResolver =
|
|
111
|
+
await ensInstance.contracts!.getUniversalResolver()!
|
|
112
|
+
const publicResolver = await ensInstance.contracts!.getPublicResolver()!
|
|
113
|
+
const getEncodedAddr = () =>
|
|
114
|
+
universalResolver['resolve(bytes,bytes)'](
|
|
115
|
+
hexEncodeName('test123.eth'),
|
|
116
|
+
publicResolver.interface.encodeFunctionData('addr(bytes32,uint256)', [
|
|
117
|
+
namehash('test123.eth'),
|
|
118
|
+
'714',
|
|
119
|
+
]),
|
|
120
|
+
)
|
|
121
|
+
const encodedAddr = await getEncodedAddr()
|
|
122
|
+
const [resultAddr] = publicResolver.interface.decodeFunctionResult(
|
|
123
|
+
'addr(bytes32,uint256)',
|
|
124
|
+
encodedAddr[0],
|
|
125
|
+
)
|
|
126
|
+
// record as hex
|
|
127
|
+
expect(resultAddr).toBe('0x18ee0dcaa9ea8ecf8e7b3953a44a081449dd5eaf')
|
|
128
|
+
|
|
129
|
+
const tx = await ensInstance.setRecord('test123.eth', {
|
|
130
|
+
type: 'addr',
|
|
131
|
+
record: {
|
|
132
|
+
key: 'BNB',
|
|
133
|
+
value: '',
|
|
134
|
+
},
|
|
135
|
+
addressOrIndex: 1,
|
|
136
|
+
})
|
|
137
|
+
expect(tx).toBeTruthy()
|
|
138
|
+
await tx.wait()
|
|
139
|
+
|
|
140
|
+
const encodedEmptyAddr = await getEncodedAddr()
|
|
141
|
+
const [resultEmptyAddr] = publicResolver.interface.decodeFunctionResult(
|
|
142
|
+
'addr(bytes32,uint256)',
|
|
143
|
+
encodedEmptyAddr[0],
|
|
144
|
+
)
|
|
145
|
+
// record as hex
|
|
146
|
+
expect(resultEmptyAddr).toBe('0x')
|
|
147
|
+
})
|
|
99
148
|
it('should allow a contenthash record set', async () => {
|
|
100
149
|
const tx = await ensInstance.setRecord('test123.eth', {
|
|
101
150
|
type: 'contentHash',
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PublicResolver__factory } from '../generated'
|
|
2
|
+
import { namehash } from './normalise'
|
|
3
|
+
import { generateSetAddr } from './recordHelpers'
|
|
4
|
+
|
|
5
|
+
describe('generateSetAddr()', () => {
|
|
6
|
+
it('should allow empty string as address', () => {
|
|
7
|
+
expect(() =>
|
|
8
|
+
generateSetAddr(
|
|
9
|
+
namehash('test'),
|
|
10
|
+
'BNB',
|
|
11
|
+
'',
|
|
12
|
+
PublicResolver__factory.connect(
|
|
13
|
+
'0x0000000000000000000000000000000000000000',
|
|
14
|
+
undefined as any,
|
|
15
|
+
),
|
|
16
|
+
),
|
|
17
|
+
).not.toThrowError()
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -38,7 +38,8 @@ export const generateSetAddr = (
|
|
|
38
38
|
coinTypeInstance = formatsByName[coinType.toUpperCase()]
|
|
39
39
|
}
|
|
40
40
|
const inputCoinType = coinTypeInstance.coinType
|
|
41
|
-
const encodedAddress =
|
|
41
|
+
const encodedAddress =
|
|
42
|
+
address !== '' ? coinTypeInstance.decoder(address) : '0x'
|
|
42
43
|
return resolver?.interface.encodeFunctionData(
|
|
43
44
|
'setAddr(bytes32,uint256,bytes)',
|
|
44
45
|
[namehash, inputCoinType, encodedAddress],
|