From 86d2388a3ff879dfda5257e60f3e1db6f596a3c1 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 18 Jan 2021 11:27:14 -0300 Subject: [PATCH 1/5] Improves the way we parse the error message on getDataFromNodeErrorMessage for supporting trezor response --- .../safe/transactions/__tests__/gas.test.ts | Bin 7372 -> 8115 bytes src/logic/safe/transactions/gas.ts | 24 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/logic/safe/transactions/__tests__/gas.test.ts b/src/logic/safe/transactions/__tests__/gas.test.ts index 828d1e64f6ff53355619733c309af0a4d4c98555..2ab2c3a7635ea26eb2c423fd0d8d4e32b93d68e4 100644 GIT binary patch delta 153 zcmX?Ox!HchNtwwHm_;Tl2#HD;r4|?D=M|?aq!s1oDwGtZR^=Bdlqcroq?SzH$Zs_H zoai}E6N3~BbuKOiAV>zPErBWvf@!q{ODQO*yA~DY7g;H!R-`7EmSpDVDHNrar52T> krdTP& { 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 + } // For new GETH nodes they will return the data as error in the format: // { @@ -77,6 +98,7 @@ export const getGasEstimationTxResponse = async (txConfig: { const web3 = getWeb3() try { const result = await web3.eth.call(txConfig) + debugger // GETH Nodes (geth version < v1.9.24) // In case that the gas is not enough we will receive an EMPTY data From f2f6bbdfad0cc359f6a922bfdf674bfa889268e2 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 18 Jan 2021 11:31:54 -0300 Subject: [PATCH 2/5] Removes debugger --- src/logic/safe/transactions/gas.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/logic/safe/transactions/gas.ts b/src/logic/safe/transactions/gas.ts index 1c0bd71889..2c471d6859 100644 --- a/src/logic/safe/transactions/gas.ts +++ b/src/logic/safe/transactions/gas.ts @@ -98,7 +98,6 @@ export const getGasEstimationTxResponse = async (txConfig: { const web3 = getWeb3() try { const result = await web3.eth.call(txConfig) - debugger // GETH Nodes (geth version < v1.9.24) // In case that the gas is not enough we will receive an EMPTY data From 4a1ebbc12cf391d2023699131b9dc726162f0622 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 18 Jan 2021 16:33:40 +0100 Subject: [PATCH 3/5] Fix trezor execution not working properly --- src/logic/safe/store/actions/processTransaction.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { From 66503b9baedd5e586610175cd015d7a7c95ac21d Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 18 Jan 2021 16:35:41 +0100 Subject: [PATCH 4/5] Add parameter to processTransaction in ApproveTxModal --- .../Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx | 1 + 1 file changed, 1 insertion(+) 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() From 083122e7d14db66c024ce69f13461a436765bab6 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 18 Jan 2021 13:03:06 -0300 Subject: [PATCH 5/5] Fix tests --- .../safe/transactions/__tests__/gas.test.ts | Bin 8115 -> 8122 bytes src/logic/safe/transactions/gas.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logic/safe/transactions/__tests__/gas.test.ts b/src/logic/safe/transactions/__tests__/gas.test.ts index 2ab2c3a7635ea26eb2c423fd0d8d4e32b93d68e4..028796ad206923d510f12579a643e819f097a517 100644 GIT binary patch delta 24 fcmdmNzsr7uC=0uONKtB4e$ixmA?wWnEXmRUY?lZX delta 21 bcmdmGzuA6+D9h$PJ`VPctFxGa3>`rLT2BXP diff --git a/src/logic/safe/transactions/gas.ts b/src/logic/safe/transactions/gas.ts index 2c471d6859..7e20aedebe 100644 --- a/src/logic/safe/transactions/gas.ts +++ b/src/logic/safe/transactions/gas.ts @@ -55,7 +55,7 @@ export const getDataFromNodeErrorMessage = (errorMessage: string): string | unde // Trezor wallet returns the error not as an JSON object but directly as string if (!errorAsJSON) { - return errorAsString + return errorAsString.length ? errorAsString : undefined } // For new GETH nodes they will return the data as error in the format: