diff --git a/Pipfile.lock b/Pipfile.lock index 5da5c80..accc857 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -329,7 +329,7 @@ "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" ], - "markers": "python_version < '3.11'", + "markers": "python_full_version < '3.11.0a7'", "version": "==2.0.1" } } diff --git a/algodices.py b/algodices.py index 89b26f3..bbed555 100644 --- a/algodices.py +++ b/algodices.py @@ -22,7 +22,7 @@ from algosdk import account from algosdk import mnemonic from algosdk.atomic_transaction_composer import AccountTransactionSigner -from algosdk.constants import MIN_TXN_FEE +from algosdk.constants import MIN_TXN_FEE, MNEMONIC_LEN from beaker.client import ApplicationClient, Network from beaker.client.api_providers import AlgoExplorer @@ -30,6 +30,7 @@ from algodices_dapp import AlgoDices ALGO_DICES_APP_ID = 120974808 +RANDOMNESS_BEACON_DELAY = 8 def args_types(args: dict) -> dict: @@ -51,7 +52,7 @@ def main(): # USER mnemonic_phrase = getpass(prompt="Mnemonic (word_1 word_2 ... word_25):") try: - assert len(mnemonic_phrase.split()) == 25 + assert len(mnemonic_phrase.split()) == MNEMONIC_LEN except AssertionError: quit('\n⚠️ Enter mnemonic phrase, formatted as: "word_1 ... word_25"') user = AccountTransactionSigner(mnemonic.to_private_key(mnemonic_phrase)) @@ -77,7 +78,7 @@ def main(): if args["book"]: current_round = testnet.algod().status()["last-round"] booked_round = current_round + args[""] - reveal_round = booked_round + 8 + reveal_round = booked_round + RANDOMNESS_BEACON_DELAY print(f"\n --- 🔖 Booking a die roll for round {booked_round}...") algo_dices.call( method=AlgoDices.book_die_roll, @@ -87,8 +88,10 @@ def main(): elif args["roll"]: current_round = testnet.algod().status()["last-round"] - booked_round = algo_dices.get_account_state(user_address)["commitment_round"] - rounds_left = booked_round + 8 - current_round + booked_round = algo_dices.get_account_state(user_address)[ + AlgoDices.randomness_round.key.byte_str[1:-1] + ] + rounds_left = booked_round + RANDOMNESS_BEACON_DELAY - current_round if rounds_left > 0: print(f" --- ⏳ {rounds_left} round left to reveal die's roll...") else: