hippius 0.1.6__py3-none-any.whl → 0.1.9__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,21 +1,22 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hippius
3
- Version: 0.1.6
3
+ Version: 0.1.9
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
7
7
  Author-email: dubs@dubs.rs
8
- Requires-Python: >=3.8,<4.0
8
+ Requires-Python: >=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
9
9
  Classifier: Development Status :: 3 - Alpha
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.9
17
17
  Provides-Extra: clipboard
18
18
  Requires-Dist: base58 (>=2.1.1,<3.0.0)
19
+ Requires-Dist: cryptography (>=44.0.0,<45.0.0)
19
20
  Requires-Dist: ipfshttpclient (>=0.7.0,<0.8.0)
20
21
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
21
22
  Requires-Dist: pynacl (>=1.5.0,<2.0.0)
@@ -66,7 +67,7 @@ client = HippiusClient()
66
67
  # Or specify custom endpoints
67
68
  client = HippiusClient(
68
69
  ipfs_gateway="https://ipfs.io", # For downloads (default)
69
- ipfs_api_url="http://relay-fr.hippius.network:5001", # For uploads (default)
70
+ ipfs_api_url="https://store.hippius.network", # For uploads (default)
70
71
  )
71
72
 
72
73
  # Upload a file to IPFS
@@ -271,6 +272,150 @@ The CLI provides detailed output during the process, including:
271
272
  - Storage confirmation in the marketplace
272
273
  - Instructions for reconstruction
273
274
 
275
+ #### Erasure Coding
276
+
277
+ Erasure coding offers redundancy by splitting files into chunks:
278
+
279
+ ```bash
280
+ # Basic erasure coding with default parameters (k=3, m=5)
281
+ hippius erasure-code my_large_file.zip
282
+
283
+ # Erasure code with custom parameters for increased redundancy
284
+ hippius erasure-code my_important_file.mp4 --k 4 --m 10 --chunk-size 2097152 --encrypt
285
+ ```
286
+
287
+ To reconstruct a file from erasure-coded chunks:
288
+
289
+ ```bash
290
+ hippius reconstruct QmMetadataCID reconstructed_filename
291
+ ```
292
+
293
+ #### Listing Erasure Coded Files
294
+
295
+ To view only your erasure-coded files:
296
+
297
+ ```bash
298
+ # List all erasure-coded files
299
+ hippius ec-files
300
+
301
+ # Show all miners for each erasure-coded file
302
+ hippius ec-files --all-miners
303
+
304
+ # Show associated chunks for each erasure-coded file
305
+ hippius ec-files --show-chunks
306
+ ```
307
+
308
+ This command provides detailed information about each erasure-coded file including:
309
+ - Original file name
310
+ - Metadata CID
311
+ - File size
312
+ - Number of chunks
313
+ - Miners storing the file
314
+ - Reconstruction command
315
+
316
+ The `ec-files` command is optimized for performance through parallel processing and intelligent filtering, making it efficient even with large numbers of files.
317
+
318
+ #### Performance Considerations
319
+
320
+ The erasure coding implementation has been optimized for:
321
+
322
+ 1. **Speed**: Parallel processing for file operations
323
+ 2. **Memory efficiency**: Files are processed in chunks to minimize memory usage
324
+ 3. **Auto-tuning**: Parameters like chunk size are automatically adjusted for small files
325
+ 4. **Intelligent filtering**: The system can quickly identify potential erasure-coded files
326
+
327
+ For extremely large files (>1GB), consider using larger chunk sizes to improve performance:
328
+
329
+ ```bash
330
+ hippius erasure-code large_video.mp4 --chunk-size 10485760 # 10MB chunks
331
+ ```
332
+
333
+ #### Directory Support for Erasure Coding
334
+
335
+ Hippius SDK now supports applying erasure coding to entire directories:
336
+
337
+ ```bash
338
+ # Apply erasure coding to an entire directory
339
+ hippius erasure-code my_directory/
340
+
341
+ # The CLI will detect that it's a directory and offer two options:
342
+ # 1. Archive the directory first, then erasure code the archive
343
+ # 2. Apply erasure coding to each file in the directory individually
344
+ ```
345
+
346
+ When choosing the second option, the system will process each file in the directory individually, adjusting parameters like chunk size automatically for small files. A summary of the operation will be displayed, showing:
347
+ - Total files processed
348
+ - Successfully coded files with their metadata CIDs
349
+ - Any files that failed, with error details
350
+
351
+ To reconstruct a file from erasure-coded chunks:
352
+
353
+ ```bash
354
+ hippius reconstruct QmMetadataCID reconstructed_filename
355
+ ```
356
+
357
+ #### Default Address Management
358
+
359
+ Hippius SDK now allows setting a default address for read-only operations, making it easier to use commands like `files` and `ec-files` without specifying an account address each time:
360
+
361
+ ```bash
362
+ # Set a default address for read-only operations
363
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
364
+
365
+ # View the currently set default address
366
+ hippius address get-default
367
+
368
+ # Clear the default address
369
+ hippius address clear-default
370
+ ```
371
+
372
+ Once a default address is set, commands like `hippius files` and `hippius ec-files` will automatically use this address when no explicit address is provided.
373
+
374
+ #### Troubleshooting
375
+
376
+ 1. **IPFS Connection Issues**: Make sure you have either:
377
+ - A local IPFS daemon running (`ipfs daemon` in a separate terminal)
378
+ - Or proper environment variables set in `.env` for remote connections
379
+
380
+ 2. **Missing Dependencies**: If you get import errors, ensure all dependencies are installed:
381
+ ```bash
382
+ poetry install --all-extras
383
+ ```
384
+
385
+ 3. **CLI Not Found**: If the `hippius` command isn't found after installing, try:
386
+ ```bash
387
+ # Verify it's installed
388
+ poetry show hippius
389
+
390
+ # Check your PATH
391
+ which hippius
392
+ ```
393
+
394
+ 4. **Default Address Issues**: If you receive errors about missing account address:
395
+ ```bash
396
+ # Set a default address for read-only operations
397
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
398
+ ```
399
+
400
+ 5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
401
+
402
+ 6. **Erasure Coding Problems**:
403
+ - **"Wrong length for input blocks"**: This typically happens with very small files
404
+ ```bash
405
+ # Try smaller k and m values for small files
406
+ hippius erasure-code small_file.txt --k 2 --m 3
407
+ ```
408
+ - **Directories can't be directly coded**: Use the directory support option when prompted
409
+ - **"zfec is required"**: Install the missing package
410
+ ```bash
411
+ pip install zfec
412
+ poetry add zfec
413
+ ```
414
+ - **Slow performance with large files**: Increase chunk size
415
+ ```bash
416
+ hippius erasure-code large_file.mp4 --chunk-size 5242880 # 5MB chunks
417
+ ```
418
+
274
419
  ## Command Line Interface
275
420
 
276
421
  The Hippius SDK includes a powerful command-line interface (CLI) that provides access to all major features of the SDK directly from your terminal.
@@ -282,7 +427,7 @@ The Hippius SDK includes a powerful command-line interface (CLI) that provides a
282
427
  hippius --help
283
428
 
284
429
  # Set global options
285
- hippius --gateway https://ipfs.io --api-url https://relay-fr.hippius.network --verbose
430
+ hippius --gateway https://ipfs.io --api-url https://store.hippius.network --verbose
286
431
  ```
287
432
 
288
433
  ### IPFS Operations
@@ -321,6 +466,12 @@ hippius files 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
321
466
 
322
467
  # Show all miners for each file
323
468
  hippius files --all-miners
469
+
470
+ # View only erasure-coded files
471
+ hippius ec-files
472
+
473
+ # View erasure-coded files with details about chunks
474
+ hippius ec-files --show-chunks
324
475
  ```
325
476
 
326
477
  ### Encryption
@@ -350,15 +501,26 @@ hippius erasure-code important_data.zip --k 4 --m 10 --chunk-size 2097152 --encr
350
501
 
351
502
  # Reconstruct a file from its metadata
