From 5f2639699d6bd73d6847675a284ab383dc4f3911 Mon Sep 17 00:00:00 2001 From: Imod7 Date: Mon, 11 Dec 2023 17:24:42 +0100 Subject: [PATCH] fix paraId filter for horizontal msgs --- src/services/blocks/XCMDecoder.ts | 32 +++++++++++++++++-------- src/types/responses/BlockXCMMessages.ts | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/services/blocks/XCMDecoder.ts b/src/services/blocks/XCMDecoder.ts index c179b718d..809d9d63d 100644 --- a/src/services/blocks/XCMDecoder.ts +++ b/src/services/blocks/XCMDecoder.ts @@ -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({ @@ -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, + }); + } }); }); } diff --git a/src/types/responses/BlockXCMMessages.ts b/src/types/responses/BlockXCMMessages.ts index be515f88f..e7510e2fd 100644 --- a/src/types/responses/BlockXCMMessages.ts +++ b/src/types/responses/BlockXCMMessages.ts @@ -21,6 +21,7 @@ export interface IUpwardMessage { export interface IDownwardMessage { sentAt: string; + msg: string; data: string; }