Socket
Socket
Sign inDemoInstall

@cosmjs/tendermint-rpc

Package Overview
Dependencies
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmjs/tendermint-rpc - npm Package Compare versions

Comparing version 0.26.6 to 0.26.8

build/tendermint34/adaptor/responses.spec.d.ts

6

build/addresses.js

@@ -10,3 +10,3 @@ "use strict";

}
return crypto_1.sha256(pubkeyData).slice(0, 20);
return (0, crypto_1.sha256)(pubkeyData).slice(0, 20);
}

@@ -18,3 +18,3 @@ exports.rawEd25519PubkeyToRawAddress = rawEd25519PubkeyToRawAddress;

}
return crypto_1.ripemd160(crypto_1.sha256(pubkeyData));
return (0, crypto_1.ripemd160)((0, crypto_1.sha256)(pubkeyData));
}

@@ -36,5 +36,5 @@ exports.rawSecp256k1PubkeyToRawAddress = rawSecp256k1PubkeyToRawAddress;

function pubkeyToAddress(type, data) {
return encoding_1.toHex(pubkeyToRawAddress(type, data)).toUpperCase();
return (0, encoding_1.toHex)(pubkeyToRawAddress(type, data)).toUpperCase();
}
exports.pubkeyToAddress = pubkeyToAddress;
//# sourceMappingURL=addresses.js.map

@@ -9,8 +9,8 @@ "use strict";

it("works for Secp256k1", () => {
const pubkey = encoding_1.fromHex("02950E1CDFCB133D6024109FD489F734EEB4502418E538C28481F22BCE276F248C");
expect(addresses_1.pubkeyToRawAddress("secp256k1", pubkey)).toEqual(encoding_1.fromHex("7C2BB42A8BE69791EC763E51F5A49BCD41E82237"));
const pubkey = (0, encoding_1.fromHex)("02950E1CDFCB133D6024109FD489F734EEB4502418E538C28481F22BCE276F248C");
expect((0, addresses_1.pubkeyToRawAddress)("secp256k1", pubkey)).toEqual((0, encoding_1.fromHex)("7C2BB42A8BE69791EC763E51F5A49BCD41E82237"));
});
it("works for Ed25519", () => {
const pubkey = encoding_1.fromHex("14253D61EF42D166D02E68D540D07FDF8D65A9AF0ACAA46302688E788A8521E2");
expect(addresses_1.pubkeyToRawAddress("ed25519", pubkey)).toEqual(encoding_1.fromHex("0CDA3F47EF3C4906693B170EF650EB968C5F4B2C"));
const pubkey = (0, encoding_1.fromHex)("14253D61EF42D166D02E68D540D07FDF8D65A9AF0ACAA46302688E788A8521E2");
expect((0, addresses_1.pubkeyToRawAddress)("ed25519", pubkey)).toEqual((0, encoding_1.fromHex)("0CDA3F47EF3C4906693B170EF650EB968C5F4B2C"));
});

@@ -20,8 +20,8 @@ });

it("works for Secp256k1", () => {
const pubkey = encoding_1.fromHex("02950E1CDFCB133D6024109FD489F734EEB4502418E538C28481F22BCE276F248C");
expect(addresses_1.pubkeyToAddress("secp256k1", pubkey)).toEqual("7C2BB42A8BE69791EC763E51F5A49BCD41E82237");
const pubkey = (0, encoding_1.fromHex)("02950E1CDFCB133D6024109FD489F734EEB4502418E538C28481F22BCE276F248C");
expect((0, addresses_1.pubkeyToAddress)("secp256k1", pubkey)).toEqual("7C2BB42A8BE69791EC763E51F5A49BCD41E82237");
});
it("works for Ed25519", () => {
const pubkey = encoding_1.fromHex("14253D61EF42D166D02E68D540D07FDF8D65A9AF0ACAA46302688E788A8521E2");
expect(addresses_1.pubkeyToAddress("ed25519", pubkey)).toEqual("0CDA3F47EF3C4906693B170EF650EB968C5F4B2C");
const pubkey = (0, encoding_1.fromHex)("14253D61EF42D166D02E68D540D07FDF8D65A9AF0ACAA46302688E788A8521E2");
expect((0, addresses_1.pubkeyToAddress)("ed25519", pubkey)).toEqual("0CDA3F47EF3C4906693B170EF650EB968C5F4B2C");
});

@@ -28,0 +28,0 @@ });

@@ -7,3 +7,3 @@ "use strict";

function fromRfc3339WithNanoseconds(dateTimeString) {
const out = encoding_1.fromRfc3339(dateTimeString);
const out = (0, encoding_1.fromRfc3339)(dateTimeString);
const nanosecondsMatch = dateTimeString.match(/\.(\d+)Z$/);

@@ -10,0 +10,0 @@ const nanoseconds = nanosecondsMatch ? nanosecondsMatch[1].slice(3) : "";

@@ -8,12 +8,12 @@ "use strict";

it("works", () => {
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26Z").nanoseconds).toEqual(0);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.7Z").nanoseconds).toEqual(0);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.77Z").nanoseconds).toEqual(0);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.778Z").nanoseconds).toEqual(0);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.7789Z").nanoseconds).toEqual(900000);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.77809Z").nanoseconds).toEqual(90000);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.778009Z").nanoseconds).toEqual(9000);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.7780009Z").nanoseconds).toEqual(900);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.77800009Z").nanoseconds).toEqual(90);
expect(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.778000009Z").nanoseconds).toEqual(9);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26Z").nanoseconds).toEqual(0);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.7Z").nanoseconds).toEqual(0);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.77Z").nanoseconds).toEqual(0);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.778Z").nanoseconds).toEqual(0);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.7789Z").nanoseconds).toEqual(900000);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.77809Z").nanoseconds).toEqual(90000);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.778009Z").nanoseconds).toEqual(9000);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.7780009Z").nanoseconds).toEqual(900);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.77800009Z").nanoseconds).toEqual(90);
expect((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.778000009Z").nanoseconds).toEqual(9);
});

@@ -25,21 +25,21 @@ });

date1.nanoseconds = 0;
expect(dates_1.toRfc3339WithNanoseconds(date1)).toEqual("2020-12-15T10:57:26.778000000Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date1)).toEqual("2020-12-15T10:57:26.778000000Z");
const date2 = new readonly_date_1.ReadonlyDate("2020-12-15T10:57:26.778Z");
date2.nanoseconds = 900000;
expect(dates_1.toRfc3339WithNanoseconds(date2)).toEqual("2020-12-15T10:57:26.778900000Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date2)).toEqual("2020-12-15T10:57:26.778900000Z");
const date3 = new readonly_date_1.ReadonlyDate("2020-12-15T10:57:26.778Z");
date3.nanoseconds = 90000;
expect(dates_1.toRfc3339WithNanoseconds(date3)).toEqual("2020-12-15T10:57:26.778090000Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date3)).toEqual("2020-12-15T10:57:26.778090000Z");
const date4 = new readonly_date_1.ReadonlyDate("2020-12-15T10:57:26.778Z");
date4.nanoseconds = 9000;
expect(dates_1.toRfc3339WithNanoseconds(date4)).toEqual("2020-12-15T10:57:26.778009000Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date4)).toEqual("2020-12-15T10:57:26.778009000Z");
const date5 = new readonly_date_1.ReadonlyDate("2020-12-15T10:57:26.778Z");
date5.nanoseconds = 900;
expect(dates_1.toRfc3339WithNanoseconds(date5)).toEqual("2020-12-15T10:57:26.778000900Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date5)).toEqual("2020-12-15T10:57:26.778000900Z");
const date6 = new readonly_date_1.ReadonlyDate("2020-12-15T10:57:26.778Z");
date6.nanoseconds = 90;
expect(dates_1.toRfc3339WithNanoseconds(date6)).toEqual("2020-12-15T10:57:26.778000090Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date6)).toEqual("2020-12-15T10:57:26.778000090Z");
const date7 = new readonly_date_1.ReadonlyDate("2020-12-15T10:57:26.778Z");
date7.nanoseconds = 9;
expect(dates_1.toRfc3339WithNanoseconds(date7)).toEqual("2020-12-15T10:57:26.778000009Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date7)).toEqual("2020-12-15T10:57:26.778000009Z");
});

@@ -49,7 +49,7 @@ it("works for DateWithNanoseconds", () => {

date1.nanoseconds = 1;
expect(dates_1.toRfc3339WithNanoseconds(date1)).toEqual("2020-12-15T10:57:26.778000001Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date1)).toEqual("2020-12-15T10:57:26.778000001Z");
});
it("works for Date", () => {
const date1 = new Date("2020-12-15T10:57:26.778Z");
expect(dates_1.toRfc3339WithNanoseconds(date1)).toEqual("2020-12-15T10:57:26.778000000Z");
expect((0, dates_1.toRfc3339WithNanoseconds)(date1)).toEqual("2020-12-15T10:57:26.778000000Z");
});

@@ -60,51 +60,51 @@ });

{
const date = dates_1.fromSeconds(1608029846);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26Z"));
const date = (0, dates_1.fromSeconds)(1608029846);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 0);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 0);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 1);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.000000001Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 1);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.000000001Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 10);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.000000010Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 10);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.000000010Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 100);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.000000100Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 100);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.000000100Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 1000);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.000001000Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 1000);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.000001000Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 10000);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.000010000Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 10000);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.000010000Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 100000);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.000100000Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 100000);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.000100000Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 1000000);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.001000000Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 1000000);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.001000000Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 10000000);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.010000000Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 10000000);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.010000000Z"));
}
{
const date = dates_1.fromSeconds(1608029846, 100000000);
expect(date).toEqual(dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.100000000Z"));
const date = (0, dates_1.fromSeconds)(1608029846, 100000000);
expect(date).toEqual((0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.100000000Z"));
}
});
it("throws for nanos out of range", () => {
expect(() => dates_1.fromSeconds(1608029846, 1000000000)).toThrow();
expect(() => dates_1.fromSeconds(1608029846, -1)).toThrow();
expect(() => dates_1.fromSeconds(1608029846, 1.2)).toThrow();
expect(() => dates_1.fromSeconds(1608029846, NaN)).toThrow();
expect(() => (0, dates_1.fromSeconds)(1608029846, 1000000000)).toThrow();
expect(() => (0, dates_1.fromSeconds)(1608029846, -1)).toThrow();
expect(() => (0, dates_1.fromSeconds)(1608029846, 1.2)).toThrow();
expect(() => (0, dates_1.fromSeconds)(1608029846, NaN)).toThrow();
});

@@ -115,40 +115,40 @@ });

{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 0 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 0 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.7Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 700000000 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.7Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 700000000 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.77Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 770000000 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.77Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 770000000 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.778Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778000000 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.778Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778000000 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.7789Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778900000 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.7789Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778900000 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.77809Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778090000 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.77809Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778090000 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.778009Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778009000 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.778009Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778009000 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.7780009Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778000900 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.7780009Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778000900 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.77800009Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778000090 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.77800009Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778000090 });
}
{
const date = dates_1.fromRfc3339WithNanoseconds("2020-12-15T10:57:26.778000009Z");
expect(dates_1.toSeconds(date)).toEqual({ seconds: 1608029846, nanos: 778000009 });
const date = (0, dates_1.fromRfc3339WithNanoseconds)("2020-12-15T10:57:26.778000009Z");
expect((0, dates_1.toSeconds)(date)).toEqual({ seconds: 1608029846, nanos: 778000009 });
}

@@ -155,0 +155,0 @@ });

