stargate: Copy amino msgs from launchpad

This commit is contained in:
willclarktech 2021-03-24 18:55:15 +01:00
parent 133898c2f7
commit 2d44ef35bc
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
4 changed files with 408 additions and 75 deletions

View File

@ -0,0 +1,337 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { AminoMsg, Coin } from "@cosmjs/amino";
// auth (no messages) - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/auth/auth.proto
// bank - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/bank/bank.proto
/** A high level transaction of the coin module */
export interface AminoMsgSend extends AminoMsg {
readonly type: "cosmos-sdk/MsgSend";
readonly value: {
/** Bech32 account address */
readonly from_address: string;
/** Bech32 account address */
readonly to_address: string;
readonly amount: readonly Coin[];
};
}
export function isAminoMsgSend(msg: AminoMsg): msg is AminoMsgSend {
return (msg as AminoMsgSend).type === "cosmos-sdk/MsgSend";
}
interface Input {
/** Bech32 account address */
readonly address: string;
readonly coins: readonly Coin[];
}
interface Output {
/** Bech32 account address */
readonly address: string;
readonly coins: readonly Coin[];
}
/** A high level transaction of the coin module */
export interface AminoMsgMultiSend extends AminoMsg {
readonly type: "cosmos-sdk/MsgMultiSend";
readonly value: {
readonly inputs: readonly Input[];
readonly outputs: readonly Output[];
};
}
export function isAminoMsgMultiSend(msg: AminoMsg): msg is AminoMsgMultiSend {
return (msg as AminoMsgMultiSend).type === "cosmos-sdk/MsgMultiSend";
}
// crisis - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/crisis/crisis.proto
/** Verifies a particular invariance */
export interface AminoMsgVerifyInvariant extends AminoMsg {
readonly type: "cosmos-sdk/MsgVerifyInvariant";
readonly value: {
/** Bech32 account address */
readonly sender: string;
readonly invariant_module_name: string;
readonly invariant_route: string;
};
}
export function isAminoMsgVerifyInvariant(msg: AminoMsg): msg is AminoMsgVerifyInvariant {
return (msg as AminoMsgVerifyInvariant).type === "cosmos-sdk/MsgVerifyInvariant";
}
// distribution - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/distribution/distribution.proto
/** Changes the withdraw address for a delegator (or validator self-delegation) */
export interface AminoMsgSetWithdrawAddress extends AminoMsg {
// NOTE: Type string and names diverge here!
readonly type: "cosmos-sdk/MsgModifyWithdrawAddress";
readonly value: {
/** Bech32 account address */
readonly delegator_address: string;
/** Bech32 account address */
readonly withdraw_address: string;
};
}
export function isAminoMsgSetWithdrawAddress(msg: AminoMsg): msg is AminoMsgSetWithdrawAddress {
// NOTE: Type string and names diverge here!
return (msg as AminoMsgSetWithdrawAddress).type === "cosmos-sdk/MsgModifyWithdrawAddress";
}
/** Message for delegation withdraw from a single validator */
export interface AminoMsgWithdrawDelegatorReward extends AminoMsg {
// NOTE: Type string and names diverge here!
readonly type: "cosmos-sdk/MsgWithdrawDelegationReward";
readonly value: {
/** Bech32 account address */
readonly delegator_address: string;
/** Bech32 account address */
readonly validator_address: string;
};
}
export function isAminoMsgWithdrawDelegatorReward(msg: AminoMsg): msg is AminoMsgWithdrawDelegatorReward {
// NOTE: Type string and names diverge here!
return (msg as AminoMsgWithdrawDelegatorReward).type === "cosmos-sdk/MsgWithdrawDelegationReward";
}
/** Message for validator withdraw */
export interface AminoMsgWithdrawValidatorCommission extends AminoMsg {
readonly type: "cosmos-sdk/MsgWithdrawValidatorCommission";
readonly value: {
/** Bech32 account address */
readonly validator_address: string;
};
}
export function isAminoMsgWithdrawValidatorCommission(
msg: AminoMsg,
): msg is AminoMsgWithdrawValidatorCommission {
return (msg as AminoMsgWithdrawValidatorCommission).type === "cosmos-sdk/MsgWithdrawValidatorCommission";
}
/** Allows an account to directly fund the community pool. */
export interface AminoMsgFundCommunityPool extends AminoMsg {
readonly type: "cosmos-sdk/MsgFundCommunityPool";
readonly value: {
readonly amount: readonly Coin[];
/** Bech32 account address */
readonly depositor: string;
};
}
export function isAminoMsgFundCommunityPool(msg: AminoMsg): msg is AminoMsgFundCommunityPool {
return (msg as AminoMsgFundCommunityPool).type === "cosmos-sdk/MsgFundCommunityPool";
}
// evidence - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/evidence/evidence.proto
interface Any {
readonly type_url: string;
readonly value: Uint8Array;
}
/** Supports submitting arbitrary evidence */
export interface AminoMsgSubmitEvidence extends AminoMsg {
readonly type: "cosmos-sdk/MsgSubmitEvidence";
readonly value: {
/** Bech32 account address */
readonly submitter: string;
readonly evidence: Any;
};
}
export function isAminoMsgSubmitEvidence(msg: AminoMsg): msg is AminoMsgSubmitEvidence {
return (msg as AminoMsgSubmitEvidence).type === "cosmos-sdk/MsgSubmitEvidence";
}
// gov - https://github.com/cosmos/cosmos-sdk/blob/efa73c7edb31a7bd65786501da213b294f89267a/proto/cosmos/gov/gov.proto
/** Supports submitting arbitrary proposal content. */
export interface AminoMsgSubmitProposal extends AminoMsg {
readonly type: "cosmos-sdk/MsgSubmitProposal";
readonly value: {
readonly content: Any;
readonly initial_deposit: readonly Coin[];
/** Bech32 account address */
readonly proposer: string;
};
}
export function isAminoMsgSubmitProposal(msg: AminoMsg): msg is AminoMsgSubmitProposal {
return (msg as AminoMsgSubmitProposal).type === "cosmos-sdk/MsgSubmitProposal";
}
enum VoteOption {
VoteOptionUnspecified,
VoteOptionYes,
VoteOptionAbstain,
VoteOptionNo,
VoteOptionNoWithVeto,
}
/** Casts a vote */
export interface AminoMsgVote extends AminoMsg {
readonly type: "cosmos-sdk/MsgVote";
readonly value: {
readonly proposal_id: number;
/** Bech32 account address */
readonly voter: string;
readonly option: VoteOption;
};
}
export function isAminoMsgVote(msg: AminoMsg): msg is AminoMsgVote {
return (msg as AminoMsgVote).type === "cosmos-sdk/MsgVote";
}
/** Submits a deposit to an existing proposal */
export interface AminoMsgDeposit extends AminoMsg {
readonly type: "cosmos-sdk/MsgDeposit";
readonly value: {
readonly proposal_id: number;
/** Bech32 account address */
readonly depositor: string;
readonly amount: readonly Coin[];
};
}
export function isAminoMsgDeposit(msg: AminoMsg): msg is AminoMsgDeposit {
return (msg as AminoMsgDeposit).type === "cosmos-sdk/MsgDeposit";
}
// ibc
// mint (no messages) - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/mint/mint.proto
// params (no messages) - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/params/params.proto
// slashing - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/slashing/slashing.proto
/** Unjails a jailed validator */
export interface AminoMsgUnjail extends AminoMsg {
readonly type: "cosmos-sdk/MsgUnjail";
readonly value: {
/** Bech32 account address */
readonly validator_addr: string;
};
}
export function isAminoMsgUnjail(msg: AminoMsg): msg is AminoMsgUnjail {
return (msg as AminoMsgUnjail).type === "cosmos-sdk/MsgUnjail";
}
// staking - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/staking/staking.proto
/** The initial commission rates to be used for creating a validator */
interface CommissionRates {
readonly rate: string;
readonly max_rate: string;
readonly max_change_rate: string;
}
/** A validator description. */
interface Description {
readonly moniker: string;
readonly identity: string;
readonly website: string;
readonly security_contact: string;
readonly details: string;
}
/** Creates a new validator. */
export interface AminoMsgCreateValidator extends AminoMsg {
readonly type: "cosmos-sdk/MsgCreateValidator";
readonly value: {
readonly description: Description;
readonly commission: CommissionRates;
readonly min_self_delegation: string;
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded validator address */
readonly validator_address: string;
/** Bech32 encoded public key */
readonly pubkey: string;
readonly value: Coin;
};
}
export function isAminoMsgCreateValidator(msg: AminoMsg): msg is AminoMsgCreateValidator {
return (msg as AminoMsgCreateValidator).type === "cosmos-sdk/MsgCreateValidator";
}
/** Edits an existing validator. */
export interface AminoMsgEditValidator extends AminoMsg {
readonly type: "cosmos-sdk/MsgEditValidator";
readonly value: {
readonly description: Description;
/** Bech32 encoded validator address */
readonly validator_address: string;
readonly commission_rate: string;
readonly min_self_delegation: string;
};
}
export function isAminoMsgEditValidator(msg: AminoMsg): msg is AminoMsgEditValidator {
return (msg as AminoMsgEditValidator).type === "cosmos-sdk/MsgEditValidator";
}
/**
* Performs a delegation from a delegate to a validator.
*
* @see https://docs.cosmos.network/master/modules/staking/03_messages.html#msgdelegate
*/
export interface AminoMsgDelegate extends AminoMsg {
readonly type: "cosmos-sdk/MsgDelegate";
readonly value: {
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded validator address */
readonly validator_address: string;
readonly amount: Coin;
};
}
export function isAminoMsgDelegate(msg: AminoMsg): msg is AminoMsgDelegate {
return (msg as AminoMsgDelegate).type === "cosmos-sdk/MsgDelegate";
}
/** Performs a redelegation from a delegate and source validator to a destination validator */
export interface AminoMsgBeginRedelegate extends AminoMsg {
readonly type: "cosmos-sdk/MsgBeginRedelegate";
readonly value: {
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded source validator address */
readonly validator_src_address: string;
/** Bech32 encoded destination validator address */
readonly validator_dst_address: string;
readonly amount: Coin;
};
}
export function isAminoMsgBeginRedelegate(msg: AminoMsg): msg is AminoMsgBeginRedelegate {
return (msg as AminoMsgBeginRedelegate).type === "cosmos-sdk/MsgBeginRedelegate";
}
/** Performs an undelegation from a delegate and a validator */
export interface AminoMsgUndelegate extends AminoMsg {
readonly type: "cosmos-sdk/MsgUndelegate";
readonly value: {
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded validator address */
readonly validator_address: string;
readonly amount: Coin;
};
}
export function isAminoMsgUndelegate(msg: AminoMsg): msg is AminoMsgUndelegate {
return (msg as AminoMsgUndelegate).type === "cosmos-sdk/MsgUndelegate";
}
// upgrade (no messages) - see https://github.com/cosmos/cosmos-sdk/blob/efa73c7/proto/cosmos/upgrade/upgrade.proto

