@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
package/README.md CHANGED
@@ -50,7 +50,7 @@ The batch function is a large part of this library, and there are plenty of situ
50
50
 
51
51
  ```js
52
52
  /* Batch functions can be called like so, with the function as the first item in an array, with the following items being the function's arguments */
53
- const batched = await batch(
53
+ const batched = await ENSInstance.batch(
54
54
  ENSInstance.getText.batch('test.eth', 'foo'),
55
55
  ENSInstance.getAddr.batch('test.eth'),
56
56
  ENSInstance.getOwner.batch('test.eth'),
@@ -66,7 +66,7 @@ const addresses = {
66
66
  "1": "0x580AF46E06DaaD47eb5940526FD64d95b815Cb70",
67
67
  "3": "0x74e20bd2a1fe0cdbe45b9a1d89cb7e0a45b36376",
68
68
  "4": "0x74e20bd2a1fe0cdbe45b9a1d89cb7e0a45b36376",
69
- "5": "0x9380F1974D2B7064eA0c0EC251968D8c69f0Ae31"
69
+ "5": "0x687c30Cc44bFA39A1449e86E172BF002E7b3f0b0"
70
70
  },
71
71
  BulkRenewal: {
72
72
  "1": "0xfF252725f6122A92551A5FA9a6b6bf10eb0Be035",
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
18
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
25
  var batchWrappers_exports = {};
20
26
  __export(batchWrappers_exports, {
@@ -23,22 +29,23 @@ __export(batchWrappers_exports, {
23
29
  universalWrapper: () => universalWrapper
24
30
  });
25
31
  module.exports = __toCommonJS(batchWrappers_exports);
32
+ var import_ccip = __toESM(require("../utils/ccip"));
26
33
  var import_hexEncodedName = require("../utils/hexEncodedName");
27
34
  const universalWrapper = {
28
35
  raw: async ({ contracts }, name, data) => {
29
36
  const universalResolver = await contracts?.getUniversalResolver();
30
37
  return {
31
38
  to: universalResolver.address,
32
- data: universalResolver.interface.encodeFunctionData("resolve", [
33
- (0, import_hexEncodedName.hexEncodeName)(name),
34
- data
35
- ])
39
+ data: universalResolver.interface.encodeFunctionData(
40
+ "resolve(bytes,bytes)",
41
+ [(0, import_hexEncodedName.hexEncodeName)(name), data]
42
+ )
36
43
  };
37
44
  },
38
45
  decode: async ({ contracts }, data) => {
39
46
  const universalResolver = await contracts?.getUniversalResolver();
40
47
  const response = universalResolver.interface.decodeFunctionResult(
41
- "resolve",
48
+ "resolve(bytes,bytes)",
42
49
  data
43
50
  );
44
51
  if (!response || !response[0]) {
@@ -84,7 +91,7 @@ const multicallWrapper = {
84
91
  ])
85
92
  };
86
93
  },
87
- async decode({ contracts }, data) {
94
+ async decode({ contracts, provider }, data, transactions) {
88
95
  if (!data)
89
96
  return;
90
97
  const multicall = await contracts?.getMulticall();
@@ -93,9 +100,35 @@ const multicallWrapper = {
93
100
  "tryAggregate",
94
101
  data
95
102
  );
96
- return result;
103
+ const ccipChecked = await Promise.all(
104
+ result.map(
105
+ async ([success, returnData], i) => {
106
+ let newArr = [success, returnData];
107
+ if (!success && returnData.startsWith("0x556f1830")) {
108
+ try {
109
+ const newData = await (0, import_ccip.default)(
110
+ provider,
111
+ transactions[i],
112
+ returnData
113
+ );
114
+ if (newData) {
115
+ newArr = [true, newData];
116
+ }
117
+ } catch {
118
+ }
119
+ }
120
+ return {
121
+ ...newArr,
122
+ success: newArr[0],
123
+ returnData: newArr[1]
124
+ };
125
+ }
126
+ )
127
+ );
128
+ return ccipChecked;
97
129
  } catch (e) {
98
- return e;
130
+ console.error(e);
131
+ return;
99
132
  }
100
133
  }
101
134
  };
@@ -27,7 +27,7 @@ const raw = async ({ contracts }, address) => {
27
27
  const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
28
28
  return {
29
29
  to: universalResolver.address,
30
- data: universalResolver.interface.encodeFunctionData("reverse", [
30
+ data: universalResolver.interface.encodeFunctionData("reverse(bytes)", [
31
31
  (0, import_hexEncodedName.hexEncodeName)(reverseNode)
32
32
  ])
33
33
  };
@@ -38,7 +38,7 @@ const decode = async ({ contracts }, data, address) => {
38
38
  const universalResolver = await contracts?.getUniversalResolver();
39
39
  try {
40
40
  const result = universalResolver.interface.decodeFunctionResult(
41
- "reverse",
41
+ "reverse(bytes)",
42
42
  data
43
43
  );
44
44
  return {
@@ -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;
@@ -88,7 +88,7 @@ const raw = async ({ contracts, multicallWrapper }, name, contract) => {
88
88
  };
89
89
  const singleContractOwnerDecode = (data) => import_ethers.ethers.utils.defaultAbiCoder.decode(["address"], data)[0];
90
90
  const decode = async ({ contracts, multicallWrapper }, data, name, contract) => {
91
- if (data === null)
91
+ if (!data)
92
92
  return;
93
93
  const labels = name.split(".");
94
94
  if (contract || labels.length === 1) {
@@ -108,7 +108,7 @@ const decode = async ({ contracts, multicallWrapper }, data, name, contract) =>
108
108
  };
109
109
  }
110
110
  const result = await multicallWrapper.decode(data);
111
- if (result === null)
111
+ if (!result)
112
112
  return;
113
113
  const nameWrapper = await contracts?.getNameWrapper();
114
114
  const decodedData = [result[0][1], result[1][1], result[2]?.[1]].map(
@@ -132,7 +132,7 @@ const decode = async ({ contracts, multicallWrapper }, data, name, contract) =>
132
132
  };
133
133
  }
134
134
  if (labels.length > 2 && import_ethers.ethers.utils.hexStripZeros(registryOwner) !== "0x") {
135
- if (registryOwner === nameWrapper.address && import_ethers.ethers.utils.hexStripZeros(nameWrapperOwner) !== "0x") {
135
+ if (registryOwner === nameWrapper.address && nameWrapperOwner && import_ethers.ethers.utils.hexStripZeros(nameWrapperOwner) !== "0x") {
136
136
  return {
137
137
  owner: nameWrapperOwner,
138
138
  ownershipLevel: "nameWrapper"
@@ -145,7 +145,7 @@ const decode = async ({ contracts, multicallWrapper }, data, name, contract) =>
145
145
  }
146
146
  return;
147
147
  }
148
- if (registryOwner === nameWrapper.address && import_ethers.ethers.utils.hexStripZeros(nameWrapperOwner) !== "0x") {
148
+ if (registryOwner === nameWrapper.address && nameWrapperOwner && import_ethers.ethers.utils.hexStripZeros(nameWrapperOwner) !== "0x") {
149
149
  return {
150
150
  owner: nameWrapperOwner,
151
151
  ownershipLevel: "nameWrapper"
@@ -23,6 +23,7 @@ __export(getProfile_exports, {
23
23
  module.exports = __toCommonJS(getProfile_exports);
24
24
  var import_address_encoder = require("@ensdomains/address-encoder");
25
25
  var import_ethers = require("ethers");
26
+ var import_utils = require("ethers/lib/utils");
26
27
  var import_contentHash = require("../utils/contentHash");
27
28
  var import_hexEncodedName = require("../utils/hexEncodedName");
28
29
  var import_normalise = require("../utils/normalise");
@@ -30,8 +31,7 @@ var import_validation = require("../utils/validation");
30
31
  const makeMulticallData = async ({
31
32
  _getAddr,
32
33
  _getContentHash,
33
- _getText,
34
- resolverMulticallWrapper
34
+ _getText
35
35
  }, name, options) => {
36
36
  let calls = [];
37
37
  if (options.texts)
@@ -60,7 +60,7 @@ const makeMulticallData = async ({
60
60
  calls.push({
61
61
  key: "contentHash",
62
62
  data: await _getContentHash.raw(name),
63
- type: "contenthash"
63
+ type: "contentHash"
64
64
  });
65
65
  }
66
66
  if (!calls.find((x) => x.key === "60")) {
@@ -70,17 +70,17 @@ const makeMulticallData = async ({
70
70
  type: "addr"
71
71
  });
72
72
  }
73
- const prRawData = await resolverMulticallWrapper.raw(calls.map((x) => x.data));
74
- return { data: prRawData.data, calls };
73
+ return { data: calls.map((x) => x.data.data), calls };
75
74
  };
76
75
  const fetchWithoutResolverMulticall = async ({ multicallWrapper }, calls, resolverAddress) => {
77
76
  const callsWithResolver = calls.map((call) => ({
78
77
  to: resolverAddress,
79
78
  data: call.data.data
80
79
  }));
81
- return (await multicallWrapper(callsWithResolver)).map(
82
- (x) => x[1]
83
- );
80
+ const results = await multicallWrapper(callsWithResolver);
81
+ if (!results || !results.length)
82
+ return [];
83
+ return results.map((x) => x[1]);
84
84
  };
85
85
  const formatRecords = async ({
86
86
  _getText,
@@ -94,7 +94,7 @@ const formatRecords = async ({
94
94
  key: calls[i].key,
95
95
  type: calls[i].type
96
96
  };
97
- if (itemRet.type === "contenthash") {
97
+ if (itemRet.type === "contentHash") {
98
98
  ;
99
99
  [decodedFromAbi] = import_ethers.ethers.utils.defaultAbiCoder.decode(
100
100
  ["bytes"],
@@ -128,7 +128,7 @@ const formatRecords = async ({
128
128
  } catch {
129
129
  return;
130
130
  }
131
- case "contenthash":
131
+ case "contentHash":
132
132
  try {
133
133
  itemRet = {
134
134
  ...itemRet,
@@ -155,7 +155,7 @@ const formatRecords = async ({
155
155
  }
156
156
  } else if (options.contentHash) {
157
157
  const foundRecord = returnedRecords.find(
158
- (item) => item.type === "contenthash"
158
+ (item) => item.type === "contentHash"
159
159
  );
160
160
  returnedResponse.contentHash = foundRecord ? foundRecord.value : null;
161
161
  }
@@ -176,57 +176,64 @@ const getDataForName = async ({
176
176
  _getAddr,
177
177
  _getContentHash,
178
178
  _getText,
179
- resolverMulticallWrapper,
180
179
  multicallWrapper
181
- }, name, options, fallbackResolver, specificResolver) => {
180
+ }, name, options, specificResolver) => {
182
181
  const universalResolver = await contracts?.getUniversalResolver();
183
182
  const { data, calls } = await makeMulticallData(
184
- { _getAddr, _getContentHash, _getText, resolverMulticallWrapper },
183
+ { _getAddr, _getContentHash, _getText },
185
184
  name,
186
185
  options
187
186
  );
188
- let resolvedData;
189
- let useFallbackResolver = false;
190
- try {
191
- if (specificResolver) {
187
+ let recordData;
188
+ let resolverAddress = specificResolver;
189
+ if (specificResolver) {
190
+ try {
192
191
  const publicResolver = await contracts?.getPublicResolver(
193
192
  void 0,
194
193
  specificResolver
195
194
  );
196
- resolvedData = await publicResolver?.callStatic.multicall(
197
- calls.map((x) => x.data)
195
+ recordData = await publicResolver?.callStatic.multicall(data);
196
+ } catch (e) {
197
+ console.error("getProfile error:", e);
198
+ recordData = await fetchWithoutResolverMulticall(
199
+ { multicallWrapper },
200
+ calls,
201
+ resolverAddress
198
202
  );
199
- } else {
200
- resolvedData = await universalResolver?.resolve((0, import_hexEncodedName.hexEncodeName)(name), data);
201
203
  }
202
- } catch {
203
- useFallbackResolver = true;
204
- }
205
- let resolverAddress;
206
- let recordData;
207
- if (useFallbackResolver) {
208
- resolverAddress = specificResolver || fallbackResolver;
209
- recordData = await fetchWithoutResolverMulticall(
210
- { multicallWrapper },
211
- calls,
212
- resolverAddress
213
- );
214
204
  } else {
215
- resolverAddress = specificResolver || resolvedData["1"];
216
- if (specificResolver) {
217
- recordData = resolvedData;
218
- } else {
219
- ;
220
- [recordData] = await resolverMulticallWrapper.decode(resolvedData["0"]);
205
+ const resolvedData = await universalResolver["resolve(bytes,bytes[])"](
206
+ (0, import_hexEncodedName.hexEncodeName)(name),
207
+ data,
208
+ {
209
+ ccipReadEnabled: true
210
+ }
211
+ );
212
+ recordData = [...resolvedData["0"]];
213
+ resolverAddress = resolvedData["1"];
214
+ for (let i = 0; i < recordData.length; i += 1) {
215
+ if (recordData[i].startsWith("0x0d1947a9")) {
216
+ calls[i] = null;
217
+ recordData[i] = null;
218
+ }
221
219
  }
222
220
  }
223
- const matchAddress = recordData[calls.findIndex((x) => x.key === "60")];
221
+ if (!resolverAddress || !recordData || (0, import_utils.hexStripZeros)(resolverAddress) === "0x") {
222
+ return {
223
+ address: null,
224
+ records: {},
225
+ resolverAddress: null
226
+ };
227
+ }
228
+ const filteredCalls = calls.filter((x) => x);
229
+ const filteredRecordData = recordData.filter((x) => x);
230
+ const matchAddress = filteredRecordData[filteredCalls.findIndex((x) => x.key === "60")];
224
231
  return {
225
232
  address: matchAddress && await _getAddr.decode(matchAddress),
226
233
  records: await formatRecords(
227
234
  { _getAddr, _getContentHash, _getText },
228
- recordData,
229
- calls,
235
+ filteredRecordData,
236
+ filteredCalls,
230
237
  options
231
238
  ),
232
239
  resolverAddress
@@ -245,7 +252,6 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress)
245
252
  addr {
246
253
  id
247
254
  }
248
- address
249
255
  }
250
256
  }
251
257
  }
@@ -285,14 +291,8 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress)
285
291
  return;
286
292
  const { isMigrated, createdAt } = domain;
287
293
  const returnedRecords = {};
288
- if (!resolverResponse)
294
+ if (!resolverResponse || !wantedRecords)
289
295
  return { isMigrated, createdAt };
290
- if (!wantedRecords)
291
- return {
292
- isMigrated,
293
- createdAt,
294
- graphResolverAddress: resolverResponse.address || resolverAddress
295
- };
296
296
  Object.keys(wantedRecords).forEach((key) => {
297
297
  const data = wantedRecords[key];
298
298
  if (typeof data === "boolean" && data) {
@@ -306,8 +306,7 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress)
306
306
  return {
307
307
  ...returnedRecords,
308
308
  isMigrated,
309
- createdAt,
310
- graphResolverAddress: resolverResponse.address || resolverAddress
309
+ createdAt
311
310
  };
312
311
  };
313
312
  const getProfileFromName = async ({
@@ -319,7 +318,7 @@ const getProfileFromName = async ({
319
318
  resolverMulticallWrapper,
320
319
  multicallWrapper
321
320
  }, name, options) => {
322
- const { resolverAddress, ..._options } = options || {};
321
+ const { resolverAddress, fallback, ..._options } = options || {};
323
322
  const optsLength = Object.keys(_options).length;
324
323
  let usingOptions;
325
324
  if (!optsLength || _options?.texts === true || _options?.coinTypes === true) {
@@ -334,32 +333,57 @@ const getProfileFromName = async ({
334
333
  usingOptions,
335
334
  resolverAddress
336
335
  );
337
- if (!graphResult)
338
- return;
339
- const {
340
- isMigrated,
341
- createdAt,
342
- graphResolverAddress,
343
- ...wantedRecords
344
- } = graphResult;
345
- if (!graphResolverAddress && !options?.resolverAddress)
346
- return { isMigrated, createdAt, message: "Name doesn't have a resolver" };
347
- const result = await getDataForName(
348
- {
349
- contracts,
350
- _getAddr,
351
- _getContentHash,
352
- _getText,
353
- resolverMulticallWrapper,
354
- multicallWrapper
355
- },
356
- name,
357
- usingOptions ? wantedRecords : options,
358
- graphResolverAddress,
359
- options?.resolverAddress
360
- );
361
- if (!result)
362
- return { isMigrated, createdAt, message: "Records fetch didn't complete" };
336
+ let isMigrated = null;
337
+ let createdAt = null;
338
+ let result = null;
339
+ if (!graphResult) {
340
+ if (!fallback)
341
+ return;
342
+ result = await getDataForName(
343
+ {
344
+ contracts,
345
+ _getAddr,
346
+ _getContentHash,
347
+ _getText,
348
+ resolverMulticallWrapper,
349
+ multicallWrapper
350
+ },
351
+ name,
352
+ fallback,
353
+ void 0
354
+ );
355
+ } else {
356
+ const {
357
+ isMigrated: _isMigrated,
358
+ createdAt: _createdAt,
359
+ ...wantedRecords
360
+ } = graphResult;
361
+ isMigrated = _isMigrated;
362
+ createdAt = _createdAt;
363
+ let recordsWithFallback = usingOptions ? wantedRecords : _options;
364
+ if ((Object.keys(recordsWithFallback).length === 0 || !recordsWithFallback.coinTypes && !recordsWithFallback.texts && Object.keys(recordsWithFallback.contentHash || {}).length === 0) && fallback) {
365
+ recordsWithFallback = fallback;
366
+ }
367
+ result = await getDataForName(
368
+ {
369
+ contracts,
370
+ _getAddr,
371
+ _getContentHash,
372
+ _getText,
373
+ resolverMulticallWrapper,
374
+ multicallWrapper
375
+ },
376
+ name,
377
+ recordsWithFallback,
378
+ options?.resolverAddress
379
+ );
380
+ }
381
+ if (!result?.resolverAddress)
382
+ return {
383
+ isMigrated,
384
+ createdAt,
385
+ message: !result ? "Records fetch didn't complete" : "Name doesn't have a resolver"
386
+ };
363
387
  return { ...result, isMigrated, createdAt, message: void 0 };
364
388
  };
365
389
  const getProfileFromAddress = async ({
@@ -404,6 +428,12 @@ const getProfileFromAddress = async ({
404
428
  message: void 0
405
429
  };
406
430
  };
431
+ const mapCoinTypes = (coin) => {
432
+ if (!Number.isNaN(parseInt(coin))) {
433
+ return coin;
434
+ }
435
+ return `${import_address_encoder.formatsByName[coin.toUpperCase()].coinType}`;
436
+ };
407
437
  async function getProfile_default({
408
438
  contracts,
409
439
  gqlInstance,
@@ -414,13 +444,13 @@ async function getProfile_default({
414
444
  resolverMulticallWrapper,
415
445
  multicallWrapper
416
446
  }, nameOrAddress, options) {
417
- if (options && options.coinTypes && typeof options.coinTypes !== "boolean") {
418
- options.coinTypes = options.coinTypes.map((coin) => {
419
- if (!Number.isNaN(parseInt(coin))) {
420
- return coin;
421
- }
422
- return `${import_address_encoder.formatsByName[coin.toUpperCase()].coinType}`;
423
- });
447
+ if (options) {
448
+ if (options.coinTypes && typeof options.coinTypes !== "boolean") {
449
+ options.coinTypes = options.coinTypes.map(mapCoinTypes);
450
+ }
451
+ if (options.fallback && options.fallback.coinTypes) {
452
+ options.fallback.coinTypes = options.fallback.coinTypes.map(mapCoinTypes);
453
+ }
424
454
  }
425
455
  const inputType = (0, import_validation.parseInputType)(nameOrAddress);
426
456
  if (inputType.type === "unknown" || inputType.info === "unsupported") {
@@ -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,
@@ -598,6 +598,19 @@ const _abi = [
598
598
  stateMutability: "view",
599
599
  type: "function"
600
600
  },
601
+ {
602
+ inputs: [],
603
+ name: "name",
604
+ outputs: [
605
+ {
606
+ internalType: "string",
607
+ name: "",
608
+ type: "string"
609
+ }
610
+ ],
611
+ stateMutability: "view",
612
+ type: "function"
613
+ },
601
614
  {
602
615
  inputs: [
603
616
  {