Skip to content

Commit

Permalink
Merge pull request #102 from zkLinkProtocol/feat/open_withdraw
Browse files Browse the repository at this point in the history
update balance after withdraw
  • Loading branch information
leochw authored Apr 13, 2024
2 parents 73805eb + b388faf commit f71d809
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions store/zksync/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ export const useZkSyncWalletStore = defineStore("zkSyncWallet", () => {
return [...knownTokens, ...otherTokens];
});

const balanceRef = reactive(balance);

const deductBalance = (tokenAddress: string, amount: BigNumberish) => {
if (!balance.value) return;
const tokenBalance = balance.value.find((balance) => balance.address === tokenAddress);
const tokenBalance = balanceRef.value.find((balance) => balance.address === tokenAddress);
if (!tokenBalance) return;
const newBalance = BigNumber.from(tokenBalance.amount).sub(amount);
tokenBalance.amount = newBalance.isNegative() ? "0" : newBalance.toString();
Expand Down Expand Up @@ -219,7 +221,7 @@ export const useZkSyncWalletStore = defineStore("zkSyncWallet", () => {
getL1VoidSigner,
getPrimaryL1VoidSigner,

balance,
balance: balanceRef,
balanceInProgress: computed(() => balanceInProgress.value),
balanceError: computed(() => balanceError.value),
requestBalance,
Expand Down
1 change: 0 additions & 1 deletion views/transactions/Withdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,6 @@ const makeTransaction = async () => {
query: { network: eraNetwork.value.key },
}).href
);
walletStore.requestBalance({ force: true }).catch(() => undefined); //refresh balances
waitForCompletion(transactionInfo.value)
.then(async (completedTransaction) => {
transactionInfo.value = completedTransaction;
Expand Down

0 comments on commit f71d809

Please sign in to comment.