@hyperlane-xyz/sdk 32.0.1 → 33.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/core/EvmCoreModule.d.ts.map +1 -1
  2. package/dist/core/EvmCoreModule.js +2 -1
  3. package/dist/core/EvmCoreModule.js.map +1 -1
  4. package/dist/core/HyperlaneCoreDeployer.d.ts.map +1 -1
  5. package/dist/core/HyperlaneCoreDeployer.js +1 -0
  6. package/dist/core/HyperlaneCoreDeployer.js.map +1 -1
  7. package/dist/core/types.d.ts +124 -22
  8. package/dist/core/types.d.ts.map +1 -1
  9. package/dist/deploy/warp.d.ts.map +1 -1
  10. package/dist/deploy/warp.js +3 -1
  11. package/dist/deploy/warp.js.map +1 -1
  12. package/dist/hook/EvmHookReader.d.ts.map +1 -1
  13. package/dist/hook/EvmHookReader.js +4 -0
  14. package/dist/hook/EvmHookReader.js.map +1 -1
  15. package/dist/hook/HyperlaneHookDeployer.d.ts.map +1 -1
  16. package/dist/hook/HyperlaneHookDeployer.js +19 -10
  17. package/dist/hook/HyperlaneHookDeployer.js.map +1 -1
  18. package/dist/hook/types.d.ts +118 -17
  19. package/dist/hook/types.d.ts.map +1 -1
  20. package/dist/hook/types.js +14 -0
  21. package/dist/hook/types.js.map +1 -1
  22. package/dist/hook/updates.d.ts +4 -1
  23. package/dist/hook/updates.d.ts.map +1 -1
  24. package/dist/hook/updates.js +1 -1
  25. package/dist/hook/updates.js.map +1 -1
  26. package/dist/hook/utils.d.ts +7 -1
  27. package/dist/hook/utils.d.ts.map +1 -1
  28. package/dist/hook/utils.js +18 -0
  29. package/dist/hook/utils.js.map +1 -1
  30. package/dist/ica/types.d.ts +36 -6
  31. package/dist/ica/types.d.ts.map +1 -1
  32. package/dist/index.d.ts +5 -3
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +5 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/predicate/PredicateApiClient.d.ts +45 -0
  37. package/dist/predicate/PredicateApiClient.d.ts.map +1 -0
  38. package/dist/predicate/PredicateApiClient.js +66 -0
  39. package/dist/predicate/PredicateApiClient.js.map +1 -0
  40. package/dist/predicate/PredicateApiClient.test.d.ts +2 -0
  41. package/dist/predicate/PredicateApiClient.test.d.ts.map +1 -0
  42. package/dist/predicate/PredicateApiClient.test.js +108 -0
  43. package/dist/predicate/PredicateApiClient.test.js.map +1 -0
  44. package/dist/predicate/PredicateDeployer.d.ts +56 -0
  45. package/dist/predicate/PredicateDeployer.d.ts.map +1 -0
  46. package/dist/predicate/PredicateDeployer.hardhat-test.d.ts +2 -0
  47. package/dist/predicate/PredicateDeployer.hardhat-test.d.ts.map +1 -0
  48. package/dist/predicate/PredicateDeployer.hardhat-test.js +209 -0
  49. package/dist/predicate/PredicateDeployer.hardhat-test.js.map +1 -0
  50. package/dist/predicate/PredicateDeployer.js +218 -0
  51. package/dist/predicate/PredicateDeployer.js.map +1 -0
  52. package/dist/router/types.d.ts +54 -9
  53. package/dist/router/types.d.ts.map +1 -1
  54. package/dist/test/testUtils.d.ts +1 -1
  55. package/dist/test/testUtils.d.ts.map +1 -1
  56. package/dist/test/testUtils.js +1 -0
  57. package/dist/test/testUtils.js.map +1 -1
  58. package/dist/token/EvmWarpModule.d.ts +55 -0
  59. package/dist/token/EvmWarpModule.d.ts.map +1 -1
  60. package/dist/token/EvmWarpModule.hardhat-test.js +29 -0
  61. package/dist/token/EvmWarpModule.hardhat-test.js.map +1 -1
  62. package/dist/token/EvmWarpModule.js +264 -21
  63. package/dist/token/EvmWarpModule.js.map +1 -1
  64. package/dist/token/EvmWarpRouteReader.d.ts +6 -0
  65. package/dist/token/EvmWarpRouteReader.d.ts.map +1 -1
  66. package/dist/token/EvmWarpRouteReader.js +34 -1
  67. package/dist/token/EvmWarpRouteReader.js.map +1 -1
  68. package/dist/token/adapters/EvmCrossCollateralAdapter.d.ts +2 -8
  69. package/dist/token/adapters/EvmCrossCollateralAdapter.d.ts.map +1 -1
  70. package/dist/token/adapters/EvmCrossCollateralAdapter.js +23 -4
  71. package/dist/token/adapters/EvmCrossCollateralAdapter.js.map +1 -1
  72. package/dist/token/adapters/EvmTokenAdapter.d.ts +21 -4
  73. package/dist/token/adapters/EvmTokenAdapter.d.ts.map +1 -1
  74. package/dist/token/adapters/EvmTokenAdapter.js +191 -22
  75. package/dist/token/adapters/EvmTokenAdapter.js.map +1 -1
  76. package/dist/token/adapters/ITokenAdapter.d.ts +10 -0
  77. package/dist/token/adapters/ITokenAdapter.d.ts.map +1 -1
  78. package/dist/token/adapters/ITokenAdapter.js +8 -0
  79. package/dist/token/adapters/ITokenAdapter.js.map +1 -1
  80. package/dist/token/deploy.d.ts +4 -1
  81. package/dist/token/deploy.d.ts.map +1 -1
  82. package/dist/token/deploy.js +30 -1
  83. package/dist/token/deploy.js.map +1 -1
  84. package/dist/token/types.d.ts +4427 -27
  85. package/dist/token/types.d.ts.map +1 -1
  86. package/dist/token/types.js +19 -0
  87. package/dist/token/types.js.map +1 -1
  88. package/dist/warp/WarpCore.d.ts +39 -19
  89. package/dist/warp/WarpCore.d.ts.map +1 -1
  90. package/dist/warp/WarpCore.js +149 -82
  91. package/dist/warp/WarpCore.js.map +1 -1
  92. package/package.json +10 -10
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredicateApiClient.test.js","sourceRoot":"","sources":["../../src/predicate/PredicateApiClient.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,kBAAkB,GAGnB,MAAM,yBAAyB,CAAC;AAEjC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,SAA0B,CAAC;IAE/B,MAAM,WAAW,GAAgC;QAC/C,EAAE,EAAE,4CAA4C;QAChD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,GAAG;Q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C,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAgB,CAAC;QAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAc,CAAC,CAAC;QAEjD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACvD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { PopulatedTransaction } from 'ethers';
2
+ import { Logger } from 'pino';
3
+ import { StaticAggregationHookFactory } from '@hyperlane-xyz/core';
4
+ import { Address } from '@hyperlane-xyz/utils';
5
+ import { MultiProvider } from '../providers/MultiProvider.js';
6
+ import { TokenType } from '../token/config.js';
7
+ import { PredicateWrapperConfig } from '../token/types.js';
8
+ import { ChainName } from '../types.js';
9
+ export interface PredicateWrapperDeploymentResult {
10
+ wrapperAddress: Address;
11
+ aggregationHookAddress: Address;
12
+ setHookTx: PopulatedTransaction;
13
+ }
14
+ export declare class PredicateWrapperDeployer {
15
+ private readonly multiProvider;
16
+ private readonly staticAggregationHookFactory;
17
+ private readonly logger;
18
+ constructor(multiProvider: MultiProvider, staticAggregationHookFactory: StaticAggregationHookFactory, logger?: Logger);
19
+ deployPredicateWrapper(chain: ChainName, warpRouteAddress: Address, config: PredicateWrapperConfig, tokenType?: TokenType): Promise<Address>;
20
+ createAggregationHook(chain: ChainName, predicateWrapperAddress: Address, existingHookAddress: Address): Promise<Address>;
21
+ /**
22
+ * Deploys the predicate wrapper and aggregation hook on-chain as a side effect, then
23
+ * returns the populated setHook transaction for the caller to include in its transaction
24
+ * array.
25
+ *
26
+ * IMPORTANT — irreversible side effects: deployPredicateWrapper submits a real on-chain
27
+ * transaction before this method returns. If the caller discards the returned setHookTx
28
+ * (dry-run, cancellation, error), the PredicateRouterWrapper is orphaned — deployed but
29
+ * unreferenced by any warp route. The aggregation hook is safe because
30
+ * StaticAggregationHookFactory uses CREATE2 (idempotent). Eliminating the wrapper orphan
31
+ * risk requires a CREATE2 factory for PredicateRouterWrapper (future contract work).
32
+ *
33
+ * This differs from EvmHookModule/EvmIsmModule: those modules own the full configuration
34
+ * lifecycle (deploy + configure in one atomic step). Here, deployment is eager but the
35
+ * final wiring (setHook) is deferred to EvmWarpModule.update(), which may choose not to
36
+ * submit it.
37
+ *
38
+ * @param existingHookOverride - When provided, skips the on-chain hook() read and uses
39
+ * this address instead. Pass the pending new hook address when a hook update is being
40
+ * applied in the same update() call to avoid wrapping a stale on-chain hook.
41
+ */
42
+ deployAndConfigure(chain: ChainName, warpRouteAddress: Address, config: PredicateWrapperConfig, tokenType?: TokenType, existingHookOverride?: Address): Promise<PredicateWrapperDeploymentResult>;
43
+ /**
44
+ * If hookAddress is a StaticAggregationHook that contains a predicate wrapper,
45
+ * strips it and (when multiple non-predicate sub-hooks remain) re-aggregates
46
+ * them via CREATE2 before returning, so the caller can safely wrap the result
47
+ * in a new aggregation without stacking wrappers.
48
+ *
49
+ * Falls back to hookAddress unchanged when:
50
+ * - The address is zero / not an aggregation hook
51
+ * - No predicate wrapper is found among sub-hooks
52
+ * - Multiple non-predicate sub-hooks remain (cannot safely re-aggregate here)
53
+ */
54
+ private stripPredicateAndReaggregateHook;
55
+ }
56
+ //# sourceMappingURL=PredicateDeployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredicateDeployer.d.ts","sourceRoot":"","sources":["../../src/predicate/PredicateDeployer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAa,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAML,4BAA4B,EAE7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAc,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,gCAAgC;IAC/C,cAAc,EAAE,OAAO,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAED,qBAAa,wBAAwB;IAIjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,4BAA4B;IAJ/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGb,aAAa,EAAE,aAAa,EAC5B,4BAA4B,EAAE,4BAA4B,EAC3E,MAAM,CAAC,EAAE,MAAM;IAMX,sBAAsB,CAC1B,KAAK,EAAE,SAAS,EAChB,gBAAgB,EAAE,OAAO,EACzB,MAAM,EAAE,sBAAsB,EAC9B,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,OAAO,CAAC;IA8Db,qBAAqB,CACzB,KAAK,EAAE,SAAS,EAChB,uBAAuB,EAAE,OAAO,EAChC,mBAAmB,EAAE,OAAO,GAC3B,OAAO,CAAC,OAAO,CAAC;IAkDnB;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,kBAAkB,CACtB,KAAK,EAAE,SAAS,EAChB,gBAAgB,EAAE,OAAO,EACzB,MAAM,EAAE,sBAAsB,EAC9B,SAAS,CAAC,EAAE,SAAS,EACrB,oBAAoB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gCAAgC,CAAC;IAoE5C;;;;;;;;;;OAUG;YACW,gCAAgC;CA+F/C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PredicateDeployer.hardhat-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredicateDeployer.hardhat-test.d.ts","sourceRoot":"","sources":["../../src/predicate/PredicateDeployer.hardhat-test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,209 @@
1
+ import { expect } from 'chai';
2
+ import { constants } from 'ethers';
3
+ import hre from 'hardhat';
4
+ import { ERC20Test__factory, HypERC20Collateral__factory, MockPredicateRegistry__factory, PredicateRouterWrapper__factory, TokenRouter__factory, } from '@hyperlane-xyz/core';
5
+ import { TestChainName } from '../consts/testChains.js';
6
+ import { TestCoreDeployer } from '../core/TestCoreDeployer.js';
7
+ import { HyperlaneProxyFactoryDeployer } from '../deploy/HyperlaneProxyFactoryDeployer.js';
8
+ import { HyperlaneIsmFactory } from '../ism/HyperlaneIsmFactory.js';
9
+ import { MultiProtocolProvider } from '../providers/MultiProtocolProvider.js';
10
+ import { MultiProvider } from '../providers/MultiProvider.js';
11
+ import { EvmHypCollateralAdapter } from '../token/adapters/EvmTokenAdapter.js';
12
+ import { PredicateWrapperDeployer } from './PredicateDeployer.js';
13
+ describe('PredicateWrapperDeployer', async () => {
14
+ const chain = TestChainName.test1;
15
+ const MOCK_POLICY_ID = 'x-test-policy-123';
16
+ let multiProvider;
17
+ let signer;
18
+ let signerAddress;
19
+ let factoryContracts;
20
+ let mailboxAddress;
21
+ let testTokenAddress;
22
+ let warpRouteAddress;
23
+ let mockPredicateRegistry;
24
+ before(async () => {
25
+ [signer] = await hre.ethers.getSigners();
26
+ signerAddress = await signer.getAddress();
27
+ multiProvider = MultiProvider.createTestMultiProvider({ signer });
28
+ const factoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider);
29
+ const contractsMap = await factoryDeployer.deploy(multiProvider.mapKnownChains(() => ({})));
30
+ factoryContracts = contractsMap[chain];
31
+ const legacyIsmFactory = new HyperlaneIsmFactory(contractsMap, multiProvider);
32
+ const testCoreDeployer = new TestCoreDeployer(multiProvider, legacyIsmFactory);
33
+ const { mailbox } = (await testCoreDeployer.deployApp()).getContracts(chain);
34
+ mailboxAddress = mailbox.address;
35
+ const testToken = await new ERC20Test__factory(signer).deploy('Test Token', 'TEST', '1000000000000000000000000', 18);
36
+ await testToken.deployed();
37
+ testTokenAddress = testToken.address;
38
+ mockPredicateRegistry = await new MockPredicateRegistry__factory(signer).deploy();
39
+ await mockPredicateRegistry.deployed();
40
+ const collateral = await new HypERC20Collateral__factory(signer).deploy(testTokenAddress, 1, 1, mailboxAddress);
41
+ await collateral.deployed();
42
+ await collateral.initialize(constants.AddressZero, constants.AddressZero, signerAddress);
43
+ warpRouteAddress = collateral.address;
44
+ });
45
+ describe('deployPredicateWrapper', () => {
46
+ it('should deploy PredicateRouterWrapper contract', async () => {
47
+ const deployer = new PredicateWrapperDeployer(multiProvider, factoryContracts.staticAggregationHookFactory);
48
+ const wrapperAddress = await deployer.deployPredicateWrapper(chain, warpRouteAddress, {
49
+ predicateRegistry: mockPredicateRegistry.address,
50
+ policyId: MOCK_POLICY_ID,
51
+ owner: signerAddress,
52
+ });
53
+ expect(wrapperAddress).to.be.properAddress;
54
+ const code = await multiProvider
55
+ .getProvider(chain)
56
+ .getCode(wrapperAddress);
57
+ expect(code).to.not.equal('0x');
58
+ });
59
+ });
60
+ describe('createAggregationHook', () => {
61
+ it('should create aggregation hook with two hooks', async () => {
62
+ const deployer = new PredicateWrapperDeployer(multiProvider, factoryContracts.staticAggregationHookFactory);
63
+ const wrapperAddress = await deployer.deployPredicateWrapper(chain, warpRouteAddress, {
64
+ predicateRegistry: mockPredicateRegistry.address,
65
+ policyId: MOCK_POLICY_ID,
66
+ owner: signerAddress,
67
+ });
68
+ const existingHookAddress = '0x1234567890123456789012345678901234567890';
69
+ const aggregationHookAddress = await deployer.createAggregationHook(chain, wrapperAddress, existingHookAddress);
70
+ expect(aggregationHookAddress).to.be.properAddress;
71
+ const code = await multiProvider
72
+ .getProvider(chain)
73
+ .getCode(aggregationHookAddress);
74
+ expect(code).to.not.equal('0x');
75
+ });
76
+ });
77
+ describe('deployAndConfigure', () => {
78
+ it('should deploy wrapper and aggregate with mailbox default hook when no existing hook', async () => {
79
+ const newCollateral = await new HypERC20Collateral__factory(signer).deploy(testTokenAddress, 1, 1, mailboxAddress);
80
+ await newCollateral.deployed();
81
+ await newCollateral.initialize(constants.AddressZero, constants.AddressZero, signerAddress);
82
+ const deployer = new PredicateWrapperDeployer(multiProvider, factoryContracts.staticAggregationHookFactory);
83
+ const result = await deployer.deployAndConfigure(chain, newCollateral.address, {
84
+ predicateRegistry: mockPredicateRegistry.address,
85
+ policyId: MOCK_POLICY_ID,
86
+ owner: signerAddress,
87
+ });
88
+ await signer.sendTransaction(result.setHookTx);
89
+ expect(result.wrapperAddress).to.be.properAddress;
90
+ expect(result.aggregationHookAddress).to.be.properAddress;
91
+ // Even with no existing hook, we aggregate with mailbox default hook for gas quoting
92
+ expect(result.wrapperAddress).to.not.equal(result.aggregationHookAddress);
93
+ const router = TokenRouter__factory.connect(newCollateral.address, signer);
94
+ const hookOnRouter = await router.hook();
95
+ expect(hookOnRouter).to.equal(result.aggregationHookAddress);
96
+ });
97
+ it('should create aggregation hook when existing hook is present', async () => {
98
+ const existingHook = await new ERC20Test__factory(signer).deploy('Dummy Hook', 'DH', '0', 18);
99
+ await existingHook.deployed();
100
+ const newCollateral = await new HypERC20Collateral__factory(signer).deploy(testTokenAddress, 1, 1, mailboxAddress);
101
+ await newCollateral.deployed();
102
+ await newCollateral.initialize(existingHook.address, constants.AddressZero, signerAddress);
103
+ const deployer = new PredicateWrapperDeployer(multiProvider, factoryContracts.staticAggregationHookFactory);
104
+ const result = await deployer.deployAndConfigure(chain, newCollateral.address, {
105
+ predicateRegistry: mockPredicateRegistry.address,
106
+ policyId: MOCK_POLICY_ID,
107
+ owner: signerAddress,
108
+ });
109
+ await signer.sendTransaction(result.setHookTx);
110
+ expect(result.wrapperAddress).to.not.equal(result.aggregationHookAddress);
111
+ const router = TokenRouter__factory.connect(newCollateral.address, signer);
112
+ const hookOnRouter = await router.hook();
113
+ expect(hookOnRouter).to.equal(result.aggregationHookAddress);
114
+ });
115
+ });
116
+ describe('Adapter Predicate Support', () => {
117
+ let wrapperAddress;
118
+ let collateralWithWrapper;
119
+ let multiProtocolProvider;
120
+ before(async () => {
121
+ multiProtocolProvider =
122
+ MultiProtocolProvider.fromMultiProvider(multiProvider);
123
+ collateralWithWrapper = await new HypERC20Collateral__factory(signer).deploy(testTokenAddress, 1, 1, mailboxAddress);
124
+ await collateralWithWrapper.deployed();
125
+ await collateralWithWrapper.initialize(constants.AddressZero, constants.AddressZero, signerAddress);
126
+ const deployer = new PredicateWrapperDeployer(multiProvider, factoryContracts.staticAggregationHookFactory);
127
+ const result = await deployer.deployAndConfigure(chain, collateralWithWrapper.address, {
128
+ predicateRegistry: mockPredicateRegistry.address,
129
+ policyId: MOCK_POLICY_ID,
130
+ owner: signerAddress,
131
+ });
132
+ await signer.sendTransaction(result.setHookTx);
133
+ wrapperAddress = result.wrapperAddress;
134
+ });
135
+ it('should detect PredicateRouterWrapper on collateral adapter', async () => {
136
+ const adapter = new EvmHypCollateralAdapter(chain, multiProtocolProvider, {
137
+ token: collateralWithWrapper.address,
138
+ });
139
+ const detectedWrapper = await adapter.getPredicateWrapperAddress();
140
+ expect(detectedWrapper).to.equal(wrapperAddress);
141
+ });
142
+ it('should return null when no PredicateRouterWrapper present', async () => {
143
+ const adapter = new EvmHypCollateralAdapter(chain, multiProtocolProvider, {
144
+ token: warpRouteAddress,
145
+ });
146
+ const detectedWrapper = await adapter.getPredicateWrapperAddress();
147
+ expect(detectedWrapper).to.be.null;
148
+ });
149
+ it('should route approval to wrapper when wrapper present', async () => {
150
+ const adapter = new EvmHypCollateralAdapter(chain, multiProtocolProvider, {
151
+ token: collateralWithWrapper.address,
152
+ });
153
+ const approveTx = await adapter.populateApproveTx({
154
+ weiAmountOrId: '1000000',
155
+ recipient: collateralWithWrapper.address,
156
+ });
157
+ expect(approveTx.to?.toLowerCase()).to.equal(testTokenAddress.toLowerCase());
158
+ expect(approveTx.data).to.include(wrapperAddress.slice(2).toLowerCase());
159
+ });
160
+ it('should throw error when attestation provided but no wrapper', async () => {
161
+ const adapter = new EvmHypCollateralAdapter(chain, multiProtocolProvider, {
162
+ token: warpRouteAddress,
163
+ });
164
+ const mockAttestation = {
165
+ uuid: 'test-uuid',
166
+ expiration: Math.floor(Date.now() / 1000) + 3600,
167
+ attester: signerAddress,
168
+ signature: '0x1234',
169
+ };
170
+ try {
171
+ await adapter.populateTransferRemoteTx({
172
+ weiAmountOrId: '1000000',
173
+ destination: 2,
174
+ recipient: signerAddress,
175
+ attestation: mockAttestation,
176
+ });
177
+ expect.fail('Expected error to be thrown');
178
+ }
179
+ catch (error) {
180
+ expect(error.message).to.include('Attestation provided but no PredicateRouterWrapper detected');
181
+ }
182
+ });
183
+ it('should populate transferRemoteWithAttestation when attestation provided', async () => {
184
+ const adapter = new EvmHypCollateralAdapter(chain, multiProtocolProvider, {
185
+ token: collateralWithWrapper.address,
186
+ });
187
+ const mockAttestation = {
188
+ uuid: 'test-uuid',
189
+ expiration: Math.floor(Date.now() / 1000) + 3600,
190
+ attester: signerAddress,
191
+ signature: '0x1234',
192
+ };
193
+ const tx = await adapter.populateTransferRemoteTx({
194
+ weiAmountOrId: '1000000',
195
+ destination: 2,
196
+ recipient: signerAddress,
197
+ attestation: mockAttestation,
198
+ interchainGas: {
199
+ igpQuote: { amount: 0n },
200
+ },
201
+ });
202
+ expect(tx.to?.toLowerCase()).to.equal(wrapperAddress.toLowerCase());
203
+ const iface = PredicateRouterWrapper__factory.createInterface();
204
+ const selector = iface.getSighash('transferRemoteWithAttestation');
205
+ expect(tx.data?.startsWith(selector)).to.be.true;
206
+ });
207
+ });
208
+ });
209
+ //# sourceMappingURL=PredicateDeployer.hardhat-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredicateDeployer.hardhat-test.js","sourceRoot":"","sources":["../../src/predicate/PredicateDeployer.hardhat-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAU,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,GAAG,MAAM,SAAS,CAAC;AAE1B,OAAO,EACL,kBAAkB,EAElB,2BAA2B,EAE3B,8BAA8B,EAC9B,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAE3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElE,QAAQ,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;IAC9C,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;IAClC,MAAM,cAAc,GAAG,mBAAmB,CAAC;IAE3C,IAAI,aAA4B,CAAC;IACjC,IAAI,MAAc,CAAC;IACnB,IAAI,aAAsB,CAAC;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,CAAC,CAAC"}
@@ -0,0 +1,218 @@
1
+ import { constants } from 'ethers';
2
+ import { CrossCollateralRouter__factory, Mailbox__factory, PredicateCrossCollateralRouterWrapper__factory, PredicateRouterWrapper__factory, StaticAggregationHook__factory, TokenRouter__factory, } from '@hyperlane-xyz/core';
3
+ import { rootLogger } from '@hyperlane-xyz/utils';
4
+ import { OnchainHookType } from '../hook/types.js';
5
+ import { TokenType } from '../token/config.js';
6
+ export class PredicateWrapperDeployer {
7
+ multiProvider;
8
+ staticAggregationHookFactory;
9
+ logger;
10
+ constructor(multiProvider, staticAggregationHookFactory, logger) {
11
+ this.multiProvider = multiProvider;
12
+ this.staticAggregationHookFactory = staticAggregationHookFactory;
13
+ this.logger =
14
+ logger ?? rootLogger.child({ module: 'PredicateWrapperDeployer' });
15
+ }
16
+ async deployPredicateWrapper(chain, warpRouteAddress, config, tokenType) {
17
+ const signer = this.multiProvider.getSigner(chain);
18
+ const isCrossCollateral = tokenType === TokenType.crossCollateral;
19
+ const wrapperName = isCrossCollateral
20
+ ? 'PredicateCrossCollateralRouterWrapper'
21
+ : 'PredicateRouterWrapper';
22
+ this.logger.info({
23
+ chain,
24
+ warpRoute: warpRouteAddress,
25
+ registry: config.predicateRegistry,
26
+ tokenType,
27
+ wrapperType: wrapperName,
28
+ }, `Deploying ${wrapperName}`);
29
+ const overrides = this.multiProvider.getTransactionOverrides(chain);
30
+ // Deploy the appropriate wrapper based on token type
31
+ // Token address is fetched from warpRoute.token() in constructor
32
+ const wrapper = isCrossCollateral
33
+ ? await new PredicateCrossCollateralRouterWrapper__factory(signer).deploy(warpRouteAddress, config.predicateRegistry, config.policyId, overrides)
34
+ : await new PredicateRouterWrapper__factory(signer).deploy(warpRouteAddress, config.predicateRegistry, config.policyId, overrides);
35
+ await wrapper.deployed();
36
+ // Transfer wrapper ownership to the warp route owner so that admin functions
37
+ // (setPolicyID, setRegistry, withdrawETH) are controlled by the same key/multisig
38
+ // that owns the warp route, not the ephemeral deployer key.
39
+ // Use the explicit owner from config rather than reading from on-chain, because
40
+ // during initial deployment the on-chain owner is still the deployer signer
41
+ // (transferOwnership hasn't run yet).
42
+ const routeOwner = config.owner;
43
+ await this.multiProvider.handleTx(chain, wrapper.transferOwnership(routeOwner, overrides));
44
+ this.logger.info({
45
+ chain,
46
+ address: wrapper.address,
47
+ owner: routeOwner,
48
+ wrapperType: wrapperName,
49
+ }, `${wrapperName} deployed and ownership transferred`);
50
+ return wrapper.address;
51
+ }
52
+ async createAggregationHook(chain, predicateWrapperAddress, existingHookAddress) {
53
+ const signer = this.multiProvider.getSigner(chain);
54
+ this.logger.info({
55
+ chain,
56
+ predicateWrapper: predicateWrapperAddress,
57
+ existingHook: existingHookAddress,
58
+ }, 'Creating aggregation hook');
59
+ const hooks = [predicateWrapperAddress, existingHookAddress];
60
+ const threshold = hooks.length;
61
+ const factory = this.staticAggregationHookFactory.connect(signer);
62
+ const existingAddress = await factory['getAddress(address[],uint8)'](hooks, threshold);
63
+ const code = await this.multiProvider
64
+ .getProvider(chain)
65
+ .getCode(existingAddress);
66
+ let aggregationHookAddress;
67
+ if (code === '0x') {
68
+ const overrides = this.multiProvider.getTransactionOverrides(chain);
69
+ const tx = await factory['deploy(address[],uint8)'](hooks, threshold, overrides);
70
+ await this.multiProvider.handleTx(chain, tx);
71
+ aggregationHookAddress = existingAddress;
72
+ }
73
+ else {
74
+ this.logger.debug({ chain, address: existingAddress }, 'Recovered existing aggregation hook');
75
+ aggregationHookAddress = existingAddress;
76
+ }
77
+ this.logger.info({ chain, address: aggregationHookAddress }, 'Aggregation hook ready');
78
+ return aggregationHookAddress;
79
+ }
80
+ /**
81
+ * Deploys the predicate wrapper and aggregation hook on-chain as a side effect, then
82
+ * returns the populated setHook transaction for the caller to include in its transaction
83
+ * array.
84
+ *
85
+ * IMPORTANT — irreversible side effects: deployPredicateWrapper submits a real on-chain
86
+ * transaction before this method returns. If the caller discards the returned setHookTx
87
+ * (dry-run, cancellation, error), the PredicateRouterWrapper is orphaned — deployed but
88
+ * unreferenced by any warp route. The aggregation hook is safe because
89
+ * StaticAggregationHookFactory uses CREATE2 (idempotent). Eliminating the wrapper orphan
90
+ * risk requires a CREATE2 factory for PredicateRouterWrapper (future contract work).
91
+ *
92
+ * This differs from EvmHookModule/EvmIsmModule: those modules own the full configuration
93
+ * lifecycle (deploy + configure in one atomic step). Here, deployment is eager but the
94
+ * final wiring (setHook) is deferred to EvmWarpModule.update(), which may choose not to
95
+ * submit it.
96
+ *
97
+ * @param existingHookOverride - When provided, skips the on-chain hook() read and uses
98
+ * this address instead. Pass the pending new hook address when a hook update is being
99
+ * applied in the same update() call to avoid wrapping a stale on-chain hook.
100
+ */
101
+ async deployAndConfigure(chain, warpRouteAddress, config, tokenType, existingHookOverride) {
102
+ const signer = this.multiProvider.getSigner(chain);
103
+ // Connect to the appropriate router type
104
+ const isCrossCollateral = tokenType === TokenType.crossCollateral;
105
+ const warpRoute = isCrossCollateral
106
+ ? CrossCollateralRouter__factory.connect(warpRouteAddress, signer)
107
+ : TokenRouter__factory.connect(warpRouteAddress, signer);
108
+ // Use the override when provided (e.g. when a hook update is pending in the same
109
+ // update() call and the on-chain value would be stale).
110
+ const rawExistingHook = existingHookOverride ?? (await warpRoute.hook());
111
+ // If the existing hook is already an aggregation containing a predicate wrapper,
112
+ // unwrap it to the base (non-predicate) hook before re-aggregating. Without this,
113
+ // updating a predicate config would stack wrappers:
114
+ // newAggregation([newWrapper, oldAggregation([oldWrapper, IGP])])
115
+ // instead of the correct:
116
+ // newAggregation([newWrapper, IGP])
117
+ const existingHook = await this.stripPredicateAndReaggregateHook(chain, rawExistingHook);
118
+ // WARNING: deployPredicateWrapper submits a real on-chain transaction here.
119
+ // If the caller discards the returned setHookTx, this wrapper will be orphaned.
120
+ this.logger.warn({ chain, warpRoute: warpRouteAddress }, 'Deploying PredicateRouterWrapper — this on-chain deployment is irreversible. ' +
121
+ 'Submit the returned setHookTx to complete wiring; discarding it will leave the wrapper orphaned.');
122
+ const wrapperAddress = await this.deployPredicateWrapper(chain, warpRouteAddress, config, tokenType);
123
+ let hookToAggregateWith;
124
+ if (existingHook !== constants.AddressZero) {
125
+ hookToAggregateWith = existingHook;
126
+ }
127
+ else {
128
+ const mailboxAddress = await warpRoute.mailbox();
129
+ const mailbox = Mailbox__factory.connect(mailboxAddress, signer);
130
+ hookToAggregateWith = await mailbox.defaultHook();
131
+ this.logger.info({ chain, defaultHook: hookToAggregateWith }, 'Using mailbox default hook for aggregation (warp route had no existing hook)');
132
+ }
133
+ const aggregationHookAddress = await this.createAggregationHook(chain, wrapperAddress, hookToAggregateWith);
134
+ const setHookTx = await warpRoute.populateTransaction.setHook(aggregationHookAddress);
135
+ return {
136
+ wrapperAddress,
137
+ aggregationHookAddress,
138
+ setHookTx,
139
+ };
140
+ }
141
+ /**
142
+ * If hookAddress is a StaticAggregationHook that contains a predicate wrapper,
143
+ * strips it and (when multiple non-predicate sub-hooks remain) re-aggregates
144
+ * them via CREATE2 before returning, so the caller can safely wrap the result
145
+ * in a new aggregation without stacking wrappers.
146
+ *
147
+ * Falls back to hookAddress unchanged when:
148
+ * - The address is zero / not an aggregation hook
149
+ * - No predicate wrapper is found among sub-hooks
150
+ * - Multiple non-predicate sub-hooks remain (cannot safely re-aggregate here)
151
+ */
152
+ async stripPredicateAndReaggregateHook(chain, hookAddress) {
153
+ if (!hookAddress || hookAddress === constants.AddressZero) {
154
+ return hookAddress;
155
+ }
156
+ const provider = this.multiProvider.getProvider(chain);
157
+ let subHooks;
158
+ try {
159
+ subHooks = await StaticAggregationHook__factory.connect(hookAddress, provider).hooks('0x');
160
+ }
161
+ catch {
162
+ // Any failure means hookAddress is not a StaticAggregationHook.
163
+ // SmartProvider wraps CALL_EXCEPTION as "Invalid response from provider" with code: undefined.
164
+ return hookAddress;
165
+ }
166
+ if (!subHooks || subHooks.length === 0)
167
+ return hookAddress;
168
+ const nonPredicateHooks = [];
169
+ for (const sub of subHooks) {
170
+ try {
171
+ const hookType = await PredicateRouterWrapper__factory.connect(sub, provider).hookType();
172
+ if (hookType === OnchainHookType.PREDICATE_ROUTER_WRAPPER) {
173
+ this.logger.debug({ chain, predicateWrapper: sub }, 'Stripping existing predicate wrapper from aggregation to avoid stacking');
174
+ }
175
+ else {
176
+ nonPredicateHooks.push(sub);
177
+ }
178
+ }
179
+ catch {
180
+ // hookType() failed — not a recognisable hook (or SmartProvider wrapped the
181
+ // revert as "Invalid response from provider" with code: undefined); keep it.
182
+ nonPredicateHooks.push(sub);
183
+ }
184
+ }
185
+ if (nonPredicateHooks.length === subHooks.length) {
186
+ // No predicate wrapper found — use hook as-is
187
+ return hookAddress;
188
+ }
189
+ if (nonPredicateHooks.length === 1) {
190
+ // Happy path: exactly one base hook remains
191
+ return nonPredicateHooks[0];
192
+ }
193
+ // Multiple non-predicate sub-hooks remain after removing the predicate wrapper.
194
+ // Re-aggregate them via CREATE2 (idempotent) so the caller produces:
195
+ // outerAgg([newWrapper, innerAgg([hookA, hookB])])
196
+ // instead of the stacking anti-pattern:
197
+ // newAgg([newWrapper, oldAgg([oldWrapper, hookA, hookB])])
198
+ this.logger.debug({ chain, nonPredicateHooks }, 'Multiple non-predicate sub-hooks found — re-aggregating without predicate wrapper');
199
+ const signer = this.multiProvider.getSigner(chain);
200
+ const overrides = this.multiProvider.getTransactionOverrides(chain);
201
+ const factory = this.staticAggregationHookFactory.connect(signer);
202
+ const threshold = nonPredicateHooks.length;
203
+ const innerAggAddress = await factory['getAddress(address[],uint8)'](nonPredicateHooks, threshold);
204
+ const code = await this.multiProvider
205
+ .getProvider(chain)
206
+ .getCode(innerAggAddress);
207
+ if (code === '0x') {
208
+ const tx = await factory['deploy(address[],uint8)'](nonPredicateHooks, threshold, overrides);
209
+ await this.multiProvider.handleTx(chain, tx);
210
+ this.logger.info({ chain, innerAgg: innerAggAddress, hooks: nonPredicateHooks }, 'Inner aggregation hook deployed for predicate-stripped sub-hooks');
211
+ }
212
+ else {
213
+ this.logger.debug({ chain, innerAgg: innerAggAddress }, 'Recovered existing inner aggregation hook');
214
+ }
215
+ return innerAggAddress;
216
+ }
217
+ }
218
+ //# sourceMappingURL=PredicateDeployer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredicateDeployer.js","sourceRoot":"","sources":["../../src/predicate/PredicateDeployer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EACL,8BAA8B,EAC9B,gBAAgB,EAChB,8CAA8C,EAC9C,+BAA+B,EAC/B,8BAA8B,EAE9B,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAW,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,MAAM,OAAO,wBAAwB;IAIhB;IACA;IAJF,MAAM,CAAS;IAEhC,YACmB,aAA4B,EAC5B,4BAA0D,EAC3E,MAAe;QAFE,kBAAa,GAAb,aAAa,CAAe;QAC5B,iCAA4B,GAA5B,4BAA4B,CAA8B;QAG3E,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,KAAgB,EAChB,gBAAyB,EACzB,MAA8B,EAC9B,SAAqB;QAErB,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEnD,MAAM,iBAAiB,GAAG,SAAS,KAAK,SAAS,CAAC,eAAe,CAAC;QAClE,MAAM,WAAW,GAAG,iBAAiB;YACnC,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,wBAAwB,CAAC;QAE7B,IAAI,CAAC,MAAM,CAAC,IAAI,CACd;YACE,KAAK;YACL,SAAS,EAAE,gBAAgB;YAC3B,Q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