Skip to content

Commit

Permalink
fix: error on calling batch with 1 item.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmdawn committed Nov 2, 2022
1 parent 0b45788 commit b458884
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/tendermint-batch-rpc/batchhttpclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import {
isJsonRpcErrorResponse,
JsonRpcRequest,
JsonRpcSuccessResponse,
parseJsonRpcResponse,
parseJsonRpcResponse
} from '@cosmjs/json-rpc';
import {
HttpClient,
HttpEndpoint,
HttpEndpoint
} from '@cosmjs/tendermint-rpc/build/rpcclients';
import { http } from '@cosmjs/tendermint-rpc/build/rpcclients/httpclient';
import { orderByFromJSON } from 'cosmjs-types/cosmos/tx/v1beta1/service';

export class BatchHttpClient extends HttpClient {
protected readonly declare url: string;
Expand All @@ -21,7 +22,9 @@ export class BatchHttpClient extends HttpClient {
public async executeBatch(
requests: JsonRpcRequest[]
): Promise<JsonRpcSuccessResponse[]> {
const responses = await http('POST', this.url, this.headers, requests);
let responses = await http('POST', this.url, this.headers, requests);
if (!(responses instanceof Array)) responses = [responses];

const parsedResponses = [];
for (const response of responses) {
const parsedResponse = parseJsonRpcResponse(response);
Expand Down

0 comments on commit b458884

Please sign in to comment.