Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] New command to list accounts #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/starkware/starknet/cli/starknet_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ async def deploy_with_invoke(args: argparse.Namespace):
Transaction hash: {gateway_response['transaction_hash']}"""
)

async def get_accounts(args, command_args):
parser = argparse.ArgumentParser(description="Lists all accounts.")
parser.parse_args(command_args, namespace=args)
account = await load_account_from_args(args)
await account.list_accounts()

async def new_account(args, command_args):
parser = argparse.ArgumentParser(description="Initializes an account contract.")
Expand Down Expand Up @@ -1491,6 +1496,7 @@ async def main():
"invoke": invoke,
"new_account": new_account,
"tx_status": tx_status,
"get_accounts": get_accounts,
}
parser = argparse.ArgumentParser(description="A tool to communicate with StarkNet.")
parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {__version__}")
Expand Down
9 changes: 9 additions & 0 deletions src/starkware/starknet/wallets/open_zeppelin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ def _get_account_given_accounts(self, accounts: dict) -> JsonObject:
)
return accounts_for_network[self.account_name]

def list_accounts(self, accounts_for_network: dict):
print("Accounts:")
for account_name, account in accounts_for_network.items():
print(f" {account_name}:")
print(f" Address: 0x{int(account['address'], 16):064x}")
print(f" Deployed: {account['deployed']}")
print(f" Public key: 0x{int(account['public_key'], 16):064x}")
print(f" Private key: 0x{int(account['private_key'], 16):064x}")

def new_account(self) -> int:
# Read the account file.
accounts = self._get_accounts()
Expand Down