export { pubkeyToAddress, pubkeyToRawAddress, rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress, } from "./addresses";
export { DateTime, ReadonlyDateWithNanoseconds, fromRfc3339WithNanoseconds, fromSeconds, toRfc3339WithNanoseconds, toSeconds, } from "./dates";
export { DateTime, fromRfc3339WithNanoseconds, fromSeconds, ReadonlyDateWithNanoseconds, toRfc3339WithNanoseconds, toSeconds, } from "./dates";
export { HttpEndpoint, } from "./rpcclients";
export { HttpClient, WebsocketClient } from "./rpcclients";
export { BlockIdFlag, CommitSignature, ValidatorEd25519Pubkey, ValidatorSecp256k1Pubkey, ValidatorPubkey, } from "./types";
export * as tendermint33 from "./tendermint33";
export { Tendermint33Client, AbciInfoResponse, AbciQueryResponse, Attribute, Block, BlockchainResponse, BlockGossipParams, BlockId, BlockMeta, BlockParams, BlockResponse, BlockResultsResponse, BroadcastTxAsyncResponse, BroadcastTxCommitResponse, broadcastTxCommitSuccess, BroadcastTxSyncResponse, broadcastTxSyncSuccess, Commit, CommitResponse, ConsensusParams, Event, Evidence, EvidenceParams, GenesisResponse, Header, HealthResponse, NewBlockEvent, NewBlockHeaderEvent, NodeInfo, ProofOp, QueryProof, Response, StatusResponse, SyncInfo, TxData, TxEvent, TxProof, TxResponse, TxSearchResponse, TxSizeParams, Validator, ValidatorsResponse, Version, Vote, VoteType, AbciInfoRequest, AbciQueryParams, AbciQueryRequest, BlockRequest, BlockchainRequest, BlockResultsRequest, BroadcastTxRequest, BroadcastTxParams, CommitRequest, GenesisRequest, HealthRequest, Method, Request, QueryTag, StatusRequest, SubscriptionEventType, TxParams, TxRequest, TxSearchParams, TxSearchRequest, ValidatorsRequest, ValidatorsParams, } from "./tendermint33";
export { AbciInfoRequest, AbciInfoResponse, AbciQueryParams, AbciQueryRequest, AbciQueryResponse, Attribute, Block, BlockchainRequest, BlockchainResponse, BlockGossipParams, BlockId, BlockMeta, BlockParams, BlockRequest, BlockResponse, BlockResultsRequest, BlockResultsResponse, BroadcastTxAsyncResponse, BroadcastTxCommitResponse, broadcastTxCommitSuccess, BroadcastTxParams, BroadcastTxRequest, BroadcastTxSyncResponse, broadcastTxSyncSuccess, Commit, CommitRequest, CommitResponse, ConsensusParams, Event, Evidence, EvidenceParams, GenesisRequest, GenesisResponse, Header, HealthRequest, HealthResponse, Method, NewBlockEvent, NewBlockHeaderEvent, NodeInfo, NumUnconfirmedTxsRequest, NumUnconfirmedTxsResponse, ProofOp, QueryProof, QueryTag, Request, Response, StatusRequest, StatusResponse, SubscriptionEventType, SyncInfo, TxData, TxEvent, TxParams, TxProof, TxRequest, TxResponse, TxSearchParams, TxSearchRequest, TxSearchResponse, TxSizeParams, Validator, ValidatorsParams, ValidatorsRequest, ValidatorsResponse, Version, Vote, VoteType, } from "./tendermint34";
export * as tendermint34 from "./tendermint34";
export { Tendermint34Client } from "./tendermint34";
export { BlockIdFlag, CommitSignature, ValidatorEd25519Pubkey, ValidatorPubkey, ValidatorSecp256k1Pubkey, } from "./types";

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Tendermint34Client = exports.tendermint34 = exports.SubscriptionEventType = exports.Method = exports.VoteType = exports.broadcastTxSyncSuccess = exports.broadcastTxCommitSuccess = exports.Tendermint33Client = exports.tendermint33 = exports.BlockIdFlag = exports.WebsocketClient = exports.HttpClient = exports.toSeconds = exports.toRfc3339WithNanoseconds = exports.fromSeconds = exports.fromRfc3339WithNanoseconds = exports.DateTime = exports.rawSecp256k1PubkeyToRawAddress = exports.rawEd25519PubkeyToRawAddress = exports.pubkeyToRawAddress = exports.pubkeyToAddress = void 0;
exports.BlockIdFlag = exports.Tendermint34Client = exports.tendermint34 = exports.VoteType = exports.SubscriptionEventType = exports.Method = exports.broadcastTxSyncSuccess = exports.broadcastTxCommitSuccess = exports.WebsocketClient = exports.HttpClient = exports.toSeconds = exports.toRfc3339WithNanoseconds = exports.fromSeconds = exports.fromRfc3339WithNanoseconds = exports.DateTime = exports.rawSecp256k1PubkeyToRawAddress = exports.rawEd25519PubkeyToRawAddress = exports.pubkeyToRawAddress = exports.pubkeyToAddress = void 0;
var addresses_1 = require("./addresses");

@@ -38,15 +38,13 @@ Object.defineProperty(exports, "pubkeyToAddress", { enumerable: true, get: function () { return addresses_1.pubkeyToAddress; } });

Object.defineProperty(exports, "WebsocketClient", { enumerable: true, get: function () { return rpcclients_1.WebsocketClient; } });
var tendermint34_1 = require("./tendermint34");
Object.defineProperty(exports, "broadcastTxCommitSuccess", { enumerable: true, get: function () { return tendermint34_1.broadcastTxCommitSuccess; } });
Object.defineProperty(exports, "broadcastTxSyncSuccess", { enumerable: true, get: function () { return tendermint34_1.broadcastTxSyncSuccess; } });
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return tendermint34_1.Method; } });
Object.defineProperty(exports, "SubscriptionEventType", { enumerable: true, get: function () { return tendermint34_1.SubscriptionEventType; } });
Object.defineProperty(exports, "VoteType", { enumerable: true, get: function () { return tendermint34_1.VoteType; } });
exports.tendermint34 = __importStar(require("./tendermint34"));
var tendermint34_2 = require("./tendermint34");
Object.defineProperty(exports, "Tendermint34Client", { enumerable: true, get: function () { return tendermint34_2.Tendermint34Client; } });
var types_1 = require("./types");
Object.defineProperty(exports, "BlockIdFlag", { enumerable: true, get: function () { return types_1.BlockIdFlag; } });
exports.tendermint33 = __importStar(require("./tendermint33"));
var tendermint33_1 = require("./tendermint33");
Object.defineProperty(exports, "Tendermint33Client", { enumerable: true, get: function () { return tendermint33_1.Tendermint33Client; } });
Object.defineProperty(exports, "broadcastTxCommitSuccess", { enumerable: true, get: function () { return tendermint33_1.broadcastTxCommitSuccess; } });
Object.defineProperty(exports, "broadcastTxSyncSuccess", { enumerable: true, get: function () { return tendermint33_1.broadcastTxSyncSuccess; } });
Object.defineProperty(exports, "VoteType", { enumerable: true, get: function () { return tendermint33_1.VoteType; } });
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return tendermint33_1.Method; } });
Object.defineProperty(exports, "SubscriptionEventType", { enumerable: true, get: function () { return tendermint33_1.SubscriptionEventType; } });
exports.tendermint34 = __importStar(require("./tendermint34"));
var tendermint34_1 = require("./tendermint34");
Object.defineProperty(exports, "Tendermint34Client", { enumerable: true, get: function () { return tendermint34_1.Tendermint34Client; } });
//# sourceMappingURL=index.js.map

@@ -20,3 +20,3 @@ "use strict";