352
503
  hippius reconstruct QmMetadataCID reconstructed_file.mp4
504
+
505
+ # List all your erasure-coded files with metadata CIDs
506
+ hippius ec-files
507
+
508
+ # Show all miners for each erasure-coded file
509
+ hippius ec-files --all-miners
510
+
511
+ # Show detailed information including associated chunks
512
+ hippius ec-files --show-chunks
353
513
  ```
354
514
 
515
+ The `ec-files` command has been optimized for performance and can now handle large numbers of files efficiently through parallel processing.
516
+
355
517
  ### Using Environment Variables
356
518
 
357
519
  The CLI automatically reads from your `.env` file for common settings:
358
520
 
359
521
  ```
360
522
  IPFS_GATEWAY=https://ipfs.io
361
- IPFS_API_URL=https://relay-fr.hippius.network
523
+ IPFS_API_URL=https://store.hippius.network
362
524
  SUBSTRATE_URL=wss://rpc.hippius.network
363
525
  SUBSTRATE_SEED_PHRASE="your twelve word seed phrase..."
364
526
  SUBSTRATE_DEFAULT_MINERS=miner1,miner2,miner3
@@ -432,6 +594,88 @@ The SDK provides robust connection handling for IPFS:
432
594
 
433
595
  This dual approach ensures maximum compatibility across different environments. The fallback happens automatically, so you don't need to worry about it.
434
596
 
597
+ ## Configuration
598
+
599
+ Hippius SDK now supports persistent configuration stored in your home directory at `~/.hippius/config.json`. This makes it easier to manage your settings without having to specify them each time or maintain environment variables.
600
+
601
+ ### Configuration Management
602
+
603
+ The configuration file is automatically created with default values when you first use the SDK. You can manage it using the CLI:
604
+
605
+ ```bash
606
+ # List all configuration settings
607
+ hippius config list
608
+
609
+ # Get a specific configuration value
610
+ hippius config get ipfs gateway
611
+
612
+ # Set a configuration value
613
+ hippius config set ipfs gateway https://ipfs.io
614
+
615
+ # Import settings from your .env file
616
+ hippius config import-env
617
+
618
+ # Reset configuration to default values
619
+ hippius config reset
620
+ ```
621
+
622
+ ### Configuration Structure
623
+
624
+ The configuration is organized in the following sections:
625
+
626
+ ```json
627
+ {
628
+ "ipfs": {
629
+ "gateway": "https://ipfs.io",
630
+ "api_url": "https://store.hippius.network",
631
+ "local_ipfs": false
632
+ },
633
+ "substrate": {
634
+ "url": "wss://rpc.hippius.network",
635
+ "seed_phrase": null,
636
+ "default_miners": [],
637
+ "default_address": null
638
+ },
639
+ "encryption": {
640
+ "encrypt_by_default": false,
641
+ "encryption_key": null
642
+ },
643
+ "erasure_coding": {
644
+ "default_k": 3,
645
+ "default_m": 5,
646
+ "default_chunk_size": 1048576
647
+ },
648
+ "cli": {
649
+ "verbose": false,
650
+ "max_retries": 3
651
+ }
652
+ }
653
+ ```
654
+
655
+ ### Environment Variables and Configuration
656
+
657
+ The SDK still supports environment variables for backward compatibility. You can import settings from your `.env` file to the configuration using:
658
+
659
+ ```bash
660
+ hippius config import-env
661
+ ```
662
+
663
+ ### Using Configuration in Code
664
+
665
+ ```python
666
+ from hippius_sdk import get_config_value, set_config_value, HippiusClient
667
+
668
+ # Get a configuration value
669
+ gateway = get_config_value("ipfs", "gateway")
670
+ print(f"Current gateway: {gateway}")
671
+
672
+ # Set a configuration value
673
+ set_config_value("ipfs", "gateway", "https://dweb.link")
674
+
675
+ # Client will automatically use configuration values
676
+ client = HippiusClient()
677
+ ```
678
+
435
679
  ## Development
436
680
 
437
681
  ```bash
@@ -575,7 +819,13 @@ hippius --help
575
819
  which hippius
576
820
  ```
