Merge pull request #324 from CosmWasm/317-postTx-broadcastTx
Rename postTx -> broadcastTx
This commit is contained in:
commit
f7745b47b2
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,5 +1,18 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 0.23.0 (unreleased)
|
||||
|
||||
- @cosmjs/cosmwasm: Rename `CosmWasmClient.postTx` method to `.broadcastTx`.
|
||||
- @cosmjs/cosmwasm: Rename `SigningCosmWasmClient.signAndPost` method to
|
||||
`.signAndBroadcast`.
|
||||
- @cosmjs/launchpad: Rename `CosmosClient.postTx` method to `.broadcastTx`.
|
||||
- @cosmjs/launchpad: Rename `SigningCosmosClient.signAndPost` method to
|
||||
`.signAndBroadcast`.
|
||||
- @cosmjs/launchpad: Rename `PostTx`-related types to `BroadcastTxResult`,
|
||||
`BroadcastTxSuccess` and `BroadcastTxFailure` respectively, as well as helper
|
||||
functions `isBroadcastTxFailure`, `isBroadcastTxSuccess` and
|
||||
`assertIsBroadcastTxSuccess`.
|
||||
|
||||
## 0.22.0 (2020-08-03)
|
||||
|
||||
- @cosmjs/cli: Now supports HTTPs URLs for `--init` code sources.
|
||||
|
||||
@ -81,7 +81,7 @@ const signedTx: StdTx = {
|
||||
memo: memo,
|
||||
signatures: [signature],
|
||||
};
|
||||
const postResult = await client.postTx(signedTx);
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
```
|
||||
|
||||
## Extended helpers
|
||||
|
||||
@ -36,5 +36,5 @@ const signedTx: StdTx = {
|
||||
signatures: [signature],
|
||||
};
|
||||
|
||||
const result = await client.postTx(signedTx);
|
||||
console.log("Post result:", result);
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
console.log("Broadcast result:", result);
|
||||
|
||||
@ -95,6 +95,7 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
|
||||
"makeCosmoshubPath",
|
||||
"makeSignBytes",
|
||||
"IndexedTx",
|
||||
"BroadcastTxResult",
|
||||
"Coin",
|
||||
"CosmosClient",
|
||||
"Msg",
|
||||
@ -102,7 +103,6 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
|
||||
"MsgSend",
|
||||
"LcdClient",
|
||||
"OfflineSigner",
|
||||
"PostTxResult",
|
||||
"PubKey",
|
||||
"pubkeyToAddress",
|
||||
"Secp256k1Wallet",
|
||||
|
||||
@ -3,8 +3,8 @@ import {
|
||||
Coin,
|
||||
coins,
|
||||
CosmosSdkTx,
|
||||
isBroadcastTxFailure,
|
||||
isMsgSend,
|
||||
isPostTxFailure,
|
||||
LcdClient,
|
||||
makeSignBytes,
|
||||
MsgSend,
|
||||
@ -115,8 +115,8 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
},
|
||||
};
|
||||
const transactionId = await client.getIdentifier(tx);
|
||||
const result = await client.postTx(tx.value);
|
||||
if (isPostTxFailure(result)) {
|
||||
const result = await client.broadcastTx(tx.value);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
sendUnsuccessful = {
|
||||
sender: alice.address0,
|
||||
recipient: recipient,
|
||||
|
||||
@ -1,7 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Sha256 } from "@cosmjs/crypto";
|
||||
import { Bech32, fromHex, fromUtf8, toAscii, toBase64 } from "@cosmjs/encoding";
|
||||
import { assertIsPostTxSuccess, makeSignBytes, MsgSend, Secp256k1Wallet, StdFee } from "@cosmjs/launchpad";
|
||||
import {
|
||||
assertIsBroadcastTxSuccess,
|
||||
makeSignBytes,
|
||||
MsgSend,
|
||||
Secp256k1Wallet,
|
||||
StdFee,
|
||||
} from "@cosmjs/launchpad";
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
import { ReadonlyDate } from "readonly-date";
|
||||
|
||||
@ -197,7 +203,7 @@ describe("CosmWasmClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("postTx", () => {
|
||||
describe("broadcastTx", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic);
|
||||
@ -238,8 +244,8 @@ describe("CosmWasmClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature],
|
||||
};
|
||||
const result = await client.postTx(signedTx);
|
||||
assertIsPostTxSuccess(result);
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const { logs, transactionHash } = result;
|
||||
const amountAttr = findAttribute(logs, "transfer", "amount");
|
||||
expect(amountAttr.value).toEqual("1234567ucosm");
|
||||
|
||||
@ -3,12 +3,12 @@ import { fromBase64, fromHex, toHex } from "@cosmjs/encoding";
|
||||
import {
|
||||
AuthExtension,
|
||||
BroadcastMode,
|
||||
BroadcastTxResult,
|
||||
Coin,
|
||||
CosmosSdkTx,
|
||||
IndexedTx,
|
||||
LcdClient,
|
||||
normalizePubkey,
|
||||
PostTxResult,
|
||||
PubKey,
|
||||
setupAuthExtension,
|
||||
StdTx,
|
||||
@ -163,7 +163,7 @@ export class CosmWasmClient {
|
||||
* for the lifetime of your application. When switching backends, a new instance must be created.
|
||||
*
|
||||
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
public constructor(apiUrl: string, broadcastMode = BroadcastMode.Block) {
|
||||
this.lcdClient = LcdClient.withExtensions(
|
||||
@ -321,8 +321,8 @@ export class CosmWasmClient {
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public async postTx(tx: StdTx): Promise<PostTxResult> {
|
||||
const result = await this.lcdClient.postTx(tx);
|
||||
public async broadcastTx(tx: StdTx): Promise<BroadcastTxResult> {
|
||||
const result = await this.lcdClient.broadcastTx(tx);
|
||||
if (!result.txhash.match(/^([0-9A-F][0-9A-F])+$/)) {
|
||||
throw new Error("Received ill-formatted txhash. Must be non-empty upper-case hex");
|
||||
}
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
import { Sha256 } from "@cosmjs/crypto";
|
||||
import { Bech32, fromAscii, fromHex, fromUtf8, toAscii, toBase64, toHex } from "@cosmjs/encoding";
|
||||
import {
|
||||
assertIsPostTxSuccess,
|
||||
assertIsBroadcastTxSuccess,
|
||||
AuthExtension,
|
||||
BroadcastTxResult,
|
||||
BroadcastTxsResponse,
|
||||
Coin,
|
||||
coin,
|
||||
coins,
|
||||
LcdClient,
|
||||
makeSignBytes,
|
||||
OfflineSigner,
|
||||
PostTxResult,
|
||||
PostTxsResponse,
|
||||
Secp256k1Wallet,
|
||||
setupAuthExtension,
|
||||
SigningCosmosClient,
|
||||
@ -52,7 +52,7 @@ function makeWasmClient(apiUrl: string): WasmClient {
|
||||
async function uploadContract(
|
||||
signer: OfflineSigner,
|
||||
contract: ContractUploadInstructions,
|
||||
): Promise<PostTxResult> {
|
||||
): Promise<BroadcastTxResult> {
|
||||
const memo = "My first contract on chain";
|
||||
const theMsg: MsgStoreCode = {
|
||||
type: "wasm/MsgStoreCode",
|
||||
@ -70,7 +70,7 @@ async function uploadContract(
|
||||
|
||||
const firstAddress = (await signer.getAccounts())[0].address;
|
||||
const client = new SigningCosmosClient(wasmd.endpoint, firstAddress, signer);
|
||||
return client.signAndPost([theMsg], fee, memo);
|
||||
return client.signAndBroadcast([theMsg], fee, memo);
|
||||
}
|
||||
|
||||
async function instantiateContract(
|
||||
@ -78,7 +78,7 @@ async function instantiateContract(
|
||||
codeId: number,
|
||||
beneficiaryAddress: string,
|
||||
transferAmount?: readonly Coin[],
|
||||
): Promise<PostTxResult> {
|
||||
): Promise<BroadcastTxResult> {
|
||||
const memo = "Create an escrow instance";
|
||||
const theMsg: MsgInstantiateContract = {
|
||||
type: "wasm/MsgInstantiateContract",
|
||||
@ -100,7 +100,7 @@ async function instantiateContract(
|
||||
|
||||
const firstAddress = (await signer.getAccounts())[0].address;
|
||||
const client = new SigningCosmosClient(wasmd.endpoint, firstAddress, signer);
|
||||
return client.signAndPost([theMsg], fee, memo);
|
||||
return client.signAndBroadcast([theMsg], fee, memo);
|
||||
}
|
||||
|
||||
async function executeContract(
|
||||
@ -108,7 +108,7 @@ async function executeContract(
|
||||
signer: OfflineSigner,
|
||||
contractAddress: string,
|
||||
msg: object,
|
||||
): Promise<PostTxsResponse> {
|
||||
): Promise<BroadcastTxsResponse> {
|
||||
const memo = "Time for action";
|
||||
const theMsg: MsgExecuteContract = {
|
||||
type: "wasm/MsgExecuteContract",
|
||||
@ -128,7 +128,7 @@ async function executeContract(
|
||||
const signBytes = makeSignBytes([theMsg], fee, wasmd.chainId, memo, account_number, sequence);
|
||||
const signature = await signer.sign(alice.address0, signBytes);
|
||||
const signedTx = makeSignedTx(theMsg, fee, memo, signature);
|
||||
return client.postTx(signedTx);
|
||||
return client.broadcastTx(signedTx);
|
||||
}
|
||||
|
||||
describe("WasmExtension", () => {
|
||||
@ -141,13 +141,13 @@ describe("WasmExtension", () => {
|
||||
if (wasmdEnabled()) {
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic);
|
||||
const result = await uploadContract(wallet, hackatom);
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const logs = parseLogs(result.logs);
|
||||
const codeIdAttr = findAttribute(logs, "message", "code_id");
|
||||
hackatomCodeId = Number.parseInt(codeIdAttr.value, 10);
|
||||
|
||||
const instantiateResult = await instantiateContract(wallet, hackatomCodeId, makeRandomAddress());
|
||||
assertIsPostTxSuccess(instantiateResult);
|
||||
assertIsBroadcastTxSuccess(instantiateResult);
|
||||
const instantiateLogs = parseLogs(instantiateResult.logs);
|
||||
const contractAddressAttr = findAttribute(instantiateLogs, "message", "contract_address");
|
||||
hackatomContractAddress = contractAddressAttr.value;
|
||||
@ -204,7 +204,7 @@ describe("WasmExtension", () => {
|
||||
}
|
||||
|
||||
const result = await instantiateContract(wallet, hackatomCodeId, beneficiaryAddress, transferAmount);
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const logs = parseLogs(result.logs);
|
||||
const contractAddressAttr = findAttribute(logs, "message", "contract_address");
|
||||
const myAddress = contractAddressAttr.value;
|
||||
@ -253,7 +253,7 @@ describe("WasmExtension", () => {
|
||||
|
||||
// create new instance and compare before and after
|
||||
const result = await instantiateContract(wallet, hackatomCodeId, beneficiaryAddress, transferAmount);
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const logs = parseLogs(result.logs);
|
||||
const contractAddressAttr = findAttribute(logs, "message", "contract_address");
|
||||
const myAddress = contractAddressAttr.value;
|
||||
@ -468,7 +468,7 @@ describe("WasmExtension", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("postTx", () => {
|
||||
describe("broadcastTx", () => {
|
||||
it("can upload, instantiate and execute wasm", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic);
|
||||
@ -483,7 +483,7 @@ describe("WasmExtension", () => {
|
||||
{
|
||||
// console.log("Raw log:", result.raw_log);
|
||||
const result = await uploadContract(wallet, getHackatom());
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const logs = parseLogs(result.logs);
|
||||
const codeIdAttr = findAttribute(logs, "message", "code_id");
|
||||
codeId = Number.parseInt(codeIdAttr.value, 10);
|
||||
@ -497,7 +497,7 @@ describe("WasmExtension", () => {
|
||||
// instantiate
|
||||
{
|
||||
const result = await instantiateContract(wallet, codeId, beneficiaryAddress, transferAmount);
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
// console.log("Raw log:", result.raw_log);
|
||||
const logs = parseLogs(result.logs);
|
||||
const contractAddressAttr = findAttribute(logs, "message", "contract_address");
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { Sha256 } from "@cosmjs/crypto";
|
||||
import { toHex } from "@cosmjs/encoding";
|
||||
import {
|
||||
assertIsPostTxSuccess,
|
||||
assertIsBroadcastTxSuccess,
|
||||
AuthExtension,
|
||||
coin,
|
||||
coins,
|
||||
@ -333,7 +333,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
|
||||
// send
|
||||
const result = await client.sendTokens(beneficiaryAddress, transferAmount, "for dinner");
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const [firstLog] = result.logs;
|
||||
expect(firstLog).toBeTruthy();
|
||||
|
||||
@ -344,7 +344,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("signAndPost", () => {
|
||||
describe("signAndBroadcast", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic);
|
||||
@ -362,8 +362,8 @@ describe("SigningCosmWasmClient", () => {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "180000", // 180k
|
||||
};
|
||||
const result = await client.signAndPost([msg], fee, "Use your power wisely");
|
||||
assertIsPostTxSuccess(result);
|
||||
const result = await client.signAndBroadcast([msg], fee, "Use your power wisely");
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,15 +3,15 @@ import { Sha256 } from "@cosmjs/crypto";
|
||||
import { toBase64, toHex } from "@cosmjs/encoding";
|
||||
import {
|
||||
BroadcastMode,
|
||||
BroadcastTxFailure,
|
||||
BroadcastTxResult,
|
||||
Coin,
|
||||
coins,
|
||||
isPostTxFailure,
|
||||
isBroadcastTxFailure,
|
||||
makeSignBytes,
|
||||
Msg,
|
||||
MsgSend,
|
||||
OfflineSigner,
|
||||
PostTxFailure,
|
||||
PostTxResult,
|
||||
StdFee,
|
||||
StdTx,
|
||||
} from "@cosmjs/launchpad";
|
||||
@ -154,8 +154,8 @@ export interface ExecuteResult {
|
||||
readonly transactionHash: string;
|
||||
}
|
||||
|
||||
function createPostTxErrorMessage(result: PostTxFailure): string {
|
||||
return `Error when posting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`;
|
||||
function createBroadcastTxErrorMessage(result: BroadcastTxFailure): string {
|
||||
return `Error when broadcasting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`;
|
||||
}
|
||||
|
||||
export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
@ -174,7 +174,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
* @param senderAddress The address that will sign and send transactions using this instance
|
||||
* @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input.
|
||||
* @param customFees The fees that are paid for transactions
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
public constructor(
|
||||
apiUrl: string,
|
||||
@ -214,9 +214,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
builder: builder,
|
||||
},
|
||||
};
|
||||
const result = await this.signAndPost([storeCodeMsg], this.fees.upload, memo);
|
||||
if (isPostTxFailure(result)) {
|
||||
throw new Error(createPostTxErrorMessage(result));
|
||||
const result = await this.signAndBroadcast([storeCodeMsg], this.fees.upload, memo);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(createBroadcastTxErrorMessage(result));
|
||||
}
|
||||
const codeIdAttr = findAttribute(result.logs, "message", "code_id");
|
||||
return {
|
||||
@ -247,9 +247,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
admin: options.admin,
|
||||
},
|
||||
};
|
||||
const result = await this.signAndPost([instantiateMsg], this.fees.init, options.memo);
|
||||
if (isPostTxFailure(result)) {
|
||||
throw new Error(createPostTxErrorMessage(result));
|
||||
const result = await this.signAndBroadcast([instantiateMsg], this.fees.init, options.memo);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(createBroadcastTxErrorMessage(result));
|
||||
}
|
||||
const contractAddressAttr = findAttribute(result.logs, "message", "contract_address");
|
||||
return {
|
||||
@ -268,9 +268,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
new_admin: newAdmin,
|
||||
},
|
||||
};
|
||||
const result = await this.signAndPost([updateAdminMsg], this.fees.changeAdmin, memo);
|
||||
if (isPostTxFailure(result)) {
|
||||
throw new Error(createPostTxErrorMessage(result));
|
||||
const result = await this.signAndBroadcast([updateAdminMsg], this.fees.changeAdmin, memo);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(createBroadcastTxErrorMessage(result));
|
||||
}
|
||||
return {
|
||||
logs: result.logs,
|
||||
@ -286,9 +286,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
contract: contractAddress,
|
||||
},
|
||||
};
|
||||
const result = await this.signAndPost([clearAdminMsg], this.fees.changeAdmin, memo);
|
||||
if (isPostTxFailure(result)) {
|
||||
throw new Error(createPostTxErrorMessage(result));
|
||||
const result = await this.signAndBroadcast([clearAdminMsg], this.fees.changeAdmin, memo);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(createBroadcastTxErrorMessage(result));
|
||||
}
|
||||
return {
|
||||
logs: result.logs,
|
||||
@ -311,9 +311,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
msg: migrateMsg,
|
||||
},
|
||||
};
|
||||
const result = await this.signAndPost([msg], this.fees.migrate, memo);
|
||||
if (isPostTxFailure(result)) {
|
||||
throw new Error(createPostTxErrorMessage(result));
|
||||
const result = await this.signAndBroadcast([msg], this.fees.migrate, memo);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(createBroadcastTxErrorMessage(result));
|
||||
}
|
||||
return {
|
||||
logs: result.logs,
|
||||
@ -336,9 +336,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
sent_funds: transferAmount || [],
|
||||
},
|
||||
};
|
||||
const result = await this.signAndPost([executeMsg], this.fees.exec, memo);
|
||||
if (isPostTxFailure(result)) {
|
||||
throw new Error(createPostTxErrorMessage(result));
|
||||
const result = await this.signAndBroadcast([executeMsg], this.fees.exec, memo);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(createBroadcastTxErrorMessage(result));
|
||||
}
|
||||
return {
|
||||
logs: result.logs,
|
||||
@ -350,7 +350,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<PostTxResult> {
|
||||
): Promise<BroadcastTxResult> {
|
||||
const sendMsg: MsgSend = {
|
||||
type: "cosmos-sdk/MsgSend",
|
||||
value: {
|
||||
@ -359,14 +359,14 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
amount: transferAmount,
|
||||
},
|
||||
};
|
||||
return this.signAndPost([sendMsg], this.fees.send, memo);
|
||||
return this.signAndBroadcast([sendMsg], this.fees.send, memo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets account number and sequence from the API, creates a sign doc,
|
||||
* creates a single signature, assembles the signed transaction and broadcasts it.
|
||||
*/
|
||||
public async signAndPost(msgs: readonly Msg[], fee: StdFee, memo = ""): Promise<PostTxResult> {
|
||||
public async signAndBroadcast(msgs: readonly Msg[], fee: StdFee, memo = ""): Promise<BroadcastTxResult> {
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes(msgs, fee, chainId, memo, accountNumber, sequence);
|
||||
@ -377,6 +377,6 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
memo: memo,
|
||||
signatures: [signature],
|
||||
};
|
||||
return this.postTx(signedTx);
|
||||
return this.broadcastTx(signedTx);
|
||||
}
|
||||
}
|
||||
|
||||
6
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
6
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
@ -1,11 +1,11 @@
|
||||
import {
|
||||
AuthExtension,
|
||||
BroadcastMode,
|
||||
BroadcastTxResult,
|
||||
Coin,
|
||||
CosmosSdkTx,
|
||||
IndexedTx,
|
||||
LcdClient,
|
||||
PostTxResult,
|
||||
PubKey,
|
||||
StdTx,
|
||||
} from "@cosmjs/launchpad";
|
||||
@ -124,7 +124,7 @@ export declare class CosmWasmClient {
|
||||
* for the lifetime of your application. When switching backends, a new instance must be created.
|
||||
*
|
||||
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
constructor(apiUrl: string, broadcastMode?: BroadcastMode);
|
||||
getChainId(): Promise<string>;
|
||||
@ -149,7 +149,7 @@ export declare class CosmWasmClient {
|
||||
*/
|
||||
getBlock(height?: number): Promise<Block>;
|
||||
searchTx(query: SearchTxQuery, filter?: SearchTxFilter): Promise<readonly IndexedTx[]>;
|
||||
postTx(tx: StdTx): Promise<PostTxResult>;
|
||||
broadcastTx(tx: StdTx): Promise<BroadcastTxResult>;
|
||||
getCodes(): Promise<readonly Code[]>;
|
||||
getCodeDetails(codeId: number): Promise<CodeDetails>;
|
||||
getContracts(codeId: number): Promise<readonly Contract[]>;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BroadcastMode, Coin, Msg, OfflineSigner, PostTxResult, StdFee } from "@cosmjs/launchpad";
|
||||
import { BroadcastMode, BroadcastTxResult, Coin, Msg, OfflineSigner, StdFee } from "@cosmjs/launchpad";
|
||||
import { Account, CosmWasmClient, GetSequenceResult } from "./cosmwasmclient";
|
||||
import { Log } from "./logs";
|
||||
/**
|
||||
@ -95,7 +95,7 @@ export declare class SigningCosmWasmClient extends CosmWasmClient {
|
||||
* @param senderAddress The address that will sign and send transactions using this instance
|
||||
* @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input.
|
||||
* @param customFees The fees that are paid for transactions
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
constructor(
|
||||
apiUrl: string,
|
||||
@ -123,10 +123,14 @@ export declare class SigningCosmWasmClient extends CosmWasmClient {
|
||||
memo?: string,
|
||||
transferAmount?: readonly Coin[],
|
||||
): Promise<ExecuteResult>;
|
||||
sendTokens(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<PostTxResult>;
|
||||
sendTokens(
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
memo?: string,
|
||||
): Promise<BroadcastTxResult>;
|
||||
/**
|
||||
* Gets account number and sequence from the API, creates a sign doc,
|
||||
* creates a single signature, assembles the signed transaction and broadcasts it.
|
||||
*/
|
||||
signAndPost(msgs: readonly Msg[], fee: StdFee, memo?: string): Promise<PostTxResult>;
|
||||
signAndBroadcast(msgs: readonly Msg[], fee: StdFee, memo?: string): Promise<BroadcastTxResult>;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ export class Faucet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and posts a send transaction. Then waits until the transaction is in a block.
|
||||
* Creates and broadcasts a send transaction. Then waits until the transaction is in a block.
|
||||
*/
|
||||
public async send(job: SendJob): Promise<void> {
|
||||
await this.clients[job.sender].sendTokens(job.recipient, [job.amount], "Make love, not war");
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
|
||||
import { coins } from "./coins";
|
||||
import { CosmosClient, isPostTxFailure } from "./cosmosclient";
|
||||
import { CosmosClient, isBroadcastTxFailure } from "./cosmosclient";
|
||||
import { makeSignBytes } from "./encoding";
|
||||
import { LcdClient } from "./lcdapi";
|
||||
import { isMsgSend, MsgSend } from "./msgs";
|
||||
@ -67,8 +67,8 @@ describe("CosmosClient.searchTx", () => {
|
||||
},
|
||||
};
|
||||
const transactionId = await client.getIdentifier(tx);
|
||||
const result = await client.postTx(tx.value);
|
||||
if (isPostTxFailure(result)) {
|
||||
const result = await client.broadcastTx(tx.value);
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
sendUnsuccessful = {
|
||||
sender: faucet.address,
|
||||
recipient: recipient,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { sleep } from "@cosmjs/utils";
|
||||
import { ReadonlyDate } from "readonly-date";
|
||||
|
||||
import { assertIsPostTxSuccess, CosmosClient, PrivateCosmWasmClient } from "./cosmosclient";
|
||||
import { assertIsBroadcastTxSuccess, CosmosClient, PrivateCosmWasmClient } from "./cosmosclient";
|
||||
import { makeSignBytes } from "./encoding";
|
||||
import { findAttribute } from "./logs";
|
||||
import { MsgSend } from "./msgs";
|
||||
@ -190,7 +190,7 @@ describe("CosmosClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("postTx", () => {
|
||||
describe("broadcastTx", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic);
|
||||
@ -233,8 +233,8 @@ describe("CosmosClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature],
|
||||
};
|
||||
const txResult = await client.postTx(signedTx);
|
||||
assertIsPostTxSuccess(txResult);
|
||||
const txResult = await client.broadcastTx(signedTx);
|
||||
assertIsBroadcastTxSuccess(txResult);
|
||||
const { logs, transactionHash } = txResult;
|
||||
const amountAttr = findAttribute(logs, "transfer", "amount");
|
||||
expect(amountAttr.value).toEqual("1234567ucosm");
|
||||
|
||||
@ -28,7 +28,7 @@ export interface Account {
|
||||
readonly sequence: number;
|
||||
}
|
||||
|
||||
export interface PostTxFailure {
|
||||
export interface BroadcastTxFailure {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly height: number;
|
||||
@ -36,7 +36,7 @@ export interface PostTxFailure {
|
||||
readonly rawLog: string;
|
||||
}
|
||||
|
||||
export interface PostTxSuccess {
|
||||
export interface BroadcastTxSuccess {
|
||||
readonly logs: readonly Log[];
|
||||
readonly rawLog: string;
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
@ -44,23 +44,23 @@ export interface PostTxSuccess {
|
||||
readonly data?: Uint8Array;
|
||||
}
|
||||
|
||||
export type PostTxResult = PostTxSuccess | PostTxFailure;
|
||||
export type BroadcastTxResult = BroadcastTxSuccess | BroadcastTxFailure;
|
||||
|
||||
export function isPostTxFailure(result: PostTxResult): result is PostTxFailure {
|
||||
return !!(result as PostTxFailure).code;
|
||||
export function isBroadcastTxFailure(result: BroadcastTxResult): result is BroadcastTxFailure {
|
||||
return !!(result as BroadcastTxFailure).code;
|
||||
}
|
||||
|
||||
export function isPostTxSuccess(result: PostTxResult): result is PostTxSuccess {
|
||||
return !isPostTxFailure(result);
|
||||
export function isBroadcastTxSuccess(result: BroadcastTxResult): result is BroadcastTxSuccess {
|
||||
return !isBroadcastTxFailure(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the given result is a success. Throws a detailed error message otherwise.
|
||||
*/
|
||||
export function assertIsPostTxSuccess(result: PostTxResult): asserts result is PostTxSuccess {
|
||||
if (isPostTxFailure(result)) {
|
||||
export function assertIsBroadcastTxSuccess(result: BroadcastTxResult): asserts result is BroadcastTxSuccess {
|
||||
if (isBroadcastTxFailure(result)) {
|
||||
throw new Error(
|
||||
`Error when posting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`,
|
||||
`Error when broadcasting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ export class CosmosClient {
|
||||
* for the lifetime of your application. When switching backends, a new instance must be created.
|
||||
*
|
||||
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
public constructor(apiUrl: string, broadcastMode = BroadcastMode.Block) {
|
||||
this.lcdClient = LcdClient.withExtensions(
|
||||
@ -310,8 +310,8 @@ export class CosmosClient {
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public async postTx(tx: StdTx): Promise<PostTxResult> {
|
||||
const result = await this.lcdClient.postTx(tx);
|
||||
public async broadcastTx(tx: StdTx): Promise<BroadcastTxResult> {
|
||||
const result = await this.lcdClient.broadcastTx(tx);
|
||||
if (!result.txhash.match(/^([0-9A-F][0-9A-F])+$/)) {
|
||||
throw new Error("Received ill-formatted txhash. Must be non-empty upper-case hex");
|
||||
}
|
||||
|
||||
@ -6,17 +6,17 @@ export { Coin, coin, coins } from "./coins";
|
||||
|
||||
export {
|
||||
Account,
|
||||
assertIsPostTxSuccess,
|
||||
assertIsBroadcastTxSuccess,
|
||||
Block,
|
||||
BlockHeader,
|
||||
CosmosClient,
|
||||
GetSequenceResult,
|
||||
IndexedTx,
|
||||
isPostTxFailure,
|
||||
isPostTxSuccess,
|
||||
PostTxFailure,
|
||||
PostTxResult,
|
||||
PostTxSuccess,
|
||||
isBroadcastTxFailure,
|
||||
isBroadcastTxSuccess,
|
||||
BroadcastTxFailure,
|
||||
BroadcastTxResult,
|
||||
BroadcastTxSuccess,
|
||||
SearchByHeightQuery,
|
||||
SearchByIdQuery,
|
||||
SearchBySentFromOrToQuery,
|
||||
@ -62,7 +62,7 @@ export {
|
||||
NodeInfoResponse,
|
||||
normalizeLcdApiArray,
|
||||
normalizePubkey,
|
||||
PostTxsResponse,
|
||||
BroadcastTxsResponse,
|
||||
SearchTxsResponse,
|
||||
setupAuthExtension,
|
||||
setupBankExtension,
|
||||
|
||||
@ -126,7 +126,7 @@ export interface SearchTxsResponse {
|
||||
readonly txs: readonly TxsResponse[];
|
||||
}
|
||||
|
||||
export interface PostTxsResponse {
|
||||
export interface BroadcastTxsResponse {
|
||||
readonly height: string;
|
||||
readonly txhash: string;
|
||||
readonly code?: number;
|
||||
|
||||
@ -3,7 +3,7 @@ import { Bech32 } from "@cosmjs/encoding";
|
||||
import { sleep } from "@cosmjs/utils";
|
||||
|
||||
import { coin, coins } from "../coins";
|
||||
import { assertIsPostTxSuccess } from "../cosmosclient";
|
||||
import { assertIsBroadcastTxSuccess } from "../cosmosclient";
|
||||
import { makeSignBytes } from "../encoding";
|
||||
import { MsgDelegate } from "../msgs";
|
||||
import { Secp256k1Wallet } from "../secp256k1wallet";
|
||||
@ -55,8 +55,8 @@ describe("DistributionExtension", () => {
|
||||
signatures: [signature],
|
||||
};
|
||||
|
||||
const result = await client.postTx(tx);
|
||||
assertIsPostTxSuccess(result);
|
||||
const result = await client.broadcastTx(tx);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
|
||||
await sleep(75); // wait until transactions are indexed
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { sleep } from "@cosmjs/utils";
|
||||
|
||||
import { coins } from "../coins";
|
||||
import { assertIsPostTxSuccess } from "../cosmosclient";
|
||||
import { assertIsBroadcastTxSuccess } from "../cosmosclient";
|
||||
import { makeSignBytes } from "../encoding";
|
||||
import { Secp256k1Wallet } from "../secp256k1wallet";
|
||||
import { SigningCosmosClient } from "../signingcosmosclient";
|
||||
@ -66,8 +66,8 @@ describe("GovExtension", () => {
|
||||
signatures: [proposalSignature],
|
||||
};
|
||||
|
||||
const proposalResult = await client.postTx(proposalTx);
|
||||
assertIsPostTxSuccess(proposalResult);
|
||||
const proposalResult = await client.broadcastTx(proposalTx);
|
||||
assertIsBroadcastTxSuccess(proposalResult);
|
||||
proposalId = proposalResult.logs[0].events
|
||||
.find(({ type }) => type === "submit_proposal")!
|
||||
.attributes.find(({ key }) => key === "proposal_id")!.value;
|
||||
@ -97,7 +97,7 @@ describe("GovExtension", () => {
|
||||
memo: voteMemo,
|
||||
signatures: [voteSignature],
|
||||
};
|
||||
await client.postTx(voteTx);
|
||||
await client.broadcastTx(voteTx);
|
||||
|
||||
await sleep(75); // wait until transactions are indexed
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ export {
|
||||
BlockResponse,
|
||||
BroadcastMode,
|
||||
EncodeTxResponse,
|
||||
PostTxsResponse,
|
||||
BroadcastTxsResponse,
|
||||
NodeInfoResponse,
|
||||
SearchTxsResponse,
|
||||
TxsResponse,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
|
||||
import { Coin } from "../coins";
|
||||
import { isPostTxFailure } from "../cosmosclient";
|
||||
import { isBroadcastTxFailure } from "../cosmosclient";
|
||||
import { makeSignBytes } from "../encoding";
|
||||
import { parseLogs } from "../logs";
|
||||
import { MsgSend } from "../msgs";
|
||||
@ -248,8 +248,8 @@ describe("LcdClient", () => {
|
||||
signatures: [signature],
|
||||
};
|
||||
const transactionId = await client.getIdentifier({ type: "cosmos-sdk/StdTx", value: signedTx });
|
||||
const result = await client.postTx(signedTx);
|
||||
assert(isPostTxFailure(result));
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
assert(isBroadcastTxFailure(result));
|
||||
unsuccessful = {
|
||||
sender: faucet.address,
|
||||
recipient: recipient,
|
||||
@ -312,7 +312,7 @@ describe("LcdClient", () => {
|
||||
});
|
||||
|
||||
describe("txsQuery", () => {
|
||||
let posted:
|
||||
let broadcasted:
|
||||
| {
|
||||
readonly sender: string;
|
||||
readonly recipient: string;
|
||||
@ -338,7 +338,7 @@ describe("LcdClient", () => {
|
||||
|
||||
await sleep(75); // wait until tx is indexed
|
||||
const txDetails = await new LcdClient(wasmd.endpoint).txById(result.transactionHash);
|
||||
posted = {
|
||||
broadcasted = {
|
||||
sender: faucet.address,
|
||||
recipient: recipient,
|
||||
hash: result.transactionHash,
|
||||
@ -350,68 +350,68 @@ describe("LcdClient", () => {
|
||||
|
||||
it("can query transactions by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const result = await client.txsQuery(`tx.height=${posted.height}&limit=26`);
|
||||
const result = await client.txsQuery(`tx.height=${broadcasted.height}&limit=26`);
|
||||
expect(result).toEqual({
|
||||
count: jasmine.stringMatching(/^(1|2|3|4|5)$/), // 1-5 transactions as string
|
||||
limit: "26",
|
||||
page_number: "1",
|
||||
page_total: "1",
|
||||
total_count: jasmine.stringMatching(/^(1|2|3|4|5)$/), // 1-5 transactions as string
|
||||
txs: jasmine.arrayContaining([posted.tx]),
|
||||
txs: jasmine.arrayContaining([broadcasted.tx]),
|
||||
});
|
||||
});
|
||||
|
||||
it("can query transactions by ID", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const result = await client.txsQuery(`tx.hash=${posted.hash}&limit=26`);
|
||||
const result = await client.txsQuery(`tx.hash=${broadcasted.hash}&limit=26`);
|
||||
expect(result).toEqual({
|
||||
count: "1",
|
||||
limit: "26",
|
||||
page_number: "1",
|
||||
page_total: "1",
|
||||
total_count: "1",
|
||||
txs: [posted.tx],
|
||||
txs: [broadcasted.tx],
|
||||
});
|
||||
});
|
||||
|
||||
it("can query transactions by sender", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const result = await client.txsQuery(`message.sender=${posted.sender}&limit=200`);
|
||||
const result = await client.txsQuery(`message.sender=${broadcasted.sender}&limit=200`);
|
||||
expect(parseInt(result.count, 10)).toBeGreaterThanOrEqual(1);
|
||||
expect(parseInt(result.limit, 10)).toEqual(200);
|
||||
expect(parseInt(result.page_number, 10)).toEqual(1);
|
||||
expect(parseInt(result.page_total, 10)).toEqual(1);
|
||||
expect(parseInt(result.total_count, 10)).toBeGreaterThanOrEqual(1);
|
||||
expect(result.txs.length).toBeGreaterThanOrEqual(1);
|
||||
expect(result.txs[result.txs.length - 1]).toEqual(posted.tx);
|
||||
expect(result.txs[result.txs.length - 1]).toEqual(broadcasted.tx);
|
||||
});
|
||||
|
||||
it("can query transactions by recipient", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const result = await client.txsQuery(`transfer.recipient=${posted.recipient}&limit=200`);
|
||||
const result = await client.txsQuery(`transfer.recipient=${broadcasted.recipient}&limit=200`);
|
||||
expect(parseInt(result.count, 10)).toEqual(1);
|
||||
expect(parseInt(result.limit, 10)).toEqual(200);
|
||||
expect(parseInt(result.page_number, 10)).toEqual(1);
|
||||
expect(parseInt(result.page_total, 10)).toEqual(1);
|
||||
expect(parseInt(result.total_count, 10)).toEqual(1);
|
||||
expect(result.txs.length).toBeGreaterThanOrEqual(1);
|
||||
expect(result.txs[result.txs.length - 1]).toEqual(posted.tx);
|
||||
expect(result.txs[result.txs.length - 1]).toEqual(broadcasted.tx);
|
||||
});
|
||||
|
||||
it("can filter by tx.hash and tx.minheight", async () => {
|
||||
pending("This combination is broken 🤷♂️. Handle client-side at higher level.");
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const hashQuery = `tx.hash=${posted.hash}`;
|
||||
const hashQuery = `tx.hash=${broadcasted.hash}`;
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=0`);
|
||||
@ -419,26 +419,26 @@ describe("LcdClient", () => {
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=${posted.height - 1}`);
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=${broadcasted.height - 1}`);
|
||||
expect(count).toEqual("1");
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=${posted.height}`);
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=${broadcasted.height}`);
|
||||
expect(count).toEqual("1");
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=${posted.height + 1}`);
|
||||
const { count } = await client.txsQuery(`${hashQuery}&tx.minheight=${broadcasted.height + 1}`);
|
||||
expect(count).toEqual("0");
|
||||
}
|
||||
});
|
||||
|
||||
it("can filter by recipient and tx.minheight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const recipientQuery = `transfer.recipient=${posted.recipient}`;
|
||||
const recipientQuery = `transfer.recipient=${broadcasted.recipient}`;
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=0`);
|
||||
@ -446,26 +446,26 @@ describe("LcdClient", () => {
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=${posted.height - 1}`);
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=${broadcasted.height - 1}`);
|
||||
expect(count).toEqual("1");
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=${posted.height}`);
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=${broadcasted.height}`);
|
||||
expect(count).toEqual("1");
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=${posted.height + 1}`);
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.minheight=${broadcasted.height + 1}`);
|
||||
expect(count).toEqual("0");
|
||||
}
|
||||
});
|
||||
|
||||
it("can filter by recipient and tx.maxheight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
assert(broadcasted);
|
||||
const client = new LcdClient(wasmd.endpoint);
|
||||
const recipientQuery = `transfer.recipient=${posted.recipient}`;
|
||||
const recipientQuery = `transfer.recipient=${broadcasted.recipient}`;
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=9999999999999`);
|
||||
@ -473,17 +473,17 @@ describe("LcdClient", () => {
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=${posted.height + 1}`);
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=${broadcasted.height + 1}`);
|
||||
expect(count).toEqual("1");
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=${posted.height}`);
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=${broadcasted.height}`);
|
||||
expect(count).toEqual("1");
|
||||
}
|
||||
|
||||
{
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=${posted.height - 1}`);
|
||||
const { count } = await client.txsQuery(`${recipientQuery}&tx.maxheight=${broadcasted.height - 1}`);
|
||||
expect(count).toEqual("0");
|
||||
}
|
||||
});
|
||||
@ -502,7 +502,7 @@ describe("LcdClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("postTx", () => {
|
||||
describe("broadcastTx", () => {
|
||||
it("can send tokens", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic);
|
||||
@ -540,7 +540,7 @@ describe("LcdClient", () => {
|
||||
const signBytes = makeSignBytes([theMsg], fee, wasmd.chainId, memo, account_number, sequence);
|
||||
const signature = await wallet.sign(walletAddress, signBytes);
|
||||
const signedTx = makeSignedTx(theMsg, fee, memo, signature);
|
||||
const result = await client.postTx(signedTx);
|
||||
const result = await client.broadcastTx(signedTx);
|
||||
expect(result.code).toBeUndefined();
|
||||
expect(result).toEqual({
|
||||
height: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
@ -606,9 +606,9 @@ describe("LcdClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature1, signature2, signature3],
|
||||
};
|
||||
const postResult = await client.postTx(signedTx);
|
||||
expect(postResult.code).toEqual(4);
|
||||
expect(postResult.raw_log).toContain("wrong number of signers");
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
expect(broadcastResult.code).toEqual(4);
|
||||
expect(broadcastResult.raw_log).toContain("wrong number of signers");
|
||||
});
|
||||
|
||||
it("can send multiple messages with one signature", async () => {
|
||||
@ -666,8 +666,8 @@ describe("LcdClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature1],
|
||||
};
|
||||
const postResult = await client.postTx(signedTx);
|
||||
expect(postResult.code).toBeUndefined();
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
expect(broadcastResult.code).toBeUndefined();
|
||||
});
|
||||
|
||||
it("can send multiple messages with multiple signatures", async () => {
|
||||
@ -732,11 +732,11 @@ describe("LcdClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature2, signature1],
|
||||
};
|
||||
const postResult = await client.postTx(signedTx);
|
||||
expect(postResult.code).toBeUndefined();
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
expect(broadcastResult.code).toBeUndefined();
|
||||
|
||||
await sleep(500);
|
||||
const searched = await client.txsQuery(`tx.hash=${postResult.txhash}`);
|
||||
const searched = await client.txsQuery(`tx.hash=${broadcastResult.txhash}`);
|
||||
expect(searched.txs.length).toEqual(1);
|
||||
expect(searched.txs[0].tx.value.signatures).toEqual([signature2, signature1]);
|
||||
});
|
||||
@ -803,8 +803,8 @@ describe("LcdClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature2, signature1],
|
||||
};
|
||||
const postResult = await client.postTx(signedTx);
|
||||
expect(postResult.code).toEqual(8);
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
expect(broadcastResult.code).toEqual(8);
|
||||
});
|
||||
|
||||
it("can't send transaction with wrong signature order (2)", async () => {
|
||||
@ -869,8 +869,8 @@ describe("LcdClient", () => {
|
||||
memo: memo,
|
||||
signatures: [signature1, signature2],
|
||||
};
|
||||
const postResult = await client.postTx(signedTx);
|
||||
expect(postResult.code).toEqual(8);
|
||||
const broadcastResult = await client.broadcastTx(signedTx);
|
||||
expect(broadcastResult.code).toEqual(8);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,9 +6,9 @@ import { CosmosSdkTx, StdTx } from "../types";
|
||||
import {
|
||||
BlockResponse,
|
||||
BroadcastMode,
|
||||
BroadcastTxsResponse,
|
||||
EncodeTxResponse,
|
||||
NodeInfoResponse,
|
||||
PostTxsResponse,
|
||||
SearchTxsResponse,
|
||||
TxsResponse,
|
||||
} from "./base";
|
||||
@ -206,7 +206,7 @@ export class LcdClient {
|
||||
* in higher level components. Feel free to raise an issue in this case.
|
||||
*
|
||||
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
public constructor(apiUrl: string, broadcastMode = BroadcastMode.Block) {
|
||||
const headers = {
|
||||
@ -298,7 +298,7 @@ export class LcdClient {
|
||||
*
|
||||
* @param tx a signed transaction as StdTx (i.e. not wrapped in type/value container)
|
||||
*/
|
||||
public async postTx(tx: StdTx): Promise<PostTxsResponse> {
|
||||
public async broadcastTx(tx: StdTx): Promise<BroadcastTxsResponse> {
|
||||
const params = {
|
||||
tx: tx,
|
||||
mode: this.broadcastMode,
|
||||
@ -307,6 +307,6 @@ export class LcdClient {
|
||||
if (!responseData.txhash) {
|
||||
throw new Error("Unexpected response data format");
|
||||
}
|
||||
return responseData as PostTxsResponse;
|
||||
return responseData as BroadcastTxsResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
|
||||
import { coin, coins } from "../coins";
|
||||
import { assertIsPostTxSuccess } from "../cosmosclient";
|
||||
import { assertIsBroadcastTxSuccess } from "../cosmosclient";
|
||||
import { makeSignBytes } from "../encoding";
|
||||
import { MsgDelegate, MsgUndelegate } from "../msgs";
|
||||
import { Secp256k1Wallet } from "../secp256k1wallet";
|
||||
@ -57,8 +57,8 @@ describe("StakingExtension", () => {
|
||||
signatures: [signature],
|
||||
};
|
||||
|
||||
const result = await client.postTx(tx);
|
||||
assertIsPostTxSuccess(result);
|
||||
const result = await client.broadcastTx(tx);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
}
|
||||
{
|
||||
const msg: MsgUndelegate = {
|
||||
@ -80,8 +80,8 @@ describe("StakingExtension", () => {
|
||||
signatures: [signature],
|
||||
};
|
||||
|
||||
const result = await client.postTx(tx);
|
||||
assertIsPostTxSuccess(result);
|
||||
const result = await client.broadcastTx(tx);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
}
|
||||
|
||||
await sleep(75); // wait until transactions are indexed
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { assert } from "@cosmjs/utils";
|
||||
|
||||
import { Coin, coin, coins } from "./coins";
|
||||
import { assertIsPostTxSuccess, PrivateCosmWasmClient } from "./cosmosclient";
|
||||
import { assertIsBroadcastTxSuccess, PrivateCosmWasmClient } from "./cosmosclient";
|
||||
import { MsgDelegate } from "./msgs";
|
||||
import { Secp256k1Wallet } from "./secp256k1wallet";
|
||||
import { SigningCosmosClient } from "./signingcosmosclient";
|
||||
@ -68,7 +68,7 @@ describe("SigningCosmosClient", () => {
|
||||
|
||||
// send
|
||||
const result = await client.sendTokens(beneficiaryAddress, transferAmount, "for dinner");
|
||||
assertIsPostTxSuccess(result);
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
const [firstLog] = result.logs;
|
||||
expect(firstLog).toBeTruthy();
|
||||
|
||||
@ -79,7 +79,7 @@ describe("SigningCosmosClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("signAndPost", () => {
|
||||
describe("signAndBroadcast", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic);
|
||||
@ -97,8 +97,8 @@ describe("SigningCosmosClient", () => {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "180000", // 180k
|
||||
};
|
||||
const result = await client.signAndPost([msg], fee, "Use your power wisely");
|
||||
assertIsPostTxSuccess(result);
|
||||
const result = await client.signAndBroadcast([msg], fee, "Use your power wisely");
|
||||
assertIsBroadcastTxSuccess(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Coin, coins } from "./coins";
|
||||
import { Account, CosmosClient, GetSequenceResult, PostTxResult } from "./cosmosclient";
|
||||
import { Account, BroadcastTxResult, CosmosClient, GetSequenceResult } from "./cosmosclient";
|
||||
import { makeSignBytes } from "./encoding";
|
||||
import { BroadcastMode } from "./lcdapi";
|
||||
import { Msg, MsgSend } from "./msgs";
|
||||
@ -28,7 +28,7 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
private readonly fees: FeeTable;
|
||||
|
||||
/**
|
||||
* Creates a new client with signing capability to interact with a CosmWasm blockchain. This is the bigger brother of CosmWasmClient.
|
||||
* Creates a new client with signing capability to interact with a Cosmos SDK blockchain. This is the bigger brother of CosmosClient.
|
||||
*
|
||||
* This instance does a lot of caching. In order to benefit from that you should try to use one instance
|
||||
* for the lifetime of your application. When switching backends, a new instance must be created.
|
||||
@ -37,7 +37,7 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
* @param senderAddress The address that will sign and send transactions using this instance
|
||||
* @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input.
|
||||
* @param customFees The fees that are paid for transactions
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
public constructor(
|
||||
apiUrl: string,
|
||||
@ -66,7 +66,7 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<PostTxResult> {
|
||||
): Promise<BroadcastTxResult> {
|
||||
const sendMsg: MsgSend = {
|
||||
type: "cosmos-sdk/MsgSend",
|
||||
value: {
|
||||
@ -75,14 +75,14 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
amount: transferAmount,
|
||||
},
|
||||
};
|
||||
return this.signAndPost([sendMsg], this.fees.send, memo);
|
||||
return this.signAndBroadcast([sendMsg], this.fees.send, memo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets account number and sequence from the API, creates a sign doc,
|
||||
* creates a single signature, assembles the signed transaction and broadcasts it.
|
||||
*/
|
||||
public async signAndPost(msgs: readonly Msg[], fee: StdFee, memo = ""): Promise<PostTxResult> {
|
||||
public async signAndBroadcast(msgs: readonly Msg[], fee: StdFee, memo = ""): Promise<BroadcastTxResult> {
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes(msgs, fee, chainId, memo, accountNumber, sequence);
|
||||
@ -93,6 +93,6 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
memo: memo,
|
||||
signatures: [signature],
|
||||
};
|
||||
return this.postTx(signedTx);
|
||||
return this.broadcastTx(signedTx);
|
||||
}
|
||||
}
|
||||
|
||||
18
packages/launchpad/types/cosmosclient.d.ts
vendored
18
packages/launchpad/types/cosmosclient.d.ts
vendored
@ -14,27 +14,29 @@ export interface Account {
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
}
|
||||
export interface PostTxFailure {
|
||||
export interface BroadcastTxFailure {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly height: number;
|
||||
readonly code: number;
|
||||
readonly rawLog: string;
|
||||
}
|
||||
export interface PostTxSuccess {
|
||||
export interface BroadcastTxSuccess {
|
||||
readonly logs: readonly Log[];
|
||||
readonly rawLog: string;
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly data?: Uint8Array;
|
||||
}
|
||||
export declare type PostTxResult = PostTxSuccess | PostTxFailure;
|
||||
export declare function isPostTxFailure(result: PostTxResult): result is PostTxFailure;
|
||||
export declare function isPostTxSuccess(result: PostTxResult): result is PostTxSuccess;
|
||||
export declare type BroadcastTxResult = BroadcastTxSuccess | BroadcastTxFailure;
|
||||
export declare function isBroadcastTxFailure(result: BroadcastTxResult): result is BroadcastTxFailure;
|
||||
export declare function isBroadcastTxSuccess(result: BroadcastTxResult): result is BroadcastTxSuccess;
|
||||
/**
|
||||
* Ensures the given result is a success. Throws a detailed error message otherwise.
|
||||
*/
|
||||
export declare function assertIsPostTxSuccess(result: PostTxResult): asserts result is PostTxSuccess;
|
||||
export declare function assertIsBroadcastTxSuccess(
|
||||
result: BroadcastTxResult,
|
||||
): asserts result is BroadcastTxSuccess;
|
||||
export interface SearchByIdQuery {
|
||||
readonly id: string;
|
||||
}
|
||||
@ -113,7 +115,7 @@ export declare class CosmosClient {
|
||||
* for the lifetime of your application. When switching backends, a new instance must be created.
|
||||
*
|
||||
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
constructor(apiUrl: string, broadcastMode?: BroadcastMode);
|
||||
getChainId(): Promise<string>;
|
||||
@ -138,6 +140,6 @@ export declare class CosmosClient {
|
||||
*/
|
||||
getBlock(height?: number): Promise<Block>;
|
||||
searchTx(query: SearchTxQuery, filter?: SearchTxFilter): Promise<readonly IndexedTx[]>;
|
||||
postTx(tx: StdTx): Promise<PostTxResult>;
|
||||
broadcastTx(tx: StdTx): Promise<BroadcastTxResult>;
|
||||
private txsQuery;
|
||||
}
|
||||
|
||||
14
packages/launchpad/types/index.d.ts
vendored
14
packages/launchpad/types/index.d.ts
vendored
@ -4,17 +4,17 @@ export { pubkeyToAddress, rawSecp256k1PubkeyToAddress } from "./address";
|
||||
export { Coin, coin, coins } from "./coins";
|
||||
export {
|
||||
Account,
|
||||
assertIsPostTxSuccess,
|
||||
assertIsBroadcastTxSuccess,
|
||||
Block,
|
||||
BlockHeader,
|
||||
CosmosClient,
|
||||
GetSequenceResult,
|
||||
IndexedTx,
|
||||
isPostTxFailure,
|
||||
isPostTxSuccess,
|
||||
PostTxFailure,
|
||||
PostTxResult,
|
||||
PostTxSuccess,
|
||||
isBroadcastTxFailure,
|
||||
isBroadcastTxSuccess,
|
||||
BroadcastTxFailure,
|
||||
BroadcastTxResult,
|
||||
BroadcastTxSuccess,
|
||||
SearchByHeightQuery,
|
||||
SearchByIdQuery,
|
||||
SearchBySentFromOrToQuery,
|
||||
@ -60,7 +60,7 @@ export {
|
||||
NodeInfoResponse,
|
||||
normalizeLcdApiArray,
|
||||
normalizePubkey,
|
||||
PostTxsResponse,
|
||||
BroadcastTxsResponse,
|
||||
SearchTxsResponse,
|
||||
setupAuthExtension,
|
||||
setupBankExtension,
|
||||
|
||||
2
packages/launchpad/types/lcdapi/base.d.ts
vendored
2
packages/launchpad/types/lcdapi/base.d.ts
vendored
@ -108,7 +108,7 @@ export interface SearchTxsResponse {
|
||||
readonly limit: string;
|
||||
readonly txs: readonly TxsResponse[];
|
||||
}
|
||||
export interface PostTxsResponse {
|
||||
export interface BroadcastTxsResponse {
|
||||
readonly height: string;
|
||||
readonly txhash: string;
|
||||
readonly code?: number;
|
||||
|
||||
2
packages/launchpad/types/lcdapi/index.d.ts
vendored
2
packages/launchpad/types/lcdapi/index.d.ts
vendored
@ -62,7 +62,7 @@ export {
|
||||
BlockResponse,
|
||||
BroadcastMode,
|
||||
EncodeTxResponse,
|
||||
PostTxsResponse,
|
||||
BroadcastTxsResponse,
|
||||
NodeInfoResponse,
|
||||
SearchTxsResponse,
|
||||
TxsResponse,
|
||||
|
||||
@ -2,9 +2,9 @@ import { CosmosSdkTx, StdTx } from "../types";
|
||||
import {
|
||||
BlockResponse,
|
||||
BroadcastMode,
|
||||
BroadcastTxsResponse,
|
||||
EncodeTxResponse,
|
||||
NodeInfoResponse,
|
||||
PostTxsResponse,
|
||||
SearchTxsResponse,
|
||||
TxsResponse,
|
||||
} from "./base";
|
||||
@ -140,7 +140,7 @@ export declare class LcdClient {
|
||||
* in higher level components. Feel free to raise an issue in this case.
|
||||
*
|
||||
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
constructor(apiUrl: string, broadcastMode?: BroadcastMode);
|
||||
get(path: string, params?: Record<string, any>): Promise<any>;
|
||||
@ -159,6 +159,6 @@ export declare class LcdClient {
|
||||
*
|
||||
* @param tx a signed transaction as StdTx (i.e. not wrapped in type/value container)
|
||||
*/
|
||||
postTx(tx: StdTx): Promise<PostTxsResponse>;
|
||||
broadcastTx(tx: StdTx): Promise<BroadcastTxsResponse>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Coin } from "./coins";
|
||||
import { Account, CosmosClient, GetSequenceResult, PostTxResult } from "./cosmosclient";
|
||||
import { Account, BroadcastTxResult, CosmosClient, GetSequenceResult } from "./cosmosclient";
|
||||
import { BroadcastMode } from "./lcdapi";
|
||||
import { Msg } from "./msgs";
|
||||
import { StdFee } from "./types";
|
||||
@ -15,7 +15,7 @@ export declare class SigningCosmosClient extends CosmosClient {
|
||||
private readonly signer;
|
||||
private readonly fees;
|
||||
/**
|
||||
* Creates a new client with signing capability to interact with a CosmWasm blockchain. This is the bigger brother of CosmWasmClient.
|
||||
* Creates a new client with signing capability to interact with a Cosmos SDK blockchain. This is the bigger brother of CosmosClient.
|
||||
*
|
||||
* This instance does a lot of caching. In order to benefit from that you should try to use one instance
|
||||
* for the lifetime of your application. When switching backends, a new instance must be created.
|
||||
@ -24,7 +24,7 @@ export declare class SigningCosmosClient extends CosmosClient {
|
||||
* @param senderAddress The address that will sign and send transactions using this instance
|
||||
* @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input.
|
||||
* @param customFees The fees that are paid for transactions
|
||||
* @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns
|
||||
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
|
||||
*/
|
||||
constructor(
|
||||
apiUrl: string,
|
||||
@ -35,10 +35,14 @@ export declare class SigningCosmosClient extends CosmosClient {
|
||||
);
|
||||
getSequence(address?: string): Promise<GetSequenceResult>;
|
||||
getAccount(address?: string): Promise<Account | undefined>;
|
||||
sendTokens(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<PostTxResult>;
|
||||
sendTokens(
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
memo?: string,
|
||||
): Promise<BroadcastTxResult>;
|
||||
/**
|
||||
* Gets account number and sequence from the API, creates a sign doc,
|
||||
* creates a single signature, assembles the signed transaction and broadcasts it.
|
||||
*/
|
||||
signAndPost(msgs: readonly Msg[], fee: StdFee, memo?: string): Promise<PostTxResult>;
|
||||
signAndBroadcast(msgs: readonly Msg[], fee: StdFee, memo?: string): Promise<BroadcastTxResult>;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, adaptor: Adaptor): void {
|
||||
client.disconnect();
|
||||
});
|
||||
|
||||
it("can post a transaction", async () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = new Client(rpcFactory(), adaptor);
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
@ -3,7 +3,12 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
const { Random } = require("@cosmjs/crypto");
|
||||
const { Bech32 } = require("@cosmjs/encoding");
|
||||
const { coins, Secp256k1Wallet, SigningCosmosClient, assertIsPostTxSuccess } = require("@cosmjs/launchpad");
|
||||
const {
|
||||
coins,
|
||||
Secp256k1Wallet,
|
||||
SigningCosmosClient,
|
||||
assertIsBroadcastTxSuccess,
|
||||
} = require("@cosmjs/launchpad");
|
||||
|
||||
const httpUrl = "http://localhost:1317";
|
||||
const faucet = {
|
||||
@ -19,7 +24,7 @@ async function main() {
|
||||
const amount = coins(226644, "ucosm");
|
||||
const memo = "Ensure chain has my pubkey";
|
||||
const sendResult = await client.sendTokens(recipient, amount, memo);
|
||||
assertIsPostTxSuccess(sendResult);
|
||||
assertIsBroadcastTxSuccess(sendResult);
|
||||
}
|
||||
|
||||
main().then(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user