Skip to content

Commit 81f1aa4

Browse files
committed
Improve error handling
1 parent 39678e7 commit 81f1aa4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

crates/anvil/src/evm/celo_precompile.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ pub fn celo_transfer_precompile<CTX: ContextTr>(
5151

5252
eprintln!("\t[Celo Transfer] from: {from_address:?}, to: {to_address:?}, value: {value}");
5353

54-
// Perform the transfer using JournalTr.transfer
55-
if let Err(e) = context.journal_mut().transfer(from_address, to_address, value) {
56-
eprintln!("[Celo Transfer] Transfer failed: {e:?}");
57-
result.result = InstructionResult::PrecompileError;
58-
return Ok(Some(result));
54+
// Perform the transfer using JournalTr.transfer and handle transfer errors
55+
match context.journal_mut().transfer(from_address, to_address, value) {
56+
Ok(None) => {
57+
// Transfer successful, continue
58+
}
59+
Ok(Some(transfer_error)) => {
60+
eprintln!("[Celo Transfer] Transfer failed: {transfer_error:?}");
61+
return Err(format!("Celo transfer failed: {transfer_error:?}"));
62+
}
63+
Err(e) => {
64+
eprintln!("[Celo Transfer] Journal error: {e:?}");
65+
return Err(format!("Celo transfer journal error: {e:?}"));
66+
}
5967
}
6068

6169
eprintln!("\t[Celo Transfer] Transfer successful");

0 commit comments

Comments
 (0)