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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERC-20 token transfer example and improvements to NFT #209
ERC-20 token transfer example and improvements to NFT #209
Changes from 18 commits
55c7031
012c5e6
72ff65b
2715a72
b4f8749
e360b47
95914a5
ee7ad2f
7d73ae0
bdacd74
0f5ad41
9108b37
8affa13
e959412
c01dac3
49dbabc
a26a56d
ee5ce68
5de7d5f
0adfb61
3bbcab0
e5f9b6f
fb8e5a8
fbed6dc
726f485
246361d
a98517d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the missing return statement in the
onCall
functionThe
onCall
function declares abytes4
return type but does not currently return any value. This will result in a compilation error and may cause unexpected behavior. Ensure that you return the appropriate selector as per the interface requirements of theGatewayEVM
.Apply this diff to add the missing return statement:
Ensure that you replace the return statement with the correct value expected by the
GatewayEVM
interface.๐ Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement revert handling logic.
The empty
onRevert
function could lead to lost tokens in case of cross-chain transfer failures. Consider implementing proper revert handling logic to ensure tokens can be recovered.Would you like me to provide an implementation for handling cross-chain transfer reverts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid hardcoding the system contract address
Hardcoding the
systemContract
address reduces flexibility and can lead to issues if the address changes across different networks or environments. Consider passing the address as a constructor parameter or providing a setter function with appropriate access control to allow for configuration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure consistent message encoding and decoding
In
transferCrossChain
, the message is encoded with two parameters:However, in
onCall
, the message is decoded expecting three parameters:This inconsistency will cause decoding errors. Ensure that the encoding and decoding formats match between these functions.
Apply this diff to align the encoding and decoding:
destination
is intended to be part of the message:destination
is not required, adjust the decoding inonCall
:Also applies to: 92-93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enhance security in
transferCrossChain
functionThe
transferCrossChain
function performs multiple external calls and token transfers, which could introduce reentrancy risks. To strengthen security:ReentrancyGuard
to prevent reentrant calls.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
Simplify origin verification in
onCall
functionComparing keccak256 hashes of byte arrays is unnecessary and gas-inefficient. Since both
messageContext.origin
andcounterparty[zrc20]
are of typebytes
, consider using a utility function to compare the byte arrays directly or, if possible, standardize on a fixed-size type likebytes32
for direct comparison. This will improve efficiency and readability.