@ensdomains/ensjs 3.0.0-alpha.13 → 3.0.0-alpha.16
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 +5 -3
- package/dist/cjs/GqlManager.js +21 -13
- 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/getFuses.d.ts +2 -1
- package/dist/cjs/functions/getFuses.js +9 -18
- package/dist/cjs/functions/getSpecificRecord.d.ts +4 -4
- package/dist/cjs/index.d.ts +12 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/utils/fuses.d.ts +18 -17
- package/dist/cjs/utils/fuses.js +10 -4
- package/dist/cjs/utils/wrapperExpiry.d.ts +1 -1
- package/dist/esm/GqlManager.d.ts +5 -3
- package/dist/esm/GqlManager.js +21 -13
- 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/getFuses.d.ts +2 -1
- package/dist/esm/functions/getFuses.js +10 -19
- package/dist/esm/functions/getSpecificRecord.d.ts +4 -4
- package/dist/esm/index.d.ts +12 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/utils/fuses.d.ts +18 -17
- package/dist/esm/utils/fuses.js +9 -3
- package/dist/esm/utils/wrapperExpiry.d.ts +1 -1
- package/package.json +1 -1
- package/src/GqlManager.test.ts +5 -4
- package/src/GqlManager.ts +54 -36
- package/src/functions/burnFuses.test.ts +123 -15
- package/src/functions/burnFuses.ts +101 -10
- package/src/functions/getFuses.test.ts +33 -15
- package/src/functions/getFuses.ts +13 -25
- package/src/index.ts +2 -0
- package/src/utils/fuses.ts +12 -4
package/dist/cjs/GqlManager.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import type { parse as Parse, print as Print, SelectionSetNode, visit as Visit } from 'graphql';
|
|
2
|
+
import type Traverse from 'traverse';
|
|
3
|
+
export declare const enter: (node: SelectionSetNode) => SelectionSetNode | undefined;
|
|
4
|
+
export declare const requestMiddleware: (visit: typeof Visit, parse: typeof Parse, print: typeof Print) => (request: any) => any;
|
|
5
|
+
export declare const responseMiddleware: (traverse: typeof Traverse) => (response: any) => any;
|
|
4
6
|
export default class GqlManager {
|
|
5
7
|
gql: any;
|
|
6
8
|
client?: any | null;
|
package/dist/cjs/GqlManager.js
CHANGED
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.responseMiddleware = exports.requestMiddleware = exports.enter = void 0;
|
|
27
|
-
// @ts-nocheck
|
|
28
27
|
const normalise_1 = require("./utils/normalise");
|
|
29
28
|
const generateSelection = (selection) => ({
|
|
30
29
|
kind: 'Field',
|
|
@@ -38,25 +37,34 @@ const generateSelection = (selection) => ({
|
|
|
38
37
|
selectionSet: undefined,
|
|
39
38
|
});
|
|
40
39
|
const enter = (node) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
let hasName = false;
|
|
41
|
+
let hasId = false;
|
|
42
|
+
for (const selection of node.selections) {
|
|
43
|
+
if ('name' in selection) {
|
|
44
|
+
if (selection.name.value === 'name')
|
|
45
|
+
hasName = true;
|
|
46
|
+
else if (selection.name.value === 'id')
|
|
47
|
+
hasId = true;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
if (hasName && !hasId) {
|
|
51
|
+
node.selections = [...node.selections, generateSelection('id')];
|
|
52
|
+
return node;
|
|
53
|
+
}
|
|
49
54
|
};
|
|
50
55
|
exports.enter = enter;
|
|
51
|
-
const requestMiddleware = (visit, parse) => (request) => {
|
|
56
|
+
const requestMiddleware = (visit, parse, print) => (request) => {
|
|
52
57
|
const requestBody = JSON.parse(request.body);
|
|
53
58
|
const rawQuery = requestBody.query;
|
|
54
59
|
const parsedQuery = parse(rawQuery);
|
|
55
|
-
const updatedQuery = visit(parsedQuery, {
|
|
56
|
-
|
|
60
|
+
const updatedQuery = visit(parsedQuery, {
|
|
61
|
+
SelectionSet: {
|
|
62
|
+
enter: exports.enter,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
57
65
|
return {
|
|
58
66
|
...request,
|
|
59
|
-
body: JSON.stringify(
|
|
67
|
+
body: JSON.stringify({ ...requestBody, query: print(updatedQuery) }),
|
|
60
68
|
};
|
|
61
69
|
};
|
|
62
70
|
exports.requestMiddleware = requestMiddleware;
|
|
@@ -81,13 +89,13 @@ class GqlManager {
|
|
|
81
89
|
client = null;
|
|
82
90
|
setUrl = async (url) => {
|
|
83
91
|
if (url) {
|
|
84
|
-
const [imported, traverse, { visit, parse }] = await Promise.all([
|
|
92
|
+
const [imported, traverse, { visit, parse, print }] = await Promise.all([
|
|
85
93
|
Promise.resolve().then(() => __importStar(require('graphql-request'))),
|
|
86
94
|
Promise.resolve().then(() => __importStar(require('traverse'))),
|
|
87
95
|
Promise.resolve().then(() => __importStar(require('graphql/language'))),
|
|
88
96
|
]);
|
|
89
97
|
this.client = new imported.GraphQLClient(url, {
|
|
90
|
-
requestMiddleware: (0, exports.requestMiddleware)(visit, parse),
|
|
98
|
+
requestMiddleware: (0, exports.requestMiddleware)(visit, parse, print),
|
|
91
99
|
responseMiddleware: (0, exports.responseMiddleware)(traverse.default),
|
|
92
100
|
});
|
|
93
101
|
this.gql = imported.gql;
|
|
@@ -5,12 +5,12 @@ export default class ContractManager {
|
|
|
5
5
|
private fetchAddress;
|
|
6
6
|
constructor(provider: ethers.providers.Provider, fetchAddress: ContractAddressFetch);
|
|
7
7
|
private generateContractGetter;
|
|
8
|
-
getPublicResolver: (passedProvider?: any, address?: string
|
|
9
|
-
getUniversalResolver: (passedProvider?: any, address?: string
|
|
10
|
-
getRegistry: (passedProvider?: any, address?: string
|
|
11
|
-
getReverseRegistrar: (passedProvider?: any, address?: string
|
|
12
|
-
getNameWrapper: (passedProvider?: any, address?: string
|
|
13
|
-
getBaseRegistrar: (passedProvider?: any, address?: string
|
|
14
|
-
getEthRegistrarController: (passedProvider?: any, address?: string
|
|
15
|
-
getMulticall: (passedProvider?: any, address?: string
|
|
8
|
+
getPublicResolver: (passedProvider?: any, address?: string) => Promise<import("../generated").PublicResolver>;
|
|
9
|
+
getUniversalResolver: (passedProvider?: any, address?: string) => Promise<import("../generated").UniversalResolver>;
|
|
10
|
+
getRegistry: (passedProvider?: any, address?: string) => Promise<import("../generated").ENSRegistry>;
|
|
11
|
+
getReverseRegistrar: (passedProvider?: any, address?: string) => Promise<import("../generated").ReverseRegistrar>;
|
|
12
|
+
getNameWrapper: (passedProvider?: any, address?: string) => Promise<import("../generated").NameWrapper>;
|
|
13
|
+
getBaseRegistrar: (passedProvider?: any, address?: string) => Promise<import("../generated").BaseRegistrarImplementation>;
|
|
14
|
+
getEthRegistrarController: (passedProvider?: any, address?: string) => Promise<import("../generated").ETHRegistrarController>;
|
|
15
|
+
getMulticall: (passedProvider?: any, address?: string) => Promise<import("../generated").Multicall>;
|
|
16
16
|
}
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { fuseEnum, unnamedFuses } from '../utils/fuses';
|
|
3
|
+
declare type FuseObj = typeof fuseEnum;
|
|
4
|
+
declare type UnnamedFuseType = typeof unnamedFuses;
|
|
5
|
+
declare type Fuse = keyof FuseObj;
|
|
6
|
+
declare type UnnamedFuseValues = UnnamedFuseType[number];
|
|
7
|
+
declare type FuseArrayPossibilities = [Fuse] | [Fuse, Fuse] | [Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse, Fuse, Fuse];
|
|
8
|
+
/**
|
|
9
|
+
* This type creates a type error if there are any duplicate fuses.
|
|
10
|
+
* It effectively works like a reduce function, starting with 0 included types, adding a type each time, and then checking for duplicates.
|
|
11
|
+
*
|
|
12
|
+
* @template A The array to check for duplicates.
|
|
13
|
+
* @template B The union of all checked existing types.
|
|
14
|
+
*/
|
|
15
|
+
declare type FusesWithoutDuplicates<A, B = never> = A extends FuseArrayPossibilities ? A extends [infer Head, ...infer Tail] ? Head extends B ? [
|
|
16
|
+
] : [
|
|
17
|
+
Head,
|
|
18
|
+
...FusesWithoutDuplicates<Tail, Head | B>
|
|
19
|
+
] : A : [
|
|
20
|
+
];
|
|
21
|
+
declare type FusePropsNamedArray<A extends FuseArrayPossibilities> = {
|
|
22
|
+
namedFusesToBurn: FusesWithoutDuplicates<A>;
|
|
23
|
+
};
|
|
24
|
+
declare type FusePropsUnnamedArray = {
|
|
25
|
+
unnamedFusesToBurn: UnnamedFuseValues[];
|
|
26
|
+
};
|
|
27
|
+
declare type FusePropsNumber = {
|
|
28
|
+
fuseNumberToBurn: number;
|
|
29
|
+
};
|
|
30
|
+
declare type FuseProps<A extends FuseArrayPossibilities> = (Partial<FusePropsNamedArray<A>> & FusePropsUnnamedArray) | (FusePropsNamedArray<A> & Partial<FusePropsUnnamedArray>) | FusePropsNumber;
|
|
31
|
+
export default function <A extends FuseArrayPossibilities>({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, props: FuseProps<A>): Promise<import("ethers").PopulatedTransaction>;
|
|
32
|
+
export {};
|
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const fuses_1 = require("../utils/fuses");
|
|
7
4
|
const normalise_1 = require("../utils/normalise");
|
|
8
|
-
async function default_1({ contracts, signer }, name,
|
|
5
|
+
async function default_1({ contracts, signer }, name, props) {
|
|
6
|
+
const isNumber = 'fuseNumberToBurn' in props;
|
|
7
|
+
const hasNamedArray = 'namedFusesToBurn' in props;
|
|
8
|
+
const hasUnnamedArray = 'unnamedFusesToBurn' in props;
|
|
9
|
+
let encodedFuses = 0;
|
|
10
|
+
if (isNumber) {
|
|
11
|
+
if (props.fuseNumberToBurn > 2 ** 32 || props.fuseNumberToBurn < 1) {
|
|
12
|
+
throw new Error(`Fuse number must be limited to uint32, ${props.fuseNumberToBurn} was too ${props.fuseNumberToBurn < 1 ? 'low' : 'high'}.`);
|
|
13
|
+
}
|
|
14
|
+
else if (props.fuseNumberToBurn % 1 !== 0) {
|
|
15
|
+
throw new Error(`Fuse number must be an integer, ${props.fuseNumberToBurn} was not.`);
|
|
16
|
+
}
|
|
17
|
+
encodedFuses = props.fuseNumberToBurn;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (!hasNamedArray && !hasUnnamedArray) {
|
|
21
|
+
throw new Error('Please provide fuses to burn');
|
|
22
|
+
}
|
|
23
|
+
if (hasNamedArray) {
|
|
24
|
+
for (const fuse of props.namedFusesToBurn) {
|
|
25
|
+
if (!(fuse in fuses_1.fuseEnum)) {
|
|
26
|
+
throw new Error(`${fuse} is not a valid named fuse.`);
|
|
27
|
+
}
|
|
28
|
+
encodedFuses |= fuses_1.fuseEnum[fuse];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (hasUnnamedArray) {
|
|
32
|
+
for (const fuse of props.unnamedFusesToBurn) {
|
|
33
|
+
if (!fuses_1.unnamedFuses.includes(fuse)) {
|
|
34
|
+
throw new Error(`${fuse} is not a valid unnamed fuse. If you are trying to burn a named fuse, use the namedFusesToBurn property.`);
|
|
35
|
+
}
|
|
36
|
+
encodedFuses |= fuse;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
9
40
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
10
41
|
const hash = (0, normalise_1.namehash)(name);
|
|
11
|
-
const encodedFuses = (0, generateFuseInput_1.default)(fusesToBurn);
|
|
12
42
|
return nameWrapper.populateTransaction.setFuses(hash, encodedFuses);
|
|
13
43
|
}
|
|
14
44
|
exports.default = default_1;
|
|
@@ -5,12 +5,13 @@ declare const _default: {
|
|
|
5
5
|
to: string;
|
|
6
6
|
data: string;
|
|
7
7
|
}>;
|
|
8
|
-
decode: ({ contracts }: ENSArgs<"contracts">, data: string
|
|
8
|
+
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
|
|
9
9
|
fuseObj: {
|
|
10
10
|
[k: string]: boolean;
|
|
11
11
|
};
|
|
12
12
|
expiryDate: Date;
|
|
13
13
|
rawFuses: BigNumber;
|
|
14
|
+
owner: any;
|
|
14
15
|
} | undefined>;
|
|
15
16
|
};
|
|
16
17
|
export default _default;
|
|
@@ -3,32 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const fuses_1 = require("../utils/fuses");
|
|
5
5
|
const normalise_1 = require("../utils/normalise");
|
|
6
|
-
const NameSafety = [
|
|
7
|
-
'Safe',
|
|
8
|
-
'RegistrantNotWrapped',
|
|
9
|
-
'ControllerNotWrapped',
|
|
10
|
-
'SubdomainReplacementAllowed',
|
|
11
|
-
'Expired',
|
|
12
|
-
];
|
|
13
6
|
const raw = async ({ contracts }, name) => {
|
|
14
7
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
15
8
|
return {
|
|
16
9
|
to: nameWrapper.address,
|
|
17
|
-
data: nameWrapper.interface.encodeFunctionData('
|
|
18
|
-
(0, normalise_1.namehash)(name),
|
|
19
|
-
]),
|
|
10
|
+
data: nameWrapper.interface.encodeFunctionData('getData', [(0, normalise_1.namehash)(name)]),
|
|
20
11
|
};
|
|
21
12
|
};
|
|
22
|
-
const decode = async ({ contracts }, data
|
|
13
|
+
const decode = async ({ contracts }, data) => {
|
|
23
14
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
24
15
|
try {
|
|
25
|
-
const
|
|
16
|
+
const { owner, fuses: _fuses, expiry, } = nameWrapper.interface.decodeFunctionResult('getData', data);
|
|
26
17
|
const fuses = ethers_1.BigNumber.from(_fuses);
|
|
27
|
-
const fuseObj = Object.fromEntries(Object.keys(fuses_1.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', '')),
|
|
31
|
-
fuses.and(fuses_1.testable[fuseEnum]).gt(0),
|
|
18
|
+
const fuseObj = Object.fromEntries(Object.keys(fuses_1.fuseEnum).map((fuse) => [
|
|
19
|
+
fuse,
|
|
20
|
+
fuses.and(fuses_1.fuseEnum[fuse]).gt(0),
|
|
32
21
|
]));
|
|
33
22
|
if (fuses.eq(0)) {
|
|
34
23
|
fuseObj.canDoEverything = true;
|
|
@@ -41,9 +30,11 @@ const decode = async ({ contracts }, data, name) => {
|
|
|
41
30
|
fuseObj,
|
|
42
31
|
expiryDate,
|
|
43
32
|
rawFuses: fuses,
|
|
33
|
+
owner,
|
|
44
34
|
};
|
|
45
35
|
}
|
|
46
|
-
catch {
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.error('Error decoding fuses data: ', e);
|
|
47
38
|
return;
|
|
48
39
|
}
|
|
49
40
|
};
|
|
@@ -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>;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -75,6 +75,16 @@ export declare class ENS {
|
|
|
75
75
|
contracts?: ContractManager;
|
|
76
76
|
getContractAddress: (networkId: SupportedNetworkId) => import("./contracts/getContractAddress").ContractAddressFetch;
|
|
77
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
|
+
};
|
|
78
88
|
constructor(options?: ENSOptions);
|
|
79
89
|
/**
|
|
80
90
|
* Checks for an initial provider and if it exists, sets it as the provider
|
|
@@ -229,12 +239,13 @@ export declare class ENS {
|
|
|
229
239
|
to: string;
|
|
230
240
|
data: string;
|
|
231
241
|
}>;
|
|
232
|
-
decode: ({ contracts }: ENSArgs<"contracts">, data: string
|
|
242
|
+
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
|
|
233
243
|
fuseObj: {
|
|
234
244
|
[k: string]: boolean;
|
|
235
245
|
};
|
|
236
246
|
expiryDate: Date;
|
|
237
247
|
rawFuses: ethers.BigNumber;
|
|
248
|
+
owner: any;
|
|
238
249
|
} | undefined>;
|
|
239
250
|
}>;
|
|
240
251
|
getHistory: (name: string) => Promise<{
|
package/dist/cjs/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const getContractAddress_1 = require("./contracts/getContractAddress");
|
|
|
32
32
|
const GqlManager_1 = __importDefault(require("./GqlManager"));
|
|
33
33
|
const singleCall_1 = __importDefault(require("./utils/singleCall"));
|
|
34
34
|
const writeTx_1 = __importDefault(require("./utils/writeTx"));
|
|
35
|
+
const fuses_1 = __importDefault(require("./utils/fuses"));
|
|
35
36
|
const graphURIEndpoints = {
|
|
36
37
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
37
38
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -46,6 +47,7 @@ class ENS {
|
|
|
46
47
|
contracts;
|
|
47
48
|
getContractAddress = getContractAddress_1.getContractAddress;
|
|
48
49
|
gqlInstance = new GqlManager_1.default();
|
|
50
|
+
fuses = fuses_1.default;
|
|
49
51
|
constructor(options) {
|
|
50
52
|
this.options = options;
|
|
51
53
|
this.getContractAddress = options?.getContractAddress || getContractAddress_1.getContractAddress;
|
|
@@ -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/cjs/utils/fuses.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.unnamedFuses = exports.fuseEnum = void 0;
|
|
4
4
|
const CANNOT_UNWRAP = 1;
|
|
5
5
|
const CANNOT_BURN_FUSES = 2;
|
|
6
6
|
const CANNOT_TRANSFER = 4;
|
|
@@ -9,7 +9,7 @@ const CANNOT_SET_TTL = 16;
|
|
|
9
9
|
const CANNOT_CREATE_SUBDOMAIN = 32;
|
|
10
10
|
const PARENT_CANNOT_CONTROL = 64;
|
|
11
11
|
const CAN_DO_EVERYTHING = 0;
|
|
12
|
-
exports.
|
|
12
|
+
exports.fuseEnum = {
|
|
13
13
|
CANNOT_UNWRAP,
|
|
14
14
|
CANNOT_BURN_FUSES,
|
|
15
15
|
CANNOT_TRANSFER,
|
|
@@ -18,7 +18,13 @@ exports.testable = {
|
|
|
18
18
|
CANNOT_CREATE_SUBDOMAIN,
|
|
19
19
|
PARENT_CANNOT_CONTROL,
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
22
|
-
|
|
21
|
+
exports.unnamedFuses = [
|
|
22
|
+
128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144,
|
|
23
|
+
524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864,
|
|
24
|
+
134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296,
|
|
25
|
+
];
|
|
26
|
+
const fullFuseEnum = {
|
|
27
|
+
...exports.fuseEnum,
|
|
23
28
|
CAN_DO_EVERYTHING,
|
|
24
29
|
};
|
|
30
|
+
exports.default = fullFuseEnum;
|
|
@@ -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>;
|
package/dist/esm/GqlManager.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import type { parse as Parse, print as Print, SelectionSetNode, visit as Visit } from 'graphql';
|
|
2
|
+
import type Traverse from 'traverse';
|
|
3
|
+
export declare const enter: (node: SelectionSetNode) => SelectionSetNode | undefined;
|
|
4
|
+
export declare const requestMiddleware: (visit: typeof Visit, parse: typeof Parse, print: typeof Print) => (request: any) => any;
|
|
5
|
+
export declare const responseMiddleware: (traverse: typeof Traverse) => (response: any) => any;
|
|
4
6
|
export default class GqlManager {
|
|
5
7
|
gql: any;
|
|
6
8
|
client?: any | null;
|
package/dist/esm/GqlManager.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { namehash } from './utils/normalise';
|
|
3
2
|
const generateSelection = (selection) => ({
|
|
4
3
|
kind: 'Field',
|
|
@@ -12,24 +11,33 @@ const generateSelection = (selection) => ({
|
|
|
12
11
|
selectionSet: undefined,
|
|
13
12
|
});
|
|
14
13
|
export const enter = (node) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
let hasName = false;
|
|
15
|
+
let hasId = false;
|
|
16
|
+
for (const selection of node.selections) {
|
|
17
|
+
if ('name' in selection) {
|
|
18
|
+
if (selection.name.value === 'name')
|
|
19
|
+
hasName = true;
|
|
20
|
+
else if (selection.name.value === 'id')
|
|
21
|
+
hasId = true;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
if (hasName && !hasId) {
|
|
25
|
+
node.selections = [...node.selections, generateSelection('id')];
|
|
26
|
+
return node;
|
|
27
|
+
}
|
|
23
28
|
};
|
|
24
|
-
export const requestMiddleware = (visit, parse) => (request) => {
|
|
29
|
+
export const requestMiddleware = (visit, parse, print) => (request) => {
|
|
25
30
|
const requestBody = JSON.parse(request.body);
|
|
26
31
|
const rawQuery = requestBody.query;
|
|
27
32
|
const parsedQuery = parse(rawQuery);
|
|
28
|
-
const updatedQuery = visit(parsedQuery, {
|
|
29
|
-
|
|
33
|
+
const updatedQuery = visit(parsedQuery, {
|
|
34
|
+
SelectionSet: {
|
|
35
|
+
enter,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
30
38
|
return {
|
|
31
39
|
...request,
|
|
32
|
-
body: JSON.stringify(
|
|
40
|
+
body: JSON.stringify({ ...requestBody, query: print(updatedQuery) }),
|
|
33
41
|
};
|
|
34
42
|
};
|
|
35
43
|
export const responseMiddleware = (traverse) => (response) => {
|
|
@@ -53,13 +61,13 @@ export default class GqlManager {
|
|
|
53
61
|
this.client = null;
|
|
54
62
|
this.setUrl = async (url) => {
|
|
55
63
|
if (url) {
|
|
56
|
-
const [imported, traverse, { visit, parse }] = await Promise.all([
|
|
64
|
+
const [imported, traverse, { visit, parse, print }] = await Promise.all([
|
|
57
65
|
import('graphql-request'),
|
|
58
66
|
import('traverse'),
|
|
59
67
|
import('graphql/language'),
|
|
60
68
|
]);
|
|
61
69
|
this.client = new imported.GraphQLClient(url, {
|
|
62
|
-
requestMiddleware: requestMiddleware(visit, parse),
|
|
70
|
+
requestMiddleware: requestMiddleware(visit, parse, print),
|
|
63
71
|
responseMiddleware: responseMiddleware(traverse.default),
|
|
64
72
|
});
|
|
65
73
|
this.gql = imported.gql;
|
|
@@ -5,12 +5,12 @@ export default class ContractManager {
|
|
|
5
5
|
private fetchAddress;
|
|
6
6
|
constructor(provider: ethers.providers.Provider, fetchAddress: ContractAddressFetch);
|
|
7
7
|
private generateContractGetter;
|
|
8
|
-
getPublicResolver: (passedProvider?: any, address?: string
|
|
9
|
-
getUniversalResolver: (passedProvider?: any, address?: string
|
|
10
|
-
getRegistry: (passedProvider?: any, address?: string
|
|
11
|
-
getReverseRegistrar: (passedProvider?: any, address?: string
|
|
12
|
-
getNameWrapper: (passedProvider?: any, address?: string
|
|
13
|
-
getBaseRegistrar: (passedProvider?: any, address?: string
|
|
14
|
-
getEthRegistrarController: (passedProvider?: any, address?: string
|
|
15
|
-
getMulticall: (passedProvider?: any, address?: string
|
|
8
|
+
getPublicResolver: (passedProvider?: any, address?: string) => Promise<import("../generated").PublicResolver>;
|
|
9
|
+
getUniversalResolver: (passedProvider?: any, address?: string) => Promise<import("../generated").UniversalResolver>;
|
|
10
|
+
getRegistry: (passedProvider?: any, address?: string) => Promise<import("../generated").ENSRegistry>;
|
|
11
|
+
getReverseRegistrar: (passedProvider?: any, address?: string) => Promise<import("../generated").ReverseRegistrar>;
|
|
12
|
+
getNameWrapper: (passedProvider?: any, address?: string) => Promise<import("../generated").NameWrapper>;
|
|
13
|
+
getBaseRegistrar: (passedProvider?: any, address?: string) => Promise<import("../generated").BaseRegistrarImplementation>;
|
|
14
|
+
getEthRegistrarController: (passedProvider?: any, address?: string) => Promise<import("../generated").ETHRegistrarController>;
|
|
15
|
+
getMulticall: (passedProvider?: any, address?: string) => Promise<import("../generated").Multicall>;
|
|
16
16
|
}
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { fuseEnum, unnamedFuses } from '../utils/fuses';
|
|
3
|
+
declare type FuseObj = typeof fuseEnum;
|
|
4
|
+
declare type UnnamedFuseType = typeof unnamedFuses;
|
|
5
|
+
declare type Fuse = keyof FuseObj;
|
|
6
|
+
declare type UnnamedFuseValues = UnnamedFuseType[number];
|
|
7
|
+
declare type FuseArrayPossibilities = [Fuse] | [Fuse, Fuse] | [Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse, Fuse, Fuse];
|
|
8
|
+
/**
|
|
9
|
+
* This type creates a type error if there are any duplicate fuses.
|
|
10
|
+
* It effectively works like a reduce function, starting with 0 included types, adding a type each time, and then checking for duplicates.
|
|
11
|
+
*
|
|
12
|
+
* @template A The array to check for duplicates.
|
|
13
|
+
* @template B The union of all checked existing types.
|
|
14
|
+
*/
|
|
15
|
+
declare type FusesWithoutDuplicates<A, B = never> = A extends FuseArrayPossibilities ? A extends [infer Head, ...infer Tail] ? Head extends B ? [
|
|
16
|
+
] : [
|
|
17
|
+
Head,
|
|
18
|
+
...FusesWithoutDuplicates<Tail, Head | B>
|
|
19
|
+
] : A : [
|
|
20
|
+
];
|
|
21
|
+
declare type FusePropsNamedArray<A extends FuseArrayPossibilities> = {
|
|
22
|
+
namedFusesToBurn: FusesWithoutDuplicates<A>;
|
|
23
|
+
};
|
|
24
|
+
declare type FusePropsUnnamedArray = {
|
|
25
|
+
unnamedFusesToBurn: UnnamedFuseValues[];
|
|
26
|
+
};
|
|
27
|
+
declare type FusePropsNumber = {
|
|
28
|
+
fuseNumberToBurn: number;
|
|
29
|
+
};
|
|
30
|
+
declare type FuseProps<A extends FuseArrayPossibilities> = (Partial<FusePropsNamedArray<A>> & FusePropsUnnamedArray) | (FusePropsNamedArray<A> & Partial<FusePropsUnnamedArray>) | FusePropsNumber;
|
|
31
|
+
export default function <A extends FuseArrayPossibilities>({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, props: FuseProps<A>): Promise<import("ethers").PopulatedTransaction>;
|
|
32
|
+
export {};
|
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fuseEnum, unnamedFuses } from '../utils/fuses';
|
|
2
2
|
import { namehash } from '../utils/normalise';
|
|
3
|
-
export default async function ({ contracts, signer }, name,
|
|
3
|
+
export default async function ({ contracts, signer }, name, props) {
|
|
4
|
+
const isNumber = 'fuseNumberToBurn' in props;
|
|
5
|
+
const hasNamedArray = 'namedFusesToBurn' in props;
|
|
6
|
+
const hasUnnamedArray = 'unnamedFusesToBurn' in props;
|
|
7
|
+
let encodedFuses = 0;
|
|
8
|
+
if (isNumber) {
|
|
9
|
+
if (props.fuseNumberToBurn > 2 ** 32 || props.fuseNumberToBurn < 1) {
|
|
10
|
+
throw new Error(`Fuse number must be limited to uint32, ${props.fuseNumberToBurn} was too ${props.fuseNumberToBurn < 1 ? 'low' : 'high'}.`);
|
|
11
|
+
}
|
|
12
|
+
else if (props.fuseNumberToBurn % 1 !== 0) {
|
|
13
|
+
throw new Error(`Fuse number must be an integer, ${props.fuseNumberToBurn} was not.`);
|
|
14
|
+
}
|
|
15
|
+
encodedFuses = props.fuseNumberToBurn;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (!hasNamedArray && !hasUnnamedArray) {
|
|
19
|
+
throw new Error('Please provide fuses to burn');
|
|
20
|
+
}
|
|
21
|
+
if (hasNamedArray) {
|
|
22
|
+
for (const fuse of props.namedFusesToBurn) {
|
|
23
|
+
if (!(fuse in fuseEnum)) {
|
|
24
|
+
throw new Error(`${fuse} is not a valid named fuse.`);
|
|
25
|
+
}
|
|
26
|
+
encodedFuses |= fuseEnum[fuse];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (hasUnnamedArray) {
|
|
30
|
+
for (const fuse of props.unnamedFusesToBurn) {
|
|
31
|
+
if (!unnamedFuses.includes(fuse)) {
|
|
32
|
+
throw new Error(`${fuse} is not a valid unnamed fuse. If you are trying to burn a named fuse, use the namedFusesToBurn property.`);
|
|
33
|
+
}
|
|
34
|
+
encodedFuses |= fuse;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
4
38
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
5
39
|
const hash = namehash(name);
|
|
6
|
-
const encodedFuses = generateFuseInput(fusesToBurn);
|
|
7
40
|
return nameWrapper.populateTransaction.setFuses(hash, encodedFuses);
|
|
8
41
|
}
|
|
@@ -5,12 +5,13 @@ declare const _default: {
|
|
|
5
5
|
to: string;
|
|
6
6
|
data: string;
|
|
7
7
|
}>;
|
|
8
|
-
decode: ({ contracts }: ENSArgs<"contracts">, data: string
|
|
8
|
+
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
|
|
9
9
|
fuseObj: {
|
|
10
10
|
[k: string]: boolean;
|
|
11
11
|
};
|
|
12
12
|
expiryDate: Date;
|
|
13
13
|
rawFuses: BigNumber;
|
|
14
|
+
owner: any;
|
|
14
15
|
} | undefined>;
|
|
15
16
|
};
|
|
16
17
|
export default _default;
|