diff --git a/contracts/terminus/TerminusFacet.sol b/contracts/terminus/TerminusFacet.sol index 1e6db9c..965dae7 100644 --- a/contracts/terminus/TerminusFacet.sol +++ b/contracts/terminus/TerminusFacet.sol @@ -132,6 +132,11 @@ contract TerminusFacet is ERC1155WithTerminusStorage { return LibTerminus.terminusStorage().currentPoolID; } + function setPoolController(uint256 poolID, address newController) external { + LibTerminus.enforcePoolIsController(poolID, msg.sender); + LibTerminus.setPoolController(poolID, newController); + } + function terminusPoolController(uint256 poolID) external view diff --git a/dao/TerminusFacet.py b/dao/TerminusFacet.py index f02707a..9a459b0 100644 --- a/dao/TerminusFacet.py +++ b/dao/TerminusFacet.py @@ -214,6 +214,14 @@ def set_pool_base_price(self, new_base_price: int, transaction_config) -> Any: self.assert_contract_is_instantiated() return self.contract.setPoolBasePrice(new_base_price, transaction_config) + def set_pool_controller( + self, pool_id: int, new_controller: ChecksumAddress, transaction_config + ) -> Any: + self.assert_contract_is_instantiated() + return self.contract.setPoolController( + pool_id, new_controller, transaction_config + ) + def set_uri(self, pool_id: int, pool_uri: str, transaction_config) -> Any: self.assert_contract_is_instantiated() return self.contract.setURI(pool_id, pool_uri, transaction_config) @@ -497,6 +505,18 @@ def handle_set_pool_base_price(args: argparse.Namespace) -> None: print(result) +def handle_set_pool_controller(args: argparse.Namespace) -> None: + network.connect(args.network) + contract = TerminusFacet(args.address) + transaction_config = get_transaction_config(args) + result = contract.set_pool_controller( + pool_id=args.pool_id, + new_controller=args.new_controller, + transaction_config=transaction_config, + ) + print(result) + + def handle_set_uri(args: argparse.Namespace) -> None: network.connect(args.network) contract = TerminusFacet(args.address) @@ -762,6 +782,16 @@ def generate_cli() -> argparse.ArgumentParser: ) set_pool_base_price_parser.set_defaults(func=handle_set_pool_base_price) + set_pool_controller_parser = subcommands.add_parser("set-pool-controller") + add_default_arguments(set_pool_controller_parser, True) + set_pool_controller_parser.add_argument( + "--pool-id", required=True, help="Type: uint256", type=int + ) + set_pool_controller_parser.add_argument( + "--new-controller", required=True, help="Type: address" + ) + set_pool_controller_parser.set_defaults(func=handle_set_pool_controller) + set_uri_parser = subcommands.add_parser("set-uri") add_default_arguments(set_uri_parser, True) set_uri_parser.add_argument( diff --git a/dao/test_terminus.py b/dao/test_terminus.py index f49df06..6888801 100644 --- a/dao/test_terminus.py +++ b/dao/test_terminus.py @@ -141,6 +141,50 @@ def setUpClass(cls) -> None: def setUp(self) -> None: self.diamond_terminus.create_simple_pool(10, {"from": accounts[1]}) + def test_set_pool_controller(self): + pool_id = self.diamond_terminus.total_pools() + old_controller = accounts[1] + new_controller = accounts[2] + + current_controller_address = self.diamond_terminus.terminus_pool_controller( + pool_id + ) + self.assertEqual(current_controller_address, old_controller.address) + + with self.assertRaises(Exception): + self.diamond_terminus.set_pool_controller( + pool_id, new_controller.address, {"from": new_controller} + ) + current_controller_address = self.diamond_terminus.terminus_pool_controller( + pool_id + ) + self.assertEqual(current_controller_address, old_controller.address) + + self.diamond_terminus.set_pool_controller( + pool_id, new_controller.address, {"from": old_controller} + ) + current_controller_address = self.diamond_terminus.terminus_pool_controller( + pool_id + ) + self.assertEqual(current_controller_address, new_controller.address) + + with self.assertRaises(Exception): + self.diamond_terminus.set_pool_controller( + pool_id, old_controller.address, {"from": old_controller} + ) + current_controller_address = self.diamond_terminus.terminus_pool_controller( + pool_id + ) + self.assertEqual(current_controller_address, new_controller.address) + + self.diamond_terminus.set_pool_controller( + pool_id, old_controller.address, {"from": new_controller} + ) + current_controller_address = self.diamond_terminus.terminus_pool_controller( + pool_id + ) + self.assertEqual(current_controller_address, old_controller.address) + def test_mint(self): pool_id = self.diamond_terminus.total_pools() self.diamond_terminus.mint(accounts[2], pool_id, 1, b"", {"from": accounts[1]}) diff --git a/setup.py b/setup.py index 66e1c61..02406e5 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="moonstream-dao", - version="0.0.1", + version="0.0.2", packages=find_packages(), install_requires=["eth-brownie", "tqdm"], extras_require={