-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch token balances for evm chains (#2380)
* rename L2 to EVM * implement getBalance * check if profileId updated * revert poll interval --------- Co-authored-by: Tuditi <[email protected]>
- Loading branch information
Showing
16 changed files
with
117 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/shared/src/lib/core/layer-2/actions/fetchEvmBalancesForAccount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IAccountState } from '@core/account/interfaces' | ||
import { getEvmNetworks } from '@core/network/stores' | ||
import { ITokenBalance } from '@core/token' | ||
import { setLayer2AccountBalanceForChain } from '@core/layer-2/stores' | ||
import { activeProfileId } from '@core/profile/stores' | ||
import { get } from 'svelte/store' | ||
|
||
export function fetchEvmBalancesForAccount(profileId: string, account: IAccountState): void { | ||
const evmNetworks = getEvmNetworks() | ||
evmNetworks.forEach(async (evmNetwork) => { | ||
try { | ||
const tokenBalance: ITokenBalance = (await evmNetwork.getBalance(account)) ?? {} | ||
|
||
if (get(activeProfileId) === profileId) { | ||
setLayer2AccountBalanceForChain(account.index, evmNetwork.id, tokenBalance) | ||
} | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
}) | ||
} |
70 changes: 0 additions & 70 deletions
70
packages/shared/src/lib/core/layer-2/actions/fetchL2BalanceForAccount.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ayer-2/actions/pollL2BalanceForAccount.ts → ...er-2/actions/pollEvmBalancesForAccount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...r-2/utils/fetchL2BalanceForAllAccounts.ts → ...2/utils/fetchEvmBalancesForAllAccounts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters