diff --git a/src/logic/safe/store/actions/processTransaction.ts b/src/logic/safe/store/actions/processTransaction.ts index 8d31d343ab..a8a352bf41 100644 --- a/src/logic/safe/store/actions/processTransaction.ts +++ b/src/logic/safe/store/actions/processTransaction.ts @@ -32,6 +32,7 @@ interface ProcessTransactionArgs { safeAddress: string tx: Transaction userAddress: string + thresholdReached: boolean } type ProcessTransactionAction = ThunkAction, AppReduxState, DispatchReturn, AnyAction> @@ -42,6 +43,7 @@ export const processTransaction = ({ safeAddress, tx, userAddress, + thresholdReached, }: ProcessTransactionArgs): ProcessTransactionAction => async ( dispatch: Dispatch, getState: () => AppReduxState, @@ -56,7 +58,7 @@ export const processTransaction = ({ const isExecution = approveAndExecute || (await shouldExecuteTransaction(safeInstance, nonce, lastTx)) const safeVersion = await getCurrentSafeVersion(safeInstance) - const preApprovingOwner = approveAndExecute ? userAddress : undefined + const preApprovingOwner = approveAndExecute && !thresholdReached ? userAddress : undefined let sigs = generateSignaturesFromTxConfirmations(tx.confirmations, preApprovingOwner) if (!sigs) { diff --git a/src/logic/safe/transactions/__tests__/gas.test.ts b/src/logic/safe/transactions/__tests__/gas.test.ts index 828d1e64f6..028796ad20 100644 Binary files a/src/logic/safe/transactions/__tests__/gas.test.ts and b/src/logic/safe/transactions/__tests__/gas.test.ts differ diff --git a/src/logic/safe/transactions/gas.ts b/src/logic/safe/transactions/gas.ts index fa220bacd8..7e20aedebe 100644 --- a/src/logic/safe/transactions/gas.ts +++ b/src/logic/safe/transactions/gas.ts @@ -25,6 +25,21 @@ const parseRequiredTxGasResponse = (data: string): number => { return data.match(/.{2}/g)?.reduce(reducer, 0) } +interface ErrorDataJson extends JSON { + originalError?: { + data?: string + } + data?: string +} + +const getJSONOrNullFromString = (stringInput: string): ErrorDataJson | null => { + try { + return JSON.parse(stringInput) + } catch (error) { + return null + } +} + // Parses the result from the error message (GETH, OpenEthereum/Parity and Nethermind) and returns the data value export const getDataFromNodeErrorMessage = (errorMessage: string): string | undefined => { // Replace illegal characters that often comes within the error string (like � for example) @@ -35,7 +50,13 @@ export const getDataFromNodeErrorMessage = (errorMessage: string): string | unde const [, ...error] = normalizedErrorString.split('\n') try { - const errorAsJSON = JSON.parse(error.join('')) + const errorAsString = error.join('') + const errorAsJSON = getJSONOrNullFromString(errorAsString) + + // Trezor wallet returns the error not as an JSON object but directly as string + if (!errorAsJSON) { + return errorAsString.length ? errorAsString : undefined + } // For new GETH nodes they will return the data as error in the format: // { diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx index 88c5c99437..f09395b108 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx @@ -105,6 +105,7 @@ export const ApproveTxModal = ({ userAddress, notifiedTransaction: TX_NOTIFICATION_TYPES.CONFIRMATION_TX, approveAndExecute: canExecute && approveAndExecute && isTheTxReadyToBeExecuted, + thresholdReached, }), ) onClose()