577
821
 
578
- 4. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
822
+ 4. **Default Address Issues**: If you receive errors about missing account address:
823
+ ```bash
824
+ # Set a default address for read-only operations
825
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
826
+ ```
827
+
828
+ 5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
579
829
 
580
830
  ## Contributing
581
831
 
@@ -585,3 +835,111 @@ Contributions are welcome! Please feel free to submit a Pull Request.
585
835
 
586
836
  This project is licensed under the MIT License - see the LICENSE file for details.
587
837
 
838
+ ### Seed Phrase Management
839
+
840
+ For enhanced security, Hippius SDK supports encrypting your Substrate seed phrase with a password:
841
+
842
+ ```bash
843
+ # Set a seed phrase in plain text
844
+ hippius seed set "your twelve word seed phrase here"
845
+
846
+ # Set a seed phrase and encrypt it with a password
847
+ hippius seed set "your twelve word seed phrase here" --encode
848
+ # You will be prompted to enter and confirm a password
849
+
850
+ # Check the status of your seed phrase
851
+ hippius seed status
852
+
853
+ # Encrypt an existing seed phrase with a password
854
+ hippius seed encode
855
+ # You will be prompted to enter and confirm a password
856
+
857
+ # Temporarily decrypt and view your seed phrase
858
+ hippius seed decode
859
+ # You will be prompted to enter your password
860
+ ```
861
+
862
+ > **Note:** Password-based encryption requires both the `pynacl` and `cryptography` Python packages, which are included as dependencies when you install Hippius SDK.
863
+
864
+ To use password-based seed phrase encryption:
865
+ 1. Set your seed phrase with encryption: `hippius seed set "your seed phrase" --encode`
866
+ 2. You'll be prompted to enter and confirm a secure password
867
+ 3. The seed phrase will be encrypted using your password and stored safely
868
+ 4. When the SDK needs to use your seed phrase, you'll be prompted for your password
869
+ 5. Your password is never stored - it's only used temporarily to decrypt the seed phrase
870
+
871
+ This provides enhanced security by:
872
+ - Protecting your seed phrase with a password only you know
873
+ - Never storing the seed phrase in plain text
874
+ - Using strong cryptography (PBKDF2 with SHA-256) to derive encryption keys
875
+ - Requiring your password every time the seed phrase is needed
876
+
877
+ When interacting with the Hippius SDK programmatically, you can provide the password when initializing clients:
878
+
879
+ ```python
880
+ from hippius_sdk import HippiusClient
881
+
882
+ # The client will prompt for password when needed to decrypt the seed phrase
883
+ client = HippiusClient()
884
+
885
+ # Or you can provide a password when initializing
886
+ client = HippiusClient(seed_phrase_password="your-password")
887
+ ```
888
+
889
+ ### Multi-Account Management
890
+
891
+ Hippius SDK now supports managing multiple named accounts, each with their own seed phrase:
892
+
893
+ ```bash
894
+ # Set a seed phrase for a named account
895
+ hippius seed set "your seed phrase here" --account "my-validator"
896
+
897
+ # Set another seed phrase for a different account
898
+ hippius seed set "another seed phrase" --account "my-developer-account" --encode
899
+
900
+ # List all configured accounts
901
+ hippius account list
902
+
903
+ # Switch the active account
904
+ hippius account switch my-developer-account
905
+
906
+ # Check the status of a specific account
907
+ hippius seed status --account my-validator
908
+
909
+ # Delete an account
910
+ hippius account delete my-developer-account
911
+ ```
912
+
913
+ Key features of the multi-account system:
914
+
915
+ 1. **Named Accounts**: Each account has a unique name for easy identification
916
+ 2. **SS58 Address Storage**: Addresses are stored unencrypted for convenient access
917
+ 3. **Active Account**: One account is designated as "active" and used by default
918
+ 4. **Shared Password**: All accounts use the same password for encryption
919
+ 5. **Separate Encryption**: Each account can choose whether to encrypt its seed phrase
920
+
921
+ To use multiple accounts in your code:
922
+
923
+ ```python
924
+ from hippius_sdk import HippiusClient, set_active_account, list_accounts
925
+
926
+ # List all accounts
927
+ accounts = list_accounts()
928
+ for name, data in accounts.items():
929
+ print(f"{name}: {data.get('ss58_address')}")
930
+
931
+ # Switch the active account
932
+ set_active_account("my-validator")
933
+
934
+ # Create a client with the active account
935
+ client = HippiusClient(seed_phrase_password="your-password")
936
+
937
+ # Or specify a different account to use
938
+ client = HippiusClient(
939
+ account_name="my-developer-account",
940
+ seed_phrase_password="your-password"
941
+ )
942
+ ```
943
+
944
+ The multi-account system makes it easier to manage multiple identities while maintaining security and convenience.
945
+
@@ -0,0 +1,10 @@
1
+ hippius_sdk/__init__.py,sha256=fs2pZ_wIl3eaUz6qFprcRsZhYakqv6-qm468NZh-8h4,1260
2
+ hippius_sdk/cli.py,sha256=0IQZh2by6kN8Sol3eDFfZzgj5otBeIOKC4lq2wIejOc,76317
3
+ hippius_sdk/client.py,sha256=54tsg4k29sqt3F77LQJ_vhzzTR73QuZ_edqI_BvZM1E,14905
4
+ hippius_sdk/config.py,sha256=gTr8EXeZ3jJNchcG9WyjbQdpPRHTxL5IWZgyIAm_X-c,22869
5
+ hippius_sdk/ipfs.py,sha256=9fds5MJwVb7t8IqROM70x9fWgyk9_Ot5psat_hMnRN8,63969
6
+ hippius_sdk/substrate.py,sha256=fa8K8vVdYGVtB3VNJ-_Vdw8bOxDUajFmj6se-rHZveQ,30853
7
+ hippius-0.1.9.dist-info/METADATA,sha256=SPXMFKAJ_at35FEPB9uDMi3iBP7EXMLxskPvLxHmCQE,28000
8
+ hippius-0.1.9.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
9
+ hippius-0.1.9.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
10
+ hippius-0.1.9.dist-info/RECORD,,
hippius_sdk/__init__.py CHANGED
@@ -4,8 +4,52 @@ Hippius SDK - Python interface for Hippius blockchain storage
4
4
 