function createJsonRpcRequest(method, params) {
const paramsCopy = params ? Object.assign({}, params) : {};
const paramsCopy = params ? { ...params } : {};
return {

@@ -23,0 +23,0 @@ jsonrpc: "2.0",

@@ -7,3 +7,3 @@ "use strict";

it("generates proper object with correct method", () => {
const request = jsonrpc_1.createJsonRpcRequest("do_something");
const request = (0, jsonrpc_1.createJsonRpcRequest)("do_something");
expect(request.jsonrpc).toEqual("2.0");

@@ -14,4 +14,4 @@ expect(request.id.toString()).toMatch(/^[1-9]{12}$/);

it("generates distinct IDs", () => {
const request1 = jsonrpc_1.createJsonRpcRequest("foo");
const request2 = jsonrpc_1.createJsonRpcRequest("foo");
const request1 = (0, jsonrpc_1.createJsonRpcRequest)("foo");
const request2 = (0, jsonrpc_1.createJsonRpcRequest)("foo");
expect(request2.id).not.toEqual(request1.id);

@@ -21,3 +21,3 @@ });

const params = { foo: "bar" };
const request = jsonrpc_1.createJsonRpcRequest("some_method", params);
const request = (0, jsonrpc_1.createJsonRpcRequest)("some_method", params);
expect(request.params).toEqual(params);

@@ -24,0 +24,0 @@ expect(request.params).not.toBe(params);

@@ -8,8 +8,22 @@ import { JsonRpcRequest, JsonRpcSuccessResponse } from "@cosmjs/json-rpc";

*/
export declare function http(method: "POST", url: string, request?: any): Promise<any>;
export declare function http(method: "POST", url: string, headers: Record<string, string> | undefined, request?: any): Promise<any>;
export interface HttpEndpoint {
/**
* The URL of the HTTP endpoint.
*
* For POST APIs like Tendermint RPC in CosmJS,
* this is without the method specific paths (e.g. https://cosmoshub-4--rpc--full.datahub.figment.io/)
*/
readonly url: string;
/**
* HTTP headers that are sent with every request, such as authorization information.
*/
readonly headers: Record<string, string>;
}
export declare class HttpClient implements RpcClient {
protected readonly url: string;
constructor(url?: string);
protected readonly headers: Record<string, string> | undefined;
constructor(endpoint: string | HttpEndpoint);
disconnect(): void;
execute(request: JsonRpcRequest): Promise<JsonRpcSuccessResponse>;
}

@@ -22,6 +22,14 @@ "use strict";

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
async function http(method, url, request) {
async function http(method, url, headers, request) {
if (typeof fetch !== "undefined") {
const body = request ? JSON.stringify(request) : undefined;
return fetch(url, { method: method, body: body })
const settings = {
method: method,
body: request ? JSON.stringify(request) : undefined,
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"Content-Type": "application/json",
...headers,
},
};
return fetch(url, settings)
.then(filterBadStatus)

@@ -31,3 +39,5 @@ .then((res) => res.json());

else {
return axios_1.default.request({ url: url, method: method, data: request }).then((res) => res.data);
return axios_1.default
.request({ url: url, method: method, data: request, headers: headers })
.then((res) => res.data);
}

@@ -37,5 +47,11 @@ }

class HttpClient {
constructor(url = "http://localhost:46657") {
// accept host.name:port and assume http protocol
this.url = rpcclient_1.hasProtocol(url) ? url : "http://" + url;
constructor(endpoint) {
if (typeof endpoint === "string") {
// accept host.name:port and assume http protocol
this.url = (0, rpcclient_1.hasProtocol)(endpoint) ? endpoint : "http://" + endpoint;
}
else {
this.url = endpoint.url;
this.headers = endpoint.headers;
}
}

@@ -46,4 +62,4 @@ disconnect() {

async execute(request) {
const response = json_rpc_1.parseJsonRpcResponse(await http("POST", this.url, request));
if (json_rpc_1.isJsonRpcErrorResponse(response)) {
const response = (0, json_rpc_1.parseJsonRpcResponse)(await http("POST", this.url, this.headers, request));
if ((0, json_rpc_1.isJsonRpcErrorResponse)(response)) {
throw new Error(JSON.stringify(response.error));

@@ -50,0 +66,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/naming-convention */
const jsonrpc_1 = require("../jsonrpc");

@@ -8,15 +9,50 @@ const testutil_spec_1 = require("../testutil.spec");

if (!process.env.TENDERMINT_ENABLED) {
pending("Set TENDERMINT_ENABLED to enable tendermint rpc tests");
pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests");
}
}
function pendingWithoutHttpServer() {
if (!process.env.HTTPSERVER_ENABLED) {
pending("Set HTTPSERVER_ENABLED to enable HTTP tests");
}
}
const tendermintUrl = testutil_spec_1.defaultInstance.url;
const echoUrl = "http://localhost:5555/echo_headers";
describe("http", () => {
it("can send a health request", async () => {
pendingWithoutTendermint();
const response = await httpclient_1.http("POST", `http://${tendermintUrl}`, jsonrpc_1.createJsonRpcRequest("health"));
const response = await (0, httpclient_1.http)("POST", `http://${tendermintUrl}`, undefined, (0, jsonrpc_1.createJsonRpcRequest)("health"));
expect(response).toEqual(jasmine.objectContaining({ jsonrpc: "2.0" }));
});
it("errors for non-open port", async () => {
await expectAsync(httpclient_1.http("POST", `http://localhost:56745`, jsonrpc_1.createJsonRpcRequest("health"))).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i);
await expectAsync((0, httpclient_1.http)("POST", `http://localhost:56745`, undefined, (0, jsonrpc_1.createJsonRpcRequest)("health"))).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i);
});
it("can send custom headers", async () => {
pendingWithoutHttpServer();
// Without custom headers
const response1 = await (0, httpclient_1.http)("POST", echoUrl, undefined, (0, jsonrpc_1.createJsonRpcRequest)("health"));
expect(response1).toEqual({
request_headers: jasmine.objectContaining({
// Basic headers from http client
Accept: jasmine.any(String),
"Content-Length": jasmine.any(String),
"Content-Type": "application/json",
Host: jasmine.any(String),
"User-Agent": jasmine.any(String),
}),
});
// With custom headers
const response2 = await (0, httpclient_1.http)("POST", echoUrl, { foo: "bar123", Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz" }, (0, jsonrpc_1.createJsonRpcRequest)("health"));
expect(response2).toEqual({
request_headers: jasmine.objectContaining({
// Basic headers from http client
"Content-Length": jasmine.any(String),
"Content-Type": "application/json",
Host: jasmine.any(String),
"User-Agent": jasmine.any(String),
// Custom headers
foo: "bar123",
Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz",
}),
});
});
});

@@ -27,9 +63,9 @@ describe("HttpClient", () => {

const client = new httpclient_1.HttpClient(tendermintUrl);
const healthResponse = await client.execute(jsonrpc_1.createJsonRpcRequest("health"));
const healthResponse = await client.execute((0, jsonrpc_1.createJsonRpcRequest)("health"));
expect(healthResponse.result).toEqual({});
const statusResponse = await client.execute(jsonrpc_1.createJsonRpcRequest("status"));
const statusResponse = await client.execute((0, jsonrpc_1.createJsonRpcRequest)("status"));
expect(statusResponse.result).toBeTruthy();
expect(statusResponse.result.node_info).toBeTruthy();
await client
.execute(jsonrpc_1.createJsonRpcRequest("no-such-method"))
.execute((0, jsonrpc_1.createJsonRpcRequest)("no-such-method"))
.then(() => fail("must not resolve"))

@@ -36,0 +72,0 @@ .catch((error) => expect(error).toBeTruthy());

@@ -0,3 +1,3 @@

export { HttpClient, HttpEndpoint } from "./httpclient";
export { instanceOfRpcStreamingClient, RpcClient, RpcStreamingClient, SubscriptionEvent } from "./rpcclient";
export { HttpClient } from "./httpclient";
export { WebsocketClient } from "./websocketclient";
"use strict";
// This folder contains Tendermint-specific RPC clients
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebsocketClient = exports.HttpClient = exports.instanceOfRpcStreamingClient = void 0;
exports.WebsocketClient = exports.instanceOfRpcStreamingClient = exports.HttpClient = void 0;
var httpclient_1 = require("./httpclient");
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return httpclient_1.HttpClient; } });
var rpcclient_1 = require("./rpcclient");
Object.defineProperty(exports, "instanceOfRpcStreamingClient", { enumerable: true, get: function () { return rpcclient_1.instanceOfRpcStreamingClient; } });
var httpclient_1 = require("./httpclient");
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return httpclient_1.HttpClient; } });
var websocketclient_1 = require("./websocketclient");
Object.defineProperty(exports, "WebsocketClient", { enumerable: true, get: function () { return websocketclient_1.WebsocketClient; } });
//# sourceMappingURL=index.js.map

@@ -10,3 +10,3 @@ "use strict";

if (!process.env.TENDERMINT_ENABLED) {
pending("Set TENDERMINT_ENABLED to enable tendermint rpc tests");
pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests");
}

@@ -20,4 +20,4 @@ }

const wsClient = new websocketclient_1.WebsocketClient(tendermintUrl);
expect(rpcclient_1.instanceOfRpcStreamingClient(httpClient)).toEqual(false);
expect(rpcclient_1.instanceOfRpcStreamingClient(wsClient)).toEqual(true);
expect((0, rpcclient_1.instanceOfRpcStreamingClient)(httpClient)).toEqual(false);
expect((0, rpcclient_1.instanceOfRpcStreamingClient)(wsClient)).toEqual(true);
httpClient.disconnect();

@@ -29,3 +29,3 @@ await wsClient.connected();

pendingWithoutTendermint();
const statusRequest = jsonrpc_1.createJsonRpcRequest("status");
const statusRequest = (0, jsonrpc_1.createJsonRpcRequest)("status");
const httpClient = new httpclient_1.HttpClient(tendermintUrl + "/");

@@ -32,0 +32,0 @@ expect(await httpClient.execute(statusRequest)).toBeDefined();

@@ -10,3 +10,3 @@ import { JsonRpcId, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse } from "@cosmjs/json-rpc";

private readonly subscriptionStreams;
constructor(baseUrl?: string, onError?: (err: any) => void);
constructor(baseUrl: string, onError?: (err: any) => void);
execute(request: JsonRpcRequest): Promise<JsonRpcSuccessResponse>;

@@ -13,0 +13,0 @@ listen(request: JsonRpcRequest): Stream<SubscriptionEvent>;

@@ -17,3 +17,3 @@ "use strict";

}
const jsonRpcEvent = json_rpc_1.parseJsonRpcResponse(JSON.parse(message.data));
const jsonRpcEvent = (0, json_rpc_1.parseJsonRpcResponse)(JSON.parse(message.data));
return jsonRpcEvent;

@@ -49,3 +49,3 @@ }

// This may fail when socket connection is not open, thus ignore errors in queueRequest
const endRequest = Object.assign(Object.assign({}, this.request), { method: "unsubscribe" });
const endRequest = { ...this.request, method: "unsubscribe" };
try {

@@ -70,3 +70,3 @@ this.socket.queueRequest(JSON.stringify(endRequest));

next: (response) => {
if (json_rpc_1.isJsonRpcErrorResponse(response)) {
if ((0, json_rpc_1.isJsonRpcErrorResponse)(response)) {
this.closeSubscriptions();

@@ -85,3 +85,3 @@ listener.error(JSON.stringify(response.error));

next: (response) => {
if (json_rpc_1.isJsonRpcErrorResponse(response)) {
if ((0, json_rpc_1.isJsonRpcErrorResponse)(response)) {
this.closeSubscriptions();

@@ -117,3 +117,3 @@ listener.error(JSON.stringify(response.error));

class WebsocketClient {
constructor(baseUrl = "ws://localhost:46657", onError = defaultErrorHandler) {
constructor(baseUrl, onError = defaultErrorHandler) {
// Lazily create streams and use the same stream when listening to the same query twice.

@@ -127,3 +127,3 @@ //

const path = baseUrl.endsWith("/") ? "websocket" : "/websocket";
const cleanBaseUrl = rpcclient_1.hasProtocol(baseUrl) ? baseUrl : "ws://" + baseUrl;
const cleanBaseUrl = (0, rpcclient_1.hasProtocol)(baseUrl) ? baseUrl : "ws://" + baseUrl;
this.url = cleanBaseUrl + path;

@@ -144,3 +144,3 @@ this.socket = new socket_1.ReconnectingSocket(this.url);

const response = await pendingResponse;
if (json_rpc_1.isJsonRpcErrorResponse(response)) {
if ((0, json_rpc_1.isJsonRpcErrorResponse)(response)) {
throw new Error(JSON.stringify(response.error));

@@ -177,3 +177,3 @@ }

async responseForRequestId(id) {
return stream_1.firstEvent(this.jsonRpcResponseStream.filter((r) => r.id === id));
return (0, stream_1.firstEvent)(this.jsonRpcResponseStream.filter((r) => r.id === id));
}

@@ -180,0 +180,0 @@ }

@@ -11,3 +11,3 @@ "use strict";

if (!process.env.TENDERMINT_ENABLED) {
pending("Set TENDERMINT_ENABLED to enable tendermint rpc tests");
pending("Set TENDERMINT_ENABLED to enable Tendermint RPC tests");
}

@@ -20,9 +20,9 @@ }

const client = new websocketclient_1.WebsocketClient(tendermintUrl);
const healthResponse = await client.execute(jsonrpc_1.createJsonRpcRequest("health"));
const healthResponse = await client.execute((0, jsonrpc_1.createJsonRpcRequest)("health"));
expect(healthResponse.result).toEqual({});
const statusResponse = await client.execute(jsonrpc_1.createJsonRpcRequest("status"));
const statusResponse = await client.execute((0, jsonrpc_1.createJsonRpcRequest)("status"));
expect(statusResponse.result).toBeTruthy();
expect(statusResponse.result.node_info).toBeTruthy();
await client
.execute(jsonrpc_1.createJsonRpcRequest("no-such-method"))
.execute((0, jsonrpc_1.createJsonRpcRequest)("no-such-method"))
.then(() => fail("must not resolve"))

@@ -36,3 +36,3 @@ .catch((error) => expect(error).toBeTruthy());

const query = "tm.event='NewBlockHeader'";
const req = jsonrpc_1.createJsonRpcRequest("subscribe", { query: query });
const req = (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: query });
const headers = client.listen(req);

@@ -66,7 +66,7 @@ const events = [];

// we need two requests with unique IDs
const request1 = jsonrpc_1.createJsonRpcRequest("subscribe", { query: newBlockHeaderQuery });
const request2 = jsonrpc_1.createJsonRpcRequest("subscribe", { query: newBlockHeaderQuery });
const request1 = (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: newBlockHeaderQuery });
const request2 = (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: newBlockHeaderQuery });
const stream1 = client.listen(request1);
const stream2 = client.listen(request2);
const eventHeights = await stream_1.toListPromise(xstream_1.Stream.merge(stream1, stream2).map((event) => {
const eventHeights = await (0, stream_1.toListPromise)(xstream_1.Stream.merge(stream1, stream2).map((event) => {
// height is string or number, depending on Tendermint version. But we don't care in this case

@@ -82,3 +82,3 @@ return event.data.value.header.height;

const query = "tm.event='NewBlockHeader'";
const req = jsonrpc_1.createJsonRpcRequest("subscribe", { query: query });
const req = (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: query });
const headers = client.listen(req);

@@ -104,3 +104,3 @@ const events = [];

client
.execute(jsonrpc_1.createJsonRpcRequest("status"))
.execute((0, jsonrpc_1.createJsonRpcRequest)("status"))
.then((startusResponse) => expect(startusResponse).toBeTruthy())

@@ -113,3 +113,3 @@ .catch(done.fail);

const query = "tm.event='NewBlockHeader'";
const req = jsonrpc_1.createJsonRpcRequest("subscribe", { query: query });
const req = (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: query });
const headers = client.listen(req);

@@ -131,6 +131,6 @@ const receivedEvents = [];

// dummy command to ensure client is connected
await client.execute(jsonrpc_1.createJsonRpcRequest("health"));
await client.execute((0, jsonrpc_1.createJsonRpcRequest)("health"));
client.disconnect();
await client
.execute(jsonrpc_1.createJsonRpcRequest("health"))
.execute((0, jsonrpc_1.createJsonRpcRequest)("health"))
.then(() => fail("must not resolve"))

@@ -145,6 +145,6 @@ .catch((error) => expect(error).toMatch(/socket has disconnected/i));

// dummy command to ensure client is connected
await client.execute(jsonrpc_1.createJsonRpcRequest("health"));
await client.execute((0, jsonrpc_1.createJsonRpcRequest)("health"));
client.disconnect();
const query = "tm.event='NewBlockHeader'";
const req = jsonrpc_1.createJsonRpcRequest("subscribe", { query: query });
const req = (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: query });
expect(() => client.listen(req).subscribe({})).toThrowError(/socket has disconnected/i);

@@ -157,3 +157,3 @@ done();

const client = new websocketclient_1.WebsocketClient(tendermintUrl);
const req = jsonrpc_1.createJsonRpcRequest("health");
const req = (0, jsonrpc_1.createJsonRpcRequest)("health");
expect(() => client.listen(req)).toThrowError(/request method must be "subscribe"/i);

@@ -160,0 +160,0 @@ await client.connected();

@@ -14,2 +14,3 @@ import { JsonRpcRequest } from "@cosmjs/json-rpc";

static encodeHealth(req: requests.HealthRequest): JsonRpcRequest;
static encodeNumUnconfirmedTxs(req: requests.NumUnconfirmedTxsRequest): JsonRpcRequest;
static encodeStatus(req: requests.StatusRequest): JsonRpcRequest;

@@ -16,0 +17,0 @@ static encodeSubscribe(req: requests.SubscribeRequest): JsonRpcRequest;

@@ -30,3 +30,3 @@ "use strict";

return {
height: encodings_1.may(encodings_1.Integer.encode, param.height),
height: (0, encodings_1.may)(encodings_1.Integer.encode, param.height),
};

@@ -36,4 +36,4 @@ }

return {
minHeight: encodings_1.may(encodings_1.Integer.encode, param.minHeight),
maxHeight: encodings_1.may(encodings_1.Integer.encode, param.maxHeight),
minHeight: (0, encodings_1.may)(encodings_1.Integer.encode, param.minHeight),
maxHeight: (0, encodings_1.may)(encodings_1.Integer.encode, param.maxHeight),
};

@@ -44,4 +44,4 @@ }

query: params.query,
page: encodings_1.may(encodings_1.Integer.encode, params.page),
per_page: encodings_1.may(encodings_1.Integer.encode, params.per_page),
page: (0, encodings_1.may)(encodings_1.Integer.encode, params.page),
per_page: (0, encodings_1.may)(encodings_1.Integer.encode, params.per_page),
order_by: params.order_by,

@@ -52,5 +52,5 @@ };

return {
path: encodings_1.assertNotEmpty(params.path),
data: encoding_1.toHex(params.data),
height: encodings_1.may(encodings_1.Integer.encode, params.height),
path: (0, encodings_1.assertNotEmpty)(params.path),
data: (0, encoding_1.toHex)(params.data),
height: (0, encodings_1.may)(encodings_1.Integer.encode, params.height),
prove: params.prove,

@@ -61,3 +61,3 @@ };

return {
tx: encoding_1.toBase64(encodings_1.assertNotEmpty(params.tx)),
tx: (0, encoding_1.toBase64)((0, encodings_1.assertNotEmpty)(params.tx)),
};

@@ -67,3 +67,3 @@ }

return {
hash: encoding_1.toBase64(encodings_1.assertNotEmpty(params.hash)),
hash: (0, encoding_1.toBase64)((0, encodings_1.assertNotEmpty)(params.hash)),
prove: params.prove,

@@ -76,4 +76,4 @@ };

prove: params.prove,
page: encodings_1.may(encodings_1.Integer.encode, params.page),
per_page: encodings_1.may(encodings_1.Integer.encode, params.per_page),
page: (0, encodings_1.may)(encodings_1.Integer.encode, params.page),
per_page: (0, encodings_1.may)(encodings_1.Integer.encode, params.per_page),
order_by: params.order_by,

@@ -84,5 +84,5 @@ };

return {
height: encodings_1.may(encodings_1.Integer.encode, params.height),
page: encodings_1.may(encodings_1.Integer.encode, params.page),
per_page: encodings_1.may(encodings_1.Integer.encode, params.per_page),
height: (0, encodings_1.may)(encodings_1.Integer.encode, params.height),
page: (0, encodings_1.may)(encodings_1.Integer.encode, params.page),
per_page: (0, encodings_1.may)(encodings_1.Integer.encode, params.per_page),
};

@@ -92,33 +92,36 @@ }

static encodeAbciInfo(req) {
return jsonrpc_1.createJsonRpcRequest(req.method);
return (0, jsonrpc_1.createJsonRpcRequest)(req.method);
}
static encodeAbciQuery(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeAbciQueryParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeAbciQueryParams(req.params));
}
static encodeBlock(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeHeightParam(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeHeightParam(req.params));
}
static encodeBlockchain(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeBlockchainRequestParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeBlockchainRequestParams(req.params));
}
static encodeBlockResults(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeHeightParam(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeHeightParam(req.params));
}
static encodeBlockSearch(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeBlockSearchParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeBlockSearchParams(req.params));
}
static encodeBroadcastTx(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeBroadcastTxParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeBroadcastTxParams(req.params));
}
static encodeCommit(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeHeightParam(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeHeightParam(req.params));
}
static encodeGenesis(req) {
return jsonrpc_1.createJsonRpcRequest(req.method);
return (0, jsonrpc_1.createJsonRpcRequest)(req.method);
}
static encodeHealth(req) {
return jsonrpc_1.createJsonRpcRequest(req.method);
return (0, jsonrpc_1.createJsonRpcRequest)(req.method);
}
static encodeNumUnconfirmedTxs(req) {
return (0, jsonrpc_1.createJsonRpcRequest)(req.method);
}
static encodeStatus(req) {
return jsonrpc_1.createJsonRpcRequest(req.method);
return (0, jsonrpc_1.createJsonRpcRequest)(req.method);
}

@@ -128,13 +131,13 @@ static encodeSubscribe(req) {

const query = requests.buildQuery({ tags: [eventTag], raw: req.query.raw });
return jsonrpc_1.createJsonRpcRequest("subscribe", { query: query });
return (0, jsonrpc_1.createJsonRpcRequest)("subscribe", { query: query });
}
static encodeTx(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeTxParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeTxParams(req.params));
}
// TODO: encode params for query string???
static encodeTxSearch(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeTxSearchParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeTxSearchParams(req.params));
}
static encodeValidators(req) {
return jsonrpc_1.createJsonRpcRequest(req.method, encodeValidatorsParams(req.params));
return (0, jsonrpc_1.createJsonRpcRequest)(req.method, encodeValidatorsParams(req.params));
}

