ink! Analyzer IR

ink! intermediate representations (IRs) and abstractions for ink! analyzer.

NOTE: This project is still work in progress, check back over the next few weeks for regular updates.

Installation

Run the following Cargo command in your project directory

shell cargo add ink-analyzer-ir

Usage

Example:

Generate an IR of ink! smart contract code.

```rust use inkanalyzerir::{InkFile, quoteasstr};

fn generateir() { let file = InkFile::parse(quoteas_str! { #[ink::contract] mod flipper {

        #[ink(storage)]
        pub struct Flipper {
            value: bool,
        }

        #[ink(event)]
        pub struct Flip {
            #[ink(topic)]
            flipped: bool,
        }

        // --snip--
    }
});
dbg!(&file);

let contracts = file.contracts();
dbg!(&contracts);

if let Some(contract) = contracts.first() {
    let events = contract.events();
    dbg!(&events);
}

} ```

Documentation

https://docs.rs/ink-analyzer-ir/latest/inkanalyzerir/

Or you can access documentation locally by running the following command from the project root

shell cargo doc -p ink-analyzer-ir --open

Testing

You can run unit tests for all the core functionality by running the following command from the project root

shell cargo test -p ink-analyzer-ir

License

This code is released under both MIT and Apache-2.0 licenses.