Giter Club home page Giter Club logo

everscale-types's Introduction

Logo

Everscale types โ€ƒ crates-io-batch docs-badge rust-version-badge workflow-badge

Status: WIP

About

A set of primitive types and utilities for the Everscale blockchain.

Heavily inspired by ton-labs-types, but with much more emphasis on speed.

Basic usage

Get Cell from Vec<u8> representation of bytes

use everscale_types::boc::Boc;

let cell: Cell = Boc::decode(bytes)?;

Encode any model e.g.MerkleProof to base64 BOC representation and vice versa

use everscale_types::boc::BocRepr;

let cell = MerkleProof::create_for_cell(cell.as_ref(), EMPTY_CELL_HASH)
            .build()
            .unwrap();

let encoded = BocRepr::encode_base64(&cell).unwrap();

let decoded = Boc::decode_base64(encoded)?.as_ref().parse::<MerkleProof>()?:

Get specific everscale type from Cell

use everscale_types::models::BlockProof;

let proof: BlockProof = cell.parse::<BlockProof>()?;

Same usage for virtualized cell

use everscale_types::prelude::DynCell;
use everscale_types::models::Block;

let virt_cell: &DynCell = cell.virtualize();
let block = virt_cell.parse::<Block>()?;

You can also use CellBuilder to create any Cell

let mut builder = CellBuilder::new();
builder.store_bit_one()?;
builder.store_u32(100u32)?
builder.store_slice(slice)?;
builder.store_raw(&[0xdd, 0x55], 10)?;

// store references to another cells
builder.store_reference(cell)?;
builder.store_reference(another_cell)?;

let final_cell = builder.build()?;

Development

How to bench

cargo bench boc
cargo bench dict

How to miri check

# Add Miri component
rustup +nightly component add miri

# Run all tests with Miri
cargo +nightly miri test

How to fuzz

# Install fuzzer
cargo install cargo-fuzz

# Run any of the fuzzer targets
cargo +nightly fuzz run boc_decode -j 12
cargo +nightly fuzz run boc_decode_encode -j 12
cargo +nightly fuzz run boc_decode_pair -j 12
cargo +nightly fuzz run boc_dict -j 12
cargo +nightly fuzz run boc_message -j 12

Contributing

We welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.

License

Licensed under either of

at your option.

everscale-types's People

Contributors

0xdeafbeef avatar mododo avatar mrwad3r avatar rexagon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.