Rust bindings for Solidity's AST and visitors

Overview

solc-ast

solc-ast provides rust bindings for the solidity AST and visitors. The visitors were built to be 1-1 compatible with the visitors from solc.

Note: The AST structs are almost entirely from camden-smallwood's solidity-rs. The main deviation is in the Visitor implementation.

Note: AST for inline assembly in incomplete.

Example

#[derive(Default, Debug)]
struct FunctionDefinitionCollector {
names: Vec<String>,
}
impl ASTConstVisitor for FunctionDefinitionCollector {
fn end_visit_function_definition(&mut self, node: &FunctionDefinition) -> Result<()> {
self.names.push(node.name.clone());
Ok(())
}
}
#[test]
fn functions() -> Result<()> {
let source_unit = read_counter()?;
let mut function_definition_collector = FunctionDefinitionCollector::default();
source_unit.accept(&mut function_definition_collector)?;
assert_eq!(
function_definition_collector.names,
vec![String::from("setNumber"), String::from("increment")]
);
Ok(())
}

You might also like...
IBC modules and relayer - Formal specifications and Rust implementation

ibc-rs Rust implementation of the Inter-Blockchain Communication (IBC) protocol. This project comprises primarily four crates: The ibc crate defines t

Fast and efficient ed25519 signing and verification in Rust.
Fast and efficient ed25519 signing and verification in Rust.

ed25519-dalek Fast and efficient Rust implementation of ed25519 key generation, signing, and verification in Rust. Documentation Documentation is avai

Complete Ethereum and Celo wallet implementation and utilities in Rust

ethers.rs Complete Ethereum and Celo wallet implementation and utilities in Rust Documentation Extensive documentation and examples are available here

A simple and secure rust command-line tool to protect your text by encrypting and decrypting it using the robust AES-256 algorithm.

Secret Keeper A simple and secure command-line tool to protect your text by encrypting and decrypting it using the robust AES-256 algorithm. Built wit

🔐 UPLINK is a Rust lightweight (2MB) tool for file transfer and remote management that uses AES-GCM and Envelope Encryption over WebSockets.

UPLINK ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█

Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

A safe implementation of the secure remote password authentication and key-exchange protocol (SRP), SRP6a and legacy are as features available.

Secure Remote Password (SRP 6 / 6a) A safe implementation of the secure remote password authentication and key-exchange protocol (SRP version 6a). Ver

Retrieving SSH and GPS keys from GitHub and GitLab

Dormarch Retrieving SSH and GPS keys from GitHub and GitLab Usage After having installed Dormarch, you can see all the options with dormarch -h. To re

Terabethia - A Bridge and Messaging Protocol between Ethereum and the Internet Computer.
Terabethia - A Bridge and Messaging Protocol between Ethereum and the Internet Computer.

Terabethia - A Bridge Between Ethereum & the Internet Computer Terabethia is a bridge between Ethereum & the Internet Computer that contracts in both

Comments
  • Magic variables have negative NodeID

    Magic variables have negative NodeID

    Cool project! Ran into the following issue:

    Things like abi, keccak256, block, etc. have negative IDs, but NodeId aliases u64 https://github.com/ethereum/solidity/blob/develop/libsolidity/analysis/GlobalContext.cpp#L39-L63

    opened by moodlezoup 0
Owner
Hari
Hari
Bindings for the etherscan API and other block explorers.

foundry-block-explorers Bindings for the etherscan.io web API and other block explorers. Examples use ethers_core::types::Chain; use foundry_block_exp

Foundry 7 Nov 3, 2023
Sodium Oxide: Fast cryptographic library for Rust (bindings to libsodium)

sodiumoxide |Crate|Documentation|Gitter| |:---:|:-----------:|:--------:|:-----:|:------:|:----:| |||| NaCl (pronounced "salt") is a new easy-to-use h

sodiumoxide 642 Dec 17, 2022
rust-native-tls — Bindings for native TLS libraries

rust-native-tls Documentation An abstraction over platform-specific TLS implementations. Specifically, this crate uses SChannel on Windows (via the sc

Steven Fackler 371 Jan 8, 2023
OpenSSL bindings for Rust

rust-openssl OpenSSL bindings for the Rust programming language. Documentation. Release Support The current supported release of openssl is 0.10 and o

Steven Fackler 1k Jan 7, 2023
Rust FFI bindings for StarkWare's crypto-cpp library

starkware-crypto-rs Rust FFI bindings for StarkWare's crypto-cpp library Note that currently target x86_64-pc-windows-msvc is not supported. If you're

Jonathan LEI 11 Aug 22, 2022
Python bindings for rage (age in Rust)

pyrage Python bindings for the Rust implementation of age. Index Installation Usage Development Licensing Installation You can install pyrage with pip

William Woodruff 14 Nov 23, 2022
Bindings to the macOS Security.framework

macOS/iOS Security framework for Rust Documentation Bindings to the Apple's Security.framework. Allows use of TLS and Keychain from Rust. License Lice

Kornel 172 Dec 24, 2022
OpenAI's tiktoken but with node bindings

⏳ tiktoken-node tiktoken is a fast BPE tokeniser for use with OpenAI's models. const tiktoken = require('tiktoken-node') let enc = tiktoken.getEncodin

Gabriel Francisco 9 Mar 23, 2023
Bindings to MLIR using the full C++ API

Mithril Oxide Mithril MLIR is hard to rust but we did it anyway. Rust bindings to MLIR via the C++ API. Project structure mithril-oxide: Our Rusty bin

Lambdaclass 6 Jun 10, 2023
Simple node and rust script to achieve an easy to use bridge between rust and node.js

Node-Rust Bridge Simple rust and node.js script to achieve a bridge between them. Only 1 bridge can be initialized per rust program. But node.js can h

Pure 5 Apr 30, 2023