mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
cosmwasm: Extract CosmosMsg types into separate file
This commit is contained in:
parent
55f422f16c
commit
cf0c939cf5
77
packages/cosmwasm/src/cosmosmsg.ts
Normal file
77
packages/cosmwasm/src/cosmosmsg.ts
Normal 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;
|
@ -1,8 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { BroadcastMode, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad";
|
||||
|
||||
import { CosmosMsg } from "./cosmosmsg";
|
||||
import { Account } from "./cosmwasmclient";
|
||||
import { CosmosMsg } from "./msgs";
|
||||
import { CosmWasmFeeTable, ExecuteResult, SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
|
||||
export type Expiration =
|
||||
|
@ -1,4 +1,5 @@
|
||||
export { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
|
||||
export { BankMsg, CosmosMsg, CustomMsg, StakingMsg, WasmMsg } from "./cosmosmsg";
|
||||
export {
|
||||
Account,
|
||||
Block,
|
||||
@ -39,11 +40,6 @@ export {
|
||||
UploadResult,
|
||||
} from "./signingcosmwasmclient";
|
||||
export {
|
||||
BankMsg,
|
||||
CosmosMsg,
|
||||
CustomMsg,
|
||||
StakingMsg,
|
||||
WasmMsg,
|
||||
isMsgClearAdmin,
|
||||
isMsgExecuteContract,
|
||||
isMsgInstantiateContract,
|
||||
|
@ -144,75 +144,3 @@ export interface MsgMigrateContract extends Msg {
|
||||
export function isMsgMigrateContract(msg: Msg): msg is MsgMigrateContract {
|
||||
return (msg as MsgMigrateContract).type === "wasm/MsgMigrateContract";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export type CosmosMsg = BankMsg | CustomMsg | StakingMsg | WasmMsg;
|
||||
|
65
packages/cosmwasm/types/cosmosmsg.d.ts
vendored
Normal file
65
packages/cosmwasm/types/cosmosmsg.d.ts
vendored
Normal 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 {};
|
@ -1,6 +1,6 @@
|
||||
import { BroadcastMode, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad";
|
||||
import { CosmosMsg } from "./cosmosmsg";
|
||||
import { Account } from "./cosmwasmclient";
|
||||
import { CosmosMsg } from "./msgs";
|
||||
import { CosmWasmFeeTable, ExecuteResult, SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
export declare type Expiration =
|
||||
| {
|
||||
|
6
packages/cosmwasm/types/index.d.ts
vendored
6
packages/cosmwasm/types/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
export { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
|
||||
export { BankMsg, CosmosMsg, CustomMsg, StakingMsg, WasmMsg } from "./cosmosmsg";
|
||||
export {
|
||||
Account,
|
||||
Block,
|
||||
@ -39,11 +40,6 @@ export {
|
||||
UploadResult,
|
||||
} from "./signingcosmwasmclient";
|
||||
export {
|
||||
BankMsg,
|
||||
CosmosMsg,
|
||||
CustomMsg,
|
||||
StakingMsg,
|
||||
WasmMsg,
|
||||
isMsgClearAdmin,
|
||||
isMsgExecuteContract,
|
||||
isMsgInstantiateContract,
|
||||
|
61
packages/cosmwasm/types/msgs.d.ts
vendored
61
packages/cosmwasm/types/msgs.d.ts
vendored
@ -117,64 +117,3 @@ export interface MsgMigrateContract extends Msg {
|
||||
};
|
||||
}
|
||||
export declare function isMsgMigrateContract(msg: Msg): msg is MsgMigrateContract;
|
||||
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;
|
||||
}
|
||||
export declare type CosmosMsg = BankMsg | CustomMsg | StakingMsg | WasmMsg;
|
||||
export {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user