sarvalabs / js-moi-sdk

JavaScript library to interact with MOI Protocol via RPC API
https://js-moi-sdk.docs.moi.technology/
Apache License 2.0
24 stars 2 forks source link

Feature to decode polo hex of manifest to json equivalient #90

Closed sarvalabs-harshrastogi closed 1 month ago

sarvalabs-harshrastogi commented 2 months ago

Add decodeManifest method to ManifestCoder

Background

Currently, our library lacks the feature to decode POLO (Protocol Object Notation) encoded manifests into their JSON equivalent. This functionality is crucial for developers working with our manifest system.

Objective

Implement a new method decodeManifest in the ManifestCoder class that can decode POLO encoded manifests into JSON format.

Requirements

  1. Add a new method decodeManifest to the ManifestCoder class.
  2. The method should accept both hex string and Uint8Array as input for the manifest.
  3. Implement input validation to ensure the manifest is in a valid format.
  4. Create an enum ManifestFormat to support various manifest formats (initially just JSON, but extensible for future formats).
  5. Return the decoded manifest as a LogicManifest.Manifest object.
  6. Implement error handling for invalid manifests or unsupported formats.
  7. Update the necessary imports/exports in js-moi-manifest.

Expected Behavior

When given a POLO encoded manifest, the decodeManifest method should return a properly structured JSON object representing the manifest.

Example Usage


const manifest = `0x0e4f031e9e01012f064e504953410fdf010ebe08be10be1cee31ce3d9e505f0300068e01636f6e7374616e742f0666737472696e6730783036363936653733373536363636363936333639363536653734323036323631366336313665363336354f0310166e0173746174653f069e0
sarvalabs-harshrastogi commented 1 month ago

closed in #91