diff --git a/app/frontend/actions.ts b/app/frontend/actions.ts index aac11a21b8..0111dd01e3 100644 --- a/app/frontend/actions.ts +++ b/app/frontend/actions.ts @@ -810,6 +810,37 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF stopLoadingAction(state, {}) } + const redeemRewards = async (state) => { + loadingAction(state, 'Preparing transaction...') + const address = await wallet.getChangeAddress() + const coins = state.shelleyBalances.rewardsAccountBalance + const balance = state.balance + let plan + try { + plan = await prepareTxPlan({ + address, + coins, + txType: 'redeem', + }) + } catch (e) { + setErrorState('transactionSubmissionError', e, { + shouldShowTransactionErrorModal: true, + }) + return + } + if (balance < (plan.fee || plan.estimatedFee)) { + setErrorState('transactionSubmissionError', NamedError('NonStakingConversionError')) + setState({ + shouldShowTransactionErrorModal: true, + }) + stopLoadingAction(state, {}) + return + } + setTransactionSummary('stake', plan, coins) + confirmTransaction(getState(), 'convert') + stopLoadingAction(state, {}) + } + const updateDonation = (state, e) => { if (state.checkedDonationType === e.target.id && e.target.id !== 'custom') { // when clicking already selected button @@ -1215,5 +1246,6 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF selectAdaliteStakepool, convertNonStakingUtxos, loadErrorBannerContent, + redeemRewards, } } diff --git a/app/frontend/components/pages/delegations/shelleyBalances.tsx b/app/frontend/components/pages/delegations/shelleyBalances.tsx index 827ade2fb1..0f7e069c9a 100644 --- a/app/frontend/components/pages/delegations/shelleyBalances.tsx +++ b/app/frontend/components/pages/delegations/shelleyBalances.tsx @@ -12,6 +12,7 @@ const shelleyBalances = ({ balance, reloadWalletInfo, convertNonStakingUtxos, + redeemRewards, }) => (