hippius 0.2.6__py3-none-any.whl → 0.2.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.2.6.dist-info → hippius-0.2.7.dist-info}/METADATA +1 -1
- {hippius-0.2.6.dist-info → hippius-0.2.7.dist-info}/RECORD +8 -8
- hippius_sdk/__init__.py +1 -1
- hippius_sdk/cli.py +9 -0
- hippius_sdk/cli_handlers.py +111 -0
- hippius_sdk/cli_parser.py +26 -3
- {hippius-0.2.6.dist-info → hippius-0.2.7.dist-info}/WHEEL +0 -0
- {hippius-0.2.6.dist-info → hippius-0.2.7.dist-info}/entry_points.txt +0 -0
@@ -1,8 +1,8 @@
|
|
1
|
-
hippius_sdk/__init__.py,sha256=
|
2
|
-
hippius_sdk/cli.py,sha256=
|
1
|
+
hippius_sdk/__init__.py,sha256=t0Lg5aOSqwtAWhW8wgmVeB4IdJvUTv7Pb77vCTP0KAE,1391
|
2
|
+
hippius_sdk/cli.py,sha256=pzwoa-X5cwdA_pM-fqUyXZKHgcZODrLe4qHZuCqQMtQ,18210
|
3
3
|
hippius_sdk/cli_assets.py,sha256=V3MX63QTiex6mCp0VDXQJ7cagm5v1s4xtsu8c1O4G_k,371
|
4
|
-
hippius_sdk/cli_handlers.py,sha256=
|
5
|
-
hippius_sdk/cli_parser.py,sha256=
|
4
|
+
hippius_sdk/cli_handlers.py,sha256=xSFMGrgQRoatFgkk0CpM9h5q6URUzAol3xHGCdFHKxE,125258
|
5
|
+
hippius_sdk/cli_parser.py,sha256=Qh2wgkFBUTPldvGoTQuoNKQl5Vo0x6fPEsPBU5oymP4,20242
|
6
6
|
hippius_sdk/cli_rich.py,sha256=_jTBYMdHi2--fIVwoeNi-EtkdOb6Zy_O2TUiGvU3O7s,7324
|
7
7
|
hippius_sdk/client.py,sha256=eYURsq_so3WlEt_JY_u7J0iECFVOKDf5vsnGyR9Kngw,16974
|
8
8
|
hippius_sdk/config.py,sha256=sCWD2remLa-FodvxC2O45tiNSJD7gzv9idIStX9sF_k,21240
|
@@ -11,7 +11,7 @@ hippius_sdk/ipfs.py,sha256=xq0y87dyKvbwf52OjEAlqFNrl4Ej1Zp5g2rZa75qfN8,71706
|
|
11
11
|
hippius_sdk/ipfs_core.py,sha256=Lxu2-AWEpE-kiJDcP-cOBEeuboK7i9eNZdjgJWPa4sI,16028
|
12
12
|
hippius_sdk/substrate.py,sha256=HqR2-_9njZZ5UCKgiaGr5L5TGQ_wtj7oyA3sA5sGGyE,47525
|
13
13
|
hippius_sdk/utils.py,sha256=Ur7P_7iVnXXYvbg7a0aVrdN_8NkVxjhdngn8NzR_zpc,7066
|
14
|
-
hippius-0.2.
|
15
|
-
hippius-0.2.
|
16
|
-
hippius-0.2.
|
17
|
-
hippius-0.2.
|
14
|
+
hippius-0.2.7.dist-info/METADATA,sha256=dNUAXbSVYGvEKLsFvTpdF_SIa3B1fM9pnm7FQzJduB8,29992
|
15
|
+
hippius-0.2.7.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
16
|
+
hippius-0.2.7.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
|
17
|
+
hippius-0.2.7.dist-info/RECORD,,
|
hippius_sdk/__init__.py
CHANGED
hippius_sdk/cli.py
CHANGED
@@ -236,6 +236,15 @@ def main():
|
|
236
236
|
force=args.force if hasattr(args, "force") else False,
|
237
237
|
)
|
238
238
|
|
239
|
+
elif args.command == "pin":
|
240
|
+
return run_async_handler(
|
241
|
+
cli_handlers.handle_pin,
|
242
|
+
client,
|
243
|
+
args.cid,
|
244
|
+
publish=not args.no_publish if hasattr(args, "no_publish") else True,
|
245
|
+
miner_ids=miner_ids,
|
246
|
+
)
|
247
|
+
|
239
248
|
elif args.command == "ec-delete":
|
240
249
|
return run_async_handler(
|
241
250
|
cli_handlers.handle_ec_delete,
|
hippius_sdk/cli_handlers.py
CHANGED
@@ -1713,6 +1713,117 @@ async def handle_delete(client: HippiusClient, cid: str, force: bool = False) ->
|
|
1713
1713
|
return 0
|
1714
1714
|
|
1715
1715
|
|
1716
|
+
async def handle_pin(
|
1717
|
+
client: HippiusClient, cid: str, publish: bool = True, miner_ids=None
|
1718
|
+
) -> int:
|
1719
|
+
"""Handle the pin command to pin a CID to IPFS and optionally publish to blockchain"""
|
1720
|
+
from rich.panel import Panel
|
1721
|
+
|
1722
|
+
# First check if this CID exists
|
1723
|
+
try:
|
1724
|
+
exists_result = await client.exists(cid)
|
1725
|
+
if not exists_result["exists"]:
|
1726
|
+
error(f"CID [bold cyan]{cid}[/bold cyan] not found on IPFS")
|
1727
|
+
return 1
|
1728
|
+
except Exception as e:
|
1729
|
+
warning(f"Error checking if CID exists: {e}")
|
1730
|
+
return 1
|
1731
|
+
|
1732
|
+
# Create operation title based on publish flag
|
1733
|
+
if publish:
|
1734
|
+
info(
|
1735
|
+
f"Preparing to pin and publish content with CID: [bold cyan]{cid}[/bold cyan]"
|
1736
|
+
)
|
1737
|
+
operation_title = "Pin & Publish Operation"
|
1738
|
+
else:
|
1739
|
+
info(f"Preparing to pin content with CID: [bold cyan]{cid}[/bold cyan]")
|
1740
|
+
operation_title = "Pin Operation"
|
1741
|
+
|
1742
|
+
# Display operation details
|
1743
|
+
operation_details = [
|
1744
|
+
f"CID: [bold cyan]{cid}[/bold cyan]",
|
1745
|
+
f"Publishing to blockchain: {'Enabled' if publish else 'Disabled'}",
|
1746
|
+
]
|
1747
|
+
print_panel("\n".join(operation_details), title=operation_title)
|
1748
|
+
|
1749
|
+
# Need to authenticate if publishing to blockchain
|
1750
|
+
if publish:
|
1751
|
+
try:
|
1752
|
+
# Ensure we have a keypair for substrate operations
|
1753
|
+
_ = client.substrate_client._ensure_keypair()
|
1754
|
+
except Exception as e:
|
1755
|
+
warning(f"Failed to initialize blockchain client: {str(e)}")
|
1756
|
+
warning("Will continue with pinning but blockchain publishing may fail")
|
1757
|
+
|
1758
|
+
# Show spinner during pinning
|
1759
|
+
with console.status(
|
1760
|
+
"[cyan]Pinning content to IPFS...[/cyan]", spinner="dots"
|
1761
|
+
) as status:
|
1762
|
+
try:
|
1763
|
+
# Pin the content to IPFS
|
1764
|
+
pin_result = await client.ipfs_client.pin(cid)
|
1765
|
+
|
1766
|
+
if not pin_result.get("success", False):
|
1767
|
+
error(
|
1768
|
+
f"Failed to pin content: {pin_result.get('message', 'Unknown error')}"
|
1769
|
+
)
|
1770
|
+
return 1
|
1771
|
+
|
1772
|
+
# If publishing to blockchain, do that now
|
1773
|
+
if publish:
|
1774
|
+
status.update("[cyan]Publishing content to blockchain...[/cyan]")
|
1775
|
+
|
1776
|
+
# Create a FileInput object for the substrate client
|
1777
|
+
from hippius_sdk.substrate import FileInput
|
1778
|
+
|
1779
|
+
file_input = FileInput(file_hash=cid, file_name=f"pinned_{cid}")
|
1780
|
+
|
1781
|
+
# Submit the storage request
|
1782
|
+
tx_hash = await client.substrate_client.storage_request(
|
1783
|
+
files=[file_input], miner_ids=miner_ids
|
1784
|
+
)
|
1785
|
+
|
1786
|
+
# Create result panel with blockchain details
|
1787
|
+
gateway_url = f"{client.ipfs_client.gateway}/ipfs/{cid}"
|
1788
|
+
panel_details = [
|
1789
|
+
f"Successfully pinned and published: [bold cyan]{cid}[/bold cyan]",
|
1790
|
+
f"Gateway URL: [bold cyan]{gateway_url}[/bold cyan]",
|
1791
|
+
f"Transaction hash: [bold green]{tx_hash}[/bold green]",
|
1792
|
+
"\nThis content is now:",
|
1793
|
+
"1. Pinned to your IPFS node",
|
1794
|
+
"2. Published to the IPFS network",
|
1795
|
+
"3. Stored on the Hippius blockchain",
|
1796
|
+
]
|
1797
|
+
console.print(
|
1798
|
+
Panel(
|
1799
|
+
"\n".join(panel_details),
|
1800
|
+
title="Operation Complete",
|
1801
|
+
border_style="green",
|
1802
|
+
)
|
1803
|
+
)
|
1804
|
+
else:
|
1805
|
+
# Just pinning, no blockchain publishing
|
1806
|
+
gateway_url = f"{client.ipfs_client.gateway}/ipfs/{cid}"
|
1807
|
+
panel_details = [
|
1808
|
+
f"Successfully pinned: [bold cyan]{cid}[/bold cyan]",
|
1809
|
+
f"Gateway URL: [bold cyan]{gateway_url}[/bold cyan]",
|
1810
|
+
"\nThis content is now pinned to your IPFS node.",
|
1811
|
+
"It will remain available as long as your node is running.",
|
1812
|
+
]
|
1813
|
+
console.print(
|
1814
|
+
Panel(
|
1815
|
+
"\n".join(panel_details),
|
1816
|
+
title="Pinning Complete",
|
1817
|
+
border_style="green",
|
1818
|
+
)
|
1819
|
+
)
|
1820
|
+
|
1821
|
+
return 0
|
1822
|
+
except Exception as e:
|
1823
|
+
error(f"Error during operation: {e}")
|
1824
|
+
return 1
|
1825
|
+
|
1826
|
+
|
1716
1827
|
async def handle_ec_delete(
|
1717
1828
|
client: HippiusClient, metadata_cid: str, force: bool = False
|
1718
1829
|
) -> int:
|
hippius_sdk/cli_parser.py
CHANGED
@@ -63,13 +63,19 @@ examples:
|
|
63
63
|
|
64
64
|
# Erasure code without publishing to global IPFS network
|
65
65
|
hippius erasure-code large_file.avi --no-publish
|
66
|
-
|
66
|
+
|
67
67
|
# Reconstruct an erasure-coded file
|
68
68
|
hippius reconstruct QmMetadataHash reconstructed_file.mp4
|
69
|
-
|
69
|
+
|
70
|
+
# Pin a CID to IPFS and publish to blockchain
|
71
|
+
hippius pin QmHash
|
72
|
+
|
73
|
+
# Pin a CID to IPFS without publishing to blockchain
|
74
|
+
hippius pin QmHash --no-publish
|
75
|
+
|
70
76
|
# Delete a file from IPFS and marketplace
|
71
77
|
hippius delete QmHash
|
72
|
-
|
78
|
+
|
73
79
|
# Delete an erasure-coded file and all its chunks
|
74
80
|
hippius ec-delete QmMetadataHash
|
75
81
|
""",
|
@@ -250,6 +256,23 @@ def add_storage_commands(subparsers):
|
|
250
256
|
help="Delete without confirmation prompt",
|
251
257
|
)
|
252
258
|
|
259
|
+
# Pin command
|
260
|
+
pin_parser = subparsers.add_parser(
|
261
|
+
"pin",
|
262
|
+
help="Pin a CID to IPFS and publish to blockchain",
|
263
|
+
)
|
264
|
+
pin_parser.add_argument("cid", help="CID to pin")
|
265
|
+
pin_parser.add_argument(
|
266
|
+
"--publish",
|
267
|
+
action="store_true",
|
268
|
+
help="Publish file to IPFS and store on the blockchain (default)",
|
269
|
+
)
|
270
|
+
pin_parser.add_argument(
|
271
|
+
"--no-publish",
|
272
|
+
action="store_true",
|
273
|
+
help="Don't publish file to blockchain (local pinning only)",
|
274
|
+
)
|
275
|
+
|
253
276
|
# Keygen command
|
254
277
|
keygen_parser = subparsers.add_parser(
|
255
278
|
"keygen", help="Generate an encryption key for secure file storage"
|
File without changes
|
File without changes
|