Remove queryVerified and queryUnverified

This commit is contained in:
Simon Warta 2023-05-24 10:37:57 +02:00
parent 6a8ba0ccb6
commit cd6fff9874
3 changed files with 3 additions and 103 deletions

View File

@ -30,6 +30,9 @@ and this project adheres to
and key/value pairs are now supported. ([#1411])
- @cosmjs/stargate: Let `searchTx` return non-readonly array. The caller owns
this array and can mutate it as they want. ([#1411])
- @cosmjs/stargate: Remove `QueryClient.queryUnverified` and
`QueryClient.queryVerified`. Please use `QueryClient.queryAbci` and
`QueryClient.queryStoreVerified` instead.
[#1409]: https://github.com/cosmos/cosmjs/issues/1409
[#1411]: https://github.com/cosmos/cosmjs/pull/1411

View File

@ -92,83 +92,6 @@ describe("QueryClient", () => {
});
});
describe("queryUnverified", () => {
it("works via WebSockets", async () => {
pendingWithoutSimapp();
const [client, tmClient] = await makeClient(simapp.tendermintUrlWs);
const requestData = Uint8Array.from(
QueryAllBalancesRequest.encode({ address: unused.address }).finish(),
);
const data = await client.queryUnverified(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData);
const response = QueryAllBalancesResponse.decode(data);
expect(response.balances.length).toEqual(2);
tmClient.disconnect();
});
it("works via http", async () => {
pendingWithoutSimapp();
const [client, tmClient] = await makeClient(simapp.tendermintUrlHttp);
const requestData = Uint8Array.from(
QueryAllBalancesRequest.encode({ address: unused.address }).finish(),
);
const data = await client.queryUnverified(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData);
const response = QueryAllBalancesResponse.decode(data);
expect(response.balances.length).toEqual(2);
tmClient.disconnect();
});
it("works for height", async () => {
pendingWithoutSimapp();
const [queryClient, tmClient] = await makeClient(simapp.tendermintUrlHttp);
const joe = makeRandomAddress();
const h1 = (await tmClient.status()).syncInfo.latestBlockHeight;
// Send tokens to `recipient`
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrlHttp,
wallet,
defaultSigningClientOptions,
);
const amount = coin(332211, simapp.denomFee);
await client.sendTokens(faucet.address0, joe, [amount], "auto");
const h2 = (await tmClient.status()).syncInfo.latestBlockHeight;
assert(h1 < h2);
// Query with no height
{
const requestData = QueryBalanceRequest.encode({ address: joe, denom: simapp.denomFee }).finish();
const data = await queryClient.queryUnverified(`/cosmos.bank.v1beta1.Query/Balance`, requestData);
const response = QueryBalanceResponse.decode(data);
expect(response.balance).toEqual(amount);
}
// Query at h2 (after send)
{
const requestData = QueryBalanceRequest.encode({ address: joe, denom: simapp.denomFee }).finish();
const data = await queryClient.queryUnverified(`/cosmos.bank.v1beta1.Query/Balance`, requestData, h2);
const response = QueryBalanceResponse.decode(data);
expect(response.balance).toEqual(amount);
}
// Query at h1 (before send)
{
const requestData = QueryBalanceRequest.encode({ address: joe, denom: simapp.denomFee }).finish();
const data = await queryClient.queryUnverified(`/cosmos.bank.v1beta1.Query/Balance`, requestData, h1);
const response = QueryBalanceResponse.decode(data);
expect(response.balance).toEqual({ amount: "0", denom: simapp.denomFee });
}
tmClient.disconnect();
});
});
describe("queryAbci", () => {
it("works via WebSockets", async () => {
pendingWithoutSimapp();

View File

@ -512,18 +512,6 @@ export class QueryClient {
this.tmClient = tmClient;
}
/**
* @deprecated use queryStoreVerified instead
*/
public async queryVerified(
store: string,
queryKey: Uint8Array,
desiredHeight?: number,
): Promise<Uint8Array> {
const { value } = await this.queryStoreVerified(store, queryKey, desiredHeight);
return value;
}
/**
* Queries the database store with a proof, which is then verified.
*
@ -608,20 +596,6 @@ export class QueryClient {
};
}
/**
* Performs an ABCI query to Tendermint without requesting a proof.
*
* @deprecated use queryAbci instead
*/
public async queryUnverified(
path: string,
request: Uint8Array,
desiredHeight?: number,
): Promise<Uint8Array> {
const response = await this.queryAbci(path, request, desiredHeight);
return response.value;
}
/**
* Performs an ABCI query to Tendermint without requesting a proof.
*