aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-11-10 06:20:06 +0800
committerFabio Berger <me@fabioberger.com>2018-11-10 06:20:06 +0800
commit773cf3cd143769a93cea66b30d46cb9f4620b74d (patch)
tree549d12546b0076d5e69d1a4570ca7a42b628c5c1 /packages/instant/src/util
parent53d0f5b98ebd132d51b1fdf463fe57481c895ec4 (diff)
parentb4a11de097258d37fa9271e64fc28a1d012a8d26 (diff)
downloaddexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.tar
dexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.tar.gz
dexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.tar.bz2
dexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.tar.lz
dexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.tar.xz
dexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.tar.zst
dexon-0x-contracts-773cf3cd143769a93cea66b30d46cb9f4620b74d.zip
Merge branch 'development' into fixOrderValidation
* development: (25 commits) Publish Updated CHANGELOGS fix(instant): fix bug where we potentially fetch balance for the wrong account fix: Lock Ledger hw-transport to 4.24.0 fix: wrong prop names used chore: PR feedback fix: broken features because of merge fix: remove default props, fix lint problems chore: convert payment method to stateless component feat: add boxShadow on dropdown hover fix: various style issues fix: remove all:initial rule from all div based ui compoennts fix: token selector scrolling container height chore(instant): fix lint errors feat(instant): fetch balance at startup feat(instant): fetch account address at startup and drive account state changes chore: cleanup fix: restore button to previous state feat: implement copy-to-clipboard feat: add MetaMask sign, refactor Circle ...
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/balance.ts13
-rw-r--r--packages/instant/src/util/etherscan.ts7
-rw-r--r--packages/instant/src/util/format.ts3
-rw-r--r--packages/instant/src/util/provider_state_factory.ts10
4 files changed, 12 insertions, 21 deletions
diff --git a/packages/instant/src/util/balance.ts b/packages/instant/src/util/balance.ts
deleted file mode 100644
index f2271495b..000000000
--- a/packages/instant/src/util/balance.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { BuyQuote } from '@0x/asset-buyer';
-import { Web3Wrapper } from '@0x/web3-wrapper';
-import * as _ from 'lodash';
-
-export const balanceUtil = {
- hasSufficientEth: async (takerAddress: string | undefined, buyQuote: BuyQuote, web3Wrapper: Web3Wrapper) => {
- if (_.isUndefined(takerAddress)) {
- return false;
- }
- const balanceWei = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
- return balanceWei.gte(buyQuote.worstCaseQuoteInfo.totalEthAmount);
- },
-};
diff --git a/packages/instant/src/util/etherscan.ts b/packages/instant/src/util/etherscan.ts
index cfc2578a3..4d62c4d9f 100644
--- a/packages/instant/src/util/etherscan.ts
+++ b/packages/instant/src/util/etherscan.ts
@@ -21,4 +21,11 @@ export const etherscanUtil = {
}
return `https://${prefix}etherscan.io/tx/${txHash}`;
},
+ getEtherScanEthAddressIfExists: (ethAddress: string, networkId: number) => {
+ const prefix = etherscanPrefix(networkId);
+ if (_.isUndefined(prefix)) {
+ return;
+ }
+ return `https://${prefix}etherscan.io/address/${ethAddress}`;
+ },
};
diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts
index 4a48dec9d..44661d697 100644
--- a/packages/instant/src/util/format.ts
+++ b/packages/instant/src/util/format.ts
@@ -50,4 +50,7 @@ export const format = {
}
return `$${ethUnitAmount.mul(ethUsdPrice).toFixed(decimalPlaces)}`;
},
+ ethAddress: (address: string): string => {
+ return `0x${address.slice(2, 7)}…${address.slice(-5)}`;
+ },
};
diff --git a/packages/instant/src/util/provider_state_factory.ts b/packages/instant/src/util/provider_state_factory.ts
index 18b188d89..3281f6bfb 100644
--- a/packages/instant/src/util/provider_state_factory.ts
+++ b/packages/instant/src/util/provider_state_factory.ts
@@ -2,18 +2,12 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { AccountNotReady, AccountState, Maybe, Network, OrderSource, ProviderState } from '../types';
+import { LOADING_ACCOUNT, NO_ACCOUNT } from '../constants';
+import { Maybe, Network, OrderSource, ProviderState } from '../types';
import { assetBuyerFactory } from './asset_buyer_factory';
import { providerFactory } from './provider_factory';
-const LOADING_ACCOUNT: AccountNotReady = {
- state: AccountState.Loading,
-};
-const NO_ACCOUNT: AccountNotReady = {
- state: AccountState.None,
-};
-
export const providerStateFactory = {
getInitialProviderState: (orderSource: OrderSource, network: Network, provider?: Provider): ProviderState => {
if (!_.isUndefined(provider)) {