Swarm CID
📖 Table of Contents
📍 Api
Utility library written in Python to convert Swarm hex references into Swarm CIDs.
The swarm-cid library provides the following functions:
encode_reference(reference, type, version)
Encodes a reference string into a CID.
- reference: The reference string to encode.
- type: The type of the reference (either ReferenceType.MANIFEST or ReferenceType.FEED).
- version: The version of the CID (either 1 or 2). Returns a CID string.
decode_cid(cid)
Decodes a CID string into a dictionary containing information about the underlying data.
- cid: The CID string to decode.
Returns a dictionary with the following keys:
- reference: The reference string extracted from the CID.
- type: The type of the reference (either ReferenceType.MANIFEST or ReferenceType.FEED).
decode_feed_cid(cid)
Decodes a CID string into a feed reference string.
- cid: The CID string to decode. Returns a feed reference string.
decode_manifest_cid(cid)
Decodes a CID string into a manifest reference string.
- cid: The CID string to decode. Returns a manifest reference string.
encode_feed_reference(reference)
Encodes a feed reference string into a CID.
- reference: The feed reference string to encode. Returns a CID string.
encode_manifest_reference(reference)
Encodes a manifest reference string into a CID.
- reference: The manifest reference string to encode.
🚀 Getting Started
Dependencies
py-multiformats-cid
🔧 Installation
pip install swarm_cid_py
🤖 Running swarm-cid-py
>>> from swarm_cid import encode_reference, decode_cid
>>> reference = "4c949794d617238d928ef1dc544ee07cbdcfd6b946e5202fa06c4d32088d7e69"
>>> cid = encode_reference(reference, ReferenceType.MANIFEST, 1)
>>> print(str(cid))
bah5acgzajskjpfgwc4ry3euo6hofitxaps647vvzi3ssal5anrgtecenpzuq
>>> decoded_cid = decode_cid(cid)
>>> print(decoded_cid.to_dict())
{'reference':
'4c949794d617238d928ef1dc544ee07cbdcfd6b946e5202fa06c4d32088d7e69', 'type': 'manifest'}
🧪 Tests
pytest tests/test_swarm_cid.py
🤝 Contributing
Contributions are welcome! Here are several ways you can contribute:
- Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
- Report Issues: Submit bugs found or log feature requests for ETHERSPHERE.
Contributing Guidelines
Click to expand
- Fork the Repository: Start by forking the project repository to your GitHub account.
- Clone Locally: Clone the forked repository to your local machine using a Git client.
git clone <your-forked-repo-url>
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear and concise message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to GitHub: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
Once your PR is reviewed and approved, it will be merged into the main branch.
📄 License
This project is protected under the BSD-3-Clause License.
Metadata
Release files for swarm-cid-py 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarm_cid_py-0.1.3.tar.gz | 6.3 kB | Without provenance | Details for swarm_cid_py-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarm_cid_py-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for swarm_cid_py-0.1.3-py3-none-any.whl |
Total release size: 13.3 kB
Release files / swarm_cid_py-0.1.3.tar.gz
| Download URL | swarm_cid_py-0.1.3.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96449f6300350e53b26b3423cea84e24d016b4ee3f5b7bfd79e9185de6781b3f
|
|
BLAKE2b-256 checksum How to use checksums |
40026776b0b2879427b96ac4e049660be377d5fe8c03cb19e492b63507b4d24a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.0
|
Release files / swarm_cid_py-0.1.3-py3-none-any.whl
| Download URL | swarm_cid_py-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d67764b7a373b9b7502bdf3b658f9a2dac0bc256788a34c9d054bb6ec7c0c5e4
|
|
BLAKE2b-256 checksum How to use checksums |
4789637cadd6caa405920d6a54b0954440d8fb6ce1e59b6d63b788769201e3fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.0
|
Security for swarm-cid-py 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.