@snapshot-labs/snapshot.js 0.12.54 → 0.12.56
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/snapshot.cjs.js +85 -4
- package/dist/snapshot.esm.js +85 -4
- package/dist/snapshot.min.js +1 -1
- package/dist/src/utils.d.ts +2 -2
- package/package.json +1 -1
- package/src/networks.json +17 -2
- package/src/utils.spec.js +9 -1
- package/src/utils.ts +78 -4
package/dist/snapshot.cjs.js
CHANGED
|
@@ -3207,7 +3207,7 @@ var networks = {
|
|
|
3207
3207
|
rpc: [
|
|
3208
3208
|
],
|
|
3209
3209
|
explorer: {
|
|
3210
|
-
url: "https://
|
|
3210
|
+
url: "https://curtis.apescan.io"
|
|
3211
3211
|
},
|
|
3212
3212
|
start: 6661339,
|
|
3213
3213
|
logo: "ipfs://bafkreicljxttjq2xkgfwwpii5xegirgq2ctrnsjnzelxudjj33qzq65apu",
|
|
@@ -3223,7 +3223,7 @@ var networks = {
|
|
|
3223
3223
|
rpc: [
|
|
3224
3224
|
],
|
|
3225
3225
|
explorer: {
|
|
3226
|
-
url: "https://
|
|
3226
|
+
url: "https://apescan.io"
|
|
3227
3227
|
},
|
|
3228
3228
|
start: 20889,
|
|
3229
3229
|
logo: "ipfs://bafkreielbgcox2jsw3g6pqulqb7pyjgx7czjt6ahnibihaij6lozoy53w4"
|
|
@@ -3471,6 +3471,22 @@ var networks = {
|
|
|
3471
3471
|
start: 1059647,
|
|
3472
3472
|
logo: "ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",
|
|
3473
3473
|
testnet: true
|
|
3474
|
+
},
|
|
3475
|
+
"314159": {
|
|
3476
|
+
key: "314159",
|
|
3477
|
+
name: "Filecoin Calibration Testnet",
|
|
3478
|
+
shortName: "testnet",
|
|
3479
|
+
chainId: 314159,
|
|
3480
|
+
network: "testnet",
|
|
3481
|
+
multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
3482
|
+
rpc: [
|
|
3483
|
+
],
|
|
3484
|
+
explorer: {
|
|
3485
|
+
url: "https://calibration.filscan.io/en"
|
|
3486
|
+
},
|
|
3487
|
+
start: 1446201,
|
|
3488
|
+
logo: "ipfs://bafkreiffbopdjior7li3nlemzko7rjua6wd2hfh2vhdbenqbv4tfsbnzwu",
|
|
3489
|
+
testnet: true
|
|
3474
3490
|
},
|
|
3475
3491
|
"686868": {
|
|
3476
3492
|
key: "686868",
|
|
@@ -4292,6 +4308,13 @@ function fetchData(_a) {
|
|
|
4292
4308
|
});
|
|
4293
4309
|
}
|
|
4294
4310
|
|
|
4311
|
+
const MUTED_ERRORS = [
|
|
4312
|
+
// mute error from coinbase, when the subdomain is not found
|
|
4313
|
+
// most other resolvers just return an empty address
|
|
4314
|
+
'response not found during CCIP fetch',
|
|
4315
|
+
// mute error from missing offchain resolver (mostly for sepolia)
|
|
4316
|
+
'UNSUPPORTED_OPERATION'
|
|
4317
|
+
];
|
|
4295
4318
|
const ENS_REGISTRY = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e';
|
|
4296
4319
|
const ENS_ABI = [
|
|
4297
4320
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
@@ -4466,6 +4489,41 @@ ajv.addFormat('domain', {
|
|
|
4466
4489
|
return !!value.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(\/)?$/);
|
|
4467
4490
|
}
|
|
4468
4491
|
});
|
|
4492
|
+
function getDomainType(domain) {
|
|
4493
|
+
const isEns = domain.endsWith('.eth');
|
|
4494
|
+
const tokens = domain.split('.');
|
|
4495
|
+
if (tokens.length === 1)
|
|
4496
|
+
return 'tld';
|
|
4497
|
+
else if (tokens.length === 2 && !isEns)
|
|
4498
|
+
return 'other-tld';
|
|
4499
|
+
else if (tokens.length > 2)
|
|
4500
|
+
return 'subdomain';
|
|
4501
|
+
else if (isEns)
|
|
4502
|
+
return 'ens';
|
|
4503
|
+
else
|
|
4504
|
+
throw new Error('Invalid domain');
|
|
4505
|
+
}
|
|
4506
|
+
// see https://docs.ens.domains/registry/dns#gasless-import
|
|
4507
|
+
function getDNSOwner(domain) {
|
|
4508
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4509
|
+
var _a;
|
|
4510
|
+
const response = yield fetch__default['default'](`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
4511
|
+
headers: {
|
|
4512
|
+
accept: 'application/dns-json'
|
|
4513
|
+
}
|
|
4514
|
+
});
|
|
4515
|
+
const data = yield response.json();
|
|
4516
|
+
// Error list: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
|
|
4517
|
+
if (data.Status === 3)
|
|
4518
|
+
return EMPTY_ADDRESS;
|
|
4519
|
+
if (data.Status !== 0)
|
|
4520
|
+
throw new Error('Failed to fetch DNS Owner');
|
|
4521
|
+
const ownerRecord = (_a = data.Answer) === null || _a === void 0 ? void 0 : _a.find((record) => record.data.includes('ENS1'));
|
|
4522
|
+
if (!ownerRecord)
|
|
4523
|
+
return EMPTY_ADDRESS;
|
|
4524
|
+
return address.getAddress(ownerRecord.data.replace(new RegExp('"', 'g'), '').split(' ').pop());
|
|
4525
|
+
});
|
|
4526
|
+
}
|
|
4469
4527
|
function call(provider, abi, call, options) {
|
|
4470
4528
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4471
4529
|
const contract = new contracts.Contract(call[0], abi, provider);
|
|
@@ -4757,6 +4815,11 @@ function getSpaceUri(id_1) {
|
|
|
4757
4815
|
}
|
|
4758
4816
|
function getEnsOwner(ens_1) {
|
|
4759
4817
|
return __awaiter(this, arguments, void 0, function* (ens, network = '1', options = {}) {
|
|
4818
|
+
var _a, _b;
|
|
4819
|
+
if (!((_b = (_a = networks[network]) === null || _a === void 0 ? void 0 : _a.ensResolvers) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
4820
|
+
throw new Error('Network not supported');
|
|
4821
|
+
}
|
|
4822
|
+
const domainType = getDomainType(ens);
|
|
4760
4823
|
const provider = getProvider(network, options);
|
|
4761
4824
|
const ensRegistry = new contracts.Contract(ENS_REGISTRY, ['function owner(bytes32) view returns (address)'], provider);
|
|
4762
4825
|
let ensHash;
|
|
@@ -4764,7 +4827,7 @@ function getEnsOwner(ens_1) {
|
|
|
4764
4827
|
ensHash = hash.namehash(hash.ensNormalize(ens));
|
|
4765
4828
|
}
|
|
4766
4829
|
catch (e) {
|
|
4767
|
-
return
|
|
4830
|
+
return EMPTY_ADDRESS;
|
|
4768
4831
|
}
|
|
4769
4832
|
const ensNameWrapper = options.ensNameWrapper || networks[network].ensNameWrapper;
|
|
4770
4833
|
let owner = yield ensRegistry.owner(ensHash);
|
|
@@ -4773,7 +4836,25 @@ function getEnsOwner(ens_1) {
|
|
|
4773
4836
|
const ensNameWrapperContract = new contracts.Contract(ensNameWrapper, ['function ownerOf(uint256) view returns (address)'], provider);
|
|
4774
4837
|
owner = yield ensNameWrapperContract.ownerOf(ensHash);
|
|
4775
4838
|
}
|
|
4776
|
-
|
|
4839
|
+
if (owner === EMPTY_ADDRESS && domainType === 'other-tld') {
|
|
4840
|
+
const resolvedAddress = yield provider.resolveName(ens);
|
|
4841
|
+
// Filter out domains with valid TXT records, but not imported
|
|
4842
|
+
if (resolvedAddress) {
|
|
4843
|
+
owner = yield getDNSOwner(ens);
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
if (owner === EMPTY_ADDRESS && domainType === 'subdomain') {
|
|
4847
|
+
try {
|
|
4848
|
+
owner = yield provider.resolveName(ens);
|
|
4849
|
+
}
|
|
4850
|
+
catch (e) {
|
|
4851
|
+
if (MUTED_ERRORS.every((error) => !e.message.includes(error))) {
|
|
4852
|
+
throw e;
|
|
4853
|
+
}
|
|
4854
|
+
owner = EMPTY_ADDRESS;
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
return owner || EMPTY_ADDRESS;
|
|
4777
4858
|
});
|
|
4778
4859
|
}
|
|
4779
4860
|
function getSpaceController(id_1) {
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -3197,7 +3197,7 @@ var networks = {
|
|
|
3197
3197
|
rpc: [
|
|
3198
3198
|
],
|
|
3199
3199
|
explorer: {
|
|
3200
|
-
url: "https://
|
|
3200
|
+
url: "https://curtis.apescan.io"
|
|
3201
3201
|
},
|
|
3202
3202
|
start: 6661339,
|
|
3203
3203
|
logo: "ipfs://bafkreicljxttjq2xkgfwwpii5xegirgq2ctrnsjnzelxudjj33qzq65apu",
|
|
@@ -3213,7 +3213,7 @@ var networks = {
|
|
|
3213
3213
|
rpc: [
|
|
3214
3214
|
],
|
|
3215
3215
|
explorer: {
|
|
3216
|
-
url: "https://
|
|
3216
|
+
url: "https://apescan.io"
|
|
3217
3217
|
},
|
|
3218
3218
|
start: 20889,
|
|
3219
3219
|
logo: "ipfs://bafkreielbgcox2jsw3g6pqulqb7pyjgx7czjt6ahnibihaij6lozoy53w4"
|
|
@@ -3461,6 +3461,22 @@ var networks = {
|
|
|
3461
3461
|
start: 1059647,
|
|
3462
3462
|
logo: "ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",
|
|
3463
3463
|
testnet: true
|
|
3464
|
+
},
|
|
3465
|
+
"314159": {
|
|
3466
|
+
key: "314159",
|
|
3467
|
+
name: "Filecoin Calibration Testnet",
|
|
3468
|
+
shortName: "testnet",
|
|
3469
|
+
chainId: 314159,
|
|
3470
|
+
network: "testnet",
|
|
3471
|
+
multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
3472
|
+
rpc: [
|
|
3473
|
+
],
|
|
3474
|
+
explorer: {
|
|
3475
|
+
url: "https://calibration.filscan.io/en"
|
|
3476
|
+
},
|
|
3477
|
+
start: 1446201,
|
|
3478
|
+
logo: "ipfs://bafkreiffbopdjior7li3nlemzko7rjua6wd2hfh2vhdbenqbv4tfsbnzwu",
|
|
3479
|
+
testnet: true
|
|
3464
3480
|
},
|
|
3465
3481
|
"686868": {
|
|
3466
3482
|
key: "686868",
|
|
@@ -4282,6 +4298,13 @@ function fetchData(_a) {
|
|
|
4282
4298
|
});
|
|
4283
4299
|
}
|
|
4284
4300
|
|
|
4301
|
+
const MUTED_ERRORS = [
|
|
4302
|
+
// mute error from coinbase, when the subdomain is not found
|
|
4303
|
+
// most other resolvers just return an empty address
|
|
4304
|
+
'response not found during CCIP fetch',
|
|
4305
|
+
// mute error from missing offchain resolver (mostly for sepolia)
|
|
4306
|
+
'UNSUPPORTED_OPERATION'
|
|
4307
|
+
];
|
|
4285
4308
|
const ENS_REGISTRY = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e';
|
|
4286
4309
|
const ENS_ABI = [
|
|
4287
4310
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
@@ -4456,6 +4479,41 @@ ajv.addFormat('domain', {
|
|
|
4456
4479
|
return !!value.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(\/)?$/);
|
|
4457
4480
|
}
|
|
4458
4481
|
});
|
|
4482
|
+
function getDomainType(domain) {
|
|
4483
|
+
const isEns = domain.endsWith('.eth');
|
|
4484
|
+
const tokens = domain.split('.');
|
|
4485
|
+
if (tokens.length === 1)
|
|
4486
|
+
return 'tld';
|
|
4487
|
+
else if (tokens.length === 2 && !isEns)
|
|
4488
|
+
return 'other-tld';
|
|
4489
|
+
else if (tokens.length > 2)
|
|
4490
|
+
return 'subdomain';
|
|
4491
|
+
else if (isEns)
|
|
4492
|
+
return 'ens';
|
|
4493
|
+
else
|
|
4494
|
+
throw new Error('Invalid domain');
|
|
4495
|
+
}
|
|
4496
|
+
// see https://docs.ens.domains/registry/dns#gasless-import
|
|
4497
|
+
function getDNSOwner(domain) {
|
|
4498
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4499
|
+
var _a;
|
|
4500
|
+
const response = yield fetch(`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
4501
|
+
headers: {
|
|
4502
|
+
accept: 'application/dns-json'
|
|
4503
|
+
}
|
|
4504
|
+
});
|
|
4505
|
+
const data = yield response.json();
|
|
4506
|
+
// Error list: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
|
|
4507
|
+
if (data.Status === 3)
|
|
4508
|
+
return EMPTY_ADDRESS;
|
|
4509
|
+
if (data.Status !== 0)
|
|
4510
|
+
throw new Error('Failed to fetch DNS Owner');
|
|
4511
|
+
const ownerRecord = (_a = data.Answer) === null || _a === void 0 ? void 0 : _a.find((record) => record.data.includes('ENS1'));
|
|
4512
|
+
if (!ownerRecord)
|
|
4513
|
+
return EMPTY_ADDRESS;
|
|
4514
|
+
return getAddress(ownerRecord.data.replace(new RegExp('"', 'g'), '').split(' ').pop());
|
|
4515
|
+
});
|
|
4516
|
+
}
|
|
4459
4517
|
function call(provider, abi, call, options) {
|
|
4460
4518
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4461
4519
|
const contract = new Contract$1(call[0], abi, provider);
|
|
@@ -4747,6 +4805,11 @@ function getSpaceUri(id_1) {
|
|
|
4747
4805
|
}
|
|
4748
4806
|
function getEnsOwner(ens_1) {
|
|
4749
4807
|
return __awaiter(this, arguments, void 0, function* (ens, network = '1', options = {}) {
|
|
4808
|
+
var _a, _b;
|
|
4809
|
+
if (!((_b = (_a = networks[network]) === null || _a === void 0 ? void 0 : _a.ensResolvers) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
4810
|
+
throw new Error('Network not supported');
|
|
4811
|
+
}
|
|
4812
|
+
const domainType = getDomainType(ens);
|
|
4750
4813
|
const provider = getProvider(network, options);
|
|
4751
4814
|
const ensRegistry = new Contract$1(ENS_REGISTRY, ['function owner(bytes32) view returns (address)'], provider);
|
|
4752
4815
|
let ensHash;
|
|
@@ -4754,7 +4817,7 @@ function getEnsOwner(ens_1) {
|
|
|
4754
4817
|
ensHash = namehash(ensNormalize(ens));
|
|
4755
4818
|
}
|
|
4756
4819
|
catch (e) {
|
|
4757
|
-
return
|
|
4820
|
+
return EMPTY_ADDRESS;
|
|
4758
4821
|
}
|
|
4759
4822
|
const ensNameWrapper = options.ensNameWrapper || networks[network].ensNameWrapper;
|
|
4760
4823
|
let owner = yield ensRegistry.owner(ensHash);
|
|
@@ -4763,7 +4826,25 @@ function getEnsOwner(ens_1) {
|
|
|
4763
4826
|
const ensNameWrapperContract = new Contract$1(ensNameWrapper, ['function ownerOf(uint256) view returns (address)'], provider);
|
|
4764
4827
|
owner = yield ensNameWrapperContract.ownerOf(ensHash);
|
|
4765
4828
|
}
|
|
4766
|
-
|
|
4829
|
+
if (owner === EMPTY_ADDRESS && domainType === 'other-tld') {
|
|
4830
|
+
const resolvedAddress = yield provider.resolveName(ens);
|
|
4831
|
+
// Filter out domains with valid TXT records, but not imported
|
|
4832
|
+
if (resolvedAddress) {
|
|
4833
|
+
owner = yield getDNSOwner(ens);
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
if (owner === EMPTY_ADDRESS && domainType === 'subdomain') {
|
|
4837
|
+
try {
|
|
4838
|
+
owner = yield provider.resolveName(ens);
|
|
4839
|
+
}
|
|
4840
|
+
catch (e) {
|
|
4841
|
+
if (MUTED_ERRORS.every((error) => !e.message.includes(error))) {
|
|
4842
|
+
throw e;
|
|
4843
|
+
}
|
|
4844
|
+
owner = EMPTY_ADDRESS;
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
return owner || EMPTY_ADDRESS;
|
|
4767
4848
|
});
|
|
4768
4849
|
}
|
|
4769
4850
|
function getSpaceController(id_1) {
|