This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: gethify eth call errors (#2186)
fixes #2133
- Loading branch information
1 parent
8ef94ff
commit d5c3bcb
Showing
10 changed files
with
84 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ contract EthCall { | |
return block.basefee; | ||
} | ||
|
||
function doARevert() public pure { | ||
revert("you are a failure"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { EVMResult } from "@ethereumjs/vm/dist/evm/evm"; | ||
import { VM_EXCEPTION } from "./errors"; | ||
import { CodedError } from "./coded-error"; | ||
import { JsonRpcErrorCode } from "@ganache/utils"; | ||
import { Data } from "@ganache/utils"; | ||
|
||
export class CallError extends CodedError { | ||
public code: JsonRpcErrorCode; | ||
public data: string; | ||
constructor(result: EVMResult) { | ||
const execResult = result.execResult; | ||
const error = execResult.exceptionError.error; | ||
let message = VM_EXCEPTION + error; | ||
|
||
super(message, JsonRpcErrorCode.INVALID_INPUT); | ||
|
||
CodedError.captureStackTraceExtended.bind(this, message); | ||
this.name = this.constructor.name; | ||
|
||
const { returnValue } = execResult; | ||
const reason = CodedError.createRevertReason(returnValue); | ||
this.message = reason ? message + " " + reason : message; | ||
this.data = Data.from(returnValue).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters