/* eslint-disable no-dupe-class-members, @typescript-eslint/ban-types, @typescript-eslint/naming-convention */ import { iavlSpec, ics23, tendermintSpec, verifyExistence, verifyNonExistence, } from "@confio/ics23"; import { toAscii, toHex } from "@cosmjs/encoding"; import { firstEvent } from "@cosmjs/stream"; import { tendermint34, Tendermint34Client } from "@cosmjs/tendermint-rpc"; import { arrayContentEquals, assert, assertDefined, isNonNullObject, sleep, } from "@cosmjs/utils"; import { ProofOps } from "cosmjs-types/tendermint/crypto/proof"; import { Stream } from "xstream"; type QueryExtensionSetup
= (base: QueryClient) => P;
function checkAndParseOp(
op: tendermint34.ProofOp,
kind: string,
key: Uint8Array
): ics23.CommitmentProof {
if (op.type !== kind) {
throw new Error(`Op expected to be ${kind}, got "${op.type}`);
}
if (!arrayContentEquals(key, op.key)) {
throw new Error(
`Proven key different than queried key.\nQuery: ${toHex(
key
)}\nProven: ${toHex(op.key)}`
);
}
return ics23.CommitmentProof.decode(op.data);
}
export interface ProvenQuery {
readonly key: Uint8Array;
readonly value: Uint8Array;
readonly proof: ProofOps;
readonly height: number;
}
export class QueryClient {
/** Constructs a QueryClient with 0 extensions */
public static withExtensions(tmClient: Tendermint34Client): QueryClient;
/** Constructs a QueryClient with 1 extension */
public static withExtensions(
tmClient: Tendermint34Client,
setupExtensionA: QueryExtensionSetup
): QueryClient & A;
/** Constructs a QueryClient with 2 extensions */
public static withExtensions(
tmClient: Tendermint34Client,
setupExtensionA: QueryExtensionSetup,
setupExtensionB: QueryExtensionSetup
): QueryClient & A & B;
/** Constructs a QueryClient with 3 extensions */
public static withExtensions<
A extends object,
B extends object,
C extends object
>(
tmClient: Tendermint34Client,
setupExtensionA: QueryExtensionSetup,
setupExtensionB: QueryExtensionSetup,
setupExtensionC: QueryExtensionSetup
): QueryClient &
A &
B &
C &
D &
E &
F &
G &
H &
I &
J &
K &
L &
M &
N &
O &
P;
/** Constructs a QueryClient with 17 extensions */
public static withExtensions<
A extends object,
B extends object,
C extends object,
D extends object,
E extends object,
F extends object,
G extends object,
H extends object,
I extends object,
J extends object,
K extends object,
L extends object,
M extends object,
N extends object,
O extends object,
P extends object,
Q extends object
>(
tmClient: Tendermint34Client,
setupExtensionA: QueryExtensionSetup,
setupExtensionB: QueryExtensionSetup,
setupExtensionC: QueryExtensionSetup