Add ibc.connection queries
This commit is contained in:
@@ -113,5 +113,45 @@ describe("IbcExtension", () => {
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
// Queries for ibc.connection
|
||||
|
||||
describe("connection", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connection("foo");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("connections", () => {
|
||||
it("can be called", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connections();
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientConnections", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.clientConnections();
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,8 @@ import { toObject } from "./utils";
|
||||
export interface IbcExtension {
|
||||
readonly ibc: {
|
||||
readonly unverified: {
|
||||
// Queries for ibc.channel
|
||||
|
||||
readonly channel: (portId: string, channelId: string) => Promise<ibc.channel.IQueryChannelResponse>;
|
||||
readonly channels: () => Promise<ibc.channel.IQueryChannelsResponse>;
|
||||
readonly connectionChannels: () => Promise<ibc.channel.IQueryConnectionChannelsResponse>;
|
||||
@@ -13,6 +15,12 @@ export interface IbcExtension {
|
||||
readonly packetAcknowledgement: () => Promise<ibc.channel.IQueryPacketAcknowledgementResponse>;
|
||||
readonly unrelayedPackets: () => Promise<ibc.channel.IQueryUnrelayedPacketsResponse>;
|
||||
readonly nextSequenceReceive: () => Promise<ibc.channel.IQueryNextSequenceReceiveResponse>;
|
||||
|
||||
// Queries for ibc.connection
|
||||
|
||||
readonly connection: (connectionId: string) => Promise<ibc.connection.IQueryConnectionResponse>;
|
||||
readonly connections: () => Promise<ibc.connection.IQueryConnectionsResponse>;
|
||||
readonly clientConnections: () => Promise<ibc.connection.IQueryClientConnectionsResponse>;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -30,9 +38,20 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
|
||||
.catch((error) => callback(error));
|
||||
});
|
||||
|
||||
const connectionQuerySerice = ibc.connection.Query.create((method: any, requestData, callback) => {
|
||||
// Parts of the path are unavailable, so we hardcode them here. See https://github.com/protobufjs/protobuf.js/issues/1229
|
||||
const path = `/ibc.connection.Query/${method.name}`;
|
||||
base
|
||||
.queryUnverified(path, requestData)
|
||||
.then((response) => callback(null, response))
|
||||
.catch((error) => callback(error));
|
||||
});
|
||||
|
||||
return {
|
||||
ibc: {
|
||||
unverified: {
|
||||
// Queries for ibc.channel
|
||||
|
||||
channel: async (portId: string, channelId: string) => {
|
||||
const response = await channelQuerySerice.channel({ portId: portId, channelId: channelId });
|
||||
return toObject(response);
|
||||
@@ -65,6 +84,21 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
|
||||
const response = await channelQuerySerice.nextSequenceReceive({});
|
||||
return toObject(response);
|
||||
},
|
||||
|
||||
// Queries for ibc.connection
|
||||
|
||||
connection: async (connectionId: string) => {
|
||||
const response = await connectionQuerySerice.connection({ connectionId: connectionId });
|
||||
return toObject(response);
|
||||
},
|
||||
connections: async () => {
|
||||
const response = await connectionQuerySerice.connections({});
|
||||
return toObject(response);
|
||||
},
|
||||
clientConnections: async () => {
|
||||
const response = await connectionQuerySerice.clientConnections({});
|
||||
return toObject(response);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
+3
@@ -11,6 +11,9 @@ export interface IbcExtension {
|
||||
readonly packetAcknowledgement: () => Promise<ibc.channel.IQueryPacketAcknowledgementResponse>;
|
||||
readonly unrelayedPackets: () => Promise<ibc.channel.IQueryUnrelayedPacketsResponse>;
|
||||
readonly nextSequenceReceive: () => Promise<ibc.channel.IQueryNextSequenceReceiveResponse>;
|
||||
readonly connection: (connectionId: string) => Promise<ibc.connection.IQueryConnectionResponse>;
|
||||
readonly connections: () => Promise<ibc.connection.IQueryConnectionsResponse>;
|
||||
readonly clientConnections: () => Promise<ibc.connection.IQueryClientConnectionsResponse>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user