Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 6.01 KB

File metadata and controls

17 lines (15 loc) · 6.01 KB

Type system

The table below is a mapping between scale-codec types (Rust) and TypeScript types that we're using for Dedot:

Scale Codec (Rust) TypeScript (dedot)

u8, u16, u32,

i8, i16, i32

number

u64, u128, u256,

i64, i128, i256

bigint (native BigInt, not bn.js)
bool boolean (true, false)
Option<T> T | undefined
Result<Ok, Err>

{

isOk: true;

isErr?: false;

value: Ok

}

Vec<T> Array<T>
str string
Tuple: (A, B), () [A, B], []

Struct:

struct {

field_1: u8,

field_2: str

}

{

field_1: number,

field_2: string

}

Enum:

enum {

Variant1(u8),

Variant2(bool),

Variant3

}

{

type: 'Variant1',

value: number

}

FlatEnum:

enum {

Variant1,

Variant2

}

'Variant1' | 'Variant2'