Skip to content

Commit aba80b7

Browse files
authored
fix: add alias - shielded for all gas spendnig keys (#2280)
1 parent 9391b05 commit aba80b7

File tree

2 files changed

+372
-3
lines changed

2 files changed

+372
-3
lines changed

apps/namadillo/src/App/Common/TransactionReceipt.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Chain } from "@chain-registry/types";
22
import { CopyToClipboardControl, Stack } from "@namada/components";
3+
import { PseudoExtendedKey } from "@namada/sdk/web";
34
import { shortenAddress } from "@namada/utils";
45
import {
56
isNamadaAddress,
@@ -48,6 +49,9 @@ const TransferTransactionReceipt = ({
4849
return chain;
4950
};
5051

52+
const isExtendedKey = (address: string): boolean =>
53+
PseudoExtendedKey.can_decode(address);
54+
5155
const sourceChain = useMemo(() => {
5256
return getChain(transaction.chainId, transaction.sourceAddress || "");
5357
}, [transaction]);
@@ -61,8 +65,18 @@ const TransferTransactionReceipt = ({
6165
);
6266
}, [transaction]);
6367

68+
const getEncodedViewingKey = (address: string): string => {
69+
const decodedPseudokey = PseudoExtendedKey.decode(address);
70+
const encodedViewingKey = decodedPseudokey.to_viewing_key().encode();
71+
return encodedViewingKey;
72+
};
73+
74+
// Used whenever the source funds are coming from the shielded pool
6475
const sourceWallet =
65-
isNamadaAddress(transaction.sourceAddress || "") ?
76+
(
77+
isNamadaAddress(transaction.sourceAddress || "") ||
78+
isExtendedKey(transaction.sourceAddress || "")
79+
) ?
6680
wallets.namada
6781
: wallets.keplr;
6882

@@ -84,8 +98,12 @@ const TransferTransactionReceipt = ({
8498
{sourceWallet && (
8599
<SelectedWallet
86100
wallet={sourceWallet}
87-
address={transaction.sourceAddress}
88-
displayTooltip={!transaction.sourceAddress?.includes("shielded")}
101+
address={
102+
isExtendedKey(transaction.sourceAddress || "") ?
103+
getEncodedViewingKey(transaction.sourceAddress || "")
104+
: transaction.sourceAddress
105+
}
106+
displayTooltip={!isExtendedKey(transaction.sourceAddress || "")}
89107
/>
90108
)}
91109
</header>

0 commit comments

Comments
 (0)