-
Notifications
You must be signed in to change notification settings - Fork 0
/
callData.sol
37 lines (31 loc) · 875 Bytes
/
callData.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract CallData {
function getCallDataSize() external pure returns(uint256 a) {
assembly {
a := calldatasize()
}
}
function getCallDataSig() external pure returns(bytes4) {
bytes4 sig;
assembly {
let free_mem := mload(0x40)
calldatacopy(free_mem, 0, 4)
sig := mload(free_mem)
}
require(sig == msg.sig, "wrong function signature");
return sig;
}
function callDummy() external view returns(bytes4) {
//return dummy() private does not return msg.sig
return this.dummy();
}
function dummy() external pure returns(bytes4) {
return msg.sig;
}
}
contract A {
function dummy() pure public returns(bytes4) {
return msg.sig;
}
}