aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/utils.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-07-02 17:12:01 +0800
committerFabio Berger <me@fabioberger.com>2018-07-02 17:12:01 +0800
commitde9f0732a09893f035ce8a7e8e01fa1141882a3a (patch)
tree63d1f0bbc6f9d65576e5d12b379378700eb88567 /packages/website/ts/utils/utils.ts
parent20acdbf6c3ba6a62e87a9a496021cb6482c0c03a (diff)
parentb9b00e10d39c3c84bc72892ef37f1313e904414d (diff)
downloaddexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar
dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.gz
dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.bz2
dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.lz
dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.xz
dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.zst
dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.zip
Merge branch 'v2-prototype' into fix/five_decimal_scenario
* v2-prototype: (75 commits) Update relayer grid tiles to use Text Fix build Update file structure Update 2.0.0 artifacts Move ledgerhq module declarations to typescript-typings Export LedgerEthereumClient type in subproviders Update artifacts Add logging and updated artifacts Fix migrations Run prettier Add Kovan artifacts Use ledger subprovider Add Kovan migrations Remove state variable from Link component in Portal Make registerAssetProxy append only Update staging api link Change getTransactionReceipt to awaitTransactionMined Move /docs route to the end Remove extra call to scrollIntoView for wallet in onboarding Update expectRevertReasonOrAlwaysFailingTransactionAsync to check status codes ...
Diffstat (limited to 'packages/website/ts/utils/utils.ts')
-rw-r--r--packages/website/ts/utils/utils.ts27
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index d12ae6a98..726e1815f 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -9,6 +9,7 @@ import deepEqual = require('deep-equal');
import * as _ from 'lodash';
import * as moment from 'moment';
import {
+ AccountState,
BlockchainCallErrs,
BrowserType,
Environments,
@@ -192,23 +193,37 @@ export const utils = {
const truncatedAddress = `${address.substring(0, 6)}...${address.substr(-4)}`; // 0x3d5a...b287
return truncatedAddress;
},
- getReadableAccountState(
+ getReadableAccountState(accountState: AccountState, userAddress: string): string {
+ switch (accountState) {
+ case AccountState.Loading:
+ return 'Loading...';
+ case AccountState.Ready:
+ return utils.getAddressBeginAndEnd(userAddress);
+ case AccountState.Locked:
+ return 'Please Unlock';
+ case AccountState.Disconnected:
+ return 'Connect a Wallet';
+ default:
+ return '';
+ }
+ },
+ getAccountState(
isBlockchainReady: boolean,
providerType: ProviderType,
injectedProviderName: string,
userAddress?: string,
- ): string {
+ ): AccountState {
const isAddressAvailable = !_.isUndefined(userAddress) && !_.isEmpty(userAddress);
const isExternallyInjectedProvider = utils.isExternallyInjected(providerType, injectedProviderName);
if (!isBlockchainReady) {
- return 'Loading account';
+ return AccountState.Loading;
} else if (isAddressAvailable) {
- return utils.getAddressBeginAndEnd(userAddress);
+ return AccountState.Ready;
// tslint:disable-next-line: prefer-conditional-expression
} else if (isExternallyInjectedProvider) {
- return 'Account locked';
+ return AccountState.Locked;
} else {
- return 'No wallet detected';
+ return AccountState.Disconnected;
}
},
hasUniqueNameAndSymbol(tokens: Token[], token: Token): boolean {