@snapshot-labs/snapshot.js 0.14.3 → 0.14.4
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 +48 -3
- package/dist/snapshot.esm.js +48 -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 +40 -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,15 @@ 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 SONIC_ABI = [
|
|
3474
|
+
'function ownerOf(uint256 tokenId) external view returns (address address)'
|
|
3475
|
+
];
|
|
3476
|
+
const SONIC_CONTRACT_ADDRESS = '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4';
|
|
3477
|
+
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
3478
|
+
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
3479
|
+
const SONIC_CHAIN_IDS = ['146'];
|
|
3480
|
+
const SONIC_TLD = '.sonic';
|
|
3481
|
+
const SHIBARIUM_TLD = '.shib';
|
|
3458
3482
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
3459
3483
|
const scoreApiHeaders = {
|
|
3460
3484
|
Accept: 'application/json',
|
|
@@ -3957,7 +3981,7 @@ function getEnsSpaceController(id_1, network_1) {
|
|
|
3957
3981
|
}
|
|
3958
3982
|
function getShibariumNameOwner(id, network) {
|
|
3959
3983
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3960
|
-
if (!id.endsWith(
|
|
3984
|
+
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
3961
3985
|
return EMPTY_ADDRESS;
|
|
3962
3986
|
}
|
|
3963
3987
|
const response = yield fetch__default['default']('https://stamp.fyi', {
|
|
@@ -3975,14 +3999,35 @@ function getShibariumNameOwner(id, network) {
|
|
|
3975
3999
|
return data.result;
|
|
3976
4000
|
});
|
|
3977
4001
|
}
|
|
4002
|
+
function getSonicNameOwner(id, network) {
|
|
4003
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4004
|
+
if (!id.endsWith(SONIC_TLD)) {
|
|
4005
|
+
return Promise.resolve(EMPTY_ADDRESS);
|
|
4006
|
+
}
|
|
4007
|
+
try {
|
|
4008
|
+
const hash$1 = hash.namehash(hash.ensNormalize(id));
|
|
4009
|
+
const tokenId = BigInt(hash$1).toString();
|
|
4010
|
+
const provider = getProvider(network);
|
|
4011
|
+
return yield call(provider, SONIC_ABI, [SONIC_CONTRACT_ADDRESS, 'ownerOf', [tokenId]], {
|
|
4012
|
+
blockTag: 'latest'
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
4015
|
+
catch (e) {
|
|
4016
|
+
return EMPTY_ADDRESS;
|
|
4017
|
+
}
|
|
4018
|
+
});
|
|
4019
|
+
}
|
|
3978
4020
|
function getSpaceController(id_1) {
|
|
3979
4021
|
return __awaiter(this, arguments, void 0, function* (id, network = '1', options = {}) {
|
|
3980
|
-
if (
|
|
4022
|
+
if (ENS_CHAIN_IDS.includes(network)) {
|
|
3981
4023
|
return getEnsSpaceController(id, network, options);
|
|
3982
4024
|
}
|
|
3983
|
-
else if (
|
|
4025
|
+
else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
3984
4026
|
return getShibariumNameOwner(id, network);
|
|
3985
4027
|
}
|
|
4028
|
+
else if (SONIC_CHAIN_IDS.includes(network)) {
|
|
4029
|
+
return getSonicNameOwner(id, network);
|
|
4030
|
+
}
|
|
3986
4031
|
throw new Error(`Network not supported: ${network}`);
|
|
3987
4032
|
});
|
|
3988
4033
|
}
|
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,15 @@ 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 SONIC_ABI = [
|
|
3464
|
+
'function ownerOf(uint256 tokenId) external view returns (address address)'
|
|
3465
|
+
];
|
|
3466
|
+
const SONIC_CONTRACT_ADDRESS = '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4';
|
|
3467
|
+
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
3468
|
+
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
3469
|
+
const SONIC_CHAIN_IDS = ['146'];
|
|
3470
|
+
const SONIC_TLD = '.sonic';
|
|
3471
|
+
const SHIBARIUM_TLD = '.shib';
|
|
3448
3472
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
3449
3473
|
const scoreApiHeaders = {
|
|
3450
3474
|
Accept: 'application/json',
|
|
@@ -3947,7 +3971,7 @@ function getEnsSpaceController(id_1, network_1) {
|
|
|
3947
3971
|
}
|
|
3948
3972
|
function getShibariumNameOwner(id, network) {
|
|
3949
3973
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3950
|
-
if (!id.endsWith(
|
|
3974
|
+
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
3951
3975
|
return EMPTY_ADDRESS;
|
|
3952
3976
|
}
|
|
3953
3977
|
const response = yield fetch('https://stamp.fyi', {
|
|
@@ -3965,14 +3989,35 @@ function getShibariumNameOwner(id, network) {
|
|
|
3965
3989
|
return data.result;
|
|
3966
3990
|
});
|
|
3967
3991
|
}
|
|
3992
|
+
function getSonicNameOwner(id, network) {
|
|
3993
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3994
|
+
if (!id.endsWith(SONIC_TLD)) {
|
|
3995
|
+
return Promise.resolve(EMPTY_ADDRESS);
|
|
3996
|
+
}
|
|
3997
|
+
try {
|
|
3998
|
+
const hash = namehash(ensNormalize(id));
|
|
3999
|
+
const tokenId = BigInt(hash).toString();
|
|
4000
|
+
const provider = getProvider(network);
|
|
4001
|
+
return yield call(provider, SONIC_ABI, [SONIC_CONTRACT_ADDRESS, 'ownerOf', [tokenId]], {
|
|
4002
|
+
blockTag: 'latest'
|
|
4003
|
+
});
|
|
4004
|
+
}
|
|
4005
|
+
catch (e) {
|
|
4006
|
+
return EMPTY_ADDRESS;
|
|
4007
|
+
}
|
|
4008
|
+
});
|
|
4009
|
+
}
|
|
3968
4010
|
function getSpaceController(id_1) {
|
|
3969
4011
|
return __awaiter(this, arguments, void 0, function* (id, network = '1', options = {}) {
|
|
3970
|
-
if (
|
|
4012
|
+
if (ENS_CHAIN_IDS.includes(network)) {
|
|
3971
4013
|
return getEnsSpaceController(id, network, options);
|
|
3972
4014
|
}
|
|
3973
|
-
else if (
|
|
4015
|
+
else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
3974
4016
|
return getShibariumNameOwner(id, network);
|
|
3975
4017
|
}
|
|
4018
|
+
else if (SONIC_CHAIN_IDS.includes(network)) {
|
|
4019
|
+
return getSonicNameOwner(id, network);
|
|
4020
|
+
}
|
|
3976
4021
|
throw new Error(`Network not supported: ${network}`);
|
|
3977
4022
|
});
|
|
3978
4023
|
}
|