@snapshot-labs/snapshot.js 0.14.4 → 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 +16 -11
- package/dist/snapshot.esm.js +16 -11
- package/dist/snapshot.min.js +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/utils.ts +16 -12
package/dist/src/utils.d.ts
CHANGED
|
@@ -31,7 +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
|
|
34
|
+
export declare function getUDNameOwner(id: string, network: string): Promise<string>;
|
|
35
35
|
export declare function getSpaceController(id: string, network?: string, options?: any): Promise<string>;
|
|
36
36
|
export declare function clone(item: any): any;
|
|
37
37
|
export declare function sleep(time: any): Promise<unknown>;
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -43,14 +43,17 @@ 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
|
|
47
|
-
'
|
|
46
|
+
const UD_MAPPING = {
|
|
47
|
+
'146': {
|
|
48
|
+
tlds: ['.sonic'],
|
|
49
|
+
registryContract: '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const UD_REGISTRY_ABI = [
|
|
53
|
+
'function ownerOf(uint256 tokenId) view returns (address owner)'
|
|
48
54
|
];
|
|
49
|
-
const SONIC_CONTRACT_ADDRESS = '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4';
|
|
50
55
|
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
51
56
|
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
52
|
-
const SONIC_CHAIN_IDS = ['146'];
|
|
53
|
-
const SONIC_TLD = '.sonic';
|
|
54
57
|
const SHIBARIUM_TLD = '.shib';
|
|
55
58
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
56
59
|
|
|
@@ -701,23 +704,24 @@ export async function getShibariumNameOwner(
|
|
|
701
704
|
return data.result;
|
|
702
705
|
}
|
|
703
706
|
|
|
704
|
-
export async function
|
|
707
|
+
export async function getUDNameOwner(
|
|
705
708
|
id: string,
|
|
706
709
|
network: string
|
|
707
710
|
): Promise<string> {
|
|
708
|
-
|
|
711
|
+
const tlds = UD_MAPPING[network]?.tlds || [];
|
|
712
|
+
if (!tlds.some((tld: string) => id.endsWith(tld))) {
|
|
709
713
|
return Promise.resolve(EMPTY_ADDRESS);
|
|
710
714
|
}
|
|
711
715
|
|
|
712
716
|
try {
|
|
713
717
|
const hash = namehash(ensNormalize(id));
|
|
714
|
-
const tokenId = BigInt(hash)
|
|
718
|
+
const tokenId = BigInt(hash);
|
|
715
719
|
const provider = getProvider(network);
|
|
716
720
|
|
|
717
721
|
return await call(
|
|
718
722
|
provider,
|
|
719
|
-
|
|
720
|
-
[
|
|
723
|
+
UD_REGISTRY_ABI,
|
|
724
|
+
[UD_MAPPING[network].registryContract, 'ownerOf', [tokenId]],
|
|
721
725
|
{
|
|
722
726
|
blockTag: 'latest'
|
|
723
727
|
}
|
|
@@ -736,8 +740,8 @@ export async function getSpaceController(
|
|
|
736
740
|
return getEnsSpaceController(id, network, options);
|
|
737
741
|
} else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
738
742
|
return getShibariumNameOwner(id, network);
|
|
739
|
-
} else if (
|
|
740
|
-
return
|
|
743
|
+
} else if (UD_MAPPING[String(network)]) {
|
|
744
|
+
return getUDNameOwner(id, network);
|
|
741
745
|
}
|
|
742
746
|
|
|
743
747
|
throw new Error(`Network not supported: ${network}`);
|