Skip to content

Commit

Permalink
fixup! refactor(suite): redundant precomposedForm state removed from …
Browse files Browse the repository at this point in the history
…sendForm reducer
  • Loading branch information
PeKne committed May 20, 2024
1 parent 7b2265b commit f635113
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions suite-common/wallet-core/src/send/sendFormThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export const signTransactionThunk = createThunk(
);

export const enhancePrecomposedTransactionThunk = createThunk(
`${SEND_MODULE_PREFIX}/prepareTransactionForSigningThunk`,
`${SEND_MODULE_PREFIX}/enhancePrecomposedTransactionThunk`,
async (
{
transactionFormValues: formValues,
Expand All @@ -440,7 +440,6 @@ export const enhancePrecomposedTransactionThunk = createThunk(
) => {
const device = selectDevice(getState());
const selectedAccountNetwork = getNetwork(selectedAccount.symbol);

if (!device) return rejectWithValue('Device not found');

// native RBF is available since FW 1.9.4/2.3.5
Expand All @@ -467,14 +466,19 @@ export const enhancePrecomposedTransactionThunk = createThunk(
...precomposedTransaction,
};

if (formValues.rbfParams && !isCardanoTx(selectedAccount, enhancedPrecomposedTransaction)) {
if (!isCardanoTx(selectedAccount, enhancedPrecomposedTransaction)) {
enhancedPrecomposedTransaction.rbf = formValues.options.includes('bitcoinRBF');
enhancedPrecomposedTransaction.prevTxid = formValues.rbfParams.txid;
enhancedPrecomposedTransaction.feeDifference = new BigNumber(precomposedTransaction.fee)
.minus(formValues.rbfParams.baseFee)
.toFixed();
enhancedPrecomposedTransaction.useNativeRbf = useNativeRbf;
enhancedPrecomposedTransaction.useDecreaseOutput = hasDecreasedOutput;

if (formValues.rbfParams) {
enhancedPrecomposedTransaction.prevTxid = formValues.rbfParams.txid;
enhancedPrecomposedTransaction.feeDifference = new BigNumber(
precomposedTransaction.fee,
)
.minus(formValues.rbfParams.baseFee)
.toFixed();
enhancedPrecomposedTransaction.useNativeRbf = useNativeRbf;
enhancedPrecomposedTransaction.useDecreaseOutput = hasDecreasedOutput;
}
}

if (
Expand All @@ -494,7 +498,6 @@ export const enhancePrecomposedTransactionThunk = createThunk(

enhancedPrecomposedTransaction.isTokenKnown = isTokenKnown;
}

// store formValues and transactionInfo in send reducer to be used by TransactionReviewModal
dispatch(
sendFormActions.storePrecomposedTransaction({
Expand Down

0 comments on commit f635113

Please sign in to comment.