Skip to content

Commit 47649b7

Browse files
feat: cctp hook type (#8649)
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent 6929388 commit 47649b7

5 files changed

Lines changed: 35 additions & 1 deletion

File tree

.changeset/mean-papayas-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperlane-xyz/sdk": minor
3+
---
4+
5+
Added CCTP hook type

typescript/sdk/src/hook/EvmHookModule.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,14 @@ export class EvmHookModule extends HyperlaneModule<
810810
return this.deployAmountRoutingHook({ config });
811811
case HookType.CCIP:
812812
return this.deployCCIPHook({ config });
813+
case HookType.CCTP:
814+
// TODO: https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/3773
815+
// we can remove the ts-ignore once we have a proper type for address Hooks
816+
// @ts-ignore
817+
return IPostDispatchHook__factory.connect(
818+
config.address,
819+
this.multiProvider.getSignerOrProvider(this.args.chain),
820+
);
813821
default:
814822
throw new Error(`Unsupported hook config: ${config}`);
815823
}

typescript/sdk/src/hook/EvmHookReader.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ export class EvmHookReader extends HyperlaneReader implements HookReader {
179179
derivedHookConfig = { type: HookType.PREDICATE, address };
180180
this._cache.set(address, derivedHookConfig);
181181
break;
182+
case OnchainHookType.CCTP:
183+
derivedHookConfig = { type: HookType.CCTP, address };
184+
this._cache.set(address, derivedHookConfig);
185+
break;
182186
default:
183187
throw new Error(
184188
`Unsupported HookType: ${OnchainHookType[onchainHookType]}`,

typescript/sdk/src/hook/types.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export const HookType = {
5252
ARB_L2_TO_L1: 'arbL2ToL1Hook',
5353
MAILBOX_DEFAULT: 'defaultHook',
5454
CCIP: 'ccipHook',
55+
/**
56+
* References a pre-deployed CCTP hook by address. Excluded from
57+
* `DeployableHookType` — not deployed via `HyperlaneHookDeployer`; the
58+
* `EvmHookModule.deploy` path just connects to `config.address`.
59+
*/
60+
CCTP: 'cctpHook',
5561
UNKNOWN: 'unknownHook',
5662
PREDICATE: 'predicateHook',
5763
} as const;
@@ -60,7 +66,10 @@ export type HookType = (typeof HookType)[keyof typeof HookType];
6066

6167
export type DeployableHookType = Exclude<
6268
HookType,
63-
typeof HookType.CUSTOM | typeof HookType.PREDICATE | typeof HookType.UNKNOWN
69+
| typeof HookType.CUSTOM
70+
| typeof HookType.PREDICATE
71+
| typeof HookType.UNKNOWN
72+
| typeof HookType.CCTP
6473
>;
6574

6675
export const HookTypeToContractNameMap: Record<DeployableHookType, string> = {
@@ -220,6 +229,12 @@ export const CCIPHookSchema = z.object({
220229
destinationChain: z.string(),
221230
});
222231

232+
export const CctpHookSchema = z.object({
233+
type: z.literal(HookType.CCTP),
234+
address: ZHash,
235+
});
236+
export type CctpHookConfig = z.infer<typeof CctpHookSchema>;
237+
223238
export const UnknownHookSchema = z
224239
.object({
225240
type: z.literal(HookType.UNKNOWN),
@@ -282,6 +297,7 @@ export const HookConfigSchema = z.union([
282297
ArbL2ToL1HookSchema,
283298
MailboxDefaultHookSchema,
284299
CCIPHookSchema,
300+
CctpHookSchema,
285301
UnknownHookSchema,
286302
PredicateHookSchema,
287303
]);

typescript/sdk/src/test/testUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const hookTypesToFilter: HookType[] = [
135135
HookType.CUSTOM,
136136
HookType.PREDICATE,
137137
HookType.CCIP,
138+
HookType.CCTP,
138139
HookType.UNKNOWN,
139140
];
140141
export const DEFAULT_TOKEN_DECIMALS = 18;

0 commit comments

Comments
 (0)