Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ccdexplorer-schema-parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ccdexplorer-schema-parser

  • 0.1.14
  • PyPI
  • Socket score

Maintainers
1

Schema parsing via Rust bindings

This repository holds the Rust bindings in src/lib.rs. They are simple exports of functionality from concordium-contracts-common. To build them locally, you require maturin and Rust installed.

We've tested with Rust 1.74 and 1.77.

Project structure

The entrypoint for Python consumers is the ccdexplorer_schema_parser package which has a single class Schema. The constructor will instantiate the schema from a deployed Wasm module.

After that the constructed object can be used to parse events or return values using the schema in the module.

from ccdexplorer_schema_parser.Schema import Schema
from ccdexplorer_fundamentals.enums import NET
from ccdexplorer_fundamentals.GRPCClient import GRPCClient
from ccdexplorer_fundamentals.GRPCClient.types_pb2 import VersionedModuleSource

versioned_module: VersionedModuleSource = (
    self.grpcclient.get_module_source_original_classes(
        module_ref, "last_final", net=NET(net)
    )
)
schema = Schema(versioned_module.v1.value, 1) if versioned_module.v1
    else Schema(versioned_module.v0.value, 0)

To parse a logged event from an account_transaction, use the following call:

event_json = schema.event_to_json(
    source_module_name, bytes.fromhex(event)
    )

Where source_module_name is the name of the module (corresponding to the module_ref you have used to parse the schema and event is the hex representation of the logged event). If this can be parsed, the result will be a dictionary.

Building

Run pip install -r requirements.txt to install dependencies.

Run maturin build to build the project.

This will produce a python wheel in target/wheels that will contain both the compiled Rust binaries and python wrappers. The compiled package is platform specific, so a package built on, e.g., Linux will not work on Windows.

Deploy

This repository has a CI.yml that builds this package for various configurations and publishes this to Pypi.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc