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

} | {

isOk?: false;

isErr: true;

err: Err

}

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

} | {

type: 'Variant2',

value: boolean

} | {

type: 'Variant3'

}

FlatEnum:

enum {

Variant1,

Variant2

}

'Variant1' | 'Variant2'

Last updated