@ensdomains/ensjs 3.0.0-alpha.27 → 3.0.0-alpha.29

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.
@@ -22,6 +22,7 @@ __export(getNames_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(getNames_exports);
24
24
  var import_format = require("../utils/format");
25
+ var import_fuses = require("../utils/fuses");
25
26
  var import_labels = require("../utils/labels");
26
27
  const mapDomain = (domain) => {
27
28
  const decrypted = (0, import_labels.decryptName)(domain.name);
@@ -33,6 +34,15 @@ const mapDomain = (domain) => {
33
34
  type: "domain"
34
35
  };
35
36
  };
37
+ const mapWrappedDomain = (wrappedDomain) => {
38
+ const domain = mapDomain(wrappedDomain.domain);
39
+ return {
40
+ expiryDate: new Date(parseInt(wrappedDomain.expiryDate) * 1e3),
41
+ fuses: (0, import_fuses.decodeFuses)(wrappedDomain.fuses),
42
+ ...domain,
43
+ type: "wrappedDomain"
44
+ };
45
+ };
36
46
  const mapRegistration = (registration) => {
37
47
  const decrypted = (0, import_labels.decryptName)(registration.domain.name);
38
48
  return {
@@ -87,6 +97,17 @@ const getNames = async ({ gqlInstance }, {
87
97
  ${domainQueryData}
88
98
  createdAt
89
99
  }
100
+ wrappedDomains(first: 1000) {
101
+ expiryDate
102
+ fuses
103
+ domain {
104
+ ${domainQueryData}
105
+ registration {
106
+ registrationDate
107
+ expiryDate
108
+ }
109
+ }
110
+ }
90
111
  }
91
112
  }
92
113
  `;
@@ -145,6 +166,69 @@ const getNames = async ({ gqlInstance }, {
145
166
  orderDirection
146
167
  };
147
168
  }
169
+ } else if (type === "wrappedOwner") {
170
+ if (typeof page !== "number") {
171
+ finalQuery = gqlInstance.gql`
172
+ query getNames(
173
+ $id: ID!
174
+ $orderBy: WrappedDomain_orderBy
175
+ $orderDirection: OrderDirection
176
+ $expiryDate: Int
177
+ ) {
178
+ account(id: $id) {
179
+ wrappedDomains(
180
+ orderBy: $orderBy
181
+ orderDirection: $orderDirection
182
+ where: { expiryDate_gt: $expiryDate }
183
+ ) {
184
+ expiryDate
185
+ fuses
186
+ domain {
187
+ ${domainQueryData}
188
+ createdAt
189
+ }
190
+ }
191
+ }
192
+ }
193
+ `;
194
+ queryVars = {
195
+ id: address,
196
+ expiryDate: Math.floor(Date.now() / 1e3) - 90 * 24 * 60 * 60
197
+ };
198
+ } else {
199
+ finalQuery = gqlInstance.gql`
200
+ query getNames(
201
+ $id: ID!
202
+ $first: Int
203
+ $skip: Int
204
+ $orderBy: WrappedDomain_orderBy
205
+ $orderDirection: OrderDirection
206
+ ) {
207
+ account(id: $id) {
208
+ wrappedDomains(
209
+ first: $first
210
+ skip: $skip
211
+ orderBy: $orderBy
212
+ orderDirection: $orderDirection
213
+ ) {
214
+ expiryDate
215
+ fuses
216
+ domain {
217
+ ${domainQueryData}
218
+ createdAt
219
+ }
220
+ }
221
+ }
222
+ }
223
+ `;
224
+ queryVars = {
225
+ id: address,
226
+ first: pageSize,
227
+ skip: (page || 0) * pageSize,
228
+ orderBy,
229
+ orderDirection
230
+ };
231
+ }
148
232
  } else if (typeof page !== "number") {
149
233
  finalQuery = gqlInstance.gql`
150
234
  query getNames(
@@ -214,7 +298,8 @@ const getNames = async ({ gqlInstance }, {
214
298
  if (type === "all") {
215
299
  return [
216
300
  ...account.domains.map(mapDomain),
217
- ...account.registrations.map(mapRegistration)
301
+ ...account.registrations.map(mapRegistration),
302
+ ...account.wrappedDomains.map(mapWrappedDomain)
218
303
  ].sort((a, b) => {
219
304
  if (orderDirection === "desc") {
220
305
  if (orderBy === "labelName") {
@@ -231,6 +316,9 @@ const getNames = async ({ gqlInstance }, {
231
316
  if (type === "owner") {
232
317
  return account.domains.map(mapDomain);
233
318
  }
319
+ if (type === "wrappedOwner") {
320
+ return account.wrappedDomains.map(mapWrappedDomain);
321
+ }
234
322
  return account.registrations.map(mapRegistration);
235
323
  };
236
324
  var getNames_default = getNames;
@@ -39,17 +39,7 @@ const decode = async ({ contracts }, data) => {
39
39
  data
40
40
  );
41
41
  const fuses = import_ethers.BigNumber.from(_fuses);
42
- const fuseObj = Object.fromEntries(
43
- Object.keys(import_fuses.fuseEnum).map((fuse) => [
44
- fuse,
45
- fuses.and(import_fuses.fuseEnum[fuse]).gt(0)
46
- ])
47
- );
48
- if (fuses.eq(0)) {
49
- fuseObj.CAN_DO_EVERYTHING = true;
50
- } else {
51
- fuseObj.CAN_DO_EVERYTHING = false;
52
- }
42
+ const fuseObj = (0, import_fuses.decodeFuses)(fuses);
53
43
  const expiryDate = new Date(expiry * 1e3);
54
44
  return {
55
45
  fuseObj,
@@ -18,12 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var fuses_exports = {};
20
20
  __export(fuses_exports, {
21
+ decodeFuses: () => decodeFuses,
21
22
  default: () => fuses_default,
22
23
  fuseEnum: () => fuseEnum,
23
24
  unnamedFuses: () => unnamedFuses,
24
25
  validateFuses: () => validateFuses
25
26
  });
26
27
  module.exports = __toCommonJS(fuses_exports);
28
+ var import_ethers = require("ethers");
27
29
  const CANNOT_UNWRAP = 1;
28
30
  const CANNOT_BURN_FUSES = 2;
29
31
  const CANNOT_TRANSFER = 4;
@@ -114,4 +116,19 @@ const validateFuses = (fuses) => {
114
116
  }
115
117
  return encodedFuses;
116
118
  };
119
+ const decodeFuses = (fuses) => {
120
+ const bnFuses = import_ethers.BigNumber.from(fuses);
121
+ const fuseObj = Object.fromEntries(
122
+ Object.keys(fuseEnum).map((fuse) => [
123
+ fuse,
124
+ bnFuses.and(fuseEnum[fuse]).gt(0)
125
+ ])
126
+ );
127
+ if (bnFuses.eq(0)) {
128
+ fuseObj.CAN_DO_EVERYTHING = true;
129
+ } else {
130
+ fuseObj.CAN_DO_EVERYTHING = false;
131
+ }
132
+ return fuseObj;
133
+ };
117
134
  var fuses_default = fullFuseEnum;
@@ -30,8 +30,8 @@ module.exports = __toCommonJS(generateFuseInput_exports);
30
30
  var import_ethers = require("ethers");
31
31
  var import_fuses = __toESM(require("./fuses"));
32
32
  var generateFuseInput_default = (fuseOptions) => {
33
- const fuseKeys = Object.keys(fuseOptions).filter((opt) => fuseOptions[opt] === true).map(
34
- (opt) => opt.split(/(?=[A-Z])/).join("_").toUpperCase()
33
+ const fuseKeys = Object.keys(fuseOptions).filter(
34
+ (opt) => fuseOptions[opt] === true
35
35
  );
36
36
  const bigNumberFuses = fuseKeys.reduce((prev, curr) => {
37
37
  return prev.or(import_fuses.default[curr]);
@@ -1,5 +1,6 @@
1
1
  // src/functions/getNames.ts
2
2
  import { truncateFormat } from "../utils/format.mjs";
3
+ import { decodeFuses } from "../utils/fuses.mjs";
3
4
  import { decryptName } from "../utils/labels.mjs";
4
5
  var mapDomain = (domain) => {
5
6
  const decrypted = decryptName(domain.name);
@@ -11,6 +12,15 @@ var mapDomain = (domain) => {
11
12
  type: "domain"
12
13
  };
13
14
  };
15
+ var mapWrappedDomain = (wrappedDomain) => {
16
+ const domain = mapDomain(wrappedDomain.domain);
17
+ return {
18
+ expiryDate: new Date(parseInt(wrappedDomain.expiryDate) * 1e3),
19
+ fuses: decodeFuses(wrappedDomain.fuses),
20
+ ...domain,
21
+ type: "wrappedDomain"
22
+ };
23
+ };
14
24
  var mapRegistration = (registration) => {
15
25
  const decrypted = decryptName(registration.domain.name);
16
26
  return {
@@ -65,6 +75,17 @@ var getNames = async ({ gqlInstance }, {
65
75
  ${domainQueryData}
66
76
  createdAt
67
77
  }
78
+ wrappedDomains(first: 1000) {
79
+ expiryDate
80
+ fuses
81
+ domain {
82
+ ${domainQueryData}
83
+ registration {
84
+ registrationDate
85
+ expiryDate
86
+ }
87
+ }
88
+ }
68
89
  }
69
90
  }
70
91
  `;
@@ -123,6 +144,69 @@ var getNames = async ({ gqlInstance }, {
123
144
  orderDirection
124
145
  };
125
146
  }
147
+ } else if (type === "wrappedOwner") {
148
+ if (typeof page !== "number") {
149
+ finalQuery = gqlInstance.gql`
150
+ query getNames(
151
+ $id: ID!
152
+ $orderBy: WrappedDomain_orderBy
153
+ $orderDirection: OrderDirection
154
+ $expiryDate: Int
155
+ ) {
156
+ account(id: $id) {
157
+ wrappedDomains(
158
+ orderBy: $orderBy
159
+ orderDirection: $orderDirection
160
+ where: { expiryDate_gt: $expiryDate }
161
+ ) {
162
+ expiryDate
163
+ fuses
164
+ domain {
165
+ ${domainQueryData}
166
+ createdAt
167
+ }
168
+ }
169
+ }
170
+ }
171
+ `;
172
+ queryVars = {
173
+ id: address,
174
+ expiryDate: Math.floor(Date.now() / 1e3) - 90 * 24 * 60 * 60
175
+ };
176
+ } else {
177
+ finalQuery = gqlInstance.gql`
178
+ query getNames(
179
+ $id: ID!
180
+ $first: Int
181
+ $skip: Int
182
+ $orderBy: WrappedDomain_orderBy
183
+ $orderDirection: OrderDirection
184
+ ) {
185
+ account(id: $id) {
186
+ wrappedDomains(
187
+ first: $first
188
+ skip: $skip
189
+ orderBy: $orderBy
190
+ orderDirection: $orderDirection
191
+ ) {
192
+ expiryDate
193
+ fuses
194
+ domain {
195
+ ${domainQueryData}
196
+ createdAt
197
+ }
198
+ }
199
+ }
200
+ }
201
+ `;
202
+ queryVars = {
203
+ id: address,
204
+ first: pageSize,
205
+ skip: (page || 0) * pageSize,
206
+ orderBy,
207
+ orderDirection
208
+ };
209
+ }
126
210
  } else if (typeof page !== "number") {
127
211
  finalQuery = gqlInstance.gql`
128
212
  query getNames(
@@ -192,7 +276,8 @@ var getNames = async ({ gqlInstance }, {
192
276
  if (type === "all") {
193
277
  return [
194
278
  ...account.domains.map(mapDomain),
195
- ...account.registrations.map(mapRegistration)
279
+ ...account.registrations.map(mapRegistration),
280
+ ...account.wrappedDomains.map(mapWrappedDomain)
196
281
  ].sort((a, b) => {
197
282
  if (orderDirection === "desc") {
198
283
  if (orderBy === "labelName") {
@@ -209,6 +294,9 @@ var getNames = async ({ gqlInstance }, {
209
294
  if (type === "owner") {
210
295
  return account.domains.map(mapDomain);
211
296
  }
297
+ if (type === "wrappedOwner") {
298
+ return account.wrappedDomains.map(mapWrappedDomain);
299
+ }
212
300
  return account.registrations.map(mapRegistration);
213
301
  };
214
302
  var getNames_default = getNames;
@@ -1,6 +1,6 @@
1
1
  // src/functions/getWrapperData.ts
2
2
  import { BigNumber } from "ethers";
3
- import { fuseEnum } from "../utils/fuses.mjs";
3
+ import { decodeFuses } from "../utils/fuses.mjs";
4
4
  import { namehash } from "../utils/normalise.mjs";
5
5
  var raw = async ({ contracts }, name) => {
6
6
  const nameWrapper = await contracts?.getNameWrapper();
@@ -17,17 +17,7 @@ var decode = async ({ contracts }, data) => {
17
17
  data
18
18
  );
19
19
  const fuses = BigNumber.from(_fuses);
20
- const fuseObj = Object.fromEntries(
21
- Object.keys(fuseEnum).map((fuse) => [
22
- fuse,
23
- fuses.and(fuseEnum[fuse]).gt(0)
24
- ])
25
- );
26
- if (fuses.eq(0)) {
27
- fuseObj.CAN_DO_EVERYTHING = true;
28
- } else {
29
- fuseObj.CAN_DO_EVERYTHING = false;
30
- }
20
+ const fuseObj = decodeFuses(fuses);
31
21
  const expiryDate = new Date(expiry * 1e3);
32
22
  return {
33
23
  fuseObj,
@@ -1,4 +1,5 @@
1
1
  // src/utils/fuses.ts
2
+ import { BigNumber } from "ethers";
2
3
  var CANNOT_UNWRAP = 1;
3
4
  var CANNOT_BURN_FUSES = 2;
4
5
  var CANNOT_TRANSFER = 4;
@@ -89,8 +90,24 @@ var validateFuses = (fuses) => {
89
90
  }
90
91
  return encodedFuses;
91
92
  };
93
+ var decodeFuses = (fuses) => {
94
+ const bnFuses = BigNumber.from(fuses);
95
+ const fuseObj = Object.fromEntries(
96
+ Object.keys(fuseEnum).map((fuse) => [
97
+ fuse,
98
+ bnFuses.and(fuseEnum[fuse]).gt(0)
99
+ ])
100
+ );
101
+ if (bnFuses.eq(0)) {
102
+ fuseObj.CAN_DO_EVERYTHING = true;
103
+ } else {
104
+ fuseObj.CAN_DO_EVERYTHING = false;
105
+ }
106
+ return fuseObj;
107
+ };
92
108
  var fuses_default = fullFuseEnum;
93
109
  export {
110
+ decodeFuses,
94
111
  fuses_default as default,
95
112
  fuseEnum,
96
113
  unnamedFuses,
@@ -2,8 +2,8 @@
2
2
  import { ethers } from "ethers";
3
3
  import fuses from "./fuses.mjs";
4
4
  var generateFuseInput_default = (fuseOptions) => {
5
- const fuseKeys = Object.keys(fuseOptions).filter((opt) => fuseOptions[opt] === true).map(
6
- (opt) => opt.split(/(?=[A-Z])/).join("_").toUpperCase()
5
+ const fuseKeys = Object.keys(fuseOptions).filter(
6
+ (opt) => fuseOptions[opt] === true
7
7
  );
8
8
  const bigNumberFuses = fuseKeys.reduce((prev, curr) => {
9
9
  return prev.or(fuses[curr]);
@@ -1,4 +1,5 @@
1
1
  import { ENSArgs } from '..';
2
+ import { CurrentFuses } from '../utils/fuses';
2
3
  export declare type Name = {
3
4
  id: string;
4
5
  labelName: string | null;
@@ -12,11 +13,12 @@ export declare type Name = {
12
13
  createdAt?: Date;
13
14
  registrationDate?: Date;
14
15
  expiryDate?: Date;
15
- type: 'domain' | 'registration';
16
+ fuses?: CurrentFuses;
17
+ type: 'domain' | 'registration' | 'wrappedDomain';
16
18
  };
17
19
  declare type BaseParams = {
18
20
  address: string;
19
- type: 'registrant' | 'owner' | 'all';
21
+ type: 'registrant' | 'owner' | 'wrappedOwner' | 'all';
20
22
  page?: number;
21
23
  pageSize?: number;
22
24
  orderDirection?: 'asc' | 'desc';
@@ -29,12 +31,16 @@ declare type OwnerParams = {
29
31
  type: 'owner';
30
32
  orderBy?: 'createdAt' | 'labelName';
31
33
  };
34
+ declare type WrappedOwnerParams = {
35
+ type: 'wrappedOwner';
36
+ orderBy?: 'expiryDate' | 'labelName';
37
+ };
32
38
  declare type AllParams = {
33
39
  type: 'all';
34
40
  orderBy?: 'labelName' | 'creationDate';
35
41
  page?: never;
36
42
  pageSize?: never;
37
43
  };
38
- declare type Params = BaseParams & (RegistrantParams | OwnerParams | AllParams);
44
+ declare type Params = BaseParams & (RegistrantParams | OwnerParams | WrappedOwnerParams | AllParams);
39
45
  declare const getNames: ({ gqlInstance }: ENSArgs<'gqlInstance'>, { address: _address, type, page, pageSize, orderDirection, orderBy, }: Params) => Promise<Name[]>;
40
46
  export default getNames;
@@ -1,13 +1,12 @@
1
1
  import { BigNumber } from 'ethers';
2
2
  import { ENSArgs } from '../index';
3
- import { CurrentFuses } from '../utils/fuses';
4
3
  declare const _default: {
5
4
  raw: ({ contracts }: ENSArgs<"contracts">, name: string) => Promise<{
6
5
  to: string;
7
6
  data: string;
8
7
  }>;
9
8
  decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
10
- fuseObj: CurrentFuses;
9
+ fuseObj: import("../utils/fuses").CurrentFuses;
11
10
  expiryDate: Date;
12
11
  rawFuses: BigNumber;
13
12
  owner: any;
@@ -391,7 +391,7 @@ export declare class ENS {
391
391
  }>;
392
392
  getNames: (args_0: {
393
393
  address: string;
394
- type: "owner" | "registrant" | "all";
394
+ type: "owner" | "wrappedOwner" | "registrant" | "all";
395
395
  page?: number | undefined;
396
396
  pageSize?: number | undefined;
397
397
  orderDirection?: "asc" | "desc" | undefined;
@@ -401,6 +401,9 @@ export declare class ENS {
401
401
  } | {
402
402
  type: "owner";
403
403
  orderBy?: "labelName" | "createdAt" | undefined;
404
+ } | {
405
+ type: "wrappedOwner";
406
+ orderBy?: "expiryDate" | "labelName" | undefined;
404
407
  } | {
405
408
  type: "all";
406
409
  orderBy?: "labelName" | "creationDate" | undefined;
@@ -1,3 +1,4 @@
1
+ import { BigNumberish } from 'ethers';
1
2
  export declare const fuseEnum: {
2
3
  readonly CANNOT_UNWRAP: 1;
3
4
  readonly CANNOT_BURN_FUSES: 2;
@@ -53,4 +54,5 @@ export declare type FusePropsNumber = {
53
54
  };
54
55
  export declare type FuseProps = (Partial<FusePropsNamedArray> & FusePropsUnnamedArray) | (FusePropsNamedArray & Partial<FusePropsUnnamedArray>) | FusePropsNumber;
55
56
  export declare const validateFuses: (fuses: FuseProps) => number;
57
+ export declare const decodeFuses: (fuses: BigNumberish) => CurrentFuses;
56
58
  export default fullFuseEnum;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensdomains/ensjs",
3
- "version": "3.0.0-alpha.27",
3
+ "version": "3.0.0-alpha.29",
4
4
  "description": "ENS javascript library for contract interaction",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -89,6 +89,25 @@ describe('getNames', () => {
89
89
  )
90
90
  testNotProperties(result[0], 'expiryDate', 'registrationDate')
91
91
  })
92
+ it('should get wrapped domains for an address', async () => {
93
+ const result = await ensInstance.getNames({
94
+ address: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
95
+ type: 'wrappedOwner',
96
+ })
97
+ expect(result).toBeTruthy()
98
+ testProperties(
99
+ result[0],
100
+ 'id',
101
+ 'labelName',
102
+ 'labelhash',
103
+ 'name',
104
+ 'isMigrated',
105
+ 'parent',
106
+ 'truncatedName',
107
+ 'expiryDate',
108
+ 'fuses',
109
+ )
110
+ })
92
111
  it('should get the registrations for an address with pagination', async () => {
93
112
  const pageOne = await ensInstance.getNames({
94
113
  address: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
@@ -147,6 +166,14 @@ describe('getNames', () => {
147
166
  })
148
167
  expect(pageFive).toHaveLength(totalOwnedNames % 10)
149
168
  })
169
+ it('should get wrapped domains for an address with pagination', async () => {
170
+ const pageOne = await ensInstance.getNames({
171
+ address: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
172
+ type: 'wrappedOwner',
173
+ page: 0,
174
+ })
175
+ expect(pageOne).toHaveLength(1)
176
+ })
150
177
  describe('orderBy', () => {
151
178
  describe('registrations', () => {
152
179
  it('descending registrationDate', async () => {
@@ -1,5 +1,6 @@
1
1
  import { ENSArgs } from '..'
2
2
  import { truncateFormat } from '../utils/format'
3
+ import { CurrentFuses, decodeFuses } from '../utils/fuses'
3
4
  import { decryptName } from '../utils/labels'
4
5
 
5
6
  export type Name = {
@@ -15,12 +16,13 @@ export type Name = {
15
16
  createdAt?: Date
16
17
  registrationDate?: Date
17
18
  expiryDate?: Date
18
- type: 'domain' | 'registration'
19
+ fuses?: CurrentFuses
20
+ type: 'domain' | 'registration' | 'wrappedDomain'
19
21
  }
20
22
 
21
23
  type BaseParams = {
22
24
  address: string
23
- type: 'registrant' | 'owner' | 'all'
25
+ type: 'registrant' | 'owner' | 'wrappedOwner' | 'all'
24
26
  page?: number
25
27
  pageSize?: number
26
28
  orderDirection?: 'asc' | 'desc'
@@ -36,6 +38,11 @@ type OwnerParams = {
36
38
  orderBy?: 'createdAt' | 'labelName'
37
39
  }
38
40
 
41
+ type WrappedOwnerParams = {
42
+ type: 'wrappedOwner'
43
+ orderBy?: 'expiryDate' | 'labelName'
44
+ }
45
+
39
46
  type AllParams = {
40
47
  type: 'all'
41
48
  orderBy?: 'labelName' | 'creationDate'
@@ -43,7 +50,8 @@ type AllParams = {
43
50
  pageSize?: never
44
51
  }
45
52
 
46
- type Params = BaseParams & (RegistrantParams | OwnerParams | AllParams)
53
+ type Params = BaseParams &
54
+ (RegistrantParams | OwnerParams | WrappedOwnerParams | AllParams)
47
55
 
48
56
  const mapDomain = (domain: any) => {
49
57
  const decrypted = decryptName(domain.name)
@@ -56,6 +64,16 @@ const mapDomain = (domain: any) => {
56
64
  }
57
65
  }
58
66
 
67
+ const mapWrappedDomain = (wrappedDomain: any) => {
68
+ const domain = mapDomain(wrappedDomain.domain)
69
+ return {
70
+ expiryDate: new Date(parseInt(wrappedDomain.expiryDate) * 1000),
71
+ fuses: decodeFuses(wrappedDomain.fuses),
72
+ ...domain,
73
+ type: 'wrappedDomain',
74
+ }
75
+ }
76
+
59
77
  const mapRegistration = (registration: any) => {
60
78
  const decrypted = decryptName(registration.domain.name)
61
79
  return {
@@ -116,6 +134,17 @@ const getNames = async (
116
134
  ${domainQueryData}
117
135
  createdAt
118
136
  }
137
+ wrappedDomains(first: 1000) {
138
+ expiryDate
139
+ fuses
140
+ domain {
141
+ ${domainQueryData}
142
+ registration {
143
+ registrationDate
144
+ expiryDate
145
+ }
146
+ }
147
+ }
119
148
  }
120
149
  }
121
150
  `
@@ -167,6 +196,71 @@ const getNames = async (
167
196
  }
168
197
  `
169
198
 
199
+ queryVars = {
200
+ id: address,
201
+ first: pageSize,
202
+ skip: (page || 0) * pageSize,
203
+ orderBy,
204
+ orderDirection,
205
+ }
206
+ }
207
+ } else if (type === 'wrappedOwner') {
208
+ if (typeof page !== 'number') {
209
+ finalQuery = gqlInstance.gql`
210
+ query getNames(
211
+ $id: ID!
212
+ $orderBy: WrappedDomain_orderBy
213
+ $orderDirection: OrderDirection
214
+ $expiryDate: Int
215
+ ) {
216
+ account(id: $id) {
217
+ wrappedDomains(
218
+ orderBy: $orderBy
219
+ orderDirection: $orderDirection
220
+ where: { expiryDate_gt: $expiryDate }
221
+ ) {
222
+ expiryDate
223
+ fuses
224
+ domain {
225
+ ${domainQueryData}
226
+ createdAt
227
+ }
228
+ }
229
+ }
230
+ }
231
+ `
232
+
233
+ queryVars = {
234
+ id: address,
235
+ expiryDate: Math.floor(Date.now() / 1000) - 90 * 24 * 60 * 60,
236
+ }
237
+ } else {
238
+ finalQuery = gqlInstance.gql`
239
+ query getNames(
240
+ $id: ID!
241
+ $first: Int
242
+ $skip: Int
243
+ $orderBy: WrappedDomain_orderBy
244
+ $orderDirection: OrderDirection
245
+ ) {
246
+ account(id: $id) {
247
+ wrappedDomains(
248
+ first: $first
249
+ skip: $skip
250
+ orderBy: $orderBy
251
+ orderDirection: $orderDirection
252
+ ) {
253
+ expiryDate
254
+ fuses
255
+ domain {
256
+ ${domainQueryData}
257
+ createdAt
258
+ }
259
+ }
260
+ }
261
+ }
262
+ `
263
+
170
264
  queryVars = {
171
265
  id: address,
172
266
  first: pageSize,
@@ -248,6 +342,7 @@ const getNames = async (
248
342
  return [
249
343
  ...account.domains.map(mapDomain),
250
344
  ...account.registrations.map(mapRegistration),
345
+ ...account.wrappedDomains.map(mapWrappedDomain),
251
346
  ].sort((a, b) => {
252
347
  if (orderDirection === 'desc') {
253
348
  if (orderBy === 'labelName') {
@@ -264,6 +359,9 @@ const getNames = async (
264
359
  if (type === 'owner') {
265
360
  return account.domains.map(mapDomain) as Name[]
266
361
  }
362
+ if (type === 'wrappedOwner') {
363
+ return account.wrappedDomains.map(mapWrappedDomain) as Name[]
364
+ }
267
365
  return account.registrations.map(mapRegistration) as Name[]
268
366
  }
269
367
 
@@ -1,6 +1,6 @@
1
1
  import { BigNumber } from 'ethers'
2
2
  import { ENSArgs } from '../index'
3
- import { CurrentFuses, fuseEnum } from '../utils/fuses'
3
+ import { decodeFuses } from '../utils/fuses'
4
4
  import { namehash } from '../utils/normalise'
5
5
 
6
6
  const raw = async ({ contracts }: ENSArgs<'contracts'>, name: string) => {
@@ -20,24 +20,12 @@ const decode = async ({ contracts }: ENSArgs<'contracts'>, data: string) => {
20
20
  )
21
21
 
22
22
  const fuses = BigNumber.from(_fuses)
23
-
24
- const fuseObj = Object.fromEntries(
25
- Object.keys(fuseEnum).map((fuse) => [
26
- fuse,
27
- fuses.and(fuseEnum[fuse as keyof typeof fuseEnum]).gt(0),
28
- ]),
29
- )
30
-
31
- if (fuses.eq(0)) {
32
- fuseObj.CAN_DO_EVERYTHING = true
33
- } else {
34
- fuseObj.CAN_DO_EVERYTHING = false
35
- }
23
+ const fuseObj = decodeFuses(fuses)
36
24
 
37
25
  const expiryDate = new Date(expiry * 1000)
38
26
 
39
27
  return {
40
- fuseObj: fuseObj as CurrentFuses,
28
+ fuseObj,
41
29
  expiryDate,
42
30
  rawFuses: fuses,
43
31
  owner,
@@ -1,3 +1,5 @@
1
+ import { BigNumber, BigNumberish } from 'ethers'
2
+
1
3
  const CANNOT_UNWRAP = 1
2
4
  const CANNOT_BURN_FUSES = 2
3
5
  const CANNOT_TRANSFER = 4
@@ -134,4 +136,23 @@ export const validateFuses = (fuses: FuseProps) => {
134
136
  return encodedFuses
135
137
  }
136
138
 
139
+ export const decodeFuses = (fuses: BigNumberish) => {
140
+ const bnFuses = BigNumber.from(fuses)
141
+
142
+ const fuseObj = Object.fromEntries(
143
+ Object.keys(fuseEnum).map((fuse) => [
144
+ fuse,
145
+ bnFuses.and(fuseEnum[fuse as keyof typeof fuseEnum]).gt(0),
146
+ ]),
147
+ )
148
+
149
+ if (bnFuses.eq(0)) {
150
+ fuseObj.CAN_DO_EVERYTHING = true
151
+ } else {
152
+ fuseObj.CAN_DO_EVERYTHING = false
153
+ }
154
+
155
+ return fuseObj as CurrentFuses
156
+ }
157
+
137
158
  export default fullFuseEnum
@@ -3,14 +3,10 @@ import { FuseOptions } from '../@types/FuseOptions'
3
3
  import fuses from './fuses'
4
4
 
5
5
  export default (fuseOptions: FuseOptions) => {
6
- const fuseKeys = Object.keys(fuseOptions)
7
- .filter((opt) => fuseOptions[opt as keyof FuseOptions] === true)
8
- .map((opt) =>
9
- opt
10
- .split(/(?=[A-Z])/)
11
- .join('_')
12
- .toUpperCase(),
13
- )
6
+ const fuseKeys = Object.keys(fuseOptions).filter(
7
+ (opt) => fuseOptions[opt as keyof FuseOptions] === true,
8
+ )
9
+
14
10
  const bigNumberFuses = fuseKeys.reduce((prev, curr) => {
15
11
  return prev.or(fuses[curr as keyof typeof fuses])
16
12
  }, ethers.BigNumber.from(0))