@@ -3,25 +3,10 @@ import { uint256, num } from 'starknet';
33import { CallData } from 'starknet' ;
44import { utils as helpers } from './utils.js' ;
55
6- // Token contract addresses by network
7- type NetworkAddresses = {
8- [ key : string ] : string ;
9- } ;
10-
11- const TOKEN_ADDRESSES : {
12- ETH : NetworkAddresses ;
13- STRK : NetworkAddresses ;
14- } = {
15- // ETH contract addresses
16- ETH : {
17- mainnet : '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' ,
18- sepolia : '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7'
19- } ,
20- // STRK contract addresses
21- STRK : {
22- mainnet : '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d' ,
23- sepolia : '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d'
24- }
6+ // Token contract addresses (same for all networks)
7+ const TOKEN_ADDRESSES = {
8+ ETH : '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' ,
9+ STRK : '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d'
2510} ;
2611
2712/**
@@ -54,7 +39,7 @@ export async function getETHBalance(
5439 const formattedAddress = parseStarknetAddress ( address ) ;
5540
5641 // ETH is managed by the ETH contract
57- const contractAddress = TOKEN_ADDRESSES . ETH [ network as keyof typeof TOKEN_ADDRESSES . ETH ] || TOKEN_ADDRESSES . ETH . mainnet ;
42+ const contractAddress = TOKEN_ADDRESSES . ETH ;
5843 const ethContract = getContract ( contractAddress , provider , network ) ;
5944
6045 // Get the class hash to fetch the ABI
@@ -90,7 +75,7 @@ export async function getSTRKBalance(
9075 const formattedAddress = parseStarknetAddress ( address ) ;
9176
9277 // STRK token contract
93- const contractAddress = TOKEN_ADDRESSES . STRK [ network as keyof typeof TOKEN_ADDRESSES . STRK ] || TOKEN_ADDRESSES . STRK . mainnet ;
78+ const contractAddress = TOKEN_ADDRESSES . STRK ;
9479 const strkContract = getContract ( contractAddress , provider , network ) ;
9580
9681 // Get the class hash to fetch the ABI
@@ -161,7 +146,7 @@ export async function getERC20Balance(
161146 }
162147} > {
163148 // Check if this is a native token request
164- if ( tokenAddress . toLowerCase ( ) === TOKEN_ADDRESSES . ETH [ network as keyof typeof TOKEN_ADDRESSES . ETH ] . toLowerCase ( ) ) {
149+ if ( tokenAddress . toLowerCase ( ) === TOKEN_ADDRESSES . ETH . toLowerCase ( ) ) {
165150 const balance = await getETHBalance ( ownerAddress , network ) ;
166151 return {
167152 raw : balance . wei ,
@@ -171,7 +156,7 @@ export async function getERC20Balance(
171156 decimals : 18
172157 }
173158 } ;
174- } else if ( tokenAddress . toLowerCase ( ) === TOKEN_ADDRESSES . STRK [ network as keyof typeof TOKEN_ADDRESSES . STRK ] . toLowerCase ( ) ) {
159+ } else if ( tokenAddress . toLowerCase ( ) === TOKEN_ADDRESSES . STRK . toLowerCase ( ) ) {
175160 const balance = await getSTRKBalance ( ownerAddress , network ) ;
176161 return {
177162 raw : balance . wei ,
0 commit comments