Merge pull request #526 from cosmos/523-ibc-packet-acknowledgements
Add IBC packetAcknowledgements query
This commit is contained in:
commit
fe56436f94
@ -92,13 +92,30 @@ describe("IbcExtension", () => {
|
||||
ibcTest.channelId,
|
||||
1,
|
||||
);
|
||||
expect(response.acknowledgement).toEqual(ibcTest.acknowledgement);
|
||||
expect(response.acknowledgement).toEqual(ibcTest.packetAcknowledgements[0].data);
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgements", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetAcknowledgements(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.acknowledgements).toEqual(ibcTest.packetAcknowledgements);
|
||||
expect(response.pagination).toBeInstanceOf(cosmos.base.query.v1beta1.PageResponse);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedPackets", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
|
||||
@ -46,6 +46,11 @@ export interface IbcExtension {
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<ibc.core.channel.v1.IQueryPacketAcknowledgementResponse>;
|
||||
readonly packetAcknowledgements: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<ibc.core.channel.v1.IQueryPacketAcknowledgementsResponse>;
|
||||
readonly unreceivedPackets: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
@ -175,6 +180,14 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
|
||||
});
|
||||
return toObject(response);
|
||||
},
|
||||
packetAcknowledgements: async (portId: string, channelId: string, paginationKey?: Uint8Array) => {
|
||||
const response = await channelQueryService.packetAcknowledgements({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
pagination: paginationKey ? { key: paginationKey } : undefined,
|
||||
});
|
||||
return toObject(response);
|
||||
},
|
||||
unreceivedPackets: async (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
|
||||
@ -42,7 +42,27 @@ export const packetState = ibc.core.channel.v1.PacketState.create({
|
||||
sequence: Long.fromInt(4, true),
|
||||
data: commitmentData,
|
||||
});
|
||||
export const acknowledgement = fromBase64("9RKC5OuTvBsFMtD79dHHvb9qCxw08IKsSJlAwmiw8tI=");
|
||||
|
||||
export const packetAcknowledgements = [
|
||||
ibc.core.channel.v1.PacketState.create({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromInt(1, true),
|
||||
data: fromBase64("9RKC5OuTvBsFMtD79dHHvb9qCxw08IKsSJlAwmiw8tI="),
|
||||
}),
|
||||
ibc.core.channel.v1.PacketState.create({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromInt(2, true),
|
||||
data: fromBase64("Nj784gGVOFk2mdt+wAk/LOoPdUOo+5+0JfYs0yAubZU="),
|
||||
}),
|
||||
ibc.core.channel.v1.PacketState.create({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromInt(3, true),
|
||||
data: fromBase64("+lLTGP1dlSD6MBpJgBIvx98Psd3U2xo500K7JyMkya8="),
|
||||
}),
|
||||
];
|
||||
|
||||
export const connection = ibc.core.connection.v1.ConnectionEnd.create({
|
||||
clientId: clientId,
|
||||
|
||||
5
packages/stargate/types/queries/ibc.d.ts
vendored
5
packages/stargate/types/queries/ibc.d.ts
vendored
@ -35,6 +35,11 @@ export interface IbcExtension {
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<ibc.core.channel.v1.IQueryPacketAcknowledgementResponse>;
|
||||
readonly packetAcknowledgements: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<ibc.core.channel.v1.IQueryPacketAcknowledgementsResponse>;
|
||||
readonly unreceivedPackets: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user