A library to generate bindings from Cairo ABI.

Related tags

Command-line cainome
Overview

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

  • 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: a compile-time library backend for the abigen macro to generate 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.

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.

Comments
  • Typescript backend

    Typescript backend

    Currently, cainome parser generates an intermediate representation of the ABI tokens.

    This list of token can then be lowered in any language, example of rust done in the rs crate.

    This issue can track the effort of typescript lowering for a contract bindings.

    opened by glihm 0
  • Cainome binary

    Cainome binary

    To ease the abigen use without depending on rust directly, having a binary for cainome can be great. The idea here is to provide a cainomeup script for quick and easy install.

    Features:

    1. Generate binding for a given backend from a Sierra class file JSON file.
    2. Generate binding for a given backend from a contract address and a rpc url, to have cainome binary fetching the ABI from the chain to generate the bindings.
    3. Specify the backend (only rust is available for now).

    Examples (arbitrary names that can be changed):

    cainome gen --sierra my_contract.contract_class.json --rust /tmp/my_contract.rs
    cainome gen --address 0x1234 --rpc-url https://sepolia... --typescript /tmp/my_contract.ts
    
    opened by glihm 0
  • Cairo 0 support

    Cairo 0 support

    Cairo 0 still very present in term of on-chain contract already deployed on mainnet.

    The main difference between cairo 1 and cairo 0 for abigen are those three:

    1. Arrays: serialized array in cairo 1 always have the length of the array as the first felt. In cairo 0, the len is always passed as a separate argument. Hence, the serialization/deserialization of cairo 0 array must behave differently.
    2. The output of a function in cairo 1 is always 0 or 1 output. In cairo 0, we can have a tuple. This must be handled.
    3. Finally, the events are different in the ABI for Cairo 0. This is something that must be considered.

    To add the cairo 0 support to cainome, some work from archived abigen repo could be done here:

    1. a new macro abigen_legacy! can be used
    2. The parser must parse a legacy ABI with old types, example of how the types were used in the archived repos is here.
    3. Finally, the built-in array serialization must be adjusted in the rs crate. In the archived repo, we used a new type CairoArray as the implementation of CairoSerde for Vec is already done with cairo 1 logic.
    opened by glihm 0
  • Add deploy function to generated `Contract` type

    Add deploy function to generated `Contract` type

    To ease the deployment of a contract instance, the generated Contract type may expose a deploy function.

    abigen!(MyContract, "/path/sierra.json");
    
    fn main() {
        // init provider and account
    
        let contract_address = MyContract::deploy(...args).await?;
    }
    

    The deploy arguments are automatically generated based on the constructor of the contract.

    To deploy, we need the class hash. It can be computed compiling the Sierra class, or by taking the Casm class as optional argument.

    The deployment is done by the UDC (we may name this function deploy_udc actually), and the parameters of the UDC may be exposed.

    The fees must be configurable. We also want to check if the class hash is already declared. If not, we can skip the deploy with an error.

    In the code, this is located in the rs crate here where a new file may be added for this, to be expanded in the contract type here.

    opened by glihm 0
  • Add declare function to the generated `Contract` type

    Add declare function to the generated `Contract` type

    To ease the declaration of a class, the generated Contract type may expose a declare function.

    abigen!(MyContract, "/path/sierra.json");
    
    fn main() {
        // init provider and account
    
        let class_hash = MyContract::declare(...args).await?;
    }
    

    There are two possible strategies:

    1. Taking only the Sierra class as input, but this enforce to re-compile the CASM class to compute the class hash (simpler interface).
    2. We can accept the CASM class as optional parameter, to have the hash out of the box (faster).

    Example for the declare can be taken here on Starkli.

    The fees must be configurable. We also may want to check if the class is not already declared, to accelerate the process in the case it is.

    In the code, this is located in the rs crate here where a new file may be added for this, to be expanded in the contract type here.

    opened by glihm 0
Releases(v0.1.7)
  • v0.1.7(Dec 19, 2023)

    What's Changed

    • feat: allow loading of the entire Sierra class by @glihm in https://github.com/cartridge-gg/cainome/pull/2

    Full Changelog: https://github.com/cartridge-gg/cainome/compare/v0.1.6...v0.1.7

    Source code(tar.gz)
    Source code(zip)
  • v0.1.6(Dec 18, 2023)

    Full Changelog: https://github.com/cartridge-gg/cainome/compare/v0.1.5...v0.1.6

    Adds support for ByteArray and bytes31 serialization/deserialization.

    Source code(tar.gz)
    Source code(zip)
