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
[#928]: https://github.com/cosmos/cosmjs/issues/928
## [0.26.5] - 2021-11-20
### Added
- @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
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
### 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.
- @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.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

View File

@ -1,6 +1,6 @@
{
"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.",
"contributors": [
"Simon Warta <webmaster128@users.noreply.github.com>"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"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)",
"contributors": [
"Ethan Frey <ethanfrey@users.noreply.github.com>",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@cosmjs/tendermint-rpc",
"version": "0.26.4",
"version": "0.26.5",
"description": "Tendermint RPC clients",
"contributors": [
"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[] {
return assertArray(events).map(decodeEvent);
function decodeEvents(events: readonly RpcEvent[] | undefined): readonly responses.Event[] {
return assertArray(events ?? []).map(decodeEvent);
}
interface RpcTxData {
@ -130,7 +130,7 @@ interface RpcTxData {
readonly log?: string;
/** base64 encoded */
readonly data?: string;
readonly events: readonly RpcEvent[];
readonly events?: readonly RpcEvent[];
}
function decodeTxData(data: RpcTxData): responses.TxData {
@ -787,7 +787,7 @@ export class Responses {
}
public static decodeBroadcastTxAsync(response: JsonRpcSuccessResponse): responses.BroadcastTxAsyncResponse {
return this.decodeBroadcastTxSync(response);
return Responses.decodeBroadcastTxSync(response);
}
public static decodeBroadcastTxCommit(

View File

@ -47,22 +47,53 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
client.disconnect();
});
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint33Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
describe("broadcastTxCommit", () => {
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint33Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.height).toBeGreaterThan(2);
expect(response.hash).toBeTruthy();
// verify success
expect(response.checkTx.code).toBeFalsy();
expect(response.deliverTx).toBeTruthy();
if (response.deliverTx) {
expect(response.deliverTx.code).toBeFalsy();
}
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.height).toBeGreaterThan(2);
expect(response.hash).toBeTruthy();
// verify success
expect(response.checkTx.code).toBeFalsy();
expect(response.deliverTx).toBeTruthy();
if (response.deliverTx) {
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 () => {

View File

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

View File

@ -47,22 +47,54 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
client.disconnect();
});
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint34Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
describe("broadcastTxCommit", () => {
it("can broadcast a transaction", async () => {
pendingWithoutTendermint();
const client = await Tendermint34Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.height).toBeGreaterThan(2);
expect(response.hash).toBeTruthy();
// verify success
expect(response.checkTx.code).toBeFalsy();
expect(response.deliverTx).toBeTruthy();
if (response.deliverTx) {
expect(response.deliverTx.code).toBeFalsy();
}
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.height).toBeGreaterThan(2);
expect(response.hash).toBeTruthy();
// verify success
expect(response.checkTx.code).toBeFalsy();
expect(response.deliverTx).toBeTruthy();
if (response.deliverTx) {
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 () => {

View File

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