#interface #introspection #generate #cairo #src5 #erc165

bin+lib src5-rs

Utility for generating SRC5 interfaces ids from Cairo traits

3 stable releases

2.0.0 Feb 13, 2024
1.0.1 Jun 26, 2023
0.1.2 Jun 23, 2023
0.1.1 Jun 23, 2023
0.1.0 Jun 23, 2023

#26 in #cairo

Download history 15/week @ 2024-02-07 25/week @ 2024-02-14 10/week @ 2024-02-21 9/week @ 2024-02-28 3/week @ 2024-03-06 2/week @ 2024-03-13 75/week @ 2024-03-20 3/week @ 2024-03-27 3/week @ 2024-04-03

85 downloads per month

MIT license

40KB
985 lines

src5-rs

Crates.io

Overview

Utility for generating SRC5 interfaces ids from Cairo traits, using Cairo source code as input.

Installation

Cargo

  • Install the rust toolchain in order to have cargo installed by following this guide.
  • run cargo install src5-rs

Usage

Run src5_rs parse <PATH_TO_CAIRO_FILE> for generating the interface ids for all the non-generic traits in the file.

As an example, copy this code into a file in your filesystem:

trait IAccount {
    fn __execute__(calls: Array<Call>) -> Array<Span<felt252>>;
    fn __validate__(calls: Array<Call>) -> felt252;
    fn __validate_declare__(class_hash: felt252) -> felt252;
    fn is_valid_signature(message: felt252, signature: Array<felt252>) -> u32;
    fn supports_interface(interface_id: u32) -> bool;
}

Notice you don't need to define or import types that are defined inside corelib, but custom Structs and Enums must be defined in the file.

Run the parse subcommand passing the path to the file as parameter:

src5_rs parse path/to/the/file

You should see the following output in the terminal:

License

Licensed under the MIT license.

Dependencies

~24–37MB
~511K SLoC