Skip to content

Conversation

@0xLayer-3
Copy link

Changelog: erc20_transaction Safety & Logic Fixes

  1. Removed unwrap() from user_address.parse()

Before:

let caller = user_address.parse().unwrap();

After:

let caller: Address = user_address.parse()?;

Reason:
unwrap() would panic if the provided user_address string was invalid or malformed. Replaced it with typed parsing and the ? operator to return a proper Err through the existing Result type. This ensures the function fails gracefully instead of crashing at runtime.

  1. Added proper error handling for invalid ERC transfer variant

Before:

ERCTransferVariant::NA => {
error!("ERC should have a variant");
}

After:

ERCTransferVariant::NA => {
error!("ERC should have a variant");
return Err("ERC should have a valid transfer variant".into());
}

Reason:
The previous behavior only logged an error but still returned Ok((new_source, new_destination)), which falsely signaled success and could propagate inconsistent or incomplete state. Now, the function correctly returns an error when an invalid variant is encountered, making it impossible for the pipeline to continue with undefined logic.

Summary

Fixed potential runtime panic safer and more predictable error propagation.

Improved logical integrity invalid ERC transfer variants now terminate early with an explicit error.

No behavior change for valid paths; existing event and handle logic remains untouched

Changelog: erc20_transaction Safety & Logic Fixes
1. Removed unwrap() from user_address.parse()

Before:

let caller = user_address.parse().unwrap();

After:

let caller: Address = user_address.parse()?;

Reason:
unwrap() would panic if the provided user_address string was invalid or malformed.
Replaced it with typed parsing and the ? operator to return a proper Err through the existing Result type.
This ensures the function fails gracefully instead of crashing at runtime.

2. Added proper error handling for invalid ERC transfer variant

Before:

ERCTransferVariant::NA => {
    error!("ERC should have a variant");
}


After:

ERCTransferVariant::NA => {
    error!("ERC should have a variant");
    return Err("ERC should have a valid transfer variant".into());
}

Reason:
The previous behavior only logged an error but still returned Ok((new_source, new_destination)),
which falsely signaled success and could propagate inconsistent or incomplete state.
Now, the function correctly returns an error when an invalid variant is encountered,
making it impossible for the pipeline to continue with undefined logic.

Summary

Fixed potential runtime panic safer and more predictable error propagation.

Improved logical integrity invalid ERC transfer variants now terminate early with an explicit error.

No behavior change for valid paths; existing event and handle logic remains untouched
@0xLayer-3 0xLayer-3 requested a review from a team as a code owner October 28, 2025 21:39
@cla-bot
Copy link

cla-bot bot commented Oct 28, 2025

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @0xLayer-3 on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant