@@ -13,6 +13,7 @@ import {
1313 setLocalAddressScreenV2Raw ,
1414 setSourceAddressScreenV2Raw ,
1515} from '@/state/raw' ;
16+ import { getHdKeyNonce } from '@/state/walletSelectors' ;
1617
1718import { signCompliancePayload } from '@/lib/compliance' ;
1819import { mapIfPresent } from '@/lib/do' ;
@@ -62,9 +63,10 @@ export function setUpIndexerSourceAddressScreenV2Query(store: RootStore) {
6263}
6364
6465const selectChainIdAndLocalAddress = createAppSelector (
65- [ getSelectedDydxChainId , getUserWalletAddress , getSelectedNetwork ] ,
66- ( chainId , address , network ) => ( {
66+ [ getSelectedDydxChainId , getUserWalletAddress , getSelectedNetwork , getHdKeyNonce ] ,
67+ ( chainId , address , network , hdKeyNonce ) => ( {
6768 chainId,
69+ hdKeyNonce,
6870 address,
6971 network,
7072 } )
@@ -81,12 +83,14 @@ const COMPLIANCE_PAYLOAD_MESSAGE = 'Verify account ownership';
8183async function updateCompliance ( {
8284 chainId,
8385 address,
86+ hdKeyNonce,
8487 network,
8588 status,
8689 action,
8790} : {
8891 chainId : DydxChainId ;
8992 address : string ;
93+ hdKeyNonce : number ;
9094 network : DydxNetwork ;
9195 status : ComplianceStatus ;
9296 action : ComplianceAction ;
@@ -104,7 +108,7 @@ async function updateCompliance({
104108 chainId,
105109 } ;
106110
107- const signingResponse = await signCompliancePayload ( address , payload ) ;
111+ const signingResponse = await signCompliancePayload ( address , hdKeyNonce , payload ) ;
108112 if ( ! signingResponse ) {
109113 return { status : ComplianceStatus . UNKNOWN } ;
110114 }
@@ -163,8 +167,8 @@ export function setUpIndexerLocalAddressScreenV2Query(store: RootStore) {
163167 address ,
164168 network ,
165169 ] ,
166- getQueryFn : ( indexerClient , { chainId, address, network } ) => {
167- if ( address == null ) {
170+ getQueryFn : ( indexerClient , { chainId, address, network, hdKeyNonce } ) => {
171+ if ( address == null || hdKeyNonce == null ) {
168172 return null ;
169173 }
170174 return async ( ) : Promise < ComplianceResponse > => {
@@ -179,6 +183,7 @@ export function setUpIndexerLocalAddressScreenV2Query(store: RootStore) {
179183
180184 const updateResult = updateCompliance ( {
181185 address,
186+ hdKeyNonce,
182187 chainId,
183188 network,
184189 status : firstScreenResult . status ,
@@ -211,15 +216,17 @@ export const triggerCompliance = (action: ComplianceAction) => {
211216 const currentLocalScreenStatus = selectRawLocalAddressScreenV2 ( state ) . data ?. status ;
212217 const chainId = getSelectedDydxChainId ( state ) ;
213218 const address = getUserWalletAddress ( state ) ;
219+ const hdKeyNonce = getHdKeyNonce ( state ) ;
214220 const network = getSelectedNetwork ( state ) ;
215221
216- if ( ! address || ! currentLocalScreenStatus ) {
222+ if ( ! address || ! currentLocalScreenStatus || ! hdKeyNonce ) {
217223 throw new Error ( 'TriggerCompliance: No account connected or screen status not loaded' ) ;
218224 }
219225
220226 const result = await updateCompliance ( {
221227 chainId,
222228 address,
229+ hdKeyNonce,
223230 network,
224231 status : currentLocalScreenStatus ,
225232 action,
0 commit comments