diff --git a/packages/stargate/src/queries/ibc.spec.ts b/packages/stargate/src/queries/ibc.spec.ts index 3cbb128a..53585efc 100644 --- a/packages/stargate/src/queries/ibc.spec.ts +++ b/packages/stargate/src/queries/ibc.spec.ts @@ -42,7 +42,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.connectionChannels(); + const response = await client.ibc.unverified.connectionChannels("foo"); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); @@ -55,7 +55,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.packetCommitment(); + const response = await client.ibc.unverified.packetCommitment("foo", "bar", 0); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); @@ -68,7 +68,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.packetCommitments(); + const response = await client.ibc.unverified.packetCommitments("foo", "bar"); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); @@ -81,7 +81,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.packetAcknowledgement(); + const response = await client.ibc.unverified.packetAcknowledgement("foo", "bar", 1); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); @@ -94,7 +94,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.unrelayedPackets(); + const response = await client.ibc.unverified.unrelayedPackets("foo", "bar", [0, 1], true); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); @@ -107,7 +107,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.nextSequenceReceive(); + const response = await client.ibc.unverified.nextSequenceReceive("foo", "bar"); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); @@ -147,7 +147,7 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.clientConnections(); + const response = await client.ibc.unverified.clientConnections("foo"); expect(response).toBeTruthy(); // TODO: implement checks tmClient.disconnect(); diff --git a/packages/stargate/src/queries/ibc.ts b/packages/stargate/src/queries/ibc.ts index 06e1ecbb..0955f22f 100644 --- a/packages/stargate/src/queries/ibc.ts +++ b/packages/stargate/src/queries/ibc.ts @@ -1,3 +1,5 @@ +import Long from "long"; + import { ibc } from "../codec"; import { QueryClient } from "./queryclient"; import { toObject } from "./utils"; @@ -9,18 +11,41 @@ export interface IbcExtension { readonly channel: (portId: string, channelId: string) => Promise; readonly channels: () => Promise; - readonly connectionChannels: () => Promise; - readonly packetCommitment: () => Promise; - readonly packetCommitments: () => Promise; - readonly packetAcknowledgement: () => Promise; - readonly unrelayedPackets: () => Promise; - readonly nextSequenceReceive: () => Promise; + readonly connectionChannels: ( + connection: string, + ) => Promise; + readonly packetCommitment: ( + portId: string, + channelId: string, + sequence: number, + ) => Promise; + readonly packetCommitments: ( + portId: string, + channelId: string, + ) => Promise; + readonly packetAcknowledgement: ( + portId: string, + channelId: string, + sequence: number, + ) => Promise; + readonly unrelayedPackets: ( + portId: string, + channelId: string, + packetCommitmentSequences: readonly number[], + acknowledgements: boolean, + ) => Promise; + readonly nextSequenceReceive: ( + portId: string, + channelId: string, + ) => Promise; // Queries for ibc.connection readonly connection: (connectionId: string) => Promise; readonly connections: () => Promise; - readonly clientConnections: () => Promise; + readonly clientConnections: ( + clientId: string, + ) => Promise; }; }; } @@ -60,28 +85,52 @@ export function setupIbcExtension(base: QueryClient): IbcExtension { const response = await channelQuerySerice.channels({}); return toObject(response); }, - connectionChannels: async () => { - const response = await channelQuerySerice.connectionChannels({}); + connectionChannels: async (connection: string) => { + const response = await channelQuerySerice.connectionChannels({ connection: connection }); return toObject(response); }, - packetCommitment: async () => { - const response = await channelQuerySerice.packetCommitment({}); + packetCommitment: async (portId: string, channelId: string, sequence: number) => { + const response = await channelQuerySerice.packetCommitment({ + portId: portId, + channelId: channelId, + sequence: Long.fromNumber(sequence), + }); return toObject(response); }, - packetCommitments: async () => { - const response = await channelQuerySerice.packetCommitments({}); + packetCommitments: async (portId: string, channelId: string) => { + const response = await channelQuerySerice.packetCommitments({ + portId: portId, + channelId: channelId, + }); return toObject(response); }, - packetAcknowledgement: async () => { - const response = await channelQuerySerice.packetAcknowledgement({}); + packetAcknowledgement: async (portId: string, channelId: string, sequence: number) => { + const response = await channelQuerySerice.packetAcknowledgement({ + portId: portId, + channelId: channelId, + sequence: Long.fromNumber(sequence), + }); return toObject(response); }, - unrelayedPackets: async () => { - const response = await channelQuerySerice.unrelayedPackets({}); + unrelayedPackets: async ( + portId: string, + channelId: string, + packetCommitmentSequences: readonly number[], + acknowledgements: boolean, + ) => { + const response = await channelQuerySerice.unrelayedPackets({ + portId: portId, + channelId: channelId, + packetCommitmentSequences: packetCommitmentSequences.map((s) => Long.fromNumber(s)), + acknowledgements: acknowledgements, + }); return toObject(response); }, - nextSequenceReceive: async () => { - const response = await channelQuerySerice.nextSequenceReceive({}); + nextSequenceReceive: async (portId: string, channelId: string) => { + const response = await channelQuerySerice.nextSequenceReceive({ + portId: portId, + channelId: channelId, + }); return toObject(response); }, @@ -95,8 +144,8 @@ export function setupIbcExtension(base: QueryClient): IbcExtension { const response = await connectionQuerySerice.connections({}); return toObject(response); }, - clientConnections: async () => { - const response = await connectionQuerySerice.clientConnections({}); + clientConnections: async (clientId: string) => { + const response = await connectionQuerySerice.clientConnections({ clientId: clientId }); return toObject(response); }, }, diff --git a/packages/stargate/types/queries/ibc.d.ts b/packages/stargate/types/queries/ibc.d.ts index e9ba331f..3ca726b4 100644 --- a/packages/stargate/types/queries/ibc.d.ts +++ b/packages/stargate/types/queries/ibc.d.ts @@ -5,15 +5,38 @@ export interface IbcExtension { readonly unverified: { readonly channel: (portId: string, channelId: string) => Promise; readonly channels: () => Promise; - readonly connectionChannels: () => Promise; - readonly packetCommitment: () => Promise; - readonly packetCommitments: () => Promise; - readonly packetAcknowledgement: () => Promise; - readonly unrelayedPackets: () => Promise; - readonly nextSequenceReceive: () => Promise; + readonly connectionChannels: ( + connection: string, + ) => Promise; + readonly packetCommitment: ( + portId: string, + channelId: string, + sequence: number, + ) => Promise; + readonly packetCommitments: ( + portId: string, + channelId: string, + ) => Promise; + readonly packetAcknowledgement: ( + portId: string, + channelId: string, + sequence: number, + ) => Promise; + readonly unrelayedPackets: ( + portId: string, + channelId: string, + packetCommitmentSequences: readonly number[], + acknowledgements: boolean, + ) => Promise; + readonly nextSequenceReceive: ( + portId: string, + channelId: string, + ) => Promise; readonly connection: (connectionId: string) => Promise; readonly connections: () => Promise; - readonly clientConnections: () => Promise; + readonly clientConnections: ( + clientId: string, + ) => Promise; }; }; }