Skip to content

Commit

Permalink
fix(abi): handle contract reverts even if JSON-RPC returns wrong erro…
Browse files Browse the repository at this point in the history
…r code
  • Loading branch information
ArtificialPB committed Jul 30, 2024
1 parent 81d9da6 commit 372e94c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ethers-abi/src/main/kotlin/io/ethers/abi/call/ContractCall.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ abstract class ReadContractCall<C, B : ReadContractCall<C, B>>(
}

protected fun tryDecodingContractRevert(err: RpcError): ContractError {
if (err.isExecutionError) {
val isRevertMessage = err.message.contains("execution revert", true)
if (err.isExecutionError || isRevertMessage) {
when {
err.data == null && err.message.contains("execution revert", true) -> {
return ExecutionRevertedError
}
err.data == null && isRevertMessage -> return ExecutionRevertedError

err.data != null && err.data!!.isTextual -> {
val data = err.data!!.textValue()
Expand Down

0 comments on commit 372e94c

Please sign in to comment.