From 2133aaf58d5c8ae493c579570e43c9e011774309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Walter?= Date: Wed, 21 Jun 2023 21:48:00 +0200 Subject: [PATCH] Add madara hacks to sharingan (#599) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Time spent on this PR: 0.1 ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Some code is run only when STARKNET_NETWORK=madara. We need to run it when network is sharingan as well ## What is the new behavior? Works on sharingan ## Other information First Kakarot deployment ✅ on sharingan! Address: 0x3fc7138043e914a2061c128fd4a868a15361f1ef8bdeaade0e282995389dcf Just deployed also an ERC20, address is 0x9bC9f3e18Ca7B721aE08D0c43Cc67D05ffc73f11 --- scripts/deploy_kakarot.py | 2 +- scripts/utils/starknet.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/deploy_kakarot.py b/scripts/deploy_kakarot.py index 8faa66b15..3fad6593c 100644 --- a/scripts/deploy_kakarot.py +++ b/scripts/deploy_kakarot.py @@ -27,7 +27,7 @@ # %% Main async def main(): # %% Declarations - if NETWORK["name"] == "madara": + if NETWORK["name"] in ["madara", "sharingan"]: await deploy_starknet_account(amount=100) account = await get_starknet_account() logger.info(f"ℹ️ Using account {hex(account.address)} as deployer") diff --git a/scripts/utils/starknet.py b/scripts/utils/starknet.py index 0fe7a8c5a..7fe97f832 100644 --- a/scripts/utils/starknet.py +++ b/scripts/utils/starknet.py @@ -153,7 +153,7 @@ async def fund_address(address: Union[int, str], amount: float): address, int_to_uint256(amount) ) # TODO: remove when madara has a regular default account - if NETWORK["name"] == "madara" and account.address == 1: + if NETWORK["name"] in ["madara", "sharingan"] and account.address == 1: transaction = Invoke( calldata=[ prepared.to_addr, @@ -312,6 +312,7 @@ async def deploy_starknet_account(private_key=None, amount=1) -> Account: logger.warning("⚠️ Transaction REJECTED") logger.info(f"✅ Account deployed at address {hex(res.account.address)}") + NETWORK["account_address"] = hex(res.account.address) NETWORK["private_key"] = hex(key_pair.private_key) return res.account @@ -445,7 +446,9 @@ async def wait_for_transaction(*args, **kwargs): status not in [TransactionStatus.ACCEPTED_ON_L2, TransactionStatus.REJECTED] and elapsed < max_wait ): - logger.info(f"ℹ️ Current status: {status}") + if elapsed > 0: + # don't log at the first iteration + logger.info(f"ℹ️ Current status: {status}") logger.info(f"ℹ️ Sleeping for {check_interval}s") time.sleep(check_interval) response = requests.post(