Bump to @confio/ics23 v0.6.3

This commit is contained in:
Ethan Frey
2020-08-18 12:48:36 +02:00
committed by Simon Warta
parent 15b1f7d836
commit 598469bfac
4 changed files with 9 additions and 54 deletions
+1 -1
View File
@@ -45,7 +45,7 @@
"postdefine-proto": "prettier --write \"src/codec/generated/codecimpl.*\""
},
"dependencies": {
"@confio/ics23": "^0.6.0",
"@confio/ics23": "^0.6.3",
"@cosmjs/encoding": "^0.22.1",
"@cosmjs/launchpad": "^0.22.1",
"@cosmjs/math": "^0.22.1",
+4 -39
View File
@@ -1,45 +1,10 @@
/* eslint-disable no-dupe-class-members, @typescript-eslint/ban-types, @typescript-eslint/naming-convention */
import { ics23, verifyExistence, verifyNonExistence } from "@confio/ics23";
import { iavlSpec, ics23, tendermintSpec, verifyExistence, verifyNonExistence } from "@confio/ics23";
import { fromAscii, toAscii, toHex } from "@cosmjs/encoding";
import { firstEvent } from "@cosmjs/stream";
import { Client as TendermintClient } from "@cosmjs/tendermint-rpc";
import { arrayContentEquals, assert, isNonNullObject } from "@cosmjs/utils";
// TODO: import these from @confio/ics23 when exported
export const IavlSpec: ics23.IProofSpec = {
leafSpec: {
prefix: Uint8Array.from([0]),
hash: ics23.HashOp.SHA256,
prehashValue: ics23.HashOp.SHA256,
prehashKey: ics23.HashOp.NO_HASH,
length: ics23.LengthOp.VAR_PROTO,
},
innerSpec: {
childOrder: [0, 1],
minPrefixLength: 4,
maxPrefixLength: 12,
childSize: 33,
hash: ics23.HashOp.SHA256,
},
};
export const TendermintSpec: ics23.IProofSpec = {
leafSpec: {
prefix: Uint8Array.from([0]),
hash: ics23.HashOp.SHA256,
prehashValue: ics23.HashOp.SHA256,
prehashKey: ics23.HashOp.NO_HASH,
length: ics23.LengthOp.VAR_PROTO,
},
innerSpec: {
childOrder: [0, 1],
minPrefixLength: 1,
maxPrefixLength: 1,
childSize: 32,
hash: ics23.HashOp.SHA256,
},
};
type QueryExtensionSetup<P> = (base: QueryClient) => P;
export class QueryClient {
@@ -233,13 +198,13 @@ export class QueryClient {
// non-existence check
assert(subProof.nonexist);
// the subproof must map the desired key to the "value" of the storeProof
verifyNonExistence(subProof.nonexist, IavlSpec, storeProof.exist.value, key);
verifyNonExistence(subProof.nonexist, iavlSpec, storeProof.exist.value, key);
} else {
// existence check
assert(subProof.exist);
assert(subProof.exist.value);
// the subproof must map the desired key to the "value" of the storeProof
verifyExistence(subProof.exist, IavlSpec, storeProof.exist.value, key, response.value);
verifyExistence(subProof.exist, iavlSpec, storeProof.exist.value, key, response.value);
}
// the storeproof must map it's declared value (root of subProof) to the appHash of the next block
@@ -253,7 +218,7 @@ export class QueryClient {
throw new Error(`Query returned height ${response.height}, but next header was ${header.height}`);
}
verifyExistence(storeProof.exist, TendermintSpec, header.appHash, toAscii(store), storeProof.exist.value);
verifyExistence(storeProof.exist, tendermintSpec, header.appHash, toAscii(store), storeProof.exist.value);
return response.value;
}
-3
View File
@@ -1,7 +1,4 @@
import { ics23 } from "@confio/ics23";
import { Client as TendermintClient } from "@cosmjs/tendermint-rpc";
export declare const IavlSpec: ics23.IProofSpec;
export declare const TendermintSpec: ics23.IProofSpec;
declare type QueryExtensionSetup<P> = (base: QueryClient) => P;
export declare class QueryClient {
/** Constructs a QueryClient with 0 extensions */