Skip to content
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
24 changes: 21 additions & 3 deletions apps/namadillo/src/App/Common/TransactionReceipt.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Chain } from "@chain-registry/types";
import { CopyToClipboardControl, Stack } from "@namada/components";
import { PseudoExtendedKey } from "@namada/sdk/web";
import { shortenAddress } from "@namada/utils";
import {
isNamadaAddress,
Expand Down Expand Up @@ -48,6 +49,9 @@ const TransferTransactionReceipt = ({
return chain;
};

const isExtendedKey = (address: string): boolean =>
PseudoExtendedKey.can_decode(address);

const sourceChain = useMemo(() => {
return getChain(transaction.chainId, transaction.sourceAddress || "");
}, [transaction]);
Expand All @@ -61,8 +65,18 @@ const TransferTransactionReceipt = ({
);
}, [transaction]);

const getEncodedViewingKey = (address: string): string => {
const decodedPseudokey = PseudoExtendedKey.decode(address);
const encodedViewingKey = decodedPseudokey.to_viewing_key().encode();
return encodedViewingKey;
};

// Used whenever the source funds are coming from the shielded pool
const sourceWallet =
isNamadaAddress(transaction.sourceAddress || "") ?
(
isNamadaAddress(transaction.sourceAddress || "") ||
isExtendedKey(transaction.sourceAddress || "")
) ?
wallets.namada
: wallets.keplr;

Expand All @@ -84,8 +98,12 @@ const TransferTransactionReceipt = ({
{sourceWallet && (
<SelectedWallet
wallet={sourceWallet}
address={transaction.sourceAddress}
displayTooltip={!transaction.sourceAddress?.includes("shielded")}
address={
isExtendedKey(transaction.sourceAddress || "") ?
getEncodedViewingKey(transaction.sourceAddress || "")
: transaction.sourceAddress
}
displayTooltip={!isExtendedKey(transaction.sourceAddress || "")}
/>
)}
</header>
Expand Down
Loading
Loading