Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccdexplorer_schema_parser-0.1.14.tar.gz (22.8 kB view hashes)

Uploaded Source

Built Distributions

ccdexplorer_schema_parser-0.1.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

ccdexplorer_schema_parser-0.1.14-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (611.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

ccdexplorer_schema_parser-0.1.14-cp312-cp312-macosx_11_0_arm64.whl (556.4 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

ccdexplorer_schema_parser-0.1.14-cp312-cp312-macosx_10_12_x86_64.whl (578.1 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

ccdexplorer_schema_parser-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ccdexplorer_schema_parser-0.1.14-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (612.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

ccdexplorer_schema_parser-0.1.14-cp311-cp311-macosx_11_0_arm64.whl (556.8 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ccdexplorer_schema_parser-0.1.14-cp311-cp311-macosx_10_12_x86_64.whl (578.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

ccdexplorer_schema_parser-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ccdexplorer_schema_parser-0.1.14-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (612.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

ccdexplorer_schema_parser-0.1.14-cp310-cp310-macosx_11_0_arm64.whl (556.8 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ccdexplorer_schema_parser-0.1.14-cp310-cp310-macosx_10_12_x86_64.whl (578.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

ccdexplorer_schema_parser-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ccdexplorer_schema_parser-0.1.14-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (611.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

ccdexplorer_schema_parser-0.1.14-cp39-cp39-macosx_11_0_arm64.whl (556.6 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ccdexplorer_schema_parser-0.1.14-cp39-cp39-macosx_10_12_x86_64.whl (578.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ x86-64

ccdexplorer_schema_parser-0.1.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (626.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

ccdexplorer_schema_parser-0.1.14-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (611.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page