@ensdomains/ensjs 3.0.0-alpha.26 → 3.0.0-alpha.28

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/contracts/getContractAddress.js +1 -1
  3. package/dist/cjs/functions/batchWrappers.js +41 -8
  4. package/dist/cjs/functions/getName.js +2 -2
  5. package/dist/cjs/functions/getNames.js +89 -1
  6. package/dist/cjs/functions/getOwner.js +4 -4
  7. package/dist/cjs/functions/getProfile.js +117 -87
  8. package/dist/cjs/functions/getWrapperData.js +1 -11
  9. package/dist/cjs/generated/factories/NameWrapper__factory.js +13 -0
  10. package/dist/cjs/generated/factories/UniversalResolver__factory.js +277 -0
  11. package/dist/cjs/utils/ccip.js +128 -0
  12. package/dist/cjs/utils/fuses.js +17 -0
  13. package/dist/cjs/utils/singleCall.js +1 -1
  14. package/dist/esm/contracts/getContractAddress.mjs +1 -1
  15. package/dist/esm/functions/batchWrappers.mjs +35 -8
  16. package/dist/esm/functions/getName.mjs +2 -2
  17. package/dist/esm/functions/getNames.mjs +89 -1
  18. package/dist/esm/functions/getOwner.mjs +4 -4
  19. package/dist/esm/functions/getProfile.mjs +117 -87
  20. package/dist/esm/functions/getWrapperData.mjs +2 -12
  21. package/dist/esm/generated/factories/NameWrapper__factory.mjs +13 -0
  22. package/dist/esm/generated/factories/UniversalResolver__factory.mjs +277 -0
  23. package/dist/esm/utils/ccip.mjs +114 -0
  24. package/dist/esm/utils/fuses.mjs +17 -0
  25. package/dist/esm/utils/singleCall.mjs +1 -1
  26. package/dist/types/functions/batchWrappers.d.ts +58 -1
  27. package/dist/types/functions/getNames.d.ts +9 -3
  28. package/dist/types/functions/getProfile.d.ts +6 -0
  29. package/dist/types/functions/getWrapperData.d.ts +1 -2
  30. package/dist/types/generated/NameWrapper.d.ts +9 -1
  31. package/dist/types/generated/UniversalResolver.d.ts +123 -21
  32. package/dist/types/index.d.ts +68 -3
  33. package/dist/types/utils/ccip.d.ts +3 -0
  34. package/dist/types/utils/fuses.d.ts +2 -0
  35. package/package.json +3 -3
  36. package/src/contracts/getContractAddress.ts +1 -1
  37. package/src/functions/batchWrappers.ts +40 -9
  38. package/src/functions/getName.ts +2 -2
  39. package/src/functions/getNames.test.ts +27 -0
  40. package/src/functions/getNames.ts +101 -3
  41. package/src/functions/getOwner.ts +4 -2
  42. package/src/functions/getProfile-ccip.test.ts +29 -0
  43. package/src/functions/getProfile.test.ts +1 -1
  44. package/src/functions/getProfile.ts +160 -100
  45. package/src/functions/getWrapperData.ts +3 -15
  46. package/src/functions/setName.test.ts +6 -2
  47. package/src/functions/setRecord.test.ts +3 -3
  48. package/src/functions/setRecords.test.ts +2 -2
  49. package/src/generated/NameWrapper.ts +14 -0
  50. package/src/generated/UniversalResolver.ts +382 -19
  51. package/src/generated/factories/NameWrapper__factory.ts +13 -0
  52. package/src/generated/factories/UniversalResolver__factory.ts +277 -0
  53. package/src/index.ts +1 -1
  54. package/src/utils/ccip.ts +148 -0
  55. package/src/utils/fuses.ts +21 -0
  56. package/src/utils/singleCall.ts +1 -1
@@ -29,6 +29,11 @@ const _abi = [
29
29
  internalType: "address",
30
30
  name: "_registry",
31
31
  type: "address"
32
+ },
33
+ {
34
+ internalType: "string[]",
35
+ name: "_urls",
36
+ type: "string[]"
32
37
  }
33
38
  ],
34
39
  stateMutability: "nonpayable",
