Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use account-view, but show that the account isn't on this chain #96

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/anchor.ts
Original file line number Diff line number Diff line change
@@ -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 (???)
Expand All @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
44 changes: 26 additions & 18 deletions src/renderer/components/AccountView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Container>
<ButtonToolbar aria-label="Toolbar with button groups">
Expand Down Expand Up @@ -94,7 +93,7 @@ function AccountView(props: { pubKey: string | undefined }) {
</td>
<td>
<small>
<InlinePK pk={account.accountId.toString()} />
{pubKey ? <InlinePK pk={pubKey} /> : 'None selected'}
</small>
</td>
</tr>
Expand All @@ -103,15 +102,17 @@ function AccountView(props: { pubKey: string | undefined }) {
<small className="text-muted">SOL</small>
</td>
<td>
<small>{truncateLamportAmount(account)}</small>
<small>
{account ? truncateLamportAmount(account) : 0}
</small>
</td>
</tr>
<tr>
<td>
<small className="text-muted">Executable</small>
</td>
<td>
{account.accountInfo.executable ? (
{account?.accountInfo.executable ? (
<div>
<FontAwesomeIcon
className="border-success rounded p-1 exe-icon"
Expand All @@ -132,17 +133,24 @@ function AccountView(props: { pubKey: string | undefined }) {
</td>
<td>
<small>
<a
onClick={() =>
analytics('clickExplorerLink', { net })
}
href={explorerURL(net, account.accountId.toString())}
target="_blank"
className="sol-link"
rel="noreferrer"
>
Link
</a>
{account ? (
<a
onClick={() =>
analytics('clickExplorerLink', { net })
}
href={explorerURL(
net,
account.accountId.toString()
)}
target="_blank"
className="sol-link"
rel="noreferrer"
>
Link
</a>
) : (
'No onchain account'
)}
</small>
</td>
</tr>
Expand Down