Skip to content

Commit 645bcb4

Browse files
committed
add msg.data processing functions to Context
1 parent 93d35e2 commit 645bcb4

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

contracts/utils/_Context.sol

+13
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,17 @@ abstract contract _Context is _IContext {
1010
function _msgSender() internal view virtual returns (address msgSender) {
1111
msgSender = msg.sender;
1212
}
13+
14+
function _msgData() internal view virtual returns (bytes calldata msgData) {
15+
msgData = msg.data;
16+
}
17+
18+
function _calldataSuffixLength()
19+
internal
20+
view
21+
virtual
22+
returns (uint256 length)
23+
{
24+
length = 0;
25+
}
1326
}

contracts/utils/_MetaTransactionContext.sol

+24
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,28 @@ abstract contract _MetaTransactionContext is _Context {
4646
msgSender = msg.sender;
4747
}
4848
}
49+
50+
function _msgData()
51+
internal
52+
view
53+
virtual
54+
override
55+
returns (bytes calldata msgData)
56+
{
57+
if (msg.sender == address(this)) {
58+
msgData = msg.data[:msg.data.length - _calldataSuffixLength()];
59+
} else {
60+
msgData = msg.data;
61+
}
62+
}
63+
64+
function _calldataSuffixLength()
65+
internal
66+
view
67+
virtual
68+
override
69+
returns (uint256 length)
70+
{
71+
length = 20;
72+
}
4973
}

0 commit comments

Comments
 (0)