Skip to content

Commit a94394a

Browse files
committed
Add EIP-7702 qa
1 parent 2018381 commit a94394a

File tree

6 files changed

+854
-20
lines changed

6 files changed

+854
-20
lines changed

Diff for: package-lock.json

+151-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"tslib": "^2.6.1"
2222
},
2323
"dependencies": {
24-
"@klaytn/ethers-ext": "^1.0.2",
24+
"@kaiachain/ethers-ext": "^1.1.1",
2525
"axios": "^1.6.5",
2626
"bls-signatures": "^2.0.2",
2727
"caver-js": "^1.11.0",
2828
"dotenv": "^16.3.2",
29-
"ethers": "^5.7.0",
29+
"ethers": "^5.7.2",
3030
"plotly": "^1.0.6"
3131
}
3232
}

Diff for: src/eip-7702/contracts/Delegation.sol

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: LGPL-3.0-only
2+
pragma solidity 0.8.25;
3+
4+
contract Delegation {
5+
uint256 public count;
6+
7+
function increment() external {
8+
count++;
9+
}
10+
11+
// It will increase count2 of Delegation2 contract
12+
function callIncrement(address _addr) external {
13+
(bool success, ) = _addr.call(abi.encodeWithSignature("increment()"));
14+
require(success, "Call failed");
15+
}
16+
17+
function getCount(address _addr) external view returns (uint256) {
18+
(bool success, bytes memory data) = _addr.staticcall(abi.encodeWithSignature("count()"));
19+
require(success, "Staticcall failed");
20+
return abi.decode(data, (uint256));
21+
}
22+
23+
// callcode has been deprecated
24+
25+
// It will increase count of Delegation contract
26+
function delegatecallIncrement(address _addr) external {
27+
(bool success, ) = _addr.delegatecall(abi.encodeWithSignature("increment()"));
28+
require(success, "Delegatecall failed");
29+
}
30+
31+
function callcodeIncrement(address _addr) external {
32+
bytes memory data = abi.encodeWithSignature("increment()");
33+
assembly {
34+
let success := callcode(gas(), _addr, 0, add(data, 0x20), mload(data), 0, 0)
35+
if iszero(success) {
36+
revert(0, 0)
37+
}
38+
}
39+
}
40+
41+
function getCodeFields(address _addr) external view returns (bytes memory code, bytes32 codehash, uint256 size) {
42+
// Testing EXTCODESIZE, EXTCODECOPY, EXTCODEHASH
43+
return (_addr.code, _addr.codehash, _addr.code.length);
44+
}
45+
}

0 commit comments

Comments
 (0)