Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Registry

Index

Constructors

  • Creates a new Registry for mapping protobuf type identifiers/type URLs to actual implementations. Those implementations are typically generated with ts-proto but we also support protobuf.js as a type generator.

    If there is no parameter given, a new Registry() adds the types Coin and MsgSend for historic reasons. Those can be overriden by customTypes.

    There are currently two methods for adding new types:

    1. Passing types to the constructor.
    2. Using the register() method

    Parameters

    Returns Registry

Methods

  • decodeTxBody(txBody: Uint8Array): TxBody
  • Takes a typeUrl/value pair and encodes the value to protobuf if the given type was previously registered.

    If the value has to be wrapped in an Any, this needs to be done manually after this call. Or use encodeAsAny instead.

    Parameters

    Returns Uint8Array

  • encodeTxBody(txBodyFields: TxBodyValue): Uint8Array
  • Looks up a type that was previously added to the registry.

    The generator information (ts-proto or pbjs) gets lost along the way. If you need to work with the result type in TypeScript, you can use:

    import { assert } from "@cosmjs/utils";

    const Coin = registry.lookupType("/cosmos.base.v1beta1.Coin");
    assert(Coin); // Ensures not unset
    assert(isTsProtoGeneratedType(Coin)); // Ensures this is the type we expect

    // Coin is typed TsProtoGeneratedType now.

    Parameters

    • typeUrl: string

    Returns undefined | GeneratedType

Generated using TypeDoc