Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from bugout-dev/terminus-set-pool-controller
Browse files Browse the repository at this point in the history
Added "setPoolController" external method to "TerminusFacet"
  • Loading branch information
zomglings authored Dec 24, 2021
2 parents bcec58b + b3addbb commit 654a468
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
5 changes: 5 additions & 0 deletions contracts/terminus/TerminusFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions dao/TerminusFacet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
44 changes: 44 additions & 0 deletions dao/test_terminus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]})
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down

0 comments on commit 654a468

Please sign in to comment.