hippius 0.1.6__py3-none-any.whl → 0.1.7__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.6.dist-info → hippius-0.1.7.dist-info}/METADATA +274 -4
- hippius-0.1.7.dist-info/RECORD +10 -0
- hippius_sdk/__init__.py +45 -1
- hippius_sdk/cli.py +1269 -36
- hippius_sdk/client.py +53 -12
- hippius_sdk/config.py +744 -0
- hippius_sdk/ipfs.py +178 -87
- hippius_sdk/substrate.py +130 -68
- hippius-0.1.6.dist-info/RECORD +0 -9
- {hippius-0.1.6.dist-info → hippius-0.1.7.dist-info}/WHEEL +0 -0
- {hippius-0.1.6.dist-info → hippius-0.1.7.dist-info}/entry_points.txt +0 -0
hippius_sdk/client.py
CHANGED
@@ -3,9 +3,13 @@ Main client for the Hippius SDK.
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
import os
|
6
|
-
from typing import Dict, Any, Optional, List, Union
|
6
|
+
from typing import Dict, Any, Optional, List, Union, Tuple, Set
|
7
7
|
from hippius_sdk.ipfs import IPFSClient
|
8
8
|
from hippius_sdk.substrate import SubstrateClient, FileInput
|
9
|
+
from hippius_sdk.config import (
|
10
|
+
get_config_value,
|
11
|
+
get_encryption_key,
|
12
|
+
)
|
9
13
|
|
10
14
|
|
11
15
|
class HippiusClient:
|
@@ -17,10 +21,12 @@ class HippiusClient:
|
|
17
21
|
|
18
22
|
def __init__(
|
19
23
|
self,
|
20
|
-
ipfs_gateway: str =
|
21
|
-
ipfs_api_url: str =
|
22
|
-
substrate_url: str = None,
|
23
|
-
substrate_seed_phrase: str = None,
|
24
|
+
ipfs_gateway: Optional[str] = None,
|
25
|
+
ipfs_api_url: Optional[str] = None,
|
26
|
+
substrate_url: Optional[str] = None,
|
27
|
+
substrate_seed_phrase: Optional[str] = None,
|
28
|
+
seed_phrase_password: Optional[str] = None,
|
29
|
+
account_name: Optional[str] = None,
|
24
30
|
encrypt_by_default: Optional[bool] = None,
|
25
31
|
encryption_key: Optional[bytes] = None,
|
26
32
|
):
|
@@ -28,13 +34,45 @@ class HippiusClient:
|
|
28
34
|
Initialize the Hippius client.
|
29
35
|
|
30
36
|
Args:
|
31
|
-
ipfs_gateway: IPFS gateway URL for downloading content
|
32
|
-
ipfs_api_url: IPFS API URL for uploading content
|
33
|
-
substrate_url: WebSocket URL of the Hippius substrate node
|
34
|
-
substrate_seed_phrase: Seed phrase for Substrate account
|
35
|
-
|
36
|
-
|
37
|
+
ipfs_gateway: IPFS gateway URL for downloading content (from config if None)
|
38
|
+
ipfs_api_url: IPFS API URL for uploading content (from config if None)
|
39
|
+
substrate_url: WebSocket URL of the Hippius substrate node (from config if None)
|
40
|
+
substrate_seed_phrase: Seed phrase for Substrate account (from config if None)
|
41
|
+
seed_phrase_password: Password to decrypt the seed phrase if it's encrypted
|
42
|
+
account_name: Name of the account to use (uses active account if None)
|
43
|
+
encrypt_by_default: Whether to encrypt files by default (from config if None)
|
44
|
+
encryption_key: Encryption key for NaCl secretbox (from config if None)
|
37
45
|
"""
|
46
|
+
# Load configuration values if not explicitly provided
|
47
|
+
if ipfs_gateway is None:
|
48
|
+
ipfs_gateway = get_config_value("ipfs", "gateway", "https://ipfs.io")
|
49
|
+
|
50
|
+
if ipfs_api_url is None:
|
51
|
+
ipfs_api_url = get_config_value(
|
52
|
+
"ipfs", "api_url", "https://relay-fr.hippius.network"
|
53
|
+
)
|
54
|
+
|
55
|
+
# Check if local IPFS is enabled in config
|
56
|
+
if get_config_value("ipfs", "local_ipfs", False):
|
57
|
+
ipfs_api_url = "http://localhost:5001"
|
58
|
+
|
59
|
+
if substrate_url is None:
|
60
|
+
substrate_url = get_config_value(
|
61
|
+
"substrate", "url", "wss://rpc.hippius.network"
|
62
|
+
)
|
63
|
+
|
64
|
+
if substrate_seed_phrase is None:
|
65
|
+
substrate_seed_phrase = get_config_value("substrate", "seed_phrase")
|
66
|
+
|
67
|
+
if encrypt_by_default is None:
|
68
|
+
encrypt_by_default = get_config_value(
|
69
|
+
"encryption", "encrypt_by_default", False
|
70
|
+
)
|
71
|
+
|
72
|
+
if encryption_key is None:
|
73
|
+
encryption_key = get_encryption_key()
|
74
|
+
|
75
|
+
# Initialize IPFS client
|
38
76
|
self.ipfs_client = IPFSClient(
|
39
77
|
gateway=ipfs_gateway,
|
40
78
|
api_url=ipfs_api_url,
|
@@ -45,7 +83,10 @@ class HippiusClient:
|
|
45
83
|
# Initialize Substrate client
|
46
84
|
try:
|
47
85
|
self.substrate_client = SubstrateClient(
|
48
|
-
url=substrate_url,
|
86
|
+
url=substrate_url,
|
87
|
+
seed_phrase=substrate_seed_phrase,
|
88
|
+
password=seed_phrase_password,
|
89
|
+
account_name=account_name,
|
49
90
|
)
|
50
91
|
except Exception as e:
|
51
92
|
print(f"Warning: Could not initialize Substrate client: {e}")
|