Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/logic/safe/store/actions/processTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface ProcessTransactionArgs {
safeAddress: string
tx: Transaction
userAddress: string
thresholdReached: boolean
}

type ProcessTransactionAction = ThunkAction<Promise<void | string>, AppReduxState, DispatchReturn, AnyAction>
Expand All @@ -42,6 +43,7 @@ export const processTransaction = ({
safeAddress,
tx,
userAddress,
thresholdReached,
}: ProcessTransactionArgs): ProcessTransactionAction => async (
dispatch: Dispatch,
getState: () => AppReduxState,
Expand All @@ -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) {
Expand Down
Binary file modified src/logic/safe/transactions/__tests__/gas.test.ts
Binary file not shown.
23 changes: 22 additions & 1 deletion src/logic/safe/transactions/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const ApproveTxModal = ({
userAddress,
notifiedTransaction: TX_NOTIFICATION_TYPES.CONFIRMATION_TX,
approveAndExecute: canExecute && approveAndExecute && isTheTxReadyToBeExecuted,
thresholdReached,
}),
)
onClose()
Expand Down