Skip to content

A typescript node module to deserialize rust Decimal values

Notifications You must be signed in to change notification settings

vyper-protocol/rust-decimal-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Decimal Wrapper

rust-decimal-wrapper is released under the MIT license. Current npm package version. Follow @VyperProtocol

A typescript node module to deserialize rust Decimal values

We created this library to read and use in js based apps decimal values serialized with the rust_decimal library.

Installation

yarn add @vyper-protocol/rust-decimal-wrapper

Usage

import { RustDecimalWrapper } from "@vyper-protocol/rust-decimal-wrapper";

// receive from an external application the bytes serialized with rust_decimal
const bytes = new Uint8Array([0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);

// create a RustDecimalWrapper around the bytes
const wrapper = new RustDecimalWrapper(bytes);

// get the original value
const value = wrapper.toNumber();

// value is 0.1

Getting Help

Join our Discord channel and post a message in #developers