@hyperlane-xyz/core 1.0.0-beta5 → 1.0.0-beta7
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/contracts/HyperlaneConnectionClient.sol +17 -4
- package/contracts/OwnableMulticall.sol +26 -27
- package/contracts/libs/MultisigIsmMetadata.sol +0 -15
- package/contracts/middleware/InterchainAccountRouter.sol +64 -15
- package/contracts/middleware/InterchainQueryRouter.sol +42 -23
- package/contracts/middleware/README.md +5 -3
- package/contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol +13 -13
- package/contracts/mock/MockHyperlaneEnvironment.sol +5 -2
- package/contracts/test/TestRouter.sol +1 -1
- package/dist/contracts/middleware/InterchainAccountRouter.d.ts +9 -25
- package/dist/contracts/middleware/InterchainAccountRouter.d.ts.map +1 -1
- package/dist/contracts/middleware/InterchainQueryRouter.d.ts +9 -57
- package/dist/contracts/middleware/InterchainQueryRouter.d.ts.map +1 -1
- package/dist/contracts/middleware/liquidity-layer/LiquidityLayerRouter.d.ts +9 -25
- package/dist/contracts/middleware/liquidity-layer/LiquidityLayerRouter.d.ts.map +1 -1
- package/dist/contracts/mock/index.d.ts +0 -1
- package/dist/contracts/mock/index.d.ts.map +1 -1
- package/dist/factories/contracts/OwnableMulticall__factory.d.ts +1 -1
- package/dist/factories/contracts/OwnableMulticall__factory.d.ts.map +1 -1
- package/dist/factories/contracts/OwnableMulticall__factory.js +1 -1
- package/dist/factories/contracts/OwnableMulticall__factory.js.map +1 -1
- package/dist/factories/contracts/isms/MultisigIsm__factory.d.ts +1 -1
- package/dist/factories/contracts/isms/MultisigIsm__factory.js +1 -1
- package/dist/factories/contracts/middleware/InterchainAccountRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/InterchainAccountRouter__factory.d.ts.map +1 -1
- package/dist/factories/contracts/middleware/InterchainAccountRouter__factory.js +3 -16
- package/dist/factories/contracts/middleware/InterchainAccountRouter__factory.js.map +1 -1
- package/dist/factories/contracts/middleware/InterchainQueryRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/InterchainQueryRouter__factory.d.ts.map +1 -1
- package/dist/factories/contracts/middleware/InterchainQueryRouter__factory.js +3 -48
- package/dist/factories/contracts/middleware/InterchainQueryRouter__factory.js.map +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/LiquidityLayerRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/LiquidityLayerRouter__factory.d.ts.map +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/LiquidityLayerRouter__factory.js +3 -16
- package/dist/factories/contracts/middleware/liquidity-layer/LiquidityLayerRouter__factory.js.map +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter__factory.d.ts.map +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter__factory.js +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter__factory.js.map +1 -1
- package/dist/factories/contracts/mock/MockHyperlaneEnvironment__factory.d.ts +1 -1
- package/dist/factories/contracts/mock/MockHyperlaneEnvironment__factory.d.ts.map +1 -1
- package/dist/factories/contracts/mock/MockHyperlaneEnvironment__factory.js +1 -1
- package/dist/factories/contracts/mock/MockHyperlaneEnvironment__factory.js.map +1 -1
- package/dist/factories/contracts/mock/index.d.ts +0 -1
- package/dist/factories/contracts/mock/index.d.ts.map +1 -1
- package/dist/factories/contracts/mock/index.js +1 -3
- package/dist/factories/contracts/mock/index.js.map +1 -1
- package/dist/factories/contracts/test/TestHyperlaneConnectionClient__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestHyperlaneConnectionClient__factory.d.ts.map +1 -1
- package/dist/factories/contracts/test/TestHyperlaneConnectionClient__factory.js +1 -1
- package/dist/factories/contracts/test/TestHyperlaneConnectionClient__factory.js.map +1 -1
- package/dist/factories/contracts/test/TestMultisigIsm__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestMultisigIsm__factory.js +1 -1
- package/dist/factories/contracts/test/TestQuery__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestQuery__factory.js +1 -1
- package/dist/factories/contracts/test/TestRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestRouter__factory.d.ts.map +1 -1
- package/dist/factories/contracts/test/TestRouter__factory.js +1 -1
- package/dist/factories/contracts/test/TestRouter__factory.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/contracts/mock/MockInterchainAccountRouter.sol +0 -48
- package/dist/contracts/mock/MockInterchainAccountRouter.d.ts +0 -414
- package/dist/contracts/mock/MockInterchainAccountRouter.d.ts.map +0 -1
- package/dist/contracts/mock/MockInterchainAccountRouter.js +0 -4
- package/dist/contracts/mock/MockInterchainAccountRouter.js.map +0 -1
- package/dist/factories/contracts/mock/MockInterchainAccountRouter__factory.d.ts +0 -69
- package/dist/factories/contracts/mock/MockInterchainAccountRouter__factory.d.ts.map +0 -1
- package/dist/factories/contracts/mock/MockInterchainAccountRouter__factory.js +0 -543
- package/dist/factories/contracts/mock/MockInterchainAccountRouter__factory.js.map +0 -1
|
@@ -89,6 +89,18 @@ abstract contract HyperlaneConnectionClient is
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
function __HyperlaneConnectionClient_initialize(
|
|
93
|
+
address _mailbox,
|
|
94
|
+
address _interchainGasPaymaster,
|
|
95
|
+
address _interchainSecurityModule,
|
|
96
|
+
address _owner
|
|
97
|
+
) internal onlyInitializing {
|
|
98
|
+
_setMailbox(_mailbox);
|
|
99
|
+
_setInterchainGasPaymaster(_interchainGasPaymaster);
|
|
100
|
+
_setInterchainSecurityModule(_interchainSecurityModule);
|
|
101
|
+
_transferOwnership(_owner);
|
|
102
|
+
}
|
|
103
|
+
|
|
92
104
|
// ============ External functions ============
|
|
93
105
|
|
|
94
106
|
/**
|
|
@@ -144,10 +156,11 @@ abstract contract HyperlaneConnectionClient is
|
|
|
144
156
|
emit MailboxSet(_mailbox);
|
|
145
157
|
}
|
|
146
158
|
|
|
147
|
-
function _setInterchainSecurityModule(address _module)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
function _setInterchainSecurityModule(address _module) internal {
|
|
160
|
+
require(
|
|
161
|
+
_module == address(0) || Address.isContract(_module),
|
|
162
|
+
"!contract"
|
|
163
|
+
);
|
|
151
164
|
interchainSecurityModule = IInterchainSecurityModule(_module);
|
|
152
165
|
emit InterchainSecurityModuleSet(_module);
|
|
153
166
|
}
|
|
@@ -6,6 +6,31 @@ pragma solidity ^0.8.13;
|
|
|
6
6
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
7
7
|
import {Call} from "./Call.sol";
|
|
8
8
|
|
|
9
|
+
function _call(Call[] memory calls, bytes[] memory callbacks)
|
|
10
|
+
returns (bytes[] memory resolveCalls)
|
|
11
|
+
{
|
|
12
|
+
resolveCalls = new bytes[](callbacks.length);
|
|
13
|
+
for (uint256 i = 0; i < calls.length; i++) {
|
|
14
|
+
(bool success, bytes memory returnData) = calls[i].to.call(
|
|
15
|
+
calls[i].data
|
|
16
|
+
);
|
|
17
|
+
require(success, "Multicall: call failed");
|
|
18
|
+
resolveCalls[i] = bytes.concat(callbacks[i], returnData);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// TODO: deduplicate
|
|
23
|
+
function _proxyCallBatch(address to, bytes[] memory calls) {
|
|
24
|
+
for (uint256 i = 0; i < calls.length; i += 1) {
|
|
25
|
+
(bool success, bytes memory returnData) = to.call(calls[i]);
|
|
26
|
+
if (!success) {
|
|
27
|
+
assembly {
|
|
28
|
+
revert(add(returnData, 32), returnData)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
9
34
|
/*
|
|
10
35
|
* @title OwnableMulticall
|
|
11
36
|
* @dev Allows only only address to execute calls to other contracts
|
|
@@ -16,7 +41,7 @@ contract OwnableMulticall is OwnableUpgradeable {
|
|
|
16
41
|
}
|
|
17
42
|
|
|
18
43
|
function initialize() external initializer {
|
|
19
|
-
|
|
44
|
+
__Ownable_init();
|
|
20
45
|
}
|
|
21
46
|
|
|
22
47
|
function proxyCalls(Call[] calldata calls) external onlyOwner {
|
|
@@ -31,30 +56,4 @@ contract OwnableMulticall is OwnableUpgradeable {
|
|
|
31
56
|
}
|
|
32
57
|
}
|
|
33
58
|
}
|
|
34
|
-
|
|
35
|
-
function _call(Call[] memory calls, bytes[] memory callbacks)
|
|
36
|
-
internal
|
|
37
|
-
returns (bytes[] memory resolveCalls)
|
|
38
|
-
{
|
|
39
|
-
resolveCalls = new bytes[](callbacks.length);
|
|
40
|
-
for (uint256 i = 0; i < calls.length; i++) {
|
|
41
|
-
(bool success, bytes memory returnData) = calls[i].to.call(
|
|
42
|
-
calls[i].data
|
|
43
|
-
);
|
|
44
|
-
require(success, "Multicall: call failed");
|
|
45
|
-
resolveCalls[i] = bytes.concat(callbacks[i], returnData);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// TODO: deduplicate
|
|
50
|
-
function proxyCallBatch(address to, bytes[] memory calls) internal {
|
|
51
|
-
for (uint256 i = 0; i < calls.length; i += 1) {
|
|
52
|
-
(bool success, bytes memory returnData) = to.call(calls[i]);
|
|
53
|
-
if (!success) {
|
|
54
|
-
assembly {
|
|
55
|
-
revert(add(returnData, 32), returnData)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
59
|
}
|
|
@@ -137,21 +137,6 @@ library MultisigIsmMetadata {
|
|
|
137
137
|
return _metadata[_validatorsOffset(_metadata):];
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
/**
|
|
141
|
-
* @notice Returns the size of the validator set encoded in the metadata
|
|
142
|
-
* @dev Validator addresses are encoded as tightly packed array of bytes32,
|
|
143
|
-
* sorted to match the enumerable set stored by the module.
|
|
144
|
-
* @param _metadata ABI encoded Multisig ISM metadata.
|
|
145
|
-
* @return The size of the validator set encoded in the metadata
|
|
146
|
-
*/
|
|
147
|
-
function commitment(bytes calldata _metadata)
|
|
148
|
-
internal
|
|
149
|
-
pure
|
|
150
|
-
returns (uint256)
|
|
151
|
-
{
|
|
152
|
-
return (_metadata.length - _validatorsOffset(_metadata)) / 32;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
140
|
/**
|
|
156
141
|
* @notice Returns the size of the validator set encoded in the metadata
|
|
157
142
|
* @dev Validator addresses are encoded as tightly packed array of bytes32,
|
|
@@ -13,19 +13,28 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
|
13
13
|
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
14
14
|
|
|
15
15
|
/*
|
|
16
|
-
* @title
|
|
17
|
-
* @dev
|
|
16
|
+
* @title Interchain Accounts Router that relays messages via proxy contracts on other chains.
|
|
17
|
+
* @dev Currently does not support Sovereign Consensus (user specified Interchain Security Modules).
|
|
18
18
|
*/
|
|
19
19
|
contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
20
20
|
address immutable implementation;
|
|
21
21
|
bytes32 immutable bytecodeHash;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @notice Emitted when an interchain account is created (first time message is sent from a given `origin`/`sender` pair)
|
|
25
|
+
* @param origin The domain of the chain where the message was sent from
|
|
26
|
+
* @param sender The address of the account that sent the message
|
|
27
|
+
* @param account The address of the proxy account that was created
|
|
28
|
+
*/
|
|
23
29
|
event InterchainAccountCreated(
|
|
24
30
|
uint32 indexed origin,
|
|
25
31
|
address sender,
|
|
26
32
|
address account
|
|
27
33
|
);
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @notice Constructor deploys a relay (OwnableMulticall.sol) contract that will be cloned for each interchain account.
|
|
37
|
+
*/
|
|
29
38
|
constructor() {
|
|
30
39
|
implementation = address(new OwnableMulticall());
|
|
31
40
|
// cannot be stored immutably because it is dynamically sized
|
|
@@ -33,27 +42,32 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
33
42
|
bytecodeHash = keccak256(bytecode);
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @notice Initializes the Router contract with Hyperlane core contracts and the address of the interchain security module.
|
|
47
|
+
* @param _mailbox The address of the mailbox contract.
|
|
48
|
+
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
|
|
49
|
+
* @param _interchainSecurityModule The address of the interchain security module contract.
|
|
50
|
+
* @param _owner The address with owner privileges.
|
|
51
|
+
*/
|
|
36
52
|
function initialize(
|
|
37
53
|
address _mailbox,
|
|
38
54
|
address _interchainGasPaymaster,
|
|
39
|
-
address _interchainSecurityModule
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
address _interchainSecurityModule,
|
|
56
|
+
address _owner
|
|
57
|
+
) external initializer {
|
|
58
|
+
__HyperlaneConnectionClient_initialize(
|
|
43
59
|
_mailbox,
|
|
44
60
|
_interchainGasPaymaster,
|
|
45
|
-
_interchainSecurityModule
|
|
61
|
+
_interchainSecurityModule,
|
|
62
|
+
_owner
|
|
46
63
|
);
|
|
47
64
|
}
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
__Router_initialize(_mailbox, _interchainGasPaymaster);
|
|
55
|
-
}
|
|
56
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @notice Dispatches a sequence of calls to be relayed by the sender's interchain account on the destination domain.
|
|
68
|
+
* @param _destinationDomain The domain of the chain where the message will be sent to.
|
|
69
|
+
* @param calls The sequence of calls to be relayed.
|
|
70
|
+
*/
|
|
57
71
|
function dispatch(uint32 _destinationDomain, Call[] calldata calls)
|
|
58
72
|
external
|
|
59
73
|
returns (bytes32)
|
|
@@ -61,6 +75,13 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
61
75
|
return _dispatch(_destinationDomain, abi.encode(msg.sender, calls));
|
|
62
76
|
}
|
|
63
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @notice Dispatches a single call to be relayed by the sender's interchain account on the destination domain.
|
|
80
|
+
* @param _destinationDomain The domain of the chain where the message will be sent to.
|
|
81
|
+
* @param target The address of the contract to be called.
|
|
82
|
+
* @param data The ABI-encoded data to be called on target contract.
|
|
83
|
+
* @return The message ID of the dispatched message.
|
|
84
|
+
*/
|
|
64
85
|
function dispatch(
|
|
65
86
|
uint32 _destinationDomain,
|
|
66
87
|
address target,
|
|
@@ -71,6 +92,12 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
71
92
|
return _dispatch(_destinationDomain, abi.encode(msg.sender, calls));
|
|
72
93
|
}
|
|
73
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @notice Returns the address of the interchain account deployed on the current chain for a given `origin`/`sender` pair.
|
|
97
|
+
* @param _origin The origin domain of the interchain account.
|
|
98
|
+
* @param _sender The parent account address on the origin domain.
|
|
99
|
+
* @return The address of the interchain account.
|
|
100
|
+
*/
|
|
74
101
|
function getInterchainAccount(uint32 _origin, address _sender)
|
|
75
102
|
public
|
|
76
103
|
view
|
|
@@ -79,6 +106,12 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
79
106
|
return _getInterchainAccount(_salt(_origin, _sender));
|
|
80
107
|
}
|
|
81
108
|
|
|
109
|
+
/**
|
|
110
|
+
* @notice Returns and deploys (if not already) the interchain account for a given `origin`/`sender` pair.
|
|
111
|
+
* @param _origin The origin domain of the interchain account.
|
|
112
|
+
* @param _sender The parent account address on the origin domain.
|
|
113
|
+
* @return The address of the interchain account.
|
|
114
|
+
*/
|
|
82
115
|
function getDeployedInterchainAccount(uint32 _origin, address _sender)
|
|
83
116
|
public
|
|
84
117
|
returns (OwnableMulticall)
|
|
@@ -94,6 +127,12 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
94
127
|
return OwnableMulticall(interchainAccount);
|
|
95
128
|
}
|
|
96
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @notice Returns the salt used to deploy the interchain account for a given `origin`/`sender` pair.
|
|
132
|
+
* @param _origin The origin domain of the interchain account.
|
|
133
|
+
* @param _sender The parent account address on the origin domain.
|
|
134
|
+
* @return The CREATE2 salt used for deploying the interchain account.
|
|
135
|
+
*/
|
|
97
136
|
function _salt(uint32 _origin, address _sender)
|
|
98
137
|
internal
|
|
99
138
|
pure
|
|
@@ -102,6 +141,11 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
102
141
|
return bytes32(abi.encodePacked(_origin, _sender));
|
|
103
142
|
}
|
|
104
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @notice Returns the address of the interchain account deployed on the current chain for a given salt.
|
|
146
|
+
* @param salt The salt used to deploy the interchain account.
|
|
147
|
+
* @return The address of the interchain account.
|
|
148
|
+
*/
|
|
105
149
|
function _getInterchainAccount(bytes32 salt)
|
|
106
150
|
internal
|
|
107
151
|
view
|
|
@@ -110,6 +154,11 @@ contract InterchainAccountRouter is Router, IInterchainAccountRouter {
|
|
|
110
154
|
return Create2.computeAddress(salt, bytecodeHash);
|
|
111
155
|
}
|
|
112
156
|
|
|
157
|
+
/**
|
|
158
|
+
* @notice Handles dispatched messages by relaying calls to the interchain account.
|
|
159
|
+
* @param _origin The origin domain of the interchain account.
|
|
160
|
+
* @param _message The ABI-encoded message containing the sender and the sequence of calls to be relayed.
|
|
161
|
+
*/
|
|
113
162
|
function _handle(
|
|
114
163
|
uint32 _origin,
|
|
115
164
|
bytes32, // router sender
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.13;
|
|
3
3
|
|
|
4
4
|
// ============ Internal Imports ============
|
|
5
|
-
import {
|
|
5
|
+
import {_call, _proxyCallBatch, Call} from "../OwnableMulticall.sol";
|
|
6
6
|
import {Router} from "../Router.sol";
|
|
7
7
|
import {IInterchainQueryRouter} from "../../interfaces/IInterchainQueryRouter.sol";
|
|
8
8
|
|
|
@@ -11,52 +11,68 @@ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
|
11
11
|
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
12
12
|
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
14
|
+
/**
|
|
15
|
+
* @title Interchain Query Router that performs remote view calls on other chains and returns the result.
|
|
16
|
+
* @dev Currently does not support Sovereign Consensus (user specified Interchain Security Modules).
|
|
17
|
+
*/
|
|
18
|
+
contract InterchainQueryRouter is Router, IInterchainQueryRouter {
|
|
19
19
|
enum Action {
|
|
20
20
|
DISPATCH,
|
|
21
21
|
RESOLVE
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @notice Emitted when a query is dispatched to another chain.
|
|
26
|
+
* @param destinationDomain The domain of the chain to query.
|
|
27
|
+
* @param sender The address that dispatched the query.
|
|
28
|
+
*/
|
|
24
29
|
event QueryDispatched(
|
|
25
30
|
uint32 indexed destinationDomain,
|
|
26
31
|
address indexed sender
|
|
27
32
|
);
|
|
33
|
+
/**
|
|
34
|
+
* @notice Emitted when a query is returned to the origin chain.
|
|
35
|
+
* @param originDomain The domain of the chain to return the result to.
|
|
36
|
+
* @param sender The address to receive the result.
|
|
37
|
+
*/
|
|
28
38
|
event QueryReturned(uint32 indexed originDomain, address indexed sender);
|
|
39
|
+
/**
|
|
40
|
+
* @notice Emitted when a query is resolved on the origin chain.
|
|
41
|
+
* @param destinationDomain The domain of the chain that was queried.
|
|
42
|
+
* @param sender The address that resolved the query.
|
|
43
|
+
*/
|
|
29
44
|
event QueryResolved(
|
|
30
45
|
uint32 indexed destinationDomain,
|
|
31
46
|
address indexed sender
|
|
32
47
|
);
|
|
33
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @notice Initializes the Router contract with Hyperlane core contracts and the address of the interchain security module.
|
|
51
|
+
* @param _mailbox The address of the mailbox contract.
|
|
52
|
+
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
|
|
53
|
+
* @param _interchainSecurityModule The address of the interchain security module contract.
|
|
54
|
+
* @param _owner The address with owner privileges.
|
|
55
|
+
*/
|
|
34
56
|
function initialize(
|
|
35
57
|
address _mailbox,
|
|
36
58
|
address _interchainGasPaymaster,
|
|
37
|
-
address _interchainSecurityModule
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
address _interchainSecurityModule,
|
|
60
|
+
address _owner
|
|
61
|
+
) external initializer {
|
|
62
|
+
__HyperlaneConnectionClient_initialize(
|
|
41
63
|
_mailbox,
|
|
42
64
|
_interchainGasPaymaster,
|
|
43
|
-
_interchainSecurityModule
|
|
65
|
+
_interchainSecurityModule,
|
|
66
|
+
_owner
|
|
44
67
|
);
|
|
45
68
|
}
|
|
46
69
|
|
|
47
|
-
function initialize(address _mailbox, address _interchainGasPaymaster)
|
|
48
|
-
public
|
|
49
|
-
initializer
|
|
50
|
-
{
|
|
51
|
-
// Transfer ownership of the contract to `msg.sender`
|
|
52
|
-
__Router_initialize(_mailbox, _interchainGasPaymaster);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
70
|
/**
|
|
56
71
|
* @param _destinationDomain Domain of destination chain
|
|
57
72
|
* @param target The address of the contract to query on destination chain.
|
|
58
73
|
* @param queryData The calldata of the view call to make on the destination chain.
|
|
59
74
|
* @param callback Callback function selector on `msg.sender` and optionally abi-encoded prefix arguments.
|
|
75
|
+
* @return messageId The ID of the message encoding the query.
|
|
60
76
|
*/
|
|
61
77
|
function query(
|
|
62
78
|
uint32 _destinationDomain,
|
|
@@ -111,14 +127,17 @@ contract InterchainQueryRouter is
|
|
|
111
127
|
emit QueryDispatched(_destinationDomain, msg.sender);
|
|
112
128
|
}
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
/**
|
|
131
|
+
* @notice Handles a message from remote enrolled Interchain Query Router.
|
|
132
|
+
* @param _origin The domain of the chain that sent the message.
|
|
133
|
+
* @param _message The ABI-encoded interchain query.
|
|
134
|
+
*/
|
|
115
135
|
function _handle(
|
|
116
136
|
uint32 _origin,
|
|
117
137
|
bytes32, // router sender
|
|
118
138
|
bytes calldata _message
|
|
119
139
|
) internal override {
|
|
120
|
-
|
|
121
|
-
Action action = abi.decode(_message, (Action));
|
|
140
|
+
Action action = Action(uint8(bytes1(_message[31])));
|
|
122
141
|
if (action == Action.DISPATCH) {
|
|
123
142
|
(
|
|
124
143
|
,
|
|
@@ -137,7 +156,7 @@ contract InterchainQueryRouter is
|
|
|
137
156
|
_message,
|
|
138
157
|
(Action, address, bytes[])
|
|
139
158
|
);
|
|
140
|
-
|
|
159
|
+
_proxyCallBatch(sender, resolveCallbacks);
|
|
141
160
|
emit QueryResolved(_origin, sender);
|
|
142
161
|
}
|
|
143
162
|
}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Interchain Accounts
|
|
4
4
|
|
|
5
|
-
An interchain account is a smart contract that is deployed on a remote chain
|
|
6
|
-
Interchain accounts provide developers with a [transparent multicall API](
|
|
5
|
+
An interchain account is a smart contract that is deployed on a remote chain controlled exclusively by the origin chain's deployer account.
|
|
6
|
+
Interchain accounts provide developers with a [transparent multicall API](../OwnableMulticall.sol) to remote smart contracts.
|
|
7
7
|
This avoids the need to deploy application specific smart contracts on remote chains while simultaneously enabling cross-chain composability.
|
|
8
8
|
|
|
9
9
|
See [IBC Interchain Accounts](https://github.com/cosmos/ibc/blob/main/spec/app/ics-027-interchain-accounts/README.md) for the Cosmos ecosystem equivalent.
|
|
10
10
|
|
|
11
11
|
## Interchain Query System
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The interchain query system generalizes view calls to contracts on remote chains. It is a [transparent multicall API](../OwnableMulticall.sol) that can be used to query remote smart contracts. This avoids the need to deploy application specific smart contracts on remote chains while simultaneously enabling cross-chain composability.
|
|
14
|
+
|
|
15
|
+
See [IBC Interchain Query System](https://github.com/cosmos/ibc/tree/main/spec/app/ics-031-crosschain-queries) for the Cosmos ecosystem equivalent.
|
|
@@ -19,27 +19,27 @@ contract LiquidityLayerRouter is Router, ILiquidityLayerRouter {
|
|
|
19
19
|
|
|
20
20
|
event LiquidityLayerAdapterSet(string indexed bridge, address adapter);
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @notice Initializes the Router contract with Hyperlane core contracts and the address of the interchain security module.
|
|
24
|
+
* @param _mailbox The address of the mailbox contract.
|
|
25
|
+
* @param _interchainGasPaymaster The address of the interchain gas paymaster contract.
|
|
26
|
+
* @param _interchainSecurityModule The address of the interchain security module contract.
|
|
27
|
+
* @param _owner The address with owner privileges.
|
|
28
|
+
*/
|
|
22
29
|
function initialize(
|
|
23
30
|
address _mailbox,
|
|
24
31
|
address _interchainGasPaymaster,
|
|
25
|
-
address _interchainSecurityModule
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
address _interchainSecurityModule,
|
|
33
|
+
address _owner
|
|
34
|
+
) external initializer {
|
|
35
|
+
__HyperlaneConnectionClient_initialize(
|
|
29
36
|
_mailbox,
|
|
30
37
|
_interchainGasPaymaster,
|
|
31
|
-
_interchainSecurityModule
|
|
38
|
+
_interchainSecurityModule,
|
|
39
|
+
_owner
|
|
32
40
|
);
|
|
33
41
|
}
|
|
34
42
|
|
|
35
|
-
function initialize(address _mailbox, address _interchainGasPaymaster)
|
|
36
|
-
public
|
|
37
|
-
initializer
|
|
38
|
-
{
|
|
39
|
-
// Transfer ownership of the contract to `msg.sender`
|
|
40
|
-
__Router_initialize(_mailbox, _interchainGasPaymaster);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
43
|
function dispatchWithTokens(
|
|
44
44
|
uint32 _destinationDomain,
|
|
45
45
|
bytes32 _recipientAddress,
|
|
@@ -39,15 +39,18 @@ contract MockHyperlaneEnvironment {
|
|
|
39
39
|
InterchainQueryRouter originQueryRouter = new InterchainQueryRouter();
|
|
40
40
|
InterchainQueryRouter destinationQueryRouter = new InterchainQueryRouter();
|
|
41
41
|
|
|
42
|
+
address owner = address(this);
|
|
42
43
|
originQueryRouter.initialize(
|
|
43
44
|
address(originMailbox),
|
|
44
45
|
address(igps[originDomain]),
|
|
45
|
-
address(isms[originDomain])
|
|
46
|
+
address(isms[originDomain]),
|
|
47
|
+
owner
|
|
46
48
|
);
|
|
47
49
|
destinationQueryRouter.initialize(
|
|
48
50
|
address(destinationMailbox),
|
|
49
51
|
address(igps[destinationDomain]),
|
|
50
|
-
address(isms[destinationDomain])
|
|
52
|
+
address(isms[destinationDomain]),
|
|
53
|
+
owner
|
|
51
54
|
);
|
|
52
55
|
|
|
53
56
|
originQueryRouter.enrollRemoteRouter(
|
|
@@ -20,8 +20,7 @@ export interface InterchainAccountRouterInterface extends utils.Interface {
|
|
|
20
20
|
"getDeployedInterchainAccount(uint32,address)": FunctionFragment;
|
|
21
21
|
"getInterchainAccount(uint32,address)": FunctionFragment;
|
|
22
22
|
"handle(uint32,bytes32,bytes)": FunctionFragment;
|
|
23
|
-
"initialize(address,address)": FunctionFragment;
|
|
24
|
-
"initialize(address,address,address)": FunctionFragment;
|
|
23
|
+
"initialize(address,address,address,address)": FunctionFragment;
|
|
25
24
|
"interchainGasPaymaster()": FunctionFragment;
|
|
26
25
|
"interchainSecurityModule()": FunctionFragment;
|
|
27
26
|
"mailbox()": FunctionFragment;
|
|
@@ -33,7 +32,7 @@ export interface InterchainAccountRouterInterface extends utils.Interface {
|
|
|
33
32
|
"setMailbox(address)": FunctionFragment;
|
|
34
33
|
"transferOwnership(address)": FunctionFragment;
|
|
35
34
|
};
|
|
36
|
-
getFunction(nameOrSignatureOrTopic: "dispatch(uint32,(address,bytes)[])" | "dispatch(uint32,address,bytes)" | "domains" | "enrollRemoteRouter" | "enrollRemoteRouters" | "getDeployedInterchainAccount" | "getInterchainAccount" | "handle" | "initialize
|
|
35
|
+
getFunction(nameOrSignatureOrTopic: "dispatch(uint32,(address,bytes)[])" | "dispatch(uint32,address,bytes)" | "domains" | "enrollRemoteRouter" | "enrollRemoteRouters" | "getDeployedInterchainAccount" | "getInterchainAccount" | "handle" | "initialize" | "interchainGasPaymaster" | "interchainSecurityModule" | "mailbox" | "owner" | "renounceOwnership" | "routers" | "setInterchainGasPaymaster" | "setInterchainSecurityModule" | "setMailbox" | "transferOwnership"): FunctionFragment;
|
|
37
36
|
encodeFunctionData(functionFragment: "dispatch(uint32,(address,bytes)[])", values: [BigNumberish, CallStruct[]]): string;
|
|
38
37
|
encodeFunctionData(functionFragment: "dispatch(uint32,address,bytes)", values: [BigNumberish, string, BytesLike]): string;
|
|
39
38
|
encodeFunctionData(functionFragment: "domains", values?: undefined): string;
|
|
@@ -42,8 +41,7 @@ export interface InterchainAccountRouterInterface extends utils.Interface {
|
|
|
42
41
|
encodeFunctionData(functionFragment: "getDeployedInterchainAccount", values: [BigNumberish, string]): string;
|
|
43
42
|
encodeFunctionData(functionFragment: "getInterchainAccount", values: [BigNumberish, string]): string;
|
|
44
43
|
encodeFunctionData(functionFragment: "handle", values: [BigNumberish, BytesLike, BytesLike]): string;
|
|
45
|
-
encodeFunctionData(functionFragment: "initialize
|
|
46
|
-
encodeFunctionData(functionFragment: "initialize(address,address,address)", values: [string, string, string]): string;
|
|
44
|
+
encodeFunctionData(functionFragment: "initialize", values: [string, string, string, string]): string;
|
|
47
45
|
encodeFunctionData(functionFragment: "interchainGasPaymaster", values?: undefined): string;
|
|
48
46
|
encodeFunctionData(functionFragment: "interchainSecurityModule", values?: undefined): string;
|
|
49
47
|
encodeFunctionData(functionFragment: "mailbox", values?: undefined): string;
|
|
@@ -62,8 +60,7 @@ export interface InterchainAccountRouterInterface extends utils.Interface {
|
|
|
62
60
|
decodeFunctionResult(functionFragment: "getDeployedInterchainAccount", data: BytesLike): Result;
|
|
63
61
|
decodeFunctionResult(functionFragment: "getInterchainAccount", data: BytesLike): Result;
|
|
64
62
|
decodeFunctionResult(functionFragment: "handle", data: BytesLike): Result;
|
|
65
|
-
decodeFunctionResult(functionFragment: "initialize
|
|
66
|
-
decodeFunctionResult(functionFragment: "initialize(address,address,address)", data: BytesLike): Result;
|
|
63
|
+
decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result;
|
|
67
64
|
decodeFunctionResult(functionFragment: "interchainGasPaymaster", data: BytesLike): Result;
|
|
68
65
|
decodeFunctionResult(functionFragment: "interchainSecurityModule", data: BytesLike): Result;
|
|
69
66
|
decodeFunctionResult(functionFragment: "mailbox", data: BytesLike): Result;
|
|
@@ -179,10 +176,7 @@ export interface InterchainAccountRouter extends BaseContract {
|
|
|
179
176
|
handle(_origin: BigNumberish, _sender: BytesLike, _message: BytesLike, overrides?: Overrides & {
|
|
180
177
|
from?: string | Promise<string>;
|
|
181
178
|
}): Promise<ContractTransaction>;
|
|
182
|
-
|
|
183
|
-
from?: string | Promise<string>;
|
|
184
|
-
}): Promise<ContractTransaction>;
|
|
185
|
-
"initialize(address,address,address)"(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, overrides?: Overrides & {
|
|
179
|
+
initialize(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, _owner: string, overrides?: Overrides & {
|
|
186
180
|
from?: string | Promise<string>;
|
|
187
181
|
}): Promise<ContractTransaction>;
|
|
188
182
|
interchainGasPaymaster(overrides?: CallOverrides): Promise<[string]>;
|
|
@@ -226,10 +220,7 @@ export interface InterchainAccountRouter extends BaseContract {
|
|
|
226
220
|
handle(_origin: BigNumberish, _sender: BytesLike, _message: BytesLike, overrides?: Overrides & {
|
|
227
221
|
from?: string | Promise<string>;
|
|
228
222
|
}): Promise<ContractTransaction>;
|
|
229
|
-
|
|
230
|
-
from?: string | Promise<string>;
|
|
231
|
-
}): Promise<ContractTransaction>;
|
|
232
|
-
"initialize(address,address,address)"(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, overrides?: Overrides & {
|
|
223
|
+
initialize(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, _owner: string, overrides?: Overrides & {
|
|
233
224
|
from?: string | Promise<string>;
|
|
234
225
|
}): Promise<ContractTransaction>;
|
|
235
226
|
interchainGasPaymaster(overrides?: CallOverrides): Promise<string>;
|
|
@@ -261,8 +252,7 @@ export interface InterchainAccountRouter extends BaseContract {
|
|
|
261
252
|
getDeployedInterchainAccount(_origin: BigNumberish, _sender: string, overrides?: CallOverrides): Promise<string>;
|
|
262
253
|
getInterchainAccount(_origin: BigNumberish, _sender: string, overrides?: CallOverrides): Promise<string>;
|
|
263
254
|
handle(_origin: BigNumberish, _sender: BytesLike, _message: BytesLike, overrides?: CallOverrides): Promise<void>;
|
|
264
|
-
|
|
265
|
-
"initialize(address,address,address)"(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, overrides?: CallOverrides): Promise<void>;
|
|
255
|
+
initialize(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, _owner: string, overrides?: CallOverrides): Promise<void>;
|
|
266
256
|
interchainGasPaymaster(overrides?: CallOverrides): Promise<string>;
|
|
267
257
|
interchainSecurityModule(overrides?: CallOverrides): Promise<string>;
|
|
268
258
|
mailbox(overrides?: CallOverrides): Promise<string>;
|
|
@@ -311,10 +301,7 @@ export interface InterchainAccountRouter extends BaseContract {
|
|
|
311
301
|
handle(_origin: BigNumberish, _sender: BytesLike, _message: BytesLike, overrides?: Overrides & {
|
|
312
302
|
from?: string | Promise<string>;
|
|
313
303
|
}): Promise<BigNumber>;
|
|
314
|
-
|
|
315
|
-
from?: string | Promise<string>;
|
|
316
|
-
}): Promise<BigNumber>;
|
|
317
|
-
"initialize(address,address,address)"(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, overrides?: Overrides & {
|
|
304
|
+
initialize(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, _owner: string, overrides?: Overrides & {
|
|
318
305
|
from?: string | Promise<string>;
|
|
319
306
|
}): Promise<BigNumber>;
|
|
320
307
|
interchainGasPaymaster(overrides?: CallOverrides): Promise<BigNumber>;
|
|
@@ -359,10 +346,7 @@ export interface InterchainAccountRouter extends BaseContract {
|
|
|
359
346
|
handle(_origin: BigNumberish, _sender: BytesLike, _message: BytesLike, overrides?: Overrides & {
|
|
360
347
|
from?: string | Promise<string>;
|
|
361
348
|
}): Promise<PopulatedTransaction>;
|
|
362
|
-
|
|
363
|
-
from?: string | Promise<string>;
|
|
364
|
-
}): Promise<PopulatedTransaction>;
|
|
365
|
-
"initialize(address,address,address)"(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, overrides?: Overrides & {
|
|
349
|
+
initialize(_mailbox: string, _interchainGasPaymaster: string, _interchainSecurityModule: string, _owner: string, overrides?: Overrides & {
|
|
366
350
|
from?: string | Promise<string>;
|
|
367
351
|
}): Promise<PopulatedTransaction>;
|
|
368
352
|
interchainGasPaymaster(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|