@@ -141,0 +144,0 @@ }

@@ -14,2 +14,36 @@ import { JsonRpcSuccessResponse } from "@cosmjs/json-rpc";

}
declare type RpcPubkey = {
readonly type: string;
/** base64 encoded */
readonly value: string;
} | {
readonly Sum: {
readonly type: string;
readonly value: {
/** base64 encoded */
[algorithm: string]: string;
};
};
};
interface RpcValidatorUpdate {
readonly pub_key: RpcPubkey;
readonly power?: string;
}
export declare function decodeValidatorUpdate(data: RpcValidatorUpdate): responses.ValidatorUpdate;
interface RpcValidatorGenesis {
/** hex-encoded */
readonly address: string;
readonly pub_key: RpcPubkey;
readonly power: string;
readonly name?: string;
}
export declare function decodeValidatorGenesis(data: RpcValidatorGenesis): responses.Validator;
interface RpcValidatorInfo {
/** hex encoded */
readonly address: string;
readonly pub_key: RpcPubkey;
readonly voting_power: string;
readonly proposer_priority?: string;
}
export declare function decodeValidatorInfo(data: RpcValidatorInfo): responses.Validator;
export declare class Responses {

@@ -28,2 +62,3 @@ static decodeAbciInfo(response: JsonRpcSuccessResponse): responses.AbciInfoResponse;

static decodeHealth(): responses.HealthResponse;
static decodeNumUnconfirmedTxs(response: JsonRpcSuccessResponse): responses.NumUnconfirmedTxsResponse;
static decodeStatus(response: JsonRpcSuccessResponse): responses.StatusResponse;

@@ -37,1 +72,2 @@ static decodeNewBlockEvent(event: SubscriptionEvent): responses.NewBlockEvent;

}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Responses = void 0;
exports.Responses = exports.decodeValidatorInfo = exports.decodeValidatorGenesis = exports.decodeValidatorUpdate = void 0;
/* eslint-disable @typescript-eslint/naming-convention */

@@ -14,4 +14,4 @@ const encoding_1 = require("@cosmjs/encoding");

data: data.data,
lastBlockHeight: encodings_1.may(encodings_1.Integer.parse, data.last_block_height),
lastBlockAppHash: encodings_1.may(encoding_1.fromBase64, data.last_block_app_hash),
lastBlockHeight: (0, encodings_1.may)(encodings_1.Integer.parse, data.last_block_height),
lastBlockAppHash: (0, encodings_1.may)(encoding_1.fromBase64, data.last_block_app_hash),
};

@@ -23,4 +23,4 @@ }

type: op.type,
key: encoding_1.fromBase64(op.key),
data: encoding_1.fromBase64(op.data),
key: (0, encoding_1.fromBase64)(op.key),
data: (0, encoding_1.fromBase64)(op.data),
})),

@@ -31,8 +31,8 @@ };

return {
key: encoding_1.fromBase64(encodings_1.optional(data.key, "")),
value: encoding_1.fromBase64(encodings_1.optional(data.value, "")),
proof: encodings_1.may(decodeQueryProof, data.proofOps),
height: encodings_1.may(encodings_1.Integer.parse, data.height),
code: encodings_1.may(encodings_1.Integer.parse, data.code),
index: encodings_1.may(encodings_1.Integer.parse, data.index),
key: (0, encoding_1.fromBase64)((0, encodings_1.optional)(data.key, "")),
value: (0, encoding_1.fromBase64)((0, encodings_1.optional)(data.value, "")),
proof: (0, encodings_1.may)(decodeQueryProof, data.proofOps),
height: (0, encodings_1.may)(encodings_1.Integer.parse, data.height),
code: (0, encodings_1.may)(encodings_1.Integer.parse, data.code),
index: (0, encodings_1.may)(encodings_1.Integer.parse, data.index),
log: data.log,

@@ -43,8 +43,8 @@ };

return {
key: encoding_1.fromBase64(encodings_1.assertNotEmpty(attribute.key)),
value: encoding_1.fromBase64(encodings_1.optional(attribute.value, "")),
key: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(attribute.key)),
value: (0, encoding_1.fromBase64)((0, encodings_1.optional)(attribute.value, "")),
};
}
function decodeAttributes(attributes) {
return encodings_1.assertArray(attributes).map(decodeAttribute);
return (0, encodings_1.assertArray)(attributes).map(decodeAttribute);
}

