Skip to content

Commit 81bf8c7

Browse files
committed
ethereum: Fix ambiguity of Ganache revert
Use a more specific check, previously it was ambiguous with the Parity error code for an unsupported request.
1 parent 48ba71f commit 81bf8c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

datasource/ethereum/src/ethereum_adapter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ where
393393
// `revert` and `require` calls with a reason string can be detected.
394394

395395
const GANACHE_VM_EXECUTION_ERROR: i64 = -32000;
396+
const GANACHE_REVERT_MESSAGE: &str =
397+
"VM Exception while processing transaction: revert";
396398
const PARITY_VM_EXECUTION_ERROR: i64 = -32015;
397399
const PARITY_REVERT_PREFIX: &str = "Reverted 0x";
398400

@@ -444,7 +446,8 @@ where
444446

445447
// Check for Ganache revert.
446448
Err(web3::Error::Rpc(ref rpc_error))
447-
if rpc_error.code.code() == GANACHE_VM_EXECUTION_ERROR =>
449+
if rpc_error.code.code() == GANACHE_VM_EXECUTION_ERROR
450+
&& rpc_error.message == GANACHE_REVERT_MESSAGE =>
448451
{
449452
Err(EthereumContractCallError::Revert(
450453
rpc_error.message.clone(),

0 commit comments

Comments
 (0)