@@ -65,6 +70,69 @@ const _abi = [
65
70
  name: "OffchainLookup",
66
71
  type: "error"
67
72
  },
73
+ {
74
+ inputs: [
75
+ {
76
+ internalType: "bytes",
77
+ name: "name",
78
+ type: "bytes"
79
+ },
80
+ {
81
+ internalType: "bytes",
82
+ name: "data",
83
+ type: "bytes"
84
+ },
85
+ {
86
+ internalType: "string[]",
87
+ name: "gateways",
88
+ type: "string[]"
89
+ },
90
+ {
91
+ internalType: "bytes4",
92
+ name: "callbackFunction",
93
+ type: "bytes4"
94
+ },
95
+ {
96
+ internalType: "bytes",
97
+ name: "metaData",
98
+ type: "bytes"
99
+ }
100
+ ],
101
+ name: "_resolveSingle",
102
+ outputs: [
103
+ {
104
+ internalType: "bytes",
105
+ name: "",
106
+ type: "bytes"
107
+ },
108
+ {
109
+ internalType: "address",
110
+ name: "",
111
+ type: "address"
112
+ }
113
+ ],
114
+ stateMutability: "view",
115
+ type: "function"
116
+ },
117
+ {
118
+ inputs: [
119
+ {
120
+ internalType: "uint256",
121
+ name: "",
122
+ type: "uint256"
123
+ }
124
+ ],
125
+ name: "batchGatewayURLs",
126
+ outputs: [
127
+ {
128
+ internalType: "string",
129
+ name: "",
130
+ type: "string"
131
+ }
132
+ ],
133
+ stateMutability: "view",
134
+ type: "function"
135
+ },
68
136
  {
69
137
  inputs: [
70
138
  {
@@ -102,6 +170,103 @@ const _abi = [
102
170
  stateMutability: "view",
103
171
  type: "function"
104
172
  },
173
+ {
174
+ inputs: [
175
+ {
176
+ internalType: "bytes",
177
+ name: "name",
178
+ type: "bytes"
179
+ },
180
+ {
181
+ internalType: "bytes",
182
+ name: "data",
183
+ type: "bytes"
184
+ },
185
+ {
186
+ internalType: "string[]",
187
+ name: "gateways",
188
+ type: "string[]"
189
+ }
190
+ ],
191
+ name: "resolve",
192
+ outputs: [
193
+ {
194
+ internalType: "bytes",
195
+ name: "",
196
+ type: "bytes"
197
+ },
198
+ {
199
+ internalType: "address",
200
+ name: "",
201
+ type: "address"
202
+ }
203
+ ],
204
+ stateMutability: "view",
205
+ type: "function"
206
+ },
207
+ {
208
+ inputs: [
209
+ {
210
+ internalType: "bytes",
211
+ name: "name",
212
+ type: "bytes"
213
+ },
214
+ {
215
+ internalType: "bytes[]",
216
+ name: "data",
217
+ type: "bytes[]"
218
+ }
219
+ ],
220
+ name: "resolve",
221
+ outputs: [
222
+ {
223
+ internalType: "bytes[]",
224
+ name: "",
225
+ type: "bytes[]"
226
+ },
227
+ {
228
+ internalType: "address",
229
+ name: "",
230
+ type: "address"
231
+ }
232
+ ],
233
+ stateMutability: "view",
234
+ type: "function"
235
+ },
236
+ {
237
+ inputs: [
238
+ {
239
+ internalType: "bytes",
240
+ name: "name",
241
+ type: "bytes"
242
+ },
243
+ {
244
+ internalType: "bytes[]",
245
+ name: "data",
246
+ type: "bytes[]"
247
+ },
248
+ {
249
+ internalType: "string[]",
250
+ name: "gateways",
251
+ type: "string[]"
252
+ }
253
+ ],
254
+ name: "resolve",
255
+ outputs: [
256
+ {
257
+ internalType: "bytes[]",
258
+ name: "",
259
+ type: "bytes[]"
260
+ },
261
+ {
262
+ internalType: "address",
263
+ name: "",
264
+ type: "address"
265
+ }
266
+ ],
267
+ stateMutability: "view",
268
+ type: "function"
269
+ },
105
270
  {
106
271
  inputs: [
107
272
  {
@@ -145,11 +310,84 @@ const _abi = [
145
310
  }
146
311
  ],
147
312
  name: "resolveCallback",
313
+ outputs: [
314
+ {
315
+ internalType: "bytes[]",
316
+ name: "",
317
+ type: "bytes[]"
318
+ },
319
+ {
320
+ internalType: "address",
321
+ name: "",
322
+ type: "address"
323
+ }
324
+ ],
325
+ stateMutability: "nonpayable",
326
+ type: "function"
327
+ },
328
+ {
329
+ inputs: [
330
+ {
331
+ internalType: "bytes",
332
+ name: "response",
333
+ type: "bytes"
334
+ },
335
+ {
336
+ internalType: "bytes",
337
+ name: "extraData",
338
+ type: "bytes"
339
+ }
340
+ ],
341
+ name: "resolveSingleCallback",
148
342
  outputs: [
149
343
  {
150
344
  internalType: "bytes",
151
345
  name: "",
152
346
  type: "bytes"
347
+ },
348
+ {
349
+ internalType: "address",
350
+ name: "",
351
+ type: "address"
352
+ }
353
+ ],
354
+ stateMutability: "nonpayable",
355
+ type: "function"
356
+ },
357
+ {
358
+ inputs: [
359
+ {
360
+ internalType: "bytes",
361
+ name: "reverseName",
362
+ type: "bytes"
363
+ },
364
+ {
365
+ internalType: "string[]",
366
+ name: "gateways",
367
+ type: "string[]"
368
+ }
369
+ ],
370
+ name: "reverse",
371
+ outputs: [
372
+ {
373
+ internalType: "string",
374
+ name: "",
375
+ type: "string"
376
+ },
377
+ {
378
+ internalType: "address",
379
+ name: "",
380
+ type: "address"
381
+ },
382
+ {
383
+ internalType: "address",
384
+ name: "",
385
+ type: "address"
386
+ },
387
+ {
388
+ internalType: "address",
389
+ name: "",
390
+ type: "address"
153
391
  }
154
392
  ],
155
393
  stateMutability: "view",
@@ -189,6 +427,45 @@ const _abi = [
189
427
  stateMutability: "view",
190
428
  type: "function"
191
429
  },
430
+ {
431
+ inputs: [
432
+ {
433
+ internalType: "bytes",
434
+ name: "response",
435
+ type: "bytes"
436
+ },
437
+ {
438
+ internalType: "bytes",
439
+ name: "extraData",
440
+ type: "bytes"
441
+ }
442
+ ],
443
+ name: "reverseCallback",
444
+ outputs: [
445
+ {
446
+ internalType: "string",
447
+ name: "",
448
+ type: "string"
449
+ },
450
+ {
451
+ internalType: "address",
452
+ name: "",
453
+ type: "address"
454
+ },
455
+ {
456
+ internalType: "address",
457
+ name: "",
458
+ type: "address"
459
+ },
460
+ {
461
+ internalType: "address",
462
+ name: "",
463
+ type: "address"
464
+ }
465
+ ],
466
+ stateMutability: "nonpayable",
467
+ type: "function"
468
+ },
192
469
  {
193
470
  inputs: [
194
471
  {
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ccip_exports = {};
20
+ __export(ccip_exports, {
21
+ default: () => ccip_default
22
+ });
23
+ module.exports = __toCommonJS(ccip_exports);
24
+ var import_ethers = require("ethers");
25
+ var import_utils = require("ethers/lib/utils");
26
+ function bytesPad(value) {
27
+ if (value.length % 32 === 0) {
28
+ return value;
29
+ }
30
+ const result = new Uint8Array(Math.ceil(value.length / 32) * 32);
31
+ result.set(value);
32
+ return result;
33
+ }
34
+ function numPad(value) {
35
+ const result = (0, import_utils.arrayify)(value);
36
+ if (result.length > 32) {
37
+ throw new Error("internal; should not happen");
38
+ }
39
+ const padded = new Uint8Array(32);
40
+ padded.set(result, 32 - result.length);
41
+ return padded;
42
+ }
43
+ function encodeBytes(datas) {
44
+ const result = [];
45
+ let byteCount = 0;
46
+ for (let i = 0; i < datas.length; i += 1) {
47
+ result.push(new Uint8Array(0));
48
+ byteCount += 32;
49
+ }
50
+ for (let i = 0; i < datas.length; i += 1) {
51
+ const data = (0, import_utils.arrayify)(datas[i]);
52
+ result[i] = numPad(byteCount);
53
+ result.push(numPad(data.length));
54
+ result.push(bytesPad(data));
55
+ byteCount += 32 + Math.ceil(data.length / 32) * 32;
56
+ }
57
+ return (0, import_utils.hexConcat)(result);
58
+ }
59
+ function _parseBytes(result, start) {
60
+ if (result === "0x") {
61
+ return null;
62
+ }
63
+ const offset = import_ethers.BigNumber.from(
64
+ (0, import_utils.hexDataSlice)(result, start, start + 32)
65
+ ).toNumber();
66
+ const length = import_ethers.BigNumber.from(
67
+ (0, import_utils.hexDataSlice)(result, offset, offset + 32)
68
+ ).toNumber();
69
+ return (0, import_utils.hexDataSlice)(result, offset + 32, offset + 32 + length);
70
+ }
71
+ function _parseString(result, start) {
72
+ try {
73
+ const bytes = _parseBytes(result, start);
74
+ if (bytes == null)
75
+ return null;
76
+ return (0, import_utils.toUtf8String)(bytes);
77
+ } catch (error) {
78
+ }
79
+ return null;
80
+ }
81
+ const ccipLookup = async (provider, transaction, result) => {
82
+ const txSender = transaction.to;
83
+ try {
84
+ const data = (0, import_utils.hexDataSlice)(result, 4);
85
+ const sender = (0, import_utils.hexDataSlice)(data, 0, 32);
86
+ if (!import_ethers.BigNumber.from(sender).eq(txSender)) {
87
+ throw new Error("CCIP Read sender did not match");
88
+ }
89
+ const urls = [];
90
+ const urlsOffset = import_ethers.BigNumber.from((0, import_utils.hexDataSlice)(data, 32, 64)).toNumber();
91
+ const urlsLength = import_ethers.BigNumber.from(
92
+ (0, import_utils.hexDataSlice)(data, urlsOffset, urlsOffset + 32)
93
+ ).toNumber();
94
+ const urlsData = (0, import_utils.hexDataSlice)(data, urlsOffset + 32);
95
+ for (let u = 0; u < urlsLength; u += 1) {
96
+ const url = _parseString(urlsData, u * 32);
97
+ if (url == null) {
98
+ throw new Error("CCIP Read contained corrupt URL string");
99
+ }
100
+ urls.push(url);
101
+ }
102
+ const calldata = _parseBytes(data, 64);
103
+ if (!import_ethers.BigNumber.from((0, import_utils.hexDataSlice)(data, 100, 128)).isZero()) {
104
+ throw new Error("CCIP Read callback selected included junk");
105
+ }
106
+ const callbackSelector = (0, import_utils.hexDataSlice)(data, 96, 100);
107
+ const extraData = _parseBytes(data, 128);
108
+ const ccipResult = await provider.ccipReadFetch(
109
+ transaction,
110
+ calldata,
111
+ urls
112
+ );
113
+ if (ccipResult == null) {
114
+ throw new Error("CCIP Read disabled or provided no URLs");
115
+ }
116
+ const tx = {
117
+ to: sender,
118
+ data: (0, import_utils.hexConcat)([
119
+ callbackSelector,
120
+ encodeBytes([ccipResult, extraData])
121
+ ])
122
+ };
123
+ return await provider._call(tx, "latest", 1);
124
+ } catch (error) {
125
+ console.error(error);
126
+ }
127
+ };
128
+ var ccip_default = ccipLookup;
@@ -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;
@@ -21,4 +21,4 @@ __export(singleCall_exports, {
21
21
  default: () => singleCall_default
22
22
  });
23
23
  module.exports = __toCommonJS(singleCall_exports);
24
- var singleCall_default = async (provider, ensData, func, ...data) => func.raw(ensData, ...data).then((rawData) => provider.call(rawData)).catch(() => null).then((ret) => func.decode(ensData, ret, ...data));
24
+ var singleCall_default = async (provider, ensData, func, ...data) => func.raw(ensData, ...data).then((rawData) => provider.call({ ...rawData, ccipReadEnabled: true })).catch(() => null).then((ret) => func.decode(ensData, ret, ...data));
@@ -44,7 +44,7 @@ var addresses = {
44
44
  "1": "0x580AF46E06DaaD47eb5940526FD64d95b815Cb70",
45
45
  "3": "0x74e20bd2a1fe0cdbe45b9a1d89cb7e0a45b36376",
46
46
  "4": "0x74e20bd2a1fe0cdbe45b9a1d89cb7e0a45b36376",
47
- "5": "0x9380F1974D2B7064eA0c0EC251968D8c69f0Ae31"
47
+ "5": "0x687c30Cc44bFA39A1449e86E172BF002E7b3f0b0"
48
48
  },
49
49
  BulkRenewal: {
50
50
  "1": "0xfF252725f6122A92551A5FA9a6b6bf10eb0Be035",
@@ -1,20 +1,21 @@
1
1
  // src/functions/batchWrappers.ts
2
+ import ccipLookup from "../utils/ccip.mjs";
2
3
  import { hexEncodeName } from "../utils/hexEncodedName.mjs";
3
4
  var universalWrapper = {
4
5
  raw: async ({ contracts }, name, data) => {
5
6
  const universalResolver = await contracts?.getUniversalResolver();
6
7
  return {
7
8
  to: universalResolver.address,
8
- data: universalResolver.interface.encodeFunctionData("resolve", [
9
- hexEncodeName(name),
10
- data
11
- ])
9
+ data: universalResolver.interface.encodeFunctionData(
10
+ "resolve(bytes,bytes)",
11
+ [hexEncodeName(name), data]
12
+ )
12
13
  };
13
14
  },
14
15
  decode: async ({ contracts }, data) => {
15
16
  const universalResolver = await contracts?.getUniversalResolver();
16
17
  const response = universalResolver.interface.decodeFunctionResult(
17
- "resolve",
18
+ "resolve(bytes,bytes)",
18
19
  data
19
20
  );
20
21
  if (!response || !response[0]) {
@@ -60,7 +61,7 @@ var multicallWrapper = {
60
61
  ])
61
62
  };
62
63
  },
63
- async decode({ contracts }, data) {
64
+ async decode({ contracts, provider }, data, transactions) {
64
65
  if (!data)
65
66
  return;
66
67
  const multicall = await contracts?.getMulticall();
@@ -69,9 +70,35 @@ var multicallWrapper = {
69
70
  "tryAggregate",
70
71
  data
71
72
  );
72
- return result;
73
+ const ccipChecked = await Promise.all(
74
+ result.map(
75
+ async ([success, returnData], i) => {
76
+ let newArr = [success, returnData];
77
+ if (!success && returnData.startsWith("0x556f1830")) {
78
+ try {
79
+ const newData = await ccipLookup(
80
+ provider,
81
+ transactions[i],
82
+ returnData
83
+ );
84
+ if (newData) {
85
+ newArr = [true, newData];
86
+ }
87
+ } catch {
88
+ }
89
+ }
90
+ return {
91
+ ...newArr,
92
+ success: newArr[0],
93
+ returnData: newArr[1]
94
+ };
95
+ }
96
+ )
97
+ );
98
+ return ccipChecked;
73
99
  } catch (e) {
74
- return e;
100
+ console.error(e);
101
+ return;
75
102
  }
76
103
  }
77
104
  };
@@ -5,7 +5,7 @@ var raw = async ({ contracts }, address) => {
5
5
  const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
6
6
  return {
7
7
  to: universalResolver.address,
8
- data: universalResolver.interface.encodeFunctionData("reverse", [
8
+ data: universalResolver.interface.encodeFunctionData("reverse(bytes)", [
9
9
  hexEncodeName(reverseNode)
10
10
  ])
11
11
  };
@@ -16,7 +16,7 @@ var decode = async ({ contracts }, data, address) => {
16
16
  const universalResolver = await contracts?.getUniversalResolver();
17
17
  try {
18
18
  const result = universalResolver.interface.decodeFunctionResult(
19
- "reverse",
19
+ "reverse(bytes)",
20
20
  data
21
21
  );
22
22
  return {
@@ -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;