From 7494f146e1b411a09048519bedb0f1df4fb76aaa Mon Sep 17 00:00:00 2001 From: joon9823 Date: Wed, 22 May 2024 21:01:54 +0900 Subject: [PATCH] Fix parsing response from ibc clientState query api --- package-lock.json | 4 ++-- package.json | 2 +- src/client/lcd/api/IbcAPI.ts | 33 +++++++++++++++++++++------------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea1b490..ce63198 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@initia/initia.js", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@initia/initia.js", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "dependencies": { "@initia/initia.proto": "^0.2.0", diff --git a/package.json b/package.json index d33f6ef..6e17b43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@initia/initia.js", - "version": "0.2.3", + "version": "0.2.4", "description": "The JavaScript SDK for Initia", "license": "MIT", "author": "InitiaLabs", diff --git a/src/client/lcd/api/IbcAPI.ts b/src/client/lcd/api/IbcAPI.ts index a7805cd..c64176c 100644 --- a/src/client/lcd/api/IbcAPI.ts +++ b/src/client/lcd/api/IbcAPI.ts @@ -9,13 +9,17 @@ import { IbcClientParams, } from '../../../core'; -export interface Status { - status: string; +export interface ClientState { + client_state: any; + proof: string | null; + proof_height: Height; } -export namespace Status { +export namespace ClientState { export interface Data { - status: string; + client_state: any; + proof: string | null; + proof_height: Height.Data; } } @@ -160,12 +164,17 @@ export class IbcAPI extends BaseAPI { public async clientState( client_id: string, params: APIParams = {} - ): Promise { + ): Promise { return this.c - .get<{ - client_state: IdentifiedClientState.Data; - }>(`/ibc/core/client/v1/client_states/${client_id}`, params) - .then(d => IdentifiedClientState.fromData(d.client_state)); + .get( + `/ibc/core/client/v1/client_states/${client_id}`, + params + ) + .then(d => ({ + client_state: d.client_state, + proof: d.proof, + proof_height: Height.fromData(d.proof_height), + })); } /** @@ -176,12 +185,12 @@ export class IbcAPI extends BaseAPI { public async clientStatus( client_id: string, params: APIParams = {} - ): Promise { + ): Promise { return this.c .get<{ - status: Status.Data; + status: string; }>(`/ibc/core/client/v1/client_status/${client_id}`, params) - .then(); + .then(d => d.status); } /**