Owner
null
Crate to generate files in ROFF format (Rust)

roffman A crate to generate roff man pages. Usage Add the following to the Cargo.toml: [dependencies] roffman = "0.3" Example use roffman::{Roff, Roff

Wojciech Kępka 23 Jul 13, 2022
git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers.⛰️

git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers. The changelog template can be customized with a configuration file to match the desired format.

Orhun Parmaksız 5k Jan 9, 2023
Small and simple CLI app to generate .editorconfig based on a given settings.

add-editorconfig Small and simple CLI app to generate .editorconfig based on a given settings. Usage # Will create an .editorconfig in the current dir

Reinaldy Rafli 3 Jan 16, 2022
Command-line tool to generate Rust code for Google Cloud Spanner

nene nene is a command-line tool to generate Rust code for Google Cloud Spanner. nene uses database schema to generate code by using Information Schem

Naohiro Yoshida 3 Dec 7, 2021
A command-line tool to generate a list of required missing Android OS Project blobs.

aosp-missing-blobs aosp-missing-blobs is a nifty tool to identify required blobs (.so) that are missing from AOSP ROM builds, and to show which existi

Josh 176 Dec 16, 2022
Cargo-about - 📜 Cargo plugin to generate list of all licenses for a crate 🦀

?? cargo-about Cargo plugin for generating a license listing for all dependencies of a crate See the book ?? for in-depth documentation. Please Note:

Embark 281 Jan 1, 2023
A Cli to generate React Component and Hooks.

React Cli A cli to create React Components and Hooks. Instructions: Download the binary. To Create A React Component ./react -n <Component Name> T

Gurpal Singh 3 Jun 24, 2022
Generate QR code of your Wi-Fi network

ranpha Generate QR code of your Wi-Fi network. Usage: -p PROTOCOL -s SSID [-k KEY] [-f IMAGE_FORMAT] [-o OUT_DIR] [--size SIZE]

Yuki Okushi 6 Oct 25, 2022
CLI tool to generate aptos keys.

aptos-keygrind CLI tool to generate aptos keys. Credit to https://github.com/solana-labs/solana/tree/master/keygen for some code I took. Installation

xjcaa 2 Aug 29, 2022
g3k: Generate Good-looking GPG Keys

g3k: Generate Good-looking GPG Keys Yet another vanity key generator. Usage: git clone https://github.com/bnoctis/g3k cd g3k cargo build --release tar

Blair Noctis 118 Dec 27, 2022
Generate Soufflé Datalog types, relations, and facts that represent ASTs from a variety of programming languages.

treeedb treeedb makes it easier to start writing a source-level program analysis in Soufflé Datalog. First, treeedb generates Soufflé types and relati

Langston Barrett 16 Nov 30, 2022
Generate HTML source files from rust functions!

Htmlificator This crate provides an element struct which can be displayed as HTML. License This crate is licensed under the MIT license Credit This cr

Isotoxal 2 Nov 7, 2022
Generate basic VCard QR codes from the command line.

vcard-qr Generate basic VCard QR codes from your terminal. Stick them on your things so people can contact you if they get lost! This little program i

null 11 Nov 20, 2022
Generate commands that add node_modules/.bin to PATH

npx-bin-helper Generate commands that add node_modules/.bin to PATH. Supports Linux, MacOS and Windows. Installation cargo install npx-bin-helper Usag

Yumeoto Zorin 2 Nov 11, 2022
Generate PHP code from Rust using a fluent API 🐘 🦀

PHP-Codegen Generate PHP code from Rust using a fluent API ?? ?? Rust PHP Usage To bring this crate into your repository, either add php_codegen to yo

PHP Rust Tools 7 Dec 24, 2022
Generate a dependency list to thank them on README.

thanks-dependencies This generates list of dependencies. I think it's better to publish dependencies explicitly on documentation. Of course users can

keiya sasaki 7 Jan 30, 2023
Generate Nix packages from URLs

Generate Nix packages from URLs with hash prefetching, dependency inference, license detection, and more

Nix community projects 130 Feb 5, 2023
Generate a vanity address (`juno1wynd...`) to show your support for WYND DAO

WYND Generator When you generate a new mnemonic, it is very random (must be to be secure), and you cannot predict the address you will get. However, i

null 9 Dec 8, 2022
Generate progress bars from cron expressions.

jalm Generate Progress Bars from Cron Expressions Installation and Usage Grab the latest binary from the Github Actions tab. Alternatively, to build f

iamkneel 22 Oct 30, 2022