Skip to content

Commit bae1979

Browse files
feat: support ZKSync-specific ISM configuration
1 parent e17ca49 commit bae1979

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

typescript/cli/src/config/ism.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
MultisigIsmConfig,
1111
MultisigIsmConfigSchema,
1212
TrustedRelayerIsmConfig,
13+
isStaticIsm,
1314
} from '@hyperlane-xyz/sdk';
1415

1516
import { CommandContext } from '../context/types.js';
@@ -87,6 +88,7 @@ const ISM_TYPE_DESCRIPTIONS: Record<string, string> = {
8788

8889
export async function createAdvancedIsmConfig(
8990
context: CommandContext,
91+
excludeStaticIsms: boolean = false,
9092
): Promise<IsmConfig> {
9193
logBlue('Creating a new advanced ISM config');
9294
logBoldUnderlinedRed('WARNING: USE AT YOUR RISK.');
@@ -96,12 +98,12 @@ export async function createAdvancedIsmConfig(
9698

9799
const moduleType = await select({
98100
message: 'Select ISM type',
99-
choices: Object.entries(ISM_TYPE_DESCRIPTIONS).map(
100-
([value, description]) => ({
101+
choices: Object.entries(ISM_TYPE_DESCRIPTIONS)
102+
.filter(([value]) => !excludeStaticIsms || !isStaticIsm(value as IsmType))
103+
.map(([value, description]) => ({
101104
value,
102105
description,
103-
}),
104-
),
106+
})),
105107
pageSize: 10,
106108
});
107109

typescript/cli/src/config/warp.ts

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { stringify as yamlStringify } from 'yaml';
33

44
import {
55
ChainMap,
6+
ChainTechnicalStack,
67
DeployedOwnableConfig,
78
IsmConfig,
89
IsmType,
@@ -158,6 +159,10 @@ export async function createWarpRouteDeployConfig({
158159
owner,
159160
);
160161

162+
const excludeStaticIsms =
163+
context.multiProvider.getChainMetadata(chain).technicalStack ===
164+
ChainTechnicalStack.ZkSync;
165+
161166
/**
162167
* The logic from the cli is as follows:
163168
* --advanced flag is provided: the user will have to build their own configuration using the available ISM types
@@ -168,15 +173,24 @@ export async function createWarpRouteDeployConfig({
168173
*/
169174
let interchainSecurityModule: IsmConfig;
170175
if (advanced) {
171-
interchainSecurityModule = await createAdvancedIsmConfig(context);
176+
interchainSecurityModule = await createAdvancedIsmConfig(
177+
context,
178+
excludeStaticIsms,
179+
);
172180
} else if (context.skipConfirmation) {
173-
interchainSecurityModule = createDefaultWarpIsmConfig(owner);
181+
interchainSecurityModule = createDefaultWarpIsmConfig(
182+
owner,
183+
excludeStaticIsms,
184+
);
174185
} else if (
175186
await confirm({
176187
message: 'Do you want to use a trusted ISM for warp route?',
177188
})
178189
) {
179-
interchainSecurityModule = createDefaultWarpIsmConfig(owner);
190+
interchainSecurityModule = createDefaultWarpIsmConfig(
191+
owner,
192+
excludeStaticIsms,
193+
);
180194
} else {
181195
interchainSecurityModule = createFallbackRoutingConfig(owner);
182196
}
@@ -291,23 +305,36 @@ export function readWarpCoreConfig(filePath: string): WarpCoreConfig {
291305
}
292306

293307
/**
294-
* Creates a default configuration for an ISM with a TRUSTED_RELAYER and FALLBACK_ROUTING.
308+
* Creates a default configuration for an ISM.
295309
*
296-
* Properties relayer and owner are both set as input owner.
310+
* When excludeStaticIsms is false (default):
311+
* - Creates an AGGREGATION ISM with TRUSTED_RELAYER and FALLBACK_ROUTING modules
312+
* - Properties relayer and owner are both set as input owner
297313
*
298-
* @param owner - The address of the owner of the ISM.
299-
* @returns The default Aggregation ISM configuration.
314+
* When excludeStaticIsms is true:
315+
* - Creates only a TRUSTED_RELAYER ISM (as static ISMs like AGGREGATION are not supported)
316+
* - Properties relayer is set as input owner
317+
*
318+
* @param owner - The address of the owner of the ISM
319+
* @param excludeStaticIsms - Whether to exclude static ISM types (default: false)
320+
* @returns The ISM configuration
300321
*/
301-
function createDefaultWarpIsmConfig(owner: Address): IsmConfig {
322+
function createDefaultWarpIsmConfig(
323+
owner: Address,
324+
excludeStaticIsms: boolean = false,
325+
): IsmConfig {
326+
const trustedRelayerModule: IsmConfig = {
327+
type: IsmType.TRUSTED_RELAYER,
328+
relayer: owner,
329+
};
330+
331+
if (excludeStaticIsms) {
332+
return trustedRelayerModule;
333+
}
334+
302335
return {
303336
type: IsmType.AGGREGATION,
304-
modules: [
305-
{
306-
type: IsmType.TRUSTED_RELAYER,
307-
relayer: owner,
308-
},
309-
createFallbackRoutingConfig(owner),
310-
],
337+
modules: [trustedRelayerModule, createFallbackRoutingConfig(owner)],
311338
threshold: 1,
312339
};
313340
}

0 commit comments

Comments
 (0)