Merge pull request #554 from cosmos/547-multisig-msg-types

CosmosMsg types for multisig client
This commit is contained in:
Will Clark 2020-11-26 15:55:27 +01:00 committed by GitHub
commit 97e3f81ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 150 additions and 4 deletions

View File

@ -0,0 +1,77 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Coin } from "@cosmjs/launchpad";
interface BankSendMsg {
readonly send: {
readonly from_address: string;
readonly to_address: string;
readonly amount: readonly Coin[];
};
}
export interface BankMsg {
readonly bank: BankSendMsg;
}
export interface CustomMsg {
readonly custom: Record<string, unknown>;
}
interface StakingDelegateMsg {
readonly delegate: {
readonly validator: string;
readonly amount: Coin;
};
}
interface StakingRedelegateMsg {
readonly redelgate: {
readonly src_validator: string;
readonly dst_validator: string;
readonly amount: Coin;
};
}
interface StakingUndelegateMsg {
readonly undelegate: {
readonly validator: string;
readonly amount: Coin;
};
}
interface StakingWithdrawMsg {
readonly withdraw: {
readonly validator: string;
readonly recipient?: string;
};
}
export interface StakingMsg {
readonly staking: StakingDelegateMsg | StakingRedelegateMsg | StakingUndelegateMsg | StakingWithdrawMsg;
}
interface WasmExecuteMsg {
readonly execute: {
readonly contract_address: string;
readonly msg: any;
readonly send: readonly Coin[];
};
}
interface WasmInstantiateMsg {
readonly instantiate: {
readonly code_id: string;
readonly msg: any;
readonly send: readonly Coin[];
readonly label?: string;
};
}
export interface WasmMsg {
readonly wasm: WasmExecuteMsg | WasmInstantiateMsg;
}
/** These definitions are derived from CosmWasm:
* https://github.com/CosmWasm/cosmwasm/blob/v0.12.0/packages/std/src/results/cosmos_msg.rs#L10-L23
*/
export type CosmosMsg = BankMsg | CustomMsg | StakingMsg | WasmMsg;

View File

@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { BroadcastMode, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad";
import { CosmosMsg } from "./cosmosmsg";
import { Account } from "./cosmwasmclient";
import { CosmWasmFeeTable, ExecuteResult, SigningCosmWasmClient } from "./signingcosmwasmclient";
@ -30,7 +31,7 @@ export interface ProposalResult {
readonly id: number;
readonly title: string;
readonly description: string;
readonly msgs: ReadonlyArray<Record<string, unknown>>;
readonly msgs: readonly CosmosMsg[];
readonly expires: Expiration;
readonly status: string;
}
@ -163,7 +164,7 @@ export class Cw3CosmWasmClient extends SigningCosmWasmClient {
public createMultisigProposal(
title: string,
description: string,
msgs: ReadonlyArray<Record<string, unknown>>,
msgs: readonly CosmosMsg[],
earliest?: Expiration,
latest?: Expiration,
memo = "",

View File

@ -1,4 +1,5 @@
export { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
export { BankMsg, CosmosMsg, CustomMsg, StakingMsg, WasmMsg } from "./cosmosmsg";
export {
Account,
Block,

65
packages/cosmwasm/types/cosmosmsg.d.ts vendored Normal file
View File

@ -0,0 +1,65 @@
import { Coin } from "@cosmjs/launchpad";
interface BankSendMsg {
readonly send: {
readonly from_address: string;
readonly to_address: string;
readonly amount: readonly Coin[];
};
}
export interface BankMsg {
readonly bank: BankSendMsg;
}
export interface CustomMsg {
readonly custom: Record<string, unknown>;
}
interface StakingDelegateMsg {
readonly delegate: {
readonly validator: string;
readonly amount: Coin;
};
}
interface StakingRedelegateMsg {
readonly redelgate: {
readonly src_validator: string;
readonly dst_validator: string;
readonly amount: Coin;
};
}
interface StakingUndelegateMsg {
readonly undelegate: {
readonly validator: string;
readonly amount: Coin;
};
}
interface StakingWithdrawMsg {
readonly withdraw: {
readonly validator: string;
readonly recipient?: string;
};
}
export interface StakingMsg {
readonly staking: StakingDelegateMsg | StakingRedelegateMsg | StakingUndelegateMsg | StakingWithdrawMsg;
}
interface WasmExecuteMsg {
readonly execute: {
readonly contract_address: string;
readonly msg: any;
readonly send: readonly Coin[];
};
}
interface WasmInstantiateMsg {
readonly instantiate: {
readonly code_id: string;
readonly msg: any;
readonly send: readonly Coin[];
readonly label?: string;
};
}
export interface WasmMsg {
readonly wasm: WasmExecuteMsg | WasmInstantiateMsg;
}
/** These definitions are derived from CosmWasm:
* https://github.com/CosmWasm/cosmwasm/blob/v0.12.0/packages/std/src/results/cosmos_msg.rs#L10-L23
*/
export declare type CosmosMsg = BankMsg | CustomMsg | StakingMsg | WasmMsg;
export {};

View File

@ -1,4 +1,5 @@
import { BroadcastMode, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad";
import { CosmosMsg } from "./cosmosmsg";
import { Account } from "./cosmwasmclient";
import { CosmWasmFeeTable, ExecuteResult, SigningCosmWasmClient } from "./signingcosmwasmclient";
export declare type Expiration =
@ -24,7 +25,7 @@ export interface ProposalResult {
readonly id: number;
readonly title: string;
readonly description: string;
readonly msgs: ReadonlyArray<Record<string, unknown>>;
readonly msgs: readonly CosmosMsg[];
readonly expires: Expiration;
readonly status: string;
}
@ -86,7 +87,7 @@ export declare class Cw3CosmWasmClient extends SigningCosmWasmClient {
createMultisigProposal(
title: string,
description: string,
msgs: ReadonlyArray<Record<string, unknown>>,
msgs: readonly CosmosMsg[],
earliest?: Expiration,
latest?: Expiration,
memo?: string,

View File

@ -1,4 +1,5 @@
export { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
export { BankMsg, CosmosMsg, CustomMsg, StakingMsg, WasmMsg } from "./cosmosmsg";
export {
Account,
Block,