Skip to content

Commit c0129bc

Browse files
authored
feat: update contracts (#41)
## Summary * updated v1 MSCA and plugins * updated v2 MSCA and modules (WIP) ## Detail ### Changeset * v1 MSCA and plugins * fix warnings * enshrine `DefaultCallbackHandler` * v2 MSCA and modules (WIP) * new progress on 6900 v0.8 accounts and modules ### Checklist - [x] Did you add new tests and confirm all tests pass? (`yarn test`) - [ ] Did you update relevant docs? (docs are found in the `docs` folder) - [x] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [x] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [ ] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`) - [x] Did you run lint (`yarn lint`) and fix any issues? - [x] Did you run formatter (`yarn format:check`) and fix any issues (`yarn format:write`)? ## Testing * Tests have been added & updated * Coverage has also been re-enabled ## Documentation n/a
1 parent d395e5e commit c0129bc

File tree

96 files changed

+2982
-3559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2982
-3559
lines changed

.github/workflows/coverage.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ jobs:
2020
- name: Setup environment
2121
uses: ./.github/actions/setup
2222

23-
# TODO report and check coverage
23+
# TODO: fail the build if coverage is below the threshold
24+
# TODO: print the coverage report in the github output
25+
- name: Run Test Coverage
26+
run: yarn coverage

.licenseignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GPL-3.0
2+
pkg:npm/erc6900-reference-implementation

foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ fs_permissions = [{ access = "read-write", path = "./gas"},
33
{ access = "read", path = "./test/fixtures"}]
44
src = 'src'
55
out = 'out'
6-
libs = ['lib']
6+
libs = ['lib', 'node_modules']
77
solc_version = "0.8.24"
88
test = 'test'
99
via_ir = true
1010
auto_detect_solc = false
1111
auto_detect_remappings = false
12+
deny_warnings = true
1213

1314
[fuzz]
1415
runs = 1024

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"scripts": {
66
"clean": "rm -rf cache artifacts typechain-types",
77
"build": "forge build",
8-
"lint": "solhint -w 112 -c .solhint-src.json './src/**/*.sol' && solhint -w 228 -c .solhint-test.json './test/**/*.sol' && solhint -w 0 -c .solhint-script.json './script/**/*.sol'",
8+
"lint": "solhint -w 105 -c .solhint-src.json './src/**/*.sol' && solhint -w 228 -c .solhint-test.json './test/**/*.sol' && solhint -w 0 -c .solhint-script.json './script/**/*.sol'",
99
"test": "forge test -vv",
1010
"gasreport": "forge test --gas-report > gas/reports/gas-report.txt",
11-
"coverage": "forge coverage --ir-minimum",
11+
"coverage": "forge coverage",
1212
"format:check": "forge fmt --check",
1313
"format:write": "forge fmt"
1414
},
@@ -20,7 +20,8 @@
2020
"@openzeppelin/contracts-upgradeable": "5.0.2",
2121
"fcl": "github:rdubois-crypto/FreshCryptoLib#8179e08cac72072bd260796633fec41fdfd5b441",
2222
"forge-std": "github:foundry-rs/forge-std#v1.9.2",
23-
"solady": "0.0.243"
23+
"solady": "0.0.243",
24+
"erc6900-reference-implementation": "0.8.0-rc.6"
2425
},
2526
"devDependencies": {
2627
"solhint": "^5.0.3"

remappings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
@solady/=node_modules/solady/src/
66
@fcl/=node_modules/fcl/solidity/src/
77
forge-std/=node_modules/forge-std/
8+
@erc6900/reference-implementation/=node_modules/erc6900-reference-implementation/src/
9+
@eth-infinitism/account-abstraction/=lib/account-abstraction/contracts/

src/msca/6900/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Acknowledgements
2+
The contracts in this folder are based on the ERC-6900 specification and are significantly influenced by the design of the ERC-6900 reference implementation.

src/msca/6900/shared/common/Errors.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ error InvalidItem();
5959

6060
// v2 NotImplemented
6161
error NotImplementedFunction(bytes4 selector, uint32 entityId);
62+
63+
error SignatureInflation();

src/msca/6900/v0.7/account/UpgradableMSCA.sol

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
pragma solidity 0.8.24;
2020

21+
import {DefaultCallbackHandler} from "../../../../callback/DefaultCallbackHandler.sol";
2122
import {ExecutionUtils} from "../../../../utils/ExecutionUtils.sol";
2223
import {InvalidInitializationInput} from "../../shared/common/Errors.sol";
2324
import {FunctionReference} from "../common/Structs.sol";
@@ -26,13 +27,17 @@ import {BaseMSCA} from "./BaseMSCA.sol";
2627
import {IEntryPoint} from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
2728
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
2829

30+
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
31+
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
32+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
33+
2934
/**
3035
* @dev Leverage {ERC1967Proxy} brought by UUPS proxies, when this contract is set as the implementation behind such a
3136
* proxy.
3237
* The {_authorizeUpgrade} function is overridden here so more granular ACLs to the upgrade mechanism should be enforced
3338
* by plugins.
3439
*/
35-
contract UpgradableMSCA is BaseMSCA, UUPSUpgradeable {
40+
contract UpgradableMSCA is BaseMSCA, DefaultCallbackHandler, UUPSUpgradeable {
3641
using ExecutionUtils for address;
3742

3843
event UpgradableMSCAInitialized(address indexed account, address indexed entryPointAddress);
@@ -72,6 +77,17 @@ contract UpgradableMSCA is BaseMSCA, UUPSUpgradeable {
7277
emit UpgradableMSCAInitialized(address(this), address(entryPoint));
7378
}
7479

80+
function supportsInterface(bytes4 interfaceId)
81+
public
82+
view
83+
override(BaseMSCA, DefaultCallbackHandler)
84+
returns (bool)
85+
{
86+
// BaseMSCA has already implemented ERC165
87+
return BaseMSCA.supportsInterface(interfaceId) || interfaceId == type(IERC721Receiver).interfaceId
88+
|| interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC1271).interfaceId;
89+
}
90+
7591
/// @inheritdoc UUPSUpgradeable
7692
function upgradeToAndCall(address newImplementation, bytes memory data)
7793
public

src/msca/6900/v0.7/libs/SelectorRegistryLib.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import {IAggregator} from "@account-abstraction/contracts/interfaces/IAggregator
2828
import {IPaymaster} from "@account-abstraction/contracts/interfaces/IPaymaster.sol";
2929
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
3030

31+
import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipient.sol";
32+
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
33+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
3134
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
3235

3336
library SelectorRegistryLib {
@@ -61,7 +64,10 @@ library SelectorRegistryLib {
6164
|| selector == IAccountLoupe.getInstalledPlugins.selector || selector == VALIDATE_USER_OP
6265
|| selector == GET_ENTRYPOINT || selector == GET_NONCE || selector == INITIALIZE_UPGRADABLE_MSCA
6366
|| selector == INITIALIZE_SINGLE_OWNER_MSCA || selector == TRANSFER_NATIVE_OWNERSHIP
64-
|| selector == RENOUNCE_NATIVE_OWNERSHIP || selector == GET_NATIVE_OWNER;
67+
|| selector == RENOUNCE_NATIVE_OWNERSHIP || selector == GET_NATIVE_OWNER
68+
|| selector == IERC1155Receiver.onERC1155Received.selector
69+
|| selector == IERC1155Receiver.onERC1155BatchReceived.selector
70+
|| selector == IERC721Receiver.onERC721Received.selector || selector == IERC777Recipient.tokensReceived.selector;
6571
}
6672

6773
function _isErc4337FunctionSelector(bytes4 selector) internal pure returns (bool) {

src/msca/6900/v0.7/plugins/BasePlugin.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ abstract contract BasePlugin is IPlugin, ERC165 {
8282
virtual
8383
returns (uint256 validationData)
8484
{
85-
(functionId, userOp, userOpHash);
85+
(functionId, userOp, userOpHash, validationData);
8686
revert NotImplemented(msg.sig, functionId);
8787
}
8888

@@ -98,7 +98,7 @@ abstract contract BasePlugin is IPlugin, ERC165 {
9898
virtual
9999
returns (uint256 validationData)
100100
{
101-
(functionId, userOp, userOpHash);
101+
(functionId, userOp, userOpHash, validationData);
102102
revert NotImplemented(msg.sig, functionId);
103103
}
104104

@@ -145,7 +145,7 @@ abstract contract BasePlugin is IPlugin, ERC165 {
145145
virtual
146146
returns (bytes memory context)
147147
{
148-
(functionId, sender, value, data);
148+
(functionId, sender, value, data, context);
149149
revert NotImplemented(msg.sig, functionId);
150150
}
151151

0 commit comments

Comments
 (0)