Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add erc7484 to msaadvanced #26

Merged
merged 5 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/MSAAdvanced.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IERC7579Account } from "./interfaces/IERC7579Account.sol";
import { IMSA } from "./interfaces/IMSA.sol";
import { ModuleManager } from "./core/ModuleManager.sol";
import { HookManager } from "./core/HookManager.sol";
import { RegistryAdapter } from "./core/RegistryAdapter.sol";

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

Expand Down Expand Up @@ -87,6 +88,7 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
external
payable
onlyExecutorModule
withRegistry(msg.sender, MODULE_TYPE_EXECUTOR)
kopy-kat marked this conversation as resolved.
Show resolved Hide resolved
returns (
bytes[] memory returnData // TODO returnData is not used
)
Expand Down Expand Up @@ -167,6 +169,7 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager {
external
payable
onlyEntryPointOrSelf
withRegistry(module, moduleTypeId)
{
if (moduleTypeId == MODULE_TYPE_VALIDATOR) _installValidator(module, initData);
else if (moduleTypeId == MODULE_TYPE_EXECUTOR) _installExecutor(module, initData);
Expand Down
31 changes: 31 additions & 0 deletions src/core/RegistryAdapter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "../interfaces/IERC7484.sol";

abstract contract RegistryAdapter {
event ERC7484RegistryConfigured(address indexed smartAccount, address indexed registry);

IERC7484 internal $registry;

modifier withRegistry(address module, uint256 moduleTypeId) {
IERC7484 registry = $registry;
if (address(registry) != address(0)) {
registry.check(module, moduleTypeId);
}
_;
}

function setRegistry(
kopy-kat marked this conversation as resolved.
Show resolved Hide resolved
IERC7484 registry,
address[] calldata attesters,
uint8 threshold
)
external
kopy-kat marked this conversation as resolved.
Show resolved Hide resolved
{
$registry = registry;
if (attesters.length > 0) {
registry.trustAttesters(threshold, attesters);
}
}
}
48 changes: 48 additions & 0 deletions src/interfaces/IERC7484.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC7484 {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* Check with Registry internal attesters */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
function check(address module) external view;

function checkForAccount(address smartAccount, address module) external view;

function check(address module, uint256 moduleType) external view;

function checkForAccount(
address smartAccount,
address module,
uint256 moduleType
)
external
view;

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* Check with external attester(s) */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

function check(address module, address attester) external view;

function check(address module, uint256 moduleType, address attester) external view;

function checkN(
address module,
address[] calldata attesters,
uint256 threshold
)
external
view;

function checkN(
address module,
uint256 moduleType,
address[] calldata attesters,
uint256 threshold
)
external
view;

function trustAttesters(uint8 threshold, address[] calldata attesters) external;
}