11import { Chain } from "@chain-registry/types" ;
22import { CopyToClipboardControl , Stack } from "@namada/components" ;
3+ import { PseudoExtendedKey } from "@namada/sdk/web" ;
34import { shortenAddress } from "@namada/utils" ;
45import {
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