🦑 ink! Analyzer

A library for semantic analysis of ink! smart contract code.

It implements utilities for performing semantic analysis of ink! smart contract code. It therefore implements the core functionality of ink! analyzer at a high level.

It currently only implements a public interface that accepts a string representation (&str) of ink! smart contract code as input and returns a list of diagnostics (Vec<Diagnostic>) as output.

The diagnostic model includes: - an error/warning message. - the text range to which the diagnostic applies - the severity (e.g error or warning).

You can find the low-level diagnostic implementations in the diagnostics module and its ink! entity specific submodules.

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

Usage

Example:

Run diagnostics for ink! smart contract code.

```rust use ink_analyzer::Analysis;

fn doanalysis() { let code = r#" #[ink::contract] mod mycontract {

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

        // --snip--
    }
"#;

let diagnostics = Analysis.diagnostics(code);
dbg!(&diagnostics);

} ```

Documentation

https://docs.rs/ink-analyzer/latest/ink_analyzer/

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

Implementations of the unit tests (and hence a good overview of the current functionality) can be found in the diagnostics submodule of the ink-analyzer crate.

License

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