Code Monkey home page Code Monkey logo

cainome's Introduction

Cainome: bindings generation from Cairo ABI

Cainome is a library to generate bindings from Cairo ABI.

Cainome architecture provides a flexible way to work with Cairo ABI for different languages (backends).

Project structure

  • cli: inside src/bin/cli, the cainome CLI binary can be built using cargo build: README.
  • lib: inside src/lib.rs, the cainome library can be built using cargo build --lib.
  • parser: a run-time library to parse an ABI file into Tokens README.
  • cairo-serde: a compile-time library that implements serialization for native Rust types from FieldElement buffer README.
  • rs-macro: a compile-time library backend for the abigen macro to generate rust bindings README.
  • rs: a a run-time library to generated rust bindings README.
  • ts: a compile-time library backend to generate TypeScript bindings (coming soon).

Currently those crates are not published on crates.io, please consider using them with the release tags.

Plugin system

Cainome uses a plugin system that is for now only supporting built-in plugins (written in rust). Cainome will support in the future plugins like protobuf, which can be written in any languages.

How to write a plugin

Currently, to write a plugin you can take as example the RustPlugin.

  1. Define a rust module inside src/bin/cli/plugins/builtins.
  2. You can write your plugin code in a crate (like rs crate), or in the module you've created at the previous step (use a folder in this case). Writting a crate can be easier to re-use in other projects though.
  3. The plugin takes a PluginInput as argument, where the tokens from the parser crate are available for each contract. From these tokens, you can easily generate code that represent the ABI of the contract. In the case of rust, you can find in the rs crate some examples of how types are handled. You don't have to use syn crate as rs crate is doing. You can simply build strings.
  4. In the current version, the plugin also receives the output_dir, so it is responsible of writing and organizing it's files.
  5. Finally, add in the PluginOptions an option for your plugin.

Cainome meaning

Cainome is a word combining Cairo and Genome. The idea of Cairo ABI being the DNA of our ecosystem, and like the genome expresses several genes which turn into proteins, from an ABI we can generate several bindings in different languages.

cainome's People

Contributors

evolveart avatar glihm avatar tarrencev avatar ybensacq 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.