@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/snapshot.cjs.js
CHANGED
|
@@ -3470,14 +3470,17 @@ const ENS_ABI = [
|
|
|
3470
3470
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
3471
3471
|
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
|
|
3472
3472
|
];
|
|
3473
|
-
const
|
|
3474
|
-
'
|
|
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)'
|
|
3475
3481
|
];
|
|
3476
|
-
const SONIC_CONTRACT_ADDRESS = '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4';
|
|
3477
3482
|
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
3478
3483
|
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
3479
|
-
const SONIC_CHAIN_IDS = ['146'];
|
|
3480
|
-
const SONIC_TLD = '.sonic';
|
|
3481
3484
|
const SHIBARIUM_TLD = '.shib';
|
|
3482
3485
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
3483
3486
|
const scoreApiHeaders = {
|
|
@@ -3999,16 +4002,18 @@ function getShibariumNameOwner(id, network) {
|
|
|
3999
4002
|
return data.result;
|
|
4000
4003
|
});
|
|
4001
4004
|
}
|
|
4002
|
-
function
|
|
4005
|
+
function getUDNameOwner(id, network) {
|
|
4003
4006
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4004
|
-
|
|
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))) {
|
|
4005
4010
|
return Promise.resolve(EMPTY_ADDRESS);
|
|
4006
4011
|
}
|
|
4007
4012
|
try {
|
|
4008
4013
|
const hash$1 = hash.namehash(hash.ensNormalize(id));
|
|
4009
|
-
const tokenId = BigInt(hash$1)
|
|
4014
|
+
const tokenId = BigInt(hash$1);
|
|
4010
4015
|
const provider = getProvider(network);
|
|
4011
|
-
return yield call(provider,
|
|
4016
|
+
return yield call(provider, UD_REGISTRY_ABI, [UD_MAPPING[network].registryContract, 'ownerOf', [tokenId]], {
|
|
4012
4017
|
blockTag: 'latest'
|
|
4013
4018
|
});
|
|
4014
4019
|
}
|
|
@@ -4025,8 +4030,8 @@ function getSpaceController(id_1) {
|
|
|
4025
4030
|
else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
4026
4031
|
return getShibariumNameOwner(id, network);
|
|
4027
4032
|
}
|
|
4028
|
-
else if (
|
|
4029
|
-
return
|
|
4033
|
+
else if (UD_MAPPING[String(network)]) {
|
|
4034
|
+
return getUDNameOwner(id, network);
|
|
4030
4035
|
}
|
|
4031
4036
|
throw new Error(`Network not supported: ${network}`);
|
|
4032
4037
|
});
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -3460,14 +3460,17 @@ const ENS_ABI = [
|
|
|
3460
3460
|
'function text(bytes32 node, string calldata key) external view returns (string memory)',
|
|
3461
3461
|
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
|
|
3462
3462
|
];
|
|
3463
|
-
const
|
|
3464
|
-
'
|
|
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)'
|
|
3465
3471
|
];
|
|
3466
|
-
const SONIC_CONTRACT_ADDRESS = '0xde1dadcf11a7447c3d093e97fdbd513f488ce3b4';
|
|
3467
3472
|
const ENS_CHAIN_IDS = ['1', '11155111'];
|
|
3468
3473
|
const SHIBARIUM_CHAIN_IDS = ['109', '157'];
|
|
3469
|
-
const SONIC_CHAIN_IDS = ['146'];
|
|
3470
|
-
const SONIC_TLD = '.sonic';
|
|
3471
3474
|
const SHIBARIUM_TLD = '.shib';
|
|
3472
3475
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
3473
3476
|
const scoreApiHeaders = {
|
|
@@ -3989,16 +3992,18 @@ function getShibariumNameOwner(id, network) {
|
|
|
3989
3992
|
return data.result;
|
|
3990
3993
|
});
|
|
3991
3994
|
}
|
|
3992
|
-
function
|
|
3995
|
+
function getUDNameOwner(id, network) {
|
|
3993
3996
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3994
|
-
|
|
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))) {
|
|
3995
4000
|
return Promise.resolve(EMPTY_ADDRESS);
|
|
3996
4001
|
}
|
|
3997
4002
|
try {
|
|
3998
4003
|
const hash = namehash(ensNormalize(id));
|
|
3999
|
-
const tokenId = BigInt(hash)
|
|
4004
|
+
const tokenId = BigInt(hash);
|
|
4000
4005
|
const provider = getProvider(network);
|
|
4001
|
-
return yield call(provider,
|
|
4006
|
+
return yield call(provider, UD_REGISTRY_ABI, [UD_MAPPING[network].registryContract, 'ownerOf', [tokenId]], {
|
|
4002
4007
|
blockTag: 'latest'
|
|
4003
4008
|
});
|
|
4004
4009
|
}
|
|
@@ -4015,8 +4020,8 @@ function getSpaceController(id_1) {
|
|
|
4015
4020
|
else if (SHIBARIUM_CHAIN_IDS.includes(network)) {
|
|
4016
4021
|
return getShibariumNameOwner(id, network);
|
|
4017
4022
|
}
|
|
4018
|
-
else if (
|
|
4019
|
-
return
|
|
4023
|
+
else if (UD_MAPPING[String(network)]) {
|
|
4024
|
+
return getUDNameOwner(id, network);
|
|
4020
4025
|
}
|
|
4021
4026
|
throw new Error(`Network not supported: ${network}`);
|
|
4022
4027
|
});
|