|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {OperationCenterInterface} from \"./interfaces/IOperationCenter.sol\";\n\ncontract AccountProxy {\n\n // auth is shared storage with AccountProxy and any OpCode.\n mapping(address => bool) internal _auth;\n\n address internal immutable opCenterAddress;\n\n constructor(address _opCenterAddress) {\n opCenterAddress = _opCenterAddress;\n }\n\n fallback() external payable {\n delegate(msg.sig);\n }\n\n receive() external payable {\n if (msg.sig != 0x00000000) {\n delegate(msg.sig);\n }\n }\n\n function delegate(bytes4 _sig) internal {\n address _opCodeAddress = OperationCenterInterface(opCenterAddress)\n .getOpCodeAddress(_sig);\n require(_opCodeAddress != address(0), \"CHFRY Account: Not found OpCode\");\n assembly {\n calldatacopy(0, 0, calldatasize())\n let result := delegatecall(gas(), _opCodeAddress, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n switch result\n case 0 { revert(0, returndatasize()) }\n default { return(0, returndatasize()) }\n }\n }\n}\n"
|