Skip to content

Commit

Permalink
feat: hook up viewing key
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Oct 14, 2024
1 parent 72673d1 commit 8331e5c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
11 changes: 8 additions & 3 deletions apps/extension/src/App/Accounts/ViewAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const ViewAccount = (): JSX.Element => {
const [parentAccount, setParentAccount] = useState<DerivedAccount>();
const [transparentAddress, setTransparentAddress] = useState("");
const [shieldedAddress, setShieldedAddress] = useState("");
const [viewingKey, setViewingKey] = useState("");
const navigate = useNavigate();

const searchParentAccount = (
Expand All @@ -41,9 +42,12 @@ export const ViewAccount = (): JSX.Element => {
setTransparentAddress(parentAccount?.address);
}

const shieldedKey = searchShieldedKey(accountId);
if (shieldedKey) {
setShieldedAddress(shieldedKey.address);
const shieldedAccount = searchShieldedKey(accountId);
if (shieldedAccount) {
setShieldedAddress(shieldedAccount.address);
if (shieldedAccount.owner) {
setViewingKey(shieldedAccount.owner);
}
}
}, [accountId]);

Expand All @@ -61,6 +65,7 @@ export const ViewAccount = (): JSX.Element => {
publicKeyAddress={parentAccount.publicKey ?? ""}
transparentAccountAddress={transparentAddress}
shieldedAccountAddress={shieldedAddress}
viewingKeys={viewingKey}
trimCharacters={21}
/>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/Setup/Ledger/LedgerConnect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ledger as LedgerApp, makeBip44Path } from "@heliax/namada-sdk/web";
import { Ledger as LedgerApp, makeBip44Path } from "@heliaxdev/namada-sdk/web";
import { chains } from "@namada/chains";
import { ActionButton, Alert, Image, Stack } from "@namada/components";
import { Bip44Path } from "@namada/types";
Expand Down
29 changes: 21 additions & 8 deletions packages/components/src/ViewKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ActionButton, GapPatterns, Input, Stack } from "@namada/components";

import { shortenAddress } from "@namada/utils";
import clsx from "clsx";
import { useState } from "react";

type ViewKeysProps = {
publicKeyAddress?: string;
Expand All @@ -20,6 +21,7 @@ export const ViewKeys = ({
footer,
trimCharacters = 16,
}: ViewKeysProps): JSX.Element => {
const [seeViewingKey, setSeeViewingKey] = useState(false);
return (
<Stack
className="flex-1 justify-center"
Expand Down Expand Up @@ -61,14 +63,25 @@ export const ViewKeys = ({
theme={"secondary"}
/>
)}
{viewingKeys && (
<div className="text-white flex flex-col text-base font-medium gap-3 text-center">
Viewing keys of shielded account
<ActionButton size="md" backgroundColor="cyan">
Download
</ActionButton>
</div>
)}
{viewingKeys &&
(seeViewingKey ?
<Input
label="Viewing Key"
variant="ReadOnlyCopy"
readOnly={true}
valueToDisplay={shortenAddress(viewingKeys, trimCharacters)}
value={viewingKeys}
theme={"secondary"}
/>
: <div className="text-white flex flex-col text-base font-medium gap-3">
<ActionButton
size="md"
backgroundColor="cyan"
onClick={() => setSeeViewingKey(true)}
>
See Viewing Key
</ActionButton>
</div>)}
</Stack>
{(viewingKeys || footer) && (
<Stack as="footer" gap={4}>
Expand Down

0 comments on commit 8331e5c

Please sign in to comment.