-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix(contracts-rfq): add forwardTo
to ZapData for Zap Actions that don't forward assets to the user
#3451
Merged
ChiTimesChi
merged 12 commits into
feat/syn-intent-router
from
fix/FbV2-zap-data-funds-recipient
Dec 10, 2024
Merged
fix(contracts-rfq): add forwardTo
to ZapData for Zap Actions that don't forward assets to the user
#3451
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5eaccd1
feat: scaffold finalToken, forwardTo in ZapDataV1
ChiTimesChi 535b4e7
feat: add finalToken, forwardTo
ChiTimesChi 1a37090
feat: scaffold TokenZap.encodeZapData
ChiTimesChi 52ba760
test: update existing tests
ChiTimesChi 08a5883
test: forwardTo scenarios
ChiTimesChi 6d7cc51
feat: token zeor address checks
ChiTimesChi 26ed1e7
feat:scaffold token forwarding
ChiTimesChi 0c7ca8b
test: more revert cases
ChiTimesChi 812a106
feat: final token forwarding
ChiTimesChi 0821a51
test: forwardTo behaviour in SIP
ChiTimesChi 2bda040
feat: support optional `forwardTo` in SIP
ChiTimesChi 4b925f9
deploy: redeploy SIP, TokenZap
ChiTimesChi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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
Ensure
finalToken_
andforwardTo_
parameters are validated appropriatelyThe addition of
finalToken_
andforwardTo_
parameters enhances the flexibility of theencodeV1
function. However, there should be explicit validations to ensure that ifforwardTo_
is not the zero address, thenfinalToken_
must also be a non-zero address, as mentioned in the documentation. Consider adding a require statement to enforce this constraint.Apply this diff to include the validation:
function encodeV1( uint16 amountPosition_, address finalToken_, address forwardTo_, address target_, bytes memory payload_ ) internal pure returns (bytes memory encodedZapData) { if (target_ == address(0)) revert ZapDataV1__TargetZeroAddress(); + if (forwardTo_ != address(0) && finalToken_ == address(0)) revert ZapDataV1__FinalTokenZeroAddress(); // Amount is encoded in [amountPosition_ .. amountPosition_ + 32), which should be within the payload. if (amountPosition_ != AMOUNT_NOT_PRESENT && (uint256(amountPosition_) + 32 > payload_.length)) { revert ZapDataV1__InvalidEncoding(); } return abi.encodePacked(VERSION, amountPosition_, finalToken_, forwardTo_, target_, payload_); }
This ensures that the function reverts if
forwardTo_
is set without a correspondingfinalToken_
, preventing potential runtime errors.Also applies to: 66-67