diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-06-01 03:00:31 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-06-05 01:27:24 +0800 |
commit | c8421efcd32af9dbe58b433fdb97d009a6d89b84 (patch) | |
tree | 31893e7a08edb731a95928677f455a58c84f383d /packages/website/ts/components/portal/portal.tsx | |
parent | f382609d01ab86da52a746ba24ddd73a1a507aa6 (diff) | |
download | dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.tar dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.tar.gz dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.tar.bz2 dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.tar.lz dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.tar.xz dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.tar.zst dexon-sol-tools-c8421efcd32af9dbe58b433fdb97d009a6d89b84.zip |
Address feedback
Diffstat (limited to 'packages/website/ts/components/portal/portal.tsx')
-rw-r--r-- | packages/website/ts/components/portal/portal.tsx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 15654083f..9aa83546a 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -582,11 +582,15 @@ export class Portal extends React.Component<PortalProps, PortalState> { private async _fetchBalancesAndAllowancesAsync(tokenAddresses: string[]): Promise<void> { const trackedTokenStateByAddress = this.state.trackedTokenStateByAddress; const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress; - for (const tokenAddress of tokenAddresses) { - const [balance, allowance] = await this._blockchain.getTokenBalanceAndAllowanceAsync( - userAddressIfExists, - tokenAddress, - ); + const balancesAndAllowances = await Promise.all( + tokenAddresses.map(async tokenAddress => { + return this._blockchain.getTokenBalanceAndAllowanceAsync(userAddressIfExists, tokenAddress); + }), + ); + for (let i = 0; i < tokenAddresses.length; i++) { + // Order is preserved in Promise.all + const [balance, allowance] = balancesAndAllowances[i]; + const tokenAddress = tokenAddresses[i]; trackedTokenStateByAddress[tokenAddress] = { balance, allowance, |