diff options
author | Brandon Millman <brandon@0xproject.com> | 2018-06-20 01:44:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 01:44:18 +0800 |
commit | 7dd208fb4990930d9d985b09367b432c1098d19e (patch) | |
tree | e991728f81ab681399da97b406b8cc9225844bc5 /packages/website/ts/utils/utils.ts | |
parent | 2338c7a3b36da7e58edec868cab395d68bfe16d2 (diff) | |
parent | 829bc962095096a2b70516862ebddc40d21ff7ee (diff) | |
download | dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.tar dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.tar.gz dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.tar.bz2 dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.tar.lz dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.tar.xz dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.tar.zst dexon-sol-tools-7dd208fb4990930d9d985b09367b432c1098d19e.zip |
Merge pull request #723 from 0xProject/bug/website/drawer-address
Consolidate account state display message 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 |