@snapshot-labs/snapshot.js 0.14.2 → 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 +54 -7
- package/dist/snapshot.esm.js +54 -7
- package/dist/snapshot.min.js +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/networks.json +26 -6
- package/src/utils/provider.ts +1 -1
- package/src/utils.ts +40 -3
package/dist/src/utils.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare function getEnsTextRecord(ens: string, record: string, network?:
|
|
|
31
31
|
export declare function getSpaceUri(id: string, network?: string, options?: any): Promise<string | null>;
|
|
32
32
|
export declare function getEnsOwner(ens: string, network?: string, options?: any): Promise<string>;
|
|
33
33
|
export declare function getShibariumNameOwner(id: string, network: string): Promise<string>;
|
|
34
|
+
export declare function getSonicNameOwner(id: string, network: string): Promise<string>;
|
|
34
35
|
export declare function getSpaceController(id: string, network?: string, options?: any): Promise<string>;
|
|
35
36
|
export declare function clone(item: any): any;
|
|
36
37
|
export declare function sleep(time: any): Promise<unknown>;
|
package/package.json
CHANGED
package/src/networks.json
CHANGED
|
@@ -518,6 +518,20 @@
|
|
|
518
518
|
"start": 13960096,
|
|
519
519
|
"logo": "ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"
|
|
520
520
|
},
|
|
521
|
+
"291": {
|
|
522
|
+
"key": "291",
|
|
523
|
+
"name": "Orderly",
|
|
524
|
+
"shortName": "mainnet",
|
|
525
|
+
"chainId": 291,
|
|
526
|
+
"network": "mainnet",
|
|
527
|
+
"multicall": "0x73e524d811263a145026113219F13f9133966b6b",
|
|
528
|
+
"rpc": [],
|
|
529
|
+
"explorer": {
|
|
530
|
+
"url": "https://explorer.orderly.network"
|
|
531
|
+
},
|
|
532
|
+
"start": 22457562,
|
|
533
|
+
"logo": "ipfs://bafkreibo62xtgkpam6nm34mau26gn65jlw6npb5odw4ylcd6dkwocea5ni"
|
|
534
|
+
},
|
|
521
535
|
"296": {
|
|
522
536
|
"key": "296",
|
|
523
537
|
"name": "Hedera Testnet",
|
|
@@ -1972,34 +1986,40 @@
|
|
|
1972
1986
|
"logo": "ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"
|
|
1973
1987
|
},
|
|
1974
1988
|
"0x534e5f4d41494e": {
|
|
1975
|
-
"key": "
|
|
1989
|
+
"key": "0x534e5f4d41494e",
|
|
1976
1990
|
"name": "Starknet",
|
|
1977
1991
|
"shortName": "Starknet",
|
|
1978
1992
|
"chainId": "0x534e5f4d41494e",
|
|
1979
1993
|
"network": "mainnet",
|
|
1980
1994
|
"starknet": true,
|
|
1995
|
+
"broviderId": "sn",
|
|
1981
1996
|
"multicall": "0x05754af3760f3356da99aea5c3ec39ccac7783d925a19666ebbeca58ff0087f4",
|
|
1982
1997
|
"explorer": {
|
|
1983
1998
|
"url": "https://starkscan.co"
|
|
1984
1999
|
},
|
|
1985
|
-
"rpc": [
|
|
2000
|
+
"rpc": [
|
|
2001
|
+
"https://starknet-mainnet.public.blastapi.io"
|
|
2002
|
+
],
|
|
1986
2003
|
"start": 8446,
|
|
1987
2004
|
"logo": "ipfs://bafkreihbjafyh7eud7r6e5743esaamifcttsvbspfwcrfoc5ykodjdi67m"
|
|
1988
2005
|
},
|
|
1989
2006
|
"0x534e5f5345504f4c4941": {
|
|
1990
|
-
"key": "
|
|
1991
|
-
"name": "Starknet
|
|
2007
|
+
"key": "0x534e5f5345504f4c4941",
|
|
2008
|
+
"name": "Starknet Sepolia",
|
|
1992
2009
|
"shortName": "testnet",
|
|
1993
2010
|
"chainId": "0x534e5f5345504f4c4941",
|
|
1994
2011
|
"network": "testnet",
|
|
1995
2012
|
"starknet": true,
|
|
2013
|
+
"broviderId": "sn-sep",
|
|
1996
2014
|
"testnet": true,
|
|
1997
2015
|
"multicall": "0x05754af3760f3356da99aea5c3ec39ccac7783d925a19666ebbeca58ff0087f4",
|
|
1998
2016
|
"explorer": {
|
|
1999
2017
|
"url": "https://sepolia.starkscan.co"
|
|
2000
2018
|
},
|
|
2001
|
-
"rpc": [
|
|
2019
|
+
"rpc": [
|
|
2020
|
+
"https://starknet-sepolia.public.blastapi.io"
|
|
2021
|
+
],
|
|
2002
2022
|
"start": 7,
|
|
2003
2023
|
"logo": "ipfs://bafkreihbjafyh7eud7r6e5743esaamifcttsvbspfwcrfoc5ykodjdi67m"
|
|
2004
2024
|
}
|
|
2005
|
-
}
|
|
2025
|
+
}
|
package/src/utils/provider.ts
CHANGED
|
@@ -38,7 +38,7 @@ function getBroviderNetworkId(network: string | number): string {
|
|
|
38
38
|
if (!config) {
|
|
39
39
|
throw new Error(`Network '${network}' is not supported`);
|
|
40
40
|
}
|
|
41
|
-
return String(
|
|
41
|
+
return config.broviderId || String(network);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function getProviderType(network: string | number): ProviderType {
|
package/src/utils.ts
CHANGED
|
@@ -43,6 +43,15 @@ const ENS_ABI = [
|
|
|
43
43
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
44
44
|
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
|
|
45
45
|
];
|
|
46
|
+
const SONIC_ABI = [
|
|
47
|
+
'function ownerOf(uint256 tokenId) external view returns (address address)'
|
|
48
|
+
];
|
|
49
|
+
const SONIC_CONTRACT_ADDRESS = '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4';
|
|
50
|
+
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
51
|
+
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
52
|
+
const SONIC_CHAIN_IDS = ['146'];
|
|
53
|
+
const SONIC_TLD = '.sonic';
|
|
54
|
+
const SHIBARIUM_TLD = '.shib';
|
|
46
55
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
47
56
|
|
|
48
57
|
const scoreApiHeaders = {
|
|
@@ -672,7 +681,7 @@ export async function getShibariumNameOwner(
|
|
|
672
681
|
id: string,
|
|
673
682
|
network: string
|
|
674
683
|
): Promise<string> {
|
|
675
|
-
if (!id.endsWith(
|
|
684
|
+
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
676
685
|
return EMPTY_ADDRESS;
|
|
677
686
|
}
|
|
678
687
|
|
|
@@ -692,15 +701,43 @@ export async function getShibariumNameOwner(
|
|
|
692
701
|
return data.result;
|
|
693
702
|
}
|
|
694
703
|
|
|
704
|
+
export async function getSonicNameOwner(
|
|
705
|
+
id: string,
|
|
706
|
+
network: string
|
|
707
|
+
): Promise<string> {
|
|
708
|
+
if (!id.endsWith(SONIC_TLD)) {
|
|
709
|
+
return Promise.resolve(EMPTY_ADDRESS);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
try {
|
|
713
|
+
const hash = namehash(ensNormalize(id));
|
|
714
|
+
const tokenId = BigInt(hash).toString();
|
|
715
|
+
const provider = getProvider(network);
|
|
716
|
+
|
|
717
|
+
return await call(
|
|
718
|
+
provider,
|
|
719
|
+
SONIC_ABI,
|
|
720
|
+
[SONIC_CONTRACT_ADDRESS, 'ownerOf', [tokenId]],
|
|
721
|
+
{
|
|
722
|
+
blockTag: 'latest'
|
|
723
|
+
}
|
|
724
|
+
);
|
|
725
|
+
} catch (e: any) {
|
|
726
|
+
return EMPTY_ADDRESS;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
695
730
|
export async function getSpaceController(
|
|
696
731
|
id: string,
|
|
697
732
|
network = '1',
|
|
698
733
|
options: any = {}
|
|
699
734
|
): Promise<string> {
|
|
700
|
-
if (
|
|
735
|
+
if (ENS_CHAIN_IDS.includes(network)) {
|
|
701
736
|
return getEnsSpaceController(id, network, options);
|
|
702
|
-
} else if (
|
|
737
|
+
} else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
703
738
|
return getShibariumNameOwner(id, network);
|
|
739
|
+
} else if (SONIC_CHAIN_IDS.includes(network)) {
|
|
740
|
+
return getSonicNameOwner(id, network);
|
|
704
741
|
}
|
|
705
742
|
|
|
706
743
|
throw new Error(`Network not supported: ${network}`);
|