From 291a22b4b60f1a92af7a00e2cdb1c53d45b5c8bc Mon Sep 17 00:00:00 2001 From: zer0dot Date: Wed, 13 Nov 2024 19:43:30 -0500 Subject: [PATCH] feat: add native functions to delegate contract --- src/helpers/NativeFunctionDelegate.sol | 38 +++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/helpers/NativeFunctionDelegate.sol b/src/helpers/NativeFunctionDelegate.sol index 51081c270..35c237e97 100644 --- a/src/helpers/NativeFunctionDelegate.sol +++ b/src/helpers/NativeFunctionDelegate.sol @@ -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"; @@ -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); } }