@snapshot-labs/snapshot.js 0.14.3 → 0.14.5
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 +53 -3
- package/dist/snapshot.esm.js +53 -3
- package/dist/snapshot.min.js +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/networks.json +21 -3
- package/src/utils.ts +44 -3
package/dist/snapshot.cjs.js
CHANGED
|
@@ -857,6 +857,21 @@ var networks = {
|
|
|
857
857
|
},
|
|
858
858
|
start: 13960096,
|
|
859
859
|
logo: "ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"
|
|
860
|
+
},
|
|
861
|
+
"291": {
|
|
862
|
+
key: "291",
|
|
863
|
+
name: "Orderly",
|
|
864
|
+
shortName: "mainnet",
|
|
865
|
+
chainId: 291,
|
|
866
|
+
network: "mainnet",
|
|
867
|
+
multicall: "0x73e524d811263a145026113219F13f9133966b6b",
|
|
868
|
+
rpc: [
|
|
869
|
+
],
|
|
870
|
+
explorer: {
|
|
871
|
+
url: "https://explorer.orderly.network"
|
|
872
|
+
},
|
|
873
|
+
start: 22457562,
|
|
874
|
+
logo: "ipfs://bafkreibo62xtgkpam6nm34mau26gn65jlw6npb5odw4ylcd6dkwocea5ni"
|
|
860
875
|
},
|
|
861
876
|
"296": {
|
|
862
877
|
key: "296",
|
|
@@ -3455,6 +3470,18 @@ const ENS_ABI = [
|
|
|
3455
3470
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
3456
3471
|
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
|
|
3457
3472
|
];
|
|
3473
|
+
const UD_MAPPING = {
|
|
3474
|
+
'146': {
|
|
3475
|
+
tlds: ['.sonic'],
|
|
3476
|
+
registryContract: '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4'
|
|
3477
|
+
}
|
|
3478
|
+
};
|
|
3479
|
+
const UD_REGISTRY_ABI = [
|
|
3480
|
+
'function ownerOf(uint256 tokenId) view returns (address owner)'
|
|
3481
|
+
];
|
|
3482
|
+
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
3483
|
+
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
3484
|
+
const SHIBARIUM_TLD = '.shib';
|
|
3458
3485
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
3459
3486
|
const scoreApiHeaders = {
|
|
3460
3487
|
Accept: 'application/json',
|
|
@@ -3957,7 +3984,7 @@ function getEnsSpaceController(id_1, network_1) {
|
|
|
3957
3984
|
}
|
|
3958
3985
|
function getShibariumNameOwner(id, network) {
|
|
3959
3986
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3960
|
-
if (!id.endsWith(
|
|
3987
|
+
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
3961
3988
|
return EMPTY_ADDRESS;
|
|
3962
3989
|
}
|
|
3963
3990
|
const response = yield fetch__default['default']('https://stamp.fyi', {
|
|
@@ -3975,14 +4002,37 @@ function getShibariumNameOwner(id, network) {
|
|
|
3975
4002
|
return data.result;
|
|
3976
4003
|
});
|
|
3977
4004
|
}
|
|
4005
|
+
function getUDNameOwner(id, network) {
|
|
4006
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4007
|
+
var _a;
|
|
4008
|
+
const tlds = ((_a = UD_MAPPING[network]) === null || _a === void 0 ? void 0 : _a.tlds) || [];
|
|
4009
|
+
if (!tlds.some((tld) => id.endsWith(tld))) {
|
|
4010
|
+
return Promise.resolve(EMPTY_ADDRESS);
|
|
4011
|
+
}
|
|
4012
|
+
try {
|
|
4013
|
+
const hash$1 = hash.namehash(hash.ensNormalize(id));
|
|
4014
|
+
const tokenId = BigInt(hash$1);
|
|
4015
|
+
const provider = getProvider(network);
|
|
4016
|
+
return yield call(provider, UD_REGISTRY_ABI, [UD_MAPPING[network].registryContract, 'ownerOf', [tokenId]], {
|
|
4017
|
+
blockTag: 'latest'
|
|
4018
|
+
});
|
|
4019
|
+
}
|
|
4020
|
+
catch (e) {
|
|
4021
|
+
return EMPTY_ADDRESS;
|
|
4022
|
+
}
|
|
4023
|
+
});
|
|
4024
|
+
}
|
|
3978
4025
|
function getSpaceController(id_1) {
|
|
3979
4026
|
return __awaiter(this, arguments, void 0, function* (id, network = '1', options = {}) {
|
|
3980
|
-
if (
|
|
4027
|
+
if (ENS_CHAIN_IDS.includes(network)) {
|
|
3981
4028
|
return getEnsSpaceController(id, network, options);
|
|
3982
4029
|
}
|
|
3983
|
-
else if (
|
|
4030
|
+
else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
3984
4031
|
return getShibariumNameOwner(id, network);
|
|
3985
4032
|
}
|
|
4033
|
+
else if (UD_MAPPING[String(network)]) {
|
|
4034
|
+
return getUDNameOwner(id, network);
|
|
4035
|
+
}
|
|
3986
4036
|
throw new Error(`Network not supported: ${network}`);
|
|
3987
4037
|
});
|
|
3988
4038
|
}
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -847,6 +847,21 @@ var networks = {
|
|
|
847
847
|
},
|
|
848
848
|
start: 13960096,
|
|
849
849
|
logo: "ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"
|
|
850
|
+
},
|
|
851
|
+
"291": {
|
|
852
|
+
key: "291",
|
|
853
|
+
name: "Orderly",
|
|
854
|
+
shortName: "mainnet",
|
|
855
|
+
chainId: 291,
|
|
856
|
+
network: "mainnet",
|
|
857
|
+
multicall: "0x73e524d811263a145026113219F13f9133966b6b",
|
|
858
|
+
rpc: [
|
|
859
|
+
],
|
|
860
|
+
explorer: {
|
|
861
|
+
url: "https://explorer.orderly.network"
|
|
862
|
+
},
|
|
863
|
+
start: 22457562,
|
|
864
|
+
logo: "ipfs://bafkreibo62xtgkpam6nm34mau26gn65jlw6npb5odw4ylcd6dkwocea5ni"
|
|
850
865
|
},
|
|
851
866
|
"296": {
|
|
852
867
|
key: "296",
|
|
@@ -3445,6 +3460,18 @@ const ENS_ABI = [
|
|
|
3445
3460
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
3446
3461
|
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
|
|
3447
3462
|
];
|
|
3463
|
+
const UD_MAPPING = {
|
|
3464
|
+
'146': {
|
|
3465
|
+
tlds: ['.sonic'],
|
|
3466
|
+
registryContract: '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4'
|
|
3467
|
+
}
|
|
3468
|
+
};
|
|
3469
|
+
const UD_REGISTRY_ABI = [
|
|
3470
|
+
'function ownerOf(uint256 tokenId) view returns (address owner)'
|
|
3471
|
+
];
|
|
3472
|
+
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
3473
|
+
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
3474
|
+
const SHIBARIUM_TLD = '.shib';
|
|
3448
3475
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
3449
3476
|
const scoreApiHeaders = {
|
|
3450
3477
|
Accept: 'application/json',
|
|
@@ -3947,7 +3974,7 @@ function getEnsSpaceController(id_1, network_1) {
|
|
|
3947
3974
|
}
|
|
3948
3975
|
function getShibariumNameOwner(id, network) {
|
|
3949
3976
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3950
|
-
if (!id.endsWith(
|
|
3977
|
+
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
3951
3978
|
return EMPTY_ADDRESS;
|
|
3952
3979
|
}
|
|
3953
3980
|
const response = yield fetch('https://stamp.fyi', {
|
|
@@ -3965,14 +3992,37 @@ function getShibariumNameOwner(id, network) {
|
|
|
3965
3992
|
return data.result;
|
|
3966
3993
|
});
|
|
3967
3994
|
}
|
|
3995
|
+
function getUDNameOwner(id, network) {
|
|
3996
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3997
|
+
var _a;
|
|
3998
|
+
const tlds = ((_a = UD_MAPPING[network]) === null || _a === void 0 ? void 0 : _a.tlds) || [];
|
|
3999
|
+
if (!tlds.some((tld) => id.endsWith(tld))) {
|
|
4000
|
+
return Promise.resolve(EMPTY_ADDRESS);
|
|
4001
|
+
}
|
|
4002
|
+
try {
|
|
4003
|
+
const hash = namehash(ensNormalize(id));
|
|
4004
|
+
const tokenId = BigInt(hash);
|
|
4005
|
+
const provider = getProvider(network);
|
|
4006
|
+
return yield call(provider, UD_REGISTRY_ABI, [UD_MAPPING[network].registryContract, 'ownerOf', [tokenId]], {
|
|
4007
|
+
blockTag: 'latest'
|
|
4008
|
+
});
|
|
4009
|
+
}
|
|
4010
|
+
catch (e) {
|
|
4011
|
+
return EMPTY_ADDRESS;
|
|
4012
|
+
}
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
3968
4015
|
function getSpaceController(id_1) {
|
|
3969
4016
|
return __awaiter(this, arguments, void 0, function* (id, network = '1', options = {}) {
|
|
3970
|
-
if (
|
|
4017
|
+
if (ENS_CHAIN_IDS.includes(network)) {
|
|
3971
4018
|
return getEnsSpaceController(id, network, options);
|
|
3972
4019
|
}
|
|
3973
|
-
else if (
|
|
4020
|
+
else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
3974
4021
|
return getShibariumNameOwner(id, network);
|
|
3975
4022
|
}
|
|
4023
|
+
else if (UD_MAPPING[String(network)]) {
|
|
4024
|
+
return getUDNameOwner(id, network);
|
|
4025
|
+
}
|
|
3976
4026
|
throw new Error(`Network not supported: ${network}`);
|
|
3977
4027
|
});
|
|
3978
4028
|
}
|