From f982b0acb07a3fb7bab5f98619d446be2850e653 Mon Sep 17 00:00:00 2001 From: Advaith Date: Wed, 28 Dec 2022 19:15:34 -0500 Subject: [PATCH] feat: Registry --- src/registry/Registry.sol | 23 +++++++++++++++++++++++ test/TestEnvironment.sol | 6 ++++++ test/registry/Registry.sol | 16 ++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/registry/Registry.sol create mode 100644 test/registry/Registry.sol diff --git a/src/registry/Registry.sol b/src/registry/Registry.sol new file mode 100644 index 0000000..6f8783a --- /dev/null +++ b/src/registry/Registry.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import "solmate/auth/Owned.sol"; + +/// @notice Registry - Allows an admin to attest data on-chain +contract Registry is Owned { + struct RegistryItem { + address admin; + string contractType; + uint256 chainId; + } + + mapping(address => RegistryItem) registry; + + constructor(address _owner) Owned(_owner) {} + + /// @notice add an item to the registy + /// @dev Can only be called by the registry owner + function addToRegistry(RegistryItem memory item) public onlyOwner { + registry[item.admin] = item; + } +} diff --git a/test/TestEnvironment.sol b/test/TestEnvironment.sol index 317190b..fe55388 100644 --- a/test/TestEnvironment.sol +++ b/test/TestEnvironment.sol @@ -7,6 +7,7 @@ import {EIP1167Factory} from "../src/patterns/EIP1167Factory.sol"; import {ImmutableArgsCloneFactory} from "../src/patterns/immutable-args/ImmutableArgsCloneFactory.sol"; import {ImmutableArgsCloneFactory} from "../src/patterns/immutable-args/ImmutableArgsCloneFactory.sol"; import {Create3Factory} from "../src/patterns/create3/Create3Factory.sol"; +import {Registry} from "../src/registry/Registry.sol"; contract TestEnvironment is Test { /// @notice EIP1167 factory @@ -18,6 +19,9 @@ contract TestEnvironment is Test { /// @notice Create3Factory Create3Factory public create3Factory; + /// @notice vanilla registry + Registry public registry; + uint256 public constant privateKey = 11111111111; /// @notice deployer nonce (test setup deplyoer) @@ -34,5 +38,7 @@ contract TestEnvironment is Test { immutableArgsCloneFactory = new ImmutableArgsCloneFactory(); create3Factory = new Create3Factory(address(this)); + + registry = new Registry(owner); } } diff --git a/test/registry/Registry.sol b/test/registry/Registry.sol new file mode 100644 index 0000000..207689a --- /dev/null +++ b/test/registry/Registry.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import {TestEnvironment} from "../TestEnvironment.sol"; +import {console2} from "forge-std/console2.sol"; + +contract RegistryTest is TestEnvironment { + function testRegistry() external { + address _admin = vm.addr(1600); + RegistryItem memory item = RegistryItem({admin: _admin, contractType: "test", chainId: 1600}); + + vm.startPrank(_admin); + registry.addToRegistry(item); + vm.stopPrank(); + } +}