aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-06-19 07:55:52 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-06-19 08:08:44 +0800
commitf97e605bf6769a17d0352219f5fb1133f7cb2430 (patch)
tree102f382273c38facd8ba8448b6cbfba2329623b4 /packages/website/ts/utils
parent49f5495c459f194f3cab6ff24526da924bd64a53 (diff)
downloaddexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar
dexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.gz
dexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.bz2
dexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.lz
dexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.xz
dexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.tar.zst
dexon-sol-tools-f97e605bf6769a17d0352219f5fb1133f7cb2430.zip
Consolidate account state messaging logic
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/utils.ts19
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