Skip to content

Commit 97a229d

Browse files
wa0x6eChaituVR
andauthored
fix: filter out starknet testnet on mainnet (#1071)
* fix: filter out starknet testnet on mainnet * Update package.json --------- Co-authored-by: Chaitanya <[email protected]>
1 parent b0eacfa commit 97a229d

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snapshot-labs/snapshot.js",
3-
"version": "0.12.23",
3+
"version": "0.12.24",
44
"repository": "snapshot-labs/snapshot.js",
55
"license": "MIT",
66
"main": "dist/snapshot.cjs.js",

src/utils.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ const ENS_ABI = [
3636
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
3737
];
3838
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
39-
const STARKNET_NETWORKS = ['0x534e5f4d41494e', '0x534e5f5345504f4c4941'];
39+
const STARKNET_NETWORKS = {
40+
'0x534e5f4d41494e': {
41+
name: 'Starknet',
42+
testnet: false
43+
},
44+
'0x534e5f5345504f4c4941': {
45+
name: 'Starknet Sepolia',
46+
testnet: true
47+
}
48+
};
4049

4150
const scoreApiHeaders = {
4251
Accept: 'application/json',
@@ -170,7 +179,15 @@ ajv.addKeyword({
170179
ajv.addKeyword({
171180
keyword: 'starknetNetwork',
172181
validate: function (schema, data) {
173-
return STARKNET_NETWORKS.includes(data);
182+
// @ts-ignore
183+
const snapshotEnv = this.snapshotEnv || 'default';
184+
if (snapshotEnv === 'mainnet') {
185+
return Object.keys(STARKNET_NETWORKS)
186+
.filter((id) => !STARKNET_NETWORKS[id].testnet)
187+
.includes(data);
188+
}
189+
190+
return Object.keys(STARKNET_NETWORKS).includes(data);
174191
},
175192
error: {
176193
message: 'network not allowed'

test/examples/space.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
"name": "Mainnet Starknet treasury",
5151
"address": "0x05702362b68a350c1cae8f2a529d74fdbb502369ddcebfadac7e91da37636947",
5252
"network": "0x534e5f4d41494e"
53-
},
54-
{
55-
"name": "Sepolia Starknet treasury",
56-
"address": "0x05702362b68a350c1cae8f2a529d74fdbb502369ddcebfadac7e91da37636947",
57-
"network": "0x534e5f5345504f4c4941"
5853
}
5954
],
6055
"labels": [

0 commit comments

Comments
 (0)