Skip to content

Commit 79b051f

Browse files
committed
fix: use networks.json to detect starknet networks
1 parent 4fc7c01 commit 79b051f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/helpers/utils.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import snapshot from '@snapshot-labs/snapshot.js';
2+
import networks from '@snapshot-labs/snapshot.js/src/networks.json';
23

34
export type Block = {
45
number: number;
@@ -17,10 +18,6 @@ interface EthereumBlockResponse {
1718

1819
type BlockResponse = StarknetBlockResponse | EthereumBlockResponse;
1920

20-
const STARKNET_MAINNET_ID = '0x534e5f4d41494e';
21-
const STARKNET_TESTNET_ID = '0x534e5f5345504f4c4941';
22-
const STARKNET_NETWORKS = [STARKNET_MAINNET_ID, STARKNET_TESTNET_ID];
23-
2421
export async function getBlockNumber(
2522
network: string,
2623
blockNum: number | 'latest'
@@ -36,7 +33,7 @@ function interpretResult(network: string, result: BlockResponse | null): Block {
3633
throw new Error(`Invalid block response for network ${network}`);
3734
}
3835

39-
if (STARKNET_NETWORKS.includes(network)) {
36+
if (networks[network].starknet) {
4037
const starknetResult = result as StarknetBlockResponse;
4138
return {
4239
number: starknetResult.block_number,

0 commit comments

Comments
 (0)