diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-04-19 03:22:02 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-04-19 08:12:38 +0800 |
commit | 51b2fce8c13c8e9393558d34dd664b7dd7749941 (patch) | |
tree | 94d623b55fac4d7b2f1a24e9ad413b065b4676e5 /packages/website/ts/components/wallet | |
parent | 39c0064ffb73b8cb0b0b350e13bd7afec69e7e7e (diff) | |
download | dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.gz dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.bz2 dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.lz dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.xz dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.zst dexon-0x-contracts-51b2fce8c13c8e9393558d34dd664b7dd7749941.zip |
Implement backendClient object to unify calls to the portal api
Diffstat (limited to 'packages/website/ts/components/wallet')
-rw-r--r-- | packages/website/ts/components/wallet/wallet.tsx | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx index 8c9e3be0f..d1ae38550 100644 --- a/packages/website/ts/components/wallet/wallet.tsx +++ b/packages/website/ts/components/wallet/wallet.tsx @@ -36,7 +36,7 @@ import { TokenState, TokenStateByAddress, } from 'ts/types'; -import { configs } from 'ts/utils/configs'; +import { backendClient } from 'ts/utils/backend_client'; import { constants } from 'ts/utils/constants'; import { utils } from 'ts/utils/utils'; import { styles as walletItemStyles } from 'ts/utils/wallet_item_styles'; @@ -72,11 +72,6 @@ interface AccessoryItemConfig { allowanceToggleConfig?: AllowanceToggleConfig; } -interface WebsiteBackendPriceInfo { - price: string; - address: string; -} - const styles: Styles = { root: { width: 346, @@ -496,17 +491,15 @@ export class Wallet extends React.Component<WalletProps, WalletState> { if (_.isEmpty(tokenAddresses)) { return {}; } - const tokenAddressesQueryString = tokenAddresses.join(','); - const endpoint = `${configs.BACKEND_BASE_URL}/prices?tokens=${tokenAddressesQueryString}`; - const response = await fetch(endpoint); - if (response.status !== 200) { + try { + const websiteBackendPriceInfos = await backendClient.getPriceInfosAsync(tokenAddresses); + const addresses = _.map(websiteBackendPriceInfos, info => info.address); + const prices = _.map(websiteBackendPriceInfos, info => new BigNumber(info.price)); + const pricesByAddress = _.zipObject(addresses, prices); + return pricesByAddress; + } catch (err) { return {}; } - const websiteBackendPriceInfos: WebsiteBackendPriceInfo[] = await response.json(); - const addresses = _.map(websiteBackendPriceInfos, info => info.address); - const prices = _.map(websiteBackendPriceInfos, info => new BigNumber(info.price)); - const pricesByAddress = _.zipObject(addresses, prices); - return pricesByAddress; } private _openWrappedEtherActionRow(wrappedEtherDirection: Side) { this.setState({ |