hippius 0.1.6__tar.gz → 0.1.9__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.1.6 → hippius-0.1.9}/PKG-INFO +365 -7
- {hippius-0.1.6 → hippius-0.1.9}/README.md +361 -4
- hippius-0.1.9/hippius_sdk/__init__.py +55 -0
- hippius-0.1.9/hippius_sdk/cli.py +2132 -0
- {hippius-0.1.6 → hippius-0.1.9}/hippius_sdk/client.py +53 -12
- hippius-0.1.9/hippius_sdk/config.py +744 -0
- {hippius-0.1.6 → hippius-0.1.9}/hippius_sdk/ipfs.py +178 -87
- {hippius-0.1.6 → hippius-0.1.9}/hippius_sdk/substrate.py +180 -88
- {hippius-0.1.6 → hippius-0.1.9}/pyproject.toml +3 -2
- hippius-0.1.6/hippius_sdk/__init__.py +0 -11
- hippius-0.1.6/hippius_sdk/cli.py +0 -899
@@ -1,21 +1,22 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: hippius
|
3
|
-
Version: 0.1.
|
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
|
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="
|
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://
|
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://
|
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. **
|
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
|
+
|