Open JoaoCampos89 opened 4 years ago
The Converting ETH <--> WETH process does not wait for the transaction to complete, giving to the user the feeling that the transaction is almost instant. How to solve the issue: store/blockchain/actions.ts
export const updateTokenBalances: ThunkCreator<Promise<any>> = (txHash?: string) => { return async (dispatch, getState, { getWeb3Wrapper }) => { const state = getState(); const ethAccount = getEthAccount(state); const knownTokens = getKnownTokens(); const wethToken = knownTokens.getWethToken(); const web3Wrapper = await getWeb3Wrapper(); if (txHash) { const tx = await web3Wrapper.awaitTransactionSuccessAsync(txHash); } const allTokenBalances = await tokensToTokenBalances([...knownTokens.getTokens(), wethToken], ethAccount); const wethBalance = allTokenBalances.find(b => b.token.symbol === wethToken.symbol); const tokenBalances = allTokenBalances.filter(b => b.token.symbol !== wethToken.symbol); dispatch(setTokenBalances(tokenBalances)); const ethBalance = await web3Wrapper.getBalanceInWeiAsync(ethAccount); if (wethBalance) { dispatch(setWethBalance(wethBalance.balance)); } dispatch(setEthBalance(ethBalance)); return ethBalance; }; };
if txhash is passed as argument we wait to the transaction to complete before update token balances
The Converting ETH <--> WETH process does not wait for the transaction to complete, giving to the user the feeling that the transaction is almost instant. How to solve the issue: store/blockchain/actions.ts
if txhash is passed as argument we wait to the transaction to complete before update token balances