@ensdomains/ensjs 3.0.0-alpha.5 → 3.0.0-alpha.8
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.d.ts +3 -0
- package/dist/cjs/GqlManager.js +62 -2
- package/dist/cjs/functions/burnFuses.d.ts +1 -1
- package/dist/cjs/functions/burnFuses.js +1 -1
- package/dist/cjs/functions/createSubname.d.ts +1 -1
- package/dist/cjs/functions/createSubname.js +2 -2
- package/dist/cjs/functions/deleteSubname.d.ts +1 -1
- package/dist/cjs/functions/deleteSubname.js +1 -1
- package/dist/cjs/functions/getProfile.d.ts +4 -1
- package/dist/cjs/functions/getProfile.js +62 -18
- package/dist/cjs/functions/getRecords.d.ts +1 -0
- package/dist/cjs/functions/setName.d.ts +1 -1
- package/dist/cjs/functions/setName.js +2 -2
- package/dist/cjs/functions/setRecords.d.ts +1 -1
- package/dist/cjs/functions/setRecords.js +1 -1
- package/dist/cjs/functions/setResolver.d.ts +1 -1
- package/dist/cjs/functions/setResolver.js +2 -2
- package/dist/cjs/functions/transferName.d.ts +1 -1
- package/dist/cjs/functions/transferName.js +3 -3
- package/dist/cjs/functions/transferSubname.d.ts +1 -1
- package/dist/cjs/functions/transferSubname.js +2 -2
- package/dist/cjs/functions/unwrapName.d.ts +1 -1
- package/dist/cjs/functions/unwrapName.js +2 -2
- package/dist/cjs/functions/wrapName.d.ts +2 -2
- package/dist/cjs/functions/wrapName.js +3 -3
- package/dist/cjs/index.d.ts +34 -52
- package/dist/cjs/index.js +10 -6
- package/dist/cjs/utils/labels.js +4 -3
- package/dist/cjs/utils/normalise.d.ts +1 -1
- package/dist/cjs/utils/normalise.js +10 -3
- package/dist/cjs/utils/writeTx.d.ts +4 -0
- package/dist/cjs/utils/writeTx.js +3 -0
- package/dist/esm/GqlManager.d.ts +3 -0
- package/dist/esm/GqlManager.js +58 -2
- package/dist/esm/functions/burnFuses.d.ts +1 -1
- package/dist/esm/functions/burnFuses.js +1 -1
- package/dist/esm/functions/createSubname.d.ts +1 -1
- package/dist/esm/functions/createSubname.js +2 -2
- package/dist/esm/functions/deleteSubname.d.ts +1 -1
- package/dist/esm/functions/deleteSubname.js +1 -1
- package/dist/esm/functions/getProfile.d.ts +4 -1
- package/dist/esm/functions/getProfile.js +62 -18
- package/dist/esm/functions/getRecords.d.ts +1 -0
- package/dist/esm/functions/setName.d.ts +1 -1
- package/dist/esm/functions/setName.js +2 -2
- package/dist/esm/functions/setRecords.d.ts +1 -1
- package/dist/esm/functions/setRecords.js +1 -1
- package/dist/esm/functions/setResolver.d.ts +1 -1
- package/dist/esm/functions/setResolver.js +2 -2
- package/dist/esm/functions/transferName.d.ts +1 -1
- package/dist/esm/functions/transferName.js +3 -3
- package/dist/esm/functions/transferSubname.d.ts +1 -1
- package/dist/esm/functions/transferSubname.js +2 -2
- package/dist/esm/functions/unwrapName.d.ts +1 -1
- package/dist/esm/functions/unwrapName.js +2 -2
- package/dist/esm/functions/wrapName.d.ts +2 -2
- package/dist/esm/functions/wrapName.js +3 -3
- package/dist/esm/index.d.ts +34 -52
- package/dist/esm/index.js +10 -6
- package/dist/esm/utils/labels.js +4 -3
- package/dist/esm/utils/normalise.d.ts +1 -1
- package/dist/esm/utils/normalise.js +10 -3
- package/dist/esm/utils/writeTx.d.ts +4 -0
- package/dist/esm/utils/writeTx.js +1 -0
- package/package.json +7 -5
- package/src/GqlManager.test.ts +170 -0
- package/src/GqlManager.ts +67 -2
- package/src/functions/burnFuses.ts +1 -1
- package/src/functions/createSubname.ts +2 -2
- package/src/functions/deleteSubname.ts +1 -1
- package/src/functions/getProfile.test.ts +16 -1
- package/src/functions/getProfile.ts +82 -19
- package/src/functions/getRecords.ts +1 -0
- package/src/functions/setName.ts +5 -5
- package/src/functions/setRecords.ts +2 -2
- package/src/functions/setResolver.ts +5 -2
- package/src/functions/transferName.ts +5 -3
- package/src/functions/transferSubname.ts +11 -2
- package/src/functions/unwrapName.ts +10 -2
- package/src/functions/wrapName.ts +5 -8
- package/src/index.ts +37 -12
- package/src/tests/populateTransaction.test.ts +40 -0
- package/src/tests/signerInjection.test.ts +7 -3
- package/src/utils/labels.ts +5 -3
- package/src/utils/normalise.ts +10 -4
- package/src/utils/writeTx.ts +6 -0
package/dist/cjs/GqlManager.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare const enter: (node: any) => any;
|
|
2
|
+
export declare const requestMiddleware: (visit: any, parse: any) => (request: any) => any;
|
|
3
|
+
export declare const responseMiddleware: (traverse: any) => (response: any) => any;
|
|
1
4
|
export default class GqlManager {
|
|
2
5
|
gql: any;
|
|
3
6
|
client?: any | null;
|
package/dist/cjs/GqlManager.js
CHANGED
|
@@ -23,13 +23,73 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.responseMiddleware = exports.requestMiddleware = exports.enter = void 0;
|
|
27
|
+
// @ts-nocheck
|
|
28
|
+
const normalise_1 = require("./utils/normalise");
|
|
29
|
+
const generateSelection = (selection) => ({
|
|
30
|
+
kind: 'Field',
|
|
31
|
+
name: {
|
|
32
|
+
kind: 'Name',
|
|
33
|
+
value: selection,
|
|
34
|
+
},
|
|
35
|
+
arguments: [],
|
|
36
|
+
directives: [],
|
|
37
|
+
alias: undefined,
|
|
38
|
+
selectionSet: undefined,
|
|
39
|
+
});
|
|
40
|
+
const enter = (node) => {
|
|
41
|
+
if (node.kind === 'SelectionSet') {
|
|
42
|
+
const id = node.selections.find((x) => x.name && x.name.value === 'id');
|
|
43
|
+
const name = node.selections.find((x) => x.name && x.name.value === 'name');
|
|
44
|
+
if (!id && name) {
|
|
45
|
+
node.selections = [...node.selections, generateSelection('id')];
|
|
46
|
+
return node;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.enter = enter;
|
|
51
|
+
const requestMiddleware = (visit, parse) => (request) => {
|
|
52
|
+
const requestBody = JSON.parse(request.body);
|
|
53
|
+
const rawQuery = requestBody.query;
|
|
54
|
+
const parsedQuery = parse(rawQuery);
|
|
55
|
+
const updatedQuery = visit(parsedQuery, { enter: exports.enter });
|
|
56
|
+
const updatedBody = { ...requestBody, query: updatedQuery.loc.source.body };
|
|
57
|
+
return {
|
|
58
|
+
...request,
|
|
59
|
+
body: JSON.stringify(updatedBody),
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.requestMiddleware = requestMiddleware;
|
|
63
|
+
const responseMiddleware = (traverse) => (response) => {
|
|
64
|
+
traverse(response).forEach(function (responseItem) {
|
|
65
|
+
if (responseItem instanceof Object && responseItem.name) {
|
|
66
|
+
//Name already in hashed form
|
|
67
|
+
if (responseItem.name && responseItem.name.includes('[')) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const hashedName = (0, normalise_1.namehash)(responseItem.name);
|
|
71
|
+
if (responseItem.id !== hashedName) {
|
|
72
|
+
this.update({ ...responseItem, name: hashedName, invalidName: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return response;
|
|
77
|
+
};
|
|
78
|
+
exports.responseMiddleware = responseMiddleware;
|
|
26
79
|
class GqlManager {
|
|
27
80
|
gql = () => null;
|
|
28
81
|
client = null;
|
|
29
82
|
setUrl = async (url) => {
|
|
30
83
|
if (url) {
|
|
31
|
-
const imported = await Promise.
|
|
32
|
-
|
|
84
|
+
const [imported, traverse, { visit, parse }] = await Promise.all([
|
|
85
|
+
Promise.resolve().then(() => __importStar(require('graphql-request'))),
|
|
86
|
+
Promise.resolve().then(() => __importStar(require('traverse'))),
|
|
87
|
+
Promise.resolve().then(() => __importStar(require('graphql/language'))),
|
|
88
|
+
]);
|
|
89
|
+
this.client = new imported.GraphQLClient(url, {
|
|
90
|
+
requestMiddleware: (0, exports.requestMiddleware)(visit, parse),
|
|
91
|
+
responseMiddleware: (0, exports.responseMiddleware)(traverse.default),
|
|
92
|
+
});
|
|
33
93
|
this.gql = imported.gql;
|
|
34
94
|
}
|
|
35
95
|
else {
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { fusesToBurn, }: {
|
|
4
4
|
fusesToBurn: FuseOptions;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -9,6 +9,6 @@ async function default_1({ contracts, signer }, name, { fusesToBurn, }) {
|
|
|
9
9
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
10
10
|
const hash = (0, normalise_1.namehash)(name);
|
|
11
11
|
const encodedFuses = (0, generateFuseInput_1.default)(fusesToBurn);
|
|
12
|
-
return nameWrapper.burnFuses(hash, encodedFuses);
|
|
12
|
+
return nameWrapper.populateTransaction.burnFuses(hash, encodedFuses);
|
|
13
13
|
}
|
|
14
14
|
exports.default = default_1;
|
|
@@ -11,5 +11,5 @@ declare type NameWrapperArgs = {
|
|
|
11
11
|
fuses?: FuseOptions;
|
|
12
12
|
} & BaseArgs;
|
|
13
13
|
declare type Args = BaseArgs | NameWrapperArgs;
|
|
14
|
-
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.
|
|
14
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.PopulatedTransaction>;
|
|
15
15
|
export {};
|
|
@@ -23,14 +23,14 @@ async function default_1({ contracts, signer }, name, { owner, resolverAddress,
|
|
|
23
23
|
switch (contract) {
|
|
24
24
|
case 'registry': {
|
|
25
25
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
26
|
-
return registry.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
26
|
+
return registry.populateTransaction.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
27
27
|
}
|
|
28
28
|
case 'nameWrapper': {
|
|
29
29
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
30
30
|
const generatedFuses = 'fuses' in wrapperArgs && wrapperArgs.fuses
|
|
31
31
|
? (0, generateFuseInput_1.default)(wrapperArgs.fuses)
|
|
32
32
|
: '0';
|
|
33
|
-
return nameWrapper.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
33
|
+
return nameWrapper.populateTransaction.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
34
34
|
}
|
|
35
35
|
default: {
|
|
36
36
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
2
|
export default function ({ transferSubname }: ENSArgs<'transferSubname'>, name: string, { contract, }: {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
|
-
}): Promise<import("ethers").
|
|
4
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
async function default_1({ transferSubname }, name, { contract, }) {
|
|
4
|
-
return transferSubname(name, {
|
|
4
|
+
return transferSubname.populateTransaction(name, {
|
|
5
5
|
contract,
|
|
6
6
|
address: '0x0000000000000000000000000000000000000000',
|
|
7
7
|
});
|
|
@@ -26,5 +26,8 @@ declare type ProfileOptions = {
|
|
|
26
26
|
texts?: boolean | string[];
|
|
27
27
|
coinTypes?: boolean | string[];
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
declare type InputProfileOptions = ProfileOptions & {
|
|
30
|
+
resolverAddress?: string;
|
|
31
|
+
};
|
|
32
|
+
export default function ({ contracts, gqlInstance, getName, _getAddr, _getContentHash, _getText, resolverMulticallWrapper, multicallWrapper, }: ENSArgs<'contracts' | 'gqlInstance' | 'getName' | '_getText' | '_getAddr' | '_getContentHash' | 'resolverMulticallWrapper' | 'multicallWrapper'>, nameOrAddress: string, options?: InputProfileOptions): Promise<ResolvedProfile | undefined>;
|
|
30
33
|
export {};
|
|
@@ -4,6 +4,7 @@ const address_encoder_1 = require("@ensdomains/address-encoder");
|
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
const contentHash_1 = require("../utils/contentHash");
|
|
6
6
|
const hexEncodedName_1 = require("../utils/hexEncodedName");
|
|
7
|
+
const normalise_1 = require("../utils/normalise");
|
|
7
8
|
const validation_1 = require("../utils/validation");
|
|
8
9
|
const makeMulticallData = async ({ _getAddr, _getContentHash, _getText, resolverMulticallWrapper, }, name, options) => {
|
|
9
10
|
let calls = [];
|
|
@@ -49,13 +50,19 @@ const fetchWithoutResolverMulticall = async ({ multicallWrapper }, calls, resolv
|
|
|
49
50
|
}));
|
|
50
51
|
return (await multicallWrapper(callsWithResolver)).map((x) => x[1]);
|
|
51
52
|
};
|
|
52
|
-
const getDataForName = async ({ contracts, _getAddr, _getContentHash, _getText, resolverMulticallWrapper, multicallWrapper, }, name, options, fallbackResolver) => {
|
|
53
|
+
const getDataForName = async ({ contracts, _getAddr, _getContentHash, _getText, resolverMulticallWrapper, multicallWrapper, }, name, options, fallbackResolver, specificResolver) => {
|
|
53
54
|
const universalResolver = await contracts?.getUniversalResolver();
|
|
54
55
|
const { data, calls } = await makeMulticallData({ _getAddr, _getContentHash, _getText, resolverMulticallWrapper }, name, options);
|
|
55
56
|
let resolvedData;
|
|
56
57
|
let useFallbackResolver = false;
|
|
57
58
|
try {
|
|
58
|
-
|
|
59
|
+
if (specificResolver) {
|
|
60
|
+
const publicResolver = await contracts?.getPublicResolver(undefined, specificResolver);
|
|
61
|
+
resolvedData = await publicResolver?.callStatic.multicall(calls.map((x) => x.data));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
resolvedData = await universalResolver?.resolve((0, hexEncodedName_1.hexEncodeName)(name), data);
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
catch {
|
|
61
68
|
useFallbackResolver = true;
|
|
@@ -63,12 +70,18 @@ const getDataForName = async ({ contracts, _getAddr, _getContentHash, _getText,
|
|
|
63
70
|
let resolverAddress;
|
|
64
71
|
let recordData;
|
|
65
72
|
if (useFallbackResolver) {
|
|
66
|
-
resolverAddress = fallbackResolver;
|
|
73
|
+
resolverAddress = specificResolver || fallbackResolver;
|
|
67
74
|
recordData = await fetchWithoutResolverMulticall({ multicallWrapper }, calls, resolverAddress);
|
|
68
75
|
}
|
|
69
76
|
else {
|
|
70
|
-
resolverAddress = resolvedData['1'];
|
|
71
|
-
|
|
77
|
+
resolverAddress = specificResolver || resolvedData['1'];
|
|
78
|
+
if (specificResolver) {
|
|
79
|
+
recordData = resolvedData;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
;
|
|
83
|
+
[recordData] = await resolverMulticallWrapper.decode(resolvedData['0']);
|
|
84
|
+
}
|
|
72
85
|
}
|
|
73
86
|
const matchAddress = recordData[calls.findIndex((x) => x.key === '60')];
|
|
74
87
|
return {
|
|
@@ -160,10 +173,10 @@ const formatRecords = async ({ _getText, _getAddr, _getContentHash, }, data, cal
|
|
|
160
173
|
}
|
|
161
174
|
return returnedResponse;
|
|
162
175
|
};
|
|
163
|
-
const graphFetch = async ({ gqlInstance }, name, wantedRecords) => {
|
|
176
|
+
const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress) => {
|
|
164
177
|
const query = gqlInstance.gql `
|
|
165
|
-
query getRecords($
|
|
166
|
-
|
|
178
|
+
query getRecords($id: String!) {
|
|
179
|
+
domain(id: $id) {
|
|
167
180
|
isMigrated
|
|
168
181
|
createdAt
|
|
169
182
|
resolver {
|
|
@@ -177,12 +190,39 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords) => {
|
|
|
177
190
|
}
|
|
178
191
|
}
|
|
179
192
|
}
|
|
193
|
+
`;
|
|
194
|
+
const customResolverQuery = gqlInstance.gql `
|
|
195
|
+
query getRecordsWithCustomResolver($id: String!, $resolverId: String!) {
|
|
196
|
+
domain(id: $id) {
|
|
197
|
+
isMigrated
|
|
198
|
+
createdAt
|
|
199
|
+
}
|
|
200
|
+
resolver(id: $resolverId) {
|
|
201
|
+
texts
|
|
202
|
+
coinTypes
|
|
203
|
+
contentHash
|
|
204
|
+
addr {
|
|
205
|
+
id
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
180
209
|
`;
|
|
181
210
|
const client = gqlInstance.client;
|
|
182
|
-
const
|
|
183
|
-
|
|
211
|
+
const id = (0, normalise_1.namehash)(name);
|
|
212
|
+
let domain;
|
|
213
|
+
let resolverResponse;
|
|
214
|
+
if (!resolverAddress) {
|
|
215
|
+
;
|
|
216
|
+
({ domain } = await client.request(query, { id }));
|
|
217
|
+
resolverResponse = domain?.resolver;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const resolverId = `${resolverAddress}-${id}`;
|
|
221
|
+
({ resolver: resolverResponse, domain } = await client.request(customResolverQuery, { id, resolverId }));
|
|
222
|
+
}
|
|
223
|
+
if (!domain)
|
|
184
224
|
return;
|
|
185
|
-
const
|
|
225
|
+
const { isMigrated, createdAt } = domain;
|
|
186
226
|
let returnedRecords = {};
|
|
187
227
|
if (!resolverResponse)
|
|
188
228
|
return { isMigrated, createdAt };
|
|
@@ -190,7 +230,7 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords) => {
|
|
|
190
230
|
return {
|
|
191
231
|
isMigrated,
|
|
192
232
|
createdAt,
|
|
193
|
-
graphResolverAddress: resolverResponse.address,
|
|
233
|
+
graphResolverAddress: resolverResponse.address || resolverAddress,
|
|
194
234
|
};
|
|
195
235
|
Object.keys(wantedRecords).forEach((key) => {
|
|
196
236
|
const data = wantedRecords[key];
|
|
@@ -207,18 +247,22 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords) => {
|
|
|
207
247
|
...returnedRecords,
|
|
208
248
|
isMigrated,
|
|
209
249
|
createdAt,
|
|
210
|
-
graphResolverAddress: resolverResponse.address,
|
|
250
|
+
graphResolverAddress: resolverResponse.address || resolverAddress,
|
|
211
251
|
};
|
|
212
252
|
};
|
|
213
253
|
const getProfileFromName = async ({ contracts, gqlInstance, _getAddr, _getContentHash, _getText, resolverMulticallWrapper, multicallWrapper, }, name, options) => {
|
|
214
|
-
const
|
|
215
|
-
|
|
254
|
+
const { resolverAddress, ..._options } = options || {};
|
|
255
|
+
const optsLength = Object.keys(_options).length;
|
|
256
|
+
const usingOptions = !optsLength || _options?.texts === true || _options?.coinTypes === true
|
|
257
|
+
? optsLength
|
|
258
|
+
? _options
|
|
259
|
+
: { contentHash: true, texts: true, coinTypes: true }
|
|
216
260
|
: undefined;
|
|
217
|
-
const graphResult = await graphFetch({ gqlInstance }, name, usingOptions);
|
|
261
|
+
const graphResult = await graphFetch({ gqlInstance }, name, usingOptions, resolverAddress);
|
|
218
262
|
if (!graphResult)
|
|
219
263
|
return;
|
|
220
264
|
const { isMigrated, createdAt, graphResolverAddress, ...wantedRecords } = graphResult;
|
|
221
|
-
if (!graphResolverAddress)
|
|
265
|
+
if (!graphResolverAddress && !options?.resolverAddress)
|
|
222
266
|
return { isMigrated, createdAt, message: "Name doesn't have a resolver" };
|
|
223
267
|
const result = await getDataForName({
|
|
224
268
|
contracts,
|
|
@@ -227,7 +271,7 @@ const getProfileFromName = async ({ contracts, gqlInstance, _getAddr, _getConten
|
|
|
227
271
|
_getText,
|
|
228
272
|
resolverMulticallWrapper,
|
|
229
273
|
multicallWrapper,
|
|
230
|
-
}, name, usingOptions ? wantedRecords : options, graphResolverAddress);
|
|
274
|
+
}, name, usingOptions ? wantedRecords : options, graphResolverAddress, options?.resolverAddress);
|
|
231
275
|
if (!result)
|
|
232
276
|
return { isMigrated, createdAt, message: "Records fetch didn't complete" };
|
|
233
277
|
return { ...result, isMigrated, createdAt, message: undefined };
|
|
@@ -3,6 +3,7 @@ declare type ProfileOptions = {
|
|
|
3
3
|
contentHash?: boolean;
|
|
4
4
|
texts?: boolean | string[];
|
|
5
5
|
coinTypes?: boolean | string[];
|
|
6
|
+
resolverAddress?: string;
|
|
6
7
|
};
|
|
7
8
|
export default function ({ getProfile }: ENSArgs<'getProfile'>, name: string, options?: ProfileOptions): Promise<{
|
|
8
9
|
isMigrated: boolean | null;
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { address, resolver, }?: {
|
|
3
3
|
address?: string;
|
|
4
4
|
resolver?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -5,8 +5,8 @@ async function default_1({ contracts, signer }, name, { address, resolver, } = {
|
|
|
5
5
|
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(signer);
|
|
6
6
|
if (address) {
|
|
7
7
|
const publicResolver = await contracts?.getPublicResolver();
|
|
8
|
-
return reverseRegistrar
|
|
8
|
+
return reverseRegistrar.populateTransaction.setNameForAddr(address, signerAddress, resolver || publicResolver.address, name);
|
|
9
9
|
}
|
|
10
|
-
return reverseRegistrar
|
|
10
|
+
return reverseRegistrar.populateTransaction.setName(name);
|
|
11
11
|
}
|
|
12
12
|
exports.default = default_1;
|
|
@@ -3,4 +3,4 @@ import { RecordOptions } from '../utils/recordHelpers';
|
|
|
3
3
|
export default function ({ contracts, provider, getResolver, signer, }: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>, name: string, { records, resolverAddress, }: {
|
|
4
4
|
records: RecordOptions;
|
|
5
5
|
resolverAddress?: string;
|
|
6
|
-
}): Promise<import("ethers").
|
|
6
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -19,6 +19,6 @@ async function default_1({ contracts, provider, getResolver, signer, }, name, {
|
|
|
19
19
|
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
20
20
|
const hash = (0, normalise_1.namehash)(name);
|
|
21
21
|
const calls = (0, recordHelpers_1.generateRecordCallArray)(hash, records, resolver);
|
|
22
|
-
return resolver
|
|
22
|
+
return resolver.populateTransaction.multicall(calls);
|
|
23
23
|
}
|
|
24
24
|
exports.default = default_1;
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, resolver, }: {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
4
|
resolver?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -8,11 +8,11 @@ async function default_1({ contracts, signer }, name, { contract, resolver, }) {
|
|
|
8
8
|
switch (contract) {
|
|
9
9
|
case 'registry': {
|
|
10
10
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
11
|
-
return registry.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
11
|
+
return registry.populateTransaction.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
12
12
|
}
|
|
13
13
|
case 'nameWrapper': {
|
|
14
14
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
15
|
-
return nameWrapper.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
15
|
+
return nameWrapper.populateTransaction.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
16
16
|
}
|
|
17
17
|
default: {
|
|
18
18
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -3,4 +3,4 @@ import { ENSArgs } from '..';
|
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
|
|
4
4
|
newOwner: string;
|
|
5
5
|
contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
|
|
6
|
-
}): Promise<ethers.
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -7,7 +7,7 @@ async function default_1({ contracts, signer }, name, { newOwner, contract, }) {
|
|
|
7
7
|
switch (contract) {
|
|
8
8
|
case 'registry': {
|
|
9
9
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
10
|
-
return registry.setOwner((0, normalise_1.namehash)(name), newOwner);
|
|
10
|
+
return registry.populateTransaction.setOwner((0, normalise_1.namehash)(name), newOwner);
|
|
11
11
|
}
|
|
12
12
|
case 'baseRegistrar': {
|
|
13
13
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
@@ -15,11 +15,11 @@ async function default_1({ contracts, signer }, name, { newOwner, contract, }) {
|
|
|
15
15
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
16
16
|
throw new Error('Invalid name for baseRegistrar');
|
|
17
17
|
}
|
|
18
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
18
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
19
19
|
}
|
|
20
20
|
case 'nameWrapper': {
|
|
21
21
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
22
|
-
return nameWrapper.safeTransferFrom(address, newOwner, (0, normalise_1.namehash)(name), 1, '0x');
|
|
22
|
+
return nameWrapper.populateTransaction.safeTransferFrom(address, newOwner, (0, normalise_1.namehash)(name), 1, '0x');
|
|
23
23
|
}
|
|
24
24
|
default: {
|
|
25
25
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -3,4 +3,4 @@ import { ENSArgs } from '..';
|
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, address, }: {
|
|
4
4
|
contract: 'registry' | 'nameWrapper';
|
|
5
5
|
address: string;
|
|
6
|
-
}): Promise<ethers.
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -10,11 +10,11 @@ async function default_1({ contracts, signer }, name, { contract, address, }) {
|
|
|
10
10
|
switch (contract) {
|
|
11
11
|
case 'registry': {
|
|
12
12
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
13
|
-
return registry.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
13
|
+
return registry.populateTransaction.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
14
14
|
}
|
|
15
15
|
case 'nameWrapper': {
|
|
16
16
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
17
|
-
return nameWrapper.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
17
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
18
18
|
}
|
|
19
19
|
default: {
|
|
20
20
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newController, newRegistrant, }: {
|
|
3
3
|
newController: string;
|
|
4
4
|
newRegistrant?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -11,13 +11,13 @@ async function default_1({ contracts, signer }, name, { newController, newRegist
|
|
|
11
11
|
if (!newRegistrant) {
|
|
12
12
|
throw new Error('newRegistrant must be specified for .eth names');
|
|
13
13
|
}
|
|
14
|
-
return nameWrapper.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
14
|
+
return nameWrapper.populateTransaction.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
if (newRegistrant) {
|
|
18
18
|
throw new Error('newRegistrant can only be specified for .eth names');
|
|
19
19
|
}
|
|
20
|
-
return nameWrapper.unwrap(parentNodehash, labelhash, newController);
|
|
20
|
+
return nameWrapper.populateTransaction.unwrap(parentNodehash, labelhash, newController);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.default = default_1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
import type { FuseOptions } from '../@types/FuseOptions';
|
|
4
|
-
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
4
|
+
export default function ({ contracts, signer, populate }: ENSArgs<'contracts' | 'signer' | 'populate'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
5
5
|
wrappedOwner: string;
|
|
6
6
|
fuseOptions?: FuseOptions | string | number;
|
|
7
7
|
resolverAddress?: string;
|
|
8
|
-
}): Promise<ethers.
|
|
8
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -11,7 +11,7 @@ async function wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolv
|
|
|
11
11
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
12
12
|
const labelhash = ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
13
13
|
const data = ethers_1.ethers.utils.defaultAbiCoder.encode(['string', 'address', 'uint32', 'uint64', 'address'], [labels[0], wrappedOwner, '0x0', decodedFuses, resolverAddress]);
|
|
14
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
14
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
15
15
|
}
|
|
16
16
|
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer) {
|
|
17
17
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
@@ -20,9 +20,9 @@ async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolv
|
|
|
20
20
|
if (!hasApproval) {
|
|
21
21
|
throw new Error('NameWrapper must have approval to wrap a name from this address.');
|
|
22
22
|
}
|
|
23
|
-
return nameWrapper.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
23
|
+
return nameWrapper.populateTransaction.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
24
24
|
}
|
|
25
|
-
async function default_1({ contracts, signer }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
25
|
+
async function default_1({ contracts, signer, populate }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
26
26
|
const address = await signer.getAddress();
|
|
27
27
|
let decodedFuses;
|
|
28
28
|
switch (typeof fuseOptions) {
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import { ContractTransaction, ethers, PopulatedTransaction } from 'ethers';
|
|
2
3
|
import ContractManager from './contracts';
|
|
3
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
4
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
|
+
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type createSubname from './functions/createSubname';
|
|
8
|
+
import type deleteSubname from './functions/deleteSubname';
|
|
9
|
+
import type setName from './functions/setName';
|
|
10
|
+
import type setRecords from './functions/setRecords';
|
|
11
|
+
import type setResolver from './functions/setResolver';
|
|
12
|
+
import type transferName from './functions/transferName';
|
|
13
|
+
import type transferSubname from './functions/transferSubname';
|
|
14
|
+
import type unwrapName from './functions/unwrapName';
|
|
15
|
+
import type wrapName from './functions/wrapName';
|
|
5
16
|
import GqlManager from './GqlManager';
|
|
6
17
|
declare type ENSOptions = {
|
|
7
18
|
graphURI?: string | null;
|
|
@@ -10,7 +21,7 @@ declare type ENSOptions = {
|
|
|
10
21
|
export declare type InternalENS = {
|
|
11
22
|
options?: ENSOptions;
|
|
12
23
|
provider?: ethers.providers.Provider;
|
|
13
|
-
signer:
|
|
24
|
+
signer: JsonRpcSigner;
|
|
14
25
|
graphURI?: string | null;
|
|
15
26
|
} & ENS;
|
|
16
27
|
export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
@@ -20,8 +31,13 @@ declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ?
|
|
|
20
31
|
declare type OmitFirstTwoArgs<F> = F extends (x: any, y: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
21
32
|
declare type WriteOptions = {
|
|
22
33
|
addressOrIndex?: string | number;
|
|
23
|
-
signer?:
|
|
34
|
+
signer?: JsonRpcSigner;
|
|
24
35
|
};
|
|
36
|
+
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;
|
|
37
|
+
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
38
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction>;
|
|
39
|
+
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
40
|
+
}
|
|
25
41
|
export declare type RawFunction = {
|
|
26
42
|
raw: (...args: any[]) => Promise<{
|
|
27
43
|
to: string;
|
|
@@ -117,11 +133,13 @@ export declare class ENS {
|
|
|
117
133
|
}>;
|
|
118
134
|
decode: ({ multicallWrapper }: ENSArgs<"multicallWrapper">, data: string, ...items: BatchFunctionResult<RawFunction>[]) => Promise<any[] | undefined>;
|
|
119
135
|
}>;
|
|
120
|
-
getProfile: (nameOrAddress: string, options?: {
|
|
136
|
+
getProfile: (nameOrAddress: string, options?: ({
|
|
121
137
|
contentHash?: boolean | undefined;
|
|
122
138
|
texts?: boolean | string[] | undefined;
|
|
123
139
|
coinTypes?: boolean | string[] | undefined;
|
|
124
|
-
}
|
|
140
|
+
} & {
|
|
141
|
+
resolverAddress?: string | undefined;
|
|
142
|
+
}) | undefined) => Promise<{
|
|
125
143
|
isMigrated: boolean | null;
|
|
126
144
|
createdAt: string | null;
|
|
127
145
|
address?: string | undefined;
|
|
@@ -150,6 +168,7 @@ export declare class ENS {
|
|
|
150
168
|
contentHash?: boolean | undefined;
|
|
151
169
|
texts?: boolean | string[] | undefined;
|
|
152
170
|
coinTypes?: boolean | string[] | undefined;
|
|
171
|
+
resolverAddress?: string | undefined;
|
|
153
172
|
} | undefined) => Promise<{
|
|
154
173
|
isMigrated: boolean | null;
|
|
155
174
|
createdAt: string | null;
|
|
@@ -436,53 +455,16 @@ export declare class ENS {
|
|
|
436
455
|
}>;
|
|
437
456
|
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<any>;
|
|
438
457
|
}>;
|
|
439
|
-
setName:
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
resolver?: string | undefined;
|
|
450
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
451
|
-
transferName: (name: string, options: {
|
|
452
|
-
newOwner: string;
|
|
453
|
-
contract: "nameWrapper" | "registry" | "baseRegistrar";
|
|
454
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
455
|
-
wrapName: (name: string, options: {
|
|
456
|
-
wrappedOwner: string;
|
|
457
|
-
fuseOptions?: string | number | import("./@types/FuseOptions").FuseOptions | undefined;
|
|
458
|
-
resolverAddress?: string | undefined;
|
|
459
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
460
|
-
unwrapName: (name: string, options: {
|
|
461
|
-
newController: string;
|
|
462
|
-
newRegistrant?: string | undefined;
|
|
463
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
464
|
-
burnFuses: (name: string, options: {
|
|
465
|
-
fusesToBurn: import("./@types/FuseOptions").FuseOptions;
|
|
466
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
467
|
-
createSubname: (name: string, options: ({
|
|
468
|
-
owner: string;
|
|
469
|
-
resolverAddress?: string | undefined;
|
|
470
|
-
contract: "nameWrapper" | "registry";
|
|
471
|
-
} | ({
|
|
472
|
-
contract: "nameWrapper";
|
|
473
|
-
fuses?: import("./@types/FuseOptions").FuseOptions | undefined;
|
|
474
|
-
} & {
|
|
475
|
-
owner: string;
|
|
476
|
-
resolverAddress?: string | undefined;
|
|
477
|
-
contract: "nameWrapper" | "registry";
|
|
478
|
-
})) & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
479
|
-
deleteSubname: (name: string, options: {
|
|
480
|
-
contract: "nameWrapper" | "registry";
|
|
481
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
482
|
-
transferSubname: (name: string, options: {
|
|
483
|
-
contract: "nameWrapper" | "registry";
|
|
484
|
-
address: string;
|
|
485
|
-
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
458
|
+
setName: WriteFunction<typeof setName>;
|
|
459
|
+
setRecords: WriteFunction<typeof setRecords>;
|
|
460
|
+
setResolver: WriteFunction<typeof setResolver>;
|
|
461
|
+
transferName: WriteFunction<typeof transferName>;
|
|
462
|
+
wrapName: WriteFunction<typeof wrapName>;
|
|
463
|
+
unwrapName: WriteFunction<typeof unwrapName>;
|
|
464
|
+
burnFuses: WriteFunction<typeof burnFuses>;
|
|
465
|
+
createSubname: WriteFunction<typeof createSubname>;
|
|
466
|
+
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
467
|
+
transferSubname: WriteFunction<typeof transferSubname>;
|
|
486
468
|
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
487
469
|
}
|
|
488
470
|
export {};
|