Skip to content

Commit

Permalink
fix: auto l1 balances recognition on sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 committed Jun 5, 2024
1 parent 87928fa commit f6313b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions store/ethereumBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ export const useEthereumBalanceStore = defineStore("ethereumBalance", () => {
if (!portalRuntimeConfig.ankrToken) throw new Error("Ankr token is not available");

const ankrProvider = new AnkrProvider(`https://rpc.ankr.com/multichain/${portalRuntimeConfig.ankrToken}`);
const networkIdToAnkr = new Map<number, AnkrSupportedChains>([[l1Networks.mainnet.id, "eth"]]);
const networkIdToAnkr = new Map<number, AnkrSupportedChains | "eth_sepolia">([
[l1Networks.mainnet.id, "eth"],
[l1Networks.sepolia.id, "eth_sepolia"],
]);
if (!networkIdToAnkr.has(eraNetwork.value.l1Network.id)) {
throw new Error(`Ankr does not support ${eraNetwork.value.l1Network.name}`);
}
const balances = await ankrProvider.getAccountBalance({
blockchain: [networkIdToAnkr.get(eraNetwork.value.l1Network.id)!],
blockchain: [networkIdToAnkr.get(eraNetwork.value.l1Network.id)!] as AnkrSupportedChains[],
walletAddress: account.value.address,
onlyWhitelisted: false,
});
Expand Down
5 changes: 4 additions & 1 deletion store/zksync/ethereumBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const useZkSyncEthereumBalanceStore = defineStore("zkSyncEthereumBalances
async () => {
if (!l1Network.value) throw new Error(`L1 network is not available on ${selectedNetwork.value.name}`);

if (([l1Networks.mainnet.id] as number[]).includes(l1Network.value?.id) && portalRuntimeConfig.ankrToken) {
if (
([l1Networks.mainnet.id, l1Networks.sepolia.id] as number[]).includes(l1Network.value?.id) &&
portalRuntimeConfig.ankrToken
) {
return await getBalancesFromApi();
} else {
return await getBalancesFromRPC();
Expand Down

0 comments on commit f6313b0

Please sign in to comment.