@ensdomains/ensjs 3.0.0-alpha.11 → 3.0.0-alpha.14
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/contracts/index.d.ts +8 -8
- package/dist/cjs/functions/burnFuses.d.ts +31 -4
- package/dist/cjs/functions/burnFuses.js +36 -6
- package/dist/cjs/functions/commitName.d.ts +26 -0
- package/dist/cjs/functions/commitName.js +24 -0
- package/dist/cjs/functions/getFuses.d.ts +2 -1
- package/dist/cjs/functions/getFuses.js +9 -18
- package/dist/cjs/functions/getHistory.d.ts +0 -30
- package/dist/cjs/functions/getHistory.js +3 -99
- package/dist/cjs/functions/getName.d.ts +2 -2
- package/dist/cjs/functions/getName.js +1 -1
- package/dist/cjs/functions/getProfile.js +1 -1
- package/dist/cjs/functions/getSpecificRecord.d.ts +4 -4
- package/dist/cjs/functions/registerName.d.ts +11 -0
- package/dist/cjs/functions/registerName.js +19 -0
- package/dist/cjs/functions/renewName.d.ts +6 -0
- package/dist/cjs/functions/renewName.js +10 -0
- package/dist/cjs/index.d.ts +24 -35
- package/dist/cjs/index.js +8 -3
- package/dist/cjs/utils/fuses.d.ts +18 -17
- package/dist/cjs/utils/fuses.js +10 -4
- package/dist/cjs/utils/registerHelpers.d.ts +44 -16
- package/dist/cjs/utils/registerHelpers.js +43 -15
- package/dist/cjs/utils/wrapperExpiry.d.ts +1 -1
- package/dist/cjs/utils/writeTx.d.ts +18 -1
- package/dist/cjs/utils/writeTx.js +4 -1
- package/dist/esm/contracts/index.d.ts +8 -8
- package/dist/esm/functions/burnFuses.d.ts +31 -4
- package/dist/esm/functions/burnFuses.js +36 -3
- package/dist/esm/functions/commitName.d.ts +26 -0
- package/dist/esm/functions/commitName.js +21 -0
- package/dist/esm/functions/getFuses.d.ts +2 -1
- package/dist/esm/functions/getFuses.js +10 -19
- package/dist/esm/functions/getHistory.d.ts +0 -30
- package/dist/esm/functions/getHistory.js +2 -96
- package/dist/esm/functions/getName.d.ts +2 -2
- package/dist/esm/functions/getName.js +1 -1
- package/dist/esm/functions/getProfile.js +1 -1
- package/dist/esm/functions/getSpecificRecord.d.ts +4 -4
- package/dist/esm/functions/registerName.d.ts +11 -0
- package/dist/esm/functions/registerName.js +16 -0
- package/dist/esm/functions/renewName.d.ts +6 -0
- package/dist/esm/functions/renewName.js +7 -0
- package/dist/esm/index.d.ts +24 -35
- package/dist/esm/index.js +8 -3
- package/dist/esm/utils/fuses.d.ts +18 -17
- package/dist/esm/utils/fuses.js +9 -3
- package/dist/esm/utils/registerHelpers.d.ts +44 -16
- package/dist/esm/utils/registerHelpers.js +40 -14
- package/dist/esm/utils/wrapperExpiry.d.ts +1 -1
- package/dist/esm/utils/writeTx.d.ts +18 -1
- package/dist/esm/utils/writeTx.js +4 -1
- package/package.json +19 -22
- package/src/functions/burnFuses.test.ts +123 -15
- package/src/functions/burnFuses.ts +101 -10
- package/src/functions/commitName.test.ts +61 -0
- package/src/functions/commitName.ts +36 -0
- package/src/functions/getFuses.test.ts +33 -15
- package/src/functions/getFuses.ts +13 -25
- package/src/functions/getHistory.test.ts +0 -84
- package/src/functions/getHistory.ts +2 -127
- package/src/functions/getName.test.ts +1 -1
- package/src/functions/getName.ts +1 -1
- package/src/functions/getProfile.ts +1 -1
- package/src/functions/registerName.test.ts +59 -0
- package/src/functions/registerName.ts +38 -0
- package/src/functions/renewName.test.ts +44 -0
- package/src/functions/renewName.ts +22 -0
- package/src/index.ts +28 -25
- package/src/utils/fuses.ts +12 -4
- package/src/utils/registerHelpers.ts +107 -49
- package/src/utils/writeTx.ts +12 -2
- package/src/tests/populateTransaction.test.ts +0 -40
- package/src/tests/setup.ts +0 -58
- package/src/tests/signerInjection.test.ts +0 -46
- package/src/tests/withProvider.test.ts +0 -28
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { formatsByCoinType } from '@ensdomains/address-encoder';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
import { decodeContenthash } from '../utils/contentHash';
|
|
4
|
-
import { makeOtherIndexes } from '../utils/makeHashIndexes';
|
|
5
4
|
const eventFormat = {
|
|
6
5
|
Domain: {
|
|
7
6
|
NewOwner: (args) => ({ owner: args.owner.id }),
|
|
@@ -43,7 +42,7 @@ const eventFormat = {
|
|
|
43
42
|
NameChanged: (args) => ({ name: args.name }),
|
|
44
43
|
AbiChanged: (args) => ({ contentType: args.contentType }),
|
|
45
44
|
PubkeyChanged: (args) => ({ x: args.x, y: args.y }),
|
|
46
|
-
TextChanged: (args) => ({ key: args.key }),
|
|
45
|
+
TextChanged: (args) => ({ key: args.key, value: args.value }),
|
|
47
46
|
ContenthashChanged: (args) => ({ hash: decodeContenthash(args.hash) }),
|
|
48
47
|
InterfaceChanged: (args) => ({
|
|
49
48
|
interfaceId: args.interfaceId,
|
|
@@ -63,31 +62,6 @@ const mapEvents = (eventArray, type) => eventArray.map((event) => ({
|
|
|
63
62
|
id: event.id,
|
|
64
63
|
data: eventFormat[type][event.__typename](event),
|
|
65
64
|
}));
|
|
66
|
-
const mapResultDetailDecode = (publicResolver) => (result) => {
|
|
67
|
-
const hashIndexes = makeOtherIndexes(result.input, '10f13a8c');
|
|
68
|
-
const abiLengths = hashIndexes.map((x) => ({
|
|
69
|
-
index: x,
|
|
70
|
-
length: x === 0
|
|
71
|
-
? ethers.utils.hexDataLength(result.input)
|
|
72
|
-
: parseInt(ethers.utils.hexDataSlice(result.input, x - 32, x), 16),
|
|
73
|
-
}));
|
|
74
|
-
const ABIs = abiLengths.map(({ index, length }) => ethers.utils.hexDataSlice(result.input, index, index + length));
|
|
75
|
-
return ABIs.map((abi) => {
|
|
76
|
-
try {
|
|
77
|
-
return publicResolver.interface.decodeFunctionData('setText(bytes32,string,string)', abi);
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
const expandDecode = (prev, curr) => {
|
|
85
|
-
if (!curr)
|
|
86
|
-
return [...prev, { value: null }];
|
|
87
|
-
if (!curr.length)
|
|
88
|
-
return [...prev, curr];
|
|
89
|
-
return [...prev, ...curr];
|
|
90
|
-
};
|
|
91
65
|
export async function getHistory({ gqlInstance }, name) {
|
|
92
66
|
const client = gqlInstance.client;
|
|
93
67
|
const query = gqlInstance.gql `
|
|
@@ -168,6 +142,7 @@ export async function getHistory({ gqlInstance }, name) {
|
|
|
168
142
|
}
|
|
169
143
|
...on TextChanged {
|
|
170
144
|
key
|
|
145
|
+
value
|
|
171
146
|
}
|
|
172
147
|
...on ContenthashChanged {
|
|
173
148
|
hash
|
|
@@ -202,72 +177,3 @@ export async function getHistory({ gqlInstance }, name) {
|
|
|
202
177
|
resolver: resolverHistory,
|
|
203
178
|
};
|
|
204
179
|
}
|
|
205
|
-
export async function getHistoryWithDetail({ contracts, gqlInstance, provider, }, name) {
|
|
206
|
-
const historyRes = await getHistory({ gqlInstance }, name);
|
|
207
|
-
if (!historyRes)
|
|
208
|
-
return;
|
|
209
|
-
const { domain, registration, resolver: resolverHistory } = historyRes;
|
|
210
|
-
const textEvents = resolverHistory.filter((event) => event.type === 'TextChanged');
|
|
211
|
-
const transactions = textEvents.reduce((prev, curr) => {
|
|
212
|
-
if (prev.includes(curr.transactionHash)) {
|
|
213
|
-
return prev;
|
|
214
|
-
}
|
|
215
|
-
return [...prev, curr.transactionHash];
|
|
216
|
-
}, []);
|
|
217
|
-
const publicResolver = await contracts?.getPublicResolver();
|
|
218
|
-
const fetchResult = (await ethers.utils.fetchJson(provider.connection, JSON.stringify(transactions.map((tx, i) => ({
|
|
219
|
-
jsonrpc: '2.0',
|
|
220
|
-
id: i,
|
|
221
|
-
method: 'eth_getTransactionByHash',
|
|
222
|
-
params: [tx],
|
|
223
|
-
})))))
|
|
224
|
-
.map((result) => result.result)
|
|
225
|
-
.map(mapResultDetailDecode(publicResolver))
|
|
226
|
-
.reduce(expandDecode, []);
|
|
227
|
-
const detailedResolverHistory = resolverHistory.map((event) => {
|
|
228
|
-
if (event.type !== 'TextChanged')
|
|
229
|
-
return event;
|
|
230
|
-
const { id } = event;
|
|
231
|
-
const matchedTextInx = textEvents.findIndex((x) => x.id === id);
|
|
232
|
-
return {
|
|
233
|
-
...event,
|
|
234
|
-
data: {
|
|
235
|
-
...event.data,
|
|
236
|
-
value: fetchResult[matchedTextInx] && fetchResult[matchedTextInx].value,
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
return {
|
|
241
|
-
domain,
|
|
242
|
-
registration,
|
|
243
|
-
resolver: detailedResolverHistory,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
export async function getHistoryDetailForTransactionHash({ contracts, provider }, hash, indexInTransaction) {
|
|
247
|
-
const publicResolver = await contracts?.getPublicResolver();
|
|
248
|
-
const transaction = await provider.getTransaction(hash);
|
|
249
|
-
if (!transaction)
|
|
250
|
-
return;
|
|
251
|
-
const result = mapResultDetailDecode(publicResolver)({
|
|
252
|
-
input: transaction.data,
|
|
253
|
-
});
|
|
254
|
-
if (!result || !result.length)
|
|
255
|
-
return;
|
|
256
|
-
if (typeof indexInTransaction === 'number') {
|
|
257
|
-
if (indexInTransaction + 1 > result.length)
|
|
258
|
-
return;
|
|
259
|
-
const resultItem = result[indexInTransaction];
|
|
260
|
-
if (!resultItem ||
|
|
261
|
-
!resultItem.key ||
|
|
262
|
-
(!resultItem.value && resultItem.value !== ''))
|
|
263
|
-
return;
|
|
264
|
-
return { key: resultItem.key, value: resultItem.value };
|
|
265
|
-
}
|
|
266
|
-
return result.map((item) => {
|
|
267
|
-
if (!item.key)
|
|
268
|
-
return;
|
|
269
|
-
if (!item.value && item.value !== '')
|
|
270
|
-
return { key: item.key, value: null };
|
|
271
|
-
return { key: item.key, value: item.value };
|
|
272
|
-
});
|
|
273
|
-
}
|
|
@@ -10,8 +10,8 @@ declare const _default: {
|
|
|
10
10
|
reverseResolverAddress: any;
|
|
11
11
|
resolverAddress: any;
|
|
12
12
|
} | {
|
|
13
|
-
name:
|
|
14
|
-
match
|
|
13
|
+
name: undefined;
|
|
14
|
+
match?: undefined;
|
|
15
15
|
reverseResolverAddress?: undefined;
|
|
16
16
|
resolverAddress?: undefined;
|
|
17
17
|
} | undefined>;
|
|
@@ -215,7 +215,7 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress)
|
|
|
215
215
|
resolverResponse = domain?.resolver;
|
|
216
216
|
}
|
|
217
217
|
else {
|
|
218
|
-
const resolverId = `${resolverAddress}-${id}`;
|
|
218
|
+
const resolverId = `${resolverAddress.toLowerCase()}-${id}`;
|
|
219
219
|
({ resolver: resolverResponse, domain } = await client.request(customResolverQuery, { id, resolverId }));
|
|
220
220
|
}
|
|
221
221
|
if (!domain)
|
|
@@ -52,21 +52,21 @@ export declare const getText: {
|
|
|
52
52
|
decode: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, data: string) => Promise<any>;
|
|
53
53
|
};
|
|
54
54
|
export declare const _getAddr: {
|
|
55
|
-
raw: ({ contracts }: ENSArgs<'contracts'>, name: string, coinType?: string | number
|
|
55
|
+
raw: ({ contracts }: ENSArgs<'contracts'>, name: string, coinType?: string | number, bypassFormat?: boolean) => Promise<{
|
|
56
56
|
to: string;
|
|
57
57
|
data: string;
|
|
58
58
|
}>;
|
|
59
|
-
decode: ({ contracts }: ENSArgs<'contracts'>, data: string, _name: string, coinType?: string | number
|
|
59
|
+
decode: ({ contracts }: ENSArgs<'contracts'>, data: string, _name: string, coinType?: string | number) => Promise<string | {
|
|
60
60
|
coin: string;
|
|
61
61
|
addr: string;
|
|
62
62
|
} | undefined>;
|
|
63
63
|
};
|
|
64
64
|
export declare const getAddr: {
|
|
65
|
-
raw: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, name: string, coinType?: string | number
|
|
65
|
+
raw: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, name: string, coinType?: string | number) => Promise<{
|
|
66
66
|
to: string;
|
|
67
67
|
data: string;
|
|
68
68
|
}>;
|
|
69
|
-
decode: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, data: string, _name: string, coinType?: string | number
|
|
69
|
+
decode: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, data: string, _name: string, coinType?: string | number) => Promise<string | {
|
|
70
70
|
coin: string;
|
|
71
71
|
addr: string;
|
|
72
72
|
} | undefined>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { ENSArgs } from '..';
|
|
3
|
+
import { CommitmentParams } from '../utils/registerHelpers';
|
|
4
|
+
declare type Params = Omit<CommitmentParams, 'name' | 'resolver'> & {
|
|
5
|
+
resolverAddress?: string;
|
|
6
|
+
secret: string;
|
|
7
|
+
wrapperExpiry: number;
|
|
8
|
+
value: BigNumber;
|
|
9
|
+
};
|
|
10
|
+
export default function ({ contracts }: ENSArgs<'contracts'>, name: string, { resolverAddress, value, ...params }: Params): Promise<import("ethers").PopulatedTransaction>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { makeRegistrationData, } from '../utils/registerHelpers';
|
|
2
|
+
export default async function ({ contracts }, name, { resolverAddress, value, ...params }) {
|
|
3
|
+
const labels = name.split('.');
|
|
4
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
5
|
+
throw new Error('Currently only .eth TLD registrations are supported');
|
|
6
|
+
const controller = await contracts.getEthRegistrarController();
|
|
7
|
+
const _resolver = await contracts.getPublicResolver(undefined, resolverAddress);
|
|
8
|
+
const generatedParams = makeRegistrationData({
|
|
9
|
+
name,
|
|
10
|
+
resolver: _resolver,
|
|
11
|
+
...params,
|
|
12
|
+
});
|
|
13
|
+
return controller.populateTransaction.register(...generatedParams, {
|
|
14
|
+
value,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default async function ({ contracts }, name, { duration, value, }) {
|
|
2
|
+
const labels = name.split('.');
|
|
3
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
4
|
+
throw new Error('Currently only .eth TLD renewals are supported');
|
|
5
|
+
const controller = await contracts.getEthRegistrarController();
|
|
6
|
+
return controller.populateTransaction.renew(labels[0], duration, { value });
|
|
7
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ import ContractManager from './contracts';
|
|
|
4
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
5
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
6
|
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type commitName from './functions/commitName';
|
|
7
8
|
import type createSubname from './functions/createSubname';
|
|
8
9
|
import type deleteSubname from './functions/deleteSubname';
|
|
10
|
+
import registerName from './functions/registerName';
|
|
11
|
+
import renewName from './functions/renewName';
|
|
9
12
|
import type setName from './functions/setName';
|
|
10
13
|
import type setRecord from './functions/setRecord';
|
|
11
14
|
import type setRecords from './functions/setRecords';
|
|
@@ -36,7 +39,9 @@ declare type WriteOptions = {
|
|
|
36
39
|
};
|
|
37
40
|
declare type OptionalWriteOptions<F> = F extends (x: any, arg_0: infer Z, options?: infer P) => infer R ? (name: Z, options?: P & WriteOptions) => R : F extends (x: any, arg_0: infer Z, options: infer P) => infer R ? (name: Z, options: P & WriteOptions) => R : never;
|
|
38
41
|
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
39
|
-
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction
|
|
42
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction & {
|
|
43
|
+
customData?: Record<string, any>;
|
|
44
|
+
}>;
|
|
40
45
|
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
41
46
|
}
|
|
42
47
|
export declare type RawFunction = {
|
|
@@ -70,6 +75,16 @@ export declare class ENS {
|
|
|
70
75
|
contracts?: ContractManager;
|
|
71
76
|
getContractAddress: (networkId: SupportedNetworkId) => import("./contracts/getContractAddress").ContractAddressFetch;
|
|
72
77
|
gqlInstance: GqlManager;
|
|
78
|
+
fuses: {
|
|
79
|
+
CAN_DO_EVERYTHING: number;
|
|
80
|
+
CANNOT_UNWRAP: 1;
|
|
81
|
+
CANNOT_BURN_FUSES: 2;
|
|
82
|
+
CANNOT_TRANSFER: 4;
|
|
83
|
+
CANNOT_SET_RESOLVER: 8;
|
|
84
|
+
CANNOT_SET_TTL: 16;
|
|
85
|
+
CANNOT_CREATE_SUBDOMAIN: 32;
|
|
86
|
+
PARENT_CANNOT_CONTROL: 64;
|
|
87
|
+
};
|
|
73
88
|
constructor(options?: ENSOptions);
|
|
74
89
|
/**
|
|
75
90
|
* Checks for an initial provider and if it exists, sets it as the provider
|
|
@@ -206,8 +221,8 @@ export declare class ENS {
|
|
|
206
221
|
reverseResolverAddress: any;
|
|
207
222
|
resolverAddress: any;
|
|
208
223
|
} | {
|
|
209
|
-
name:
|
|
210
|
-
match
|
|
224
|
+
name: undefined;
|
|
225
|
+
match?: undefined;
|
|
211
226
|
reverseResolverAddress?: undefined;
|
|
212
227
|
resolverAddress?: undefined;
|
|
213
228
|
} | undefined>;
|
|
@@ -224,12 +239,13 @@ export declare class ENS {
|
|
|
224
239
|
to: string;
|
|
225
240
|
data: string;
|
|
226
241
|
}>;
|
|
227
|
-
decode: ({ contracts }: ENSArgs<"contracts">, data: string
|
|
242
|
+
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
|
|
228
243
|
fuseObj: {
|
|
229
244
|
[k: string]: boolean;
|
|
230
245
|
};
|
|
231
246
|
expiryDate: Date;
|
|
232
247
|
rawFuses: ethers.BigNumber;
|
|
248
|
+
owner: any;
|
|
233
249
|
} | undefined>;
|
|
234
250
|
}>;
|
|
235
251
|
getHistory: (name: string) => Promise<{
|
|
@@ -255,36 +271,6 @@ export declare class ENS {
|
|
|
255
271
|
data: Record<string, any>;
|
|
256
272
|
}[];
|
|
257
273
|
} | undefined>;
|
|
258
|
-
getHistoryWithDetail: (name: string) => Promise<{
|
|
259
|
-
domain: {
|
|
260
|
-
type: any;
|
|
261
|
-
blockNumber: any;
|
|
262
|
-
transactionHash: any;
|
|
263
|
-
id: any;
|
|
264
|
-
data: Record<string, any>;
|
|
265
|
-
}[];
|
|
266
|
-
registration: {
|
|
267
|
-
type: any;
|
|
268
|
-
blockNumber: any;
|
|
269
|
-
transactionHash: any;
|
|
270
|
-
id: any;
|
|
271
|
-
data: Record<string, any>;
|
|
272
|
-
}[];
|
|
273
|
-
resolver: {
|
|
274
|
-
type: any;
|
|
275
|
-
blockNumber: any;
|
|
276
|
-
transactionHash: any;
|
|
277
|
-
id: any;
|
|
278
|
-
data: Record<string, any>;
|
|
279
|
-
}[];
|
|
280
|
-
} | undefined>;
|
|
281
|
-
getHistoryDetailForTransactionHash: (hash: string, indexInTransaction?: number | undefined) => Promise<({
|
|
282
|
-
key: any;
|
|
283
|
-
value: any;
|
|
284
|
-
} | undefined)[] | {
|
|
285
|
-
key: any;
|
|
286
|
-
value: any;
|
|
287
|
-
} | undefined>;
|
|
288
274
|
getContentHash: GeneratedRawFunction<{
|
|
289
275
|
raw: ({ contracts, universalWrapper }: ENSArgs<"contracts" | "universalWrapper">, name: string) => Promise<{
|
|
290
276
|
to: string;
|
|
@@ -435,6 +421,7 @@ export declare class ENS {
|
|
|
435
421
|
premium: ethers.BigNumber;
|
|
436
422
|
} | undefined>;
|
|
437
423
|
}>;
|
|
424
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
438
425
|
universalWrapper: GeneratedRawFunction<{
|
|
439
426
|
raw: ({ contracts }: ENSArgs<"contracts">, name: string, data: string) => Promise<{
|
|
440
427
|
to: string;
|
|
@@ -473,6 +460,8 @@ export declare class ENS {
|
|
|
473
460
|
createSubname: WriteFunction<typeof createSubname>;
|
|
474
461
|
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
475
462
|
transferSubname: WriteFunction<typeof transferSubname>;
|
|
476
|
-
|
|
463
|
+
commitName: WriteFunction<typeof commitName>;
|
|
464
|
+
registerName: WriteFunction<typeof registerName>;
|
|
465
|
+
renewName: WriteFunction<typeof renewName>;
|
|
477
466
|
}
|
|
478
467
|
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { getContractAddress as _getContractAddress } from './contracts/getContra
|
|
|
3
3
|
import GqlManager from './GqlManager';
|
|
4
4
|
import singleCall from './utils/singleCall';
|
|
5
5
|
import writeTx from './utils/writeTx';
|
|
6
|
+
import fuseEnum from './utils/fuses';
|
|
6
7
|
const graphURIEndpoints = {
|
|
7
8
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
8
9
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -13,6 +14,7 @@ export class ENS {
|
|
|
13
14
|
constructor(options) {
|
|
14
15
|
this.getContractAddress = _getContractAddress;
|
|
15
16
|
this.gqlInstance = new GqlManager();
|
|
17
|
+
this.fuses = fuseEnum;
|
|
16
18
|
/**
|
|
17
19
|
* Checks for an initial provider and if it exists, sets it as the provider
|
|
18
20
|
* @returns {Promise<void>} - A promise that resolves when the provider is checked, and set if needed
|
|
@@ -168,8 +170,6 @@ export class ENS {
|
|
|
168
170
|
'contracts',
|
|
169
171
|
]);
|
|
170
172
|
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
173
|
this.getContentHash = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getContentHash');
|
|
174
174
|
this._getContentHash = this.generateRawFunction('initialGetters', ['contracts'], '_getContentHash');
|
|
175
175
|
this.getAddr = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getAddr');
|
|
@@ -181,6 +181,7 @@ export class ENS {
|
|
|
181
181
|
this.getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
182
182
|
this.getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
183
183
|
this.getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
184
|
+
this.getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
184
185
|
this.universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
185
186
|
this.resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
186
187
|
this.multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
@@ -206,7 +207,11 @@ export class ENS {
|
|
|
206
207
|
this.createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
207
208
|
this.deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
208
209
|
this.transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
209
|
-
this.
|
|
210
|
+
this.commitName = this.generateWriteFunction('commitName', ['contracts']);
|
|
211
|
+
this.registerName = this.generateWriteFunction('registerName', ['contracts']);
|
|
212
|
+
this.renewName = this.generateWriteFunction('renewName', [
|
|
213
|
+
'contracts',
|
|
214
|
+
]);
|
|
210
215
|
this.options = options;
|
|
211
216
|
this.getContractAddress = options?.getContractAddress || _getContractAddress;
|
|
212
217
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
CANNOT_UNWRAP:
|
|
3
|
-
CANNOT_BURN_FUSES:
|
|
4
|
-
CANNOT_TRANSFER:
|
|
5
|
-
CANNOT_SET_RESOLVER:
|
|
6
|
-
CANNOT_SET_TTL:
|
|
7
|
-
CANNOT_CREATE_SUBDOMAIN:
|
|
8
|
-
PARENT_CANNOT_CONTROL:
|
|
1
|
+
export declare const fuseEnum: {
|
|
2
|
+
readonly CANNOT_UNWRAP: 1;
|
|
3
|
+
readonly CANNOT_BURN_FUSES: 2;
|
|
4
|
+
readonly CANNOT_TRANSFER: 4;
|
|
5
|
+
readonly CANNOT_SET_RESOLVER: 8;
|
|
6
|
+
readonly CANNOT_SET_TTL: 16;
|
|
7
|
+
readonly CANNOT_CREATE_SUBDOMAIN: 32;
|
|
8
|
+
readonly PARENT_CANNOT_CONTROL: 64;
|
|
9
9
|
};
|
|
10
|
-
declare const
|
|
10
|
+
export declare const unnamedFuses: readonly [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296];
|
|
11
|
+
declare const fullFuseEnum: {
|
|
11
12
|
CAN_DO_EVERYTHING: number;
|
|
12
|
-
CANNOT_UNWRAP:
|
|
13
|
-
CANNOT_BURN_FUSES:
|
|
14
|
-
CANNOT_TRANSFER:
|
|
15
|
-
CANNOT_SET_RESOLVER:
|
|
16
|
-
CANNOT_SET_TTL:
|
|
17
|
-
CANNOT_CREATE_SUBDOMAIN:
|
|
18
|
-
PARENT_CANNOT_CONTROL:
|
|
13
|
+
CANNOT_UNWRAP: 1;
|
|
14
|
+
CANNOT_BURN_FUSES: 2;
|
|
15
|
+
CANNOT_TRANSFER: 4;
|
|
16
|
+
CANNOT_SET_RESOLVER: 8;
|
|
17
|
+
CANNOT_SET_TTL: 16;
|
|
18
|
+
CANNOT_CREATE_SUBDOMAIN: 32;
|
|
19
|
+
PARENT_CANNOT_CONTROL: 64;
|
|
19
20
|
};
|
|
20
|
-
export default
|
|
21
|
+
export default fullFuseEnum;
|
package/dist/esm/utils/fuses.js
CHANGED
|
@@ -6,7 +6,7 @@ const CANNOT_SET_TTL = 16;
|
|
|
6
6
|
const CANNOT_CREATE_SUBDOMAIN = 32;
|
|
7
7
|
const PARENT_CANNOT_CONTROL = 64;
|
|
8
8
|
const CAN_DO_EVERYTHING = 0;
|
|
9
|
-
export const
|
|
9
|
+
export const fuseEnum = {
|
|
10
10
|
CANNOT_UNWRAP,
|
|
11
11
|
CANNOT_BURN_FUSES,
|
|
12
12
|
CANNOT_TRANSFER,
|
|
@@ -15,7 +15,13 @@ export const testable = {
|
|
|
15
15
|
CANNOT_CREATE_SUBDOMAIN,
|
|
16
16
|
PARENT_CANNOT_CONTROL,
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
|
|
18
|
+
export const unnamedFuses = [
|
|
19
|
+
128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144,
|
|
20
|
+
524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864,
|
|
21
|
+
134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296,
|
|
22
|
+
];
|
|
23
|
+
const fullFuseEnum = {
|
|
24
|
+
...fuseEnum,
|
|
20
25
|
CAN_DO_EVERYTHING,
|
|
21
26
|
};
|
|
27
|
+
export default fullFuseEnum;
|
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
import type { FuseOptions } from '../@types/FuseOptions';
|
|
2
2
|
import type { PublicResolver } from '../generated';
|
|
3
3
|
import { RecordOptions } from './recordHelpers';
|
|
4
|
-
export declare
|
|
5
|
-
export declare const makeCommitment: ({ name, owner, duration, resolver, records, reverseRecord, fuses, }: {
|
|
4
|
+
export declare type RegistrationParams = {
|
|
6
5
|
name: string;
|
|
7
6
|
owner: string;
|
|
8
7
|
duration: number;
|
|
8
|
+
secret: string;
|
|
9
9
|
resolver: PublicResolver;
|
|
10
|
-
records?: RecordOptions
|
|
11
|
-
reverseRecord?: boolean
|
|
12
|
-
fuses?: FuseOptions
|
|
13
|
-
|
|
10
|
+
records?: RecordOptions;
|
|
11
|
+
reverseRecord?: boolean;
|
|
12
|
+
fuses?: FuseOptions;
|
|
13
|
+
wrapperExpiry: number;
|
|
14
|
+
};
|
|
15
|
+
export declare type CommitmentParams = Omit<RegistrationParams, 'secret' | 'wrapperExpiry'> & {
|
|
16
|
+
secret?: string;
|
|
17
|
+
wrapperExpiry?: number;
|
|
18
|
+
};
|
|
19
|
+
export declare type RegistrationTuple = [
|
|
20
|
+
name: string,
|
|
21
|
+
owner: string,
|
|
22
|
+
duration: number,
|
|
23
|
+
secret: string,
|
|
24
|
+
resolver: string,
|
|
25
|
+
data: string[],
|
|
26
|
+
reverseRecord: boolean,
|
|
27
|
+
fuses: string,
|
|
28
|
+
wrapperExpiry: number
|
|
29
|
+
];
|
|
30
|
+
export declare type CommitmentTuple = [
|
|
31
|
+
labelhash: string,
|
|
32
|
+
owner: string,
|
|
33
|
+
duration: number,
|
|
34
|
+
resolver: string,
|
|
35
|
+
data: string[],
|
|
36
|
+
secret: string,
|
|
37
|
+
reverseRecord: boolean,
|
|
38
|
+
fuses: string,
|
|
39
|
+
wrapperExpiry: number
|
|
40
|
+
];
|
|
41
|
+
export declare const randomSecret: () => string;
|
|
42
|
+
export declare const makeCommitmentData: ({ name, owner, duration, resolver, records, reverseRecord, fuses, wrapperExpiry, secret, }: Omit<RegistrationParams, "secret" | "wrapperExpiry"> & {
|
|
43
|
+
secret?: string | undefined;
|
|
44
|
+
wrapperExpiry?: number | undefined;
|
|
45
|
+
} & {
|
|
46
|
+
secret: string;
|
|
47
|
+
}) => CommitmentTuple;
|
|
48
|
+
export declare const makeRegistrationData: (params: RegistrationParams) => RegistrationTuple;
|
|
49
|
+
export declare const makeCommitment: ({ secret, ...inputParams }: CommitmentParams) => {
|
|
14
50
|
secret: string;
|
|
15
51
|
commitment: string;
|
|
52
|
+
wrapperExpiry: number;
|
|
16
53
|
};
|
|
17
|
-
export declare const _makeCommitment: (
|
|
18
|
-
labelhash: string;
|
|
19
|
-
owner: string;
|
|
20
|
-
duration: number;
|
|
21
|
-
secret: string;
|
|
22
|
-
resolver: string;
|
|
23
|
-
data: string[];
|
|
24
|
-
reverseRecord: boolean;
|
|
25
|
-
fuses: string;
|
|
26
|
-
}) => string;
|
|
54
|
+
export declare const _makeCommitment: (params: CommitmentTuple) => string;
|
|
@@ -7,37 +7,63 @@ export const randomSecret = () => {
|
|
|
7
7
|
const bytes = Buffer.allocUnsafe(32);
|
|
8
8
|
return '0x' + crypto.getRandomValues(bytes).toString('hex');
|
|
9
9
|
};
|
|
10
|
-
export const
|
|
10
|
+
export const makeCommitmentData = ({ name, owner, duration, resolver, records, reverseRecord, fuses, wrapperExpiry, secret, }) => {
|
|
11
11
|
const label = labelhash(name.split('.')[0]);
|
|
12
12
|
const hash = namehash(name);
|
|
13
13
|
const resolverAddress = resolver.address;
|
|
14
|
-
const data = records ? generateRecordCallArray(hash, records, resolver) : [];
|
|
15
|
-
const secret = randomSecret();
|
|
16
14
|
const fuseData = fuses ? generateFuseInput(fuses) : '0';
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (reverseRecord) {
|
|
16
|
+
if (!records) {
|
|
17
|
+
records = { coinTypes: [{ key: 'ETH', value: owner }] };
|
|
18
|
+
}
|
|
19
|
+
else if (!records.coinTypes?.find((c) => c.key === 'ETH')) {
|
|
20
|
+
if (!records.coinTypes)
|
|
21
|
+
records.coinTypes = [];
|
|
22
|
+
records.coinTypes.push({ key: 'ETH', value: owner });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const data = records ? generateRecordCallArray(hash, records, resolver) : [];
|
|
26
|
+
return [
|
|
27
|
+
label,
|
|
19
28
|
owner,
|
|
20
29
|
duration,
|
|
21
|
-
|
|
22
|
-
resolver: resolverAddress,
|
|
30
|
+
resolverAddress,
|
|
23
31
|
data,
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
secret,
|
|
33
|
+
!!reverseRecord,
|
|
34
|
+
fuseData,
|
|
35
|
+
wrapperExpiry || Math.floor(Date.now() / 1000) + duration,
|
|
36
|
+
];
|
|
37
|
+
};
|
|
38
|
+
export const makeRegistrationData = (params) => {
|
|
39
|
+
const commitmentData = makeCommitmentData(params);
|
|
40
|
+
commitmentData[0] = params.name.split('.')[0];
|
|
41
|
+
const secret = commitmentData.splice(5, 1)[0];
|
|
42
|
+
commitmentData.splice(3, 0, secret);
|
|
43
|
+
return commitmentData;
|
|
44
|
+
};
|
|
45
|
+
export const makeCommitment = ({ secret = randomSecret(), ...inputParams }) => {
|
|
46
|
+
const generatedParams = makeCommitmentData({
|
|
47
|
+
...inputParams,
|
|
48
|
+
secret,
|
|
26
49
|
});
|
|
50
|
+
const commitment = _makeCommitment(generatedParams);
|
|
27
51
|
return {
|
|
28
52
|
secret,
|
|
29
53
|
commitment,
|
|
54
|
+
wrapperExpiry: generatedParams[8],
|
|
30
55
|
};
|
|
31
56
|
};
|
|
32
|
-
export const _makeCommitment = (
|
|
33
|
-
return utils.
|
|
57
|
+
export const _makeCommitment = (params) => {
|
|
58
|
+
return utils.keccak256(utils.defaultAbiCoder.encode([
|
|
34
59
|
'bytes32',
|
|
35
60
|
'address',
|
|
36
61
|
'uint256',
|
|
37
|
-
'bytes32',
|
|
38
62
|
'address',
|
|
39
63
|
'bytes[]',
|
|
64
|
+
'bytes32',
|
|
40
65
|
'bool',
|
|
41
|
-
'
|
|
42
|
-
|
|
66
|
+
'uint32',
|
|
67
|
+
'uint64',
|
|
68
|
+
], params));
|
|
43
69
|
};
|
|
@@ -2,4 +2,4 @@ import { BigNumber } from 'ethers';
|
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
export declare type Expiry = string | number | Date | BigNumber;
|
|
4
4
|
export declare const MAX_EXPIRY: BigNumber;
|
|
5
|
-
export declare const makeExpiry: ({ getExpiry }: ENSArgs<'getExpiry'>, name: string, expiry?: Expiry
|
|
5
|
+
export declare const makeExpiry: ({ getExpiry }: ENSArgs<'getExpiry'>, name: string, expiry?: Expiry) => Promise<BigNumber>;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
2
|
import type { PopulatedTransaction } from 'ethers';
|
|
3
|
-
declare
|
|
3
|
+
declare type CustomData = Record<string, any>;
|
|
4
|
+
declare const _default: (signer: JsonRpcSigner, populate: boolean) => ({ customData, ...tx }: PopulatedTransaction) => {
|
|
5
|
+
to?: string | undefined;
|
|
6
|
+
from?: string | undefined;
|
|
7
|
+
nonce?: number | undefined;
|
|
8
|
+
gasLimit?: import("ethers").BigNumber | undefined;
|
|
9
|
+
gasPrice?: import("ethers").BigNumber | undefined;
|
|
10
|
+
data?: string | undefined;
|
|
11
|
+
value?: import("ethers").BigNumber | undefined;
|
|
12
|
+
chainId?: number | undefined;
|
|
13
|
+
type?: number | undefined;
|
|
14
|
+
accessList?: import("ethers/lib/utils").AccessList | undefined;
|
|
15
|
+
maxFeePerGas?: import("ethers").BigNumber | undefined;
|
|
16
|
+
maxPriorityFeePerGas?: import("ethers").BigNumber | undefined;
|
|
17
|
+
ccipReadEnabled?: boolean | undefined;
|
|
18
|
+
} | Promise<import("@ethersproject/providers").TransactionResponse | (import("@ethersproject/providers").TransactionResponse & {
|
|
19
|
+
customData: CustomData;
|
|
20
|
+
})>;
|
|
4
21
|
export default _default;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const withCustomData = (tx, customData) => customData ? { ...tx, customData } : tx;
|
|
2
|
+
export default (signer, populate) => ({ customData, ...tx }) => populate
|
|
3
|
+
? withCustomData(tx, customData)
|
|
4
|
+
: signer.sendTransaction(tx).then((r) => withCustomData(r, customData));
|