From b0cce33e9dc84b158e4851ce8670c371946f4504 Mon Sep 17 00:00:00 2001 From: Ilias Trichopoulos Date: Wed, 26 Feb 2025 18:04:29 +0100 Subject: [PATCH 1/2] Bump desktop wallet version to 3.0.0-rc.2 --- apps/desktop-wallet/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop-wallet/package.json b/apps/desktop-wallet/package.json index 960e59ce7..737523a11 100644 --- a/apps/desktop-wallet/package.json +++ b/apps/desktop-wallet/package.json @@ -1,7 +1,7 @@ { "name": "alephium-desktop-wallet", "description": "The official Alephium wallet", - "version": "3.0.0-rc.1", + "version": "3.0.0-rc.2", "author": "Alephium dev ", "main": "dist-electron/main.js", "homepage": "./", From f006d296275d5bd2d8470e6e3e234ea5d4f29dc9 Mon Sep 17 00:00:00 2001 From: Ilias Trichopoulos Date: Thu, 27 Feb 2025 10:17:15 +0100 Subject: [PATCH 2/2] Fix consolidation Closes #1290 --- .../src/features/send/SendModal.tsx | 147 ++++++++++-------- .../sendModals/transfer/TransferSendModal.tsx | 5 +- .../src/features/send/sendTypes.ts | 1 - 3 files changed, 82 insertions(+), 71 deletions(-) diff --git a/apps/desktop-wallet/src/features/send/SendModal.tsx b/apps/desktop-wallet/src/features/send/SendModal.tsx index f45ce578f..34f9b813a 100644 --- a/apps/desktop-wallet/src/features/send/SendModal.tsx +++ b/apps/desktop-wallet/src/features/send/SendModal.tsx @@ -125,83 +125,92 @@ function SendModal({ setUnsignedTxId, setContractAddress, isSweeping, - consolidationRequired, buildExecuteScriptTxResult, setBuildExecuteScriptTxResult }), - [buildExecuteScriptTxResult, consolidationRequired, isSweeping, sweepUnsignedTxs, unsignedTransaction, unsignedTxId] + [buildExecuteScriptTxResult, isSweeping, sweepUnsignedTxs, unsignedTransaction, unsignedTxId] ) - const handleSendExtended = useCallback(async () => { - if (!transactionData) return + const handleSendExtended = useCallback( + async (consolidationRequired: boolean) => { + if (!transactionData) return - setIsLoading(isLedger ? t('Please, confirm the transaction on your Ledger.') : true) + setIsLoading(isLedger ? t('Please, confirm the transaction on your Ledger.') : true) - try { - const signature = - type === 'transfer' - ? await handleTransferSend(transactionData as TransferTxData, txContext, posthog, isLedger, onLedgerError) - : type === 'call-contract' - ? await handleCallContractSend( - transactionData as CallContractTxData, - txContext, - posthog, - isLedger, - onLedgerError - ) - : await handleDeployContractSend( - transactionData as DeployContractTxData, + try { + const signature = + type === 'transfer' + ? await handleTransferSend( + transactionData as TransferTxData, txContext, posthog, isLedger, - onLedgerError + onLedgerError, + consolidationRequired ) - - if (signature && triggeredByWalletConnect) { - const result = - type === 'transfer' - ? getTransferWalletConnectResult(txContext, signature) : type === 'call-contract' - ? getCallContractWalletConnectResult(txContext, signature) - : getDeployContractWalletConnectResult(txContext, signature, contractAddress) - - sendSuccessResponse(result) - } + ? await handleCallContractSend( + transactionData as CallContractTxData, + txContext, + posthog, + isLedger, + onLedgerError + ) + : await handleDeployContractSend( + transactionData as DeployContractTxData, + txContext, + posthog, + isLedger, + onLedgerError + ) + + if (signature && triggeredByWalletConnect) { + const result = + type === 'transfer' + ? getTransferWalletConnectResult(txContext, signature) + : type === 'call-contract' + ? getCallContractWalletConnectResult(txContext, signature) + : getDeployContractWalletConnectResult(txContext, signature, contractAddress) + + sendSuccessResponse(result) + } - dispatch(transactionsSendSucceeded({ nbOfTransactionsSent: isSweeping ? sweepUnsignedTxs.length : 1 })) - setStep('tx-sent') - } catch (error) { - dispatch(transactionSendFailed(getHumanReadableError(error, t('Error while sending the transaction')))) - sendAnalytics({ type: 'error', message: 'Could not send tx' }) - - if (triggeredByWalletConnect) { - sendFailureResponse({ - message: getHumanReadableError(error, 'Error while sending the transaction'), - code: WALLETCONNECT_ERRORS.TRANSACTION_SEND_FAILED - }) - dispatch(closeModal({ id })) + dispatch(transactionsSendSucceeded({ nbOfTransactionsSent: isSweeping ? sweepUnsignedTxs.length : 1 })) + setStep('tx-sent') + } catch (error) { + dispatch(transactionSendFailed(getHumanReadableError(error, t('Error while sending the transaction')))) + sendAnalytics({ type: 'error', message: 'Could not send tx' }) + + if (triggeredByWalletConnect) { + sendFailureResponse({ + message: getHumanReadableError(error, 'Error while sending the transaction'), + code: WALLETCONNECT_ERRORS.TRANSACTION_SEND_FAILED + }) + dispatch(closeModal({ id })) + } + } finally { + setIsLoading(false) } - } finally { - setIsLoading(false) - } - }, [ - contractAddress, - dispatch, - id, - isLedger, - isSweeping, - onLedgerError, - posthog, - sendAnalytics, - sendFailureResponse, - sendSuccessResponse, - sweepUnsignedTxs.length, - t, - transactionData, - triggeredByWalletConnect, - txContext, - type - ]) + }, + [ + contractAddress, + dispatch, + id, + isLedger, + isSweeping, + onLedgerError, + posthog, + sendAnalytics, + sendFailureResponse, + sendSuccessResponse, + sweepUnsignedTxs.length, + t, + transactionData, + triggeredByWalletConnect, + txContext, + type + ] + ) const goToAddresses = useCallback(() => setStep('addresses'), []) const goToBuildTx = useCallback(() => setStep('build-tx'), []) @@ -243,7 +252,9 @@ function SendModal({ name: 'ConsolidateUTXOsModal', props: { fee: fees, - onConsolidateClick: passwordRequirement ? () => setStep('password-check') : handleSendExtended + onConsolidateClick: passwordRequirement + ? () => setStep('password-check') + : () => handleSendExtended(true) } }) ) @@ -352,7 +363,7 @@ function SendModal({ handleSendExtended(consolidationRequired)} onBack={goToBuildTx} dAppUrl={dAppUrl} /> @@ -360,7 +371,7 @@ function SendModal({ handleSendExtended(consolidationRequired)} onBack={goToBuildTx} dAppUrl={dAppUrl} /> @@ -368,7 +379,7 @@ function SendModal({ handleSendExtended(consolidationRequired)} onBack={goToBuildTx} dAppUrl={dAppUrl} /> @@ -378,7 +389,7 @@ function SendModal({ text={t('Enter your password to send the transaction.')} buttonText={t('Send')} highlightButton - onCorrectPasswordEntered={handleSendExtended} + onCorrectPasswordEntered={() => handleSendExtended(consolidationRequired)} onBack={goToInfoCheck} > diff --git a/apps/desktop-wallet/src/features/send/sendModals/transfer/TransferSendModal.tsx b/apps/desktop-wallet/src/features/send/sendModals/transfer/TransferSendModal.tsx index 07362af13..f16eca338 100644 --- a/apps/desktop-wallet/src/features/send/sendModals/transfer/TransferSendModal.tsx +++ b/apps/desktop-wallet/src/features/send/sendModals/transfer/TransferSendModal.tsx @@ -58,10 +58,11 @@ export const handleTransferSend = async ( context: TxContext, posthog: PostHog, isLedger: boolean, - onLedgerError: (error: Error) => void + onLedgerError: (error: Error) => void, + consolidationRequired: boolean ) => { const { fromAddress, toAddress, lockTime: lockDateTime, assetAmounts } = transactionData - const { isSweeping, sweepUnsignedTxs, consolidationRequired, unsignedTxId, unsignedTransaction } = context + const { isSweeping, sweepUnsignedTxs, unsignedTxId, unsignedTransaction } = context if (toAddress) { const { attoAlphAmount, tokens } = getTransactionAssetAmounts(assetAmounts) diff --git a/apps/desktop-wallet/src/features/send/sendTypes.ts b/apps/desktop-wallet/src/features/send/sendTypes.ts index d249c881a..6fac711c3 100644 --- a/apps/desktop-wallet/src/features/send/sendTypes.ts +++ b/apps/desktop-wallet/src/features/send/sendTypes.ts @@ -88,7 +88,6 @@ export type TxContext = { setUnsignedTxId: (txId: string) => void setContractAddress: (contractAddress: string) => void isSweeping: boolean - consolidationRequired: boolean buildExecuteScriptTxResult: node.BuildExecuteScriptTxResult | undefined setBuildExecuteScriptTxResult: (tx: node.BuildExecuteScriptTxResult | undefined) => void }