Skip to content

Commit

Permalink
Update cheatsheet.rst
Browse files Browse the repository at this point in the history
The documentation currently says:

````
``abi.encodeCall(function functionPointer, (...)) returns (bytes memory)``: ABI-encodes a call to ``functionPointer`` with the arguments found in the
  tuple. Performs a full type-check, ensuring the types match the function signature. Result equals ``abi.encodeWithSelector(functionPointer.selector, (...))``
````

However, this is not correct.

`abi.encodeWithSelector` does not take a tuple as a second argument, instead, it takes an unended list of arguments. Saying these two are identical, is then not correct:

- `abi.encodeCall(function functionPointer, (...)) `
- `abi.encodeWithSelector(functionPointer.selector, (...))`

It should be that these two are identical:

- `abi.encodeCall(function functionPointer, (...)) `
- `abi.encodeWithSelector(functionPointer.selector, ...)`

subtle, but maybe there is a clearly way to say that `encodeWithSelector` is the same as the unpacked tuple from `encodeCall`.
  • Loading branch information
PatrickAlphaC committed Apr 27, 2024
1 parent 2c3fc90 commit 61ced0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/cheatsheet.rst
Expand Up @@ -23,7 +23,7 @@ ABI Encoding and Decoding Functions
- ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory)``: :ref:`ABI <ABI>`-encodes
the given arguments starting from the second and prepends the given four-byte selector
- ``abi.encodeCall(function functionPointer, (...)) returns (bytes memory)``: ABI-encodes a call to ``functionPointer`` with the arguments found in the
tuple. Performs a full type-check, ensuring the types match the function signature. Result equals ``abi.encodeWithSelector(functionPointer.selector, (...))``
tuple. Performs a full type-check, ensuring the types match the function signature. Result equals ``abi.encodeWithSelector(functionPointer.selector, ...)``
- ``abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)``: Equivalent
to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature))), ...)``

Expand Down

0 comments on commit 61ced0d

Please sign in to comment.