@hyperlane-xyz/core 1.2.0 → 1.2.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/README.md +3 -3
- package/contracts/igps/InterchainGasPaymaster.sol +133 -29
- package/contracts/igps/gas-oracles/StorageGasOracle.sol +104 -0
- package/contracts/mock/MockHyperlaneEnvironment.sol +2 -2
- package/contracts/test/LightTestRecipient.sol +3 -0
- package/contracts/test/TestInterchainGasPaymaster.sol +4 -5
- package/dist/contracts/igps/InterchainGasPaymaster.d.ts +116 -8
- package/dist/contracts/igps/InterchainGasPaymaster.d.ts.map +1 -1
- package/dist/contracts/igps/OverheadIgp.d.ts +15 -0
- package/dist/contracts/igps/OverheadIgp.d.ts.map +1 -1
- package/dist/contracts/igps/gas-oracles/StorageGasOracle.d.ts +205 -0
- package/dist/contracts/igps/gas-oracles/StorageGasOracle.d.ts.map +1 -0
- package/dist/contracts/igps/gas-oracles/StorageGasOracle.js +4 -0
- package/dist/contracts/igps/gas-oracles/StorageGasOracle.js.map +1 -0
- package/dist/contracts/igps/gas-oracles/index.d.ts +2 -0
- package/dist/contracts/igps/gas-oracles/index.d.ts.map +1 -0
- package/dist/contracts/igps/gas-oracles/index.js +3 -0
- package/dist/contracts/igps/gas-oracles/index.js.map +1 -0
- package/dist/contracts/igps/index.d.ts +2 -0
- package/dist/contracts/igps/index.d.ts.map +1 -1
- package/dist/contracts/igps/index.js +1 -0
- package/dist/contracts/igps/index.js.map +1 -1
- package/dist/contracts/test/TestInterchainGasPaymaster.d.ts +116 -16
- package/dist/contracts/test/TestInterchainGasPaymaster.d.ts.map +1 -1
- package/dist/factories/contracts/igps/InterchainGasPaymaster__factory.d.ts +24 -4
- package/dist/factories/contracts/igps/InterchainGasPaymaster__factory.d.ts.map +1 -1
- package/dist/factories/contracts/igps/InterchainGasPaymaster__factory.js +150 -7
- package/dist/factories/contracts/igps/InterchainGasPaymaster__factory.js.map +1 -1
- package/dist/factories/contracts/igps/OverheadIgp__factory.d.ts +1 -1
- package/dist/factories/contracts/igps/OverheadIgp__factory.d.ts.map +1 -1
- package/dist/factories/contracts/igps/OverheadIgp__factory.js +26 -1
- package/dist/factories/contracts/igps/OverheadIgp__factory.js.map +1 -1
- package/dist/factories/contracts/igps/gas-oracles/StorageGasOracle__factory.d.ts +64 -0
- package/dist/factories/contracts/igps/gas-oracles/StorageGasOracle__factory.d.ts.map +1 -0
- package/dist/factories/contracts/igps/gas-oracles/StorageGasOracle__factory.js +226 -0
- package/dist/factories/contracts/igps/gas-oracles/StorageGasOracle__factory.js.map +1 -0
- package/dist/factories/contracts/igps/gas-oracles/index.d.ts +2 -0
- package/dist/factories/contracts/igps/gas-oracles/index.d.ts.map +1 -0
- package/dist/factories/contracts/igps/gas-oracles/index.js +9 -0
- package/dist/factories/contracts/igps/gas-oracles/index.js.map +1 -0
- package/dist/factories/contracts/igps/index.d.ts +1 -0
- package/dist/factories/contracts/igps/index.d.ts.map +1 -1
- package/dist/factories/contracts/igps/index.js +25 -1
- package/dist/factories/contracts/igps/index.js.map +1 -1
- package/dist/factories/contracts/middleware/InterchainAccountRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/InterchainAccountRouter__factory.js +1 -1
- package/dist/factories/contracts/middleware/InterchainQueryRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/InterchainQueryRouter__factory.js +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/LiquidityLayerRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/LiquidityLayerRouter__factory.js +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.js +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/adapters/PortalAdapter__factory.d.ts +1 -1
- package/dist/factories/contracts/middleware/liquidity-layer/adapters/PortalAdapter__factory.js +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/test/LightTestRecipient__factory.d.ts +1 -1
- package/dist/factories/contracts/test/LightTestRecipient__factory.js +1 -1
- package/dist/factories/contracts/test/TestGasRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestGasRouter__factory.js +1 -1
- package/dist/factories/contracts/test/TestHyperlaneConnectionClient__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestHyperlaneConnectionClient__factory.js +1 -1
- package/dist/factories/contracts/test/TestInterchainGasPaymaster__factory.d.ts +31 -4
- package/dist/factories/contracts/test/TestInterchainGasPaymaster__factory.d.ts.map +1 -1
- package/dist/factories/contracts/test/TestInterchainGasPaymaster__factory.js +158 -10
- package/dist/factories/contracts/test/TestInterchainGasPaymaster__factory.js.map +1 -1
- package/dist/factories/contracts/test/TestQuerySender__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestQuerySender__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.js +1 -1
- package/dist/factories/contracts/test/TestSendReceiver__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestSendReceiver__factory.js +1 -1
- package/dist/factories/interfaces/IGasOracle__factory.d.ts +23 -0
- package/dist/factories/interfaces/IGasOracle__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IGasOracle__factory.js +42 -0
- package/dist/factories/interfaces/IGasOracle__factory.js.map +1 -0
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.d.ts +15 -2
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.d.ts.map +1 -1
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.js +25 -0
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.js.map +1 -1
- package/dist/factories/interfaces/index.d.ts +1 -0
- package/dist/factories/interfaces/index.d.ts.map +1 -1
- package/dist/factories/interfaces/index.js +3 -1
- package/dist/factories/interfaces/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/IGasOracle.d.ts +61 -0
- package/dist/interfaces/IGasOracle.d.ts.map +1 -0
- package/dist/interfaces/IGasOracle.js +4 -0
- package/dist/interfaces/IGasOracle.js.map +1 -0
- package/dist/interfaces/IInterchainGasPaymaster.d.ts +20 -3
- package/dist/interfaces/IInterchainGasPaymaster.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.d.ts.map +1 -1
- package/interfaces/IGasOracle.sol +16 -0
- package/interfaces/IInterchainGasPaymaster.sol +12 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# Hyperlane Solidity
|
|
2
2
|
|
|
3
3
|
On-chain implementations of Hyperlane in Solidity.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Setup
|
|
6
6
|
|
|
7
7
|
- `npm install --dev`
|
|
8
8
|
- `brew install jq` OR `sudo apt-get install jq`
|
|
9
9
|
- `npm install -g solhint`, check it is installed using `solhint --version`
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Build
|
|
12
12
|
|
|
13
13
|
- `npm run compile`
|
|
14
14
|
- `npm run test`
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity >=0.8.0;
|
|
3
3
|
|
|
4
4
|
// ============ Internal Imports ============
|
|
5
|
+
import {IGasOracle} from "../../interfaces/IGasOracle.sol";
|
|
5
6
|
import {IInterchainGasPaymaster} from "../../interfaces/IInterchainGasPaymaster.sol";
|
|
6
7
|
// ============ External Imports ============
|
|
7
8
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
@@ -11,31 +12,63 @@ import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Own
|
|
|
11
12
|
* @notice Manages payments on a source chain to cover gas costs of relaying
|
|
12
13
|
* messages to destination chains.
|
|
13
14
|
*/
|
|
14
|
-
contract InterchainGasPaymaster is
|
|
15
|
+
contract InterchainGasPaymaster is
|
|
16
|
+
IInterchainGasPaymaster,
|
|
17
|
+
IGasOracle,
|
|
18
|
+
OwnableUpgradeable
|
|
19
|
+
{
|
|
20
|
+
// ============ Constants ============
|
|
21
|
+
|
|
22
|
+
/// @notice The scale of gas oracle token exchange rates.
|
|
23
|
+
uint256 internal constant TOKEN_EXCHANGE_RATE_SCALE = 1e10;
|
|
24
|
+
|
|
25
|
+
// ============ Public Storage ============
|
|
26
|
+
|
|
27
|
+
/// @notice Keyed by remote domain, the gas oracle to use for the domain.
|
|
28
|
+
mapping(uint32 => IGasOracle) public gasOracles;
|
|
29
|
+
|
|
30
|
+
/// @notice The benficiary that can receive native tokens paid into this contract.
|
|
31
|
+
address public beneficiary;
|
|
32
|
+
|
|
15
33
|
// ============ Events ============
|
|
16
34
|
|
|
17
35
|
/**
|
|
18
|
-
* @notice Emitted when
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param payment The amount of native tokens paid.
|
|
36
|
+
* @notice Emitted when the gas oracle for a remote domain is set.
|
|
37
|
+
* @param remoteDomain The remote domain.
|
|
38
|
+
* @param gasOracle The gas oracle.
|
|
22
39
|
*/
|
|
23
|
-
event
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
event GasOracleSet(uint32 indexed remoteDomain, address gasOracle);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @notice Emitted when the beneficiary is set.
|
|
44
|
+
* @param beneficiary The new beneficiary.
|
|
45
|
+
*/
|
|
46
|
+
event BeneficiarySet(address beneficiary);
|
|
47
|
+
|
|
48
|
+
struct GasOracleConfig {
|
|
49
|
+
uint32 remoteDomain;
|
|
50
|
+
address gasOracle;
|
|
51
|
+
}
|
|
28
52
|
|
|
29
53
|
// ============ Constructor ============
|
|
30
54
|
|
|
31
|
-
constructor() {
|
|
32
|
-
initialize(); // allows contract to be used without proxying
|
|
55
|
+
constructor(address _beneficiary) {
|
|
56
|
+
initialize(msg.sender, _beneficiary); // allows contract to be used without proxying
|
|
33
57
|
}
|
|
34
58
|
|
|
35
59
|
// ============ External Functions ============
|
|
36
60
|
|
|
37
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @param _owner The owner of the contract.
|
|
63
|
+
* @param _beneficiary The beneficiary.
|
|
64
|
+
*/
|
|
65
|
+
function initialize(address _owner, address _beneficiary)
|
|
66
|
+
public
|
|
67
|
+
initializer
|
|
68
|
+
{
|
|
38
69
|
__Ownable_init();
|
|
70
|
+
_transferOwnership(_owner);
|
|
71
|
+
_setBeneficiary(_beneficiary);
|
|
39
72
|
}
|
|
40
73
|
|
|
41
74
|
/**
|
|
@@ -45,8 +78,8 @@ contract InterchainGasPaymaster is IInterchainGasPaymaster, OwnableUpgradeable {
|
|
|
45
78
|
* Callers should be aware that this may present reentrancy issues.
|
|
46
79
|
* @param _messageId The ID of the message to pay for.
|
|
47
80
|
* @param _destinationDomain The domain of the message's destination chain.
|
|
48
|
-
* @param _gasAmount The amount of destination gas to pay for.
|
|
49
|
-
* @param _refundAddress The address to refund any overpayment to.
|
|
81
|
+
* @param _gasAmount The amount of destination gas to pay for.
|
|
82
|
+
* @param _refundAddress The address to refund any overpayment to.
|
|
50
83
|
*/
|
|
51
84
|
function payForGas(
|
|
52
85
|
bytes32 _messageId,
|
|
@@ -68,13 +101,47 @@ contract InterchainGasPaymaster is IInterchainGasPaymaster, OwnableUpgradeable {
|
|
|
68
101
|
require(_success, "Interchain gas payment refund failed");
|
|
69
102
|
}
|
|
70
103
|
|
|
71
|
-
emit GasPayment(_messageId, _gasAmount,
|
|
104
|
+
emit GasPayment(_messageId, _gasAmount, _requiredPayment);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @notice Transfers the entire native token balance to the beneficiary.
|
|
109
|
+
* @dev The beneficiary must be able to receive native tokens.
|
|
110
|
+
*/
|
|
111
|
+
function claim() external {
|
|
112
|
+
// Transfer the entire balance to the beneficiary.
|
|
113
|
+
(bool success, ) = beneficiary.call{value: address(this).balance}("");
|
|
114
|
+
require(success, "!transfer");
|
|
72
115
|
}
|
|
73
116
|
|
|
117
|
+
/**
|
|
118
|
+
* @notice Sets the gas oracles for remote domains specified in the config array.
|
|
119
|
+
* @param _configs An array of configs including the remote domain and gas oracles to set.
|
|
120
|
+
*/
|
|
121
|
+
function setGasOracles(GasOracleConfig[] calldata _configs)
|
|
122
|
+
external
|
|
123
|
+
onlyOwner
|
|
124
|
+
{
|
|
125
|
+
uint256 _len = _configs.length;
|
|
126
|
+
for (uint256 i = 0; i < _len; i++) {
|
|
127
|
+
_setGasOracle(_configs[i].remoteDomain, _configs[i].gasOracle);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @notice Sets the beneficiary.
|
|
133
|
+
* @param _beneficiary The new beneficiary.
|
|
134
|
+
*/
|
|
135
|
+
function setBeneficiary(address _beneficiary) external onlyOwner {
|
|
136
|
+
_setBeneficiary(_beneficiary);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ============ Public Functions ============
|
|
140
|
+
|
|
74
141
|
/**
|
|
75
142
|
* @notice Quotes the amount of native tokens to pay for interchain gas.
|
|
76
143
|
* @param _destinationDomain The domain of the message's destination chain.
|
|
77
|
-
* @param _gasAmount The amount of destination gas to pay for.
|
|
144
|
+
* @param _gasAmount The amount of destination gas to pay for.
|
|
78
145
|
* @return The amount of native tokens required to pay for interchain gas.
|
|
79
146
|
*/
|
|
80
147
|
function quoteGasPayment(uint32 _destinationDomain, uint256 _gasAmount)
|
|
@@ -84,21 +151,58 @@ contract InterchainGasPaymaster is IInterchainGasPaymaster, OwnableUpgradeable {
|
|
|
84
151
|
override
|
|
85
152
|
returns (uint256)
|
|
86
153
|
{
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
154
|
+
// Get the gas data for the destination domain.
|
|
155
|
+
(
|
|
156
|
+
uint128 _tokenExchangeRate,
|
|
157
|
+
uint128 _gasPrice
|
|
158
|
+
) = getExchangeRateAndGasPrice(_destinationDomain);
|
|
159
|
+
|
|
160
|
+
// The total cost quoted in destination chain's native token.
|
|
161
|
+
uint256 _destinationGasCost = _gasAmount * uint256(_gasPrice);
|
|
162
|
+
|
|
163
|
+
// Convert to the local native token.
|
|
164
|
+
return
|
|
165
|
+
(_destinationGasCost * _tokenExchangeRate) /
|
|
166
|
+
TOKEN_EXCHANGE_RATE_SCALE;
|
|
93
167
|
}
|
|
94
168
|
|
|
95
169
|
/**
|
|
96
|
-
* @notice
|
|
97
|
-
*
|
|
170
|
+
* @notice Gets the token exchange rate and gas price from the configured gas oracle
|
|
171
|
+
* for a given destination domain.
|
|
172
|
+
* @param _destinationDomain The destination domain.
|
|
173
|
+
* @return tokenExchangeRate The exchange rate of the remote native token quoted in the local native token.
|
|
174
|
+
* @return gasPrice The gas price on the remote chain.
|
|
98
175
|
*/
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
176
|
+
function getExchangeRateAndGasPrice(uint32 _destinationDomain)
|
|
177
|
+
public
|
|
178
|
+
view
|
|
179
|
+
override
|
|
180
|
+
returns (uint128 tokenExchangeRate, uint128 gasPrice)
|
|
181
|
+
{
|
|
182
|
+
IGasOracle _gasOracle = gasOracles[_destinationDomain];
|
|
183
|
+
require(address(_gasOracle) != address(0), "!gas oracle");
|
|
184
|
+
|
|
185
|
+
return _gasOracle.getExchangeRateAndGasPrice(_destinationDomain);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ============ Internal Functions ============
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @notice Sets the beneficiary.
|
|
192
|
+
* @param _beneficiary The new beneficiary.
|
|
193
|
+
*/
|
|
194
|
+
function _setBeneficiary(address _beneficiary) internal {
|
|
195
|
+
beneficiary = _beneficiary;
|
|
196
|
+
emit BeneficiarySet(_beneficiary);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @notice Sets the gas oracle for a remote domain.
|
|
201
|
+
* @param _remoteDomain The remote domain.
|
|
202
|
+
* @param _gasOracle The gas oracle.
|
|
203
|
+
*/
|
|
204
|
+
function _setGasOracle(uint32 _remoteDomain, address _gasOracle) internal {
|
|
205
|
+
gasOracles[_remoteDomain] = IGasOracle(_gasOracle);
|
|
206
|
+
emit GasOracleSet(_remoteDomain, _gasOracle);
|
|
103
207
|
}
|
|
104
208
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
// ============ Internal Imports ============
|
|
5
|
+
import {IGasOracle} from "../../../interfaces/IGasOracle.sol";
|
|
6
|
+
// ============ External Imports ============
|
|
7
|
+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @notice A gas oracle that uses data stored within the contract.
|
|
11
|
+
* @dev This contract is intended to be owned by an address that will
|
|
12
|
+
* update the stored remote gas data.
|
|
13
|
+
*/
|
|
14
|
+
contract StorageGasOracle is IGasOracle, Ownable {
|
|
15
|
+
// ============ Public Storage ============
|
|
16
|
+
|
|
17
|
+
/// @notice Keyed by remote domain, gas data on that remote domain.
|
|
18
|
+
mapping(uint32 => IGasOracle.RemoteGasData) public remoteGasData;
|
|
19
|
+
|
|
20
|
+
// ============ Events ============
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @notice Emitted when an entry in `remoteGasData` is set.
|
|
24
|
+
* @param remoteDomain The remote domain in which the gas data was set for.
|
|
25
|
+
* @param tokenExchangeRate The exchange rate of the remote native token quoted in the local native token.
|
|
26
|
+
* @param gasPrice The gas price on the remote chain.
|
|
27
|
+
*/
|
|
28
|
+
event RemoteGasDataSet(
|
|
29
|
+
uint32 indexed remoteDomain,
|
|
30
|
+
uint128 tokenExchangeRate,
|
|
31
|
+
uint128 gasPrice
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
struct RemoteGasDataConfig {
|
|
35
|
+
uint32 remoteDomain;
|
|
36
|
+
uint128 tokenExchangeRate;
|
|
37
|
+
uint128 gasPrice;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ============ External Functions ============
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @notice Returns the stored `remoteGasData` for the `_destinationDomain`.
|
|
44
|
+
* @param _destinationDomain The destination domain.
|
|
45
|
+
* @return tokenExchangeRate The exchange rate of the remote native token quoted in the local native token.
|
|
46
|
+
* @return gasPrice The gas price on the remote chain.
|
|
47
|
+
*/
|
|
48
|
+
function getExchangeRateAndGasPrice(uint32 _destinationDomain)
|
|
49
|
+
external
|
|
50
|
+
view
|
|
51
|
+
override
|
|
52
|
+
returns (uint128 tokenExchangeRate, uint128 gasPrice)
|
|
53
|
+
{
|
|
54
|
+
// Intentionally allow unset / zero values
|
|
55
|
+
IGasOracle.RemoteGasData memory _data = remoteGasData[
|
|
56
|
+
_destinationDomain
|
|
57
|
+
];
|
|
58
|
+
return (_data.tokenExchangeRate, _data.gasPrice);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @notice Sets the remote gas data for many remotes at a time.
|
|
63
|
+
* @param _configs The configs to use when setting the remote gas data.
|
|
64
|
+
*/
|
|
65
|
+
function setRemoteGasDataConfigs(RemoteGasDataConfig[] calldata _configs)
|
|
66
|
+
external
|
|
67
|
+
onlyOwner
|
|
68
|
+
{
|
|
69
|
+
uint256 _len = _configs.length;
|
|
70
|
+
for (uint256 i = 0; i < _len; i++) {
|
|
71
|
+
_setRemoteGasData(_configs[i]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @notice Sets the remote gas data using the values in `_config`.
|
|
77
|
+
* @param _config The config to use when setting the remote gas data.
|
|
78
|
+
*/
|
|
79
|
+
function setRemoteGasData(RemoteGasDataConfig calldata _config)
|
|
80
|
+
external
|
|
81
|
+
onlyOwner
|
|
82
|
+
{
|
|
83
|
+
_setRemoteGasData(_config);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ============ Internal functions ============
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @notice Sets the remote gas data using the values in `_config`.
|
|
90
|
+
* @param _config The config to use when setting the remote gas data.
|
|
91
|
+
*/
|
|
92
|
+
function _setRemoteGasData(RemoteGasDataConfig calldata _config) internal {
|
|
93
|
+
remoteGasData[_config.remoteDomain] = IGasOracle.RemoteGasData({
|
|
94
|
+
tokenExchangeRate: _config.tokenExchangeRate,
|
|
95
|
+
gasPrice: _config.gasPrice
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
emit RemoteGasDataSet(
|
|
99
|
+
_config.remoteDomain,
|
|
100
|
+
_config.tokenExchangeRate,
|
|
101
|
+
_config.gasPrice
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -27,8 +27,8 @@ contract MockHyperlaneEnvironment {
|
|
|
27
27
|
originMailbox.addRemoteMailbox(_destinationDomain, destinationMailbox);
|
|
28
28
|
destinationMailbox.addRemoteMailbox(_originDomain, originMailbox);
|
|
29
29
|
|
|
30
|
-
igps[originDomain] = new TestInterchainGasPaymaster();
|
|
31
|
-
igps[destinationDomain] = new TestInterchainGasPaymaster();
|
|
30
|
+
igps[originDomain] = new TestInterchainGasPaymaster(address(this));
|
|
31
|
+
igps[destinationDomain] = new TestInterchainGasPaymaster(address(this));
|
|
32
32
|
|
|
33
33
|
isms[originDomain] = new TestIsm();
|
|
34
34
|
isms[destinationDomain] = new TestIsm();
|
|
@@ -5,15 +5,14 @@ pragma solidity >=0.8.0;
|
|
|
5
5
|
import {InterchainGasPaymaster} from "../igps/InterchainGasPaymaster.sol";
|
|
6
6
|
|
|
7
7
|
contract TestInterchainGasPaymaster is InterchainGasPaymaster {
|
|
8
|
-
uint256 gasPrice =
|
|
8
|
+
uint256 public constant gasPrice = 10;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
10
|
+
// Ensure the same constructor interface as the inherited InterchainGasPaymaster
|
|
11
|
+
constructor(address _beneficiary) InterchainGasPaymaster(_beneficiary) {}
|
|
13
12
|
|
|
14
13
|
function quoteGasPayment(uint32, uint256 gasAmount)
|
|
15
14
|
public
|
|
16
|
-
|
|
15
|
+
pure
|
|
17
16
|
override
|
|
18
17
|
returns (uint256)
|
|
19
18
|
{
|
|
@@ -2,40 +2,85 @@ import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from "../..
|
|
|
2
2
|
import type { FunctionFragment, Result, EventFragment } from "@ethersproject/abi";
|
|
3
3
|
import type { Listener, Provider } from "@ethersproject/providers";
|
|
4
4
|
import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, PayableOverrides, PopulatedTransaction, Signer, utils } from "ethers";
|
|
5
|
+
export declare namespace InterchainGasPaymaster {
|
|
6
|
+
type GasOracleConfigStruct = {
|
|
7
|
+
remoteDomain: BigNumberish;
|
|
8
|
+
gasOracle: string;
|
|
9
|
+
};
|
|
10
|
+
type GasOracleConfigStructOutput = [number, string] & {
|
|
11
|
+
remoteDomain: number;
|
|
12
|
+
gasOracle: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
5
15
|
export interface InterchainGasPaymasterInterface extends utils.Interface {
|
|
6
16
|
functions: {
|
|
17
|
+
"beneficiary()": FunctionFragment;
|
|
7
18
|
"claim()": FunctionFragment;
|
|
8
|
-
"
|
|
19
|
+
"gasOracles(uint32)": FunctionFragment;
|
|
20
|
+
"getExchangeRateAndGasPrice(uint32)": FunctionFragment;
|
|
21
|
+
"initialize(address,address)": FunctionFragment;
|
|
9
22
|
"owner()": FunctionFragment;
|
|
10
23
|
"payForGas(bytes32,uint32,uint256,address)": FunctionFragment;
|
|
11
24
|
"quoteGasPayment(uint32,uint256)": FunctionFragment;
|
|
12
25
|
"renounceOwnership()": FunctionFragment;
|
|
26
|
+
"setBeneficiary(address)": FunctionFragment;
|
|
27
|
+
"setGasOracles((uint32,address)[])": FunctionFragment;
|
|
13
28
|
"transferOwnership(address)": FunctionFragment;
|
|
14
29
|
};
|
|
15
|
-
getFunction(nameOrSignatureOrTopic: "claim" | "initialize" | "owner" | "payForGas" | "quoteGasPayment" | "renounceOwnership" | "transferOwnership"): FunctionFragment;
|
|
30
|
+
getFunction(nameOrSignatureOrTopic: "beneficiary" | "claim" | "gasOracles" | "getExchangeRateAndGasPrice" | "initialize" | "owner" | "payForGas" | "quoteGasPayment" | "renounceOwnership" | "setBeneficiary" | "setGasOracles" | "transferOwnership"): FunctionFragment;
|
|
31
|
+
encodeFunctionData(functionFragment: "beneficiary", values?: undefined): string;
|
|
16
32
|
encodeFunctionData(functionFragment: "claim", values?: undefined): string;
|
|
17
|
-
encodeFunctionData(functionFragment: "
|
|
33
|
+
encodeFunctionData(functionFragment: "gasOracles", values: [BigNumberish]): string;
|
|
34
|
+
encodeFunctionData(functionFragment: "getExchangeRateAndGasPrice", values: [BigNumberish]): string;
|
|
35
|
+
encodeFunctionData(functionFragment: "initialize", values: [string, string]): string;
|
|
18
36
|
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
|
19
37
|
encodeFunctionData(functionFragment: "payForGas", values: [BytesLike, BigNumberish, BigNumberish, string]): string;
|
|
20
38
|
encodeFunctionData(functionFragment: "quoteGasPayment", values: [BigNumberish, BigNumberish]): string;
|
|
21
39
|
encodeFunctionData(functionFragment: "renounceOwnership", values?: undefined): string;
|
|
40
|
+
encodeFunctionData(functionFragment: "setBeneficiary", values: [string]): string;
|
|
41
|
+
encodeFunctionData(functionFragment: "setGasOracles", values: [InterchainGasPaymaster.GasOracleConfigStruct[]]): string;
|
|
22
42
|
encodeFunctionData(functionFragment: "transferOwnership", values: [string]): string;
|
|
43
|
+
decodeFunctionResult(functionFragment: "beneficiary", data: BytesLike): Result;
|
|
23
44
|
decodeFunctionResult(functionFragment: "claim", data: BytesLike): Result;
|
|
45
|
+
decodeFunctionResult(functionFragment: "gasOracles", data: BytesLike): Result;
|
|
46
|
+
decodeFunctionResult(functionFragment: "getExchangeRateAndGasPrice", data: BytesLike): Result;
|
|
24
47
|
decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result;
|
|
25
48
|
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
|
26
49
|
decodeFunctionResult(functionFragment: "payForGas", data: BytesLike): Result;
|
|
27
50
|
decodeFunctionResult(functionFragment: "quoteGasPayment", data: BytesLike): Result;
|
|
28
51
|
decodeFunctionResult(functionFragment: "renounceOwnership", data: BytesLike): Result;
|
|
52
|
+
decodeFunctionResult(functionFragment: "setBeneficiary", data: BytesLike): Result;
|
|
53
|
+
decodeFunctionResult(functionFragment: "setGasOracles", data: BytesLike): Result;
|
|
29
54
|
decodeFunctionResult(functionFragment: "transferOwnership", data: BytesLike): Result;
|
|
30
55
|
events: {
|
|
56
|
+
"BeneficiarySet(address)": EventFragment;
|
|
57
|
+
"GasOracleSet(uint32,address)": EventFragment;
|
|
31
58
|
"GasPayment(bytes32,uint256,uint256)": EventFragment;
|
|
32
59
|
"Initialized(uint8)": EventFragment;
|
|
33
60
|
"OwnershipTransferred(address,address)": EventFragment;
|
|
34
61
|
};
|
|
62
|
+
getEvent(nameOrSignatureOrTopic: "BeneficiarySet"): EventFragment;
|
|
63
|
+
getEvent(nameOrSignatureOrTopic: "GasOracleSet"): EventFragment;
|
|
35
64
|
getEvent(nameOrSignatureOrTopic: "GasPayment"): EventFragment;
|
|
36
65
|
getEvent(nameOrSignatureOrTopic: "Initialized"): EventFragment;
|
|
37
66
|
getEvent(nameOrSignatureOrTopic: "OwnershipTransferred"): EventFragment;
|
|
38
67
|
}
|
|
68
|
+
export interface BeneficiarySetEventObject {
|
|
69
|
+
beneficiary: string;
|
|
70
|
+
}
|
|
71
|
+
export declare type BeneficiarySetEvent = TypedEvent<[
|
|
72
|
+
string
|
|
73
|
+
], BeneficiarySetEventObject>;
|
|
74
|
+
export declare type BeneficiarySetEventFilter = TypedEventFilter<BeneficiarySetEvent>;
|
|
75
|
+
export interface GasOracleSetEventObject {
|
|
76
|
+
remoteDomain: number;
|
|
77
|
+
gasOracle: string;
|
|
78
|
+
}
|
|
79
|
+
export declare type GasOracleSetEvent = TypedEvent<[
|
|
80
|
+
number,
|
|
81
|
+
string
|
|
82
|
+
], GasOracleSetEventObject>;
|
|
83
|
+
export declare type GasOracleSetEventFilter = TypedEventFilter<GasOracleSetEvent>;
|
|
39
84
|
export interface GasPaymentEventObject {
|
|
40
85
|
messageId: string;
|
|
41
86
|
gasAmount: BigNumber;
|
|
@@ -76,10 +121,19 @@ export interface InterchainGasPaymaster extends BaseContract {
|
|
|
76
121
|
once: OnEvent<this>;
|
|
77
122
|
removeListener: OnEvent<this>;
|
|
78
123
|
functions: {
|
|
124
|
+
beneficiary(overrides?: CallOverrides): Promise<[string]>;
|
|
79
125
|
claim(overrides?: Overrides & {
|
|
80
126
|
from?: string | Promise<string>;
|
|
81
127
|
}): Promise<ContractTransaction>;
|
|
82
|
-
|
|
128
|
+
gasOracles(arg0: BigNumberish, overrides?: CallOverrides): Promise<[string]>;
|
|
129
|
+
getExchangeRateAndGasPrice(_destinationDomain: BigNumberish, overrides?: CallOverrides): Promise<[
|
|
130
|
+
BigNumber,
|
|
131
|
+
BigNumber
|
|
132
|
+
] & {
|
|
133
|
+
tokenExchangeRate: BigNumber;
|
|
134
|
+
gasPrice: BigNumber;
|
|
135
|
+
}>;
|
|
136
|
+
initialize(_owner: string, _beneficiary: string, overrides?: Overrides & {
|
|
83
137
|
from?: string | Promise<string>;
|
|
84
138
|
}): Promise<ContractTransaction>;
|
|
85
139
|
owner(overrides?: CallOverrides): Promise<[string]>;
|
|
@@ -90,14 +144,29 @@ export interface InterchainGasPaymaster extends BaseContract {
|
|
|
90
144
|
renounceOwnership(overrides?: Overrides & {
|
|
91
145
|
from?: string | Promise<string>;
|
|
92
146
|
}): Promise<ContractTransaction>;
|
|
147
|
+
setBeneficiary(_beneficiary: string, overrides?: Overrides & {
|
|
148
|
+
from?: string | Promise<string>;
|
|
149
|
+
}): Promise<ContractTransaction>;
|
|
150
|
+
setGasOracles(_configs: InterchainGasPaymaster.GasOracleConfigStruct[], overrides?: Overrides & {
|
|
151
|
+
from?: string | Promise<string>;
|
|
152
|
+
}): Promise<ContractTransaction>;
|
|
93
153
|
transferOwnership(newOwner: string, overrides?: Overrides & {
|
|
94
154
|
from?: string | Promise<string>;
|
|
95
155
|
}): Promise<ContractTransaction>;
|
|
96
156
|
};
|
|
157
|
+
beneficiary(overrides?: CallOverrides): Promise<string>;
|
|
97
158
|
claim(overrides?: Overrides & {
|
|
98
159
|
from?: string | Promise<string>;
|
|
99
160
|
}): Promise<ContractTransaction>;
|
|
100
|
-
|
|
161
|
+
gasOracles(arg0: BigNumberish, overrides?: CallOverrides): Promise<string>;
|
|
162
|
+
getExchangeRateAndGasPrice(_destinationDomain: BigNumberish, overrides?: CallOverrides): Promise<[
|
|
163
|
+
BigNumber,
|
|
164
|
+
BigNumber
|
|
165
|
+
] & {
|
|
166
|
+
tokenExchangeRate: BigNumber;
|
|
167
|
+
gasPrice: BigNumber;
|
|
168
|
+
}>;
|
|
169
|
+
initialize(_owner: string, _beneficiary: string, overrides?: Overrides & {
|
|
101
170
|
from?: string | Promise<string>;
|
|
102
171
|
}): Promise<ContractTransaction>;
|
|
103
172
|
owner(overrides?: CallOverrides): Promise<string>;
|
|
@@ -108,19 +177,40 @@ export interface InterchainGasPaymaster extends BaseContract {
|
|
|
108
177
|
renounceOwnership(overrides?: Overrides & {
|
|
109
178
|
from?: string | Promise<string>;
|
|
110
179
|
}): Promise<ContractTransaction>;
|
|
180
|
+
setBeneficiary(_beneficiary: string, overrides?: Overrides & {
|
|
181
|
+
from?: string | Promise<string>;
|
|
182
|
+
}): Promise<ContractTransaction>;
|
|
183
|
+
setGasOracles(_configs: InterchainGasPaymaster.GasOracleConfigStruct[], overrides?: Overrides & {
|
|
184
|
+
from?: string | Promise<string>;
|
|
185
|
+
}): Promise<ContractTransaction>;
|
|
111
186
|
transferOwnership(newOwner: string, overrides?: Overrides & {
|
|
112
187
|
from?: string | Promise<string>;
|
|
113
188
|
}): Promise<ContractTransaction>;
|
|
114
189
|
callStatic: {
|
|
190
|
+
beneficiary(overrides?: CallOverrides): Promise<string>;
|
|
115
191
|
claim(overrides?: CallOverrides): Promise<void>;
|
|
116
|
-
|
|
192
|
+
gasOracles(arg0: BigNumberish, overrides?: CallOverrides): Promise<string>;
|
|
193
|
+
getExchangeRateAndGasPrice(_destinationDomain: BigNumberish, overrides?: CallOverrides): Promise<[
|
|
194
|
+
BigNumber,
|
|
195
|
+
BigNumber
|
|
196
|
+
] & {
|
|
197
|
+
tokenExchangeRate: BigNumber;
|
|
198
|
+
gasPrice: BigNumber;
|
|
199
|
+
}>;
|
|
200
|
+
initialize(_owner: string, _beneficiary: string, overrides?: CallOverrides): Promise<void>;
|
|
117
201
|
owner(overrides?: CallOverrides): Promise<string>;
|
|
118
202
|
payForGas(_messageId: BytesLike, _destinationDomain: BigNumberish, _gasAmount: BigNumberish, _refundAddress: string, overrides?: CallOverrides): Promise<void>;
|
|
119
203
|
quoteGasPayment(_destinationDomain: BigNumberish, _gasAmount: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
|
|
120
204
|
renounceOwnership(overrides?: CallOverrides): Promise<void>;
|
|
205
|
+
setBeneficiary(_beneficiary: string, overrides?: CallOverrides): Promise<void>;
|
|
206
|
+
setGasOracles(_configs: InterchainGasPaymaster.GasOracleConfigStruct[], overrides?: CallOverrides): Promise<void>;
|
|
121
207
|
transferOwnership(newOwner: string, overrides?: CallOverrides): Promise<void>;
|
|
122
208
|
};
|
|
123
209
|
filters: {
|
|
210
|
+
"BeneficiarySet(address)"(beneficiary?: null): BeneficiarySetEventFilter;
|
|
211
|
+
BeneficiarySet(beneficiary?: null): BeneficiarySetEventFilter;
|
|
212
|
+
"GasOracleSet(uint32,address)"(remoteDomain?: BigNumberish | null, gasOracle?: null): GasOracleSetEventFilter;
|
|
213
|
+
GasOracleSet(remoteDomain?: BigNumberish | null, gasOracle?: null): GasOracleSetEventFilter;
|
|
124
214
|
"GasPayment(bytes32,uint256,uint256)"(messageId?: BytesLike | null, gasAmount?: null, payment?: null): GasPaymentEventFilter;
|
|
125
215
|
GasPayment(messageId?: BytesLike | null, gasAmount?: null, payment?: null): GasPaymentEventFilter;
|
|
126
216
|
"Initialized(uint8)"(version?: null): InitializedEventFilter;
|
|
@@ -129,10 +219,13 @@ export interface InterchainGasPaymaster extends BaseContract {
|
|
|
129
219
|
OwnershipTransferred(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter;
|
|
130
220
|
};
|
|
131
221
|
estimateGas: {
|
|
222
|
+
beneficiary(overrides?: CallOverrides): Promise<BigNumber>;
|
|
132
223
|
claim(overrides?: Overrides & {
|
|
133
224
|
from?: string | Promise<string>;
|
|
134
225
|
}): Promise<BigNumber>;
|
|
135
|
-
|
|
226
|
+
gasOracles(arg0: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
|
|
227
|
+
getExchangeRateAndGasPrice(_destinationDomain: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
|
|
228
|
+
initialize(_owner: string, _beneficiary: string, overrides?: Overrides & {
|
|
136
229
|
from?: string | Promise<string>;
|
|
137
230
|
}): Promise<BigNumber>;
|
|
138
231
|
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
|
@@ -143,15 +236,24 @@ export interface InterchainGasPaymaster extends BaseContract {
|
|
|
143
236
|
renounceOwnership(overrides?: Overrides & {
|
|
144
237
|
from?: string | Promise<string>;
|
|
145
238
|
}): Promise<BigNumber>;
|
|
239
|
+
setBeneficiary(_beneficiary: string, overrides?: Overrides & {
|
|
240
|
+
from?: string | Promise<string>;
|
|
241
|
+
}): Promise<BigNumber>;
|
|
242
|
+
setGasOracles(_configs: InterchainGasPaymaster.GasOracleConfigStruct[], overrides?: Overrides & {
|
|
243
|
+
from?: string | Promise<string>;
|
|
244
|
+
}): Promise<BigNumber>;
|
|
146
245
|
transferOwnership(newOwner: string, overrides?: Overrides & {
|
|
147
246
|
from?: string | Promise<string>;
|
|
148
247
|
}): Promise<BigNumber>;
|
|
149
248
|
};
|
|
150
249
|
populateTransaction: {
|
|
250
|
+
beneficiary(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
151
251
|
claim(overrides?: Overrides & {
|
|
152
252
|
from?: string | Promise<string>;
|
|
153
253
|
}): Promise<PopulatedTransaction>;
|
|
154
|
-
|
|
254
|
+
gasOracles(arg0: BigNumberish, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
255
|
+
getExchangeRateAndGasPrice(_destinationDomain: BigNumberish, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
256
|
+
initialize(_owner: string, _beneficiary: string, overrides?: Overrides & {
|
|
155
257
|
from?: string | Promise<string>;
|
|
156
258
|
}): Promise<PopulatedTransaction>;
|
|
157
259
|
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
@@ -162,6 +264,12 @@ export interface InterchainGasPaymaster extends BaseContract {
|
|
|
162
264
|
renounceOwnership(overrides?: Overrides & {
|
|
163
265
|
from?: string | Promise<string>;
|
|
164
266
|
}): Promise<PopulatedTransaction>;
|
|
267
|
+
setBeneficiary(_beneficiary: string, overrides?: Overrides & {
|
|
268
|
+
from?: string | Promise<string>;
|
|
269
|
+
}): Promise<PopulatedTransaction>;
|
|
270
|
+
setGasOracles(_configs: InterchainGasPaymaster.GasOracleConfigStruct[], overrides?: Overrides & {
|
|
271
|
+
from?: string | Promise<string>;
|
|
272
|
+
}): Promise<PopulatedTransaction>;
|
|
165
273
|
transferOwnership(newOwner: string, overrides?: Overrides & {
|
|
166
274
|
from?: string | Promise<string>;
|
|
167
275
|
}): Promise<PopulatedTransaction>;
|