1
1
import { Chain } from "@chain-registry/types" ;
2
2
import { CopyToClipboardControl , Stack } from "@namada/components" ;
3
+ import { PseudoExtendedKey } from "@namada/sdk/web" ;
3
4
import { shortenAddress } from "@namada/utils" ;
4
5
import {
5
6
isNamadaAddress ,
@@ -48,6 +49,9 @@ const TransferTransactionReceipt = ({
48
49
return chain ;
49
50
} ;
50
51
52
+ const isExtendedKey = ( address : string ) : boolean =>
53
+ PseudoExtendedKey . can_decode ( address ) ;
54
+
51
55
const sourceChain = useMemo ( ( ) => {
52
56
return getChain ( transaction . chainId , transaction . sourceAddress || "" ) ;
53
57
} , [ transaction ] ) ;
@@ -61,8 +65,18 @@ const TransferTransactionReceipt = ({
61
65
) ;
62
66
} , [ transaction ] ) ;
63
67
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
64
75
const sourceWallet =
65
- isNamadaAddress ( transaction . sourceAddress || "" ) ?
76
+ (
77
+ isNamadaAddress ( transaction . sourceAddress || "" ) ||
78
+ isExtendedKey ( transaction . sourceAddress || "" )
79
+ ) ?
66
80
wallets . namada
67
81
: wallets . keplr ;
68
82
@@ -84,8 +98,12 @@ const TransferTransactionReceipt = ({
84
98
{ sourceWallet && (
85
99
< SelectedWallet
86
100
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 || "" ) }
89
107
/>
90
108
) }
91
109
</ header >
0 commit comments