@@ -21,7 +21,7 @@ import { useAnalyticsContext } from '@providers';
21
21
import { TX_CREATION_TYPE_KEY , TxCreationType } from '@providers/AnalyticsProvider/analyticsTracker' ;
22
22
import { signingCoordinator } from '@lib/wallet-api-ui' ;
23
23
import { senderToDappInfo } from '@src/utils/senderToDappInfo' ;
24
- import { useOnUnload } from './confirm-transaction/hooks' ;
24
+ import { useGetOwnPubDRepKeyHash , useOnUnload } from './confirm-transaction/hooks' ;
25
25
import { parseError } from '@src/utils/parse-error' ;
26
26
27
27
const INDENT_SPACING = 2 ;
@@ -39,6 +39,10 @@ const hasJsonStructure = (str: string): boolean => {
39
39
}
40
40
} ;
41
41
42
+ const isPaymentAddress = (
43
+ signWith : Wallet . Cardano . PaymentAddress | Wallet . Cardano . RewardAccount
44
+ ) : signWith is Wallet . Cardano . PaymentAddress => signWith . startsWith ( 'addr' ) ;
45
+
42
46
export const DappConfirmData = ( ) : React . ReactElement => {
43
47
const {
44
48
utils : { setNextView } ,
@@ -53,6 +57,8 @@ export const DappConfirmData = (): React.ReactElement => {
53
57
const [ dappInfo , setDappInfo ] = useState < Wallet . DappInfo > ( ) ;
54
58
const analytics = useAnalyticsContext ( ) ;
55
59
60
+ const { ownPubDRepKeyHash, loading : isLoadingOwnPubDRepKeyHash } = useGetOwnPubDRepKeyHash ( ) ;
61
+
56
62
const [ formattedData , setFormattedData ] = useState < {
57
63
address : string ;
58
64
dataToSign : string ;
@@ -99,15 +105,31 @@ export const DappConfirmData = (): React.ReactElement => {
99
105
useEffect ( ( ) => {
100
106
if ( ! req ) return ;
101
107
const dataFromHex = fromHex ( req . signContext . payload ) ;
102
- const txDataAddress = req . signContext . signWith ;
108
+
109
+ let txDataAddress = req . signContext . signWith ;
110
+
111
+ if ( ownPubDRepKeyHash && isPaymentAddress ( txDataAddress ) ) {
112
+ const drepAddr = Wallet . Cardano . Address . fromString ( txDataAddress ) ;
113
+
114
+ if (
115
+ drepAddr ?. getType ( ) === Wallet . Cardano . AddressType . EnterpriseKey &&
116
+ drepAddr ?. getProps ( ) . paymentPart ?. hash === ownPubDRepKeyHash
117
+ ) {
118
+ txDataAddress = Wallet . Cardano . DRepID . cip129FromCredential ( {
119
+ hash : drepAddr ?. getProps ( ) . paymentPart ?. hash ,
120
+ type : Wallet . Cardano . CredentialType . KeyHash
121
+ } ) ;
122
+ }
123
+ }
124
+
103
125
const jsonStructureOrHexString = {
104
126
address : txDataAddress ,
105
127
dataToSign : hasJsonStructure ( dataFromHex )
106
128
? JSON . stringify ( JSON . parse ( dataFromHex ) , undefined , INDENT_SPACING )
107
129
: dataFromHex
108
130
} ;
109
131
setFormattedData ( jsonStructureOrHexString ) ;
110
- } , [ req ] ) ;
132
+ } , [ req , ownPubDRepKeyHash ] ) ;
111
133
112
134
const signWithHardwareWallet = useCallback ( async ( ) => {
113
135
setIsConfirmingTx ( true ) ;
@@ -138,7 +160,7 @@ export const DappConfirmData = (): React.ReactElement => {
138
160
< Layout pageClassname = { styles . spaceBetween } title = { t ( sectionTitle [ DAPP_VIEWS . CONFIRM_DATA ] ) } >
139
161
< div className = { styles . container } >
140
162
< DappInfo { ...dappInfo } className = { styles . dappInfo } />
141
- { formattedData ? (
163
+ { formattedData && ! isLoadingOwnPubDRepKeyHash ? (
142
164
< >
143
165
< div className = { styles . contentSection } >
144
166
< p className = { styles . heading } data-testid = "dapp-transaction-recipient-address-title" >
0 commit comments