hippius 0.2.24__py3-none-any.whl → 0.2.26__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hippius
3
- Version: 0.2.24
3
+ Version: 0.2.26
4
4
  Summary: Python SDK and CLI for Hippius blockchain storage
5
5
  Home-page: https://github.com/thenervelab/hippius-sdk
6
6
  Author: Dubs
@@ -1,10 +1,10 @@
1
- hippius_sdk/__init__.py,sha256=ldt2ilZdJBE44h4J2PMfknmFTj4RyAJOCwq17AoFuq0,1474
1
+ hippius_sdk/__init__.py,sha256=ygfnOeNCKSKoBHinG89dBAK07unIL6ak4rWiAoWONgE,1474
2
2
  hippius_sdk/cli.py,sha256=aqKOYSBSWt7UhcpFt7wf9yIPJ3bznpsJ6ehOnuZ4usI,18235
3
3
  hippius_sdk/cli_assets.py,sha256=V3MX63QTiex6mCp0VDXQJ7cagm5v1s4xtsu8c1O4G_k,371
4
4
  hippius_sdk/cli_handlers.py,sha256=TQNE9os87gRzRKLEO-SIwhFnBtEFMiaSESv-Bu7omfo,128909
5
5
  hippius_sdk/cli_parser.py,sha256=z7UvgWvvy04ey-R56qZiCqYc_9RaNq1rVDkQyXoK3JU,21100
6
6
  hippius_sdk/cli_rich.py,sha256=_jTBYMdHi2--fIVwoeNi-EtkdOb6Zy_O2TUiGvU3O7s,7324
7
- hippius_sdk/client.py,sha256=Hj87gu5kapNM0V0-EgwJBsuA63HTsVHFGr2VnmwFH6I,22298
7
+ hippius_sdk/client.py,sha256=ft4gxn3NUvpiWm2R037BbsmJ9xOe8AiQpkrGQo4WUBw,22505
8
8
  hippius_sdk/config.py,sha256=Hf_aUYzG9ylzqauA_ABUSSB5mBTYbp-VtB36VQt2XDw,21981
9
9
  hippius_sdk/db/README.md,sha256=okDeI1qgkaZqXSlJ8L0xIE4UpuxO-qEGPIbXUvSHQjU,2030
10
10
  hippius_sdk/db/env.db.template,sha256=_6hEC3IvkzCDOAzG1_yJUKRUfCTMciNaJUicZpMCat4,217
@@ -12,12 +12,12 @@ hippius_sdk/db/migrations/20241201000001_create_key_storage_tables.sql,sha256=mi
12
12
  hippius_sdk/db/setup_database.sh,sha256=bDeIiTnMuX0AYCdefAfEI1CyXho6A6kLzufsDZFSXpE,3118
13
13
  hippius_sdk/db_utils.py,sha256=-x0rbN0as7Tn3PJPZBYCgreZe52FLH40ppA1TLxsg90,1851
14
14
  hippius_sdk/errors.py,sha256=LScJJmawVAx7aRzqqQguYSkf9iazSjEQEBNlD_GXZ6Y,1589
15
- hippius_sdk/ipfs.py,sha256=8hwxOlNUJu9rKfPbZg50uSokhhoIC33n8NLhZcqiSHk,94580
15
+ hippius_sdk/ipfs.py,sha256=8OLkBkNV7zEKqrtokAwrvD842qXt8qgFMIc03h_sdN0,94610
16
16
  hippius_sdk/ipfs_core.py,sha256=eOOgLoyP9mvwndnCjldnTc7z94ImYCXY3nm7JU3e_Mo,12676
17
17
  hippius_sdk/key_storage.py,sha256=oxfRRQXu8XVncUjhKJJ8rsc81JAkaj9MqZEwQa96idc,9474
18
- hippius_sdk/substrate.py,sha256=-lIavQkfE6Kw2KzllH9IMgNkzl2d6vEmU3RmwKNJQvc,48093
18
+ hippius_sdk/substrate.py,sha256=S1Sd3TLRY4BR7zbYOPzO98rielHfCf-wEglVbUQg09A,49708
19
19
  hippius_sdk/utils.py,sha256=rJ611yvwKSyiBpYU3w-SuyQxoghMGU-ePuslrPv5H5g,7388
20
- hippius-0.2.24.dist-info/METADATA,sha256=nli5Y4SxnNOR2niE6A6q1QpZK2zyC2BfgwjrSPGENaY,30088
21
- hippius-0.2.24.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
22
- hippius-0.2.24.dist-info/entry_points.txt,sha256=bFAZjW3vndretf9-8s587jA2ebMVI7puhn_lVs8jPc8,149
23
- hippius-0.2.24.dist-info/RECORD,,
20
+ hippius-0.2.26.dist-info/METADATA,sha256=iXpVVM8lf_VMvvtTZY4_hevJWIg2-xpea4yt46wzLAY,30088
21
+ hippius-0.2.26.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
22
+ hippius-0.2.26.dist-info/entry_points.txt,sha256=bFAZjW3vndretf9-8s587jA2ebMVI7puhn_lVs8jPc8,149
23
+ hippius-0.2.26.dist-info/RECORD,,
hippius_sdk/__init__.py CHANGED
@@ -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.24"
29
+ __version__ = "0.2.26"
30
30
  __all__ = [
31
31
  "HippiusClient",
32
32
  "IPFSClient",
hippius_sdk/client.py CHANGED
@@ -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, encrypt, seed_phrase, store_node, pin_node
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(
hippius_sdk/ipfs.py CHANGED
@@ -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(seed_phrase=seed_phrase, url=substrate_url)
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
  )
hippius_sdk/substrate.py CHANGED
@@ -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"]Payment info: {json.dumps(payment_info, indent=2)}")
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