diff --git a/packages/sdk/src/restclient.ts b/packages/sdk/src/restclient.ts index 0db2f078..e66b0906 100644 --- a/packages/sdk/src/restclient.ts +++ b/packages/sdk/src/restclient.ts @@ -1,4 +1,4 @@ -import { Encoding } from "@iov/encoding"; +import { Encoding, isNonNullObject } from "@iov/encoding"; import axios, { AxiosError, AxiosInstance } from "axios"; import { Coin, CosmosSdkTx, Model, parseWasmData, StdTx, WasmData } from "./types"; @@ -138,8 +138,6 @@ interface SearchTxsResponse { readonly txs: readonly TxsResponse[]; } -interface PostTxsParams {} - export interface PostTxsResponse { readonly height: string; readonly txhash: string; @@ -295,7 +293,8 @@ export class RestClient { return data; } - public async post(path: string, params: PostTxsParams): Promise { + public async post(path: string, params: any): Promise { + if (!isNonNullObject(params)) throw new Error("Got unexpected type of params. Expected object."); const { data } = await this.client.post(path, params).catch(parseAxiosError); if (data === null) { throw new Error("Received null response from server"); diff --git a/packages/sdk/types/restclient.d.ts b/packages/sdk/types/restclient.d.ts index 4ef9b5e6..90a28789 100644 --- a/packages/sdk/types/restclient.d.ts +++ b/packages/sdk/types/restclient.d.ts @@ -110,7 +110,6 @@ interface SearchTxsResponse { readonly limit: string; readonly txs: readonly TxsResponse[]; } -interface PostTxsParams {} export interface PostTxsResponse { readonly height: string; readonly txhash: string; @@ -192,7 +191,7 @@ export declare class RestClient { */ constructor(apiUrl: string, broadcastMode?: BroadcastMode); get(path: string): Promise; - post(path: string, params: PostTxsParams): Promise; + post(path: string, params: any): Promise; authAccounts(address: string): Promise; blocksLatest(): Promise; blocks(height: number): Promise;