From f27f45467d505dca4e6cda78f28ebcccebb1d4a5 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Fri, 10 Nov 2023 14:05:40 +0100 Subject: [PATCH] Custom Registry not needed anymore --- contracts/core/eip6551/ERC6551Registry.sol | 62 ------------------- .../eip6551/interfaces/IERC6551Registry.sol | 36 ----------- 2 files changed, 98 deletions(-) delete mode 100644 contracts/core/eip6551/ERC6551Registry.sol delete mode 100644 contracts/core/eip6551/interfaces/IERC6551Registry.sol diff --git a/contracts/core/eip6551/ERC6551Registry.sol b/contracts/core/eip6551/ERC6551Registry.sol deleted file mode 100644 index 3c28f79..0000000 --- a/contracts/core/eip6551/ERC6551Registry.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; - -/* solhint-disable reason-string */ - -import "@openzeppelin/contracts/utils/Create2.sol"; -import "./interfaces/IERC6551Registry.sol"; - -contract ERC6551Registry is IERC6551Registry { - error InitializationFailed(); - - function createAccount( - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt, - bytes calldata initData - ) external returns (address) { - bytes memory code = _creationCode(implementation, chainId, tokenContract, tokenId, salt); - - address _account = Create2.computeAddress(bytes32(salt), keccak256(code)); - - if (_account.code.length != 0) return _account; - - _account = Create2.deploy(0, bytes32(salt), code); - - if (initData.length != 0) { - (bool success,) = _account.call(initData); - if (!success) revert InitializationFailed(); - } - - emit AccountCreated(_account, implementation, chainId, tokenContract, tokenId, salt); - - return _account; - } - - function account(address implementation, uint256 chainId, address tokenContract, uint256 tokenId, uint256 salt) - external - view - returns (address) - { - bytes32 bytecodeHash = keccak256(_creationCode(implementation, chainId, tokenContract, tokenId, salt)); - - return Create2.computeAddress(bytes32(salt), bytecodeHash); - } - - function _creationCode( - address implementation_, - uint256 chainId_, - address tokenContract_, - uint256 tokenId_, - uint256 salt_ - ) internal pure returns (bytes memory) { - return abi.encodePacked( - hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73", - implementation_, - hex"5af43d82803e903d91602b57fd5bf3", - abi.encode(salt_, chainId_, tokenContract_, tokenId_) - ); - } -} diff --git a/contracts/core/eip6551/interfaces/IERC6551Registry.sol b/contracts/core/eip6551/interfaces/IERC6551Registry.sol deleted file mode 100644 index de97b68..0000000 --- a/contracts/core/eip6551/interfaces/IERC6551Registry.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; - -interface IERC6551Registry { - /// @dev The registry SHALL emit the AccountCreated event upon successful account creation - event AccountCreated( - address account, address implementation, uint256 chainId, address tokenContract, uint256 tokenId, uint256 salt - ); - - /// @dev Creates a token bound account for an ERC-721 token. - /// - /// If account has already been created, returns the account address without calling create2. - /// - /// If initData is not empty and account has not yet been created, calls account with - /// provided initData after creation. - /// - /// Emits AccountCreated event. - /// - /// @return the address of the account - function createAccount( - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt, - bytes calldata initData - ) external returns (address); - - /// @dev Returns the computed address of a token bound account - /// - /// @return The computed address of the account - function account(address implementation, uint256 chainId, address tokenContract, uint256 tokenId, uint256 salt) - external - view - returns (address); -}