@hyperlane-xyz/sdk 14.0.0 → 14.2.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.
- package/dist/ccip/consts.d.ts.map +1 -1
- package/dist/ccip/consts.js +0 -20
- package/dist/ccip/consts.js.map +1 -1
- package/dist/consts/multisigIsm.d.ts.map +1 -1
- package/dist/consts/multisigIsm.js +27 -22
- package/dist/consts/multisigIsm.js.map +1 -1
- package/dist/contracts/contracts.d.ts +2 -0
- package/dist/contracts/contracts.d.ts.map +1 -1
- package/dist/contracts/contracts.hardhat-test.d.ts +2 -0
- package/dist/contracts/contracts.hardhat-test.d.ts.map +1 -0
- package/dist/contracts/contracts.hardhat-test.js +34 -0
- package/dist/contracts/contracts.hardhat-test.js.map +1 -0
- package/dist/contracts/contracts.js +7 -0
- package/dist/contracts/contracts.js.map +1 -1
- package/dist/core/CosmosNativeCoreModule.d.ts +5 -5
- package/dist/core/CosmosNativeCoreModule.d.ts.map +1 -1
- package/dist/core/CosmosNativeCoreModule.js +10 -10
- package/dist/core/CosmosNativeCoreModule.js.map +1 -1
- package/dist/core/EvmCoreModule.d.ts +3 -1
- package/dist/core/EvmCoreModule.d.ts.map +1 -1
- package/dist/core/EvmCoreModule.hardhat-test.js +85 -1
- package/dist/core/EvmCoreModule.hardhat-test.js.map +1 -1
- package/dist/core/EvmCoreModule.js +32 -2
- package/dist/core/EvmCoreModule.js.map +1 -1
- package/dist/core/HyperlaneRelayer.d.ts +43 -0
- package/dist/core/HyperlaneRelayer.d.ts.map +1 -1
- package/dist/core/types.d.ts +741 -18
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/deploy/proxy.d.ts +9 -2
- package/dist/deploy/proxy.d.ts.map +1 -1
- package/dist/deploy/proxy.js +21 -0
- package/dist/deploy/proxy.js.map +1 -1
- package/dist/deploy/verify/ContractVerifier.d.ts.map +1 -1
- package/dist/deploy/verify/ContractVerifier.js +0 -6
- package/dist/deploy/verify/ContractVerifier.js.map +1 -1
- package/dist/gas/oracle/types.d.ts +51 -0
- package/dist/gas/oracle/types.d.ts.map +1 -1
- package/dist/gas/oracle/types.js +8 -0
- package/dist/gas/oracle/types.js.map +1 -1
- package/dist/gas/utils.d.ts +3 -2
- package/dist/gas/utils.d.ts.map +1 -1
- package/dist/gas/utils.js +4 -1
- package/dist/gas/utils.js.map +1 -1
- package/dist/hook/CosmosNativeHookModule.d.ts +3 -2
- package/dist/hook/CosmosNativeHookModule.d.ts.map +1 -1
- package/dist/hook/CosmosNativeHookModule.js +10 -10
- package/dist/hook/CosmosNativeHookModule.js.map +1 -1
- package/dist/hook/CosmosNativeHookReader.d.ts +2 -2
- package/dist/hook/CosmosNativeHookReader.d.ts.map +1 -1
- package/dist/hook/EvmHookModule.d.ts +6 -15
- package/dist/hook/EvmHookModule.d.ts.map +1 -1
- package/dist/hook/EvmHookModule.js +74 -71
- package/dist/hook/EvmHookModule.js.map +1 -1
- package/dist/hook/types.d.ts +318 -0
- package/dist/hook/types.d.ts.map +1 -1
- package/dist/hook/types.js +2 -2
- package/dist/hook/types.js.map +1 -1
- package/dist/hook/updates.d.ts +28 -0
- package/dist/hook/updates.d.ts.map +1 -0
- package/dist/hook/updates.js +34 -0
- package/dist/hook/updates.js.map +1 -0
- package/dist/ica/types.d.ts +88 -2
- package/dist/ica/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/ism/CosmosNativeIsmModule.d.ts +3 -2
- package/dist/ism/CosmosNativeIsmModule.d.ts.map +1 -1
- package/dist/ism/CosmosNativeIsmModule.js +12 -12
- package/dist/ism/CosmosNativeIsmModule.js.map +1 -1
- package/dist/metadata/ChainMetadataManager.d.ts +1 -0
- package/dist/metadata/ChainMetadataManager.d.ts.map +1 -1
- package/dist/metadata/ChainMetadataManager.js +5 -0
- package/dist/metadata/ChainMetadataManager.js.map +1 -1
- package/dist/metadata/agentConfig.d.ts +1560 -1560
- package/dist/metadata/chainMetadataTypes.d.ts +6 -6
- package/dist/providers/transactions/submitter/builder/types.d.ts +25 -25
- package/dist/providers/transactions/submitter/ethersV5/types.d.ts +2 -2
- package/dist/providers/transactions/submitter/types.d.ts +9 -9
- package/dist/router/types.d.ts +130 -1
- package/dist/router/types.d.ts.map +1 -1
- package/dist/token/CosmosNativeWarpModule.d.ts +95 -0
- package/dist/token/CosmosNativeWarpModule.d.ts.map +1 -0
- package/dist/token/CosmosNativeWarpModule.js +296 -0
- package/dist/token/CosmosNativeWarpModule.js.map +1 -0
- package/dist/token/EvmERC20WarpModule.d.ts +0 -17
- package/dist/token/EvmERC20WarpModule.d.ts.map +1 -1
- package/dist/token/EvmERC20WarpModule.hardhat-test.js +7 -7
- package/dist/token/EvmERC20WarpModule.hardhat-test.js.map +1 -1
- package/dist/token/EvmERC20WarpModule.js +19 -71
- package/dist/token/EvmERC20WarpModule.js.map +1 -1
- package/dist/token/EvmERC20WarpRouteReader.d.ts +3 -1
- package/dist/token/EvmERC20WarpRouteReader.d.ts.map +1 -1
- package/dist/token/EvmERC20WarpRouteReader.hardhat-test.js +123 -5
- package/dist/token/EvmERC20WarpRouteReader.hardhat-test.js.map +1 -1
- package/dist/token/EvmERC20WarpRouteReader.js +68 -10
- package/dist/token/EvmERC20WarpRouteReader.js.map +1 -1
- package/dist/token/adapters/StarknetTokenAdapter.js +2 -2
- package/dist/token/adapters/StarknetTokenAdapter.js.map +1 -1
- package/dist/token/configUtils.d.ts.map +1 -1
- package/dist/token/configUtils.js +29 -6
- package/dist/token/configUtils.js.map +1 -1
- package/dist/token/cosmosnativeDeploy.d.ts +16 -0
- package/dist/token/cosmosnativeDeploy.d.ts.map +1 -0
- package/dist/token/cosmosnativeDeploy.js +58 -0
- package/dist/token/cosmosnativeDeploy.js.map +1 -0
- package/dist/token/deploy.d.ts.map +1 -1
- package/dist/token/deploy.js +7 -7
- package/dist/token/deploy.js.map +1 -1
- package/dist/token/types.d.ts +273 -8
- package/dist/token/types.d.ts.map +1 -1
- package/dist/token/types.js +20 -6
- package/dist/token/types.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SigningHyperlaneModuleClient } from '@hyperlane-xyz/cosmos-sdk';
|
|
2
|
+
import { Address, Domain, ProtocolType } from '@hyperlane-xyz/utils';
|
|
3
|
+
import { HyperlaneModule, HyperlaneModuleParams } from '../core/AbstractHyperlaneModule.js';
|
|
4
|
+
import { ChainMetadataManager } from '../metadata/ChainMetadataManager.js';
|
|
5
|
+
import { MultiProvider } from '../providers/MultiProvider.js';
|
|
6
|
+
import { AnnotatedCosmJsNativeTransaction } from '../providers/ProviderType.js';
|
|
7
|
+
import { ChainName, ChainNameOrId } from '../types.js';
|
|
8
|
+
import { CosmosNativeWarpRouteReader } from './CosmosNativeWarpRouteReader.js';
|
|
9
|
+
import { DerivedTokenRouterConfig, HypTokenRouterConfig } from './types.js';
|
|
10
|
+
type WarpRouteAddresses = {
|
|
11
|
+
deployedTokenRoute: Address;
|
|
12
|
+
};
|
|
13
|
+
export declare class CosmosNativeWarpModule extends HyperlaneModule<ProtocolType.CosmosNative, HypTokenRouterConfig, WarpRouteAddresses> {
|
|
14
|
+
protected readonly metadataManager: ChainMetadataManager;
|
|
15
|
+
protected readonly signer: SigningHyperlaneModuleClient;
|
|
16
|
+
protected logger: import("pino").default.Logger<never>;
|
|
17
|
+
reader: CosmosNativeWarpRouteReader;
|
|
18
|
+
readonly chainName: ChainName;
|
|
19
|
+
readonly chainId: string;
|
|
20
|
+
readonly domainId: Domain;
|
|
21
|
+
constructor(metadataManager: ChainMetadataManager, args: HyperlaneModuleParams<HypTokenRouterConfig, WarpRouteAddresses>, signer: SigningHyperlaneModuleClient);
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the token router configuration for the specified address.
|
|
24
|
+
*
|
|
25
|
+
* @param address - The address to derive the token router configuration from.
|
|
26
|
+
* @returns A promise that resolves to the token router configuration.
|
|
27
|
+
*/
|
|
28
|
+
read(): Promise<DerivedTokenRouterConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* Updates the Warp Route contract with the provided configuration.
|
|
31
|
+
*
|
|
32
|
+
* @param expectedConfig - The configuration for the token router to be updated.
|
|
33
|
+
* @returns An array of Cosmos transactions that were executed to update the contract, or an error if the update failed.
|
|
34
|
+
*/
|
|
35
|
+
update(expectedConfig: HypTokenRouterConfig): Promise<AnnotatedCosmJsNativeTransaction[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a transaction to update the remote routers for the Warp Route contract.
|
|
38
|
+
*
|
|
39
|
+
* @param actualConfig - The on-chain router configuration, including the remoteRouters array.
|
|
40
|
+
* @param expectedConfig - The expected token router configuration.
|
|
41
|
+
* @returns An array with Cosmos Native transactions that need to be executed to enroll the routers
|
|
42
|
+
*/
|
|
43
|
+
createEnrollRemoteRoutersUpdateTxs(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): AnnotatedCosmJsNativeTransaction[];
|
|
44
|
+
createUnenrollRemoteRoutersUpdateTxs(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): AnnotatedCosmJsNativeTransaction[];
|
|
45
|
+
/**
|
|
46
|
+
* Create a transaction to update the remote routers for the Warp Route contract.
|
|
47
|
+
*
|
|
48
|
+
* @param actualConfig - The on-chain router configuration, including the remoteRouters array.
|
|
49
|
+
* @param expectedConfig - The expected token router configuration.
|
|
50
|
+
* @returns A array with Cosmos transactions that need to be executed to update the destination gas
|
|
51
|
+
*/
|
|
52
|
+
createSetDestinationGasUpdateTxs(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): Promise<AnnotatedCosmJsNativeTransaction[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Create transactions to update an existing ISM config, or deploy a new ISM and return a tx to setInterchainSecurityModule
|
|
55
|
+
*
|
|
56
|
+
* @param actualConfig - The on-chain router configuration, including the ISM configuration, and address.
|
|
57
|
+
* @param expectedConfig - The expected token router configuration, including the ISM configuration.
|
|
58
|
+
* @returns Cosmos transaction that need to be executed to update the ISM configuration.
|
|
59
|
+
*/
|
|
60
|
+
createIsmUpdateTxs(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): Promise<AnnotatedCosmJsNativeTransaction[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Transfer ownership of an existing Warp route with a given config.
|
|
63
|
+
*
|
|
64
|
+
* @param actualConfig - The on-chain router configuration.
|
|
65
|
+
* @param expectedConfig - The expected token router configuration.
|
|
66
|
+
* @returns Cosmos transaction that need to be executed to update the owner.
|
|
67
|
+
*/
|
|
68
|
+
createOwnershipUpdateTxs(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): AnnotatedCosmJsNativeTransaction[];
|
|
69
|
+
/**
|
|
70
|
+
* Updates or deploys the ISM using the provided configuration.
|
|
71
|
+
*
|
|
72
|
+
* @returns Object with deployedIsm address, and update Transactions
|
|
73
|
+
*/
|
|
74
|
+
deployOrUpdateIsm(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): Promise<{
|
|
75
|
+
deployedIsm: Address;
|
|
76
|
+
updateTransactions: AnnotatedCosmJsNativeTransaction[];
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Deploys the Warp Route.
|
|
80
|
+
*
|
|
81
|
+
* @param chain - The chain to deploy the module on.
|
|
82
|
+
* @param config - The configuration for the token router.
|
|
83
|
+
* @param multiProvider - The multi-provider instance to use.
|
|
84
|
+
* @param signer - The Cosmos signing client
|
|
85
|
+
* @returns A new instance of the CosmosNativeWarpModule.
|
|
86
|
+
*/
|
|
87
|
+
static create(params: {
|
|
88
|
+
chain: ChainNameOrId;
|
|
89
|
+
config: HypTokenRouterConfig;
|
|
90
|
+
multiProvider: MultiProvider;
|
|
91
|
+
signer: SigningHyperlaneModuleClient;
|
|
92
|
+
}): Promise<CosmosNativeWarpModule>;
|
|
93
|
+
}
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=CosmosNativeWarpModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosmosNativeWarpModule.d.ts","sourceRoot":"","sources":["../../src/token/CosmosNativeWarpModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,4BAA4B,EAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,OAAO,EACP,MAAM,EACN,YAAY,EAQb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,qBAAqB,EACtB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB,KAAK,kBAAkB,GAAG;IACxB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,qBAAa,sBAAuB,SAAQ,eAAe,CACzD,YAAY,CAAC,YAAY,EACzB,oBAAoB,EACpB,kBAAkB,CACnB;IAUG,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,oBAAoB;IAExD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,4BAA4B;IAXzD,SAAS,CAAC,MAAM,uCAEb;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC,SAAgB,SAAS,EAAE,SAAS,CAAC;IACrC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAGZ,eAAe,EAAE,oBAAoB,EACxD,IA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
|
+
import { zeroAddress } from 'viem';
|
|
2
|
+
import { COSMOS_MODULE_MESSAGE_REGISTRY as R, } from '@hyperlane-xyz/cosmos-sdk';
|
|
3
|
+
import { addressToBytes32, assert, deepEquals, difference, eqAddress, objMap, rootLogger, } from '@hyperlane-xyz/utils';
|
|
4
|
+
import { HyperlaneModule, } from '../core/AbstractHyperlaneModule.js';
|
|
5
|
+
import { CosmosNativeIsmModule } from '../ism/CosmosNativeIsmModule.js';
|
|
6
|
+
import { CosmosNativeWarpRouteReader } from './CosmosNativeWarpRouteReader.js';
|
|
7
|
+
import { CosmosNativeDeployer } from './cosmosnativeDeploy.js';
|
|
8
|
+
import { HypTokenRouterConfigSchema, } from './types.js';
|
|
9
|
+
export class CosmosNativeWarpModule extends HyperlaneModule {
|
|
10
|
+
metadataManager;
|
|
11
|
+
signer;
|
|
12
|
+
logger = rootLogger.child({
|
|
13
|
+
module: 'CosmosNativeWarpModule',
|
|
14
|
+
});
|
|
15
|
+
reader;
|
|
16
|
+
chainName;
|
|
17
|
+
chainId;
|
|
18
|
+
domainId;
|
|
19
|
+
constructor(metadataManager, args, signer) {
|
|
20
|
+
super(args);
|
|
21
|
+
this.metadataManager = metadataManager;
|
|
22
|
+
this.signer = signer;
|
|
23
|
+
this.reader = new CosmosNativeWarpRouteReader(metadataManager, args.chain, signer);
|
|
24
|
+
this.chainName = this.metadataManager.getChainName(args.chain);
|
|
25
|
+
this.chainId = metadataManager.getChainId(args.chain).toString();
|
|
26
|
+
this.domainId = metadataManager.getDomainId(args.chain);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the token router configuration for the specified address.
|
|
30
|
+
*
|
|
31
|
+
* @param address - The address to derive the token router configuration from.
|
|
32
|
+
* @returns A promise that resolves to the token router configuration.
|
|
33
|
+
*/
|
|
34
|
+
async read() {
|
|
35
|
+
return this.reader.deriveWarpRouteConfig(this.args.addresses.deployedTokenRoute);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Updates the Warp Route contract with the provided configuration.
|
|
39
|
+
*
|
|
40
|
+
* @param expectedConfig - The configuration for the token router to be updated.
|
|
41
|
+
* @returns An array of Cosmos transactions that were executed to update the contract, or an error if the update failed.
|
|
42
|
+
*/
|
|
43
|
+
async update(expectedConfig) {
|
|
44
|
+
HypTokenRouterConfigSchema.parse(expectedConfig);
|
|
45
|
+
const actualConfig = await this.read();
|
|
46
|
+
const transactions = [];
|
|
47
|
+
/**
|
|
48
|
+
* @remark
|
|
49
|
+
* The order of operations matter
|
|
50
|
+
* 1. createOwnershipUpdateTxs() must always be LAST because no updates possible after ownership transferred
|
|
51
|
+
* 2. createRemoteRoutersUpdateTxs() must always be BEFORE createSetDestinationGasUpdateTxs() because gas enumeration depends on domains
|
|
52
|
+
*/
|
|
53
|
+
transactions.push(...(await this.createIsmUpdateTxs(actualConfig, expectedConfig)), ...this.createEnrollRemoteRoutersUpdateTxs(actualConfig, expectedConfig), ...this.createUnenrollRemoteRoutersUpdateTxs(actualConfig, expectedConfig), ...(await this.createSetDestinationGasUpdateTxs(actualConfig, expectedConfig)), ...this.createOwnershipUpdateTxs(actualConfig, expectedConfig));
|
|
54
|
+
return transactions;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a transaction to update the remote routers for the Warp Route contract.
|
|
58
|
+
*
|
|
59
|
+
* @param actualConfig - The on-chain router configuration, including the remoteRouters array.
|
|
60
|
+
* @param expectedConfig - The expected token router configuration.
|
|
61
|
+
* @returns An array with Cosmos Native transactions that need to be executed to enroll the routers
|
|
62
|
+
*/
|
|
63
|
+
createEnrollRemoteRoutersUpdateTxs(actualConfig, expectedConfig) {
|
|
64
|
+
const updateTransactions = [];
|
|
65
|
+
if (!expectedConfig.remoteRouters) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
assert(actualConfig.remoteRouters, 'actualRemoteRouters is undefined');
|
|
69
|
+
assert(expectedConfig.remoteRouters, 'expectedRemoteRouters is undefined');
|
|
70
|
+
const { remoteRouters: actualRemoteRouters } = actualConfig;
|
|
71
|
+
const { remoteRouters: expectedRemoteRouters } = expectedConfig;
|
|
72
|
+
const routesToEnroll = Object.entries(expectedRemoteRouters)
|
|
73
|
+
.filter(([domain, expectedRouter]) => {
|
|
74
|
+
const actualRouter = actualRemoteRouters[domain];
|
|
75
|
+
// Enroll if router doesn't exist for domain or has different address
|
|
76
|
+
return (!actualRouter ||
|
|
77
|
+
!eqAddress(actualRouter.address, expectedRouter.address));
|
|
78
|
+
})
|
|
79
|
+
.map(([domain]) => domain);
|
|
80
|
+
if (routesToEnroll.length === 0) {
|
|
81
|
+
return updateTransactions;
|
|
82
|
+
}
|
|
83
|
+
// in cosmos the gas is attached to the remote router. we set
|
|
84
|
+
// it to zero for now and set the real value later during the
|
|
85
|
+
// createSetDestinationGasUpdateTxs step
|
|
86
|
+
routesToEnroll.forEach((domainId) => {
|
|
87
|
+
updateTransactions.push({
|
|
88
|
+
annotation: `Enrolling Router ${this.args.addresses.deployedTokenRoute} on ${this.args.chain}`,
|
|
89
|
+
typeUrl: R.MsgEnrollRemoteRouter.proto.type,
|
|
90
|
+
value: R.MsgEnrollRemoteRouter.proto.converter.create({
|
|
91
|
+
owner: actualConfig.owner,
|
|
92
|
+
token_id: this.args.addresses.deployedTokenRoute,
|
|
93
|
+
remote_router: {
|
|
94
|
+
receiver_domain: parseInt(domainId),
|
|
95
|
+
receiver_contract: addressToBytes32(expectedRemoteRouters[domainId].address),
|
|
96
|
+
gas: '0',
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return updateTransactions;
|
|
102
|
+
}
|
|
103
|
+
createUnenrollRemoteRoutersUpdateTxs(actualConfig, expectedConfig) {
|
|
104
|
+
const updateTransactions = [];
|
|
105
|
+
if (!expectedConfig.remoteRouters) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
assert(actualConfig.remoteRouters, 'actualRemoteRouters is undefined');
|
|
109
|
+
assert(expectedConfig.remoteRouters, 'expectedRemoteRouters is undefined');
|
|
110
|
+
const { remoteRouters: actualRemoteRouters } = actualConfig;
|
|
111
|
+
const { remoteRouters: expectedRemoteRouters } = expectedConfig;
|
|
112
|
+
const routesToUnenroll = Array.from(difference(new Set(Object.keys(actualRemoteRouters)), new Set(Object.keys(expectedRemoteRouters))));
|
|
113
|
+
if (routesToUnenroll.length === 0) {
|
|
114
|
+
return updateTransactions;
|
|
115
|
+
}
|
|
116
|
+
routesToUnenroll.forEach((domainId) => {
|
|
117
|
+
updateTransactions.push({
|
|
118
|
+
annotation: `Unenrolling Router ${this.args.addresses.deployedTokenRoute} on ${this.args.chain}`,
|
|
119
|
+
typeUrl: R.MsgUnrollRemoteRouter.proto.type,
|
|
120
|
+
value: R.MsgUnrollRemoteRouter.proto.converter.create({
|
|
121
|
+
owner: actualConfig.owner,
|
|
122
|
+
token_id: this.args.addresses.deployedTokenRoute,
|
|
123
|
+
receiver_domain: parseInt(domainId),
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return updateTransactions;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a transaction to update the remote routers for the Warp Route contract.
|
|
131
|
+
*
|
|
132
|
+
* @param actualConfig - The on-chain router configuration, including the remoteRouters array.
|
|
133
|
+
* @param expectedConfig - The expected token router configuration.
|
|
134
|
+
* @returns A array with Cosmos transactions that need to be executed to update the destination gas
|
|
135
|
+
*/
|
|
136
|
+
async createSetDestinationGasUpdateTxs(actualConfig, expectedConfig) {
|
|
137
|
+
const updateTransactions = [];
|
|
138
|
+
if (!expectedConfig.destinationGas) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
assert(actualConfig.destinationGas, 'actualDestinationGas is undefined');
|
|
142
|
+
assert(expectedConfig.destinationGas, 'expectedDestinationGas is undefined');
|
|
143
|
+
assert(expectedConfig.remoteRouters, 'expectedRemoteRouters is undefined');
|
|
144
|
+
const { destinationGas: actualDestinationGas } = actualConfig;
|
|
145
|
+
const { destinationGas: expectedDestinationGas } = expectedConfig;
|
|
146
|
+
const { remoteRouters: expectedRemoteRouters } = expectedConfig;
|
|
147
|
+
// refetch after routes have been previously enrolled without the "actualConfig"
|
|
148
|
+
// updating
|
|
149
|
+
const { remote_routers: actualRemoteRouters } = await this.signer.query.warp.RemoteRouters({
|
|
150
|
+
id: this.args.addresses.deployedTokenRoute,
|
|
151
|
+
});
|
|
152
|
+
const alreadyEnrolledDomains = actualRemoteRouters.map((router) => router.receiver_domain);
|
|
153
|
+
if (!deepEquals(actualDestinationGas, expectedDestinationGas)) {
|
|
154
|
+
// Convert { 1: 2, 2: 3, ... } to [{ 1: 2 }, { 2: 3 }]
|
|
155
|
+
const gasRouterConfigs = [];
|
|
156
|
+
objMap(expectedDestinationGas, (domain, gas) => {
|
|
157
|
+
gasRouterConfigs.push({
|
|
158
|
+
domain,
|
|
159
|
+
gas,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
// in cosmos updating the gas config is done by unenrolling the router and then
|
|
163
|
+
// enrolling it with the updating value again
|
|
164
|
+
gasRouterConfigs.forEach(({ domain, gas }) => {
|
|
165
|
+
if (alreadyEnrolledDomains.includes(parseInt(domain))) {
|
|
166
|
+
updateTransactions.push({
|
|
167
|
+
annotation: `Unenrolling ${this.args.addresses.deployedTokenRoute} on ${this.args.chain}`,
|
|
168
|
+
typeUrl: R.MsgUnrollRemoteRouter.proto.type,
|
|
169
|
+
value: R.MsgUnrollRemoteRouter.proto.converter.create({
|
|
170
|
+
owner: actualConfig.owner,
|
|
171
|
+
token_id: this.args.addresses.deployedTokenRoute,
|
|
172
|
+
receiver_domain: parseInt(domain),
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
updateTransactions.push({
|
|
177
|
+
annotation: `Setting destination gas for ${this.args.addresses.deployedTokenRoute} on ${this.args.chain}`,
|
|
178
|
+
typeUrl: R.MsgEnrollRemoteRouter.proto.type,
|
|
179
|
+
value: R.MsgEnrollRemoteRouter.proto.converter.create({
|
|
180
|
+
owner: actualConfig.owner,
|
|
181
|
+
token_id: this.args.addresses.deployedTokenRoute,
|
|
182
|
+
remote_router: {
|
|
183
|
+
receiver_domain: parseInt(domain),
|
|
184
|
+
receiver_contract: addressToBytes32(expectedRemoteRouters[domain].address),
|
|
185
|
+
gas,
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return updateTransactions;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create transactions to update an existing ISM config, or deploy a new ISM and return a tx to setInterchainSecurityModule
|
|
195
|
+
*
|
|
196
|
+
* @param actualConfig - The on-chain router configuration, including the ISM configuration, and address.
|
|
197
|
+
* @param expectedConfig - The expected token router configuration, including the ISM configuration.
|
|
198
|
+
* @returns Cosmos transaction that need to be executed to update the ISM configuration.
|
|
199
|
+
*/
|
|
200
|
+
async createIsmUpdateTxs(actualConfig, expectedConfig) {
|
|
201
|
+
const updateTransactions = [];
|
|
202
|
+
if (!expectedConfig.interchainSecurityModule ||
|
|
203
|
+
expectedConfig.interchainSecurityModule === zeroAddress) {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
const actualDeployedIsm = actualConfig.interchainSecurityModule.address;
|
|
207
|
+
// Try to update (may also deploy) Ism with the expected config
|
|
208
|
+
const { deployedIsm: expectedDeployedIsm, updateTransactions: ismUpdateTransactions, } = await this.deployOrUpdateIsm(actualConfig, expectedConfig);
|
|
209
|
+
// If an ISM is updated in-place, push the update txs
|
|
210
|
+
updateTransactions.push(...ismUpdateTransactions);
|
|
211
|
+
// If a new ISM is deployed, push the setInterchainSecurityModule tx
|
|
212
|
+
if (actualDeployedIsm !== expectedDeployedIsm) {
|
|
213
|
+
updateTransactions.push({
|
|
214
|
+
annotation: `Setting ISM for Warp Route to ${expectedDeployedIsm}`,
|
|
215
|
+
typeUrl: R.MsgSetToken.proto.type,
|
|
216
|
+
value: R.MsgSetToken.proto.converter.create({
|
|
217
|
+
owner: actualConfig.owner,
|
|
218
|
+
token_id: this.args.addresses.deployedTokenRoute,
|
|
219
|
+
ism_id: expectedDeployedIsm,
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return updateTransactions;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Transfer ownership of an existing Warp route with a given config.
|
|
227
|
+
*
|
|
228
|
+
* @param actualConfig - The on-chain router configuration.
|
|
229
|
+
* @param expectedConfig - The expected token router configuration.
|
|
230
|
+
* @returns Cosmos transaction that need to be executed to update the owner.
|
|
231
|
+
*/
|
|
232
|
+
createOwnershipUpdateTxs(actualConfig, expectedConfig) {
|
|
233
|
+
if (eqAddress(actualConfig.owner, expectedConfig.owner)) {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
return [
|
|
237
|
+
{
|
|
238
|
+
annotation: `Transferring ownership of ${this.args.addresses.deployedTokenRoute} from ${actualConfig.owner} to ${expectedConfig.owner}`,
|
|
239
|
+
typeUrl: R.MsgSetToken.proto.type,
|
|
240
|
+
value: R.MsgSetToken.proto.converter.create({
|
|
241
|
+
owner: actualConfig.owner,
|
|
242
|
+
token_id: this.args.addresses.deployedTokenRoute,
|
|
243
|
+
new_owner: expectedConfig.owner,
|
|
244
|
+
}),
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Updates or deploys the ISM using the provided configuration.
|
|
250
|
+
*
|
|
251
|
+
* @returns Object with deployedIsm address, and update Transactions
|
|
252
|
+
*/
|
|
253
|
+
async deployOrUpdateIsm(actualConfig, expectedConfig) {
|
|
254
|
+
assert(expectedConfig.interchainSecurityModule, 'Ism derived incorrectly');
|
|
255
|
+
const ismModule = new CosmosNativeIsmModule(this.metadataManager, {
|
|
256
|
+
chain: this.args.chain,
|
|
257
|
+
config: expectedConfig.interchainSecurityModule,
|
|
258
|
+
addresses: {
|
|
259
|
+
...this.args.addresses,
|
|
260
|
+
mailbox: expectedConfig.mailbox,
|
|
261
|
+
deployedIsm: actualConfig.interchainSecurityModule.address,
|
|
262
|
+
},
|
|
263
|
+
}, this.signer);
|
|
264
|
+
this.logger.info(`Comparing target ISM config with ${this.args.chain} chain`);
|
|
265
|
+
const updateTransactions = await ismModule.update(expectedConfig.interchainSecurityModule);
|
|
266
|
+
const { deployedIsm } = ismModule.serialize();
|
|
267
|
+
return { deployedIsm, updateTransactions };
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Deploys the Warp Route.
|
|
271
|
+
*
|
|
272
|
+
* @param chain - The chain to deploy the module on.
|
|
273
|
+
* @param config - The configuration for the token router.
|
|
274
|
+
* @param multiProvider - The multi-provider instance to use.
|
|
275
|
+
* @param signer - The Cosmos signing client
|
|
276
|
+
* @returns A new instance of the CosmosNativeWarpModule.
|
|
277
|
+
*/
|
|
278
|
+
static async create(params) {
|
|
279
|
+
const { chain, config, multiProvider, signer } = params;
|
|
280
|
+
const deployer = new CosmosNativeDeployer(multiProvider, {
|
|
281
|
+
[chain]: signer,
|
|
282
|
+
});
|
|
283
|
+
const { [chain]: deployedTokenRoute } = await deployer.deploy({
|
|
284
|
+
[chain]: config,
|
|
285
|
+
});
|
|
286
|
+
const warpModule = new CosmosNativeWarpModule(multiProvider, {
|
|
287
|
+
addresses: {
|
|
288
|
+
deployedTokenRoute,
|
|
289
|
+
},
|
|
290
|
+
chain,
|
|
291
|
+
config,
|
|
292
|
+
}, signer);
|
|
293
|
+
return warpModule;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=CosmosNativeWarpModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosmosNativeWarpModule.js","sourceRoot":"","sources":["../../src/token/CosmosNativeWarpModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAA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AC,MAAM,CAC/C,cAAc,CAAC,wBAAwB,CACxC,CAAC;QACF,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QAE9C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAKnB;QACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAExD,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAC,aAAa,EAAE;YACvD,CAAC,KAAK,CAAC,EAAE,MAAM;SAChB,CAAC,CAAC;QAEH,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YAC5D,CAAC,KAAK,CAAC,EAAE,MAAM;SAChB,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,IAAI,sBAAsB,CAC3C,aAAa,EACb;YACE,SAAS,EAAE;gBACT,kBAAkB;aACnB;YACD,KAAK;YACL,MAAM;SACP,EACD,MAAM,CACP,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -84,23 +84,6 @@ export declare class EvmERC20WarpModule extends HyperlaneModule<ProtocolType.Eth
|
|
|
84
84
|
deployedIsm: Address;
|
|
85
85
|
updateTransactions: AnnotatedEV5Transaction[];
|
|
86
86
|
}>;
|
|
87
|
-
/**
|
|
88
|
-
* Updates or deploys the hook using the provided configuration.
|
|
89
|
-
*
|
|
90
|
-
* @returns Object with deployedHook address, and update Transactions
|
|
91
|
-
*/
|
|
92
|
-
deployOrUpdateHook(actualConfig: DerivedTokenRouterConfig, expectedConfig: HypTokenRouterConfig): Promise<{
|
|
93
|
-
deployedHook: Address;
|
|
94
|
-
updateTransactions: AnnotatedEV5Transaction[];
|
|
95
|
-
}>;
|
|
96
|
-
deployNewHook(expectedConfig: HypTokenRouterConfig): Promise<{
|
|
97
|
-
deployedHook: Address;
|
|
98
|
-
updateTransactions: AnnotatedEV5Transaction[];
|
|
99
|
-
}>;
|
|
100
|
-
updateExistingHook(expectedConfig: HypTokenRouterConfig, actualConfig: DerivedTokenRouterConfig): Promise<{
|
|
101
|
-
deployedHook: Address;
|
|
102
|
-
updateTransactions: AnnotatedEV5Transaction[];
|
|
103
|
-
}>;
|
|
104
87
|
/**
|
|
105
88
|
* Creates a transaction to upgrade the Warp Route implementation if the package version is below specified version.
|
|
106
89
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmERC20WarpModule.d.ts","sourceRoot":"","sources":["../../src/token/EvmERC20WarpModule.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,OAAO,EACP,MAAM,EACN,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"EvmERC20WarpModule.d.ts","sourceRoot":"","sources":["../../src/token/EvmERC20WarpModule.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,OAAO,EACP,MAAM,EACN,UAAU,EACV,YAAY,EAUb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,qBAAqB,EACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAM/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAIxE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EACL,wBAAwB,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AAiB,CAAC,EAAE,iBAAiB,CAAC;QACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,qBAAqB,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;KAClE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsEhC"}
|
|
@@ -3,7 +3,7 @@ import chaiAsPromised from 'chai-as-promised';
|
|
|
3
3
|
import hre from 'hardhat';
|
|
4
4
|
import sinon from 'sinon';
|
|
5
5
|
import { UINT_256_MAX } from 'starknet';
|
|
6
|
-
import { ERC20Test__factory, ERC4626Test__factory, HypERC20__factory, HypERC4626Collateral__factory, HypNative__factory, MailboxClient__factory, Mailbox__factory, MovableCollateralRouter__factory, } from '@hyperlane-xyz/core';
|
|
6
|
+
import { CONTRACTS_PACKAGE_VERSION, ERC20Test__factory, ERC4626Test__factory, HypERC20__factory, HypERC4626Collateral__factory, HypNative__factory, MailboxClient__factory, Mailbox__factory, MovableCollateralRouter__factory, } from '@hyperlane-xyz/core';
|
|
7
7
|
import { EvmIsmModule, HookType, IsmType, TestChainName, proxyAdmin, proxyImplementation, serializeContracts, } from '@hyperlane-xyz/sdk';
|
|
8
8
|
import { addressToBytes32, assert, deepCopy, eqAddress, normalizeAddressEvm, randomInt, } from '@hyperlane-xyz/utils';
|
|
9
9
|
import { TestCoreDeployer } from '../core/TestCoreDeployer.js';
|
|
@@ -14,7 +14,7 @@ import { randomAddress } from '../test/testUtils.js';
|
|
|
14
14
|
import { normalizeConfig } from '../utils/ism.js';
|
|
15
15
|
import { EvmERC20WarpModule } from './EvmERC20WarpModule.js';
|
|
16
16
|
import { TokenType, isMovableCollateralTokenType, } from './config.js';
|
|
17
|
-
import {
|
|
17
|
+
import { HypTokenRouterConfigSchema, derivedHookAddress, isMovableCollateralTokenConfig, } from './types.js';
|
|
18
18
|
chai.use(chaiAsPromised);
|
|
19
19
|
const { expect } = chai;
|
|
20
20
|
const randomRemoteRouters = (n) => {
|
|
@@ -868,12 +868,12 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
|
|
|
868
868
|
// If it is, we deploy a new implementation and run upgradeTo
|
|
869
869
|
await sendTxs(await evmERC20WarpModule.update({
|
|
870
870
|
...config,
|
|
871
|
-
contractVersion:
|
|
871
|
+
contractVersion: CONTRACTS_PACKAGE_VERSION,
|
|
872
872
|
}));
|
|
873
873
|
versionStub.restore();
|
|
874
874
|
const updatedConfig = await evmERC20WarpModule.read();
|
|
875
875
|
// Assert
|
|
876
|
-
expect(updatedConfig.contractVersion).to.eq(
|
|
876
|
+
expect(updatedConfig.contractVersion).to.eq(CONTRACTS_PACKAGE_VERSION);
|
|
877
877
|
const newImpl = await proxyImplementation(multiProvider.getProvider(chain), deployedTokenRoute);
|
|
878
878
|
expect(origImpl).to.not.eq(newImpl);
|
|
879
879
|
});
|
|
@@ -906,12 +906,12 @@ describe('EvmERC20WarpHyperlaneModule', async () => {
|
|
|
906
906
|
// This will throw an error
|
|
907
907
|
await expect(evmERC20WarpModule.update({
|
|
908
908
|
...config,
|
|
909
|
-
contractVersion:
|
|
910
|
-
})).to.be.rejectedWith(`Expected contract version ${
|
|
909
|
+
contractVersion: CONTRACTS_PACKAGE_VERSION,
|
|
910
|
+
})).to.be.rejectedWith(`Expected contract version ${CONTRACTS_PACKAGE_VERSION} is lower than actual contract version ${reallyHighVersion}`);
|
|
911
911
|
versionStub.restore();
|
|
912
912
|
const updatedConfig = await evmERC20WarpModule.read();
|
|
913
913
|
// Assert
|
|
914
|
-
expect(updatedConfig.contractVersion).to.eq(
|
|
914
|
+
expect(updatedConfig.contractVersion).to.eq(CONTRACTS_PACKAGE_VERSION);
|
|
915
915
|
});
|
|
916
916
|
});
|
|
917
917
|
});
|