Skip to content

Commit

Permalink
Fix safeTxGas estimation for viem
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniSomoza committed Apr 29, 2024
1 parent 707c1ec commit 9090d93
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/protocol-kit/src/utils/transactions/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ function decodeSafeTxGas(encodedDataResponse: string): string {

type GnosisChainEstimationError = { info: { error: { data: string | { data: string } } } }
type EthersEstimationError = { data: string }
type EstimationError = Error & EthersEstimationError & GnosisChainEstimationError
type ViemEstimationError = { info: { error: { message: string } } }
type EstimationError = Error &
EthersEstimationError &
GnosisChainEstimationError &
ViemEstimationError

/**
* Parses the SafeTxGas estimation response from different providers.
Expand All @@ -417,6 +421,12 @@ function parseSafeTxGasErrorResponse(error: EstimationError) {
return decodeSafeTxGas(ethersData)
}

// viem
const viemError = error?.info?.error?.message
if (viemError) {
return decodeSafeTxGas(viemError)
}

// gnosis-chain
const gnosisChainProviderData = error?.info?.error?.data

Expand Down

0 comments on commit 9090d93

Please sign in to comment.