From 233eb06c2bc9f0e767edceebe2d03f8bd8b648fd Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Wed, 4 May 2022 14:33:47 +1000 Subject: [PATCH 1/3] use account-view, but show that the account isn't on this chain Signed-off-by: Sven Dowideit --- src/renderer/components/AccountView.tsx | 48 +++++++++++++++---------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/renderer/components/AccountView.tsx b/src/renderer/components/AccountView.tsx index 137ab784..c082181c 100644 --- a/src/renderer/components/AccountView.tsx +++ b/src/renderer/components/AccountView.tsx @@ -61,10 +61,9 @@ function AccountView(props: { pubKey: string | undefined }) { } }, 666); - if (!account) { - return <>No account selected; - } - const humanName = getHumanName(account); + const humanName = account + ? getHumanName(account) + : 'No on-chain account selected'; return ( @@ -94,7 +93,11 @@ function AccountView(props: { pubKey: string | undefined }) { - + {account ? ( + + ) : ( + 'No' + )} @@ -103,7 +106,9 @@ function AccountView(props: { pubKey: string | undefined }) { SOL - {truncateLamportAmount(account)} + + {account ? truncateLamportAmount(account) : 0} + @@ -111,7 +116,7 @@ function AccountView(props: { pubKey: string | undefined }) { Executable - {account.accountInfo.executable ? ( + {account?.accountInfo.executable ? (
- - analytics('clickExplorerLink', { net }) - } - href={explorerURL(net, account.accountId.toString())} - target="_blank" - className="sol-link" - rel="noreferrer" - > - Link - + {account ? ( + + analytics('clickExplorerLink', { net }) + } + href={explorerURL( + net, + account.accountId.toString() + )} + target="_blank" + className="sol-link" + rel="noreferrer" + > + Link + + ) : ( + 'No onchain account' + )} From a7d92398a6d5e930e52ca0b92b13329fc1a6286b Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Thu, 5 May 2022 09:20:53 +1000 Subject: [PATCH 2/3] use logger, not console Signed-off-by: Sven Dowideit --- src/main/anchor.ts | 3 ++- src/main/main.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/anchor.ts b/src/main/anchor.ts index abefe4d6..f34d9168 100644 --- a/src/main/anchor.ts +++ b/src/main/anchor.ts @@ -1,5 +1,6 @@ import { FetchAnchorIDLRequest } from '../types/types'; import { execAsync, RESOURCES_PATH } from './const'; +import { logger } from './logger'; const fetchAnchorIdl = async (msg: FetchAnchorIDLRequest) => { // Anchor doesn't seem to accept a flag for where Anchor.toml is (???) @@ -11,7 +12,7 @@ const fetchAnchorIdl = async (msg: FetchAnchorIDLRequest) => { process.chdir(cwd); return JSON.parse(stdout); } catch (error) { - console.log(error); + logger.error(error); return { error, }; diff --git a/src/main/main.ts b/src/main/main.ts index dd7b871c..c78a0242 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -56,7 +56,7 @@ ipcMain.on( break; case 'fetch-anchor-idl': res = await fetchAnchorIdl(msg); - console.log(`fetchIDL(${msg}: (${res})`); + logger.debug(`fetchIDL(${msg}: (${res})`); break; // case 'update-account-name': // await updateAccountName(msg); From 867fb3a1f8a68a86cb691e4a77d7ee589bff425d Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Thu, 5 May 2022 09:28:42 +1000 Subject: [PATCH 3/3] show the selected pubkey when its not onchain Signed-off-by: Sven Dowideit --- src/renderer/components/AccountView.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/renderer/components/AccountView.tsx b/src/renderer/components/AccountView.tsx index c082181c..facd5cd1 100644 --- a/src/renderer/components/AccountView.tsx +++ b/src/renderer/components/AccountView.tsx @@ -93,11 +93,7 @@ function AccountView(props: { pubKey: string | undefined }) { - {account ? ( - - ) : ( - 'No' - )} + {pubKey ? : 'None selected'}