Messages
Messages are the highest level of abstraction in integrations built on top of the Encoding Subsystem, but also the strictest.
// @apophis-sdk/core/encoding/protobuf/any.ts
export type ProtobufType<T1 extends string = string, T2 = any> = {
get protobufTypeUrl(): T1;
toProtobuf(value: T2): Uint8Array;
fromProtobuf(value: Uint8Array): T2;
};
export declare function registerDefaultProtobuf(...types: ProtobufType[]): void;
// @apophis-sdk/cosmos/encoding/amino.ts
export type AminoType<T1 extends string = string, T2 = any> = {
get aminoTypeUrl(): T1;
new(data: T2): { get data(); T2 }
};
export declare function registerDefaultAmino(...types: AminoType[]): void;import { registerDefaultProtobufs } from '@apophis-sdk/core/encoding/protobuf/any.js';
import type { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx';
import { registerDefaultAminos } from '../encoding/amino';
export namespace Bank {
export type SendData = {
fromAddress: string;
toAddress: string;
amount: Coin[];
}
export class Send {
static readonly protobufTypeUrl = '/cosmos.bank.v1beta1.MsgSend';
static readonly aminoTypeUrl = 'cosmos-sdk/MsgSend';
constructor(public data: SendData) {}
static toProtobuf(value: Send): Uint8Array {
return MsgSend.encode(MsgSend.fromPartial(value.data)).finish();
}
static fromProtobuf(value: Uint8Array): Send {
const { fromAddress, toAddress, amount } = MsgSend.decode(value);
return new Send({ fromAddress, toAddress, amount });
}
};
registerDefaultProtobufs(Send);
registerDefaultAminos(Send);
}
Last updated