hippius 0.2.24__tar.gz → 0.2.26__tar.gz
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.2.24 → hippius-0.2.26}/PKG-INFO +1 -1
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/__init__.py +1 -1
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/client.py +8 -1
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/ipfs.py +3 -1
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/substrate.py +51 -6
- {hippius-0.2.24 → hippius-0.2.26}/pyproject.toml +1 -1
- {hippius-0.2.24 → hippius-0.2.26}/README.md +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/cli.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/cli_assets.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/cli_handlers.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/cli_parser.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/cli_rich.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/config.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/db/README.md +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/db/env.db.template +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/db/migrations/20241201000001_create_key_storage_tables.sql +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/db/setup_database.sh +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/db_utils.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/errors.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/ipfs_core.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/key_storage.py +0 -0
- {hippius-0.2.24 → hippius-0.2.26}/hippius_sdk/utils.py +0 -0
@@ -26,7 +26,7 @@ from hippius_sdk.config import (
|
|
26
26
|
from hippius_sdk.ipfs import IPFSClient, S3PublishResult, S3DownloadResult
|
27
27
|
from hippius_sdk.utils import format_cid, format_size, hex_to_ipfs_cid
|
28
28
|
|
29
|
-
__version__ = "0.2.
|
29
|
+
__version__ = "0.2.26"
|
30
30
|
__all__ = [
|
31
31
|
"HippiusClient",
|
32
32
|
"IPFSClient",
|
@@ -518,6 +518,7 @@ class HippiusClient:
|
|
518
518
|
seed_phrase: str,
|
519
519
|
store_node: str = "http://localhost:5001",
|
520
520
|
pin_node: str = "https://store.hippius.network",
|
521
|
+
substrate_url: str = "wss://rpc.hippius.network",
|
521
522
|
) -> S3PublishResult:
|
522
523
|
"""
|
523
524
|
Publish a file to IPFS and the Hippius marketplace in one operation.
|
@@ -532,6 +533,7 @@ class HippiusClient:
|
|
532
533
|
seed_phrase: Seed phrase for blockchain transaction signing
|
533
534
|
store_node: IPFS node URL for initial upload (default: local node)
|
534
535
|
pin_node: IPFS node URL for backup pinning (default: remote service)
|
536
|
+
substrate_url: substrate url to use for the storage request.
|
535
537
|
|
536
538
|
Returns:
|
537
539
|
S3PublishResult: Object containing CID, file info, and transaction hash
|
@@ -543,7 +545,12 @@ class HippiusClient:
|
|
543
545
|
ValueError: If encryption is requested but not available
|
544
546
|
"""
|
545
547
|
return await self.ipfs_client.s3_publish(
|
546
|
-
file_path,
|
548
|
+
file_path,
|
549
|
+
encrypt,
|
550
|
+
seed_phrase,
|
551
|
+
store_node,
|
552
|
+
pin_node,
|
553
|
+
substrate_url,
|
547
554
|
)
|
548
555
|
|
549
556
|
async def s3_download(
|
@@ -2070,7 +2070,9 @@ class IPFSClient:
|
|
2070
2070
|
# Publish to substrate marketplace
|
2071
2071
|
try:
|
2072
2072
|
# Pass the seed phrase directly to avoid password prompts for encrypted config
|
2073
|
-
substrate_client = SubstrateClient(
|
2073
|
+
substrate_client = SubstrateClient(
|
2074
|
+
seed_phrase=seed_phrase, url=substrate_url
|
2075
|
+
)
|
2074
2076
|
logger.info(
|
2075
2077
|
f"Submitting storage request to substrate for file: {filename}, CID: {cid}"
|
2076
2078
|
)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import datetime
|
2
2
|
import json
|
3
3
|
import os
|
4
|
-
import pprint
|
5
4
|
import tempfile
|
6
5
|
import time
|
7
6
|
import uuid
|
@@ -9,6 +8,7 @@ from typing import Any, Dict, List, Optional, Union
|
|
9
8
|
|
10
9
|
from dotenv import load_dotenv
|
11
10
|
from mnemonic import Mnemonic
|
11
|
+
from scalecodec.exceptions import RemainingScaleBytesNotEmptyException
|
12
12
|
from substrateinterface import Keypair, SubstrateInterface
|
13
13
|
|
14
14
|
from hippius_sdk.config import (
|
@@ -21,11 +21,7 @@ from hippius_sdk.config import (
|
|
21
21
|
set_seed_phrase,
|
22
22
|
)
|
23
23
|
from hippius_sdk.errors import (
|
24
|
-
HippiusAlreadyDeletedError,
|
25
24
|
HippiusFailedSubstrateDelete,
|
26
|
-
HippiusNotFoundError,
|
27
|
-
HippiusSubstrateAuthError,
|
28
|
-
HippiusSubstrateConnectionError,
|
29
25
|
)
|
30
26
|
from hippius_sdk.utils import (
|
31
27
|
format_size,
|
@@ -608,7 +604,7 @@ class SubstrateClient:
|
|
608
604
|
keypair=self._keypair,
|
609
605
|
)
|
610
606
|
|
611
|
-
print(f"
|
607
|
+
print(f"Payment info: {json.dumps(payment_info, indent=2)}")
|
612
608
|
|
613
609
|
# Convert partialFee from Substrate (10^18 units) to a more readable format
|
614
610
|
estimated_fee = payment_info.get("partialFee", 0)
|
@@ -1258,3 +1254,52 @@ class SubstrateClient:
|
|
1258
1254
|
raise HippiusFailedSubstrateDelete(
|
1259
1255
|
f"Failed to cancel storage request: {str(e)}"
|
1260
1256
|
)
|
1257
|
+
|
1258
|
+
|
1259
|
+
def query_sub_account(self, account_id: str, seed_phrase: str) -> str | None:
|
1260
|
+
try:
|
1261
|
+
if not self._substrate:
|
1262
|
+
self.connect(seed_phrase)
|
1263
|
+
# Initialize connection to the Substrate node
|
1264
|
+
result = self._substrate.query(
|
1265
|
+
module="SubAccount",
|
1266
|
+
storage_function="SubAccount",
|
1267
|
+
params=[account_id]
|
1268
|
+
)
|
1269
|
+
|
1270
|
+
# Check if the result exists and return the value
|
1271
|
+
if result and result.value:
|
1272
|
+
return result.value
|
1273
|
+
return None
|
1274
|
+
|
1275
|
+
except Exception as e:
|
1276
|
+
print(f"Error querying SubAccount: {e}")
|
1277
|
+
return None
|
1278
|
+
|
1279
|
+
|
1280
|
+
def is_main_account(self, account_id: str, seed_phrase: str) -> bool:
|
1281
|
+
sub_account = self.query_sub_account(account_id, seed_phrase=seed_phrase)
|
1282
|
+
return sub_account is None
|
1283
|
+
|
1284
|
+
|
1285
|
+
def query_free_credits(self, account_id: str, seed_phrase) -> int:
|
1286
|
+
try:
|
1287
|
+
if not self._substrate:
|
1288
|
+
self.connect(seed_phrase)
|
1289
|
+
|
1290
|
+
# Query the FreeCredits storage map
|
1291
|
+
result = self._substrate.query(
|
1292
|
+
module="Credits",
|
1293
|
+
storage_function="FreeCredits",
|
1294
|
+
params=[account_id]
|
1295
|
+
)
|
1296
|
+
|
1297
|
+
# Return the u128 value (converted to int for Python compatibility)
|
1298
|
+
return int(result.value) if result and result.value is not None else 0
|
1299
|
+
|
1300
|
+
except RemainingScaleBytesNotEmptyException as e:
|
1301
|
+
print(f"Scale decoding error in query_free_credits: {e}")
|
1302
|
+
return 0
|
1303
|
+
except Exception as e:
|
1304
|
+
print(f"Error querying FreeCredits: {e}")
|
1305
|
+
return 0
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|