View File

@ -1,21 +1,21 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { encodeBech32Pubkey } from "@cosmjs/amino";
import { fromBase64 } from "@cosmjs/encoding";
import {
MsgBeginRedelegate as LaunchpadMsgBeginRedelegate,
MsgCreateValidator as LaunchpadMsgCreateValidator,
MsgDelegate as LaunchpadMsgDelegate,
MsgEditValidator as LaunchpadMsgEditValidator,
MsgFundCommunityPool as LaunchpadMsgFundCommunityPool,
MsgMultiSend as LaunchpadMsgMultiSend,
MsgSend as LaunchpadMsgSend,
MsgSetWithdrawAddress as LaunchpadMsgSetWithdrawAddress,
MsgUndelegate as LaunchpadMsgUndelegate,
MsgWithdrawDelegatorReward as LaunchpadMsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission as LaunchpadMsgWithdrawValidatorCommission,
} from "@cosmjs/launchpad";
import { coin, coins } from "@cosmjs/proto-signing";
import {
AminoMsgBeginRedelegate,
AminoMsgCreateValidator,
AminoMsgDelegate,
AminoMsgEditValidator,
AminoMsgFundCommunityPool,
AminoMsgMultiSend,
AminoMsgSend,
AminoMsgSetWithdrawAddress,
AminoMsgUndelegate,
AminoMsgWithdrawDelegatorReward,
AminoMsgWithdrawValidatorCommission,
} from "./aminomsgs";
import { AminoTypes } from "./aminotypes";
import { MsgMultiSend, MsgSend } from "./codec/cosmos/bank/v1beta1/tx";
import {
@ -44,7 +44,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
value: msg,
});
const expected: LaunchpadMsgSend = {
const expected: AminoMsgSend = {
type: "cosmos-sdk/MsgSend",
value: {
from_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -70,7 +70,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend",
value: msg,
});
const expected: LaunchpadMsgMultiSend = {
const expected: AminoMsgMultiSend = {
type: "cosmos-sdk/MsgMultiSend",
value: {
inputs: [
@ -95,7 +95,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool",
value: msg,
});
const expected: LaunchpadMsgFundCommunityPool = {
const expected: AminoMsgFundCommunityPool = {
type: "cosmos-sdk/MsgFundCommunityPool",
value: {
amount: coins(1234, "ucosm"),
@ -114,7 +114,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
value: msg,
});
const expected: LaunchpadMsgSetWithdrawAddress = {
const expected: AminoMsgSetWithdrawAddress = {
type: "cosmos-sdk/MsgModifyWithdrawAddress",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -133,7 +133,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
value: msg,
});
const expected: LaunchpadMsgWithdrawDelegatorReward = {
const expected: AminoMsgWithdrawDelegatorReward = {
type: "cosmos-sdk/MsgWithdrawDelegationReward",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -151,7 +151,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
value: msg,
});
const expected: LaunchpadMsgWithdrawValidatorCommission = {
const expected: AminoMsgWithdrawValidatorCommission = {
type: "cosmos-sdk/MsgWithdrawValidatorCommission",
value: {
validator_address: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
@ -171,7 +171,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
value: msg,
});
const expected: LaunchpadMsgBeginRedelegate = {
const expected: AminoMsgBeginRedelegate = {
type: "cosmos-sdk/MsgBeginRedelegate",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -210,7 +210,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator",
value: msg,
});
const expected: LaunchpadMsgCreateValidator = {
const expected: AminoMsgCreateValidator = {
type: "cosmos-sdk/MsgCreateValidator",
value: {
description: {
@ -248,7 +248,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
value: msg,
});
const expected: LaunchpadMsgDelegate = {
const expected: AminoMsgDelegate = {
type: "cosmos-sdk/MsgDelegate",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -276,7 +276,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator",
value: msg,
});
const expected: LaunchpadMsgEditValidator = {
const expected: AminoMsgEditValidator = {
type: "cosmos-sdk/MsgEditValidator",
value: {
description: {
@ -304,7 +304,7 @@ describe("AminoTypes", () => {
typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate",
value: msg,
});
const expected: LaunchpadMsgUndelegate = {
const expected: AminoMsgUndelegate = {
type: "cosmos-sdk/MsgUndelegate",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -382,7 +382,7 @@ describe("AminoTypes", () => {
describe("fromAmino", () => {
it("works for MsgSend", () => {
const aminoMsg: LaunchpadMsgSend = {
const aminoMsg: AminoMsgSend = {
type: "cosmos-sdk/MsgSend",
value: {
from_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -403,7 +403,7 @@ describe("AminoTypes", () => {
});
it("works for MsgMultiSend", () => {
const aminoMsg: LaunchpadMsgMultiSend = {
const aminoMsg: AminoMsgMultiSend = {
type: "cosmos-sdk/MsgMultiSend",
value: {
inputs: [
@ -434,7 +434,7 @@ describe("AminoTypes", () => {
});
it("works for MsgBeginRedelegate", () => {
const aminoMsg: LaunchpadMsgBeginRedelegate = {
const aminoMsg: AminoMsgBeginRedelegate = {
type: "cosmos-sdk/MsgBeginRedelegate",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -457,7 +457,7 @@ describe("AminoTypes", () => {
});
it("works for MsgCreateValidator", () => {
const aminoMsg: LaunchpadMsgCreateValidator = {
const aminoMsg: AminoMsgCreateValidator = {
type: "cosmos-sdk/MsgCreateValidator",
value: {
description: {
@ -512,7 +512,7 @@ describe("AminoTypes", () => {
});
it("works for MsgDelegate", () => {
const aminoMsg: LaunchpadMsgDelegate = {
const aminoMsg: AminoMsgDelegate = {
type: "cosmos-sdk/MsgDelegate",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
@ -533,7 +533,7 @@ describe("AminoTypes", () => {
});
it("works for MsgEditValidator", () => {
const aminoMsg: LaunchpadMsgEditValidator = {
const aminoMsg: AminoMsgEditValidator = {
type: "cosmos-sdk/MsgEditValidator",
value: {
description: {
@ -568,7 +568,7 @@ describe("AminoTypes", () => {
});
it("works for MsgUndelegate", () => {
const aminoMsg: LaunchpadMsgUndelegate = {
const aminoMsg: AminoMsgUndelegate = {
type: "cosmos-sdk/MsgUndelegate",
value: {
delegator_address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",

View File

@ -1,22 +1,22 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { AminoMsg, decodeBech32Pubkey, encodeBech32Pubkey } from "@cosmjs/amino";
import { fromBase64, toBase64 } from "@cosmjs/encoding";
import {
MsgBeginRedelegate as LaunchpadMsgBeginRedelegate,
MsgCreateValidator as LaunchpadMsgCreateValidator,
MsgDelegate as LaunchpadMsgDelegate,
MsgEditValidator as LaunchpadMsgEditValidator,
MsgFundCommunityPool as LaunchpadMsgFundCommunityPool,
MsgMultiSend as LaunchpadMsgMultiSend,
MsgSend as LaunchpadMsgSend,
MsgSetWithdrawAddress as LaunchpadMsgSetWithdrawAddress,
MsgUndelegate as LaunchpadMsgUndelegate,
MsgWithdrawDelegatorReward as LaunchpadMsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission as LaunchpadMsgWithdrawValidatorCommission,
} from "@cosmjs/launchpad";
import { EncodeObject } from "@cosmjs/proto-signing";
import { assertDefinedAndNotNull } from "@cosmjs/utils";
import {
AminoMsgBeginRedelegate,
AminoMsgCreateValidator,
AminoMsgDelegate,
AminoMsgEditValidator,
AminoMsgFundCommunityPool,
AminoMsgMultiSend,
AminoMsgSend,
AminoMsgSetWithdrawAddress,
AminoMsgUndelegate,
AminoMsgWithdrawDelegatorReward,
AminoMsgWithdrawValidatorCommission,
} from "./aminomsgs";
import { MsgMultiSend, MsgSend } from "./codec/cosmos/bank/v1beta1/tx";
import {
MsgFundCommunityPool,
@ -43,7 +43,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
return {
"/cosmos.bank.v1beta1.MsgSend": {
aminoType: "cosmos-sdk/MsgSend",
toAmino: ({ fromAddress, toAddress, amount }: MsgSend): LaunchpadMsgSend["value"] => {
toAmino: ({ fromAddress, toAddress, amount }: MsgSend): AminoMsgSend["value"] => {
assertDefinedAndNotNull(fromAddress, "missing fromAddress");
assertDefinedAndNotNull(toAddress, "missing toAddress");
assertDefinedAndNotNull(amount, "missing amount");
@ -53,7 +53,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
amount: amount.map(coinFromProto),
};
},
fromAmino: ({ from_address, to_address, amount }: LaunchpadMsgSend["value"]): MsgSend => ({
fromAmino: ({ from_address, to_address, amount }: AminoMsgSend["value"]): MsgSend => ({
fromAddress: from_address,
toAddress: to_address,
amount: [...amount],
@ -61,7 +61,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
},
"/cosmos.bank.v1beta1.MsgMultiSend": {
aminoType: "cosmos-sdk/MsgMultiSend",
toAmino: ({ inputs, outputs }: MsgMultiSend): LaunchpadMsgMultiSend["value"] => {
toAmino: ({ inputs, outputs }: MsgMultiSend): AminoMsgMultiSend["value"] => {
assertDefinedAndNotNull(inputs, "missing inputs");
assertDefinedAndNotNull(outputs, "missing outputs");
return {
@ -83,7 +83,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
}),
};
},
fromAmino: ({ inputs, outputs }: LaunchpadMsgMultiSend["value"]): MsgMultiSend => ({
fromAmino: ({ inputs, outputs }: AminoMsgMultiSend["value"]): MsgMultiSend => ({
inputs: inputs.map((input) => ({
address: input.address,
coins: [...input.coins],
@ -96,7 +96,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
},
"/cosmos.distribution.v1beta1.MsgFundCommunityPool": {
aminoType: "cosmos-sdk/MsgFundCommunityPool",
toAmino: ({ amount, depositor }: MsgFundCommunityPool): LaunchpadMsgFundCommunityPool["value"] => {
toAmino: ({ amount, depositor }: MsgFundCommunityPool): AminoMsgFundCommunityPool["value"] => {
assertDefinedAndNotNull(amount);
assertDefinedAndNotNull(depositor);
return {
@ -104,7 +104,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
depositor: depositor,
};
},
fromAmino: ({ amount, depositor }: LaunchpadMsgFundCommunityPool["value"]): MsgFundCommunityPool => ({
fromAmino: ({ amount, depositor }: AminoMsgFundCommunityPool["value"]): MsgFundCommunityPool => ({
amount: [...amount],
depositor: depositor,
}),
@ -114,7 +114,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
toAmino: ({
delegatorAddress,
withdrawAddress,
}: MsgSetWithdrawAddress): LaunchpadMsgSetWithdrawAddress["value"] => {
}: MsgSetWithdrawAddress): AminoMsgSetWithdrawAddress["value"] => {
assertDefinedAndNotNull(delegatorAddress);
assertDefinedAndNotNull(withdrawAddress);
return {
@ -125,7 +125,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
fromAmino: ({
delegator_address,
withdraw_address,
}: LaunchpadMsgSetWithdrawAddress["value"]): MsgSetWithdrawAddress => ({
}: AminoMsgSetWithdrawAddress["value"]): MsgSetWithdrawAddress => ({
delegatorAddress: delegator_address,
withdrawAddress: withdraw_address,
}),
@ -135,7 +135,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
toAmino: ({
delegatorAddress,
validatorAddress,
}: MsgWithdrawDelegatorReward): LaunchpadMsgWithdrawDelegatorReward["value"] => {
}: MsgWithdrawDelegatorReward): AminoMsgWithdrawDelegatorReward["value"] => {
assertDefinedAndNotNull(delegatorAddress);
assertDefinedAndNotNull(validatorAddress);
return {
@ -146,7 +146,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
fromAmino: ({
delegator_address,
validator_address,
}: LaunchpadMsgWithdrawDelegatorReward["value"]): MsgWithdrawDelegatorReward => ({
}: AminoMsgWithdrawDelegatorReward["value"]): MsgWithdrawDelegatorReward => ({
delegatorAddress: delegator_address,
validatorAddress: validator_address,
}),
@ -155,7 +155,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
aminoType: "cosmos-sdk/MsgWithdrawValidatorCommission",
toAmino: ({
validatorAddress,
}: MsgWithdrawValidatorCommission): LaunchpadMsgWithdrawValidatorCommission["value"] => {
}: MsgWithdrawValidatorCommission): AminoMsgWithdrawValidatorCommission["value"] => {
assertDefinedAndNotNull(validatorAddress);
return {
validator_address: validatorAddress,
@ -163,7 +163,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
},
fromAmino: ({
validator_address,
}: LaunchpadMsgWithdrawValidatorCommission["value"]): MsgWithdrawValidatorCommission => ({
}: AminoMsgWithdrawValidatorCommission["value"]): MsgWithdrawValidatorCommission => ({
validatorAddress: validator_address,
}),
},
@ -174,7 +174,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
validatorSrcAddress,
validatorDstAddress,
amount,
}: MsgBeginRedelegate): LaunchpadMsgBeginRedelegate["value"] => {
}: MsgBeginRedelegate): AminoMsgBeginRedelegate["value"] => {
assertDefinedAndNotNull(delegatorAddress, "missing delegatorAddress");
assertDefinedAndNotNull(validatorSrcAddress, "missing validatorSrcAddress");
assertDefinedAndNotNull(validatorDstAddress, "missing validatorDstAddress");
@ -191,7 +191,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
validator_src_address,
validator_dst_address,
amount,
}: LaunchpadMsgBeginRedelegate["value"]): MsgBeginRedelegate => ({
}: AminoMsgBeginRedelegate["value"]): MsgBeginRedelegate => ({
delegatorAddress: delegator_address,
validatorSrcAddress: validator_src_address,
validatorDstAddress: validator_dst_address,
@ -208,7 +208,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
validatorAddress,
pubkey,
value,
}: MsgCreateValidator): LaunchpadMsgCreateValidator["value"] => {
}: MsgCreateValidator): AminoMsgCreateValidator["value"] => {
assertDefinedAndNotNull(description, "missing description");
assertDefinedAndNotNull(description.moniker, "missing description.moniker");
assertDefinedAndNotNull(description.identity, "missing description.identity");
@ -259,7 +259,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
validator_address,
pubkey,
value,
}: LaunchpadMsgCreateValidator["value"]): MsgCreateValidator => {
}: AminoMsgCreateValidator["value"]): MsgCreateValidator => {
const decodedPubkey = decodeBech32Pubkey(pubkey);
if (decodedPubkey.type !== "tendermint/PubKeySecp256k1") {
throw new Error("Only Secp256k1 public keys are supported");
@ -290,11 +290,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
},
"/cosmos.staking.v1beta1.MsgDelegate": {
aminoType: "cosmos-sdk/MsgDelegate",
toAmino: ({
delegatorAddress,
validatorAddress,
amount,
}: MsgDelegate): LaunchpadMsgDelegate["value"] => {
toAmino: ({ delegatorAddress, validatorAddress, amount }: MsgDelegate): AminoMsgDelegate["value"] => {
assertDefinedAndNotNull(delegatorAddress, "missing delegatorAddress");
assertDefinedAndNotNull(validatorAddress, "missing validatorAddress");
assertDefinedAndNotNull(amount, "missing amount");
@ -308,7 +304,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
delegator_address,
validator_address,
amount,
}: LaunchpadMsgDelegate["value"]): MsgDelegate => ({
}: AminoMsgDelegate["value"]): MsgDelegate => ({
delegatorAddress: delegator_address,
validatorAddress: validator_address,
amount: amount,
@ -321,7 +317,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
commissionRate,
minSelfDelegation,
validatorAddress,
}: MsgEditValidator): LaunchpadMsgEditValidator["value"] => {
}: MsgEditValidator): AminoMsgEditValidator["value"] => {
assertDefinedAndNotNull(description, "missing description");
assertDefinedAndNotNull(description.moniker, "missing description.moniker");
assertDefinedAndNotNull(description.identity, "missing description.identity");
@ -349,7 +345,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
commission_rate,
min_self_delegation,
validator_address,
}: LaunchpadMsgEditValidator["value"]): MsgEditValidator => ({
}: AminoMsgEditValidator["value"]): MsgEditValidator => ({
description: {
moniker: description.moniker,
identity: description.identity,
@ -368,7 +364,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
delegatorAddress,
validatorAddress,
amount,
}: MsgUndelegate): LaunchpadMsgUndelegate["value"] => {
}: MsgUndelegate): AminoMsgUndelegate["value"] => {
assertDefinedAndNotNull(delegatorAddress, "missing delegatorAddress");
assertDefinedAndNotNull(validatorAddress, "missing validatorAddress");
assertDefinedAndNotNull(amount, "missing amount");
@ -382,7 +378,7 @@ function createDefaultTypes(prefix: string): Record<string, AminoConverter> {
delegator_address,
validator_address,
amount,
}: LaunchpadMsgUndelegate["value"]): MsgUndelegate => ({
}: AminoMsgUndelegate["value"]): MsgUndelegate => ({
delegatorAddress: delegator_address,
validatorAddress: validator_address,
amount: amount,

View File

@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/naming-convention,no-bitwise */
import { Secp256k1HdWallet } from "@cosmjs/amino";
import { MsgDelegate as LaunchpadMsgDelegate } from "@cosmjs/launchpad";
import { coin, coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { assert, sleep } from "@cosmjs/utils";
import protobuf from "protobufjs/minimal";
import { AminoMsgDelegate } from "./aminomsgs";
import { AminoTypes } from "./aminotypes";
import { MsgSend } from "./codec/cosmos/bank/v1beta1/tx";
import { Coin } from "./codec/cosmos/base/v1beta1/coin";
@ -346,7 +346,7 @@ describe("SigningStargateClient", () => {
customDelegatorAddress,
customValidatorAddress,
customAmount,
}: CustomMsgDelegate): LaunchpadMsgDelegate["value"] => {
}: CustomMsgDelegate): AminoMsgDelegate["value"] => {
assert(customDelegatorAddress, "missing customDelegatorAddress");
assert(customValidatorAddress, "missing validatorAddress");
assert(customAmount, "missing amount");
@ -365,7 +365,7 @@ describe("SigningStargateClient", () => {
delegator_address,
validator_address,
amount,
}: LaunchpadMsgDelegate["value"]): CustomMsgDelegate => ({
}: AminoMsgDelegate["value"]): CustomMsgDelegate => ({
customDelegatorAddress: delegator_address,
customValidatorAddress: validator_address,
customAmount: Coin.fromPartial(amount),
@ -614,7 +614,7 @@ describe("SigningStargateClient", () => {
customDelegatorAddress,
customValidatorAddress,
customAmount,
}: CustomMsgDelegate): LaunchpadMsgDelegate["value"] => {
}: CustomMsgDelegate): AminoMsgDelegate["value"] => {
assert(customDelegatorAddress, "missing customDelegatorAddress");
assert(customValidatorAddress, "missing validatorAddress");
assert(customAmount, "missing amount");
@ -633,7 +633,7 @@ describe("SigningStargateClient", () => {
delegator_address,
validator_address,
amount,
}: LaunchpadMsgDelegate["value"]): CustomMsgDelegate => ({
}: AminoMsgDelegate["value"]): CustomMsgDelegate => ({
customDelegatorAddress: delegator_address,
customValidatorAddress: validator_address,
customAmount: Coin.fromPartial(amount),