5
5
  from hippius_sdk.client import HippiusClient
6
6
  from hippius_sdk.ipfs import IPFSClient
7
+ from hippius_sdk.config import (
8
+ get_config_value,
9
+ set_config_value,
10
+ get_encryption_key,
11
+ set_encryption_key,
12
+ load_config,
13
+ save_config,
14
+ initialize_from_env,
15
+ get_all_config,
16
+ reset_config,
17
+ get_seed_phrase,
18
+ set_seed_phrase,
19
+ encrypt_seed_phrase,
20
+ decrypt_seed_phrase,
21
+ get_active_account,
22
+ set_active_account,
23
+ list_accounts,
24
+ delete_account,
25
+ get_account_address,
26
+ )
7
27
 
8
28
  __version__ = "0.1.0"
9
- __all__ = ["HippiusClient", "IPFSClient"]
29
+ __all__ = [
30
+ "HippiusClient",
31
+ "IPFSClient",
32
+ "get_config_value",
33
+ "set_config_value",
34
+ "get_encryption_key",
35
+ "set_encryption_key",
36
+ "load_config",
37
+ "save_config",
38
+ "initialize_from_env",
39
+ "get_all_config",
40
+ "reset_config",
41
+ "get_seed_phrase",
42
+ "set_seed_phrase",
43
+ "encrypt_seed_phrase",
44
+ "decrypt_seed_phrase",
45
+ "get_active_account",
46
+ "set_active_account",
47
+ "list_accounts",
48
+ "delete_account",
49
+ "get_account_address",
50
+ ]
51
+
52
+ # Initialize configuration from environment variables for backward compatibility
53
+ initialize_from_env()
10
54
 
11
55
  # Note: Substrate functionality will be added in a future release