Skip to content

Commit 39c5cb2

Browse files
committed
fix(money): update transaction data when pay token changes on deposit
The deposit total stayed stale after changing the pay token because handleDone (which syncs requiredAssets and atomic-batch calldata) only fired on the first prefill. Reset the one-shot latch when the prefill drops so the full update re-runs for the new token/amount. Also shallow-spread txParams in syncMoneyAccountDepositRequiredAssets to avoid mutating frozen controller state (read-only 'type' error).
1 parent 955fd0a commit 39c5cb2

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

app/components/Views/confirmations/components/info/custom-amount-info/custom-amount-info.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,14 @@ export const CustomAmountInfo: React.FC<CustomAmountInfoProps> = memo(
295295

296296
const hasAutoSubmittedPrefill = useRef(false);
297297
useEffect(() => {
298-
if (
299-
!hasAutoSubmittedPrefill.current &&
300-
isDepositPrefilled &&
301-
amountFiat !== '0'
302-
) {
298+
// Reset when prefill drops (e.g. pay token changed) so handleDone
299+
// re-fires once the new prefill amount is ready.
300+
if (!isDepositPrefilled) {
301+
hasAutoSubmittedPrefill.current = false;
302+
return;
303+
}
304+
305+
if (!hasAutoSubmittedPrefill.current && amountFiat !== '0') {
303306
hasAutoSubmittedPrefill.current = true;
304307
handleDone();
305308
}

app/components/Views/confirmations/hooks/pay/useUpdateTransactionPayAmount.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function syncMoneyAccountDepositRequiredAssets(
148148
updateTransaction(
149149
{
150150
...transactionMeta,
151+
txParams: { ...transactionMeta.txParams },
151152
requiredAssets: [{ ...existing[0], amount }, ...existing.slice(1)],
152153
},
153154
'Money Account deposit: sync requiredAssets amount',

0 commit comments

Comments
 (0)