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

Commit 654a468

Browse files
authored
Merge pull request #18 from bugout-dev/terminus-set-pool-controller
Added "setPoolController" external method to "TerminusFacet"
2 parents bcec58b + b3addbb commit 654a468

4 files changed

Lines changed: 80 additions & 1 deletion

File tree

contracts/terminus/TerminusFacet.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ contract TerminusFacet is ERC1155WithTerminusStorage {
132132
return LibTerminus.terminusStorage().currentPoolID;
133133
}
134134

135+
function setPoolController(uint256 poolID, address newController) external {
136+
LibTerminus.enforcePoolIsController(poolID, msg.sender);
137+
LibTerminus.setPoolController(poolID, newController);
138+
}
139+
135140
function terminusPoolController(uint256 poolID)
136141
external
137142
view

dao/TerminusFacet.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ def set_pool_base_price(self, new_base_price: int, transaction_config) -> Any:
214214
self.assert_contract_is_instantiated()
215215
return self.contract.setPoolBasePrice(new_base_price, transaction_config)
216216

217+
def set_pool_controller(
218+
self, pool_id: int, new_controller: ChecksumAddress, transaction_config
219+
) -> Any:
220+
self.assert_contract_is_instantiated()
221+
return self.contract.setPoolController(
222+
pool_id, new_controller, transaction_config
223+
)
224+
217225
def set_uri(self, pool_id: int, pool_uri: str, transaction_config) -> Any:
218226
self.assert_contract_is_instantiated()
219227
return self.contract.setURI(pool_id, pool_uri, transaction_config)
@@ -497,6 +505,18 @@ def handle_set_pool_base_price(args: argparse.Namespace) -> None:
497505
print(result)
498506

499507

508+
def handle_set_pool_controller(args: argparse.Namespace) -> None:
509+
network.connect(args.network)
510+
contract = TerminusFacet(args.address)
511+
transaction_config = get_transaction_config(args)
512+
result = contract.set_pool_controller(
513+
pool_id=args.pool_id,
514+
new_controller=args.new_controller,
515+
transaction_config=transaction_config,
516+
)
517+
print(result)
518+
519+
500520
def handle_set_uri(args: argparse.Namespace) -> None:
501521
network.connect(args.network)
502522
contract = TerminusFacet(args.address)
@@ -762,6 +782,16 @@ def generate_cli() -> argparse.ArgumentParser:
762782
)
763783
set_pool_base_price_parser.set_defaults(func=handle_set_pool_base_price)
764784

785+
set_pool_controller_parser = subcommands.add_parser("set-pool-controller")
786+
add_default_arguments(set_pool_controller_parser, True)
787+
set_pool_controller_parser.add_argument(
788+
"--pool-id", required=True, help="Type: uint256", type=int
789+
)
790+
set_pool_controller_parser.add_argument(
791+
"--new-controller", required=True, help="Type: address"
792+
)
793+
set_pool_controller_parser.set_defaults(func=handle_set_pool_controller)
794+
765795
set_uri_parser = subcommands.add_parser("set-uri")
766796
add_default_arguments(set_uri_parser, True)
767797
set_uri_parser.add_argument(

dao/test_terminus.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,50 @@ def setUpClass(cls) -> None:
141141
def setUp(self) -> None:
142142
self.diamond_terminus.create_simple_pool(10, {"from": accounts[1]})
143143

144+
def test_set_pool_controller(self):
145+
pool_id = self.diamond_terminus.total_pools()
146+
old_controller = accounts[1]
147+
new_controller = accounts[2]
148+
149+
current_controller_address = self.diamond_terminus.terminus_pool_controller(
150+
pool_id
151+
)
152+
self.assertEqual(current_controller_address, old_controller.address)
153+
154+
with self.assertRaises(Exception):
155+
self.diamond_terminus.set_pool_controller(
156+
pool_id, new_controller.address, {"from": new_controller}
157+
)
158+
current_controller_address = self.diamond_terminus.terminus_pool_controller(
159+
pool_id
160+
)
161+
self.assertEqual(current_controller_address, old_controller.address)
162+
163+
self.diamond_terminus.set_pool_controller(
164+
pool_id, new_controller.address, {"from": old_controller}
165+
)
166+
current_controller_address = self.diamond_terminus.terminus_pool_controller(
167+
pool_id
168+
)
169+
self.assertEqual(current_controller_address, new_controller.address)
170+
171+
with self.assertRaises(Exception):
172+
self.diamond_terminus.set_pool_controller(
173+
pool_id, old_controller.address, {"from": old_controller}
174+
)
175+
current_controller_address = self.diamond_terminus.terminus_pool_controller(
176+
pool_id
177+
)
178+
self.assertEqual(current_controller_address, new_controller.address)
179+
180+
self.diamond_terminus.set_pool_controller(
181+
pool_id, old_controller.address, {"from": new_controller}
182+
)
183+
current_controller_address = self.diamond_terminus.terminus_pool_controller(
184+
pool_id
185+
)
186+
self.assertEqual(current_controller_address, old_controller.address)
187+
144188
def test_mint(self):
145189
pool_id = self.diamond_terminus.total_pools()
146190
self.diamond_terminus.mint(accounts[2], pool_id, 1, b"", {"from": accounts[1]})

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="moonstream-dao",
9-
version="0.0.1",
9+
version="0.0.2",
1010
packages=find_packages(),
1111
install_requires=["eth-brownie", "tqdm"],
1212
extras_require={

0 commit comments

Comments
 (0)