@@ -3,25 +3,10 @@ import { uint256, num } from 'starknet';
3
3
import { CallData } from 'starknet' ;
4
4
import { utils as helpers } from './utils.js' ;
5
5
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'
25
10
} ;
26
11
27
12
/**
@@ -54,7 +39,7 @@ export async function getETHBalance(
54
39
const formattedAddress = parseStarknetAddress ( address ) ;
55
40
56
41
// 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 ;
58
43
const ethContract = getContract ( contractAddress , provider , network ) ;
59
44
60
45
// Get the class hash to fetch the ABI
@@ -90,7 +75,7 @@ export async function getSTRKBalance(
90
75
const formattedAddress = parseStarknetAddress ( address ) ;
91
76
92
77
// 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 ;
94
79
const strkContract = getContract ( contractAddress , provider , network ) ;
95
80
96
81
// Get the class hash to fetch the ABI
@@ -161,7 +146,7 @@ export async function getERC20Balance(
161
146
}
162
147
} > {
163
148
// 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 ( ) ) {
165
150
const balance = await getETHBalance ( ownerAddress , network ) ;
166
151
return {
167
152
raw : balance . wei ,
@@ -171,7 +156,7 @@ export async function getERC20Balance(
171
156
decimals : 18
172
157
}
173
158
} ;
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 ( ) ) {
175
160
const balance = await getSTRKBalance ( ownerAddress , network ) ;
176
161
return {
177
162
raw : balance . wei ,
0 commit comments