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-0.1.11.dist-info → hippius-0.1.13.dist-info}/METADATA +1 -105
- hippius-0.1.13.dist-info/RECORD +10 -0
- hippius_sdk/__init__.py +15 -19
- hippius_sdk/cli.py +195 -495
- hippius_sdk/client.py +7 -8
- hippius_sdk/config.py +7 -77
- hippius_sdk/ipfs.py +12 -12
- hippius_sdk/substrate.py +8 -5
- hippius-0.1.11.dist-info/RECORD +0 -12
- hippius_sdk/account.py +0 -648
- hippius_sdk/utils.py +0 -87
- {hippius-0.1.11.dist-info → hippius-0.1.13.dist-info}/WHEEL +0 -0
- {hippius-0.1.11.dist-info → hippius-0.1.13.dist-info}/entry_points.txt +0 -0
hippius_sdk/client.py
CHANGED
@@ -3,13 +3,11 @@ Main client for the Hippius SDK.
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
import os
|
6
|
-
from typing import Dict,
|
6
|
+
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
7
|
+
|
8
|
+
from hippius_sdk.config import get_config_value, get_encryption_key
|
7
9
|
from hippius_sdk.ipfs import IPFSClient
|
8
|
-
from hippius_sdk.substrate import
|
9
|
-
from hippius_sdk.config import (
|
10
|
-
get_config_value,
|
11
|
-
get_encryption_key,
|
12
|
-
)
|
10
|
+
from hippius_sdk.substrate import FileInput, SubstrateClient
|
13
11
|
|
14
12
|
|
15
13
|
class HippiusClient:
|
@@ -272,10 +270,11 @@ class HippiusClient:
|
|
272
270
|
ImportError: If PyNaCl is not installed
|
273
271
|
"""
|
274
272
|
try:
|
275
|
-
import nacl.utils
|
276
|
-
import nacl.secret
|
277
273
|
import base64
|
278
274
|
|
275
|
+
import nacl.secret
|
276
|
+
import nacl.utils
|
277
|
+
|
279
278
|
# Generate a random key
|
280
279
|
key = nacl.utils.random(nacl.secret.SecretBox.KEY_SIZE)
|
281
280
|
|
hippius_sdk/config.py
CHANGED
@@ -5,13 +5,13 @@ This module handles loading and saving configuration from the user's home direct
|
|
5
5
|
specifically in ~/.hippius/config.
|
6
6
|
"""
|
7
7
|
|
8
|
-
import os
|
9
|
-
import json
|
10
8
|
import base64
|
11
|
-
import hashlib
|
12
9
|
import getpass
|
10
|
+
import hashlib
|
11
|
+
import json
|
12
|
+
import os
|
13
13
|
from pathlib import Path
|
14
|
-
from typing import Dict,
|
14
|
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
15
15
|
|
16
16
|
# Define constants
|
17
17
|
CONFIG_DIR = os.path.expanduser("~/.hippius")
|
@@ -196,9 +196,10 @@ def _derive_key_from_password(
|
|
196
196
|
"""
|
197
197
|
# Import cryptography for PBKDF2
|
198
198
|
try:
|
199
|
-
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
200
|
-
from cryptography.hazmat.primitives import hashes
|
201
199
|
import os
|
200
|
+
|
201
|
+
from cryptography.hazmat.primitives import hashes
|
202
|
+
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
202
203
|
except ImportError:
|
203
204
|
raise ImportError(
|
204
205
|
"cryptography is required for password-based encryption. Install it with: pip install cryptography"
|
@@ -740,76 +741,5 @@ def reset_config() -> bool:
|
|
740
741
|
return save_config(DEFAULT_CONFIG.copy())
|
741
742
|
|
742
743
|
|
743
|
-
def get_keypair(
|
744
|
-
ss58_address: Optional[str] = None, account_name: Optional[str] = None
|
745
|
-
) -> "Keypair":
|
746
|
-
"""
|
747
|
-
Get a Keypair object for a given SS58 address or account name.
|
748
|
-
|
749
|
-
This function will attempt to find the specified account and generate
|
750
|
-
a Keypair object using the stored seed phrase.
|
751
|
-
|
752
|
-
Args:
|
753
|
-
ss58_address: SS58 address of the account
|
754
|
-
account_name: Name of the account (used if ss58_address is None)
|
755
|
-
|
756
|
-
Returns:
|
757
|
-
Keypair: A substrate Keypair object
|
758
|
-
|
759
|
-
Raises:
|
760
|
-
ValueError: If the account cannot be found or if the seed phrase is not available
|
761
|
-
ImportError: If the required dependencies are not installed
|
762
|
-
"""
|
763
|
-
# Import here to avoid circular imports
|
764
|
-
try:
|
765
|
-
from substrateinterface import Keypair
|
766
|
-
except ImportError:
|
767
|
-
raise ImportError(
|
768
|
-
"Substrate interface is required to get a keypair. "
|
769
|
-
"Install with: pip install substrate-interface"
|
770
|
-
)
|
771
|
-
|
772
|
-
# If ss58_address is provided, look for a matching account
|
773
|
-
if ss58_address:
|
774
|
-
accounts = list_accounts()
|
775
|
-
found_account = None
|
776
|
-
|
777
|
-
for name, data in accounts.items():
|
778
|
-
if data.get("ss58_address") == ss58_address:
|
779
|
-
found_account = name
|
780
|
-
break
|
781
|
-
|
782
|
-
if found_account:
|
783
|
-
account_name = found_account
|
784
|
-
else:
|
785
|
-
raise ValueError(f"No account found with SS58 address: {ss58_address}")
|
786
|
-
|
787
|
-
# If no account_name by this point, use the active account
|
788
|
-
if not account_name:
|
789
|
-
account_name = get_active_account()
|
790
|
-
if not account_name:
|
791
|
-
raise ValueError(
|
792
|
-
"No account specified and no active account. "
|
793
|
-
"Set an active account with: hippius account switch <account_name>"
|
794
|
-
)
|
795
|
-
|
796
|
-
# Get the seed phrase for the account
|
797
|
-
seed_phrase = get_seed_phrase(account_name=account_name)
|
798
|
-
if not seed_phrase:
|
799
|
-
if get_config_value("substrate", "seed_phrase_encoded"):
|
800
|
-
raise ValueError(
|
801
|
-
f"The seed phrase for account '{account_name}' is encrypted. "
|
802
|
-
f"Please decrypt it first with: hippius seed decode --account {account_name}"
|
803
|
-
)
|
804
|
-
else:
|
805
|
-
raise ValueError(
|
806
|
-
f"No seed phrase found for account '{account_name}'. "
|
807
|
-
f'Set one with: hippius seed set "your seed phrase" --account {account_name}'
|
808
|
-
)
|
809
|
-
|
810
|
-
# Create and return the keypair
|
811
|
-
return Keypair.create_from_mnemonic(seed_phrase)
|
812
|
-
|
813
|
-
|
814
744
|
# Initialize configuration on module import
|
815
745
|
ensure_config_dir()
|
hippius_sdk/ipfs.py
CHANGED
@@ -2,21 +2,20 @@
|
|
2
2
|
IPFS operations for the Hippius SDK.
|
3
3
|
"""
|
4
4
|
|
5
|
-
import os
|
6
|
-
import json
|
7
|
-
import requests
|
8
5
|
import base64
|
9
|
-
import time
|
10
|
-
import tempfile
|
11
6
|
import hashlib
|
7
|
+
import json
|
8
|
+
import os
|
9
|
+
import tempfile
|
10
|
+
import time
|
12
11
|
import uuid
|
13
|
-
from typing import Dict,
|
12
|
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
13
|
+
|
14
14
|
import ipfshttpclient
|
15
|
+
import requests
|
15
16
|
from dotenv import load_dotenv
|
16
|
-
|
17
|
-
|
18
|
-
get_encryption_key,
|
19
|
-
)
|
17
|
+
|
18
|
+
from hippius_sdk.config import get_config_value, get_encryption_key
|
20
19
|
|
21
20
|
# Import PyNaCl for encryption
|
22
21
|
try:
|
@@ -704,9 +703,10 @@ class IPFSClient:
|
|
704
703
|
|
705
704
|
# If the above doesn't work, try the standard CID decoding
|
706
705
|
try:
|
707
|
-
import base58
|
708
706
|
import binascii
|
709
707
|
|
708
|
+
import base58
|
709
|
+
|
710
710
|
# Try to decode hex to binary then to base58 for CIDv0
|
711
711
|
try:
|
712
712
|
binary_data = binascii.unhexlify(cid)
|
@@ -1585,7 +1585,7 @@ class IPFSClient:
|
|
1585
1585
|
|
1586
1586
|
# Step 2: Import substrate client if we need it
|
1587
1587
|
if substrate_client is None:
|
1588
|
-
from hippius_sdk.substrate import
|
1588
|
+
from hippius_sdk.substrate import FileInput, SubstrateClient
|
1589
1589
|
|
1590
1590
|
substrate_client = SubstrateClient()
|
1591
1591
|
else:
|
hippius_sdk/substrate.py
CHANGED
@@ -4,18 +4,20 @@ Substrate operations for the Hippius SDK.
|
|
4
4
|
Note: This functionality is coming soon and not implemented yet.
|
5
5
|
"""
|
6
6
|
|
7
|
-
import os
|
8
7
|
import json
|
8
|
+
import os
|
9
9
|
import uuid
|
10
|
-
from typing import Dict,
|
11
|
-
|
10
|
+
from typing import Any, Dict, List, Optional, Union
|
11
|
+
|
12
12
|
from dotenv import load_dotenv
|
13
|
+
from substrateinterface import Keypair, SubstrateInterface
|
14
|
+
|
13
15
|
from hippius_sdk.config import (
|
16
|
+
get_account_address,
|
17
|
+
get_active_account,
|
14
18
|
get_config_value,
|
15
19
|
get_seed_phrase,
|
16
20
|
set_seed_phrase,
|
17
|
-
get_account_address,
|
18
|
-
get_active_account,
|
19
21
|
)
|
20
22
|
|
21
23
|
# Load environment variables
|
@@ -275,6 +277,7 @@ class SubstrateClient:
|
|
275
277
|
|
276
278
|
# Step 2: Upload the JSON file to IPFS
|
277
279
|
import tempfile
|
280
|
+
|
278
281
|
from hippius_sdk.ipfs import IPFSClient
|
279
282
|
|
280
283
|
ipfs_client = IPFSClient()
|
hippius-0.1.11.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
hippius_sdk/__init__.py,sha256=OluIKx43ZOGvMI0W06B4bTTcmOJz4e6lq46GLBbPg8M,1402
|
2
|
-
hippius_sdk/account.py,sha256=R0lsyUAqe4nmPyiMt4hGDRucoSrpeLouWBVe7DP20Bc,24308
|
3
|
-
hippius_sdk/cli.py,sha256=yG1K0N2syohVUIoz9FSoBPTEVpc6ZsDIiPM1H0VsHwU,85646
|
4
|
-
hippius_sdk/client.py,sha256=54tsg4k29sqt3F77LQJ_vhzzTR73QuZ_edqI_BvZM1E,14905
|
5
|
-
hippius_sdk/config.py,sha256=wrVU0599aH39NIVRL59pZPyHXRevATQR9zwIUkCaWFE,25389
|
6
|
-
hippius_sdk/ipfs.py,sha256=9fds5MJwVb7t8IqROM70x9fWgyk9_Ot5psat_hMnRN8,63969
|
7
|
-
hippius_sdk/substrate.py,sha256=V49s1VYbl94Wk8-IH8DQsXLmRsAShGhIX9aYSY0BkBk,33034
|
8
|
-
hippius_sdk/utils.py,sha256=FSdVhYuCsKRNZiN9-XdzN2HESHXAVcWEpOpb3CLmVPI,2192
|
9
|
-
hippius-0.1.11.dist-info/METADATA,sha256=8O4ifXpoKIvnchWph3WdHLytZniD37M8exHG_HhXux8,31735
|
10
|
-
hippius-0.1.11.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
11
|
-
hippius-0.1.11.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
|
12
|
-
hippius-0.1.11.dist-info/RECORD,,
|