@@ -58,40 +58,43 @@ function decodeEvent(event) {

function decodeEvents(events) {
return encodings_1.assertArray(events).map(decodeEvent);
return (0, encodings_1.assertArray)(events).map(decodeEvent);
}
function decodeTxData(data) {
return {
code: encodings_1.Integer.parse(encodings_1.assertNumber(encodings_1.optional(data.code, 0))),
code: encodings_1.Integer.parse((0, encodings_1.assertNumber)((0, encodings_1.optional)(data.code, 0))),
codeSpace: data.codespace,
log: data.log,
data: encodings_1.may(encoding_1.fromBase64, data.data),
data: (0, encodings_1.may)(encoding_1.fromBase64, data.data),
events: data.events ? decodeEvents(data.events) : [],
gasWanted: encodings_1.Integer.parse(encodings_1.optional(data.gas_wanted, "0")),
gasUsed: encodings_1.Integer.parse(encodings_1.optional(data.gas_used, "0")),
gasWanted: encodings_1.Integer.parse((0, encodings_1.optional)(data.gas_wanted, "0")),
gasUsed: encodings_1.Integer.parse((0, encodings_1.optional)(data.gas_used, "0")),
};
}
function decodePubkey(data) {
switch (data.type) {
// go-amino special code
case "tendermint/PubKeyEd25519":
return {
algorithm: "ed25519",
data: encoding_1.fromBase64(encodings_1.assertNotEmpty(data.value)),
};
case "tendermint/PubKeySecp256k1":
return {
algorithm: "secp256k1",
data: encoding_1.fromBase64(encodings_1.assertNotEmpty(data.value)),
};
default:
throw new Error(`unknown pubkey type: ${data.type}`);
if ("Sum" in data) {
// we don't need to check type because we're checking algorithm
const [[algorithm, value]] = Object.entries(data.Sum.value);
(0, utils_1.assert)(algorithm === "ed25519" || algorithm === "secp256k1", `unknown pubkey type: ${algorithm}`);
return {
algorithm,
data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(value)),
};
}
else {
switch (data.type) {
// go-amino special code
case "tendermint/PubKeyEd25519":
return {
algorithm: "ed25519",
data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.value)),
};
case "tendermint/PubKeySecp256k1":
return {
algorithm: "secp256k1",
data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.value)),
};
default:
throw new Error(`unknown pubkey type: ${data.type}`);
}
}
}
function decodeValidatorUpdate(data) {
return {
pubkey: decodePubkey(encodings_1.assertObject(data.pub_key)),
votingPower: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.voting_power)),
address: encoding_1.fromHex(encodings_1.assertNotEmpty(data.address)),
proposerPriority: encodings_1.Integer.parse(data.proposer_priority),
};
}
/**

@@ -105,4 +108,4 @@ * Note: we do not parse block.time_iota_ms for now because of this CHANGELOG entry

return {
maxBytes: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.max_bytes)),
maxGas: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.max_gas)),
maxBytes: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.max_bytes)),
maxGas: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.max_gas)),
};

@@ -112,4 +115,4 @@ }

return {
maxAgeNumBlocks: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.max_age_num_blocks)),
maxAgeDuration: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.max_age_duration)),
maxAgeNumBlocks: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.max_age_num_blocks)),
maxAgeDuration: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.max_age_duration)),
};

@@ -119,12 +122,20 @@ }

return {
block: decodeBlockParams(encodings_1.assertObject(data.block)),
evidence: decodeEvidenceParams(encodings_1.assertObject(data.evidence)),
block: decodeBlockParams((0, encodings_1.assertObject)(data.block)),
evidence: decodeEvidenceParams((0, encodings_1.assertObject)(data.evidence)),
};
}
function decodeValidatorUpdate(data) {
var _a;
return {
pubkey: decodePubkey((0, encodings_1.assertObject)(data.pub_key)),
votingPower: encodings_1.Integer.parse((_a = data.power) !== null && _a !== void 0 ? _a : 0),
};
}
exports.decodeValidatorUpdate = decodeValidatorUpdate;
function decodeBlockResults(data) {
return {
height: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.height)),
height: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.height)),
results: (data.txs_results || []).map(decodeTxData),
validatorUpdates: (data.validator_updates || []).map(decodeValidatorUpdate),
consensusUpdates: encodings_1.may(decodeConsensusParams, data.consensus_param_updates),
consensusUpdates: (0, encodings_1.may)(decodeConsensusParams, data.consensus_param_updates),
beginBlockEvents: decodeEvents(data.begin_block_events || []),

@@ -136,6 +147,6 @@ endBlockEvents: decodeEvents(data.end_block_events || []),

return {
hash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.hash)),
hash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.hash)),
parts: {
total: encodings_1.assertNotEmpty(data.parts.total),
hash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.parts.hash)),
total: (0, encodings_1.assertNotEmpty)(data.parts.total),
hash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.parts.hash)),
},

@@ -154,17 +165,17 @@ };

version: decodeBlockVersion(data.version),
chainId: encodings_1.assertNotEmpty(data.chain_id),
height: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.height)),
time: dates_1.fromRfc3339WithNanoseconds(encodings_1.assertNotEmpty(data.time)),
chainId: (0, encodings_1.assertNotEmpty)(data.chain_id),
height: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.height)),
time: (0, dates_1.fromRfc3339WithNanoseconds)((0, encodings_1.assertNotEmpty)(data.time)),
// When there is no last block ID (i.e. this block's height is 1), we get an empty structure like this:
// { hash: '', parts: { total: 0, hash: '' } }
lastBlockId: data.last_block_id.hash ? decodeBlockId(data.last_block_id) : null,
lastCommitHash: encoding_1.fromHex(encodings_1.assertSet(data.last_commit_hash)),
dataHash: encoding_1.fromHex(encodings_1.assertSet(data.data_hash)),
validatorsHash: encoding_1.fromHex(encodings_1.assertSet(data.validators_hash)),
nextValidatorsHash: encoding_1.fromHex(encodings_1.assertSet(data.next_validators_hash)),
consensusHash: encoding_1.fromHex(encodings_1.assertSet(data.consensus_hash)),
appHash: encoding_1.fromHex(encodings_1.assertSet(data.app_hash)),
lastResultsHash: encoding_1.fromHex(encodings_1.assertSet(data.last_results_hash)),
evidenceHash: encoding_1.fromHex(encodings_1.assertSet(data.evidence_hash)),
proposerAddress: encoding_1.fromHex(encodings_1.assertNotEmpty(data.proposer_address)),
lastCommitHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.last_commit_hash)),
dataHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.data_hash)),
validatorsHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.validators_hash)),
nextValidatorsHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.next_validators_hash)),
consensusHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.consensus_hash)),
appHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.app_hash)),
lastResultsHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.last_results_hash)),
evidenceHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.evidence_hash)),
proposerAddress: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.proposer_address)),
};

@@ -175,5 +186,5 @@ }

blockId: decodeBlockId(data.block_id),
blockSize: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.block_size)),
blockSize: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.block_size)),
header: decodeHeader(data.header),
numTxs: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.num_txs)),
numTxs: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.num_txs)),
};

@@ -183,8 +194,11 @@ }

return {
lastHeight: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.last_height)),
blockMetas: encodings_1.assertArray(data.block_metas).map(decodeBlockMeta),
lastHeight: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.last_height)),
blockMetas: (0, encodings_1.assertArray)(data.block_metas).map(decodeBlockMeta),
};
}
function decodeBroadcastTxSync(data) {
return Object.assign(Object.assign({}, decodeTxData(data)), { hash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.hash)) });
return {
...decodeTxData(data),
hash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.hash)),
};
}

@@ -194,9 +208,9 @@ function decodeBroadcastTxCommit(data) {

height: encodings_1.Integer.parse(data.height),
hash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.hash)),
checkTx: decodeTxData(encodings_1.assertObject(data.check_tx)),
deliverTx: encodings_1.may(decodeTxData, data.deliver_tx),
hash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.hash)),
checkTx: decodeTxData((0, encodings_1.assertObject)(data.check_tx)),
deliverTx: (0, encodings_1.may)(decodeTxData, data.deliver_tx),
};
}
function decodeBlockIdFlag(blockIdFlag) {
utils_1.assert(blockIdFlag in types_1.BlockIdFlag);
(0, utils_1.assert)(blockIdFlag in types_1.BlockIdFlag);
return blockIdFlag;

@@ -212,3 +226,3 @@ }

const nonZeroTime = timestamp && !timestamp.startsWith("0001-01-01");
return nonZeroTime ? dates_1.fromRfc3339WithNanoseconds(timestamp) : undefined;
return nonZeroTime ? (0, dates_1.fromRfc3339WithNanoseconds)(timestamp) : undefined;
}

@@ -218,5 +232,5 @@ function decodeCommitSignature(data) {

blockIdFlag: decodeBlockIdFlag(data.block_id_flag),
validatorAddress: data.validator_address ? encoding_1.fromHex(data.validator_address) : undefined,
validatorAddress: data.validator_address ? (0, encoding_1.fromHex)(data.validator_address) : undefined,
timestamp: decodeOptionalTime(data.timestamp),
signature: data.signature ? encoding_1.fromBase64(data.signature) : undefined,
signature: data.signature ? (0, encoding_1.fromBase64)(data.signature) : undefined,
};

@@ -226,6 +240,6 @@ }

return {
blockId: decodeBlockId(encodings_1.assertObject(data.block_id)),
height: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.height)),
blockId: decodeBlockId((0, encodings_1.assertObject)(data.block_id)),
height: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.height)),
round: encodings_1.Integer.parse(data.round),
signatures: encodings_1.assertArray(data.signatures).map(decodeCommitSignature),
signatures: (0, encodings_1.assertArray)(data.signatures).map(decodeCommitSignature),
};

@@ -235,3 +249,3 @@ }

return {
canonical: encodings_1.assertBoolean(data.canonical),
canonical: (0, encodings_1.assertBoolean)(data.canonical),
header: decodeHeader(data.signed_header.header),

@@ -243,14 +257,15 @@ commit: decodeCommit(data.signed_header.commit),

return {
address: encoding_1.fromHex(encodings_1.assertNotEmpty(data.address)),
pubkey: decodePubkey(encodings_1.assertObject(data.pub_key)),
votingPower: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.power)),
address: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.address)),
pubkey: decodePubkey((0, encodings_1.assertObject)(data.pub_key)),
votingPower: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.power)),
};
}
exports.decodeValidatorGenesis = decodeValidatorGenesis;
function decodeGenesis(data) {
return {
genesisTime: dates_1.fromRfc3339WithNanoseconds(encodings_1.assertNotEmpty(data.genesis_time)),
chainId: encodings_1.assertNotEmpty(data.chain_id),
genesisTime: (0, dates_1.fromRfc3339WithNanoseconds)((0, encodings_1.assertNotEmpty)(data.genesis_time)),
chainId: (0, encodings_1.assertNotEmpty)(data.chain_id),
consensusParams: decodeConsensusParams(data.consensus_params),
validators: data.validators ? encodings_1.assertArray(data.validators).map(decodeValidatorGenesis) : [],
appHash: encoding_1.fromHex(encodings_1.assertSet(data.app_hash)),
validators: data.validators ? (0, encodings_1.assertArray)(data.validators).map(decodeValidatorGenesis) : [],
appHash: (0, encoding_1.fromHex)((0, encodings_1.assertSet)(data.app_hash)),
appState: data.app_state,

@@ -261,20 +276,22 @@ };

return {
pubkey: decodePubkey(encodings_1.assertObject(data.pub_key)),
votingPower: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.voting_power)),
address: encoding_1.fromHex(encodings_1.assertNotEmpty(data.address)),
pubkey: decodePubkey((0, encodings_1.assertObject)(data.pub_key)),
votingPower: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.voting_power)),
address: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.address)),
proposerPriority: data.proposer_priority ? encodings_1.Integer.parse(data.proposer_priority) : undefined,
};
}
exports.decodeValidatorInfo = decodeValidatorInfo;
function decodeNodeInfo(data) {
return {
id: encoding_1.fromHex(encodings_1.assertNotEmpty(data.id)),
listenAddr: encodings_1.assertNotEmpty(data.listen_addr),
network: encodings_1.assertNotEmpty(data.network),
version: encodings_1.assertString(data.version),
channels: encodings_1.assertNotEmpty(data.channels),
moniker: encodings_1.assertNotEmpty(data.moniker),
other: encodings_1.dictionaryToStringMap(data.other),
id: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.id)),
listenAddr: (0, encodings_1.assertNotEmpty)(data.listen_addr),
network: (0, encodings_1.assertNotEmpty)(data.network),
version: (0, encodings_1.assertString)(data.version),
channels: (0, encodings_1.assertNotEmpty)(data.channels),
moniker: (0, encodings_1.assertNotEmpty)(data.moniker),
other: (0, encodings_1.dictionaryToStringMap)(data.other),
protocolVersion: {
app: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.protocol_version.app)),
block: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.protocol_version.block)),
p2p: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.protocol_version.p2p)),
app: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.protocol_version.app)),
block: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.protocol_version.block)),
p2p: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.protocol_version.p2p)),
},

@@ -285,7 +302,7 @@ };

return {
latestBlockHash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.latest_block_hash)),
latestAppHash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.latest_app_hash)),
latestBlockTime: dates_1.fromRfc3339WithNanoseconds(encodings_1.assertNotEmpty(data.latest_block_time)),
latestBlockHeight: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.latest_block_height)),
catchingUp: encodings_1.assertBoolean(data.catching_up),
latestBlockHash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.latest_block_hash)),
latestAppHash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.latest_app_hash)),
latestBlockTime: (0, dates_1.fromRfc3339WithNanoseconds)((0, encodings_1.assertNotEmpty)(data.latest_block_time)),
latestBlockHeight: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.latest_block_height)),
catchingUp: (0, encodings_1.assertBoolean)(data.catching_up),
};

@@ -302,9 +319,9 @@ }

return {
data: encoding_1.fromBase64(encodings_1.assertNotEmpty(data.data)),
rootHash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.root_hash)),
data: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.data)),
rootHash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.root_hash)),
proof: {
total: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.proof.total)),
index: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.proof.index)),
leafHash: encoding_1.fromBase64(encodings_1.assertNotEmpty(data.proof.leaf_hash)),
aunts: encodings_1.assertArray(data.proof.aunts).map(encoding_1.fromBase64),
total: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.proof.total)),
index: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.proof.index)),
leafHash: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.proof.leaf_hash)),
aunts: (0, encodings_1.assertArray)(data.proof.aunts).map(encoding_1.fromBase64),
},

@@ -315,8 +332,8 @@ };

return {
tx: encoding_1.fromBase64(encodings_1.assertNotEmpty(data.tx)),
result: decodeTxData(encodings_1.assertObject(data.tx_result)),
height: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.height)),
index: encodings_1.Integer.parse(encodings_1.assertNumber(data.index)),
hash: encoding_1.fromHex(encodings_1.assertNotEmpty(data.hash)),
proof: encodings_1.may(decodeTxProof, data.proof),
tx: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.tx)),
result: decodeTxData((0, encodings_1.assertObject)(data.tx_result)),
height: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.height)),
index: encodings_1.Integer.parse((0, encodings_1.assertNumber)(data.index)),
hash: (0, encoding_1.fromHex)((0, encodings_1.assertNotEmpty)(data.hash)),
proof: (0, encodings_1.may)(decodeTxProof, data.proof),
};

@@ -326,14 +343,14 @@ }

return {
totalCount: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.total_count)),
txs: encodings_1.assertArray(data.txs).map(decodeTxResponse),
totalCount: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.total_count)),
txs: (0, encodings_1.assertArray)(data.txs).map(decodeTxResponse),
};
}
function decodeTxEvent(data) {
const tx = encoding_1.fromBase64(encodings_1.assertNotEmpty(data.tx));
const tx = (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.tx));
return {
tx: tx,
hash: hasher_1.hashTx(tx),
hash: (0, hasher_1.hashTx)(tx),
result: decodeTxData(data.result),
height: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.height)),
index: encodings_1.may(encodings_1.Integer.parse, data.index),
height: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.height)),
index: (0, encodings_1.may)(encodings_1.Integer.parse, data.index),
};

@@ -343,28 +360,19 @@ }

return {
blockHeight: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.block_height)),
validators: encodings_1.assertArray(data.validators).map(decodeValidatorUpdate),
count: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.count)),
total: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.total)),
blockHeight: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.block_height)),
validators: (0, encodings_1.assertArray)(data.validators).map(decodeValidatorInfo),
count: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.count)),
total: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.total)),
};
}
function decodeEvidence(data) {
return {
type: encodings_1.assertNotEmpty(data.type),
height: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.height)),
time: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.time)),
totalVotingPower: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.totalVotingPower)),
validator: decodeValidatorUpdate(data.validator),
};
}
function decodeEvidences(ev) {
return encodings_1.assertArray(ev).map(decodeEvidence);
}
function decodeBlock(data) {
var _a, _b;
return {
header: decodeHeader(encodings_1.assertObject(data.header)),
header: decodeHeader((0, encodings_1.assertObject)(data.header)),
// For the block at height 1, last commit is not set. This is represented in an empty object like this:
// { height: '0', round: 0, block_id: { hash: '', parts: [Object] }, signatures: [] }
lastCommit: data.last_commit.block_id.hash ? decodeCommit(encodings_1.assertObject(data.last_commit)) : null,
txs: data.data.txs ? encodings_1.assertArray(data.data.txs).map(encoding_1.fromBase64) : [],
evidence: data.evidence && encodings_1.may(decodeEvidences, data.evidence.evidence),
lastCommit: data.last_commit.block_id.hash ? decodeCommit((0, encodings_1.assertObject)(data.last_commit)) : null,
txs: data.data.txs ? (0, encodings_1.assertArray)(data.data.txs).map(encoding_1.fromBase64) : [],
// Lift up .evidence.evidence to just .evidence
// See https://github.com/tendermint/tendermint/issues/7697
evidence: (_b = (_a = data.evidence) === null || _a === void 0 ? void 0 : _a.evidence) !== null && _b !== void 0 ? _b : [],
};

@@ -380,12 +388,18 @@ }

return {
totalCount: encodings_1.Integer.parse(encodings_1.assertNotEmpty(data.total_count)),
blocks: encodings_1.assertArray(data.blocks).map(decodeBlockResponse),
totalCount: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.total_count)),
blocks: (0, encodings_1.assertArray)(data.blocks).map(decodeBlockResponse),
};
}
function decodeNumUnconfirmedTxs(data) {
return {
total: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.total)),
totalBytes: encodings_1.Integer.parse((0, encodings_1.assertNotEmpty)(data.total_bytes)),
};
}
class Responses {
static decodeAbciInfo(response) {
return decodeAbciInfo(encodings_1.assertObject(response.result.response));
return decodeAbciInfo((0, encodings_1.assertObject)(response.result.response));
}
static decodeAbciQuery(response) {
return decodeAbciQuery(encodings_1.assertObject(response.result.response));
return decodeAbciQuery((0, encodings_1.assertObject)(response.result.response));
}

@@ -417,3 +431,3 @@ static decodeBlock(response) {

static decodeGenesis(response) {
return decodeGenesis(encodings_1.assertObject(response.result.genesis));
return decodeGenesis((0, encodings_1.assertObject)(response.result.genesis));
}

@@ -423,2 +437,5 @@ static decodeHealth() {

}
static decodeNumUnconfirmedTxs(response) {
return decodeNumUnconfirmedTxs(response.result);
}
static decodeStatus(response) {

@@ -425,0 +442,0 @@ return decodeStatus(response.result);

@@ -24,2 +24,3 @@ import { JsonRpcRequest, JsonRpcSuccessResponse } from "@cosmjs/json-rpc";

readonly encodeHealth: (req: requests.HealthRequest) => JsonRpcRequest;
readonly encodeNumUnconfirmedTxs: (req: requests.NumUnconfirmedTxsRequest) => JsonRpcRequest;
readonly encodeStatus: (req: requests.StatusRequest) => JsonRpcRequest;

@@ -44,2 +45,3 @@ readonly encodeSubscribe: (req: requests.SubscribeRequest) => JsonRpcRequest;

readonly decodeHealth: (response: JsonRpcSuccessResponse) => responses.HealthResponse;
readonly decodeNumUnconfirmedTxs: (response: JsonRpcSuccessResponse) => responses.NumUnconfirmedTxsResponse;
readonly decodeStatus: (response: JsonRpcSuccessResponse) => responses.StatusResponse;

@@ -46,0 +48,0 @@ readonly decodeTx: (response: JsonRpcSuccessResponse) => responses.TxResponse;

@@ -153,3 +153,3 @@ "use strict";

function encodeString(s) {
const utf8 = encoding_1.toUtf8(s);
const utf8 = (0, encoding_1.toUtf8)(s);
return Uint8Array.from([utf8.length, ...utf8]);

@@ -156,0 +156,0 @@ }

@@ -8,5 +8,5 @@ "use strict";

it("works", () => {
expect(encodings_1.encodeString("")).toEqual(Uint8Array.from([0]));
expect((0, encodings_1.encodeString)("")).toEqual(Uint8Array.from([0]));
const str = "hello iov";
expect(encodings_1.encodeString(str)).toEqual(Uint8Array.from([str.length, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x69, 0x6f, 0x76]));
expect((0, encodings_1.encodeString)(str)).toEqual(Uint8Array.from([str.length, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x69, 0x6f, 0x76]));
});

@@ -16,8 +16,8 @@ });

it("works", () => {
expect(encodings_1.encodeInt(0)).toEqual(Uint8Array.from([0]));
expect(encodings_1.encodeInt(1)).toEqual(Uint8Array.from([1]));
expect(encodings_1.encodeInt(127)).toEqual(Uint8Array.from([127]));
expect(encodings_1.encodeInt(128)).toEqual(Uint8Array.from([128, 1]));
expect(encodings_1.encodeInt(255)).toEqual(Uint8Array.from([255, 1]));
expect(encodings_1.encodeInt(256)).toEqual(Uint8Array.from([128, 2]));
expect((0, encodings_1.encodeInt)(0)).toEqual(Uint8Array.from([0]));
expect((0, encodings_1.encodeInt)(1)).toEqual(Uint8Array.from([1]));
expect((0, encodings_1.encodeInt)(127)).toEqual(Uint8Array.from([127]));
expect((0, encodings_1.encodeInt)(128)).toEqual(Uint8Array.from([128, 1]));
expect((0, encodings_1.encodeInt)(255)).toEqual(Uint8Array.from([255, 1]));
expect((0, encodings_1.encodeInt)(256)).toEqual(Uint8Array.from([128, 2]));
});

@@ -29,3 +29,3 @@ });

readonlyDateWithNanoseconds.nanoseconds = 666666;
expect(encodings_1.encodeTime(readonlyDateWithNanoseconds)).toEqual(Uint8Array.from([0x08, 173, 174, 89, 0x10, 170, 220, 215, 95]));
expect((0, encodings_1.encodeTime)(readonlyDateWithNanoseconds)).toEqual(Uint8Array.from([0x08, 173, 174, 89, 0x10, 170, 220, 215, 95]));
});

@@ -35,5 +35,5 @@ });

it("works", () => {
expect(encodings_1.encodeBytes(Uint8Array.from([]))).toEqual(Uint8Array.from([]));
expect((0, encodings_1.encodeBytes)(Uint8Array.from([]))).toEqual(Uint8Array.from([]));
const uint8Array = Uint8Array.from([1, 2, 3, 4, 5, 6, 7]);
expect(encodings_1.encodeBytes(uint8Array)).toEqual(Uint8Array.from([uint8Array.length, 1, 2, 3, 4, 5, 6, 7]));
expect((0, encodings_1.encodeBytes)(uint8Array)).toEqual(Uint8Array.from([uint8Array.length, 1, 2, 3, 4, 5, 6, 7]));
});

@@ -47,3 +47,3 @@ });

};
expect(encodings_1.encodeVersion(version)).toEqual(Uint8Array.from([0x08, 170, 216, 40, 0x10, 200, 1]));
expect((0, encodings_1.encodeVersion)(version)).toEqual(Uint8Array.from([0x08, 170, 216, 40, 0x10, 200, 1]));
});

@@ -60,3 +60,3 @@ });

};
expect(encodings_1.encodeBlockId(blockId)).toEqual(Uint8Array.from([
expect((0, encodings_1.encodeBlockId)(blockId)).toEqual(Uint8Array.from([
0x0a,

@@ -63,0 +63,0 @@ blockId.hash.length,

@@ -9,3 +9,3 @@ "use strict";

function hashTx(tx) {
return crypto_1.sha256(tx);
return (0, crypto_1.sha256)(tx);
}

@@ -51,16 +51,16 @@ exports.hashTx = hashTx;

const encodedFields = [
encodings_1.encodeVersion(header.version),
encodings_1.encodeString(header.chainId),
encodings_1.encodeInt(header.height),
encodings_1.encodeTime(header.time),
encodings_1.encodeBlockId(header.lastBlockId),
encodings_1.encodeBytes(header.lastCommitHash),
encodings_1.encodeBytes(header.dataHash),
encodings_1.encodeBytes(header.validatorsHash),
encodings_1.encodeBytes(header.nextValidatorsHash),
encodings_1.encodeBytes(header.consensusHash),
encodings_1.encodeBytes(header.appHash),
encodings_1.encodeBytes(header.lastResultsHash),
encodings_1.encodeBytes(header.evidenceHash),
encodings_1.encodeBytes(header.proposerAddress),
(0, encodings_1.encodeVersion)(header.version),
(0, encodings_1.encodeString)(header.chainId),
(0, encodings_1.encodeInt)(header.height),
(0, encodings_1.encodeTime)(header.time),
(0, encodings_1.encodeBlockId)(header.lastBlockId),
(0, encodings_1.encodeBytes)(header.lastCommitHash),
(0, encodings_1.encodeBytes)(header.dataHash),
(0, encodings_1.encodeBytes)(header.validatorsHash),
(0, encodings_1.encodeBytes)(header.nextValidatorsHash),
(0, encodings_1.encodeBytes)(header.consensusHash),
(0, encodings_1.encodeBytes)(header.appHash),
(0, encodings_1.encodeBytes)(header.lastResultsHash),
(0, encodings_1.encodeBytes)(header.evidenceHash),
(0, encodings_1.encodeBytes)(header.proposerAddress),
];

@@ -67,0 +67,0 @@ return hashTree(encodedFields);

@@ -10,5 +10,5 @@ "use strict";

// curl "http://localhost:11127/tx_search?query=\"tx.hash='5CB2CF94A1097A4BC19258BC2353C3E76102B6D528458BE45C855DC5563C1DB2'\""
const txId = encoding_1.fromHex("5CB2CF94A1097A4BC19258BC2353C3E76102B6D528458BE45C855DC5563C1DB2");
const txData = encoding_1.fromBase64("YUpxZDY2NURaUDMxPWd2TzBPdnNrVWFWYg==");
expect(hasher_1.hashTx(txData)).toEqual(txId);
const txId = (0, encoding_1.fromHex)("5CB2CF94A1097A4BC19258BC2353C3E76102B6D528458BE45C855DC5563C1DB2");
const txData = (0, encoding_1.fromBase64)("YUpxZDY2NURaUDMxPWd2TzBPdnNrVWFWYg==");
expect((0, hasher_1.hashTx)(txData)).toEqual(txId);
});

@@ -18,3 +18,3 @@ it("creates block hash equal to local test for empty block", () => {

// curl "http://localhost:11133/block"
const blockId = encoding_1.fromHex("153C484DCBC33633F0616BC019388C93DEA94F7880627976F2BFE83749E062F7");
const blockId = (0, encoding_1.fromHex)("153C484DCBC33633F0616BC019388C93DEA94F7880627976F2BFE83749E062F7");
const time = new readonly_date_1.ReadonlyDate("2020-06-23T13:54:15.4638668Z");

@@ -31,19 +31,19 @@ time.nanoseconds = 866800;

lastBlockId: {
hash: encoding_1.fromHex("1EC48444E64E7B96585BA518613612E52B976E3DA2F2222B9CD4D1602656C96F"),
hash: (0, encoding_1.fromHex)("1EC48444E64E7B96585BA518613612E52B976E3DA2F2222B9CD4D1602656C96F"),
parts: {
total: 1,
hash: encoding_1.fromHex("D4E6F1B0EE08D0438C9BB8455D7D3F2FC1883C32D66F7C69C4A0F093B073F6D2"),
hash: (0, encoding_1.fromHex)("D4E6F1B0EE08D0438C9BB8455D7D3F2FC1883C32D66F7C69C4A0F093B073F6D2"),
},
},
lastCommitHash: encoding_1.fromHex("BA6A5EEA6687ACA8EE4FFE4F5D40EA073CB7397A5336309C3EC824805AF9723E"),
dataHash: encoding_1.fromHex(""),
validatorsHash: encoding_1.fromHex("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
nextValidatorsHash: encoding_1.fromHex("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
consensusHash: encoding_1.fromHex("048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F"),
appHash: encoding_1.fromHex("8801000000000000"),
lastResultsHash: encoding_1.fromHex(""),
evidenceHash: encoding_1.fromHex(""),
proposerAddress: encoding_1.fromHex("614F305502F65C01114F9B8711D9A0AB0AC369F4"),
lastCommitHash: (0, encoding_1.fromHex)("BA6A5EEA6687ACA8EE4FFE4F5D40EA073CB7397A5336309C3EC824805AF9723E"),
dataHash: (0, encoding_1.fromHex)(""),
validatorsHash: (0, encoding_1.fromHex)("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
nextValidatorsHash: (0, encoding_1.fromHex)("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
consensusHash: (0, encoding_1.fromHex)("048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F"),
appHash: (0, encoding_1.fromHex)("8801000000000000"),
lastResultsHash: (0, encoding_1.fromHex)(""),
evidenceHash: (0, encoding_1.fromHex)(""),
proposerAddress: (0, encoding_1.fromHex)("614F305502F65C01114F9B8711D9A0AB0AC369F4"),
};
expect(hasher_1.hashBlock(blockData)).toEqual(blockId);
expect((0, hasher_1.hashBlock)(blockData)).toEqual(blockId);
});

@@ -53,3 +53,3 @@ it("creates block hash equal to local test for block with a transaction", () => {

// curl "http://localhost:11133/block?height=13575"
const blockId = encoding_1.fromHex("FF2995AF1F38B9A584077E53B5E144778718FB86539A51886A2C55F730403373");
const blockId = (0, encoding_1.fromHex)("FF2995AF1F38B9A584077E53B5E144778718FB86539A51886A2C55F730403373");
const time = new readonly_date_1.ReadonlyDate("2020-06-23T15:34:12.3232688Z");

@@ -66,21 +66,21 @@ time.nanoseconds = 268800;

lastBlockId: {
hash: encoding_1.fromHex("046D5441FC4D008FCDBF9F3DD5DC25CF00883763E44CF4FAF3923FB5FEA42D8F"),
hash: (0, encoding_1.fromHex)("046D5441FC4D008FCDBF9F3DD5DC25CF00883763E44CF4FAF3923FB5FEA42D8F"),
parts: {
total: 1,
hash: encoding_1.fromHex("02E4715343625093C717638EAC67FB3A4B24CCC8DA610E0CB324D705E68FEF7B"),
hash: (0, encoding_1.fromHex)("02E4715343625093C717638EAC67FB3A4B24CCC8DA610E0CB324D705E68FEF7B"),
},
},
lastCommitHash: encoding_1.fromHex("AA2B807F3B0ACC866AB58D90C2D0FC70B6C860CFAC440590B4F590CDC178A207"),
dataHash: encoding_1.fromHex("56782879F526889734BA65375CD92A9152C7114B2C91B2D2AD8464FF69E884AA"),
validatorsHash: encoding_1.fromHex("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
nextValidatorsHash: encoding_1.fromHex("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
consensusHash: encoding_1.fromHex("048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F"),
appHash: encoding_1.fromHex("CC02000000000000"),
lastResultsHash: encoding_1.fromHex("6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D"),
evidenceHash: encoding_1.fromHex(""),
proposerAddress: encoding_1.fromHex("614F305502F65C01114F9B8711D9A0AB0AC369F4"),
lastCommitHash: (0, encoding_1.fromHex)("AA2B807F3B0ACC866AB58D90C2D0FC70B6C860CFAC440590B4F590CDC178A207"),
dataHash: (0, encoding_1.fromHex)("56782879F526889734BA65375CD92A9152C7114B2C91B2D2AD8464FF69E884AA"),
validatorsHash: (0, encoding_1.fromHex)("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
nextValidatorsHash: (0, encoding_1.fromHex)("0BEEBC6AB3B7D4FE21E22B609CD4AEC7E121A42C07604FF1827651F0173745EB"),
consensusHash: (0, encoding_1.fromHex)("048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F"),
appHash: (0, encoding_1.fromHex)("CC02000000000000"),
lastResultsHash: (0, encoding_1.fromHex)("6E340B9CFFB37A989CA544E6BB780A2C78901D3FB33738768511A30617AFA01D"),
evidenceHash: (0, encoding_1.fromHex)(""),
proposerAddress: (0, encoding_1.fromHex)("614F305502F65C01114F9B8711D9A0AB0AC369F4"),
};
expect(hasher_1.hashBlock(blockData)).toEqual(blockId);
expect((0, hasher_1.hashBlock)(blockData)).toEqual(blockId);
});
});
//# sourceMappingURL=hasher.spec.js.map

@@ -0,3 +1,3 @@

export { AbciInfoRequest, AbciQueryParams, AbciQueryRequest, BlockchainRequest, BlockRequest, BlockResultsRequest, BlockSearchParams, BlockSearchRequest, BroadcastTxParams, BroadcastTxRequest, CommitRequest, GenesisRequest, HealthRequest, Method, NumUnconfirmedTxsRequest, QueryTag, Request, StatusRequest, SubscriptionEventType, TxParams, TxRequest, TxSearchParams, TxSearchRequest, ValidatorsParams, ValidatorsRequest, } from "./requests";
export { AbciInfoResponse, AbciQueryResponse, Attribute, Block, BlockchainResponse, BlockGossipParams, BlockId, BlockMeta, BlockParams, BlockResponse, BlockResultsResponse, BlockSearchResponse, BroadcastTxAsyncResponse, BroadcastTxCommitResponse, broadcastTxCommitSuccess, BroadcastTxSyncResponse, broadcastTxSyncSuccess, Commit, CommitResponse, ConsensusParams, Event, Evidence, EvidenceParams, GenesisResponse, Header, HealthResponse, NewBlockEvent, NewBlockHeaderEvent, NodeInfo, NumUnconfirmedTxsResponse, ProofOp, QueryProof, Response, StatusResponse, SyncInfo, TxData, TxEvent, TxProof, TxResponse, TxSearchResponse, TxSizeParams, Validator, ValidatorsResponse, Version, Vote, VoteType, } from "./responses";
export { Tendermint34Client } from "./tendermint34client";
export { AbciInfoRequest, AbciQueryParams, AbciQueryRequest, BlockRequest, BlockchainRequest, BlockSearchParams, BlockSearchRequest, BlockResultsRequest, BroadcastTxRequest, BroadcastTxParams, CommitRequest, GenesisRequest, HealthRequest, Method, Request, QueryTag, StatusRequest, SubscriptionEventType, TxParams, TxRequest, TxSearchParams, TxSearchRequest, ValidatorsRequest, ValidatorsParams, } from "./requests";
export { AbciInfoResponse, AbciQueryResponse, Attribute, Block, BlockchainResponse, BlockGossipParams, BlockId, BlockMeta, BlockParams, BlockResponse, BlockResultsResponse, BlockSearchResponse, BroadcastTxAsyncResponse, BroadcastTxCommitResponse, broadcastTxCommitSuccess, BroadcastTxSyncResponse, broadcastTxSyncSuccess, Commit, CommitResponse, ConsensusParams, Event, Evidence, EvidenceParams, GenesisResponse, Header, HealthResponse, NewBlockEvent, NewBlockHeaderEvent, NodeInfo, ProofOp, QueryProof, Response, StatusResponse, SyncInfo, TxData, TxEvent, TxProof, TxResponse, TxSearchResponse, TxSizeParams, Validator, ValidatorsResponse, Version, Vote, VoteType, } from "./responses";

@@ -5,5 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.VoteType = exports.broadcastTxSyncSuccess = exports.broadcastTxCommitSuccess = exports.SubscriptionEventType = exports.Method = exports.Tendermint34Client = void 0;
var tendermint34client_1 = require("./tendermint34client");
Object.defineProperty(exports, "Tendermint34Client", { enumerable: true, get: function () { return tendermint34client_1.Tendermint34Client; } });
exports.Tendermint34Client = exports.VoteType = exports.broadcastTxSyncSuccess = exports.broadcastTxCommitSuccess = exports.SubscriptionEventType = exports.Method = void 0;
var requests_1 = require("./requests");

@@ -16,2 +14,4 @@ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return requests_1.Method; } });

Object.defineProperty(exports, "VoteType", { enumerable: true, get: function () { return responses_1.VoteType; } });
var tendermint34client_1 = require("./tendermint34client");
Object.defineProperty(exports, "Tendermint34Client", { enumerable: true, get: function () { return tendermint34client_1.Tendermint34Client; } });
//# sourceMappingURL=index.js.map

@@ -20,2 +20,3 @@ /**

Health = "health",
NumUnconfirmedTxs = "num_unconfirmed_txs",
Status = "status",

@@ -28,3 +29,3 @@ Subscribe = "subscribe",

}
export declare type Request = AbciInfoRequest | AbciQueryRequest | BlockRequest | BlockSearchRequest | BlockchainRequest | BlockResultsRequest | BroadcastTxRequest | CommitRequest | GenesisRequest | HealthRequest | StatusRequest | TxRequest | TxSearchRequest | ValidatorsRequest;
export declare type Request = AbciInfoRequest | AbciQueryRequest | BlockRequest | BlockSearchRequest | BlockchainRequest | BlockResultsRequest | BroadcastTxRequest | CommitRequest | GenesisRequest | HealthRequest | NumUnconfirmedTxsRequest | StatusRequest | TxRequest | TxSearchRequest | ValidatorsRequest;
/**

@@ -108,2 +109,5 @@ * Raw values must match the tendermint event name

}
export interface NumUnconfirmedTxsRequest {
readonly method: Method.NumUnconfirmedTxs;
}
export interface StatusRequest {

@@ -110,0 +114,0 @@ readonly method: Method.Status;

@@ -25,2 +25,3 @@ "use strict";

Method["Health"] = "health";
Method["NumUnconfirmedTxs"] = "num_unconfirmed_txs";
Method["Status"] = "status";

@@ -27,0 +28,0 @@ Method["Subscribe"] = "subscribe";

@@ -7,11 +7,11 @@ "use strict";

it("works for no input", () => {
const query = requests_1.buildQuery({});
const query = (0, requests_1.buildQuery)({});
expect(query).toEqual("");
});
it("works for one tags", () => {
const query = requests_1.buildQuery({ tags: [{ key: "abc", value: "def" }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "abc", value: "def" }] });
expect(query).toEqual("abc='def'");
});
it("works for two tags", () => {
const query = requests_1.buildQuery({
const query = (0, requests_1.buildQuery)({
tags: [

@@ -25,7 +25,7 @@ { key: "k", value: "9" },

it("works for raw input", () => {
const query = requests_1.buildQuery({ raw: "aabbCCDD" });
const query = (0, requests_1.buildQuery)({ raw: "aabbCCDD" });
expect(query).toEqual("aabbCCDD");
});
it("works for mixed input", () => {
const query = requests_1.buildQuery({
const query = (0, requests_1.buildQuery)({
tags: [

@@ -32,0 +32,0 @@ { key: "k", value: "9" },

import { ReadonlyDate } from "readonly-date";
import { ReadonlyDateWithNanoseconds } from "../dates";
import { CommitSignature, ValidatorPubkey } from "../types";
export declare type Response = AbciInfoResponse | AbciQueryResponse | BlockResponse | BlockResultsResponse | BlockchainResponse | BroadcastTxAsyncResponse | BroadcastTxSyncResponse | BroadcastTxCommitResponse | CommitResponse | GenesisResponse | HealthResponse | StatusResponse | TxResponse | TxSearchResponse | ValidatorsResponse;
export declare type Response = AbciInfoResponse | AbciQueryResponse | BlockResponse | BlockResultsResponse | BlockSearchResponse | BlockchainResponse | BroadcastTxAsyncResponse | BroadcastTxSyncResponse | BroadcastTxCommitResponse | CommitResponse | GenesisResponse | HealthResponse | NumUnconfirmedTxsResponse | StatusResponse | TxResponse | TxSearchResponse | ValidatorsResponse;
export interface AbciInfoResponse {

@@ -34,3 +34,3 @@ readonly data?: string;

readonly results: readonly TxData[];
readonly validatorUpdates: readonly Validator[];
readonly validatorUpdates: readonly ValidatorUpdate[];
readonly consensusUpdates?: ConsensusParams;

@@ -48,4 +48,7 @@ readonly beginBlockEvents: readonly Event[];

}
/** No data in here because RPC method BroadcastTxAsync "returns right away, with no response" */
/**
* No transaction data in here because RPC method BroadcastTxAsync "returns right away, with no response"
*/
export interface BroadcastTxAsyncResponse {
readonly hash: Uint8Array;
}

