Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog: erc20_transaction Safety & Logic Fixes
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.
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