Remove hashTx/hashBlock from Adaptor abstraction

This commit is contained in:
Simon Warta 2023-08-24 16:32:57 +02:00
parent 3cffb629a1
commit 4adfcb0f6a
9 changed files with 6 additions and 21 deletions

View File

@ -1,4 +1,3 @@
import { hashBlock, hashTx } from "../hasher";
import { Params } from "./requests";
import { Responses } from "./responses";
import { Adaptor } from "./types";
@ -8,6 +7,4 @@ export { Decoder, Encoder, Params, Responses } from "./types";
export const adaptor38: Adaptor = {
params: Params,
responses: Responses,
hashTx: hashTx,
hashBlock: hashBlock,
};

View File

@ -7,8 +7,6 @@ import * as responses from "../responses";
export interface Adaptor {
readonly params: Params;
readonly responses: Responses;
readonly hashTx: (tx: Uint8Array) => Uint8Array;
readonly hashBlock: (header: responses.Header) => Uint8Array;
}
// Encoder is a generic that matches all methods of Params

View File

@ -16,8 +16,8 @@ import {
tendermintInstances,
tendermintSearchIndexUpdated,
} from "../testutil.spec";
import { adaptor38 } from "./adaptor";
import { Comet38Client } from "./comet38client";
import { hashTx } from "./hasher";
import { buildQuery } from "./requests";
import * as responses from "./responses";
@ -100,7 +100,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
pendingWithoutTendermint();
const client = await Comet38Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const calculatedTxHash = adaptor38.hashTx(tx);
const calculatedTxHash = hashTx(tx);
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.hash).toEqual(calculatedTxHash);

View File

@ -1,4 +1,3 @@
import { hashBlock, hashTx } from "../hasher";
import { Params } from "./requests";
import { Responses } from "./responses";
import { Adaptor } from "./types";
@ -8,6 +7,4 @@ export { Decoder, Encoder, Params, Responses } from "./types";
export const adaptor34: Adaptor = {
params: Params,
responses: Responses,
hashTx: hashTx,
hashBlock: hashBlock,
};

View File

@ -7,8 +7,6 @@ import * as responses from "../responses";
export interface Adaptor {
readonly params: Params;
readonly responses: Responses;
readonly hashTx: (tx: Uint8Array) => Uint8Array;
readonly hashBlock: (header: responses.Header) => Uint8Array;
}
// Encoder is a generic that matches all methods of Params

View File

@ -16,7 +16,7 @@ import {
tendermintInstances,
tendermintSearchIndexUpdated,
} from "../testutil.spec";
import { adaptor34 } from "./adaptor";
import { hashTx } from "./hasher";
import { buildQuery } from "./requests";
import * as responses from "./responses";
import { Tendermint34Client } from "./tendermint34client";
@ -100,7 +100,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
pendingWithoutTendermint();
const client = await Tendermint34Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const calculatedTxHash = adaptor34.hashTx(tx);
const calculatedTxHash = hashTx(tx);
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.hash).toEqual(calculatedTxHash);

View File

@ -1,4 +1,3 @@
import { hashBlock, hashTx } from "../hasher";
import { Params } from "./requests";
import { Responses } from "./responses";
import { Adaptor } from "./types";
@ -8,6 +7,4 @@ export { Decoder, Encoder, Params, Responses } from "./types";
export const adaptor37: Adaptor = {
params: Params,
responses: Responses,
hashTx: hashTx,
hashBlock: hashBlock,
};

View File

@ -7,8 +7,6 @@ import * as responses from "../responses";
export interface Adaptor {
readonly params: Params;
readonly responses: Responses;
readonly hashTx: (tx: Uint8Array) => Uint8Array;
readonly hashBlock: (header: responses.Header) => Uint8Array;
}
// Encoder is a generic that matches all methods of Params

View File

@ -16,7 +16,7 @@ import {
tendermintInstances,
tendermintSearchIndexUpdated,
} from "../testutil.spec";
import { adaptor37 } from "./adaptor";
import { hashTx } from "./hasher";
import { buildQuery } from "./requests";
import * as responses from "./responses";
import { Tendermint37Client } from "./tendermint37client";
@ -100,7 +100,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
pendingWithoutTendermint();
const client = await Tendermint37Client.create(rpcFactory());
const tx = buildKvTx(randomString(), randomString());
const calculatedTxHash = adaptor37.hashTx(tx);
const calculatedTxHash = hashTx(tx);
const response = await client.broadcastTxCommit({ tx: tx });
expect(response.hash).toEqual(calculatedTxHash);