Skip to content

Commit

Permalink
fix paraId filter for horizontal msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Imod7 committed Dec 11, 2023
1 parent 5945988 commit 5f26396
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/services/blocks/XCMDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ export class XcmDecoder {
if (frame.pallet === 'parachainSystem' && frame.method === 'setValidationData') {
const data = extrinsic.args.data as ISanitizedParachainInherentData;
data.downwardMessages.forEach((msg) => {
const message = msg.data;
if (message.length > 0) {
const message = msg.msg;
if (message && message.toString().length > 0) {
const downwardMessage: IDownwardMessage[] = [];
const xcmMessageDecoded = this.decodeMsg(api, message);
downwardMessage.push({
sentAt: msg.sentAt,
msg: message.toString(),
data: xcmMessageDecoded,
});
xcmMessages.push({
Expand All @@ -109,14 +110,25 @@ export class XcmDecoder {
msgs.forEach((msg) => {
const horizontalMessage: IHorizontalMessage[] = [];
const xcmMessageDecoded = this.decodeMsg(api, msg.data.slice(1));
horizontalMessage.push({
sentAt: msg.sentAt,
paraId: index,
data: xcmMessageDecoded,
});
xcmMessages.push({
horizontalMessages: horizontalMessage,
});
if (paraId !== undefined && index.toString() === paraId) {
horizontalMessage.push({
sentAt: msg.sentAt,
paraId: index,
data: xcmMessageDecoded,
});
xcmMessages.push({
horizontalMessages: horizontalMessage,
});
} else if (paraId === undefined) {
horizontalMessage.push({
sentAt: msg.sentAt,
paraId: index,
data: xcmMessageDecoded,
});
xcmMessages.push({
horizontalMessages: horizontalMessage,
});
}
});
});
}
Expand Down
1 change: 1 addition & 0 deletions src/types/responses/BlockXCMMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface IUpwardMessage {

export interface IDownwardMessage {
sentAt: string;
msg: string;
data: string;
}

Expand Down

0 comments on commit 5f26396

Please sign in to comment.