Merge branch '0.26'

This commit is contained in:
Simon Warta 2021-11-22 18:58:32 +01:00
commit 8ac88b7f74
22 changed files with 124 additions and 51 deletions

View File

@ -24,12 +24,21 @@ and this project adheres to
[#897]: https://github.com/cosmos/cosmjs/issues/897 [#897]: https://github.com/cosmos/cosmjs/issues/897
[#928]: https://github.com/cosmos/cosmjs/issues/928 [#928]: https://github.com/cosmos/cosmjs/issues/928
## [0.26.5] - 2021-11-20
### Added ### Added
- @cosmjs/amino: The `coin` and `coins` helpers now support both `number` and - @cosmjs/amino: The `coin` and `coins` helpers now support both `number` and
`string` as input types for the amount. This is useful if your values exceed `string` as input types for the amount. This is useful if your values exceed
the safe integer range. the safe integer range.
### Fixed
- @cosmjs/tendermint-rpc: Fix undefined `this` in `decodeBroadcastTxAsync` and
`broadcastTxAsync` ([#937]).
[#937]: https://github.com/cosmos/cosmjs/pull/937
## [0.26.4] - 2021-10-28 ## [0.26.4] - 2021-10-28
### Fixed ### Fixed
@ -648,7 +657,8 @@ CHANGELOG entries missing. Please see [the diff][0.24.1].
`FeeTable`. @cosmjs/cosmwasm has its own `FeeTable` with those properties. `FeeTable`. @cosmjs/cosmwasm has its own `FeeTable` with those properties.
- @cosmjs/sdk38: Rename package to @cosmjs/launchpad. - @cosmjs/sdk38: Rename package to @cosmjs/launchpad.
[unreleased]: https://github.com/cosmos/cosmjs/compare/v0.26.4...HEAD [unreleased]: https://github.com/cosmos/cosmjs/compare/v0.26.5...HEAD
[0.26.5]: https://github.com/cosmos/cosmjs/compare/v0.26.4...v0.26.5
[0.26.4]: https://github.com/cosmos/cosmjs/compare/v0.26.3...v0.26.4 [0.26.4]: https://github.com/cosmos/cosmjs/compare/v0.26.3...v0.26.4
[0.26.3]: https://github.com/cosmos/cosmjs/compare/v0.26.2...v0.26.3 [0.26.3]: https://github.com/cosmos/cosmjs/compare/v0.26.2...v0.26.3
[0.26.2]: https://github.com/cosmos/cosmjs/compare/v0.26.1...v0.26.2 [0.26.2]: https://github.com/cosmos/cosmjs/compare/v0.26.1...v0.26.2

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/amino", "name": "@cosmjs/amino",
"version": "0.26.4", "version": "0.26.5",
"description": "Helpers for Amino based signing which are shared between @cosmjs/launchpad and @cosmjs/stargate.", "description": "Helpers for Amino based signing which are shared between @cosmjs/launchpad and @cosmjs/stargate.",
"contributors": [ "contributors": [
"Simon Warta <webmaster128@users.noreply.github.com>" "Simon Warta <webmaster128@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/cli", "name": "@cosmjs/cli",
"version": "0.26.4", "version": "0.26.5",
"description": "Command line interface", "description": "Command line interface",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/cosmwasm-stargate", "name": "@cosmjs/cosmwasm-stargate",
"version": "0.26.4", "version": "0.26.5",
"description": "CosmWasm SDK", "description": "CosmWasm SDK",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>" "Will Clark <willclarktech@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/crypto", "name": "@cosmjs/crypto",
"version": "0.26.4", "version": "0.26.5",
"description": "Cryptography resources for blockchain projects", "description": "Cryptography resources for blockchain projects",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/encoding", "name": "@cosmjs/encoding",
"version": "0.26.4", "version": "0.26.5",
"description": "Encoding helpers for blockchain projects", "description": "Encoding helpers for blockchain projects",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>" "IOV SAS <admin@iov.one>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/faucet-client", "name": "@cosmjs/faucet-client",
"version": "0.26.4", "version": "0.26.5",
"description": "The faucet client", "description": "The faucet client",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>" "Will Clark <willclarktech@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/faucet", "name": "@cosmjs/faucet",
"version": "0.26.4", "version": "0.26.5",
"description": "The faucet", "description": "The faucet",
"contributors": [ "contributors": [
"Ethan Frey <ethanfrey@users.noreply.github.com>", "Ethan Frey <ethanfrey@users.noreply.github.com>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/json-rpc", "name": "@cosmjs/json-rpc",
"version": "0.26.4", "version": "0.26.5",
"description": "Framework for implementing a JSON-RPC 2.0 API", "description": "Framework for implementing a JSON-RPC 2.0 API",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/launchpad", "name": "@cosmjs/launchpad",
"version": "0.26.4", "version": "0.26.5",
"description": "A client library for the Cosmos SDK 0.37 (cosmoshub-3), 0.38 and 0.39 (Launchpad)", "description": "A client library for the Cosmos SDK 0.37 (cosmoshub-3), 0.38 and 0.39 (Launchpad)",
"contributors": [ "contributors": [
"Ethan Frey <ethanfrey@users.noreply.github.com>", "Ethan Frey <ethanfrey@users.noreply.github.com>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/ledger-amino", "name": "@cosmjs/ledger-amino",
"version": "0.26.4", "version": "0.26.5",
"description": "A library for signing Amino-encoded transactions using Ledger devices", "description": "A library for signing Amino-encoded transactions using Ledger devices",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>" "Will Clark <willclarktech@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/math", "name": "@cosmjs/math",
"version": "0.26.4", "version": "0.26.5",
"description": "Math helpers for blockchain projects", "description": "Math helpers for blockchain projects",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>" "IOV SAS <admin@iov.one>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/proto-signing", "name": "@cosmjs/proto-signing",
"version": "0.26.4", "version": "0.26.5",
"description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)", "description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>", "Will Clark <willclarktech@users.noreply.github.com>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/socket", "name": "@cosmjs/socket",
"version": "0.26.4", "version": "0.26.5",
"description": "Utility functions for working with WebSockets", "description": "Utility functions for working with WebSockets",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/stargate", "name": "@cosmjs/stargate",
"version": "0.26.4", "version": "0.26.5",
"description": "Utilities for Cosmos SDK 0.40", "description": "Utilities for Cosmos SDK 0.40",
"contributors": [ "contributors": [
"Simon Warta <webmaster128@users.noreply.github.com>" "Simon Warta <webmaster128@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/stream", "name": "@cosmjs/stream",
"version": "0.26.4", "version": "0.26.5",
"description": "Utility functions for producing and consuming streams", "description": "Utility functions for producing and consuming streams",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/tendermint-rpc", "name": "@cosmjs/tendermint-rpc",
"version": "0.26.4", "version": "0.26.5",
"description": "Tendermint RPC clients", "description": "Tendermint RPC clients",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -121,8 +121,8 @@ function decodeEvent(event: RpcEvent): responses.Event {
}; };
} }
function decodeEvents(events: readonly RpcEvent[]): readonly responses.Event[] { function decodeEvents(events: readonly RpcEvent[] | undefined): readonly responses.Event[] {
return assertArray(events).map(decodeEvent); return assertArray(events ?? []).map(decodeEvent);
} }
interface RpcTxData { interface RpcTxData {
@ -130,7 +130,7 @@ interface RpcTxData {
readonly log?: string; readonly log?: string;
/** base64 encoded */ /** base64 encoded */
readonly data?: string; readonly data?: string;
readonly events: readonly RpcEvent[]; readonly events?: readonly RpcEvent[];
} }
function decodeTxData(data: RpcTxData): responses.TxData { function decodeTxData(data: RpcTxData): responses.TxData {
@ -787,7 +787,7 @@ export class Responses {
} }
public static decodeBroadcastTxAsync(response: JsonRpcSuccessResponse): responses.BroadcastTxAsyncResponse { public static decodeBroadcastTxAsync(response: JsonRpcSuccessResponse): responses.BroadcastTxAsyncResponse {
return this.decodeBroadcastTxSync(response); return Responses.decodeBroadcastTxSync(response);
} }
public static decodeBroadcastTxCommit( public static decodeBroadcastTxCommit(

View File

@ -47,22 +47,53 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
client.disconnect(); client.disconnect();
}); });
it("can broadcast a transaction", async () => { describe("broadcastTxCommit", () => {
pendingWithoutTendermint(); it("can broadcast a transaction", async () => {
const client = await Tendermint33Client.create(rpcFactory()); pendingWithoutTendermint();
const tx = buildKvTx(randomString(), randomString()); const client = await Tendermint33Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxCommit({ tx: tx }); const response = await client.broadcastTxCommit({ tx: tx });
expect(response.height).toBeGreaterThan(2); expect(response.height).toBeGreaterThan(2);
expect(response.hash).toBeTruthy(); expect(response.hash).toBeTruthy();
// verify success // verify success
expect(response.checkTx.code).toBeFalsy(); expect(response.checkTx.code).toBeFalsy();
expect(response.deliverTx).toBeTruthy(); expect(response.deliverTx).toBeTruthy();
if (response.deliverTx) { if (response.deliverTx) {
expect(response.deliverTx.code).toBeFalsy(); expect(response.deliverTx.code).toBeFalsy();
} }
client.disconnect(); client.disconnect();
});
});
describe("broadcastTxSync", () => {
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint33Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxSync({ tx: tx });
expect(response.hash.length).toEqual(32);
// verify success
expect(response.code).toBeFalsy();
client.disconnect();
});
});
describe("broadcastTxAsync", () => {
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint33Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxAsync({ tx: tx });
// TODO: Remove any cast after https://github.com/cosmos/cosmjs/issues/938
expect((response as any).hash.length).toEqual(32);
client.disconnect();
});
}); });
it("gets the same tx hash from backend as calculated locally", async () => { it("gets the same tx hash from backend as calculated locally", async () => {

View File

@ -829,7 +829,7 @@ export class Responses {
} }
public static decodeBroadcastTxAsync(response: JsonRpcSuccessResponse): responses.BroadcastTxAsyncResponse { public static decodeBroadcastTxAsync(response: JsonRpcSuccessResponse): responses.BroadcastTxAsyncResponse {
return this.decodeBroadcastTxSync(response); return Responses.decodeBroadcastTxSync(response);
} }
public static decodeBroadcastTxCommit( public static decodeBroadcastTxCommit(

View File

@ -47,22 +47,54 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
client.disconnect(); client.disconnect();
}); });
it("can broadcast a transaction", async () => { describe("broadcastTxCommit", () => {
pendingWithoutTendermint(); it("can broadcast a transaction", async () => {
const client = await Tendermint34Client.create(rpcFactory()); pendingWithoutTendermint();
const tx = buildKvTx(randomString(), randomString()); const client = await Tendermint34Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxCommit({ tx: tx }); const response = await client.broadcastTxCommit({ tx: tx });
expect(response.height).toBeGreaterThan(2); expect(response.height).toBeGreaterThan(2);
expect(response.hash).toBeTruthy(); expect(response.hash).toBeTruthy();
// verify success // verify success
expect(response.checkTx.code).toBeFalsy(); expect(response.checkTx.code).toBeFalsy();
expect(response.deliverTx).toBeTruthy(); expect(response.deliverTx).toBeTruthy();
if (response.deliverTx) { if (response.deliverTx) {
expect(response.deliverTx.code).toBeFalsy(); expect(response.deliverTx.code).toBeFalsy();
} }
client.disconnect(); client.disconnect();
});
});
describe("broadcastTxSync", () => {
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint34Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxSync({ tx: tx });
expect(response.hash.length).toEqual(32);
// verify success
expect(response.code).toBeFalsy();
expect(response.codeSpace).toBeFalsy();
client.disconnect();
});
});
describe("broadcastTxAsync", () => {
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint34Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxAsync({ tx: tx });
// TODO: Remove any cast after https://github.com/cosmos/cosmjs/issues/938
expect((response as any).hash.length).toEqual(32);
client.disconnect();
});
}); });
it("gets the same tx hash from backend as calculated locally", async () => { it("gets the same tx hash from backend as calculated locally", async () => {

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/utils", "name": "@cosmjs/utils",
"version": "0.26.4", "version": "0.26.5",
"description": "Utility tools, primarily for testing code", "description": "Utility tools, primarily for testing code",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>" "IOV SAS <admin@iov.one>"