@hyperlane-xyz/core 4.0.0-beta → 4.0.0-beta2
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/client/GasRouter.sol +34 -4
- package/contracts/client/MailboxClient.sol +0 -81
- package/contracts/client/Router.sol +55 -10
- package/contracts/test/ERC20Test.sol +54 -6
- package/contracts/test/TestGasRouter.sol +1 -1
- package/contracts/token/HypNative.sol +4 -12
- package/contracts/token/README.md +2 -2
- package/contracts/token/extensions/HypNativeScaled.sol +5 -7
- package/contracts/token/extensions/HypXERC20.sol +3 -1
- package/contracts/token/extensions/HypXERC20Lockbox.sol +25 -3
- package/contracts/token/interfaces/IXERC20.sol +18 -0
- package/contracts/token/libs/FastTokenRouter.sol +4 -2
- package/contracts/token/libs/TokenRouter.sol +32 -39
- package/dist/buildArtifact.js +1 -1
- package/dist/buildArtifact.json +1 -1
- package/dist/contracts/client/GasRouter.d.ts +2 -6
- package/dist/contracts/client/GasRouter.d.ts.map +1 -1
- package/dist/contracts/test/ERC20Test.sol/XERC20LockboxTest.d.ts +220 -0
- package/dist/contracts/test/ERC20Test.sol/XERC20LockboxTest.d.ts.map +1 -0
- package/dist/contracts/test/ERC20Test.sol/XERC20LockboxTest.js +2 -0
- package/dist/contracts/test/ERC20Test.sol/XERC20LockboxTest.js.map +1 -0
- package/dist/contracts/test/ERC20Test.sol/XERC20Test.d.ts +31 -1
- package/dist/contracts/test/ERC20Test.sol/XERC20Test.d.ts.map +1 -1
- package/dist/contracts/test/ERC20Test.sol/index.d.ts +1 -0
- package/dist/contracts/test/ERC20Test.sol/index.d.ts.map +1 -1
- package/dist/contracts/test/TestGasRouter.d.ts +2 -6
- package/dist/contracts/test/TestGasRouter.d.ts.map +1 -1
- package/dist/contracts/token/HypERC20.d.ts +2 -6
- package/dist/contracts/token/HypERC20.d.ts.map +1 -1
- package/dist/contracts/token/HypERC20Collateral.d.ts +2 -6
- package/dist/contracts/token/HypERC20Collateral.d.ts.map +1 -1
- package/dist/contracts/token/HypERC721.d.ts +2 -6
- package/dist/contracts/token/HypERC721.d.ts.map +1 -1
- package/dist/contracts/token/HypERC721Collateral.d.ts +2 -6
- package/dist/contracts/token/HypERC721Collateral.d.ts.map +1 -1
- package/dist/contracts/token/HypNative.d.ts +2 -6
- package/dist/contracts/token/HypNative.d.ts.map +1 -1
- package/dist/contracts/token/extensions/FastHypERC20.d.ts +2 -6
- package/dist/contracts/token/extensions/FastHypERC20.d.ts.map +1 -1
- package/dist/contracts/token/extensions/FastHypERC20Collateral.d.ts +2 -6
- package/dist/contracts/token/extensions/FastHypERC20Collateral.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypERC20CollateralVaultDeposit.d.ts +2 -6
- package/dist/contracts/token/extensions/HypERC20CollateralVaultDeposit.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypERC721URICollateral.d.ts +2 -6
- package/dist/contracts/token/extensions/HypERC721URICollateral.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypERC721URIStorage.d.ts +2 -6
- package/dist/contracts/token/extensions/HypERC721URIStorage.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypFiatToken.d.ts +2 -6
- package/dist/contracts/token/extensions/HypFiatToken.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypNativeScaled.d.ts +2 -6
- package/dist/contracts/token/extensions/HypNativeScaled.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypXERC20.d.ts +2 -6
- package/dist/contracts/token/extensions/HypXERC20.d.ts.map +1 -1
- package/dist/contracts/token/extensions/HypXERC20Lockbox.d.ts +44 -17
- package/dist/contracts/token/extensions/HypXERC20Lockbox.d.ts.map +1 -1
- package/dist/contracts/token/interfaces/IXERC20.d.ts +39 -1
- package/dist/contracts/token/interfaces/IXERC20.d.ts.map +1 -1
- package/dist/contracts/token/libs/FastTokenRouter.d.ts +2 -6
- package/dist/contracts/token/libs/FastTokenRouter.d.ts.map +1 -1
- package/dist/contracts/token/libs/TokenRouter.d.ts +2 -6
- package/dist/contracts/token/libs/TokenRouter.d.ts.map +1 -1
- package/dist/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.d.ts +1 -1
- package/dist/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.js +1 -1
- package/dist/factories/contracts/client/GasRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/client/GasRouter__factory.js +1 -1
- package/dist/factories/contracts/client/GasRouter__factory.js.map +1 -1
- package/dist/factories/contracts/hooks/MerkleTreeHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/MerkleTreeHook__factory.js +1 -1
- package/dist/factories/contracts/hooks/OPStackHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/OPStackHook__factory.js +1 -1
- package/dist/factories/contracts/hooks/PolygonPosHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/PolygonPosHook__factory.js +1 -1
- package/dist/factories/contracts/hooks/aggregation/ERC5164Hook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/aggregation/ERC5164Hook__factory.js +1 -1
- package/dist/factories/contracts/hooks/layer-zero/LayerZeroV1Hook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/layer-zero/LayerZeroV1Hook__factory.js +1 -1
- package/dist/factories/contracts/hooks/layer-zero/LayerZeroV2Hook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/layer-zero/LayerZeroV2Hook__factory.js +1 -1
- package/dist/factories/contracts/hooks/routing/DestinationRecipientRoutingHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/routing/DestinationRecipientRoutingHook__factory.js +1 -1
- package/dist/factories/contracts/hooks/routing/DomainRoutingHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/routing/DomainRoutingHook__factory.js +1 -1
- package/dist/factories/contracts/hooks/routing/FallbackDomainRoutingHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/routing/FallbackDomainRoutingHook__factory.js +1 -1
- package/dist/factories/contracts/hooks/warp-route/RateLimitedHook__factory.d.ts +1 -1
- package/dist/factories/contracts/hooks/warp-route/RateLimitedHook__factory.js +1 -1
- package/dist/factories/contracts/isms/multisig/ValidatorAnnounce__factory.d.ts +1 -1
- package/dist/factories/contracts/isms/multisig/ValidatorAnnounce__factory.js +1 -1
- package/dist/factories/contracts/isms/routing/DefaultFallbackRoutingIsm__factory.d.ts +1 -1
- package/dist/factories/contracts/isms/routing/DefaultFallbackRoutingIsm__factory.js +1 -1
- package/dist/factories/contracts/isms/routing/DomainRoutingIsmFactory.sol/DomainRoutingIsmFactory__factory.d.ts +1 -1
- package/dist/factories/contracts/isms/routing/DomainRoutingIsmFactory.sol/DomainRoutingIsmFactory__factory.js +1 -1
- package/dist/factories/contracts/isms/warp-route/RateLimitedIsm__factory.d.ts +1 -1
- package/dist/factories/contracts/isms/warp-route/RateLimitedIsm__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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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.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/test/ERC20Test.sol/ERC20Test__factory.d.ts +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/ERC20Test__factory.js +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/FiatTokenTest__factory.d.ts +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/FiatTokenTest__factory.js +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20LockboxTest__factory.d.ts +119 -0
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20LockboxTest__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20LockboxTest__factory.js +166 -0
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20LockboxTest__factory.js.map +1 -0
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20Test__factory.d.ts +29 -1
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20Test__factory.d.ts.map +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20Test__factory.js +39 -1
- package/dist/factories/contracts/test/ERC20Test.sol/XERC20Test__factory.js.map +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/index.d.ts +1 -0
- package/dist/factories/contracts/test/ERC20Test.sol/index.d.ts.map +1 -1
- package/dist/factories/contracts/test/ERC20Test.sol/index.js +1 -0
- package/dist/factories/contracts/test/ERC20Test.sol/index.js.map +1 -1
- package/dist/factories/contracts/test/TestGasRouter__factory.d.ts +2 -2
- package/dist/factories/contracts/test/TestGasRouter__factory.d.ts.map +1 -1
- package/dist/factories/contracts/test/TestGasRouter__factory.js +2 -2
- package/dist/factories/contracts/test/TestGasRouter__factory.js.map +1 -1
- package/dist/factories/contracts/test/TestMerkleTreeHook__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestMerkleTreeHook__factory.js +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.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/factories/contracts/test/TestSendReceiver__factory.d.ts +1 -1
- package/dist/factories/contracts/test/TestSendReceiver__factory.js +1 -1
- package/dist/factories/contracts/token/HypERC20Collateral__factory.d.ts +2 -2
- package/dist/factories/contracts/token/HypERC20Collateral__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/HypERC20Collateral__factory.js +2 -2
- package/dist/factories/contracts/token/HypERC20Collateral__factory.js.map +1 -1
- package/dist/factories/contracts/token/HypERC20__factory.d.ts +2 -2
- package/dist/factories/contracts/token/HypERC20__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/HypERC20__factory.js +2 -2
- package/dist/factories/contracts/token/HypERC20__factory.js.map +1 -1
- package/dist/factories/contracts/token/HypERC721Collateral__factory.d.ts +2 -2
- package/dist/factories/contracts/token/HypERC721Collateral__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/HypERC721Collateral__factory.js +2 -2
- package/dist/factories/contracts/token/HypERC721Collateral__factory.js.map +1 -1
- package/dist/factories/contracts/token/HypERC721__factory.d.ts +2 -2
- package/dist/factories/contracts/token/HypERC721__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/HypERC721__factory.js +2 -2
- package/dist/factories/contracts/token/HypERC721__factory.js.map +1 -1
- package/dist/factories/contracts/token/HypNative__factory.d.ts +2 -2
- package/dist/factories/contracts/token/HypNative__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/HypNative__factory.js +2 -2
- package/dist/factories/contracts/token/HypNative__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/FastHypERC20Collateral__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/FastHypERC20Collateral__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/FastHypERC20Collateral__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/FastHypERC20Collateral__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/FastHypERC20__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/FastHypERC20__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/FastHypERC20__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/FastHypERC20__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypERC20CollateralVaultDeposit__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/HypERC20CollateralVaultDeposit__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypERC20CollateralVaultDeposit__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/HypERC20CollateralVaultDeposit__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypERC721URICollateral__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/HypERC721URICollateral__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypERC721URICollateral__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/HypERC721URICollateral__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypERC721URIStorage__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/HypERC721URIStorage__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypERC721URIStorage__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/HypERC721URIStorage__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypFiatToken__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/HypFiatToken__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypFiatToken__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/HypFiatToken__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypNativeScaled__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/HypNativeScaled__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypNativeScaled__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/HypNativeScaled__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypXERC20Lockbox__factory.d.ts +9 -3
- package/dist/factories/contracts/token/extensions/HypXERC20Lockbox__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypXERC20Lockbox__factory.js +10 -3
- package/dist/factories/contracts/token/extensions/HypXERC20Lockbox__factory.js.map +1 -1
- package/dist/factories/contracts/token/extensions/HypXERC20__factory.d.ts +2 -2
- package/dist/factories/contracts/token/extensions/HypXERC20__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/extensions/HypXERC20__factory.js +2 -2
- package/dist/factories/contracts/token/extensions/HypXERC20__factory.js.map +1 -1
- package/dist/factories/contracts/token/interfaces/IXERC20__factory.d.ts +28 -0
- package/dist/factories/contracts/token/interfaces/IXERC20__factory.d.ts.map +1 -1
- package/dist/factories/contracts/token/interfaces/IXERC20__factory.js +38 -0
- package/dist/factories/contracts/token/interfaces/IXERC20__factory.js.map +1 -1
- package/dist/factories/contracts/token/libs/FastTokenRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/token/libs/FastTokenRouter__factory.js +1 -1
- package/dist/factories/contracts/token/libs/FastTokenRouter__factory.js.map +1 -1
- package/dist/factories/contracts/token/libs/TokenRouter__factory.d.ts +1 -1
- package/dist/factories/contracts/token/libs/TokenRouter__factory.js +1 -1
- package/dist/factories/contracts/token/libs/TokenRouter__factory.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
|
@@ -43,13 +43,13 @@ abstract contract GasRouter is Router {
|
|
|
43
43
|
*/
|
|
44
44
|
function quoteGasPayment(
|
|
45
45
|
uint32 _destinationDomain
|
|
46
|
-
) external view returns (uint256
|
|
47
|
-
return
|
|
46
|
+
) external view returns (uint256) {
|
|
47
|
+
return _GasRouter_quoteDispatch(_destinationDomain, "", address(hook));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function
|
|
50
|
+
function _GasRouter_hookMetadata(
|
|
51
51
|
uint32 _destination
|
|
52
|
-
) internal view
|
|
52
|
+
) internal view returns (bytes memory) {
|
|
53
53
|
return
|
|
54
54
|
StandardHookMetadata.overrideGasLimit(destinationGas[_destination]);
|
|
55
55
|
}
|
|
@@ -57,4 +57,34 @@ abstract contract GasRouter is Router {
|
|
|
57
57
|
function _setDestinationGas(uint32 domain, uint256 gas) internal {
|
|
58
58
|
destinationGas[domain] = gas;
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
function _GasRouter_dispatch(
|
|
62
|
+
uint32 _destination,
|
|
63
|
+
uint256 _value,
|
|
64
|
+
bytes memory _messageBody,
|
|
65
|
+
address _hook
|
|
66
|
+
) internal returns (bytes32) {
|
|
67
|
+
return
|
|
68
|
+
_Router_dispatch(
|
|
69
|
+
_destination,
|
|
70
|
+
_value,
|
|
71
|
+
_messageBody,
|
|
72
|
+
_GasRouter_hookMetadata(_destination),
|
|
73
|
+
_hook
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _GasRouter_quoteDispatch(
|
|
78
|
+
uint32 _destination,
|
|
79
|
+
bytes memory _messageBody,
|
|
80
|
+
address _hook
|
|
81
|
+
) internal view returns (uint256) {
|
|
82
|
+
return
|
|
83
|
+
_Router_quoteDispatch(
|
|
84
|
+
_destination,
|
|
85
|
+
_messageBody,
|
|
86
|
+
_GasRouter_hookMetadata(_destination),
|
|
87
|
+
_hook
|
|
88
|
+
);
|
|
89
|
+
}
|
|
60
90
|
}
|
|
@@ -95,85 +95,4 @@ abstract contract MailboxClient is OwnableUpgradeable {
|
|
|
95
95
|
function _isDelivered(bytes32 id) internal view returns (bool) {
|
|
96
96
|
return mailbox.delivered(id);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
function _metadata(
|
|
100
|
-
uint32 /*_destinationDomain*/
|
|
101
|
-
) internal view virtual returns (bytes memory) {
|
|
102
|
-
return "";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function _dispatch(
|
|
106
|
-
uint32 _destinationDomain,
|
|
107
|
-
bytes32 _recipient,
|
|
108
|
-
bytes memory _messageBody
|
|
109
|
-
) internal virtual returns (bytes32) {
|
|
110
|
-
return
|
|
111
|
-
_dispatch(_destinationDomain, _recipient, msg.value, _messageBody);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function _dispatch(
|
|
115
|
-
uint32 _destinationDomain,
|
|
116
|
-
bytes32 _recipient,
|
|
117
|
-
uint256 _value,
|
|
118
|
-
bytes memory _messageBody
|
|
119
|
-
) internal virtual returns (bytes32) {
|
|
120
|
-
return
|
|
121
|
-
mailbox.dispatch{value: _value}(
|
|
122
|
-
_destinationDomain,
|
|
123
|
-
_recipient,
|
|
124
|
-
_messageBody,
|
|
125
|
-
_metadata(_destinationDomain),
|
|
126
|
-
hook
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function _dispatch(
|
|
131
|
-
uint32 _destinationDomain,
|
|
132
|
-
bytes32 _recipient,
|
|
133
|
-
uint256 _value,
|
|
134
|
-
bytes memory _messageBody,
|
|
135
|
-
bytes memory _hookMetadata,
|
|
136
|
-
IPostDispatchHook _hook
|
|
137
|
-
) internal virtual returns (bytes32) {
|
|
138
|
-
return
|
|
139
|
-
mailbox.dispatch{value: _value}(
|
|
140
|
-
_destinationDomain,
|
|
141
|
-
_recipient,
|
|
142
|
-
_messageBody,
|
|
143
|
-
_hookMetadata,
|
|
144
|
-
_hook
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function _quoteDispatch(
|
|
149
|
-
uint32 _destinationDomain,
|
|
150
|
-
bytes32 _recipient,
|
|
151
|
-
bytes memory _messageBody
|
|
152
|
-
) internal view virtual returns (uint256) {
|
|
153
|
-
return
|
|
154
|
-
mailbox.quoteDispatch(
|
|
155
|
-
_destinationDomain,
|
|
156
|
-
_recipient,
|
|
157
|
-
_messageBody,
|
|
158
|
-
_metadata(_destinationDomain),
|
|
159
|
-
hook
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function _quoteDispatch(
|
|
164
|
-
uint32 _destinationDomain,
|
|
165
|
-
bytes32 _recipient,
|
|
166
|
-
bytes memory _messageBody,
|
|
167
|
-
bytes calldata _hookMetadata,
|
|
168
|
-
IPostDispatchHook _hook
|
|
169
|
-
) internal view virtual returns (uint256) {
|
|
170
|
-
return
|
|
171
|
-
mailbox.quoteDispatch(
|
|
172
|
-
_destinationDomain,
|
|
173
|
-
_recipient,
|
|
174
|
-
_messageBody,
|
|
175
|
-
_hookMetadata,
|
|
176
|
-
_hook
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
98
|
}
|
|
@@ -167,28 +167,73 @@ abstract contract Router is MailboxClient, IMessageRecipient {
|
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
function
|
|
170
|
+
function _Router_dispatch(
|
|
171
171
|
uint32 _destinationDomain,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
uint256 _value,
|
|
173
|
+
bytes memory _messageBody,
|
|
174
|
+
bytes memory _hookMetadata,
|
|
175
|
+
address _hook
|
|
176
|
+
) internal returns (bytes32) {
|
|
177
|
+
bytes32 _router = _mustHaveRemoteRouter(_destinationDomain);
|
|
178
|
+
return
|
|
179
|
+
mailbox.dispatch{value: _value}(
|
|
180
|
+
_destinationDomain,
|
|
181
|
+
_router,
|
|
182
|
+
_messageBody,
|
|
183
|
+
_hookMetadata,
|
|
184
|
+
IPostDispatchHook(_hook)
|
|
185
|
+
);
|
|
175
186
|
}
|
|
176
187
|
|
|
188
|
+
/**
|
|
189
|
+
* DEPRECATED: Use `_Router_dispatch` instead
|
|
190
|
+
* @dev For backward compatibility with v2 client contracts
|
|
191
|
+
*/
|
|
177
192
|
function _dispatch(
|
|
178
193
|
uint32 _destinationDomain,
|
|
179
|
-
uint256 _value,
|
|
180
194
|
bytes memory _messageBody
|
|
181
|
-
) internal
|
|
195
|
+
) internal returns (bytes32) {
|
|
196
|
+
return
|
|
197
|
+
_Router_dispatch(
|
|
198
|
+
_destinationDomain,
|
|
199
|
+
msg.value,
|
|
200
|
+
_messageBody,
|
|
201
|
+
"",
|
|
202
|
+
address(hook)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function _Router_quoteDispatch(
|
|
207
|
+
uint32 _destinationDomain,
|
|
208
|
+
bytes memory _messageBody,
|
|
209
|
+
bytes memory _hookMetadata,
|
|
210
|
+
address _hook
|
|
211
|
+
) internal view returns (uint256) {
|
|
182
212
|
bytes32 _router = _mustHaveRemoteRouter(_destinationDomain);
|
|
183
213
|
return
|
|
184
|
-
|
|
214
|
+
mailbox.quoteDispatch(
|
|
215
|
+
_destinationDomain,
|
|
216
|
+
_router,
|
|
217
|
+
_messageBody,
|
|
218
|
+
_hookMetadata,
|
|
219
|
+
IPostDispatchHook(_hook)
|
|
220
|
+
);
|
|
185
221
|
}
|
|
186
222
|
|
|
223
|
+
/**
|
|
224
|
+
* DEPRECATED: Use `_Router_quoteDispatch` instead
|
|
225
|
+
* @dev For backward compatibility with v2 client contracts
|
|
226
|
+
*/
|
|
187
227
|
function _quoteDispatch(
|
|
188
228
|
uint32 _destinationDomain,
|
|
189
229
|
bytes memory _messageBody
|
|
190
|
-
) internal view
|
|
191
|
-
|
|
192
|
-
|
|
230
|
+
) internal view returns (uint256) {
|
|
231
|
+
return
|
|
232
|
+
_Router_quoteDispatch(
|
|
233
|
+
_destinationDomain,
|
|
234
|
+
_messageBody,
|
|
235
|
+
"",
|
|
236
|
+
address(hook)
|
|
237
|
+
);
|
|
193
238
|
}
|
|
194
239
|
}
|
|
@@ -3,6 +3,7 @@ pragma solidity >=0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
5
5
|
|
|
6
|
+
import "../token/interfaces/IXERC20Lockbox.sol";
|
|
6
7
|
import "../token/interfaces/IXERC20.sol";
|
|
7
8
|
import "../token/interfaces/IFiatToken.sol";
|
|
8
9
|
|
|
@@ -66,15 +67,62 @@ contract XERC20Test is ERC20Test, IXERC20 {
|
|
|
66
67
|
_burn(account, amount);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
function setLimits(
|
|
70
|
-
|
|
71
|
-
uint256 /* _mintingLimit */,
|
|
72
|
-
uint256 /* _burningLimit */
|
|
73
|
-
) external pure {
|
|
74
|
-
require(false, "setLimits(): not implemented");
|
|
70
|
+
function setLimits(address, uint256, uint256) external pure {
|
|
71
|
+
assert(false);
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
function owner() external pure returns (address) {
|
|
78
75
|
return address(0x0);
|
|
79
76
|
}
|
|
77
|
+
|
|
78
|
+
function burningCurrentLimitOf(
|
|
79
|
+
address _bridge
|
|
80
|
+
) external view returns (uint256) {
|
|
81
|
+
return type(uint256).max;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function mintingCurrentLimitOf(
|
|
85
|
+
address _bridge
|
|
86
|
+
) external view returns (uint256) {
|
|
87
|
+
return type(uint256).max;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
contract XERC20LockboxTest is IXERC20Lockbox {
|
|
92
|
+
IXERC20 public immutable XERC20;
|
|
93
|
+
IERC20 public immutable ERC20;
|
|
94
|
+
|
|
95
|
+
constructor(
|
|
96
|
+
string memory name,
|
|
97
|
+
string memory symbol,
|
|
98
|
+
uint256 totalSupply,
|
|
99
|
+
uint8 __decimals
|
|
100
|
+
) {
|
|
101
|
+
ERC20Test erc20 = new ERC20Test(name, symbol, totalSupply, __decimals);
|
|
102
|
+
erc20.transfer(msg.sender, totalSupply);
|
|
103
|
+
ERC20 = erc20;
|
|
104
|
+
XERC20 = new XERC20Test(name, symbol, 0, __decimals);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function depositTo(address _user, uint256 _amount) public {
|
|
108
|
+
ERC20.transferFrom(msg.sender, address(this), _amount);
|
|
109
|
+
XERC20.mint(_user, _amount);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function deposit(uint256 _amount) external {
|
|
113
|
+
depositTo(msg.sender, _amount);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function depositNativeTo(address) external payable {
|
|
117
|
+
assert(false);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function withdrawTo(address _user, uint256 _amount) public {
|
|
121
|
+
XERC20.burn(msg.sender, _amount);
|
|
122
|
+
ERC20Test(address(ERC20)).mintTo(_user, _amount);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function withdraw(uint256 _amount) external {
|
|
126
|
+
withdrawTo(msg.sender, _amount);
|
|
127
|
+
}
|
|
80
128
|
}
|
|
@@ -7,7 +7,7 @@ contract TestGasRouter is GasRouter {
|
|
|
7
7
|
constructor(address _mailbox) GasRouter(_mailbox) {}
|
|
8
8
|
|
|
9
9
|
function dispatch(uint32 _destination, bytes memory _msg) external payable {
|
|
10
|
-
|
|
10
|
+
_GasRouter_dispatch(_destination, msg.value, _msg, address(hook));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function _handle(uint32, bytes32, bytes calldata) internal pure override {}
|
|
@@ -36,24 +36,16 @@ contract HypNative is TokenRouter {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @inheritdoc TokenRouter
|
|
39
|
-
* @dev uses (`msg.value` - `_amount`) as
|
|
39
|
+
* @dev uses (`msg.value` - `_amount`) as hook payment and `msg.sender` as refund address.
|
|
40
40
|
*/
|
|
41
41
|
function transferRemote(
|
|
42
42
|
uint32 _destination,
|
|
43
43
|
bytes32 _recipient,
|
|
44
44
|
uint256 _amount
|
|
45
|
-
)
|
|
45
|
+
) external payable virtual override returns (bytes32 messageId) {
|
|
46
46
|
require(msg.value >= _amount, "Native: amount exceeds msg.value");
|
|
47
|
-
uint256
|
|
48
|
-
return
|
|
49
|
-
_transferRemote(
|
|
50
|
-
_destination,
|
|
51
|
-
_recipient,
|
|
52
|
-
_amount,
|
|
53
|
-
gasPayment,
|
|
54
|
-
bytes(""),
|
|
55
|
-
address(0)
|
|
56
|
-
);
|
|
47
|
+
uint256 _hookPayment = msg.value - _amount;
|
|
48
|
+
return _transferRemote(_destination, _recipient, _amount, _hookPayment);
|
|
57
49
|
}
|
|
58
50
|
|
|
59
51
|
function balanceOf(
|
|
@@ -6,7 +6,7 @@ For instructions on deploying Warp Routes, see [the deployment documentation](ht
|
|
|
6
6
|
|
|
7
7
|
## Warp Route Architecture
|
|
8
8
|
|
|
9
|
-
A Warp Route is a collection of [`TokenRouter`](./
|
|
9
|
+
A Warp Route is a collection of [`TokenRouter`](./libs/TokenRouter.sol) contracts deployed across a set of Hyperlane chains. These contracts leverage the `Router` pattern to implement access control and routing logic for remote token transfers. These contracts send and receive [`Messages`](./libs/TokenMessage.sol) which encode payloads containing a transfer `amount` and `recipient` address.
|
|
10
10
|
|
|
11
11
|
```mermaid
|
|
12
12
|
%%{ init: {
|
|
@@ -39,7 +39,7 @@ graph LR
|
|
|
39
39
|
Mailbox_G[(Mailbox)]
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
HYP_E -. "
|
|
42
|
+
HYP_E -. "TokenMessage" .- HYP_P -. "TokenMessage" .- HYP_G
|
|
43
43
|
|
|
44
44
|
```
|
|
45
45
|
|
|
@@ -25,18 +25,16 @@ contract HypNativeScaled is HypNative {
|
|
|
25
25
|
uint32 _destination,
|
|
26
26
|
bytes32 _recipient,
|
|
27
27
|
uint256 _amount
|
|
28
|
-
)
|
|
28
|
+
) external payable override returns (bytes32 messageId) {
|
|
29
29
|
require(msg.value >= _amount, "Native: amount exceeds msg.value");
|
|
30
|
-
uint256
|
|
31
|
-
uint256
|
|
30
|
+
uint256 _hookPayment = msg.value - _amount;
|
|
31
|
+
uint256 _scaledAmount = _amount / scale;
|
|
32
32
|
return
|
|
33
33
|
_transferRemote(
|
|
34
34
|
_destination,
|
|
35
35
|
_recipient,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
bytes(""),
|
|
39
|
-
address(0)
|
|
36
|
+
_scaledAmount,
|
|
37
|
+
_hookPayment
|
|
40
38
|
);
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -8,7 +8,9 @@ contract HypXERC20 is HypERC20Collateral {
|
|
|
8
8
|
constructor(
|
|
9
9
|
address _xerc20,
|
|
10
10
|
address _mailbox
|
|
11
|
-
) HypERC20Collateral(_xerc20, _mailbox) {
|
|
11
|
+
) HypERC20Collateral(_xerc20, _mailbox) {
|
|
12
|
+
_disableInitializers();
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
function _transferFromSender(
|
|
14
16
|
uint256 _amountOrId
|
|
@@ -17,18 +17,40 @@ contract HypXERC20Lockbox is HypERC20Collateral {
|
|
|
17
17
|
) HypERC20Collateral(address(IXERC20Lockbox(_lockbox).ERC20()), _mailbox) {
|
|
18
18
|
lockbox = IXERC20Lockbox(_lockbox);
|
|
19
19
|
xERC20 = lockbox.XERC20();
|
|
20
|
+
approveLockbox();
|
|
21
|
+
_disableInitializers();
|
|
22
|
+
}
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @notice Approve the lockbox to spend the wrapped token and xERC20
|
|
26
|
+
* @dev This function is idempotent and need not be access controlled
|
|
27
|
+
*/
|
|
28
|
+
function approveLockbox() public {
|
|
22
29
|
require(
|
|
23
|
-
IERC20(wrappedToken).approve(
|
|
30
|
+
IERC20(wrappedToken).approve(address(lockbox), MAX_INT),
|
|
24
31
|
"erc20 lockbox approve failed"
|
|
25
32
|
);
|
|
26
33
|
require(
|
|
27
|
-
xERC20.approve(
|
|
34
|
+
xERC20.approve(address(lockbox), MAX_INT),
|
|
28
35
|
"xerc20 lockbox approve failed"
|
|
29
36
|
);
|
|
30
37
|
}
|
|
31
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @notice Initialize the contract
|
|
41
|
+
* @param _hook The address of the hook contract
|
|
42
|
+
* @param _ism The address of the interchain security module
|
|
43
|
+
* @param _owner The address of the owner
|
|
44
|
+
*/
|
|
45
|
+
function initialize(
|
|
46
|
+
address _hook,
|
|
47
|
+
address _ism,
|
|
48
|
+
address _owner
|
|
49
|
+
) public override initializer {
|
|
50
|
+
approveLockbox();
|
|
51
|
+
_MailboxClient_initialize(_hook, _ism, _owner);
|
|
52
|
+
}
|
|
53
|
+
|
|
32
54
|
function _transferFromSender(
|
|
33
55
|
uint256 _amount
|
|
34
56
|
) internal override returns (bytes memory) {
|
|
@@ -36,4 +36,22 @@ interface IXERC20 is IERC20 {
|
|
|
36
36
|
) external;
|
|
37
37
|
|
|
38
38
|
function owner() external returns (address);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @notice Returns the current limit of a bridge
|
|
42
|
+
* @param _bridge the bridge we are viewing the limits of
|
|
43
|
+
* @return _limit The limit the bridge has
|
|
44
|
+
*/
|
|
45
|
+
function burningCurrentLimitOf(
|
|
46
|
+
address _bridge
|
|
47
|
+
) external view returns (uint256 _limit);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @notice Returns the current limit of a bridge
|
|
51
|
+
* @param _bridge the bridge we are viewing the limits of
|
|
52
|
+
* @return _limit The limit the bridge has
|
|
53
|
+
*/
|
|
54
|
+
function mintingCurrentLimitOf(
|
|
55
|
+
address _bridge
|
|
56
|
+
) external view returns (uint256 _limit);
|
|
39
57
|
}
|
|
@@ -109,9 +109,11 @@ abstract contract FastTokenRouter is TokenRouter {
|
|
|
109
109
|
_fastTransferId
|
|
110
110
|
);
|
|
111
111
|
|
|
112
|
-
messageId =
|
|
112
|
+
messageId = _GasRouter_dispatch(
|
|
113
113
|
_destination,
|
|
114
|
-
|
|
114
|
+
msg.value,
|
|
115
|
+
TokenMessage.format(_recipient, _amountOrId, metadata),
|
|
116
|
+
address(hook)
|
|
115
117
|
);
|
|
116
118
|
emit SentTransferRemote(_destination, _recipient, _amountOrId);
|
|
117
119
|
}
|
|
@@ -57,14 +57,7 @@ abstract contract TokenRouter is GasRouter {
|
|
|
57
57
|
uint256 _amountOrId
|
|
58
58
|
) external payable virtual returns (bytes32 messageId) {
|
|
59
59
|
return
|
|
60
|
-
_transferRemote(
|
|
61
|
-
_destination,
|
|
62
|
-
_recipient,
|
|
63
|
-
_amountOrId,
|
|
64
|
-
msg.value,
|
|
65
|
-
bytes(""),
|
|
66
|
-
address(0)
|
|
67
|
-
);
|
|
60
|
+
_transferRemote(_destination, _recipient, _amountOrId, msg.value);
|
|
68
61
|
}
|
|
69
62
|
|
|
70
63
|
/**
|
|
@@ -97,45 +90,45 @@ abstract contract TokenRouter is GasRouter {
|
|
|
97
90
|
);
|
|
98
91
|
}
|
|
99
92
|
|
|
100
|
-
/**
|
|
101
|
-
* @notice Transfers `_amountOrId` token to `_recipient` on `_destination` domain.
|
|
102
|
-
* @dev Delegates transfer logic to `_transferFromSender` implementation.
|
|
103
|
-
* @dev The metadata is the token metadata, and is DIFFERENT than the hook metadata.
|
|
104
|
-
* @dev Emits `SentTransferRemote` event on the origin chain.
|
|
105
|
-
* @param _destination The identifier of the destination chain.
|
|
106
|
-
* @param _recipient The address of the recipient on the destination chain.
|
|
107
|
-
* @param _amountOrId The amount or identifier of tokens to be sent to the remote recipient.
|
|
108
|
-
* @param _gasPayment The amount of native token to pay for interchain gas.
|
|
109
|
-
* @param _hookMetadata The metadata passed into the hook
|
|
110
|
-
* @param _hook The post dispatch hook to be called by the Mailbox
|
|
111
|
-
* @return messageId The identifier of the dispatched message.
|
|
112
|
-
*/
|
|
113
93
|
function _transferRemote(
|
|
114
94
|
uint32 _destination,
|
|
115
95
|
bytes32 _recipient,
|
|
116
96
|
uint256 _amountOrId,
|
|
117
|
-
uint256
|
|
118
|
-
bytes memory _hookMetadata,
|
|
119
|
-
address _hook
|
|
97
|
+
uint256 _value
|
|
120
98
|
) internal returns (bytes32 messageId) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (address(_hook) == address(0)) {
|
|
124
|
-
messageId = _dispatch(
|
|
125
|
-
_destination,
|
|
126
|
-
_gasPayment,
|
|
127
|
-
TokenMessage.format(_recipient, _amountOrId, metadata)
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
messageId = _dispatch(
|
|
99
|
+
return
|
|
100
|
+
_transferRemote(
|
|
131
101
|
_destination,
|
|
132
102
|
_recipient,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
103
|
+
_amountOrId,
|
|
104
|
+
_value,
|
|
105
|
+
_GasRouter_hookMetadata(_destination),
|
|
106
|
+
address(hook)
|
|
137
107
|
);
|
|
138
|
-
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function _transferRemote(
|
|
111
|
+
uint32 _destination,
|
|
112
|
+
bytes32 _recipient,
|
|
113
|
+
uint256 _amountOrId,
|
|
114
|
+
uint256 _value,
|
|
115
|
+
bytes memory _hookMetadata,
|
|
116
|
+
address _hook
|
|
117
|
+
) internal virtual returns (bytes32 messageId) {
|
|
118
|
+
bytes memory _tokenMetadata = _transferFromSender(_amountOrId);
|
|
119
|
+
bytes memory _tokenMessage = TokenMessage.format(
|
|
120
|
+
_recipient,
|
|
121
|
+
_amountOrId,
|
|
122
|
+
_tokenMetadata
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
messageId = _Router_dispatch(
|
|
126
|
+
_destination,
|
|
127
|
+
_value,
|
|
128
|
+
_tokenMessage,
|
|
129
|
+
_hookMetadata,
|
|
130
|
+
_hook
|
|
131
|
+
);
|
|
139
132
|
|
|
140
133
|
emit SentTransferRemote(_destination, _recipient, _amountOrId);
|
|
141
134
|
}
|