@hyperlane-xyz/sdk 4.1.0 → 4.2.0-beta.2
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.
- package/dist/aws/validator.js +1 -1
- package/dist/aws/validator.js.map +1 -1
- package/dist/consts/multisigIsm.d.ts.map +1 -1
- package/dist/consts/multisigIsm.js +52 -19
- package/dist/consts/multisigIsm.js.map +1 -1
- package/dist/core/EvmCoreModule.d.ts +4 -0
- package/dist/core/EvmCoreModule.d.ts.map +1 -1
- package/dist/core/EvmCoreModule.js +8 -9
- package/dist/core/EvmCoreModule.js.map +1 -1
- package/dist/core/EvmIcaModule.d.ts +3 -1
- package/dist/core/EvmIcaModule.d.ts.map +1 -1
- package/dist/core/EvmIcaModule.js +2 -2
- package/dist/core/EvmIcaModule.js.map +1 -1
- package/dist/core/HyperlaneCore.d.ts +23 -7
- package/dist/core/HyperlaneCore.d.ts.map +1 -1
- package/dist/core/HyperlaneCore.js +81 -21
- package/dist/core/HyperlaneCore.js.map +1 -1
- package/dist/core/HyperlaneCoreChecker.d.ts.map +1 -1
- package/dist/core/HyperlaneCoreChecker.js +1 -1
- package/dist/core/HyperlaneCoreChecker.js.map +1 -1
- package/dist/core/HyperlaneCoreDeployer.d.ts.map +1 -1
- package/dist/core/HyperlaneCoreDeployer.js +6 -1
- package/dist/core/HyperlaneCoreDeployer.js.map +1 -1
- package/dist/core/HyperlaneRelayer.d.ts +328 -0
- package/dist/core/HyperlaneRelayer.d.ts.map +1 -0
- package/dist/core/HyperlaneRelayer.js +144 -0
- package/dist/core/HyperlaneRelayer.js.map +1 -0
- package/dist/core/schemas.d.ts +842 -842
- package/dist/deploy/EvmModuleDeployer.d.ts +4 -3
- package/dist/deploy/EvmModuleDeployer.d.ts.map +1 -1
- package/dist/deploy/EvmModuleDeployer.js +11 -4
- package/dist/deploy/EvmModuleDeployer.js.map +1 -1
- package/dist/deploy/HyperlaneDeployer.d.ts +1 -1
- package/dist/deploy/HyperlaneDeployer.d.ts.map +1 -1
- package/dist/deploy/HyperlaneDeployer.js +20 -9
- package/dist/deploy/HyperlaneDeployer.js.map +1 -1
- package/dist/deploy/proxy.d.ts +1 -0
- package/dist/deploy/proxy.d.ts.map +1 -1
- package/dist/deploy/proxy.js +6 -0
- package/dist/deploy/proxy.js.map +1 -1
- package/dist/deploy/schemas.d.ts +1 -0
- package/dist/deploy/schemas.d.ts.map +1 -1
- package/dist/deploy/verify/ContractVerifier.d.ts +20 -6
- package/dist/deploy/verify/ContractVerifier.d.ts.map +1 -1
- package/dist/deploy/verify/ContractVerifier.js +187 -97
- package/dist/deploy/verify/ContractVerifier.js.map +1 -1
- package/dist/deploy/verify/types.d.ts +15 -4
- package/dist/deploy/verify/types.d.ts.map +1 -1
- package/dist/deploy/verify/types.js +4 -3
- package/dist/deploy/verify/types.js.map +1 -1
- package/dist/deploy/verify/utils.d.ts +9 -2
- package/dist/deploy/verify/utils.d.ts.map +1 -1
- package/dist/deploy/verify/utils.js +4 -3
- package/dist/deploy/verify/utils.js.map +1 -1
- package/dist/hook/EvmHookModule.d.ts +45 -6
- package/dist/hook/EvmHookModule.d.ts.map +1 -1
- package/dist/hook/EvmHookModule.hardhat-test.js +334 -106
- package/dist/hook/EvmHookModule.hardhat-test.js.map +1 -1
- package/dist/hook/EvmHookModule.js +291 -68
- package/dist/hook/EvmHookModule.js.map +1 -1
- package/dist/hook/EvmHookReader.d.ts +5 -10
- package/dist/hook/EvmHookReader.d.ts.map +1 -1
- package/dist/hook/EvmHookReader.js +21 -24
- package/dist/hook/EvmHookReader.js.map +1 -1
- package/dist/hook/schemas.d.ts +4 -4
- package/dist/hook/types.d.ts +1 -0
- package/dist/hook/types.d.ts.map +1 -1
- package/dist/hook/types.js +8 -0
- package/dist/hook/types.js.map +1 -1
- package/dist/index.d.ts +61 -58
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -46
- package/dist/index.js.map +1 -1
- package/dist/ism/EvmIsmModule.d.ts +7 -7
- package/dist/ism/EvmIsmModule.d.ts.map +1 -1
- package/dist/ism/EvmIsmModule.hardhat-test.js +9 -28
- package/dist/ism/EvmIsmModule.hardhat-test.js.map +1 -1
- package/dist/ism/EvmIsmModule.js +38 -57
- package/dist/ism/EvmIsmModule.js.map +1 -1
- package/dist/ism/EvmIsmReader.d.ts +5 -4
- package/dist/ism/EvmIsmReader.d.ts.map +1 -1
- package/dist/ism/EvmIsmReader.js +56 -36
- package/dist/ism/EvmIsmReader.js.map +1 -1
- package/dist/ism/HyperlaneIsmFactory.d.ts.map +1 -1
- package/dist/ism/HyperlaneIsmFactory.js +2 -0
- package/dist/ism/HyperlaneIsmFactory.js.map +1 -1
- package/dist/ism/metadata/aggregation.test.js +1 -1
- package/dist/ism/metadata/aggregation.test.js.map +1 -1
- package/dist/ism/metadata/builder.hardhat-test.js +29 -14
- package/dist/ism/metadata/builder.hardhat-test.js.map +1 -1
- package/dist/ism/metadata/multisig.d.ts.map +1 -1
- package/dist/ism/metadata/multisig.js +1 -1
- package/dist/ism/metadata/multisig.js.map +1 -1
- package/dist/ism/utils.js +2 -2
- package/dist/ism/utils.js.map +1 -1
- package/dist/metadata/ChainMetadataManager.d.ts +2 -0
- package/dist/metadata/ChainMetadataManager.d.ts.map +1 -1
- package/dist/metadata/ChainMetadataManager.js +6 -0
- package/dist/metadata/ChainMetadataManager.js.map +1 -1
- package/dist/metadata/agentConfig.d.ts +46 -46
- package/dist/metadata/deploymentArtifacts.d.ts +2 -2
- package/dist/providers/MultiProvider.d.ts +7 -0
- package/dist/providers/MultiProvider.d.ts.map +1 -1
- package/dist/providers/MultiProvider.js +9 -1
- package/dist/providers/MultiProvider.js.map +1 -1
- package/dist/providers/SmartProvider/SmartProvider.d.ts +2 -1
- package/dist/providers/SmartProvider/SmartProvider.d.ts.map +1 -1
- package/dist/providers/SmartProvider/SmartProvider.foundry-test.js +58 -0
- package/dist/providers/SmartProvider/SmartProvider.foundry-test.js.map +1 -1
- package/dist/providers/SmartProvider/SmartProvider.js +34 -9
- package/dist/providers/SmartProvider/SmartProvider.js.map +1 -1
- package/dist/providers/transactions/schemas.d.ts +13 -0
- package/dist/providers/transactions/schemas.d.ts.map +1 -1
- package/dist/providers/transactions/schemas.js +1 -0
- package/dist/providers/transactions/schemas.js.map +1 -1
- package/dist/providers/transactions/submitter/builder/schemas.d.ts +67 -146
- package/dist/providers/transactions/submitter/builder/schemas.d.ts.map +1 -1
- package/dist/providers/transactions/submitter/ethersV5/EV5GnosisSafeTxSubmitter.d.ts +2 -2
- package/dist/providers/transactions/submitter/ethersV5/EV5GnosisSafeTxSubmitter.d.ts.map +1 -1
- package/dist/providers/transactions/submitter/ethersV5/EV5GnosisSafeTxSubmitter.js.map +1 -1
- package/dist/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.d.ts +2 -2
- package/dist/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.d.ts.map +1 -1
- package/dist/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.js.map +1 -1
- package/dist/providers/transactions/submitter/ethersV5/EV5JsonRpcTxSubmitter.d.ts +2 -2
- package/dist/providers/transactions/submitter/ethersV5/EV5JsonRpcTxSubmitter.d.ts.map +1 -1
- package/dist/providers/transactions/submitter/ethersV5/EV5JsonRpcTxSubmitter.js.map +1 -1
- package/dist/providers/transactions/submitter/schemas.d.ts +9 -34
- package/dist/providers/transactions/submitter/schemas.d.ts.map +1 -1
- package/dist/providers/transactions/submitter/schemas.js +2 -3
- package/dist/providers/transactions/submitter/schemas.js.map +1 -1
- package/dist/providers/transactions/transformer/ethersV5/EV5InterchainAccountTxTransformer.d.ts +2 -2
- package/dist/providers/transactions/transformer/ethersV5/EV5InterchainAccountTxTransformer.d.ts.map +1 -1
- package/dist/providers/transactions/transformer/ethersV5/EV5InterchainAccountTxTransformer.js +5 -5
- package/dist/providers/transactions/transformer/ethersV5/EV5InterchainAccountTxTransformer.js.map +1 -1
- package/dist/providers/transactions/transformer/schemas.d.ts +36 -76
- package/dist/providers/transactions/transformer/schemas.d.ts.map +1 -1
- package/dist/providers/transactions/transformer/schemas.js +1 -1
- package/dist/providers/transactions/transformer/schemas.js.map +1 -1
- package/dist/providers/transactions/types.d.ts +2 -1
- package/dist/providers/transactions/types.d.ts.map +1 -1
- package/dist/router/schemas.d.ts +97 -90
- package/dist/router/schemas.d.ts.map +1 -1
- package/dist/router/schemas.js +6 -1
- package/dist/router/schemas.js.map +1 -1
- package/dist/router/types.d.ts +2 -1
- package/dist/router/types.d.ts.map +1 -1
- package/dist/router/types.js.map +1 -1
- package/dist/test/testUtils.js +1 -1
- package/dist/test/testUtils.js.map +1 -1
- package/dist/token/EvmERC20WarpModule.d.ts +20 -1
- package/dist/token/EvmERC20WarpModule.d.ts.map +1 -1
- package/dist/token/EvmERC20WarpModule.hardhat-test.js +123 -2
- package/dist/token/EvmERC20WarpModule.hardhat-test.js.map +1 -1
- package/dist/token/EvmERC20WarpModule.js +93 -21
- package/dist/token/EvmERC20WarpModule.js.map +1 -1
- package/dist/token/EvmERC20WarpRouteReader.d.ts +4 -9
- package/dist/token/EvmERC20WarpRouteReader.d.ts.map +1 -1
- package/dist/token/EvmERC20WarpRouteReader.hardhat-test.js +27 -2
- package/dist/token/EvmERC20WarpRouteReader.hardhat-test.js.map +1 -1
- package/dist/token/EvmERC20WarpRouteReader.js +19 -21
- package/dist/token/EvmERC20WarpRouteReader.js.map +1 -1
- package/dist/token/IToken.d.ts +6 -6
- package/dist/token/TokenConnection.d.ts +2 -2
- package/dist/token/deploy.d.ts.map +1 -1
- package/dist/token/deploy.js +14 -5
- package/dist/token/deploy.js.map +1 -1
- package/dist/token/schemas.d.ts +96 -88
- package/dist/token/schemas.d.ts.map +1 -1
- package/dist/utils/HyperlaneReader.d.ts +17 -0
- package/dist/utils/HyperlaneReader.d.ts.map +1 -0
- package/dist/utils/HyperlaneReader.js +21 -0
- package/dist/utils/HyperlaneReader.js.map +1 -0
- package/dist/utils/cosmos.d.ts +5 -0
- package/dist/utils/cosmos.d.ts.map +1 -1
- package/dist/utils/cosmos.js +7 -1
- package/dist/utils/cosmos.js.map +1 -1
- package/dist/warp/WarpCore.d.ts +12 -0
- package/dist/warp/WarpCore.d.ts.map +1 -1
- package/dist/warp/WarpCore.js +63 -32
- package/dist/warp/WarpCore.js.map +1 -1
- package/dist/warp/types.d.ts +10 -10
- package/package.json +3 -3
|
@@ -22,29 +22,55 @@ type HookModuleAddresses = {
|
|
|
22
22
|
};
|
|
23
23
|
export declare class EvmHookModule extends HyperlaneModule<ProtocolType.Ethereum, HookConfig, HyperlaneAddresses<ProxyFactoryFactories> & HookModuleAddresses> {
|
|
24
24
|
protected readonly multiProvider: MultiProvider;
|
|
25
|
+
protected readonly contractVerifier?: ContractVerifier | undefined;
|
|
25
26
|
protected readonly logger: import("pino").default.Logger<never>;
|
|
26
27
|
protected readonly reader: EvmHookReader;
|
|
27
28
|
protected readonly deployer: EvmModuleDeployer<HookFactories & IgpFactories>;
|
|
28
29
|
readonly chain: string;
|
|
29
30
|
readonly domainId: number;
|
|
30
31
|
protected readonly txOverrides: Partial<ethers.providers.TransactionRequest>;
|
|
31
|
-
protected constructor(multiProvider: MultiProvider,
|
|
32
|
+
protected constructor(multiProvider: MultiProvider, params: HyperlaneModuleParams<HookConfig, HyperlaneAddresses<ProxyFactoryFactories> & HookModuleAddresses>, contractVerifier?: ContractVerifier | undefined);
|
|
32
33
|
read(): Promise<HookConfig>;
|
|
33
|
-
update(
|
|
34
|
-
static create({ chain, config, proxyFactoryFactories, coreAddresses, multiProvider, }: {
|
|
34
|
+
update(targetConfig: HookConfig): Promise<AnnotatedEV5Transaction[]>;
|
|
35
|
+
static create({ chain, config, proxyFactoryFactories, coreAddresses, multiProvider, contractVerifier, }: {
|
|
35
36
|
chain: ChainNameOrId;
|
|
36
37
|
config: HookConfig;
|
|
37
38
|
proxyFactoryFactories: HyperlaneAddresses<ProxyFactoryFactories>;
|
|
38
39
|
coreAddresses: CoreAddresses;
|
|
39
40
|
multiProvider: MultiProvider;
|
|
41
|
+
contractVerifier?: ContractVerifier;
|
|
40
42
|
}): Promise<EvmHookModule>;
|
|
41
43
|
protected computeRoutingHooksToSet({ currentDomains, targetDomains, }: {
|
|
42
44
|
currentDomains: DomainRoutingHookConfig['domains'];
|
|
43
45
|
targetDomains: DomainRoutingHookConfig['domains'];
|
|
44
46
|
}): Promise<DomainRoutingHook.HookConfigStruct[]>;
|
|
45
|
-
protected
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
protected updatePausableHook({ currentConfig, targetConfig, }: {
|
|
48
|
+
currentConfig: PausableHookConfig;
|
|
49
|
+
targetConfig: PausableHookConfig;
|
|
50
|
+
}): Promise<AnnotatedEV5Transaction[]>;
|
|
51
|
+
protected updateIgpHook({ currentConfig, targetConfig, }: {
|
|
52
|
+
currentConfig: IgpHookConfig;
|
|
53
|
+
targetConfig: IgpHookConfig;
|
|
54
|
+
}): Promise<AnnotatedEV5Transaction[]>;
|
|
55
|
+
protected updateIgpRemoteGasParams({ interchainGasPaymaster, gasOracle, currentOverheads, targetOverheads, }: {
|
|
56
|
+
interchainGasPaymaster: Address;
|
|
57
|
+
gasOracle: Address;
|
|
58
|
+
currentOverheads?: IgpConfig['overhead'];
|
|
59
|
+
targetOverheads: IgpConfig['overhead'];
|
|
60
|
+
}): Promise<AnnotatedEV5Transaction[]>;
|
|
61
|
+
protected updateStorageGasOracle({ gasOracle, currentOracleConfig, targetOracleConfig, targetOverhead, }: {
|
|
62
|
+
gasOracle: Address;
|
|
63
|
+
currentOracleConfig?: IgpConfig['oracleConfig'];
|
|
64
|
+
targetOracleConfig: IgpConfig['oracleConfig'];
|
|
65
|
+
targetOverhead: IgpConfig['overhead'];
|
|
66
|
+
}): Promise<AnnotatedEV5Transaction[]>;
|
|
67
|
+
protected updateProtocolFeeHook({ currentConfig, targetConfig, }: {
|
|
68
|
+
currentConfig: ProtocolFeeHookConfig;
|
|
69
|
+
targetConfig: ProtocolFeeHookConfig;
|
|
70
|
+
}): Promise<AnnotatedEV5Transaction[]>;
|
|
71
|
+
protected updateRoutingHook({ currentConfig, targetConfig, }: {
|
|
72
|
+
currentConfig: DomainRoutingHookConfig | FallbackRoutingHookConfig;
|
|
73
|
+
targetConfig: DomainRoutingHookConfig | FallbackRoutingHookConfig;
|
|
48
74
|
}): Promise<AnnotatedEV5Transaction[]>;
|
|
49
75
|
protected deploy({ config, }: {
|
|
50
76
|
config: HookConfig;
|
|
@@ -74,6 +100,19 @@ export declare class EvmHookModule extends HyperlaneModule<ProtocolType.Ethereum
|
|
|
74
100
|
protected deployStorageGasOracle({ config, }: {
|
|
75
101
|
config: IgpConfig;
|
|
76
102
|
}): Promise<StorageGasOracle>;
|
|
103
|
+
/**
|
|
104
|
+
* Determines if a new hook should be deployed based on the current and target configurations.
|
|
105
|
+
*
|
|
106
|
+
* @param currentConfig - The current hook configuration.
|
|
107
|
+
* @param targetConfig - The target hook configuration. Must not be a string.
|
|
108
|
+
* @returns {boolean} - Returns true if a new hook should be deployed, otherwise false.
|
|
109
|
+
*
|
|
110
|
+
* Conditions for deploying a new hook:
|
|
111
|
+
* - If updating from an address/custom config to a proper hook config.
|
|
112
|
+
* - If updating a proper hook config whose types are different.
|
|
113
|
+
* - If it is not a mutable Hook.
|
|
114
|
+
*/
|
|
115
|
+
private shouldDeployNewHook;
|
|
77
116
|
}
|
|
78
117
|
export {};
|
|
79
118
|
//# sourceMappingURL=EvmHookModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmHookModule.d.ts","sourceRoot":"","sources":["../../src/hook/EvmHookModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EACL,iBAAiB,EAKjB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"EvmHookModule.d.ts","sourceRoot":"","sources":["../../src/hook/EvmHookModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,E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CAAC,EACrC,MAAM,GACP,EAAE;QACD,MAAM,EAAE,SAAS,CAAC;KACnB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA6B7B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,mBAAmB;CAU5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import hre from 'hardhat';
|
|
4
|
-
import {
|
|
4
|
+
import { assert, deepEquals, eqAddress, normalizeConfig, } from '@hyperlane-xyz/utils';
|
|
5
5
|
import { TestChainName, testChains } from '../consts/testChains.js';
|
|
6
6
|
import { TestCoreDeployer } from '../core/TestCoreDeployer.js';
|
|
7
7
|
import { HyperlaneProxyFactoryDeployer } from '../deploy/HyperlaneProxyFactoryDeployer.js';
|
|
@@ -9,7 +9,7 @@ import { HyperlaneIsmFactory } from '../ism/HyperlaneIsmFactory.js';
|
|
|
9
9
|
import { MultiProvider } from '../providers/MultiProvider.js';
|
|
10
10
|
import { randomAddress, randomInt } from '../test/testUtils.js';
|
|
11
11
|
import { EvmHookModule } from './EvmHookModule.js';
|
|
12
|
-
import { HookType, } from './types.js';
|
|
12
|
+
import { HookType, MUTABLE_HOOK_TYPE, } from './types.js';
|
|
13
13
|
const hookTypes = Object.values(HookType);
|
|
14
14
|
function randomHookType() {
|
|
15
15
|
// OP_STACK filtering is temporary until we have a way to deploy the required contracts
|
|
@@ -102,13 +102,16 @@ function randomHookConfig(depth = 0, maxDepth = 2, providedHookType) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
describe('EvmHookModule', async () => {
|
|
105
|
+
const chain = TestChainName.test4;
|
|
105
106
|
let multiProvider;
|
|
106
107
|
let coreAddresses;
|
|
107
|
-
|
|
108
|
+
let signer;
|
|
109
|
+
let funder;
|
|
108
110
|
let proxyFactoryAddresses;
|
|
109
111
|
let factoryContracts;
|
|
112
|
+
let exampleRoutingConfig;
|
|
110
113
|
beforeEach(async () => {
|
|
111
|
-
|
|
114
|
+
[signer, funder] = await hre.ethers.getSigners();
|
|
112
115
|
multiProvider = MultiProvider.createTestMultiProvider({ signer });
|
|
113
116
|
const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider);
|
|
114
117
|
const contractsMap = await ismFactoryDeployer.deploy(multiProvider.mapKnownChains(() => ({})));
|
|
@@ -130,24 +133,46 @@ describe('EvmHookModule', async () => {
|
|
|
130
133
|
proxyAdmin: proxyAdmin.address,
|
|
131
134
|
validatorAnnounce: validatorAnnounce.address,
|
|
132
135
|
};
|
|
136
|
+
// reusable for routing/fallback routing specific tests
|
|
137
|
+
exampleRoutingConfig = {
|
|
138
|
+
owner: (await multiProvider.getSignerAddress(chain)).toLowerCase(),
|
|
139
|
+
domains: Object.fromEntries(testChains.map((c) => [
|
|
140
|
+
c,
|
|
141
|
+
{
|
|
142
|
+
type: HookType.MERKLE_TREE,
|
|
143
|
+
},
|
|
144
|
+
])),
|
|
145
|
+
type: HookType.FALLBACK_ROUTING,
|
|
146
|
+
fallback: { type: HookType.MERKLE_TREE },
|
|
147
|
+
};
|
|
133
148
|
});
|
|
134
|
-
// Helper method for
|
|
135
|
-
async function
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
// Helper method for create a new multiprovider with an impersonated account
|
|
150
|
+
async function impersonateAccount(account) {
|
|
151
|
+
await hre.ethers.provider.send('hardhat_impersonateAccount', [account]);
|
|
152
|
+
await funder.sendTransaction({
|
|
153
|
+
to: account,
|
|
154
|
+
value: hre.ethers.utils.parseEther('1.0'),
|
|
155
|
+
});
|
|
156
|
+
return MultiProvider.createTestMultiProvider({
|
|
157
|
+
signer: hre.ethers.provider.getSigner(account),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Helper method to expect exactly N updates to be applied
|
|
161
|
+
async function expectTxsAndUpdate(hook, config, n) {
|
|
162
|
+
const txs = await hook.update(config);
|
|
163
|
+
expect(txs.length).to.equal(n);
|
|
164
|
+
for (const tx of txs) {
|
|
165
|
+
await multiProvider.sendTransaction(chain, tx);
|
|
142
166
|
}
|
|
143
|
-
return matches;
|
|
144
167
|
}
|
|
145
168
|
// hook module and config for testing
|
|
146
169
|
let testHook;
|
|
147
170
|
let testConfig;
|
|
148
171
|
// expect that the hook matches the config after all tests
|
|
149
172
|
afterEach(async () => {
|
|
150
|
-
|
|
173
|
+
const normalizedDerivedConfig = normalizeConfig(await testHook.read());
|
|
174
|
+
const normalizedConfig = normalizeConfig(testConfig);
|
|
175
|
+
deepEquals(normalizedDerivedConfig, normalizedConfig);
|
|
151
176
|
});
|
|
152
177
|
// create a new Hook and verify that it matches the config
|
|
153
178
|
async function createHook(config) {
|
|
@@ -158,106 +183,36 @@ describe('EvmHookModule', async () => {
|
|
|
158
183
|
coreAddresses,
|
|
159
184
|
multiProvider,
|
|
160
185
|
});
|
|
161
|
-
testConfig = config;
|
|
162
186
|
testHook = hook;
|
|
187
|
+
testConfig = config;
|
|
163
188
|
return { hook, initialHookAddress: hook.serialize().deployedHook };
|
|
164
189
|
}
|
|
165
190
|
describe('create', async () => {
|
|
191
|
+
// generate a random config for each hook type
|
|
192
|
+
const exampleHookConfigs = [
|
|
193
|
+
// include an address config
|
|
194
|
+
randomAddress(),
|
|
195
|
+
...hookTypes
|
|
196
|
+
// need to setup deploying/mocking IL1CrossDomainMessenger before this test can be enabled
|
|
197
|
+
.filter((hookType) => hookType !== HookType.OP_STACK && hookType !== HookType.CUSTOM)
|
|
198
|
+
// generate a random config for each hook type
|
|
199
|
+
.map((hookType) => {
|
|
200
|
+
return randomHookConfig(0, 1, hookType);
|
|
201
|
+
}),
|
|
202
|
+
];
|
|
203
|
+
// test deployment of each hookType, except OP_STACK and CUSTOM
|
|
204
|
+
// minimum depth only
|
|
205
|
+
for (const config of exampleHookConfigs) {
|
|
206
|
+
it(`deploys a hook of type ${typeof config === 'string' ? 'address' : config.type}`, async () => {
|
|
207
|
+
await createHook(config);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// manually include test for CUSTOM hook type
|
|
166
211
|
it('deploys a hook of type CUSTOM', async () => {
|
|
167
212
|
const config = randomAddress();
|
|
168
213
|
await createHook(config);
|
|
169
214
|
});
|
|
170
|
-
|
|
171
|
-
const config = {
|
|
172
|
-
type: HookType.MERKLE_TREE,
|
|
173
|
-
};
|
|
174
|
-
await createHook(config);
|
|
175
|
-
});
|
|
176
|
-
it('deploys a hook of type INTERCHAIN_GAS_PAYMASTER', async () => {
|
|
177
|
-
const owner = randomAddress();
|
|
178
|
-
const config = {
|
|
179
|
-
owner,
|
|
180
|
-
type: HookType.INTERCHAIN_GAS_PAYMASTER,
|
|
181
|
-
beneficiary: randomAddress(),
|
|
182
|
-
oracleKey: owner,
|
|
183
|
-
overhead: Object.fromEntries(testChains.map((c) => [c, Math.floor(Math.random() * 100)])),
|
|
184
|
-
oracleConfig: Object.fromEntries(testChains.map((c) => [
|
|
185
|
-
c,
|
|
186
|
-
{
|
|
187
|
-
tokenExchangeRate: randomInt(1234567891234).toString(),
|
|
188
|
-
gasPrice: randomInt(1234567891234).toString(),
|
|
189
|
-
},
|
|
190
|
-
])),
|
|
191
|
-
};
|
|
192
|
-
await createHook(config);
|
|
193
|
-
});
|
|
194
|
-
it('deploys a hook of type PROTOCOL_FEE', async () => {
|
|
195
|
-
const { maxProtocolFee, protocolFee } = randomProtocolFee();
|
|
196
|
-
const config = {
|
|
197
|
-
owner: randomAddress(),
|
|
198
|
-
type: HookType.PROTOCOL_FEE,
|
|
199
|
-
maxProtocolFee,
|
|
200
|
-
protocolFee,
|
|
201
|
-
beneficiary: randomAddress(),
|
|
202
|
-
};
|
|
203
|
-
await createHook(config);
|
|
204
|
-
});
|
|
205
|
-
it('deploys a hook of type ROUTING', async () => {
|
|
206
|
-
const config = {
|
|
207
|
-
owner: randomAddress(),
|
|
208
|
-
type: HookType.ROUTING,
|
|
209
|
-
domains: Object.fromEntries(testChains
|
|
210
|
-
.filter((c) => c !== TestChainName.test4)
|
|
211
|
-
.map((c) => [
|
|
212
|
-
c,
|
|
213
|
-
{
|
|
214
|
-
type: HookType.MERKLE_TREE,
|
|
215
|
-
},
|
|
216
|
-
])),
|
|
217
|
-
};
|
|
218
|
-
await createHook(config);
|
|
219
|
-
});
|
|
220
|
-
it('deploys a hook of type FALLBACK_ROUTING', async () => {
|
|
221
|
-
const config = {
|
|
222
|
-
owner: randomAddress(),
|
|
223
|
-
type: HookType.FALLBACK_ROUTING,
|
|
224
|
-
fallback: { type: HookType.MERKLE_TREE },
|
|
225
|
-
domains: Object.fromEntries(testChains
|
|
226
|
-
.filter((c) => c !== TestChainName.test4)
|
|
227
|
-
.map((c) => [
|
|
228
|
-
c,
|
|
229
|
-
{
|
|
230
|
-
type: HookType.MERKLE_TREE,
|
|
231
|
-
},
|
|
232
|
-
])),
|
|
233
|
-
};
|
|
234
|
-
await createHook(config);
|
|
235
|
-
});
|
|
236
|
-
it('deploys a hook of type AGGREGATION', async () => {
|
|
237
|
-
const config = {
|
|
238
|
-
type: HookType.AGGREGATION,
|
|
239
|
-
hooks: [{ type: HookType.MERKLE_TREE }, { type: HookType.MERKLE_TREE }],
|
|
240
|
-
};
|
|
241
|
-
await createHook(config);
|
|
242
|
-
});
|
|
243
|
-
it('deploys a hook of type PAUSABLE', async () => {
|
|
244
|
-
const config = {
|
|
245
|
-
owner: randomAddress(),
|
|
246
|
-
type: HookType.PAUSABLE,
|
|
247
|
-
paused: false,
|
|
248
|
-
};
|
|
249
|
-
await createHook(config);
|
|
250
|
-
});
|
|
251
|
-
// it('deploys a hook of type OP_STACK', async () => {
|
|
252
|
-
// need to setup deploying/mocking IL1CrossDomainMessenger before this test can be enabled
|
|
253
|
-
// const config: OpStackHookConfig = {
|
|
254
|
-
// owner: randomAddress(),
|
|
255
|
-
// type: HookType.OP_STACK,
|
|
256
|
-
// nativeBridge: randomAddress(),
|
|
257
|
-
// destinationChain: 'testChain',
|
|
258
|
-
// };
|
|
259
|
-
// await createHook(config);
|
|
260
|
-
// });
|
|
215
|
+
// random configs upto depth 2
|
|
261
216
|
for (let i = 0; i < 16; i++) {
|
|
262
217
|
it(`deploys a random hook config #${i}`, async () => {
|
|
263
218
|
// random config with depth 0-2
|
|
@@ -265,6 +220,7 @@ describe('EvmHookModule', async () => {
|
|
|
265
220
|
await createHook(config);
|
|
266
221
|
});
|
|
267
222
|
}
|
|
223
|
+
// manual test to catch regressions on a complex config type
|
|
268
224
|
it('regression test #1', async () => {
|
|
269
225
|
const config = {
|
|
270
226
|
type: HookType.AGGREGATION,
|
|
@@ -376,5 +332,277 @@ describe('EvmHookModule', async () => {
|
|
|
376
332
|
await createHook(config);
|
|
377
333
|
});
|
|
378
334
|
});
|
|
335
|
+
describe('update', async () => {
|
|
336
|
+
it('should update by deploying a new aggregation hook', async () => {
|
|
337
|
+
const config = {
|
|
338
|
+
type: HookType.AGGREGATION,
|
|
339
|
+
hooks: [randomHookConfig(0, 2), randomHookConfig(0, 2)],
|
|
340
|
+
};
|
|
341
|
+
// create a new hook
|
|
342
|
+
const { hook, initialHookAddress } = await createHook(config);
|
|
343
|
+
// change the hooks
|
|
344
|
+
config.hooks = [randomHookConfig(0, 2), randomHookConfig(0, 2)];
|
|
345
|
+
// expect 0 tx to be returned, as it should deploy a new aggregation hook
|
|
346
|
+
await expectTxsAndUpdate(hook, config, 0);
|
|
347
|
+
// expect the hook address to be different
|
|
348
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to.be
|
|
349
|
+
.false;
|
|
350
|
+
});
|
|
351
|
+
const createDeployerOwnedIgpHookConfig = async () => {
|
|
352
|
+
const owner = await multiProvider.getSignerAddress(chain);
|
|
353
|
+
return {
|
|
354
|
+
owner,
|
|
355
|
+
type: HookType.INTERCHAIN_GAS_PAYMASTER,
|
|
356
|
+
beneficiary: randomAddress(),
|
|
357
|
+
oracleKey: owner,
|
|
358
|
+
overhead: Object.fromEntries(testChains.map((c) => [c, Math.floor(Math.random() * 100)])),
|
|
359
|
+
oracleConfig: Object.fromEntries(testChains.map((c) => [
|
|
360
|
+
c,
|
|
361
|
+
{
|
|
362
|
+
tokenExchangeRate: randomInt(1234567891234).toString(),
|
|
363
|
+
gasPrice: randomInt(1234567891234).toString(),
|
|
364
|
+
},
|
|
365
|
+
])),
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
it('should update beneficiary in IGP', async () => {
|
|
369
|
+
const config = await createDeployerOwnedIgpHookConfig();
|
|
370
|
+
// create a new hook
|
|
371
|
+
const { hook } = await createHook(config);
|
|
372
|
+
// change the beneficiary
|
|
373
|
+
config.beneficiary = randomAddress();
|
|
374
|
+
// expect 1 tx to update the beneficiary
|
|
375
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
376
|
+
});
|
|
377
|
+
it('should update the overheads in IGP', async () => {
|
|
378
|
+
const config = await createDeployerOwnedIgpHookConfig();
|
|
379
|
+
// create a new hook
|
|
380
|
+
const { hook } = await createHook(config);
|
|
381
|
+
// change the overheads
|
|
382
|
+
config.overhead = Object.fromEntries(testChains.map((c) => [c, Math.floor(Math.random() * 100)]));
|
|
383
|
+
// expect 1 tx to update the overheads
|
|
384
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
385
|
+
});
|
|
386
|
+
it('should update the oracle config in IGP', async () => {
|
|
387
|
+
const config = await createDeployerOwnedIgpHookConfig();
|
|
388
|
+
// create a new hook
|
|
389
|
+
const { hook } = await createHook(config);
|
|
390
|
+
// change the oracle config
|
|
391
|
+
config.oracleConfig = Object.fromEntries(testChains.map((c) => [
|
|
392
|
+
c,
|
|
393
|
+
{
|
|
394
|
+
tokenExchangeRate: randomInt(987654321).toString(),
|
|
395
|
+
gasPrice: randomInt(987654321).toString(),
|
|
396
|
+
},
|
|
397
|
+
]));
|
|
398
|
+
// expect 1 tx to update the oracle config
|
|
399
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
400
|
+
});
|
|
401
|
+
it('should update protocol fee in protocol fee hook', async () => {
|
|
402
|
+
const config = {
|
|
403
|
+
owner: await multiProvider.getSignerAddress(chain),
|
|
404
|
+
type: HookType.PROTOCOL_FEE,
|
|
405
|
+
maxProtocolFee: '1000',
|
|
406
|
+
protocolFee: '100',
|
|
407
|
+
beneficiary: randomAddress(),
|
|
408
|
+
};
|
|
409
|
+
// create a new hook
|
|
410
|
+
const { hook } = await createHook(config);
|
|
411
|
+
// change the protocol fee
|
|
412
|
+
config.protocolFee = '200';
|
|
413
|
+
// expect 1 tx to update the protocol fee
|
|
414
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
415
|
+
});
|
|
416
|
+
it('should update max fee in protocol fee hook', async () => {
|
|
417
|
+
const config = {
|
|
418
|
+
owner: await multiProvider.getSignerAddress(chain),
|
|
419
|
+
type: HookType.PROTOCOL_FEE,
|
|
420
|
+
maxProtocolFee: '1000',
|
|
421
|
+
protocolFee: '100',
|
|
422
|
+
beneficiary: randomAddress(),
|
|
423
|
+
};
|
|
424
|
+
// create a new hook
|
|
425
|
+
const { hook, initialHookAddress } = await createHook(config);
|
|
426
|
+
// change the protocol fee
|
|
427
|
+
config.maxProtocolFee = '2000';
|
|
428
|
+
// expect 0 tx to update the max protocol fee as it has to deploy a new hook
|
|
429
|
+
await expectTxsAndUpdate(hook, config, 0);
|
|
430
|
+
// expect the hook address to be different
|
|
431
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to.be
|
|
432
|
+
.false;
|
|
433
|
+
});
|
|
434
|
+
it('should update paused state of pausable hook', async () => {
|
|
435
|
+
const config = {
|
|
436
|
+
owner: randomAddress(),
|
|
437
|
+
type: HookType.PAUSABLE,
|
|
438
|
+
paused: false,
|
|
439
|
+
};
|
|
440
|
+
// create a new hook
|
|
441
|
+
const { hook } = await createHook(config);
|
|
442
|
+
// change the paused state
|
|
443
|
+
config.paused = true;
|
|
444
|
+
// impersonate the hook owner
|
|
445
|
+
multiProvider = await impersonateAccount(config.owner);
|
|
446
|
+
// expect 1 tx to update the paused state
|
|
447
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
448
|
+
});
|
|
449
|
+
for (const type of [HookType.ROUTING, HookType.FALLBACK_ROUTING]) {
|
|
450
|
+
beforeEach(() => {
|
|
451
|
+
exampleRoutingConfig.type = type;
|
|
452
|
+
});
|
|
453
|
+
it(`should skip deployment with warning if no chain metadata configured ${type}`, async () => {
|
|
454
|
+
// create a new hook
|
|
455
|
+
const { hook } = await createHook(exampleRoutingConfig);
|
|
456
|
+
// add config for a domain the multiprovider doesn't have
|
|
457
|
+
const updatedConfig = {
|
|
458
|
+
...exampleRoutingConfig,
|
|
459
|
+
domains: {
|
|
460
|
+
...exampleRoutingConfig.domains,
|
|
461
|
+
test5: { type: HookType.MERKLE_TREE },
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
// expect 0 txs, as adding test5 domain is no-op
|
|
465
|
+
await expectTxsAndUpdate(hook, updatedConfig, 0);
|
|
466
|
+
});
|
|
467
|
+
it(`no changes to an existing ${type} means no redeployment or updates`, async () => {
|
|
468
|
+
// create a new hook
|
|
469
|
+
const { hook, initialHookAddress } = await createHook(exampleRoutingConfig);
|
|
470
|
+
// expect 0 updates
|
|
471
|
+
await expectTxsAndUpdate(hook, exampleRoutingConfig, 0);
|
|
472
|
+
// expect the hook address to be the same
|
|
473
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to
|
|
474
|
+
.be.true;
|
|
475
|
+
});
|
|
476
|
+
it(`updates an existing ${type} with new domains`, async () => {
|
|
477
|
+
exampleRoutingConfig = {
|
|
478
|
+
owner: (await multiProvider.getSignerAddress(chain)).toLowerCase(),
|
|
479
|
+
domains: {
|
|
480
|
+
test1: {
|
|
481
|
+
type: HookType.MERKLE_TREE,
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
type: HookType.FALLBACK_ROUTING,
|
|
485
|
+
fallback: { type: HookType.MERKLE_TREE },
|
|
486
|
+
};
|
|
487
|
+
// create a new hook
|
|
488
|
+
const { hook, initialHookAddress } = await createHook(exampleRoutingConfig);
|
|
489
|
+
// add a new domain
|
|
490
|
+
exampleRoutingConfig.domains[TestChainName.test2] = {
|
|
491
|
+
type: HookType.MERKLE_TREE,
|
|
492
|
+
};
|
|
493
|
+
// expect 1 tx to update the domains
|
|
494
|
+
await expectTxsAndUpdate(hook, exampleRoutingConfig, 1);
|
|
495
|
+
// expect the hook address to be the same
|
|
496
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to
|
|
497
|
+
.be.true;
|
|
498
|
+
});
|
|
499
|
+
it(`updates an existing ${type} with new domains`, async () => {
|
|
500
|
+
exampleRoutingConfig = {
|
|
501
|
+
owner: (await multiProvider.getSignerAddress(chain)).toLowerCase(),
|
|
502
|
+
domains: {
|
|
503
|
+
test1: {
|
|
504
|
+
type: HookType.MERKLE_TREE,
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
type: HookType.FALLBACK_ROUTING,
|
|
508
|
+
fallback: { type: HookType.MERKLE_TREE },
|
|
509
|
+
};
|
|
510
|
+
// create a new hook
|
|
511
|
+
const { hook, initialHookAddress } = await createHook(exampleRoutingConfig);
|
|
512
|
+
// add multiple new domains
|
|
513
|
+
exampleRoutingConfig.domains[TestChainName.test2] = {
|
|
514
|
+
type: HookType.MERKLE_TREE,
|
|
515
|
+
};
|
|
516
|
+
exampleRoutingConfig.domains[TestChainName.test3] = {
|
|
517
|
+
type: HookType.MERKLE_TREE,
|
|
518
|
+
};
|
|
519
|
+
exampleRoutingConfig.domains[TestChainName.test4] = {
|
|
520
|
+
type: HookType.MERKLE_TREE,
|
|
521
|
+
};
|
|
522
|
+
// expect 1 tx to update the domains
|
|
523
|
+
await expectTxsAndUpdate(hook, exampleRoutingConfig, 1);
|
|
524
|
+
// expect the hook address to be the same
|
|
525
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to
|
|
526
|
+
.be.true;
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
it(`update fallback in an existing fallback routing hook`, async () => {
|
|
530
|
+
// create a new hook
|
|
531
|
+
const config = exampleRoutingConfig;
|
|
532
|
+
const { hook, initialHookAddress } = await createHook(config);
|
|
533
|
+
// change the fallback
|
|
534
|
+
config.fallback = {
|
|
535
|
+
type: HookType.PROTOCOL_FEE,
|
|
536
|
+
owner: randomAddress(),
|
|
537
|
+
maxProtocolFee: '9000',
|
|
538
|
+
protocolFee: '350',
|
|
539
|
+
beneficiary: randomAddress(),
|
|
540
|
+
};
|
|
541
|
+
// expect 0 tx as it will have to deploy a new fallback routing hook
|
|
542
|
+
await expectTxsAndUpdate(hook, config, 0);
|
|
543
|
+
// expect the hook address to be different
|
|
544
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to.be
|
|
545
|
+
.false;
|
|
546
|
+
});
|
|
547
|
+
it(`update fallback in an existing fallback routing hook with no change`, async () => {
|
|
548
|
+
// create a new hook
|
|
549
|
+
const config = exampleRoutingConfig;
|
|
550
|
+
const { hook } = await createHook(config);
|
|
551
|
+
// expect 0 updates
|
|
552
|
+
await expectTxsAndUpdate(hook, config, 0);
|
|
553
|
+
});
|
|
554
|
+
// generate a random config for each ownable hook type
|
|
555
|
+
const ownableHooks = hookTypes
|
|
556
|
+
.filter((hookType) => MUTABLE_HOOK_TYPE.includes(hookType))
|
|
557
|
+
.map((hookType) => {
|
|
558
|
+
return randomHookConfig(0, 1, hookType);
|
|
559
|
+
});
|
|
560
|
+
for (const config of ownableHooks) {
|
|
561
|
+
assert(typeof config !== 'string', 'Address is not an ownable hook config');
|
|
562
|
+
assert('owner' in config, 'Ownable hook config must have an owner property');
|
|
563
|
+
it(`updates owner in an existing ${config.type}`, async () => {
|
|
564
|
+
// hook owned by the deployer
|
|
565
|
+
config.owner = await multiProvider.getSignerAddress(chain);
|
|
566
|
+
// create a new hook
|
|
567
|
+
const { hook, initialHookAddress } = await createHook(config);
|
|
568
|
+
// change the config owner
|
|
569
|
+
config.owner = randomAddress();
|
|
570
|
+
// expect 1 tx to transfer ownership
|
|
571
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
572
|
+
// expect the hook address to be the same
|
|
573
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to
|
|
574
|
+
.be.true;
|
|
575
|
+
});
|
|
576
|
+
it(`update owner in an existing ${config.type} not owned by deployer`, async () => {
|
|
577
|
+
// hook owner is not the deployer
|
|
578
|
+
config.owner = randomAddress();
|
|
579
|
+
const originalOwner = config.owner;
|
|
580
|
+
// create a new hook
|
|
581
|
+
const { hook, initialHookAddress } = await createHook(config);
|
|
582
|
+
// update the config owner and impersonate the original owner
|
|
583
|
+
config.owner = randomAddress();
|
|
584
|
+
multiProvider = await impersonateAccount(originalOwner);
|
|
585
|
+
// expect 1 tx to transfer ownership
|
|
586
|
+
await expectTxsAndUpdate(hook, config, 1);
|
|
587
|
+
// expect the hook address to be unchanged
|
|
588
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to
|
|
589
|
+
.be.true;
|
|
590
|
+
});
|
|
591
|
+
it(`update owner in an existing ${config.type} not owned by deployer and no change`, async () => {
|
|
592
|
+
// hook owner is not the deployer
|
|
593
|
+
config.owner = randomAddress();
|
|
594
|
+
const originalOwner = config.owner;
|
|
595
|
+
// create a new hook
|
|
596
|
+
const { hook, initialHookAddress } = await createHook(config);
|
|
597
|
+
// impersonate the original owner
|
|
598
|
+
multiProvider = await impersonateAccount(originalOwner);
|
|
599
|
+
// expect 0 updates
|
|
600
|
+
await expectTxsAndUpdate(hook, config, 0);
|
|
601
|
+
// expect the hook address to be unchanged
|
|
602
|
+
expect(eqAddress(initialHookAddress, hook.serialize().deployedHook)).to
|
|
603
|
+
.be.true;
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
});
|
|
379
607
|
});
|
|
380
608
|
//# sourceMappingURL=EvmHookModule.hardhat-test.js.map
|