Skip to content

Commit 4f27201

Browse files
authored
Merge pull request #26 from erc7579/feature/add-erc7484
feat: add erc7484 to msaadvanced
2 parents 338bf8a + 7374cb6 commit 4f27201

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

src/MSAAdvanced.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IERC7579Account } from "./interfaces/IERC7579Account.sol";
1010
import { IMSA } from "./interfaces/IMSA.sol";
1111
import { ModuleManager } from "./core/ModuleManager.sol";
1212
import { HookManager } from "./core/HookManager.sol";
13+
import { RegistryAdapter } from "./core/RegistryAdapter.sol";
1314

1415
/**
1516
* @author zeroknots.eth | rhinestone.wtf
@@ -18,7 +19,7 @@ import { HookManager } from "./core/HookManager.sol";
1819
* This account implements ExecType: DEFAULT and TRY.
1920
* Hook support is implemented
2021
*/
21-
contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
22+
contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager, RegistryAdapter {
2223
using ExecutionLib for bytes;
2324
using ModeLib for ModeCode;
2425

@@ -85,6 +86,7 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
8586
payable
8687
onlyExecutorModule
8788
withHook
89+
withRegistry(msg.sender, MODULE_TYPE_EXECUTOR)
8890
returns (
8991
bytes[] memory returnData // TODO returnData is not used
9092
)
@@ -162,6 +164,7 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
162164
payable
163165
onlyEntryPointOrSelf
164166
withHook
167+
withRegistry(module, moduleTypeId)
165168
{
166169
if (!IModule(module).isModuleType(moduleTypeId)) revert MismatchModuleTypeId(moduleTypeId);
167170

src/core/RegistryAdapter.sol

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.23;
3+
4+
import { IERC7484 } from "../interfaces/IERC7484.sol";
5+
import { AccountBase } from "./AccountBase.sol";
6+
7+
/**
8+
* @title RegistryAdapter
9+
* @author kopy-kat | rhinestone.wtf
10+
* @dev This contract uses ERC-7484 to check if a module is attested to and exposes a modifier to
11+
* use it.
12+
*/
13+
abstract contract RegistryAdapter is AccountBase {
14+
event ERC7484RegistryConfigured(address indexed smartAccount, address indexed registry);
15+
16+
IERC7484 internal $registry;
17+
18+
modifier withRegistry(address module, uint256 moduleTypeId) {
19+
IERC7484 registry = $registry;
20+
if (address(registry) != address(0)) {
21+
registry.check(module, moduleTypeId);
22+
}
23+
_;
24+
}
25+
26+
function setRegistry(
27+
IERC7484 registry,
28+
address[] calldata attesters,
29+
uint8 threshold
30+
)
31+
external
32+
onlyEntryPointOrSelf
33+
{
34+
$registry = registry;
35+
if (attesters.length > 0) {
36+
registry.trustAttesters(threshold, attesters);
37+
}
38+
}
39+
}

src/interfaces/IERC7484.sol

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
interface IERC7484 {
5+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
6+
/* Check with Registry internal attesters */
7+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
8+
function check(address module) external view;
9+
10+
function checkForAccount(address smartAccount, address module) external view;
11+
12+
function check(address module, uint256 moduleType) external view;
13+
14+
function checkForAccount(
15+
address smartAccount,
16+
address module,
17+
uint256 moduleType
18+
)
19+
external
20+
view;
21+
22+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
23+
/* Check with external attester(s) */
24+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
25+
26+
function check(address module, address attester) external view;
27+
28+
function check(address module, uint256 moduleType, address attester) external view;
29+
30+
function checkN(
31+
address module,
32+
address[] calldata attesters,
33+
uint256 threshold
34+
)
35+
external
36+
view;
37+
38+
function checkN(
39+
address module,
40+
uint256 moduleType,
41+
address[] calldata attesters,
42+
uint256 threshold
43+
)
44+
external
45+
view;
46+
47+
function trustAttesters(uint8 threshold, address[] calldata attesters) external;
48+
}

0 commit comments

Comments
 (0)