mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Improve Msg types
This commit is contained in:
parent
5da7bbc93c
commit
9d054c6dd3
@ -1,7 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
import { MsgExecuteContract } from "@cosmwasm/cosmwasm";
|
||||
import { Coin, IndexedTx, PubKey, StdSignature, StdTx } from "@cosmwasm/sdk38";
|
||||
import { Msg } from "@cosmwasm/sdk38/types/types";
|
||||
import { Coin, IndexedTx, Msg, PubKey, StdSignature, StdTx } from "@cosmwasm/sdk38";
|
||||
import { Address, Algorithm, isSendTransaction, SendTransaction, TokenTicker } from "@iov/bcp";
|
||||
import { Encoding } from "@iov/encoding";
|
||||
import { assert } from "@iov/utils";
|
||||
|
@ -1,6 +1,16 @@
|
||||
import { isMsgExecuteContract } from "@cosmwasm/cosmwasm";
|
||||
import { Coin, IndexedTx, PubKey, StdSignature } from "@cosmwasm/sdk38";
|
||||
import { isMsgSend, isStdTx, Msg, pubkeyType, StdFee, StdTx } from "@cosmwasm/sdk38/types/types";
|
||||
import {
|
||||
Coin,
|
||||
IndexedTx,
|
||||
isMsgSend,
|
||||
isStdTx,
|
||||
Msg,
|
||||
PubKey,
|
||||
pubkeyType,
|
||||
StdFee,
|
||||
StdSignature,
|
||||
StdTx,
|
||||
} from "@cosmwasm/sdk38";
|
||||
import {
|
||||
Address,
|
||||
Algorithm,
|
||||
|
3
packages/bcp/types/decode.d.ts
vendored
3
packages/bcp/types/decode.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Coin, IndexedTx, PubKey, StdSignature } from "@cosmwasm/sdk38";
|
||||
import { Msg, StdFee, StdTx } from "@cosmwasm/sdk38/types/types";
|
||||
import { Coin, IndexedTx, Msg, PubKey, StdFee, StdSignature, StdTx } from "@cosmwasm/sdk38";
|
||||
import {
|
||||
Amount,
|
||||
ChainId,
|
||||
|
@ -72,6 +72,7 @@ export function main(originalArgs: readonly string[]): void {
|
||||
"marshalTx",
|
||||
"IndexedTx",
|
||||
"Coin",
|
||||
"Msg",
|
||||
"MsgSend",
|
||||
"Pen",
|
||||
"PubKey",
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
import { Coin, CosmosSdkTx, makeSignBytes, Secp256k1Pen } from "@cosmwasm/sdk38";
|
||||
import { Coin, CosmosSdkTx, isMsgSend, makeSignBytes, MsgSend, Secp256k1Pen } from "@cosmwasm/sdk38";
|
||||
import { assert, sleep } from "@iov/utils";
|
||||
|
||||
import { CosmWasmClient } from "./cosmwasmclient";
|
||||
import { isMsgExecuteContract, isMsgInstantiateContract, isMsgSend, MsgSend } from "./msgs";
|
||||
import { isMsgExecuteContract, isMsgInstantiateContract } from "./msgs";
|
||||
import { RestClient } from "./restclient";
|
||||
import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
import { makeSignBytes, Secp256k1Pen, StdFee } from "@cosmwasm/sdk38";
|
||||
import { makeSignBytes, MsgSend, Secp256k1Pen, StdFee } from "@cosmwasm/sdk38";
|
||||
import { Sha256 } from "@iov/crypto";
|
||||
import { Bech32, Encoding } from "@iov/encoding";
|
||||
import { assert, sleep } from "@iov/utils";
|
||||
@ -7,7 +7,6 @@ import { ReadonlyDate } from "readonly-date";
|
||||
|
||||
import { Code, CosmWasmClient, PrivateCosmWasmClient } from "./cosmwasmclient";
|
||||
import { findAttribute } from "./logs";
|
||||
import { MsgSend } from "./msgs";
|
||||
import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import cosmoshub from "./testdata/cosmoshub.json";
|
||||
import {
|
||||
|
@ -1,28 +1,11 @@
|
||||
import { Coin } from "@cosmwasm/sdk38";
|
||||
|
||||
interface MsgTemplate {
|
||||
readonly type: string;
|
||||
readonly value: any;
|
||||
}
|
||||
|
||||
/** A Cosmos SDK token transfer message */
|
||||
export interface MsgSend extends MsgTemplate {
|
||||
readonly type: "cosmos-sdk/MsgSend";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
readonly from_address: string;
|
||||
/** Bech32 account address */
|
||||
readonly to_address: string;
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
};
|
||||
}
|
||||
import { Coin, Msg } from "@cosmwasm/sdk38";
|
||||
|
||||
/**
|
||||
* Uploads Wam code to the chain
|
||||
*
|
||||
* @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L17
|
||||
*/
|
||||
export interface MsgStoreCode extends MsgTemplate {
|
||||
export interface MsgStoreCode extends Msg {
|
||||
readonly type: "wasm/store-code";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -41,7 +24,7 @@ export interface MsgStoreCode extends MsgTemplate {
|
||||
*
|
||||
* @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L73
|
||||
*/
|
||||
export interface MsgInstantiateContract extends MsgTemplate {
|
||||
export interface MsgInstantiateContract extends Msg {
|
||||
readonly type: "wasm/instantiate";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -61,7 +44,7 @@ export interface MsgInstantiateContract extends MsgTemplate {
|
||||
*
|
||||
* @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L103
|
||||
*/
|
||||
export interface MsgExecuteContract extends MsgTemplate {
|
||||
export interface MsgExecuteContract extends Msg {
|
||||
readonly type: "wasm/execute";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -74,12 +57,6 @@ export interface MsgExecuteContract extends MsgTemplate {
|
||||
};
|
||||
}
|
||||
|
||||
export type Msg = MsgSend | MsgStoreCode | MsgInstantiateContract | MsgExecuteContract | MsgTemplate;
|
||||
|
||||
export function isMsgSend(msg: Msg): msg is MsgSend {
|
||||
return (msg as MsgSend).type === "cosmos-sdk/MsgSend";
|
||||
}
|
||||
|
||||
export function isMsgStoreCode(msg: Msg): msg is MsgStoreCode {
|
||||
return (msg as MsgStoreCode).type === "wasm/store-code";
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import {
|
||||
encodeBech32Pubkey,
|
||||
makeCosmoshubPath,
|
||||
makeSignBytes,
|
||||
Msg,
|
||||
MsgSend,
|
||||
Pen,
|
||||
rawSecp256k1PubkeyToAddress,
|
||||
Secp256k1Pen,
|
||||
@ -20,10 +22,8 @@ import { findAttribute, parseLogs } from "./logs";
|
||||
import {
|
||||
isMsgInstantiateContract,
|
||||
isMsgStoreCode,
|
||||
Msg,
|
||||
MsgExecuteContract,
|
||||
MsgInstantiateContract,
|
||||
MsgSend,
|
||||
MsgStoreCode,
|
||||
} from "./msgs";
|
||||
import { PostTxsResponse, RestClient, TxsResponse } from "./restclient";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Coin, coins, makeSignBytes, StdFee, StdSignature } from "@cosmwasm/sdk38";
|
||||
import { Coin, coins, makeSignBytes, MsgSend, StdFee, StdSignature } from "@cosmwasm/sdk38";
|
||||
import { Sha256 } from "@iov/crypto";
|
||||
import { Encoding } from "@iov/encoding";
|
||||
import pako from "pako";
|
||||
@ -6,7 +6,7 @@ import pako from "pako";
|
||||
import { isValidBuilder } from "./builder";
|
||||
import { Account, CosmWasmClient, GetNonceResult, PostTxResult } from "./cosmwasmclient";
|
||||
import { findAttribute, Log } from "./logs";
|
||||
import { MsgExecuteContract, MsgInstantiateContract, MsgSend, MsgStoreCode } from "./msgs";
|
||||
import { MsgExecuteContract, MsgInstantiateContract, MsgStoreCode } from "./msgs";
|
||||
import { BroadcastMode } from "./restclient";
|
||||
|
||||
export interface SigningCallback {
|
||||
|
26
packages/cosmwasm/types/msgs.d.ts
vendored
26
packages/cosmwasm/types/msgs.d.ts
vendored
@ -1,25 +1,10 @@
|
||||
import { Coin } from "@cosmwasm/sdk38";
|
||||
interface MsgTemplate {
|
||||
readonly type: string;
|
||||
readonly value: any;
|
||||
}
|
||||
/** A Cosmos SDK token transfer message */
|
||||
export interface MsgSend extends MsgTemplate {
|
||||
readonly type: "cosmos-sdk/MsgSend";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
readonly from_address: string;
|
||||
/** Bech32 account address */
|
||||
readonly to_address: string;
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
};
|
||||
}
|
||||
import { Coin, Msg } from "@cosmwasm/sdk38";
|
||||
/**
|
||||
* Uploads Wam code to the chain
|
||||
*
|
||||
* @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L17
|
||||
*/
|
||||
export interface MsgStoreCode extends MsgTemplate {
|
||||
export interface MsgStoreCode extends Msg {
|
||||
readonly type: "wasm/store-code";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -37,7 +22,7 @@ export interface MsgStoreCode extends MsgTemplate {
|
||||
*
|
||||
* @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L73
|
||||
*/
|
||||
export interface MsgInstantiateContract extends MsgTemplate {
|
||||
export interface MsgInstantiateContract extends Msg {
|
||||
readonly type: "wasm/instantiate";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -56,7 +41,7 @@ export interface MsgInstantiateContract extends MsgTemplate {
|
||||
*
|
||||
* @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L103
|
||||
*/
|
||||
export interface MsgExecuteContract extends MsgTemplate {
|
||||
export interface MsgExecuteContract extends Msg {
|
||||
readonly type: "wasm/execute";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -68,9 +53,6 @@ export interface MsgExecuteContract extends MsgTemplate {
|
||||
readonly sent_funds: ReadonlyArray<Coin>;
|
||||
};
|
||||
}
|
||||
export declare type Msg = MsgSend | MsgStoreCode | MsgInstantiateContract | MsgExecuteContract | MsgTemplate;
|
||||
export declare function isMsgSend(msg: Msg): msg is MsgSend;
|
||||
export declare function isMsgStoreCode(msg: Msg): msg is MsgStoreCode;
|
||||
export declare function isMsgInstantiateContract(msg: Msg): msg is MsgInstantiateContract;
|
||||
export declare function isMsgExecuteContract(msg: Msg): msg is MsgExecuteContract;
|
||||
export {};
|
||||
|
@ -37,6 +37,7 @@ export {
|
||||
pubkeyType,
|
||||
CosmosSdkTx,
|
||||
PubKey,
|
||||
Msg,
|
||||
MsgSend,
|
||||
StdFee,
|
||||
StdSignature,
|
||||
|
@ -24,13 +24,13 @@ export interface CosmosSdkTx {
|
||||
readonly value: StdTx;
|
||||
}
|
||||
|
||||
interface MsgTemplate {
|
||||
export interface Msg {
|
||||
readonly type: string;
|
||||
readonly value: any;
|
||||
}
|
||||
|
||||
/** A Cosmos SDK token transfer message */
|
||||
export interface MsgSend extends MsgTemplate {
|
||||
export interface MsgSend extends Msg {
|
||||
readonly type: "cosmos-sdk/MsgSend";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -41,8 +41,6 @@ export interface MsgSend extends MsgTemplate {
|
||||
};
|
||||
}
|
||||
|
||||
export type Msg = MsgSend | MsgTemplate;
|
||||
|
||||
export function isMsgSend(msg: Msg): msg is MsgSend {
|
||||
return (msg as MsgSend).type === "cosmos-sdk/MsgSend";
|
||||
}
|
||||
|
1
packages/sdk38/types/index.d.ts
vendored
1
packages/sdk38/types/index.d.ts
vendored
@ -35,6 +35,7 @@ export {
|
||||
pubkeyType,
|
||||
CosmosSdkTx,
|
||||
PubKey,
|
||||
Msg,
|
||||
MsgSend,
|
||||
StdFee,
|
||||
StdSignature,
|
||||
|
6
packages/sdk38/types/types.d.ts
vendored
6
packages/sdk38/types/types.d.ts
vendored
@ -11,12 +11,12 @@ export interface CosmosSdkTx {
|
||||
readonly type: string;
|
||||
readonly value: StdTx;
|
||||
}
|
||||
interface MsgTemplate {
|
||||
export interface Msg {
|
||||
readonly type: string;
|
||||
readonly value: any;
|
||||
}
|
||||
/** A Cosmos SDK token transfer message */
|
||||
export interface MsgSend extends MsgTemplate {
|
||||
export interface MsgSend extends Msg {
|
||||
readonly type: "cosmos-sdk/MsgSend";
|
||||
readonly value: {
|
||||
/** Bech32 account address */
|
||||
@ -26,7 +26,6 @@ export interface MsgSend extends MsgTemplate {
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
};
|
||||
}
|
||||
export declare type Msg = MsgSend | MsgTemplate;
|
||||
export declare function isMsgSend(msg: Msg): msg is MsgSend;
|
||||
export interface StdFee {
|
||||
readonly amount: ReadonlyArray<Coin>;
|
||||
@ -63,4 +62,3 @@ export declare function parseWasmData({ key, val }: WasmData): Model;
|
||||
* This doen't privide any type safety over `any` but expresses intent in the code.
|
||||
*/
|
||||
export declare type JsonObject = any;
|
||||
export {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user