diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-06-19 07:55:52 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-06-19 08:08:44 +0800 |
commit | f97e605bf6769a17d0352219f5fb1133f7cb2430 (patch) | |
tree | 102f382273c38facd8ba8448b6cbfba2329623b4 /packages/website/ts/utils/utils.ts | |
parent | 49f5495c459f194f3cab6ff24526da924bd64a53 (diff) | |
download | dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.gz dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.bz2 dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.lz dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.xz dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.zst dexon-0x-contracts-f97e605bf6769a17d0352219f5fb1133f7cb2430.zip |
Consolidate account state messaging logic
Diffstat (limited to 'packages/website/ts/utils/utils.ts')
-rw-r--r-- | packages/website/ts/utils/utils.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 414361c1b..0bd3dbcfa 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -190,6 +190,25 @@ export const utils = { const truncatedAddress = `${address.substring(0, 6)}...${address.substr(-4)}`; // 0x3d5a...b287 return truncatedAddress; }, + getReadableAccountState( + isBlockchainReady: boolean, + providerType: ProviderType, + injectedProviderName: string, + userAddress?: string, + ): string { + const isAddressAvailable = !_.isUndefined(userAddress) && !_.isEmpty(userAddress); + const isExternallyInjectedProvider = utils.isExternallyInjected(providerType, injectedProviderName); + if (!isBlockchainReady) { + return 'Loading account'; + } else if (isAddressAvailable) { + return utils.getAddressBeginAndEnd(userAddress); + // tslint:disable-next-line: prefer-conditional-expression + } else if (isExternallyInjectedProvider) { + return 'Account locked'; + } else { + return 'No wallet detected'; + } + }, hasUniqueNameAndSymbol(tokens: Token[], token: Token): boolean { if (token.isRegistered) { return true; // Since it's registered, it is the canonical token |