aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/utils.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-06-27 08:28:38 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-06-29 02:50:08 +0800
commit1ca182e741fbdff4cd4df5877de18174b83a532b (patch)
tree9b67250d1a3d5a3e1561d8256057aa4169d82b3c /packages/website/ts/utils/utils.ts
parent8419db53bb94354280ed4776540386fc271e4589 (diff)
downloaddexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.tar
dexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.tar.gz
dexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.tar.bz2
dexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.tar.lz
dexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.tar.xz
dexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.tar.zst
dexon-sol-tools-1ca182e741fbdff4cd4df5877de18174b83a532b.zip
Update ProviderDisplay with new design
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..5a180fdca 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.Unconnected:
+ 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.Unconnected;
}
},
hasUniqueNameAndSymbol(tokens: Token[], token: Token): boolean {