Export normalizeLcdApiArray

This commit is contained in:
Simon Warta 2020-07-07 23:20:43 +02:00
parent e121ea9d08
commit ab4bbb7d28
7 changed files with 9 additions and 7 deletions

View File

@ -29,6 +29,7 @@ export {
LcdClient,
LcdModule,
NodeInfoResponse,
normalizeLcdApiArray,
PostTxsResponse,
SearchTxsResponse,
TxsResponse,

View File

@ -18,4 +18,4 @@ export {
SearchTxsResponse,
TxsResponse,
} from "./base";
export { LcdApiArray, LcdClient, LcdModule } from "./lcdclient";
export { LcdApiArray, LcdClient, LcdModule, normalizeLcdApiArray } from "./lcdclient";

View File

@ -22,7 +22,7 @@ import {
} from "../testutils.spec";
import { StdFee } from "../types";
import { TxsResponse } from "./base";
import { LcdApiArray, LcdClient, normalizeArray } from "./lcdclient";
import { LcdApiArray, LcdClient, normalizeLcdApiArray } from "./lcdclient";
/** Deployed as part of scripts/wasmd/init.sh */
export const deployedErc20 = {
@ -94,7 +94,7 @@ describe("LcdClient", () => {
listCodeInfo: async (): Promise<readonly CodeInfo[]> => {
const path = `/wasm/code`;
const responseData = (await base.get(path)) as WasmResponse<LcdApiArray<CodeInfo>>;
return normalizeArray(unwrapWasmResponse(responseData));
return normalizeLcdApiArray(unwrapWasmResponse(responseData));
},
};
}
@ -115,7 +115,7 @@ describe("LcdClient", () => {
listCodeInfo: async (): Promise<readonly CodeInfo[]> => {
const path = `/wasm/code`;
const responseData = (await base.get(path)) as WasmResponse<LcdApiArray<CodeInfo>>;
return normalizeArray(unwrapWasmResponse(responseData));
return normalizeLcdApiArray(unwrapWasmResponse(responseData));
},
};
}

View File

@ -17,7 +17,7 @@ import {
/** Unfortunately, Cosmos SDK encodes empty arrays as null */
export type LcdApiArray<T> = readonly T[] | null;
export function normalizeArray<T>(backend: LcdApiArray<T>): readonly T[] {
export function normalizeLcdApiArray<T>(backend: LcdApiArray<T>): readonly T[] {
return backend || [];
}

View File

@ -27,6 +27,7 @@ export {
LcdClient,
LcdModule,
NodeInfoResponse,
normalizeLcdApiArray,
PostTxsResponse,
SearchTxsResponse,
TxsResponse,

View File

@ -9,4 +9,4 @@ export {
SearchTxsResponse,
TxsResponse,
} from "./base";
export { LcdApiArray, LcdClient, LcdModule } from "./lcdclient";
export { LcdApiArray, LcdClient, LcdModule, normalizeLcdApiArray } from "./lcdclient";

View File

@ -11,7 +11,7 @@ import {
} from "./base";
/** Unfortunately, Cosmos SDK encodes empty arrays as null */
export declare type LcdApiArray<T> = readonly T[] | null;
export declare function normalizeArray<T>(backend: LcdApiArray<T>): readonly T[];
export declare function normalizeLcdApiArray<T>(backend: LcdApiArray<T>): readonly T[];
export declare type LcdModule = Record<string, (...args: any[]) => any>;
declare type LcdModuleSetup<M> = (base: LcdClient) => M;
export interface LcdClientBaseOptions {