From f115d48fdf4154b0901d864e765a34d58ac18e2b Mon Sep 17 00:00:00 2001 From: Yorke Rhodes Date: Fri, 3 May 2024 15:31:25 -0400 Subject: [PATCH] Fix lint --- .../sdk/src/ism/metadata/aggregation.ts | 22 ++++++++++++++----- .../sdk/src/ism/metadata/multisig.test.ts | 4 ++-- typescript/sdk/src/ism/metadata/multisig.ts | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/typescript/sdk/src/ism/metadata/aggregation.ts b/typescript/sdk/src/ism/metadata/aggregation.ts index 87fbfc68f1..0aa127f7f2 100644 --- a/typescript/sdk/src/ism/metadata/aggregation.ts +++ b/typescript/sdk/src/ism/metadata/aggregation.ts @@ -6,6 +6,8 @@ import { AggregationIsmConfig } from '../types.js'; import { BaseMetadataBuilder, MetadataBuilder } from './builder.js'; +// null indicates that metadata is NOT INCLUDED for this submodule +// empty or 0x string indicates that metadata is INCLUDED but NULL export interface AggregationIsmMetadata { submoduleMetadata: Array; } @@ -20,16 +22,24 @@ export class AggregationIsmMetadataBuilder async build( message: DispatchedMessage, - ismConfig: WithAddress, + config: WithAddress, ): Promise { - const metadatas = await Promise.all( - ismConfig.modules.map((module) => + const results = await Promise.allSettled( + config.modules.map((module) => this.base.build(message, module as DerivedIsmConfigWithAddress), ), ); - return AggregationIsmMetadataBuilder.encode({ - submoduleMetadata: metadatas, - }); + const submoduleMetadata = results.map((r) => + r.status === 'fulfilled' ? r.value : null, + ); + const included = submoduleMetadata.filter((m) => m !== null).length; + if (included < config.threshold) { + throw new Error( + `Only built ${included} of ${config.threshold} required modules`, + ); + } + + return AggregationIsmMetadataBuilder.encode({ submoduleMetadata }); } static rangeIndex(index: number): number { diff --git a/typescript/sdk/src/ism/metadata/multisig.test.ts b/typescript/sdk/src/ism/metadata/multisig.test.ts index 30276fd151..384dc457ce 100644 --- a/typescript/sdk/src/ism/metadata/multisig.test.ts +++ b/typescript/sdk/src/ism/metadata/multisig.test.ts @@ -19,12 +19,12 @@ const fixtures: Fixture[] = files .map((contents) => { const type = contents.type as MultisigMetadata['type']; - const { dummy, ...signatureValues } = contents.signatures; + const { dummy: _dummy, ...signatureValues } = contents.signatures; const signatures = Object.values(signatureValues); let decoded: MultisigMetadata; if (type === ModuleType.MERKLE_ROOT_MULTISIG) { - const { dummy, ...branchValues } = contents.prefix.proof; + const { dummy: _dummy, ...branchValues } = contents.prefix.proof; const branch = Object.values(branchValues); decoded = { type, diff --git a/typescript/sdk/src/ism/metadata/multisig.ts b/typescript/sdk/src/ism/metadata/multisig.ts index 5a067b0fc6..ea6c4a2c5e 100644 --- a/typescript/sdk/src/ism/metadata/multisig.ts +++ b/typescript/sdk/src/ism/metadata/multisig.ts @@ -202,7 +202,7 @@ export class MultisigMetadataBuilder metadata: string, type: ModuleType.MERKLE_ROOT_MULTISIG | ModuleType.MESSAGE_ID_MULTISIG, ): MultisigMetadata { - const prefix = + const prefix: any = type === ModuleType.MERKLE_ROOT_MULTISIG ? this.decodeProofPrefix(metadata) : this.decodeSimplePrefix(metadata);