mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Create new msgs module
This commit is contained in:
parent
a7596ae62f
commit
6b52d376b5
@ -4,6 +4,7 @@ import { assert, sleep } from "@cosmjs/utils";
|
|||||||
import { Coin } from "./coins";
|
import { Coin } from "./coins";
|
||||||
import { CosmosClient, isPostTxFailure } from "./cosmosclient";
|
import { CosmosClient, isPostTxFailure } from "./cosmosclient";
|
||||||
import { makeSignBytes } from "./encoding";
|
import { makeSignBytes } from "./encoding";
|
||||||
|
import { isMsgSend, MsgSend } from "./msgs";
|
||||||
import { Secp256k1Pen } from "./pen";
|
import { Secp256k1Pen } from "./pen";
|
||||||
import { RestClient } from "./restclient";
|
import { RestClient } from "./restclient";
|
||||||
import { SigningCosmosClient } from "./signingcosmosclient";
|
import { SigningCosmosClient } from "./signingcosmosclient";
|
||||||
@ -15,7 +16,7 @@ import {
|
|||||||
wasmd,
|
wasmd,
|
||||||
wasmdEnabled,
|
wasmdEnabled,
|
||||||
} from "./testutils.spec";
|
} from "./testutils.spec";
|
||||||
import { CosmosSdkTx, isMsgSend, MsgSend } from "./types";
|
import { CosmosSdkTx } from "./types";
|
||||||
|
|
||||||
describe("CosmosClient.searchTx", () => {
|
describe("CosmosClient.searchTx", () => {
|
||||||
let sendSuccessful:
|
let sendSuccessful:
|
||||||
|
@ -5,6 +5,7 @@ import { ReadonlyDate } from "readonly-date";
|
|||||||
import { CosmosClient, isPostTxFailure, PrivateCosmWasmClient } from "./cosmosclient";
|
import { CosmosClient, isPostTxFailure, PrivateCosmWasmClient } from "./cosmosclient";
|
||||||
import { makeSignBytes } from "./encoding";
|
import { makeSignBytes } from "./encoding";
|
||||||
import { findAttribute } from "./logs";
|
import { findAttribute } from "./logs";
|
||||||
|
import { MsgSend } from "./msgs";
|
||||||
import { Secp256k1Pen } from "./pen";
|
import { Secp256k1Pen } from "./pen";
|
||||||
import cosmoshub from "./testdata/cosmoshub.json";
|
import cosmoshub from "./testdata/cosmoshub.json";
|
||||||
import {
|
import {
|
||||||
@ -15,7 +16,7 @@ import {
|
|||||||
unused,
|
unused,
|
||||||
wasmd,
|
wasmd,
|
||||||
} from "./testutils.spec";
|
} from "./testutils.spec";
|
||||||
import { MsgSend, StdFee } from "./types";
|
import { StdFee } from "./types";
|
||||||
|
|
||||||
const blockTime = 1_000; // ms
|
const blockTime = 1_000; // ms
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { toUtf8 } from "@cosmjs/encoding";
|
import { toUtf8 } from "@cosmjs/encoding";
|
||||||
|
|
||||||
import { Msg, StdFee } from "./types";
|
import { Msg } from "./msgs";
|
||||||
|
import { StdFee } from "./types";
|
||||||
|
|
||||||
function sortJson(json: any): any {
|
function sortJson(json: any): any {
|
||||||
if (typeof json !== "object" || json === null) {
|
if (typeof json !== "object" || json === null) {
|
||||||
|
@ -30,20 +30,10 @@ export {
|
|||||||
SearchTxsResponse,
|
SearchTxsResponse,
|
||||||
TxsResponse,
|
TxsResponse,
|
||||||
} from "./restclient";
|
} from "./restclient";
|
||||||
|
export { isMsgSend, Msg, MsgSend } from "./msgs";
|
||||||
export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen";
|
export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen";
|
||||||
export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey";
|
export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey";
|
||||||
export { findSequenceForSignedTx } from "./sequence";
|
export { findSequenceForSignedTx } from "./sequence";
|
||||||
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
|
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
|
||||||
export { FeeTable, SigningCallback, SigningCosmosClient } from "./signingcosmosclient";
|
export { FeeTable, SigningCallback, SigningCosmosClient } from "./signingcosmosclient";
|
||||||
export {
|
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
|
||||||
isMsgSend,
|
|
||||||
isStdTx,
|
|
||||||
pubkeyType,
|
|
||||||
CosmosSdkTx,
|
|
||||||
PubKey,
|
|
||||||
Msg,
|
|
||||||
MsgSend,
|
|
||||||
StdFee,
|
|
||||||
StdSignature,
|
|
||||||
StdTx,
|
|
||||||
} from "./types";
|
|
||||||
|
22
packages/sdk38/src/msgs.ts
Normal file
22
packages/sdk38/src/msgs.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { Coin } from "./coins";
|
||||||
|
|
||||||
|
export interface Msg {
|
||||||
|
readonly type: string;
|
||||||
|
readonly value: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A Cosmos SDK token transfer message */
|
||||||
|
export interface MsgSend extends Msg {
|
||||||
|
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>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isMsgSend(msg: Msg): msg is MsgSend {
|
||||||
|
return (msg as MsgSend).type === "cosmos-sdk/MsgSend";
|
||||||
|
}
|
@ -7,6 +7,7 @@ import { rawSecp256k1PubkeyToAddress } from "./address";
|
|||||||
import { isPostTxFailure } from "./cosmosclient";
|
import { isPostTxFailure } from "./cosmosclient";
|
||||||
import { makeSignBytes } from "./encoding";
|
import { makeSignBytes } from "./encoding";
|
||||||
import { parseLogs } from "./logs";
|
import { parseLogs } from "./logs";
|
||||||
|
import { Msg, MsgSend } from "./msgs";
|
||||||
import { makeCosmoshubPath, Secp256k1Pen } from "./pen";
|
import { makeCosmoshubPath, Secp256k1Pen } from "./pen";
|
||||||
import { encodeBech32Pubkey } from "./pubkey";
|
import { encodeBech32Pubkey } from "./pubkey";
|
||||||
import { RestClient, TxsResponse } from "./restclient";
|
import { RestClient, TxsResponse } from "./restclient";
|
||||||
@ -26,7 +27,7 @@ import {
|
|||||||
wasmd,
|
wasmd,
|
||||||
wasmdEnabled,
|
wasmdEnabled,
|
||||||
} from "./testutils.spec";
|
} from "./testutils.spec";
|
||||||
import { Msg, MsgSend, StdFee, StdSignature, StdTx } from "./types";
|
import { StdFee, StdSignature, StdTx } from "./types";
|
||||||
|
|
||||||
const emptyAddress = "cosmos1ltkhnmdcqemmd2tkhnx7qx66tq7e0wykw2j85k";
|
const emptyAddress = "cosmos1ltkhnmdcqemmd2tkhnx7qx66tq7e0wykw2j85k";
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Coin, coins } from "./coins";
|
import { Coin, coins } from "./coins";
|
||||||
import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient";
|
import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient";
|
||||||
import { makeSignBytes } from "./encoding";
|
import { makeSignBytes } from "./encoding";
|
||||||
|
import { MsgSend } from "./msgs";
|
||||||
import { BroadcastMode } from "./restclient";
|
import { BroadcastMode } from "./restclient";
|
||||||
import { MsgSend, StdFee, StdSignature } from "./types";
|
import { StdFee, StdSignature } from "./types";
|
||||||
|
|
||||||
export interface SigningCallback {
|
export interface SigningCallback {
|
||||||
(signBytes: Uint8Array): Promise<StdSignature>;
|
(signBytes: Uint8Array): Promise<StdSignature>;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Coin } from "./coins";
|
import { Coin } from "./coins";
|
||||||
|
import { Msg } from "./msgs";
|
||||||
|
|
||||||
/** An Amino/Cosmos SDK StdTx */
|
/** An Amino/Cosmos SDK StdTx */
|
||||||
export interface StdTx {
|
export interface StdTx {
|
||||||
@ -20,27 +21,6 @@ export interface CosmosSdkTx {
|
|||||||
readonly value: StdTx;
|
readonly value: StdTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Msg {
|
|
||||||
readonly type: string;
|
|
||||||
readonly value: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A Cosmos SDK token transfer message */
|
|
||||||
export interface MsgSend extends Msg {
|
|
||||||
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>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isMsgSend(msg: Msg): msg is MsgSend {
|
|
||||||
return (msg as MsgSend).type === "cosmos-sdk/MsgSend";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StdFee {
|
export interface StdFee {
|
||||||
readonly amount: ReadonlyArray<Coin>;
|
readonly amount: ReadonlyArray<Coin>;
|
||||||
readonly gas: string;
|
readonly gas: string;
|
||||||
|
3
packages/sdk38/types/encoding.d.ts
vendored
3
packages/sdk38/types/encoding.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
import { Msg, StdFee } from "./types";
|
import { Msg } from "./msgs";
|
||||||
|
import { StdFee } from "./types";
|
||||||
export declare function makeSignBytes(
|
export declare function makeSignBytes(
|
||||||
msgs: readonly Msg[],
|
msgs: readonly Msg[],
|
||||||
fee: StdFee,
|
fee: StdFee,
|
||||||
|
14
packages/sdk38/types/index.d.ts
vendored
14
packages/sdk38/types/index.d.ts
vendored
@ -28,20 +28,10 @@ export {
|
|||||||
SearchTxsResponse,
|
SearchTxsResponse,
|
||||||
TxsResponse,
|
TxsResponse,
|
||||||
} from "./restclient";
|
} from "./restclient";
|
||||||
|
export { isMsgSend, Msg, MsgSend } from "./msgs";
|
||||||
export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen";
|
export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen";
|
||||||
export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey";
|
export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey";
|
||||||
export { findSequenceForSignedTx } from "./sequence";
|
export { findSequenceForSignedTx } from "./sequence";
|
||||||
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
|
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
|
||||||
export { FeeTable, SigningCallback, SigningCosmosClient } from "./signingcosmosclient";
|
export { FeeTable, SigningCallback, SigningCosmosClient } from "./signingcosmosclient";
|
||||||
export {
|
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
|
||||||
isMsgSend,
|
|
||||||
isStdTx,
|
|
||||||
pubkeyType,
|
|
||||||
CosmosSdkTx,
|
|
||||||
PubKey,
|
|
||||||
Msg,
|
|
||||||
MsgSend,
|
|
||||||
StdFee,
|
|
||||||
StdSignature,
|
|
||||||
StdTx,
|
|
||||||
} from "./types";
|
|
||||||
|
17
packages/sdk38/types/msgs.d.ts
vendored
Normal file
17
packages/sdk38/types/msgs.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { Coin } from "./coins";
|
||||||
|
export interface Msg {
|
||||||
|
readonly type: string;
|
||||||
|
readonly value: any;
|
||||||
|
}
|
||||||
|
/** A Cosmos SDK token transfer message */
|
||||||
|
export interface MsgSend extends Msg {
|
||||||
|
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>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export declare function isMsgSend(msg: Msg): msg is MsgSend;
|
17
packages/sdk38/types/types.d.ts
vendored
17
packages/sdk38/types/types.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
import { Coin } from "./coins";
|
import { Coin } from "./coins";
|
||||||
|
import { Msg } from "./msgs";
|
||||||
/** An Amino/Cosmos SDK StdTx */
|
/** An Amino/Cosmos SDK StdTx */
|
||||||
export interface StdTx {
|
export interface StdTx {
|
||||||
readonly msg: ReadonlyArray<Msg>;
|
readonly msg: ReadonlyArray<Msg>;
|
||||||
@ -11,22 +12,6 @@ export interface CosmosSdkTx {
|
|||||||
readonly type: string;
|
readonly type: string;
|
||||||
readonly value: StdTx;
|
readonly value: StdTx;
|
||||||
}
|
}
|
||||||
export interface Msg {
|
|
||||||
readonly type: string;
|
|
||||||
readonly value: any;
|
|
||||||
}
|
|
||||||
/** A Cosmos SDK token transfer message */
|
|
||||||
export interface MsgSend extends Msg {
|
|
||||||
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>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export declare function isMsgSend(msg: Msg): msg is MsgSend;
|
|
||||||
export interface StdFee {
|
export interface StdFee {
|
||||||
readonly amount: ReadonlyArray<Coin>;
|
readonly amount: ReadonlyArray<Coin>;
|
||||||
readonly gas: string;
|
readonly gas: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user