Skip to main content
Module

x/capi/mod.ts>$.Codec

[WIP] A framework for crafting interactions with Substrate chains
Latest
class $.Codec
implements AnyCodec
extends _Codec
Re-export
Abstract
import { $ } from "https://deno.land/x/capi@v0.1.1-beta.1/mod.ts";
const { Codec } = $;

Type Parameters

I
optional
O = I

Properties

abstract
_assert: (state: AssertState) => void

Asserts that the value is valid for this codec

abstract
_decode: (buffer: DecodeBuffer) => O

Decodes the value from the supplied buffer

abstract
_encode: (buffer: EncodeBuffer, value: I) => void

Encodes the value into the supplied buffer, which should have at least _staticSize free byte.

abstract
_metadata: Metadata<I, O>

An array with metadata representing the construction of this codec

abstract
_staticSize: number

A static estimation of the size, which may be an under- or over-estimate

Methods

assert(value: unknown): asserts value is I

Requires the codec to have an explicit type annotation; if it doesn't, use $.assert instead.

decode(array: Uint8Array)

Decodes a value from the supplied Uint8Array

encode(value: I)

Encodes the value into a new Uint8Array (throws if async)

encodeAsync(value: I)

Asynchronously encodes the value into a new Uint8Array