@@ -84,2 +87,6 @@ export interface BroadcastTxSyncResponse extends TxData {

export declare type HealthResponse = null;
export interface NumUnconfirmedTxsResponse {
readonly total: number;
readonly totalBytes: number;
}
export interface StatusResponse {

@@ -173,11 +180,11 @@ readonly nodeInfo: NodeInfo;

readonly txs: readonly Uint8Array[];
readonly evidence?: readonly Evidence[];
readonly evidence: readonly Evidence[];
}
export interface Evidence {
readonly type: string;
readonly validator: Validator;
readonly height: number;
readonly time: number;
readonly totalVotingPower: number;
}
/**
* We lost track on how the evidence structure actually looks like.
* This is any now and passed to the caller untouched.
*
* See also https://github.com/cosmos/cosmjs/issues/980.
*/
export declare type Evidence = any;
export interface Commit {

@@ -274,2 +281,6 @@ readonly blockId: BlockId;

}
export interface ValidatorUpdate {
readonly pubkey: ValidatorPubkey;
readonly votingPower: number;
}
export interface ConsensusParams {

@@ -276,0 +287,0 @@ readonly block: BlockParams;

import { Stream } from "xstream";
import { RpcClient } from "../rpcclients";
import { HttpEndpoint, RpcClient } from "../rpcclients";
import * as requests from "./requests";

@@ -11,3 +11,3 @@ import * as responses from "./responses";

*/
static connect(url: string): Promise<Tendermint34Client>;
static connect(endpoint: string | HttpEndpoint): Promise<Tendermint34Client>;
/**

@@ -68,2 +68,3 @@ * Creates a new Tendermint client given an RPC client.

health(): Promise<responses.HealthResponse>;
numUnconfirmedTxs(): Promise<responses.NumUnconfirmedTxsResponse>;
status(): Promise<responses.StatusResponse>;

@@ -70,0 +71,0 @@ subscribeNewBlock(): Stream<responses.NewBlockEvent>;

@@ -41,6 +41,11 @@ "use strict";

*/
static async connect(url) {
const useHttp = url.startsWith("http://") || url.startsWith("https://");
const rpcClient = useHttp ? new rpcclients_1.HttpClient(url) : new rpcclients_1.WebsocketClient(url);
return Tendermint34Client.create(rpcClient);
static async connect(endpoint) {
if (typeof endpoint === "object") {
return Tendermint34Client.create(new rpcclients_1.HttpClient(endpoint));
}
else {
const useHttp = endpoint.startsWith("http://") || endpoint.startsWith("https://");
const rpcClient = useHttp ? new rpcclients_1.HttpClient(endpoint) : new rpcclients_1.WebsocketClient(endpoint);
return Tendermint34Client.create(rpcClient);
}
}

@@ -59,3 +64,3 @@ /**

static async detectVersion(client) {
const req = jsonrpc_1.createJsonRpcRequest(requests.Method.Status);
const req = (0, jsonrpc_1.createJsonRpcRequest)(requests.Method.Status);
const response = await client.execute(req);

@@ -105,5 +110,7 @@ const result = response.result;

const resp = await this.doCall(query, this.p.encodeBlockSearch, this.r.decodeBlockSearch);
return Object.assign(Object.assign({}, resp), {
return {
...resp,
// make sure we sort by height, as tendermint may be sorting by string value of the height
blocks: [...resp.blocks].sort((a, b) => a.block.header.height - b.block.header.height) });
blocks: [...resp.blocks].sort((a, b) => a.block.header.height - b.block.header.height),
};
}

@@ -120,3 +127,3 @@ // this should paginate through all blockSearch options to ensure it returns all results.

while (!done) {
const resp = await this.blockSearch(Object.assign(Object.assign({}, params), { page: page }));
const resp = await this.blockSearch({ ...params, page: page });
blocks.push(...resp.blocks);

@@ -193,2 +200,6 @@ if (blocks.length < resp.totalCount) {

}
async numUnconfirmedTxs() {
const query = { method: requests.Method.NumUnconfirmedTxs };
return this.doCall(query, this.p.encodeNumUnconfirmedTxs, this.r.decodeNumUnconfirmedTxs);
}
async status() {

@@ -247,3 +258,3 @@ const query = { method: requests.Method.Status };

while (!done) {
const resp = await this.txSearch(Object.assign(Object.assign({}, params), { page: page }));
const resp = await this.txSearch({ ...params, page: page });
txs.push(...resp.txs);

@@ -304,3 +315,3 @@ if (txs.length < resp.totalCount) {

subscribe(request, decode) {
if (!rpcclients_1.instanceOfRpcStreamingClient(this.client)) {
if (!(0, rpcclients_1.instanceOfRpcStreamingClient)(this.client)) {
throw new Error("This RPC client type cannot subscribe to events");

@@ -307,0 +318,0 @@ }

@@ -37,3 +37,3 @@ "use strict";

it("can auto-discover Tendermint version and communicate", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -45,3 +45,3 @@ const info = await client.abciInfo();

it("can connect to Tendermint with known version", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -53,3 +53,3 @@ expect(await client.abciInfo()).toBeTruthy();

it("can get genesis", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -62,5 +62,5 @@ const genesis = await client.genesis();

it("can broadcast a transaction", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const tx = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const tx = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const response = await client.broadcastTxCommit({ tx: tx });

@@ -80,5 +80,5 @@ expect(response.height).toBeGreaterThan(2);

it("can broadcast a transaction", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const tx = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const tx = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const response = await client.broadcastTxSync({ tx: tx });

@@ -94,7 +94,6 @@ expect(response.hash.length).toEqual(32);

it("can broadcast a transaction", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const tx = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const tx = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const response = await client.broadcastTxAsync({ tx: tx });
// TODO: Remove any cast after https://github.com/cosmos/cosmjs/issues/938
expect(response.hash.length).toEqual(32);

@@ -105,5 +104,5 @@ client.disconnect();

it("gets the same tx hash from backend as calculated locally", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const tx = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const tx = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const calculatedTxHash = adaptor_1.adaptor34.hashTx(tx);

@@ -115,9 +114,9 @@ const response = await client.broadcastTxCommit({ tx: tx });

it("can query the state", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const key = testutil_spec_1.randomString();
const value = testutil_spec_1.randomString();
await client.broadcastTxCommit({ tx: testutil_spec_1.buildKvTx(key, value) });
const binKey = encoding_1.toAscii(key);
const binValue = encoding_1.toAscii(value);
const key = (0, testutil_spec_1.randomString)();
const value = (0, testutil_spec_1.randomString)();
await client.broadcastTxCommit({ tx: (0, testutil_spec_1.buildKvTx)(key, value) });
const binKey = (0, encoding_1.toAscii)(key);
const binValue = (0, encoding_1.toAscii)(value);
const queryParams = { path: "/key", data: binKey, prove: true };

@@ -132,3 +131,3 @@ const response = await client.abciQuery(queryParams);

var _a, _b;
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -145,3 +144,3 @@ const response = await client.commit(4);

it("can get validators", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -161,3 +160,3 @@ const response = await client.validators({});

it("can get all validators", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -177,3 +176,3 @@ const response = await client.validatorsAll();

it("can call a bunch of methods", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -187,3 +186,3 @@ expect(await client.block()).toBeTruthy();

it("works", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -210,5 +209,15 @@ const status = await client.status();

});
describe("numUnconfirmedTxs", () => {
it("works", async () => {
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const response = await client.numUnconfirmedTxs();
expect(response.total).toBeGreaterThanOrEqual(0);
expect(response.totalBytes).toBeGreaterThanOrEqual(0);
client.disconnect();
});
});
describe("blockResults", () => {
it("works", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -226,7 +235,7 @@ const height = 3;

beforeAll(async () => {
if (testutil_spec_1.tendermintEnabled()) {
if ((0, testutil_spec_1.tendermintEnabled)()) {
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
// eslint-disable-next-line no-inner-declarations
async function sendTx() {
const tx = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const tx = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const txRes = await client.broadcastTxCommit({ tx: tx });

@@ -242,9 +251,9 @@ expect(responses.broadcastTxCommitSuccess(txRes)).toEqual(true);

client.disconnect();
await testutil_spec_1.tendermintSearchIndexUpdated();
await (0, testutil_spec_1.tendermintSearchIndexUpdated)();
}
});
it("can paginate over blockSearch results", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
const query = (0, requests_1.buildQuery)({ raw: "block.height >= 1 AND block.height <= 3" });
// expect one page of results

@@ -261,5 +270,5 @@ const s1 = await client.blockSearch({ query: query, page: 1, per_page: 2 });

it("can get all search results in one call", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
const query = (0, requests_1.buildQuery)({ raw: "block.height >= 1 AND block.height <= 3" });
const sall = await client.blockSearchAll({ query: query, per_page: 2 });

@@ -277,3 +286,3 @@ expect(sall.totalCount).toEqual(3);

it("returns latest in descending order by default", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -291,3 +300,3 @@ // Run in parallel to increase chance there is no block between the calls

it("can limit by maxHeight", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -303,3 +312,3 @@ const height = (await client.status()).syncInfo.latestBlockHeight;

it("works with maxHeight in the future", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -315,3 +324,3 @@ const height = (await client.status()).syncInfo.latestBlockHeight;

it("can limit by minHeight and maxHeight", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -327,3 +336,3 @@ const height = (await client.status()).syncInfo.latestBlockHeight;

it("contains all the info", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

@@ -350,7 +359,7 @@ const height = (await client.status()).syncInfo.latestBlockHeight;

it("can query a tx properly", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const find = testutil_spec_1.randomString();
const me = testutil_spec_1.randomString();
const tx = testutil_spec_1.buildKvTx(find, me);
const find = (0, testutil_spec_1.randomString)();
const me = (0, testutil_spec_1.randomString)();
const tx = (0, testutil_spec_1.buildKvTx)(find, me);
const txRes = await client.broadcastTxCommit({ tx: tx });

@@ -362,3 +371,3 @@ expect(responses.broadcastTxCommitSuccess(txRes)).toEqual(true);

const hash = txRes.hash;
await testutil_spec_1.tendermintSearchIndexUpdated();
await (0, testutil_spec_1.tendermintSearchIndexUpdated)();
// find by hash - does it match?

@@ -374,3 +383,3 @@ const r = await client.tx({ hash: hash, prove: true });

// tendermint, else you get empty results
const query = requests_1.buildQuery({ tags: [{ key: "app.key", value: find }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "app.key", value: find }] });
const s = await client.txSearch({ query: query, page: 1, per_page: 30 });

@@ -381,3 +390,3 @@ // should find the tx

// except without the proof
expect(s.txs[0]).toEqual(Object.assign(Object.assign({}, r), { proof: undefined }));
expect(s.txs[0]).toEqual({ ...r, proof: undefined });
// ensure txSearchAll works as well

@@ -389,3 +398,3 @@ const sall = await client.txSearchAll({ query: query });

// except without the proof
expect(sall.txs[0]).toEqual(Object.assign(Object.assign({}, r), { proof: undefined }));
expect(sall.txs[0]).toEqual({ ...r, proof: undefined });
// and let's query the block itself to see this transaction

@@ -399,10 +408,10 @@ const block = await client.block(height);

describe("txSearch", () => {
const key = testutil_spec_1.randomString();
const key = (0, testutil_spec_1.randomString)();
beforeAll(async () => {
if (testutil_spec_1.tendermintEnabled()) {
if ((0, testutil_spec_1.tendermintEnabled)()) {
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
// eslint-disable-next-line no-inner-declarations
async function sendTx() {
const me = testutil_spec_1.randomString();
const tx = testutil_spec_1.buildKvTx(key, me);
const me = (0, testutil_spec_1.randomString)();
const tx = (0, testutil_spec_1.buildKvTx)(key, me);
const txRes = await client.broadcastTxCommit({ tx: tx });

@@ -418,3 +427,3 @@ expect(responses.broadcastTxCommitSuccess(txRes)).toEqual(true);

client.disconnect();
await testutil_spec_1.tendermintSearchIndexUpdated();
await (0, testutil_spec_1.tendermintSearchIndexUpdated)();
}

@@ -426,5 +435,5 @@ });

// Code: https://github.com/tendermint/tendermint/blob/v0.34.10/rpc/core/tx.go#L89
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ tags: [{ key: "app.key", value: key }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "app.key", value: key }] });
const s = await client.txSearch({ query: query });

@@ -439,5 +448,5 @@ expect(s.totalCount).toEqual(3);

it("can set the order", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ tags: [{ key: "app.key", value: key }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "app.key", value: key }] });
const s1 = await client.txSearch({ query: query, order_by: "desc" });

@@ -450,5 +459,5 @@ const s2 = await client.txSearch({ query: query, order_by: "asc" });

it("can paginate over txSearch results", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ tags: [{ key: "app.key", value: key }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "app.key", value: key }] });
// expect one page of results

@@ -465,5 +474,5 @@ const s1 = await client.txSearch({ query: query, page: 1, per_page: 2 });

it("can get all search results in one call", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ tags: [{ key: "app.key", value: key }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "app.key", value: key }] });
const sall = await client.txSearchAll({ query: query, per_page: 2 });

@@ -482,3 +491,3 @@ expect(sall.totalCount).toEqual(3);

it("can subscribe to block header events", (done) => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const testStart = readonly_date_1.ReadonlyDate.now();

@@ -531,6 +540,6 @@ (async () => {

it("can subscribe to block events", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const testStart = readonly_date_1.ReadonlyDate.now();
const transactionData1 = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const transactionData2 = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const transactionData1 = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const transactionData2 = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const events = [];

@@ -566,3 +575,3 @@ const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

// wait for events to be processed
await utils_1.sleep(100);
await (0, utils_1.sleep)(100);
expect(events.length).toEqual(2);

@@ -583,3 +592,3 @@ // Block header

it("can subscribe to transaction events", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const events = [];

@@ -600,8 +609,8 @@ const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());

});
const transactionData1 = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const transactionData2 = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const transactionData1 = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const transactionData2 = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
await client.broadcastTxCommit({ tx: transactionData1 });
await client.broadcastTxCommit({ tx: transactionData2 });
// wait for events to be processed
await utils_1.sleep(100);
await (0, utils_1.sleep)(100);
expect(events.length).toEqual(2);

@@ -617,8 +626,8 @@ // Meta

it("can subscribe to transaction events filtered by creator", async () => {
testutil_spec_1.pendingWithoutTendermint();
const transactionData1 = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
const transactionData2 = testutil_spec_1.buildKvTx(testutil_spec_1.randomString(), testutil_spec_1.randomString());
(0, testutil_spec_1.pendingWithoutTendermint)();
const transactionData1 = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const transactionData2 = (0, testutil_spec_1.buildKvTx)((0, testutil_spec_1.randomString)(), (0, testutil_spec_1.randomString)());
const events = [];
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const query = requests_1.buildQuery({ tags: [{ key: "app.creator", value: expected.appCreator }] });
const query = (0, requests_1.buildQuery)({ tags: [{ key: "app.creator", value: expected.appCreator }] });
const stream = client.subscribeTx(query);

@@ -641,3 +650,3 @@ expect(stream).toBeTruthy();

// wait for events to be processed
await utils_1.sleep(100);
await (0, utils_1.sleep)(100);
expect(events.length).toEqual(2);

@@ -653,20 +662,20 @@ // Meta

it("can unsubscribe and re-subscribe to the same stream", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const stream = client.subscribeNewBlockHeader();
const event1 = await stream_1.firstEvent(stream);
const event1 = await (0, stream_1.firstEvent)(stream);
expect(event1.height).toBeGreaterThanOrEqual(1);
expect(event1.time.getTime()).toBeGreaterThanOrEqual(1);
// No sleep: producer will not be stopped in the meantime
const event2 = await stream_1.firstEvent(stream);
const event2 = await (0, stream_1.firstEvent)(stream);
expect(event2.height).toBeGreaterThan(event1.height);
expect(event2.time.getTime()).toBeGreaterThan(event1.time.getTime());
// Very short sleep: just enough to schedule asynchronous producer stopping
await utils_1.sleep(5);
const event3 = await stream_1.firstEvent(stream);
await (0, utils_1.sleep)(5);
const event3 = await (0, stream_1.firstEvent)(stream);
expect(event3.height).toBeGreaterThan(event2.height);
expect(event3.time.getTime()).toBeGreaterThan(event2.time.getTime());
// Proper sleep: enough to finish unsubscribing at over the network
await utils_1.sleep(100);
const event4 = await stream_1.firstEvent(stream);
await (0, utils_1.sleep)(100);
const event4 = await (0, stream_1.firstEvent)(stream);
expect(event4.height).toBeGreaterThan(event3.height);

@@ -677,7 +686,7 @@ expect(event4.time.getTime()).toBeGreaterThan(event3.time.getTime());

it("can subscribe twice", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
const client = await tendermint34client_1.Tendermint34Client.create(rpcFactory());
const stream1 = client.subscribeNewBlockHeader();
const stream2 = client.subscribeNewBlockHeader();
const events = await stream_1.toListPromise(xstream_1.Stream.merge(stream1, stream2), 4);
const events = await (0, stream_1.toListPromise)(xstream_1.Stream.merge(stream1, stream2), 4);
expect(new Set(events.map((e) => e.height)).size).toEqual(2);

@@ -688,5 +697,5 @@ client.disconnect();

describe("Tendermint34Client", () => {
const { url, expected } = testutil_spec_1.tendermintInstances[1];
const { url, expected } = testutil_spec_1.tendermintInstances[0];
it("can connect to a given url", async () => {
testutil_spec_1.pendingWithoutTendermint();
(0, testutil_spec_1.pendingWithoutTendermint)();
// default connection

@@ -693,0 +702,0 @@ {

@@ -22,14 +22,2 @@ "use strict";

{
url: "localhost:11133",
version: "0.33.x",
blockTime: 1000,
expected: {
version: "0.33.8",
appCreator: "Cosmoshi Netowoko",
p2pVersion: 7,
blockVersion: 10,
appVersion: 1,
},
},
{
url: "localhost:11134",

@@ -60,7 +48,7 @@ version: "0.34.x",

// Tendermint needs some time before a committed transaction is found in search
return utils_1.sleep(75);
return (0, utils_1.sleep)(75);
}
exports.tendermintSearchIndexUpdated = tendermintSearchIndexUpdated;
function buildKvTx(k, v) {
return encoding_1.toAscii(`${k}=${v}`);
return (0, encoding_1.toAscii)(`${k}=${v}`);
}

@@ -67,0 +55,0 @@ exports.buildKvTx = buildKvTx;

{
"name": "@cosmjs/tendermint-rpc",
"version": "0.26.6",
"version": "0.26.8",
"description": "Tendermint RPC clients",

@@ -33,3 +33,3 @@ "contributors": [

"format-text": "prettier --write \"./*.md\"",
"test-node": "node --require esm jasmine-testrunner.js",
"test-node": "yarn node jasmine-testrunner.js",
"test-edge": "yarn pack-web && karma start --single-run --browsers Edge",

@@ -46,8 +46,9 @@ "test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox",

"dependencies": {
"@cosmjs/crypto": "0.26.6",
"@cosmjs/encoding": "0.26.6",
"@cosmjs/json-rpc": "0.26.6",
"@cosmjs/math": "0.26.6",
"@cosmjs/socket": "0.26.6",
"@cosmjs/stream": "0.26.6",
"@cosmjs/crypto": "0.26.8",
"@cosmjs/encoding": "0.26.8",
"@cosmjs/json-rpc": "0.26.8",
"@cosmjs/math": "0.26.8",
"@cosmjs/socket": "0.26.8",
"@cosmjs/stream": "0.26.8",
"@cosmjs/utils": "0.26.8",
"axios": "^0.21.2",

@@ -58,3 +59,2 @@ "readonly-date": "^1.0.0",

"devDependencies": {
"@cosmjs/utils": "0.26.6",
"@istanbuljs/nyc-config-typescript": "^1.0.1",

@@ -67,4 +67,4 @@ "@types/eslint-plugin-prettier": "^3",

"@types/node": "^15.0.1",
"@typescript-eslint/eslint-plugin": "^4.28",
"@typescript-eslint/parser": "^4.28",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"eslint": "^7.5",

@@ -78,6 +78,5 @@ "eslint-config-prettier": "^8.3.0",

"glob": "^7.1.6",
"jasmine": "^3.8",
"jasmine-core": "^3.7.1",
"jasmine": "^3.99",
"jasmine-spec-reporter": "^6",
"karma": "^6.1.1",
"karma": "^6.3.14",
"karma-chrome-launcher": "^3.1.0",

@@ -92,4 +91,4 @@ "karma-firefox-launcher": "^2.1.0",

"ts-node": "^8",
"typedoc": "^0.21",
"typescript": "~4.3",
"typedoc": "^0.22",
"typescript": "~4.4",
"webpack": "^5.32.0",

@@ -96,0 +95,0 @@ "webpack-cli": "^4.6.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc