Skip to content

Commit

Permalink
feat: add native functions to delegate contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0dot committed Nov 14, 2024
1 parent e6a880a commit 291a22b
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/helpers/NativeFunctionDelegate.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;

import {IModularAccount} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol";
import {IModularAccountView} from "@erc6900/reference-implementation/interfaces/IModularAccountView.sol";
import {IAccount} from "@eth-infinitism/account-abstraction/interfaces/IAccount.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

import {ModularAccountBase} from "../account/ModularAccountBase.sol";
Expand All @@ -18,25 +19,30 @@ contract NativeFunctionDelegate {
return
// check against IAccount methods
selector == uint32(IAccount.validateUserOp.selector)
// check against IModularAccount methods
|| selector == uint32(IModularAccount.installExecution.selector)
|| selector == uint32(IModularAccount.uninstallExecution.selector)
|| selector == uint32(IModularAccount.installValidation.selector)
|| selector == uint32(IModularAccount.uninstallValidation.selector)
|| selector == uint32(IModularAccount.execute.selector)
|| selector == uint32(IModularAccount.executeBatch.selector)
|| selector == uint32(IModularAccount.executeWithRuntimeValidation.selector)
|| selector == uint32(IModularAccount.accountId.selector)
// check against ModularAccount methods
|| selector == uint32(ModularAccountBase.installExecution.selector)
|| selector == uint32(ModularAccountBase.uninstallExecution.selector)
|| selector == uint32(ModularAccountBase.installValidation.selector)
|| selector == uint32(ModularAccountBase.uninstallValidation.selector)
|| selector == uint32(ModularAccountBase.execute.selector)
|| selector == uint32(ModularAccountBase.executeBatch.selector)
|| selector == uint32(ModularAccountBase.executeWithRuntimeValidation.selector)
|| selector == uint32(ModularAccountBase.accountId.selector)
|| selector == uint32(ModularAccountBase.performCreate.selector)
|| selector == uint32(ModularAccountBase.invalidateDeferredValidationInstallNonce.selector)
|| selector == uint32(ModularAccountBase.executeUserOp.selector)
|| selector == uint32(ModularAccountBase.isValidSignature.selector)
// check against IModularAccountView methods
|| selector == uint32(IModularAccountView.getExecutionData.selector)
|| selector == uint32(IModularAccountView.getValidationData.selector)
// check against IERC165 methods
|| selector == uint32(IERC165.supportsInterface.selector)
// check against UUPSUpgradeable methods
|| selector == uint32(UUPSUpgradeable.proxiableUUID.selector)
|| selector == uint32(UUPSUpgradeable.upgradeToAndCall.selector)
// check against IModularAccountView methods
|| selector == uint32(IModularAccountView.getExecutionData.selector)
|| selector == uint32(IModularAccountView.getValidationData.selector)
// check against ModularAccount methods
|| selector == uint32(ModularAccountBase.performCreate.selector)
|| selector == uint32(ModularAccountBase.invalidateDeferredValidationInstallNonce.selector);
// Check against token receiver methods
|| selector == uint32(IERC721Receiver.onERC721Received.selector)
|| selector == uint32(IERC1155Receiver.onERC1155Received.selector)
|| selector == uint32(IERC1155Receiver.onERC1155BatchReceived.selector);
}
}

0 comments on commit 291a22b

Please sign in to comment.