hippius 0.1.11__py3-none-any.whl → 0.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hippius_sdk/cli.py CHANGED
@@ -6,47 +6,48 @@ This module provides CLI tools for working with the Hippius SDK, including
6
6
  utilities for encryption key generation, file operations, and marketplace interactions.
7
7
  """
8
8
 
9
- import base64
10
9
  import argparse
10
+ import base64
11
+ import concurrent.futures
12
+ import getpass
13
+ import json
11
14
  import os
15
+ import random
12
16
  import sys
13
- import time
14
- import json
15
- from typing import Optional, List
16
- import getpass
17
- import concurrent.futures
18
17
  import threading
19
- import random
18
+ import time
20
19
  import uuid
20
+ from typing import List, Optional
21
+
22
+ from dotenv import load_dotenv
21
23
 
22
24
  # Import SDK components
23
- from hippius_sdk import HippiusClient
24
- from hippius_sdk.substrate import FileInput
25
25
  from hippius_sdk import (
26
+ HippiusClient,
27
+ decrypt_seed_phrase,
28
+ delete_account,
29
+ encrypt_seed_phrase,
30
+ get_account_address,
31
+ get_active_account,
32
+ get_all_config,
26
33
  get_config_value,
27
- set_config_value,
28
34
  get_encryption_key,
29
- set_encryption_key,
35
+ get_seed_phrase,
36
+ initialize_from_env,
37
+ list_accounts,
30
38
  load_config,
31
- save_config,
32
- get_all_config,
33
39
  reset_config,
34
- initialize_from_env,
35
- get_seed_phrase,
36
- set_seed_phrase,
37
- encrypt_seed_phrase,
38
- decrypt_seed_phrase,
39
- get_active_account,
40
+ save_config,
40
41
  set_active_account,
41
- list_accounts,
42
- delete_account,
43
- get_account_address,
42
+ set_config_value,
43
+ set_encryption_key,
44
+ set_seed_phrase,
44
45
  )
45
- from dotenv import load_dotenv
46
+ from hippius_sdk.substrate import FileInput
46
47
 
47
48
  try:
48
- import nacl.utils
49
49
  import nacl.secret
50
+ import nacl.utils
50
51
  except ImportError:
51
52
  ENCRYPTION_AVAILABLE = False
52
53
  else:
@@ -59,6 +60,12 @@ load_dotenv()
59
60
  initialize_from_env()
60
61
 
61
62
 
63
+ def get_default_address():
64
+ """Get the default address for read-only operations"""
65
+ config = load_config()
66
+ return config["substrate"].get("default_address")
67
+
68
+
62
69
  def generate_key():
63
70
  """Generate a random encryption key for NaCl secretbox."""
64
71
  if not ENCRYPTION_AVAILABLE:
@@ -162,9 +169,9 @@ def create_client(args):
162
169
  ipfs_gateway=gateway,
163
170
  ipfs_api_url=api_url,
164
171
  substrate_url=substrate_url,
165
- substrate_seed_phrase=args.seed_phrase
166
- if hasattr(args, "seed_phrase")
167
- else None,
172
+ substrate_seed_phrase=(
173
+ args.seed_phrase if hasattr(args, "seed_phrase") else None
174
+ ),
168
175
  seed_phrase_password=args.password if hasattr(args, "password") else None,
169
176
  account_name=args.account if hasattr(args, "account") else None,
170
177
  encrypt_by_default=encrypt,
@@ -411,12 +418,22 @@ def handle_credits(client, account_address):
411
418
  if default_address:
412
419
  account_address = default_address
413
420
  else:
421
+ has_default = get_default_address() is not None
422
+
414
423
  print(
415
424
  "Error: No account address provided, and client has no keypair."
416
425
  )
417
- print(
418
- "Please provide an account address with '--account_address' or set a default with 'hippius address set-default'"
419
- )
426
+
427
+ if has_default:
428
+ print(
429
+ "Please provide an account address with '--account_address' or the default address may be invalid."
430
+ )
431
+ else:
432
+ print(
433
+ "Please provide an account address with '--account_address' or set a default with:"
434
+ )
435
+ print(" hippius address set-default <your_account_address>")
436
+
420
437
  return 1
421
438
 
422
439
  credits = client.substrate_client.get_free_credits(account_address)
@@ -454,12 +471,21 @@ def handle_files(client, account_address, show_all_miners=False):
454
471
  if default_address:
455
472
  account_address = default_address
456
473
  else:
474
+ has_default = get_default_address() is not None
475
+
457
476
  print(
458
477
  "Error: No account address provided, and client has no keypair."
459
478
  )
460
- print(
461
- "Please provide an account address with '--account_address' or set a default with 'hippius address set-default'"
462
- )
479
+
480
+ if has_default:
481
+ print(
482
+ "Please provide an account address with '--account_address' or the default address may be invalid."
483
+ )
484
+ else:
485
+ print(
486
+ "Please provide an account address with '--account_address' or set a default with:"
487
+ )
488
+ print(" hippius address set-default <your_account_address>")
463
489
  return 1
464
490
 
465
491
  # Get files for the account using the new profile-based method
@@ -560,12 +586,21 @@ def handle_ec_files(client, account_address, show_all_miners=False, show_chunks=
560
586
  if default_address:
561
587
  account_address = default_address
562
588
  else:
589
+ has_default = get_default_address() is not None
590
+
563
591
  print(
564
592
  "Error: No account address provided, and client has no keypair."
565
593
  )
566
- print(
567
- "Please provide an account address with '--account_address' or set a default with 'hippius address set-default'"
568
- )
594
+
595
+ if has_default:
596
+ print(
597
+ "Please provide an account address with '--account_address' or the default address may be invalid."
598
+ )
599
+ else:
600
+ print(
601
+ "Please provide an account address with '--account_address' or set a default with:"
602
+ )
603
+ print(" hippius address set-default <your_account_address>")
569
604
  return 1
570
605
 
571
606
  # First, get all user files using the profile method
@@ -714,7 +749,6 @@ def handle_ec_files(client, account_address, show_all_miners=False, show_chunks=
714
749
  original_name = (
715
750
  file_name.replace(".ec_metadata", "") if file_name else "file"
716
751
  )
717
- # We're already using formatted_cid from above
718
752
  print(
719
753
  f" hippius reconstruct {formatted_cid} reconstructed_{original_name}"
720
754
  )
@@ -889,11 +923,8 @@ def handle_erasure_code(
889
923
  print(f" 1. The metadata CID: {metadata_cid}")
890
924
  print(" 2. Access to at least k chunks for each original chunk")
891
925
  print("\nReconstruction command:")
892
-
893
- # Format the CID for the command
894
- formatted_cid = client.format_cid(metadata_cid)
895
926
  print(
896
- f" hippius reconstruct {formatted_cid} reconstructed_{original_file.get('name')}"
927
+ f" hippius reconstruct {metadata_cid} reconstructed_{original_file.get('name')}"
897
928
  )
898
929
 
899
930
  return 0
@@ -1080,12 +1111,9 @@ def handle_reconstruct(client, metadata_cid, output_file, verbose=True):
1080
1111
  start_time = time.time()
1081
1112
 
1082
1113
  try:
1083
- # Format the CID to ensure it's properly handled
1084
- formatted_cid = client.format_cid(metadata_cid)
1085
-
1086
- # Use the formatted CID for reconstruction
1114
+ # Use the reconstruct_from_erasure_code method
1087
1115
  result = client.reconstruct_from_erasure_code(
1088
- metadata_cid=formatted_cid, output_file=output_file, verbose=verbose
1116
+ metadata_cid=metadata_cid, output_file=output_file, verbose=verbose
1089
1117
  )
1090
1118
 
1091
1119
  elapsed_time = time.time() - start_time
@@ -1357,316 +1385,119 @@ def handle_seed_phrase_status(account_name=None):
1357
1385
  return 0
1358
1386
 
1359
1387
 
1360
- def handle_account_list(args):
1361
- """Handle listing accounts."""
1362
- from hippius_sdk.account import AccountManager
1363
-
1364
- account_manager = AccountManager()
1365
-
1366
- if args.type == "coldkey":
1367
- accounts = account_manager.list_coldkeys()
1368
- print(f"Found {len(accounts)} coldkeys:")
1369
-
1370
- for i, account in enumerate(accounts, 1):
1371
- print(f"{i}. {account['name']}: {account['address']}")
1372
-
1373
- # If verbose, show associated hotkeys
1374
- if args.verbose:
1375
- hotkeys = account_manager.list_hotkeys(account["address"])
1376
- if hotkeys:
1377
- print(f" Associated hotkeys:")
1378
- for j, hotkey in enumerate(hotkeys, 1):
1379
- print(f" {j}. {hotkey['name']}: {hotkey['address']}")
1380
- else:
1381
- print(f" No associated hotkeys")
1382
-
1383
- elif args.type == "hotkey":
1384
- try:
1385
- if args.coldkey:
1386
- accounts = account_manager.list_hotkeys(args.coldkey)
1387
- coldkey_name = None
1388
- if accounts and "coldkey_name" in accounts[0]:
1389
- coldkey_name = accounts[0]["coldkey_name"]
1390
-
1391
- if coldkey_name:
1392
- print(
1393
- f"Found {len(accounts)} hotkeys for coldkey {args.coldkey} ({coldkey_name}):"
1394
- )
1395
- else:
1396
- print(f"Found {len(accounts)} hotkeys for coldkey {args.coldkey}:")
1397
- else:
1398
- accounts = account_manager.list_hotkeys()
1399
- print(f"Found {len(accounts)} hotkeys:")
1400
-
1401
- for i, account in enumerate(accounts, 1):
1402
- coldkey_info = ""
1403
- if "associated_coldkey" in account:
1404
- if "coldkey_name" in account:
1405
- coldkey_info = f" → coldkey: {account['coldkey_name']} ({account['associated_coldkey']})"
1406
- else:
1407
- coldkey_info = f" → coldkey: {account['associated_coldkey']}"
1408
-
1409
- print(f"{i}. {account['name']}: {account['address']}{coldkey_info}")
1410
-
1411
- # If verbose, show more details
1412
- if args.verbose:
1413
- created_at = account.get("created_at", 0)
1414
- if created_at:
1415
- from datetime import datetime
1416
-
1417
- created_time = datetime.fromtimestamp(created_at).strftime(
1418
- "%Y-%m-%d %H:%M:%S"
1419
- )
1420
- print(f" Created: {created_time}")
1421
-
1422
- # Show whether there is a blockchain proxy relationship
1423
- try:
1424
- proxies = account_manager.list_proxies(
1425
- account.get("associated_coldkey")
1426
- )
1427
- has_proxy = any(
1428
- proxy["hotkey"] == account["address"] for proxy in proxies
1429
- )
1430
- if has_proxy:
1431
- print(f" Blockchain proxy: YES (active on-chain)")
1432
- else:
1433
- print(f" Blockchain proxy: NO (local association only)")
1434
- except Exception:
1435
- print(f" Blockchain proxy: Unknown (could not verify)")
1436
-
1437
- except ValueError as e:
1438
- print(f"Error: {str(e)}")
1439
- return None
1440
- except Exception as e:
1441
- print(f"Error listing hotkeys: {str(e)}")
1442
- return None
1443
-
1444
- elif args.type == "proxy":
1445
- try:
1446
- proxies = account_manager.list_proxies(args.coldkey)
1447
- print(f"Found {len(proxies)} proxy relationships on the blockchain:")
1448
-
1449
- for i, proxy in enumerate(proxies, 1):
1450
- coldkey = proxy["coldkey"]
1451
- hotkey = proxy["hotkey"]
1452
-
1453
- # Try to get human-readable names
1454
- data = account_manager._load_accounts_data()
1455
- coldkey_name = (
1456
- data.get("coldkeys", {}).get(coldkey, {}).get("name", "Unknown")
1457
- )
1458
- hotkey_name = (
1459
- data.get("hotkeys", {}).get(hotkey, {}).get("name", "Unknown")
1460
- )
1461
-
1462
- print(f"{i}. {coldkey_name} ({coldkey}) → {hotkey_name} ({hotkey})")
1463
- print(f" Type: {proxy['proxy_type']}, Delay: {proxy['delay']}")
1464
- except Exception as e:
1465
- print(f"Error listing proxies: {str(e)}")
1466
-
1467
- return accounts
1468
-
1469
-
1470
- def handle_account_proxy_create(args):
1471
- """Handle creating a proxy relationship."""
1472
- from hippius_sdk.account import AccountManager
1473
-
1474
- account_manager = AccountManager()
1475
-
1476
- try:
1477
- result = account_manager.create_proxy_relationship(
1478
- coldkey_address=args.coldkey,
1479
- hotkey_address=args.hotkey,
1480
- proxy_type=args.proxy_type,
1481
- delay=args.delay,
1482
- password=args.password, # Pass the password if provided
1483
- )
1484
-
1485
- if result.get("success"):
1486
- print(f"Successfully created proxy relationship!")
1487
- print(f"Coldkey: {result['coldkey']}")
1488
- print(f"Hotkey: {result['hotkey']}")
1489
- print(f"Type: {result['proxy_type']}")
1490
- print(f"Tx Hash: {result['transaction_hash']}")
1491
- else:
1492
- print(
1493
- f"Failed to create proxy relationship: {result.get('error', 'Unknown error')}"
1494
- )
1495
-
1496
- return result
1497
-
1498
- except Exception as e:
1499
- print(f"Error creating proxy relationship: {str(e)}")
1500
- return None
1501
-
1502
-
1503
- def handle_account_proxy_remove(args):
1504
- """Handle removing a proxy relationship."""
1505
- from hippius_sdk.account import AccountManager
1506
-
1507
- account_manager = AccountManager()
1508
-
1509
- try:
1510
- result = account_manager.remove_proxy(
1511
- coldkey_address=args.coldkey,
1512
- hotkey_address=args.hotkey,
1513
- password=args.password,
1514
- proxy_type=args.proxy_type,
1515
- delay=args.delay,
1516
- )
1517
-
1518
- if result.get("success"):
1519
- print(f"Successfully removed proxy relationship!")
1520
- print(f"Coldkey: {result['coldkey']}")
1521
- print(f"Hotkey: {result['hotkey']}")
1522
- print(f"Tx Hash: {result['transaction_hash']}")
1523
- else:
1524
- print(
1525
- f"Failed to remove proxy relationship: {result.get('error', 'Unknown error')}"
1526
- )
1527
-
1528
- return result
1529
-
1530
- except Exception as e:
1531
- print(f"Error removing proxy relationship: {str(e)}")
1532
- return None
1533
-
1534
-
1535
- def handle_account_coldkey_create(args):
1536
- """Handle creating a new coldkey account."""
1537
- from hippius_sdk.account import AccountManager
1388
+ def handle_account_list():
1389
+ """Handle listing all accounts"""
1390
+ accounts = list_accounts()
1538
1391
 
1539
- account_manager = AccountManager()
1392
+ if not accounts:
1393
+ print("No accounts configured")
1394
+ return 0
1540
1395
 
1541
- # Determine if we're creating from a mnemonic
1542
- mnemonic = None
1543
- if args.mnemonic:
1544
- mnemonic = args.mnemonic
1545
- elif args.generate_mnemonic:
1546
- # We'll use the keypair generation which automatically creates a mnemonic
1547
- pass
1396
+ print(f"Found {len(accounts)} accounts:")
1548
1397
 
1549
- try:
1550
- coldkey = account_manager.create_coldkey(
1551
- name=args.name if args.name else "hippius_coldkey",
1552
- mnemonic=mnemonic,
1553
- encrypt=not args.no_encrypt, # Default to encrypt=True unless explicitly disabled
1554
- password=None, # Let the method handle prompting for password
1398
+ for name, data in accounts.items():
1399
+ active_marker = " (active)" if data.get("is_active", False) else ""
1400
+ encoded_status = (
1401
+ "encrypted" if data.get("seed_phrase_encoded", False) else "plain text"
1555
1402
  )
1403
+ address = data.get("ss58_address", "unknown")
1556
1404
 
1557
- # Success message is already printed in the create_coldkey method
1558
- # If show_mnemonic was requested and it's not encrypted, show it
1559
- if args.show_mnemonic and not coldkey.get("encrypted", True):
1560
- print("\nIMPORTANT: Save this mnemonic phrase to recover your account!")
1561
- print(f"Mnemonic: {coldkey['mnemonic']}")
1562
- print("\nWARNING: Never share this mnemonic with anyone!")
1563
-
1564
- return coldkey
1405
+ print(f" {name}{active_marker}:")
1406
+ print(f" SS58 Address: {address}")
1407
+ print(f" Seed phrase: {encoded_status}")
1408
+ print()
1565
1409
 
1566
- except Exception as e:
1567
- print(f"Error creating coldkey: {str(e)}")
1568
- return None
1410
+ return 0
1569
1411
 
1570
1412
 
1571
- def handle_account_hotkey_create(args):
1572
- """Handle creating a new hotkey account."""
1573
- from hippius_sdk.account import AccountManager
1413
+ def handle_account_switch(account_name):
1414
+ """Handle switching the active account"""
1415
+ if set_active_account(account_name):
1416
+ print(f"Switched to account '{account_name}'")
1574
1417
 
1575
- account_manager = AccountManager()
1418
+ # Show address
1419
+ address = get_account_address(account_name)
1420
+ if address:
1421
+ print(f"SS58 Address: {address}")
1576
1422
 
1577
- try:
1578
- # If no coldkey provided, let the AccountManager handle it
1579
- # It will use the only coldkey if there's just one, or raise an error
1580
- hotkey = account_manager.create_hotkey(
1581
- name=args.name, coldkey_address=args.coldkey
1582
- )
1423
+ return 0
1424
+ else:
1425
+ return 1
1583
1426
 
1584
- # Success message is already printed in create_hotkey
1585
1427
 
1586
- # If show_mnemonic was requested, show it
1587
- if args.show_mnemonic and hotkey.get("mnemonic"):
1588
- print("\nHotkey mnemonic: {0}".format(hotkey["mnemonic"]))
1589
- print("Note: This mnemonic is only needed if you want to use this hotkey")
1590
- print(" outside of the Hippius SDK. For normal operations, the proxy")
1591
- print(" relationship will allow your coldkey to authorize actions.")
1428
+ def handle_account_delete(account_name):
1429
+ """Handle deleting an account"""
1430
+ # Ask for confirmation
1431
+ confirm = input(
1432
+ f"Are you sure you want to delete account '{account_name}'? This cannot be undone. (y/N): "
1433
+ )
1434
+ if confirm.lower() not in ("y", "yes"):
1435
+ print("Operation cancelled")
1436
+ return 0
1592
1437
 
1593
- return hotkey
1438
+ if delete_account(account_name):
1439
+ print(f"Account '{account_name}' deleted")
1594
1440
 
1595
- except ValueError as e:
1596
- # Handle the specific error case of multiple coldkeys
1597
- if "multiple coldkeys exist" in str(e):
1598
- print(f"Error: {e}")
1599
- print("\nPlease specify which coldkey to use with:")
1600
- print(
1601
- " hippius account hotkey create --coldkey <COLDKEY_ADDRESS> [--name <NAME>]"
1602
- )
1441
+ # Show the new active account if any
1442
+ active_account = get_active_account()
1443
+ if active_account:
1444
+ print(f"Active account is now '{active_account}'")
1603
1445
  else:
1604
- print(f"Error creating hotkey: {str(e)}")
1446
+ print("No accounts remaining")
1605
1447
 
1606
- return None
1607
- except Exception as e:
1608
- print(f"Error creating hotkey: {str(e)}")
1609
- return None
1610
-
1611
-
1612
- def handle_account_proxy_create(args):
1613
- """Handle creating a proxy relationship."""
1614
- from hippius_sdk.account import AccountManager
1448
+ return 0
1449
+ else:
1450
+ return 1
1615
1451
 
1616
- account_manager = AccountManager()
1617
1452
 
1618
- try:
1619
- result = account_manager.create_proxy_relationship(
1620
- coldkey_address=args.coldkey,
1621
- hotkey_address=args.hotkey,
1622
- proxy_type=args.proxy_type,
1623
- delay=args.delay,
1453
+ def handle_default_address_set(address):
1454
+ """Handle setting the default address for read-only operations"""
1455
+ # Validate SS58 address format (basic check)
1456
+ if not address.startswith("5"):
1457
+ print(
1458
+ f"Warning: '{address}' doesn't look like a valid SS58 address. SS58 addresses typically start with '5'."
1624
1459
  )
1460
+ confirm = input("Do you want to continue anyway? (y/N): ")
1461
+ if confirm.lower() not in ("y", "yes"):
1462
+ print("Operation cancelled")
1463
+ return 1
1625
1464
 
1626
- if result.get("success"):
1627
- print(f"Successfully created proxy relationship!")
1628
- print(f"Coldkey: {result['coldkey']}")
1629
- print(f"Hotkey: {result['hotkey']}")
1630
- print(f"Type: {result['proxy_type']}")
1631
- print(f"Tx Hash: {result['transaction_hash']}")
1632
- else:
1633
- print(
1634
- f"Failed to create proxy relationship: {result.get('error', 'Unknown error')}"
1635
- )
1636
-
1637
- return result
1465
+ config = load_config()
1466
+ config["substrate"]["default_address"] = address
1467
+ save_config(config)
1638
1468
 
1639
- except Exception as e:
1640
- print(f"Error creating proxy relationship: {str(e)}")
1641
- return None
1469
+ print(f"Default address for read-only operations set to: {address}")
1470
+ print(
1471
+ "This address will be used for commands like 'files' and 'ec-files' when no address is explicitly provided."
1472
+ )
1473
+ return 0
1642
1474
 
1643
1475
 
1644
- def handle_account_proxy_remove(args):
1645
- """Handle removing a proxy relationship."""
1646
- from hippius_sdk.account import AccountManager
1476
+ def handle_default_address_get():
1477
+ """Handle getting the current default address for read-only operations"""
1478
+ config = load_config()
1479
+ address = config["substrate"].get("default_address")
1647
1480
 
1648
- account_manager = AccountManager()
1481
+ if address:
1482
+ print(f"Current default address for read-only operations: {address}")
1483
+ else:
1484
+ print("No default address set for read-only operations")
1485
+ print("You can set one with: hippius address set-default <ss58_address>")
1649
1486
 
1650
- try:
1651
- result = account_manager.remove_proxy(
1652
- coldkey_address=args.coldkey, hotkey_address=args.hotkey
1653
- )
1487
+ return 0
1654
1488
 
1655
- if result.get("success"):
1656
- print(f"Successfully removed proxy relationship!")
1657
- print(f"Coldkey: {result['coldkey']}")
1658
- print(f"Hotkey: {result['hotkey']}")
1659
- print(f"Tx Hash: {result['transaction_hash']}")
1660
- else:
1661
- print(
1662
- f"Failed to remove proxy relationship: {result.get('error', 'Unknown error')}"
1663
- )
1664
1489
 
1665
- return result
1490
+ def handle_default_address_clear():
1491
+ """Handle clearing the default address for read-only operations"""
1492
+ config = load_config()
1493
+ if "default_address" in config["substrate"]:
1494
+ del config["substrate"]["default_address"]
1495
+ save_config(config)
1496
+ print("Default address for read-only operations has been cleared")
1497
+ else:
1498
+ print("No default address was set")
1666
1499
 
1667
- except Exception as e:
1668
- print(f"Error removing proxy relationship: {str(e)}")
1669
- return None
1500
+ return 0
1670
1501
 
1671
1502
 
1672
1503
  def main():
@@ -1915,41 +1746,6 @@ examples:
1915
1746
  "--verbose", action="store_true", help="Enable verbose output", default=True
1916
1747
  )
1917
1748
 
1918
- # Erasure code directory command
1919
- erasure_code_dir_parser = subparsers.add_parser(
1920
- "erasure-code-dir", help="Apply erasure coding to each file in a directory"
1921
- )
1922
- erasure_code_dir_parser.add_argument(
1923
- "dir_path", help="Path to directory to process"
1924
- )
1925
- erasure_code_dir_parser.add_argument(
1926
- "--k",
1927
- type=int,
1928
- default=3,
1929
- help="Number of data chunks needed to reconstruct (default: 3)",
1930
- )
1931
- erasure_code_dir_parser.add_argument(
1932
- "--m", type=int, default=5, help="Total number of chunks to create (default: 5)"
1933
- )
1934
- erasure_code_dir_parser.add_argument(
1935
- "--chunk-size",
1936
- type=int,
1937
- default=1048576,
1938
- help="Chunk size in bytes (default: 1MB)",
1939
- )
1940
- erasure_code_dir_parser.add_argument(
1941
- "--miner-ids", help="Comma-separated list of miner IDs"
1942
- )
1943
- erasure_code_dir_parser.add_argument(
1944
- "--encrypt", action="store_true", help="Encrypt the files"
1945
- )
1946
- erasure_code_dir_parser.add_argument(
1947
- "--no-encrypt", action="store_true", help="Do not encrypt the files"
1948
- )
1949
- erasure_code_dir_parser.add_argument(
1950
- "--verbose", action="store_true", help="Enable verbose output", default=True
1951
- )
1952
-
1953
1749
  # Reconstruct command
1954
1750
  reconstruct_parser = subparsers.add_parser(
1955
1751
  "reconstruct", help="Reconstruct an erasure-coded file"
@@ -2045,139 +1841,55 @@ examples:
2045
1841
  )
2046
1842
 
2047
1843
  # Account subcommand
2048
- account_parser = subparsers.add_parser("account", help="Manage blockchain accounts")
1844
+ account_parser = subparsers.add_parser("account", help="Manage substrate accounts")
2049
1845
  account_subparsers = account_parser.add_subparsers(
2050
- dest="account_action", help="Account management actions"
1846
+ dest="account_action", help="Account action"
2051
1847
  )
2052
1848
 
2053
- # Coldkey subcommands
2054
- coldkey_parser = account_subparsers.add_parser(
2055
- "coldkey", help="Manage coldkey accounts"
2056
- )
2057
- coldkey_subparsers = coldkey_parser.add_subparsers(
2058
- dest="coldkey_action", help="Coldkey actions"
2059
- )
1849
+ # List accounts
1850
+ account_subparsers.add_parser("list", help="List all accounts")
2060
1851
 
2061
- # Create coldkey command
2062
- create_coldkey_parser = coldkey_subparsers.add_parser(
2063
- "create", help="Create a new coldkey"
1852
+ # Switch active account
1853
+ switch_account_parser = account_subparsers.add_parser(
1854
+ "switch", help="Switch to a different account"
2064
1855
  )
2065
- create_coldkey_parser.add_argument(
2066
- "--name", help="Name for the coldkey (default: hippius_coldkey)"
2067
- )
2068
- mnemonic_group = create_coldkey_parser.add_mutually_exclusive_group()
2069
- mnemonic_group.add_argument("--mnemonic", help="Mnemonic seed phrase to use")
2070
- mnemonic_group.add_argument(
2071
- "--generate-mnemonic",
2072
- action="store_true",
2073
- help="Generate a new mnemonic (default if no mnemonic provided)",
2074
- )
2075
- create_coldkey_parser.add_argument(
2076
- "--show-mnemonic",
2077
- action="store_true",
2078
- help="Display the mnemonic after creation (USE WITH CAUTION)",
2079
- )
2080
- create_coldkey_parser.add_argument(
2081
- "--no-encrypt",
2082
- action="store_true",
2083
- help="Do NOT encrypt the mnemonic with a password (not recommended)",
1856
+ switch_account_parser.add_argument(
1857
+ "account_name", help="Name of the account to switch to"
2084
1858
  )
2085
- create_coldkey_parser.set_defaults(func=handle_account_coldkey_create)
2086
1859
 
2087
- # Hotkey subcommands
2088
- hotkey_parser = account_subparsers.add_parser(
2089
- "hotkey", help="Manage hotkey accounts"
1860
+ # Delete account
1861
+ delete_account_parser = account_subparsers.add_parser(
1862
+ "delete", help="Delete an account"
2090
1863
  )
2091
- hotkey_subparsers = hotkey_parser.add_subparsers(
2092
- dest="hotkey_action", help="Hotkey actions"
1864
+ delete_account_parser.add_argument(
1865
+ "account_name", help="Name of the account to delete"
2093
1866
  )
2094
1867
 
2095
- # Create hotkey command
2096
- create_hotkey_parser = hotkey_subparsers.add_parser(
2097
- "create", help="Create a new hotkey associated with a coldkey"
1868
+ # Address subcommand for read-only operations
1869
+ address_parser = subparsers.add_parser(
1870
+ "address", help="Manage default address for read-only operations"
2098
1871
  )
2099
- create_hotkey_parser.add_argument(
2100
- "--name", help="Name for the hotkey (default: hippius_hotkey_N)"
1872
+ address_subparsers = address_parser.add_subparsers(
1873
+ dest="address_action", help="Address action"
2101
1874
  )
2102
- create_hotkey_parser.add_argument(
2103
- "--coldkey",
2104
- help="Coldkey address to associate with (required if multiple coldkeys exist)",
2105
- )
2106
- create_hotkey_parser.add_argument(
2107
- "--show-mnemonic",
2108
- action="store_true",
2109
- help="Display the mnemonic after creation",
2110
- )
2111
- create_hotkey_parser.set_defaults(func=handle_account_hotkey_create)
2112
1875
 
2113
- # List accounts command
2114
- list_accounts_parser = account_subparsers.add_parser("list", help="List accounts")
2115
- list_accounts_parser.add_argument(
2116
- "type", choices=["coldkey", "hotkey", "proxy"], help="Type of accounts to list"
1876
+ # Set default address
1877
+ set_default_parser = address_subparsers.add_parser(
1878
+ "set-default", help="Set the default address for read-only operations"
2117
1879
  )
2118
- list_accounts_parser.add_argument("--coldkey", help="Coldkey address to filter by")
2119
- list_accounts_parser.add_argument(
2120
- "--verbose", "-v", action="store_true", help="Show more details"
1880
+ set_default_parser.add_argument(
1881
+ "address", help="The SS58 address to use as default"
2121
1882
  )
2122
- list_accounts_parser.set_defaults(func=handle_account_list)
2123
1883
 
2124
- # Proxy subcommands
2125
- proxy_parser = account_subparsers.add_parser(
2126
- "proxy", help="Manage proxy relationships"
2127
- )
2128
- proxy_subparsers = proxy_parser.add_subparsers(
2129
- dest="proxy_action", help="Proxy actions"
1884
+ # Get current default address
1885
+ address_subparsers.add_parser(
1886
+ "get-default", help="Show the current default address for read-only operations"
2130
1887
  )
2131
1888
 
2132
- # Create proxy command
2133
- create_proxy_parser = proxy_subparsers.add_parser(
2134
- "create", help="Create a proxy relationship"
1889
+ # Clear default address
1890
+ address_subparsers.add_parser(
1891
+ "clear-default", help="Clear the default address for read-only operations"
2135
1892
  )
2136
- create_proxy_parser.add_argument(
2137
- "--coldkey", required=True, help="Coldkey address (delegator)"
2138
- )
2139
- create_proxy_parser.add_argument(
2140
- "--hotkey", required=True, help="Hotkey address (delegate)"
2141
- )
2142
- create_proxy_parser.add_argument(
2143
- "--proxy-type", default="NonTransfer", help="Proxy type (default: NonTransfer)"
2144
- )
2145
- create_proxy_parser.add_argument(
2146
- "--delay",
2147
- type=int,
2148
- default=0,
2149
- help="Delay in blocks before proxy becomes active (default: 0)",
2150
- )
2151
- create_proxy_parser.add_argument(
2152
- "--password",
2153
- help="Password for the coldkey (will prompt if not provided and needed)",
2154
- )
2155
- create_proxy_parser.set_defaults(func=handle_account_proxy_create)
2156
-
2157
- # Remove proxy command
2158
- remove_proxy_parser = proxy_subparsers.add_parser(
2159
- "remove", help="Remove a proxy relationship"
2160
- )
2161
- remove_proxy_parser.add_argument(
2162
- "--coldkey", required=True, help="Coldkey address (delegator)"
2163
- )
2164
- remove_proxy_parser.add_argument(
2165
- "--hotkey", required=True, help="Hotkey address (delegate)"
2166
- )
2167
- remove_proxy_parser.add_argument(
2168
- "--password",
2169
- help="Password for the coldkey (will prompt if not provided and needed)",
2170
- )
2171
- remove_proxy_parser.add_argument(
2172
- "--proxy-type", default="NonTransfer", help="Proxy type (default: NonTransfer)"
2173
- )
2174
- remove_proxy_parser.add_argument(
2175
- "--delay",
2176
- type=int,
2177
- default=0,
2178
- help="Delay value used when creating the proxy (default: 0)",
2179
- )
2180
- remove_proxy_parser.set_defaults(func=handle_account_proxy_remove)
2181
1893
 
2182
1894
  args = parser.parse_args()
2183
1895
 
@@ -2268,18 +1980,18 @@ examples:
2268
1980
  return handle_files(
2269
1981
  client,
2270
1982
  args.account_address,
2271
- show_all_miners=args.all_miners
2272
- if hasattr(args, "all_miners")
2273
- else False,
1983
+ show_all_miners=(
1984
+ args.all_miners if hasattr(args, "all_miners") else False
1985
+ ),
2274
1986
  )
2275
1987
 
2276
1988
  elif args.command == "ec-files":
2277
1989
  return handle_ec_files(
2278
1990
  client,
2279
1991
  args.account_address,
2280
- show_all_miners=args.all_miners
2281
- if hasattr(args, "all_miners")
2282
- else False,
1992
+ show_all_miners=(
1993
+ args.all_miners if hasattr(args, "all_miners") else False
1994
+ ),
2283
1995
  show_chunks=args.show_chunks if hasattr(args, "show_chunks") else False,
2284
1996
  )
2285
1997
 
@@ -2295,18 +2007,6 @@ examples:
2295
2007
  verbose=args.verbose,
2296
2008
  )
2297
2009
 
2298
- elif args.command == "erasure-code-dir":
2299
- return handle_erasure_code_directory(
2300
- client,
2301
- args.dir_path,
2302
- args.k,
2303
- args.m,
2304
- args.chunk_size,
2305
- miner_ids,
2306
- encrypt=args.encrypt,
2307
- verbose=args.verbose,
2308
- )
2309
-
2310
2010
  elif args.command == "reconstruct":
2311
2011
  return handle_reconstruct(
2312
2012
  client, args.metadata_cid, args.output_file, verbose=args.verbose