Git Product home page Git Product logo

swarm-cid-py's Introduction


Swarm CID

Python Poetry GitHub%20Actions Pytest

Code style: black imports: isort

GitHub license git-last-commit GitHub commit activity GitHub top language

๐Ÿ“– 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:

Contributing Guidelines

Click to expand
  1. Fork the Repository: Start by forking the project repository to your GitHub account.
  2. Clone Locally: Clone the forked repository to your local machine using a Git client.
    git clone <your-forked-repo-url>
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear and concise message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to GitHub: Push the changes to your forked repository.
    git push origin new-feature-x
  7. 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.

Return


swarm-cid-py's People

Contributors

aviksaikat avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.