Add links to account modal

This commit is contained in:
Valtteri Karesto
2022-06-29 15:26:33 +03:00
parent b4a0bcb90d
commit ec8bfc5eee
2 changed files with 35 additions and 6 deletions

View File

@@ -118,7 +118,13 @@ export const AccountDialog = ({
fontFamily: "$monospace", fontFamily: "$monospace",
}} }}
> >
{activeAccount?.address} <a
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${activeAccount?.address}`}
target="_blank"
rel="noopener noreferrer"
>
{activeAccount?.address}
</a>
</Text> </Text>
</Flex> </Flex>
<Flex css={{ marginLeft: "auto", color: "$mauve12" }}> <Flex css={{ marginLeft: "auto", color: "$mauve12" }}>
@@ -240,7 +246,18 @@ export const AccountDialog = ({
}} }}
> >
{activeAccount && activeAccount.hooks.length > 0 {activeAccount && activeAccount.hooks.length > 0
? activeAccount.hooks.map((i) => truncate(i, 12)).join(",") ? activeAccount.hooks.map((i) => {
return (
<a
key={i.index}
href={`https://${process.env.NEXT_PUBLIC_EXPLORER_URL}/${i.index}`}
target="_blank"
rel="noopener noreferrer"
>
{truncate(i.HookHash, 12)}
</a>
);
})
: ""} : ""}
</Text> </Text>
</Flex> </Flex>
@@ -327,15 +344,21 @@ const Accounts: FC<AccountProps> = (props) => {
}); });
const objectResponses = await Promise.all(objectRequests); const objectResponses = await Promise.all(objectRequests);
objectResponses.forEach((res: any) => { objectResponses.forEach((res: any) => {
console.log(res);
const address = res?.account as string; const address = res?.account as string;
const accountToUpdate = state.accounts.find( const accountToUpdate = state.accounts.find(
(acc) => acc.address === address (acc) => acc.address === address
); );
if (accountToUpdate) { if (accountToUpdate) {
const hookObj = res.account_objects.find(
(ac: any) => ac?.LedgerEntryType === "Hook"
);
accountToUpdate.hooks = accountToUpdate.hooks =
res.account_objects hookObj?.Hooks?.map((oo: any) => ({
.find((ac: any) => ac?.LedgerEntryType === "Hook") HookHash: oo.Hook?.HookHash,
?.Hooks?.map((oo: any) => oo.Hook.HookHash) || []; HookNamespace: oo.Hook?.HookNamespace,
index: hookObj.index,
})) || [];
} }
}); });
} }

View File

@@ -26,13 +26,19 @@ export interface FaucetAccountRes {
code: string; code: string;
} }
export interface IHooks {
HookHash: string;
HookNamespace: string;
index: string;
}
export interface IAccount { export interface IAccount {
name: string; name: string;
address: string; address: string;
secret: string; secret: string;
xrp: string; xrp: string;
sequence: number; sequence: number;
hooks: string[]; hooks: IHooks[];
isLoading: boolean; isLoading: boolean;
version?: string; version?: string;
error?: { error?: {