Skip to content

Commit cd7b38f

Browse files
committed
feat: allow fiat-funded deposits to submit and fix conversion casing check
Fiat-funded pay deposits (perps/predict/mUSD) auto-submit right after the on-ramp order is created, before any pay token is ever selected on the controller, so the pay-token-required publish guard always threw for them. Also fix a checksum-vs-lowercase mismatch that could mark an optional conversion as required and block a valid direct submission.
1 parent cefe5d2 commit cd7b38f

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

app/util/transactions/hooks/index.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function validateRequiredQuote(
274274
}
275275

276276
if (isPayTokenRequiredType) {
277-
if (isValidatedDirectDeposit(data)) {
277+
if (isValidatedDirectDeposit(data) || isValidatedFiatDeposit(data)) {
278278
return;
279279
}
280280

@@ -333,13 +333,30 @@ function isValidatedDirectDeposit(data: TransactionData | undefined): boolean {
333333

334334
const hasRequiredConversion = (data?.sourceAmounts ?? []).some(
335335
(sourceAmount) =>
336-
!tokens.find((token) => token.address === sourceAmount.targetTokenAddress)
337-
?.skipIfBalance,
336+
!tokens.find(
337+
(token) =>
338+
token.address.toLowerCase() ===
339+
sourceAmount.targetTokenAddress.toLowerCase(),
340+
)?.skipIfBalance,
338341
);
339342

340343
return !hasRequiredConversion;
341344
}
342345

346+
/**
347+
* A fiat-funded deposit submits without a pay quote because the on-ramp
348+
* order itself is the funding source; the flow is validated at confirmation
349+
* time by the fiat no-quotes alert (see useNoPayTokenQuotesAlert), and the
350+
* auto-fiat-submission hook publishes as soon as the order is created,
351+
* before any pay token is ever selected on the controller.
352+
*
353+
* @param data - Pay state for the transaction.
354+
* @returns Whether the fiat-funded submission is safe.
355+
*/
356+
function isValidatedFiatDeposit(data: TransactionData | undefined): boolean {
357+
return Boolean(data?.fiatPayment?.orderId);
358+
}
359+
343360
function getSmartTransactionCommonParams(state: RootState, chainId: Hex) {
344361
const shouldUseSmartTransaction = selectShouldUseSmartTransaction(
345362
state,

0 commit comments

Comments
 (0)