Skip to content

Commit

Permalink
Merge pull request #314 from moonstream-to/terminus_equipment
Browse files Browse the repository at this point in the history
Terminus equipment
  • Loading branch information
kellan-simiotics authored Jul 19, 2023
2 parents 97c907f + 5fdc52d commit 34658bc
Show file tree
Hide file tree
Showing 14 changed files with 4,329 additions and 336 deletions.
1,250 changes: 1,250 additions & 0 deletions cli/enginecli/ITerminus.py

Large diffs are not rendered by default.

1,075 changes: 1,075 additions & 0 deletions cli/enginecli/InventoryFacet.py

Large diffs are not rendered by default.

328 changes: 262 additions & 66 deletions cli/enginecli/Lootbox.py

Large diffs are not rendered by default.

300 changes: 257 additions & 43 deletions cli/enginecli/MockTerminus.py

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions cli/enginecli/cli.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import argparse
import logging

from enginecli.ITerminus import ITerminus

from . import (
core,
flows,
drop,
DropperFacet,
Dropper,
Lootbox,
MockErc20,
MockERC721,
MockTerminus,
ITerminus,
setup_drop,
CraftingFacet,
GOFPFacet,
InventoryFacet,
)


Expand All @@ -31,6 +35,9 @@ def main() -> None:
core_parser = core.generate_cli()
subparsers.add_parser("core", parents=[core_parser], add_help=False)

flows_parser = flows.generate_cli()
subparsers.add_parser("flows", parents=[flows_parser], add_help=False)

dropper_parser = Dropper.generate_cli()
subparsers.add_parser("dropper-v1", parents=[dropper_parser], add_help=False)

Expand All @@ -49,7 +56,7 @@ def main() -> None:
drop_parser = drop.generate_cli()
subparsers.add_parser("drop", parents=[drop_parser], add_help=False)

terminus_parser = MockTerminus.generate_cli()
terminus_parser = ITerminus.generate_cli()
subparsers.add_parser("terminus", parents=[terminus_parser], add_help=False)

crafting_parser = CraftingFacet.generate_cli()
Expand All @@ -61,6 +68,9 @@ def main() -> None:
setup_drop_parser = setup_drop.generate_cli()
subparsers.add_parser("setup-drop", parents=[setup_drop_parser], add_help=False)

inventory_parser = InventoryFacet.generate_cli()
subparsers.add_parser("inventory", parents=[inventory_parser], add_help=False)

args = parser.parse_args()
args.func(args)

Expand Down
55 changes: 25 additions & 30 deletions cli/enginecli/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,55 +474,36 @@ def create_lootboxes_from_config(

def lootbox_gogogo(
terminus_address,
admin_terminus_address,
admin_terminus_pool_id,
vrf_coordinator_address,
link_token_address,
chainlik_vrf_fee,
chainlik_vrf_keyhash,
tx_config,
) -> Dict[str, Any]:
deployer = tx_config["from"]
terminus_contract = MockTerminus.MockTerminus(terminus_address)

terminus_payment_token_address = terminus_contract.payment_token()
terminus_payment_token = MockErc20(terminus_payment_token_address)

pool_base_price = terminus_contract.pool_base_price()
deployer_payment_token_balance = terminus_payment_token.balance_of(deployer.address)

if deployer_payment_token_balance < pool_base_price:
raise Exception(
f"Deployer does not have enough tokens to create terminus pool."
f"Need {pool_base_price} but only have {deployer_payment_token_balance}"
)

print("Approving deployer to spend tokens to create terminus pool...")
terminus_payment_token.approve(terminus_address, pool_base_price, tx_config)

print("Creating terminus pool...")
terminus_contract.create_pool_v1(pool_base_price, False, True, tx_config)

admin_token_pool_id = terminus_contract.total_pools()
admin_terminus_contract = MockTerminus.MockTerminus(admin_terminus_address)

print("Deploying lootbox...")
lootbox_contract = Lootbox.Lootbox(None)
lootbox_contract.deploy(
terminus_address,
admin_token_pool_id,
admin_terminus_address,
admin_terminus_pool_id,
vrf_coordinator_address,
link_token_address,
chainlik_vrf_fee,
chainlik_vrf_keyhash,
tx_config,
)

print("Setting pool controller...")
terminus_contract.set_pool_controller(
admin_token_pool_id, lootbox_contract.address, tx_config
)

contracts = {
"Lootbox": lootbox_contract.address,
"adminTokenPoolId": admin_token_pool_id,
"Lootbox": {
"Address": lootbox_contract.address,
"TerminusAddress": terminus_address,
"AdminTerminusAddress": admin_terminus_address,
"AdminTokenPoolId": admin_terminus_pool_id,
},
}

return contracts
Expand Down Expand Up @@ -615,6 +596,8 @@ def handle_lootbox_gogogo(args: argparse.Namespace) -> None:
transaction_config = MockTerminus.get_transaction_config(args)
result = lootbox_gogogo(
terminus_address,
args.admin_terminus_address,
args.admin_terminus_pool_id,
args.vrf_coordinator_address,
args.link_token_address,
args.chainlik_vrf_fee,
Expand Down Expand Up @@ -812,6 +795,18 @@ def generate_cli():
help="Address of the terminus contract",
)

lootbox_gogogo_parser.add_argument(
"--admin-terminus-address",
required=True,
help="Address of Terminus contract defining access control for this Lootbox contract",
)
lootbox_gogogo_parser.add_argument(
"--admin-terminus-pool-id",
required=True,
type=int,
help="Pool ID of Terminus pool for administrators of this Lootbox contract",
)

lootbox_gogogo_parser.add_argument(
"--vrf-coordinator-address",
type=str,
Expand Down
Loading

0 comments on commit 34658bc

Please sign in to comment.