mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9167 from ethereum/fixDocExDecode
Fix documentation example.
This commit is contained in:
commit
4cf4068020
@ -430,7 +430,13 @@ Array slices are useful to ABI-decode secondary data passed in function paramete
|
|||||||
/// Forward call to "setOwner(address)" that is implemented by client
|
/// Forward call to "setOwner(address)" that is implemented by client
|
||||||
/// after doing basic validation on the address argument.
|
/// after doing basic validation on the address argument.
|
||||||
function forward(bytes calldata _payload) external {
|
function forward(bytes calldata _payload) external {
|
||||||
bytes4 sig = abi.decode(_payload[:4], (bytes4));
|
// Since ABI decoding requires padded data, we cannot
|
||||||
|
// use abi.decode(_payload[:4], (bytes4)).
|
||||||
|
bytes4 sig =
|
||||||
|
_payload[0] |
|
||||||
|
(bytes4(_payload[1]) >> 8) |
|
||||||
|
(bytes4(_payload[2]) >> 16) |
|
||||||
|
(bytes4(_payload[3]) >> 24);
|
||||||
if (sig == bytes4(keccak256("setOwner(address)"))) {
|
if (sig == bytes4(keccak256("setOwner(address)"))) {
|
||||||
address owner = abi.decode(_payload[4:], (address));
|
address owner = abi.decode(_payload[4:], (address));
|
||||||
require(owner != address(0), "Address of owner cannot be zero.");
|
require(owner != address(0), "Address of owner cannot be zero.");
|
||||||
|
Loading…
Reference in New Issue
Block a user