Skip to content

Commit

Permalink
Fix: createStakedExpenditure saga stuck if enough active tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubcolony committed Oct 13, 2024
1 parent b2a06f7 commit 0e35c83
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/redux/sagas/expenditures/createStakedExpenditure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ function* createStakedExpenditure({
yield createMulticallChannels();

try {
if (stakeAmount.gt(activeBalance)) {
const needsActivatingTokens = stakeAmount.gt(activeBalance);

if (needsActivatingTokens) {
const missingActiveTokens = stakeAmount.sub(activeBalance);

yield createGroupTransaction({
Expand Down Expand Up @@ -198,13 +200,15 @@ function* createStakedExpenditure({
});
}

yield takeFrom(approve.channel, ActionTypes.TRANSACTION_CREATED);
yield initiateTransaction(approve.id);
yield waitForTxResult(approve.channel);
if (needsActivatingTokens) {
yield takeFrom(approve.channel, ActionTypes.TRANSACTION_CREATED);
yield initiateTransaction(approve.id);
yield waitForTxResult(approve.channel);

yield takeFrom(deposit.channel, ActionTypes.TRANSACTION_CREATED);
yield initiateTransaction(deposit.id);
yield waitForTxResult(deposit.channel);
yield takeFrom(deposit.channel, ActionTypes.TRANSACTION_CREATED);
yield initiateTransaction(deposit.id);
yield waitForTxResult(deposit.channel);
}

yield takeFrom(approveStake.channel, ActionTypes.TRANSACTION_CREATED);
yield initiateTransaction(approveStake.id);
Expand Down

0 comments on commit 0e35c83

Please sign in to comment.