Skip to content

Commit

Permalink
Fix parsing response from ibc clientState query api
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed May 22, 2024
1 parent acab3a6 commit 7494f14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
33 changes: 21 additions & 12 deletions src/client/lcd/api/IbcAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -160,12 +164,17 @@ export class IbcAPI extends BaseAPI {
public async clientState(
client_id: string,
params: APIParams = {}
): Promise<IdentifiedClientState> {
): Promise<ClientState> {
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<ClientState.Data>(
`/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),
}));
}

/**
Expand All @@ -176,12 +185,12 @@ export class IbcAPI extends BaseAPI {
public async clientStatus(
client_id: string,
params: APIParams = {}
): Promise<Status> {
): Promise<string> {
return this.c
.get<{
status: Status.Data;
status: string;
}>(`/ibc/core/client/v1/client_status/${client_id}`, params)
.then();
.then(d => d.status);
}

/**
Expand Down

0 comments on commit 7494f14

Please sign in to comment.