* Improves the way we parse the error message on getDataFromNodeErrorMessage for supporting trezor response * Fix trezor execution not working properly * Add parameter to processTransaction in ApproveTxModal Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
parent
0fb1824f49
commit
ce43a97bee
|
@ -32,6 +32,7 @@ interface ProcessTransactionArgs {
|
|||
safeAddress: string
|
||||
tx: Transaction
|
||||
userAddress: string
|
||||
thresholdReached: boolean
|
||||
}
|
||||
|
||||
type ProcessTransactionAction = ThunkAction<Promise<void | string>, 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) {
|
||||
|
|
Binary file not shown.
|
@ -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 <20> 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:
|
||||
// {
|
||||
|
|
|
@ -105,6 +105,7 @@ export const ApproveTxModal = ({
|
|||
userAddress,
|
||||
notifiedTransaction: TX_NOTIFICATION_TYPES.CONFIRMATION_TX,
|
||||
approveAndExecute: canExecute && approveAndExecute && isTheTxReadyToBeExecuted,
|
||||
thresholdReached,
|
||||
}),
|
||||
)
|
||||
onClose()
|
||||
|
|
Loading…
Reference in New Issue