Add ILiquidityLayerRouter (#1378)

asaj/image
Nam Chu Hoai 2 years ago committed by GitHub
parent 848f96780f
commit 93a8fb0c9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      solidity/contracts/Router.sol
  2. 23
      solidity/contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol
  3. 2
      solidity/contracts/test/TestLiquidityLayerMessageRecipient.sol
  4. 2
      solidity/contracts/test/TestTokenRecipient.sol
  5. 0
      solidity/interfaces/ILiquidityLayerMessageRecipient.sol
  6. 15
      solidity/interfaces/ILiquidityLayerRouter.sol

@ -161,8 +161,8 @@ abstract contract Router is HyperlaneConnectionClient, IMessageRecipient {
uint256 _gasAmount,
uint256 _gasPayment,
address _gasPaymentRefundAddress
) internal {
bytes32 _messageId = _dispatch(_destinationDomain, _messageBody);
) internal returns (bytes32 _messageId) {
_messageId = _dispatch(_destinationDomain, _messageBody);
// Call the IGP even if the gas payment is zero. This is to support on-chain
// fee quoting in IGPs, which should always revert if gas payment is insufficient.
interchainGasPaymaster.payForGas{value: _gasPayment}(

@ -3,17 +3,17 @@ pragma solidity ^0.8.13;
import {Router} from "../../Router.sol";
import {IMessageRecipient} from "../../../interfaces/IMessageRecipient.sol";
import {ILiquidityLayerRouter} from "../../../interfaces/ILiquidityLayerRouter.sol";
import {ICircleBridge} from "./interfaces/circle/ICircleBridge.sol";
import {ICircleMessageTransmitter} from "./interfaces/circle/ICircleMessageTransmitter.sol";
import {ILiquidityLayerAdapter} from "./interfaces/ILiquidityLayerAdapter.sol";
import {ILiquidityLayerMessageRecipient} from "./interfaces/ILiquidityLayerMessageRecipient.sol";
import {ILiquidityLayerMessageRecipient} from "../../../interfaces/ILiquidityLayerMessageRecipient.sol";
import {TypeCasts} from "../../libs/TypeCasts.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract LiquidityLayerRouter is Router {
contract LiquidityLayerRouter is Router, ILiquidityLayerRouter {
// Token bridge => adapter address
mapping(string => address) public liquidityLayerAdapters;
@ -39,7 +39,7 @@ contract LiquidityLayerRouter is Router {
address _token,
uint256 _amount,
string calldata _bridge
) external payable {
) external payable returns (bytes32) {
ILiquidityLayerAdapter _adapter = _getAdapter(_bridge);
// Transfer the tokens to the adapter
@ -71,13 +71,14 @@ contract LiquidityLayerRouter is Router {
);
// Dispatch the _messageWithMetadata to the destination's LiquidityLayerRouter.
_dispatchWithGas(
_destinationDomain,
_messageWithMetadata,
0, // TODO eventually accommodate gas amounts
msg.value,
msg.sender
);
return
_dispatchWithGas(
_destinationDomain,
_messageWithMetadata,
0, // TODO eventually accommodate gas amounts
msg.value,
msg.sender
);
}
// Handles a message from an enrolled remote LiquidityLayerRouter

@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import {ILiquidityLayerMessageRecipient} from "../middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol";
import {ILiquidityLayerMessageRecipient} from "../../interfaces/ILiquidityLayerMessageRecipient.sol";
contract TestLiquidityLayerMessageRecipient is ILiquidityLayerMessageRecipient {
event HandledWithTokens(

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;
import {ILiquidityLayerMessageRecipient} from "../middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol";
import {ILiquidityLayerMessageRecipient} from "../../interfaces/ILiquidityLayerMessageRecipient.sol";
contract TestTokenRecipient is ILiquidityLayerMessageRecipient {
bytes32 public lastSender;

@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.6.11;
import {Call} from "../contracts/Call.sol";
interface ILiquidityLayerRouter {
function dispatchWithTokens(
uint32 _destinationDomain,
bytes32 _recipientAddress,
bytes calldata _messageBody,
address _token,
uint256 _amount,
string calldata _bridge
) external payable returns (bytes32);
}
Loading…
Cancel
Save