|
10 | 10 | import { validateIsmConfig } from '@hyperlane-xyz/deploy-sdk'; |
11 | 11 | import { type CoreConfig as ProviderCoreConfig } from '@hyperlane-xyz/provider-sdk/core'; |
12 | 12 | import { type IsmConfig as ProviderIsmConfig } from '@hyperlane-xyz/provider-sdk/ism'; |
13 | | -import { |
14 | | - type CollateralWarpConfig, |
15 | | - type NativeWarpConfig, |
16 | | - TokenType as ProviderTokenType, |
17 | | - type WarpConfig as ProviderWarpConfig, |
18 | | - type SyntheticWarpConfig, |
19 | | -} from '@hyperlane-xyz/provider-sdk/warp'; |
20 | | -import { |
21 | | - type CoreConfig, |
22 | | - TokenType, |
23 | | - type WarpRouteDeployConfigMailboxRequired, |
24 | | -} from '@hyperlane-xyz/sdk'; |
25 | | - |
26 | | -/** |
27 | | - * Supported token types in provider-sdk. |
28 | | - * Alt-VM chains currently support collateral, synthetic, and native tokens. |
29 | | - */ |
30 | | -const SUPPORTED_TOKEN_TYPES = new Set<TokenType>([ |
31 | | - TokenType.synthetic, |
32 | | - TokenType.collateral, |
33 | | - TokenType.native, |
34 | | -]); |
| 13 | +import { type CoreConfig } from '@hyperlane-xyz/sdk'; |
| 14 | +export { validateWarpConfigForAltVM } from '@hyperlane-xyz/sdk'; |
35 | 15 |
|
36 | 16 | /** |
37 | 17 | * Validates that a CoreConfig is compatible with provider-sdk requirements. |
@@ -62,77 +42,3 @@ export function validateCoreConfigForAltVM( |
62 | 42 | // and provider-sdk types are a subset of SDK types |
63 | 43 | return config as ProviderCoreConfig; |
64 | 44 | } |
65 | | - |
66 | | -/** |
67 | | - * Validates that a WarpRouteDeployConfig is compatible with provider-sdk requirements. |
68 | | - * |
69 | | - * @param config - WarpRouteDeployConfig from the main SDK |
70 | | - * @param chain - Chain name for error messages |
71 | | - * @returns a provider-sdk WarpConfig derived from the given config |
72 | | - * @throws Error if config contains unsupported token types |
73 | | - */ |
74 | | -export function validateWarpConfigForAltVM( |
75 | | - config: WarpRouteDeployConfigMailboxRequired[string], |
76 | | - chain: string, |
77 | | -): ProviderWarpConfig { |
78 | | - // Check if token type is supported |
79 | | - if (!SUPPORTED_TOKEN_TYPES.has(config.type)) { |
80 | | - const supportedTypes = Array.from(SUPPORTED_TOKEN_TYPES).join(', '); |
81 | | - const errorMsg = |
82 | | - `Unsupported token type '${config.type}' for Alt-VM chain '${chain}'.\n` + |
83 | | - `Supported token types: ${supportedTypes}.`; |
84 | | - throw new Error(errorMsg); |
85 | | - } |
86 | | - |
87 | | - // Validate the token conforms to basic collateral or synthetic structure |
88 | | - if (config.type === TokenType.collateral) { |
89 | | - if (!config.token) { |
90 | | - const errorMsg = `Collateral token config for chain '${chain}' must specify 'token' address`; |
91 | | - throw new Error(errorMsg); |
92 | | - } |
93 | | - } |
94 | | - |
95 | | - // Validate ISM if present (handles recursion for routing ISMs) |
96 | | - if (config.interchainSecurityModule) { |
97 | | - validateIsmConfig( |
98 | | - config.interchainSecurityModule as ProviderIsmConfig | string, |
99 | | - chain, |
100 | | - 'warp config', |
101 | | - ); |
102 | | - } |
103 | | - |
104 | | - // Construct the provider-sdk config |
105 | | - const baseConfig = { |
106 | | - owner: config.owner, |
107 | | - mailbox: config.mailbox, |
108 | | - interchainSecurityModule: config.interchainSecurityModule, |
109 | | - hook: config.hook, |
110 | | - remoteRouters: config.remoteRouters, |
111 | | - destinationGas: config.destinationGas, |
112 | | - }; |
113 | | - |
114 | | - if (config.type === TokenType.collateral) { |
115 | | - return { |
116 | | - ...baseConfig, |
117 | | - type: ProviderTokenType.collateral, |
118 | | - token: config.token, |
119 | | - } as CollateralWarpConfig; |
120 | | - } else if (config.type === TokenType.synthetic) { |
121 | | - return { |
122 | | - ...baseConfig, |
123 | | - type: ProviderTokenType.synthetic, |
124 | | - name: config.name, |
125 | | - symbol: config.symbol, |
126 | | - decimals: config.decimals, |
127 | | - } as SyntheticWarpConfig; |
128 | | - } else if (config.type === TokenType.native) { |
129 | | - return { |
130 | | - ...baseConfig, |
131 | | - type: ProviderTokenType.native, |
132 | | - } as NativeWarpConfig; |
133 | | - } else { |
134 | | - throw new Error( |
135 | | - `Unsupported token type '${config.type}' for Alt-VM chain '${chain}'.`, |
136 | | - ); |
137 | | - } |
138 | | -} |
0 commit comments