-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Replace abi.encodeWithSelector & abi.encodeWithSignature with abi.encodeCall #4293
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
Merged
frangio
merged 5 commits into
OpenZeppelin:master
from
balajipachai:replace-abi-encodewithselector-with-abi-encodecall
Jun 6, 2023
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef91e28
feat: replaces abi.encodeWithSelector & abi.encodeWithSignature with …
balajipachai f171e6f
Merge branch 'master' into replace-abi-encodewithselector-with-abi-en…
balajipachai d281193
chore: updates changeset
balajipachai 653cf08
Update big-plums-cover.md
Amxx c2fbbde
Update test/utils/ShortStrings.t.sol
balajipachai 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| 'openzeppelin-solidity': major | ||
| --- | ||
|
|
||
| Replaces abi.encodeWithSelector & abi.encodeWithSignature with abi.encodeCall | ||
|
|
||
| - WHAT the breaking change is | ||
|
|
||
| - The change replaces all occurences of abi.encodeWithSelector & abi.encodeWithSignature with abi.ecnodeCall | ||
|
|
||
| - WHY the change was made | ||
|
|
||
| - `abi.encodeWithSelector & abi.encodeWithSignature` can use with `interface.<function>.selector` to prevent `typo error`, but it `doesn't provide type checking`. | ||
|
|
||
| - HOW a consumer should update their code | ||
|
|
||
| ```` | ||
| interface miniERC20 { | ||
|
|
||
| function transfer(address to, uint256 value) external; | ||
| } | ||
|
|
||
| // works successfully | ||
| function transferData(uint256 to, uint256 value) public pure returns (bytes memory) { | ||
| return abi.encodeWithSelector(miniERC20.transfer.selector, to, value); | ||
| }``` | ||
| ```` | ||
|
|
||
| `abi.encodeCall` provides type checking during compile time. | ||
|
|
||
| ``` | ||
| function transferData(uint256 to, uint256 value) public pure returns (bytes memory) { | ||
| return abi.encodeCall(miniERC20.transfer, (to, value)); | ||
| } | ||
| ``` | ||
|
|
||
| ``` | ||
| error[5407]: TypeError: Cannot implicitly convert component at position 0 from "uint256" to "address". | ||
| ``` | ||
|
|
||
| `abi.encodeCall(function pointer, (function arguments...))` |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.