Skip to content

Commit

Permalink
Add update_default option when deploying an account
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementWalter committed Jul 31, 2023
1 parent a684ba4 commit 894ba27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/starksheet-cairo/scripts/add_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ async def main():
# %% Deploy accounts
for i in range(count):
private_key = random.randbytes(31).hex()
account = await deploy_starknet_account(private_key=private_key, amount=amount)
account = await deploy_starknet_account(
private_key=private_key, amount=amount, update_default=False
)
Path(f"{i}").mkdir(exist_ok=True, parents=True)
(Path(f"{i}") / ".env").write_text(
f"ACCOUNT_ADDRESS=0x{account.address:x}\nPRIVATE_KEY=0x{private_key}\n"
Expand Down
7 changes: 4 additions & 3 deletions packages/starksheet-cairo/utils/starknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _convert_offset_to_hex(obj):


async def deploy_starknet_account(
private_key=None, amount: Union[int, float] = 1
private_key=None, amount: Union[int, float] = 1, update_default=True
) -> Account:
compile_contract(
{"contract_name": "OpenzeppelinAccount", "is_account_contract": True}
Expand Down Expand Up @@ -323,8 +323,9 @@ async def deploy_starknet_account(
status = "✅" if status == TransactionStatus.ACCEPTED_ON_L2 else "❌"
logger.info(f"{status} Account deployed at address {hex(res.account.address)}")

NETWORK["account_address"] = hex(res.account.address)
NETWORK["private_key"] = hex(key_pair.private_key)
if update_default:
NETWORK["account_address"] = hex(res.account.address)
NETWORK["private_key"] = hex(key_pair.private_key)
return res.account


Expand Down

0 comments on commit 894ba27

Please sign in to comment.