diff --git a/solidity/contracts/middleware/token-bridge/TokenBridgeRouter.sol b/solidity/contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol similarity index 81% rename from solidity/contracts/middleware/token-bridge/TokenBridgeRouter.sol rename to solidity/contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol index 60712ee4d..e9023c0a4 100644 --- a/solidity/contracts/middleware/token-bridge/TokenBridgeRouter.sol +++ b/solidity/contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol @@ -6,18 +6,18 @@ import {Router} from "../../Router.sol"; import {IMessageRecipient} from "../../../interfaces/IMessageRecipient.sol"; import {ICircleBridge} from "./interfaces/circle/ICircleBridge.sol"; import {ICircleMessageTransmitter} from "./interfaces/circle/ICircleMessageTransmitter.sol"; -import {ITokenBridgeAdapter} from "./interfaces/ITokenBridgeAdapter.sol"; -import {ITokenBridgeMessageRecipient} from "./interfaces/ITokenBridgeMessageRecipient.sol"; +import {ILiquidityLayerAdapter} from "./interfaces/ILiquidityLayerAdapter.sol"; +import {ILiquidityLayerMessageRecipient} from "./interfaces/ILiquidityLayerMessageRecipient.sol"; import {TypeCasts} from "../../libs/TypeCasts.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -contract TokenBridgeRouter is Router { +contract LiquidityLayerRouter is Router { // Token bridge => adapter address - mapping(string => address) public tokenBridgeAdapters; + mapping(string => address) public liquidityLayerAdapters; - event TokenBridgeAdapterSet(string indexed bridge, address adapter); + event LiquidityLayerAdapterSet(string indexed bridge, address adapter); function initialize( address _owner, @@ -40,7 +40,7 @@ contract TokenBridgeRouter is Router { uint256 _amount, string calldata _bridge ) external payable { - ITokenBridgeAdapter _adapter = _getAdapter(_bridge); + ILiquidityLayerAdapter _adapter = _getAdapter(_bridge); // Transfer the tokens to the adapter // TODO: use safeTransferFrom @@ -70,11 +70,11 @@ contract TokenBridgeRouter is Router { _messageBody // The "user" message ); - // Dispatch the _messageWithMetadata to the destination's TokenBridgeRouter. + // Dispatch the _messageWithMetadata to the destination's LiquidityLayerRouter. _dispatchWithGas(_destinationDomain, _messageWithMetadata, msg.value); } - // Handles a message from an enrolled remote TokenBridgeRouter + // Handles a message from an enrolled remote LiquidityLayerRouter function _handle( uint32 _origin, bytes32, // _sender, unused @@ -93,7 +93,7 @@ contract TokenBridgeRouter is Router { (bytes32, bytes32, uint256, string, bytes, bytes) ); - ITokenBridgeMessageRecipient _userRecipient = ITokenBridgeMessageRecipient( + ILiquidityLayerMessageRecipient _userRecipient = ILiquidityLayerMessageRecipient( TypeCasts.bytes32ToAddress(_userRecipientAddress) ); @@ -115,20 +115,20 @@ contract TokenBridgeRouter is Router { ); } - function setTokenBridgeAdapter(string calldata _bridge, address _adapter) + function setLiquidityLayerAdapter(string calldata _bridge, address _adapter) external onlyOwner { - tokenBridgeAdapters[_bridge] = _adapter; - emit TokenBridgeAdapterSet(_bridge, _adapter); + liquidityLayerAdapters[_bridge] = _adapter; + emit LiquidityLayerAdapterSet(_bridge, _adapter); } function _getAdapter(string memory _bridge) internal view - returns (ITokenBridgeAdapter _adapter) + returns (ILiquidityLayerAdapter _adapter) { - _adapter = ITokenBridgeAdapter(tokenBridgeAdapters[_bridge]); + _adapter = ILiquidityLayerAdapter(liquidityLayerAdapters[_bridge]); // Require the adapter to have been set require(address(_adapter) != address(0), "No adapter found for bridge"); } diff --git a/solidity/contracts/middleware/token-bridge/adapters/CircleBridgeAdapter.sol b/solidity/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter.sol similarity index 91% rename from solidity/contracts/middleware/token-bridge/adapters/CircleBridgeAdapter.sol rename to solidity/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter.sol index f857afa7c..5ae80d7dd 100644 --- a/solidity/contracts/middleware/token-bridge/adapters/CircleBridgeAdapter.sol +++ b/solidity/contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter.sol @@ -5,19 +5,19 @@ import {Router} from "../../../Router.sol"; import {ICircleBridge} from "../interfaces/circle/ICircleBridge.sol"; import {ICircleMessageTransmitter} from "../interfaces/circle/ICircleMessageTransmitter.sol"; -import {ITokenBridgeAdapter} from "../interfaces/ITokenBridgeAdapter.sol"; +import {ILiquidityLayerAdapter} from "../interfaces/ILiquidityLayerAdapter.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { +contract CircleBridgeAdapter is ILiquidityLayerAdapter, Router { /// @notice The CircleBridge contract. ICircleBridge public circleBridge; /// @notice The Circle MessageTransmitter contract. ICircleMessageTransmitter public circleMessageTransmitter; - /// @notice The TokenBridgeRouter contract. - address public tokenBridgeRouter; + /// @notice The LiquidityLayerRouter contract. + address public liquidityLayerRouter; /// @notice Hyperlane domain => Circle domain. /// ATM, known Circle domains are Ethereum = 0 and Avalanche = 1. @@ -54,8 +54,8 @@ contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { */ event TokenRemoved(address indexed token, string indexed symbol); - modifier onlyTokenBridgeRouter() { - require(msg.sender == tokenBridgeRouter, "!tokenBridgeRouter"); + modifier onlyLiquidityLayerRouter() { + require(msg.sender == liquidityLayerRouter, "!liquidityLayerRouter"); _; } @@ -63,13 +63,13 @@ contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { * @param _owner The new owner. * @param _circleBridge The CircleBridge contract. * @param _circleMessageTransmitter The Circle MessageTransmitter contract. - * @param _tokenBridgeRouter The TokenBridgeRouter contract. + * @param _liquidityLayerRouter The LiquidityLayerRouter contract. */ function initialize( address _owner, address _circleBridge, address _circleMessageTransmitter, - address _tokenBridgeRouter + address _liquidityLayerRouter ) public initializer { // Transfer ownership of the contract to deployer _transferOwnership(_owner); @@ -82,7 +82,7 @@ contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { circleMessageTransmitter = ICircleMessageTransmitter( _circleMessageTransmitter ); - tokenBridgeRouter = _tokenBridgeRouter; + liquidityLayerRouter = _liquidityLayerRouter; } function sendTokens( @@ -90,7 +90,7 @@ contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { bytes32, // _recipientAddress, unused address _token, uint256 _amount - ) external onlyTokenBridgeRouter returns (bytes memory) { + ) external onlyLiquidityLayerRouter returns (bytes memory) { string memory _tokenSymbol = tokenAddressToSymbol[_token]; require( bytes(_tokenSymbol).length > 0, @@ -106,7 +106,7 @@ contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { "CircleBridgeAdapter: No router for domain" ); - // Approve the token to Circle. We assume that the TokenBridgeRouter + // Approve the token to Circle. We assume that the LiquidityLayerRouter // has already transferred the token to this contract. require( IERC20(_token).approve(address(circleBridge), _amount), @@ -130,7 +130,7 @@ contract CircleBridgeAdapter is ITokenBridgeAdapter, Router { address _recipient, uint256 _amount, bytes calldata _adapterData // The adapter data from the message - ) external onlyTokenBridgeRouter returns (address, uint256) { + ) external onlyLiquidityLayerRouter returns (address, uint256) { // The origin Circle domain uint32 _originCircleDomain = hyperlaneDomainToCircleDomain[ _originDomain diff --git a/solidity/contracts/middleware/token-bridge/interfaces/ITokenBridgeAdapter.sol b/solidity/contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerAdapter.sol similarity index 93% rename from solidity/contracts/middleware/token-bridge/interfaces/ITokenBridgeAdapter.sol rename to solidity/contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerAdapter.sol index de8847a13..95b97f6c4 100644 --- a/solidity/contracts/middleware/token-bridge/interfaces/ITokenBridgeAdapter.sol +++ b/solidity/contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerAdapter.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; -interface ITokenBridgeAdapter { +interface ILiquidityLayerAdapter { function sendTokens( uint32 _destinationDomain, bytes32 _recipientAddress, diff --git a/solidity/contracts/middleware/token-bridge/interfaces/ITokenBridgeMessageRecipient.sol b/solidity/contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol similarity index 84% rename from solidity/contracts/middleware/token-bridge/interfaces/ITokenBridgeMessageRecipient.sol rename to solidity/contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol index 49264cda7..1fc03e334 100644 --- a/solidity/contracts/middleware/token-bridge/interfaces/ITokenBridgeMessageRecipient.sol +++ b/solidity/contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; -interface ITokenBridgeMessageRecipient { +interface ILiquidityLayerMessageRecipient { function handleWithTokens( uint32 _origin, bytes32 _sender, diff --git a/solidity/contracts/middleware/token-bridge/interfaces/circle/ICircleBridge.sol b/solidity/contracts/middleware/liquidity-layer/interfaces/circle/ICircleBridge.sol similarity index 100% rename from solidity/contracts/middleware/token-bridge/interfaces/circle/ICircleBridge.sol rename to solidity/contracts/middleware/liquidity-layer/interfaces/circle/ICircleBridge.sol diff --git a/solidity/contracts/middleware/token-bridge/interfaces/circle/ICircleMessageTransmitter.sol b/solidity/contracts/middleware/liquidity-layer/interfaces/circle/ICircleMessageTransmitter.sol similarity index 100% rename from solidity/contracts/middleware/token-bridge/interfaces/circle/ICircleMessageTransmitter.sol rename to solidity/contracts/middleware/liquidity-layer/interfaces/circle/ICircleMessageTransmitter.sol diff --git a/solidity/contracts/mock/MockCircleBridge.sol b/solidity/contracts/mock/MockCircleBridge.sol index dc1d9c066..071087a05 100644 --- a/solidity/contracts/mock/MockCircleBridge.sol +++ b/solidity/contracts/mock/MockCircleBridge.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; -import {ICircleBridge} from "../middleware/token-bridge/interfaces/circle/ICircleBridge.sol"; +import {ICircleBridge} from "../middleware/liquidity-layer/interfaces/circle/ICircleBridge.sol"; import {MockToken} from "./MockToken.sol"; contract MockCircleBridge is ICircleBridge { diff --git a/solidity/contracts/mock/MockCircleMessageTransmitter.sol b/solidity/contracts/mock/MockCircleMessageTransmitter.sol index 3361b17d1..d883d9949 100644 --- a/solidity/contracts/mock/MockCircleMessageTransmitter.sol +++ b/solidity/contracts/mock/MockCircleMessageTransmitter.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; -import {ICircleMessageTransmitter} from "../middleware/token-bridge/interfaces/circle/ICircleMessageTransmitter.sol"; +import {ICircleMessageTransmitter} from "../middleware/liquidity-layer/interfaces/circle/ICircleMessageTransmitter.sol"; import {MockToken} from "./MockToken.sol"; contract MockCircleMessageTransmitter is ICircleMessageTransmitter { diff --git a/solidity/contracts/test/TestTokenBridgeMessageRecipient.sol b/solidity/contracts/test/TestLiquidityLayerMessageRecipient.sol similarity index 69% rename from solidity/contracts/test/TestTokenBridgeMessageRecipient.sol rename to solidity/contracts/test/TestLiquidityLayerMessageRecipient.sol index a753c4b2b..4f4001212 100644 --- a/solidity/contracts/test/TestTokenBridgeMessageRecipient.sol +++ b/solidity/contracts/test/TestLiquidityLayerMessageRecipient.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; -import {ITokenBridgeMessageRecipient} from "../middleware/token-bridge/interfaces/ITokenBridgeMessageRecipient.sol"; +import {ILiquidityLayerMessageRecipient} from "../middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol"; -contract TestTokenBridgeMessageRecipient is ITokenBridgeMessageRecipient { +contract TestLiquidityLayerMessageRecipient is ILiquidityLayerMessageRecipient { event HandledWithTokens( uint32 origin, bytes32 sender, diff --git a/solidity/contracts/test/TestTokenRecipient.sol b/solidity/contracts/test/TestTokenRecipient.sol index 202abf4d5..ebcec4710 100644 --- a/solidity/contracts/test/TestTokenRecipient.sol +++ b/solidity/contracts/test/TestTokenRecipient.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; -import {ITokenBridgeMessageRecipient} from "../middleware/token-bridge/interfaces/ITokenBridgeMessageRecipient.sol"; +import {ILiquidityLayerMessageRecipient} from "../middleware/liquidity-layer/interfaces/ILiquidityLayerMessageRecipient.sol"; -contract TestTokenRecipient is ITokenBridgeMessageRecipient { +contract TestTokenRecipient is ILiquidityLayerMessageRecipient { bytes32 public lastSender; bytes public lastData; address public lastToken; diff --git a/solidity/test/TokenBridgeRouter.t.sol b/solidity/test/LiquidityLayerRouter.t.sol similarity index 73% rename from solidity/test/TokenBridgeRouter.t.sol rename to solidity/test/LiquidityLayerRouter.t.sol index 7e404e501..29a52d134 100644 --- a/solidity/test/TokenBridgeRouter.t.sol +++ b/solidity/test/LiquidityLayerRouter.t.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.13; import "forge-std/Test.sol"; -import {TokenBridgeRouter} from "../contracts/middleware/token-bridge/TokenBridgeRouter.sol"; -import {CircleBridgeAdapter} from "../contracts/middleware/token-bridge/adapters/CircleBridgeAdapter.sol"; +import {LiquidityLayerRouter} from "../contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol"; +import {CircleBridgeAdapter} from "../contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter.sol"; import {MockToken} from "../contracts/mock/MockToken.sol"; import {TestTokenRecipient} from "../contracts/test/TestTokenRecipient.sol"; import {MockCircleMessageTransmitter} from "../contracts/mock/MockCircleMessageTransmitter.sol"; @@ -12,11 +12,11 @@ import {MockHyperlaneEnvironment} from "../contracts/mock/MockHyperlaneEnvironme import {TypeCasts} from "../contracts/libs/TypeCasts.sol"; -contract TokenBridgeRouterTest is Test { +contract LiquidityLayerRouterTest is Test { MockHyperlaneEnvironment testEnvironment; - TokenBridgeRouter originTokenBridgeRouter; - TokenBridgeRouter destinationTokenBridgeRouter; + LiquidityLayerRouter originLiquidityLayerRouter; + LiquidityLayerRouter destinationLiquidityLayerRouter; MockCircleMessageTransmitter messageTransmitter; MockCircleBridge circleBridge; @@ -33,7 +33,7 @@ contract TokenBridgeRouterTest is Test { bytes messageBody = hex"beefdead"; uint256 amount = 420000; - event TokenBridgeAdapterSet(string indexed bridge, address adapter); + event LiquidityLayerAdapterSet(string indexed bridge, address adapter); function setUp() public { token = new MockToken(); @@ -45,8 +45,8 @@ contract TokenBridgeRouterTest is Test { recipient = new TestTokenRecipient(); - originTokenBridgeRouter = new TokenBridgeRouter(); - destinationTokenBridgeRouter = new TokenBridgeRouter(); + originLiquidityLayerRouter = new LiquidityLayerRouter(); + destinationLiquidityLayerRouter = new LiquidityLayerRouter(); testEnvironment = new MockHyperlaneEnvironment( originDomain, @@ -54,38 +54,38 @@ contract TokenBridgeRouterTest is Test { ); // TODO: set IGP? - originTokenBridgeRouter.initialize( + originLiquidityLayerRouter.initialize( address(this), address(testEnvironment.connectionManager(originDomain)), address(0) ); - destinationTokenBridgeRouter.initialize( + destinationLiquidityLayerRouter.initialize( address(this), address(testEnvironment.connectionManager(destinationDomain)), address(0) ); - originTokenBridgeRouter.enrollRemoteRouter( + originLiquidityLayerRouter.enrollRemoteRouter( destinationDomain, - TypeCasts.addressToBytes32(address(destinationTokenBridgeRouter)) + TypeCasts.addressToBytes32(address(destinationLiquidityLayerRouter)) ); - destinationTokenBridgeRouter.enrollRemoteRouter( + destinationLiquidityLayerRouter.enrollRemoteRouter( originDomain, - TypeCasts.addressToBytes32(address(originTokenBridgeRouter)) + TypeCasts.addressToBytes32(address(originLiquidityLayerRouter)) ); originBridgeAdapter.initialize( address(this), address(circleBridge), address(messageTransmitter), - address(originTokenBridgeRouter) + address(originLiquidityLayerRouter) ); destinationBridgeAdapter.initialize( address(this), address(circleBridge), address(messageTransmitter), - address(destinationTokenBridgeRouter) + address(destinationLiquidityLayerRouter) ); originBridgeAdapter.addToken(address(token), "USDC"); @@ -100,12 +100,12 @@ contract TokenBridgeRouterTest is Test { TypeCasts.addressToBytes32(address(originBridgeAdapter)) ); - originTokenBridgeRouter.setTokenBridgeAdapter( + originLiquidityLayerRouter.setLiquidityLayerAdapter( bridge, address(originBridgeAdapter) ); - destinationTokenBridgeRouter.setTokenBridgeAdapter( + destinationLiquidityLayerRouter.setLiquidityLayerAdapter( bridge, address(destinationBridgeAdapter) ); @@ -113,21 +113,21 @@ contract TokenBridgeRouterTest is Test { token.mint(address(this), amount); } - function testSetTokenBridgeAdapter() public { - // Expect the TokenBridgeAdapterSet event. + function testSetLiquidityLayerAdapter() public { + // Expect the LiquidityLayerAdapterSet event. // Expect topic0 & data to match vm.expectEmit(true, false, false, true); - emit TokenBridgeAdapterSet(bridge, address(originBridgeAdapter)); + emit LiquidityLayerAdapterSet(bridge, address(originBridgeAdapter)); // Set the token bridge adapter - originTokenBridgeRouter.setTokenBridgeAdapter( + originLiquidityLayerRouter.setLiquidityLayerAdapter( bridge, address(originBridgeAdapter) ); // Expect the bridge adapter to have been set assertEq( - originTokenBridgeRouter.tokenBridgeAdapters(bridge), + originLiquidityLayerRouter.liquidityLayerAdapters(bridge), address(originBridgeAdapter) ); } @@ -136,7 +136,7 @@ contract TokenBridgeRouterTest is Test { function testDispatchWithTokensRevertsWithUnkownBridgeAdapter() public { vm.expectRevert("No adapter found for bridge"); - originTokenBridgeRouter.dispatchWithTokens( + originLiquidityLayerRouter.dispatchWithTokens( destinationDomain, TypeCasts.addressToBytes32(address(recipient)), messageBody, @@ -148,7 +148,7 @@ contract TokenBridgeRouterTest is Test { function testDispatchWithTokensRevertsWithFailedTransferIn() public { vm.expectRevert("ERC20: insufficient allowance"); - originTokenBridgeRouter.dispatchWithTokens( + originLiquidityLayerRouter.dispatchWithTokens( destinationDomain, TypeCasts.addressToBytes32(address(recipient)), messageBody, @@ -159,8 +159,8 @@ contract TokenBridgeRouterTest is Test { } function testDispatchWithTokenTransfersMovesTokens() public { - token.approve(address(originTokenBridgeRouter), amount); - originTokenBridgeRouter.dispatchWithTokens( + token.approve(address(originLiquidityLayerRouter), amount); + originLiquidityLayerRouter.dispatchWithTokens( destinationDomain, TypeCasts.addressToBytes32(address(recipient)), messageBody, @@ -181,8 +181,8 @@ contract TokenBridgeRouterTest is Test { amount ) ); - token.approve(address(originTokenBridgeRouter), amount); - originTokenBridgeRouter.dispatchWithTokens( + token.approve(address(originLiquidityLayerRouter), amount); + originLiquidityLayerRouter.dispatchWithTokens( destinationDomain, TypeCasts.addressToBytes32(address(recipient)), messageBody, @@ -193,8 +193,8 @@ contract TokenBridgeRouterTest is Test { } function testProcessingRevertsIfBridgeAdapterReverts() public { - token.approve(address(originTokenBridgeRouter), amount); - originTokenBridgeRouter.dispatchWithTokens( + token.approve(address(originLiquidityLayerRouter), amount); + originLiquidityLayerRouter.dispatchWithTokens( destinationDomain, TypeCasts.addressToBytes32(address(recipient)), messageBody, @@ -208,8 +208,8 @@ contract TokenBridgeRouterTest is Test { } function testDispatchWithTokensTransfersOnDestination() public { - token.approve(address(originTokenBridgeRouter), amount); - originTokenBridgeRouter.dispatchWithTokens( + token.approve(address(originLiquidityLayerRouter), amount); + originLiquidityLayerRouter.dispatchWithTokens( destinationDomain, TypeCasts.addressToBytes32(address(recipient)), messageBody, diff --git a/typescript/infra/config/environments/testnet2/token-bridge.ts b/typescript/infra/config/environments/testnet2/liquidityLayer.ts similarity index 100% rename from typescript/infra/config/environments/testnet2/token-bridge.ts rename to typescript/infra/config/environments/testnet2/liquidityLayer.ts diff --git a/typescript/infra/config/environments/testnet2/middleware/token-bridge/addresses.json b/typescript/infra/config/environments/testnet2/middleware/liquidity-layer/addresses.json similarity index 100% rename from typescript/infra/config/environments/testnet2/middleware/token-bridge/addresses.json rename to typescript/infra/config/environments/testnet2/middleware/liquidity-layer/addresses.json diff --git a/typescript/infra/config/environments/testnet2/middleware/token-bridge/verification.json b/typescript/infra/config/environments/testnet2/middleware/liquidity-layer/verification.json similarity index 100% rename from typescript/infra/config/environments/testnet2/middleware/token-bridge/verification.json rename to typescript/infra/config/environments/testnet2/middleware/liquidity-layer/verification.json diff --git a/typescript/infra/scripts/circle-relayer.ts b/typescript/infra/scripts/circle-relayer.ts index 103cedb18..3abbe678a 100644 --- a/typescript/infra/scripts/circle-relayer.ts +++ b/typescript/infra/scripts/circle-relayer.ts @@ -3,13 +3,13 @@ import path from 'path'; import { ChainMap, Chains, - TokenBridgeApp, + LiquidityLayerApp, buildContracts, + liquidityLayerFactories, objMap, - tokenBridgeFactories, } from '@hyperlane-xyz/sdk'; -import { circleBridgeAdapterConfig } from '../config/environments/testnet2/token-bridge'; +import { circleBridgeAdapterConfig } from '../config/environments/testnet2/liquidityLayer'; import { readJSON, sleep } from '../src/utils/utils'; import { @@ -26,15 +26,15 @@ async function check() { __dirname, '../', getEnvironmentDirectory(environment), - 'middleware/token-bridge', + 'middleware/liquidity-layer', ); const addresses = readJSON(dir, 'addresses.json'); // @ts-ignore - const contracts: ChainMap = buildContracts( + const contracts: ChainMap = buildContracts( addresses, - tokenBridgeFactories, + liquidityLayerFactories, ); - const app = new TokenBridgeApp( + const app = new LiquidityLayerApp( contracts, multiProvider, objMap(circleBridgeAdapterConfig, (_chain, conf) => [conf]), diff --git a/typescript/infra/scripts/middleware/deploy-token-bridge.ts b/typescript/infra/scripts/middleware/deploy-liquidity-layer.ts similarity index 80% rename from typescript/infra/scripts/middleware/deploy-token-bridge.ts rename to typescript/infra/scripts/middleware/deploy-liquidity-layer.ts index 31fc96cf7..5e48e9296 100644 --- a/typescript/infra/scripts/middleware/deploy-token-bridge.ts +++ b/typescript/infra/scripts/middleware/deploy-liquidity-layer.ts @@ -2,12 +2,12 @@ import path from 'path'; import { HyperlaneCore, - TokenBridgeDeployer, + LiquidityLayerDeployer, + liquidityLayerFactories, objMap, - tokenBridgeFactories, } from '@hyperlane-xyz/sdk'; -import { circleBridgeAdapterConfig } from '../../config/environments/testnet2/token-bridge'; +import { circleBridgeAdapterConfig } from '../../config/environments/testnet2/liquidityLayer'; import { deployWithArtifacts } from '../../src/deploy'; import { getConfiguration } from '../helloworld/utils'; import { @@ -24,23 +24,23 @@ async function main() { const dir = path.join( getEnvironmentDirectory(environment), - 'middleware/token-bridge', + 'middleware/liquidity-layer', ); // config gcp deployer key as owner const ownerConfigMap = await getConfiguration(environment, multiProvider); - const deployer = new TokenBridgeDeployer( + const deployer = new LiquidityLayerDeployer( multiProvider, objMap(circleBridgeAdapterConfig, (chain, conf) => ({ bridgeAdapterConfigs: [conf], ...ownerConfigMap[chain], })), core, - 'TokenBridgeDeploy2', + 'LiquidityLayerDeploy2', ); - await deployWithArtifacts(dir, tokenBridgeFactories, deployer); + await deployWithArtifacts(dir, liquidityLayerFactories, deployer); } main() diff --git a/typescript/sdk/src/deploy/middleware/TokenBridgeApp.ts b/typescript/sdk/src/deploy/middleware/LiquidityLayerApp.ts similarity index 94% rename from typescript/sdk/src/deploy/middleware/TokenBridgeApp.ts rename to typescript/sdk/src/deploy/middleware/LiquidityLayerApp.ts index 0cfc79952..c2bd0f76f 100644 --- a/typescript/sdk/src/deploy/middleware/TokenBridgeApp.ts +++ b/typescript/sdk/src/deploy/middleware/LiquidityLayerApp.ts @@ -9,7 +9,7 @@ import { import { HyperlaneApp } from '../../HyperlaneApp'; import { Chains } from '../../consts/chains'; -import { TokenBridgeContracts } from '../../middleware'; +import { LiquidityLayerContracts } from '../../middleware'; import { MultiProvider } from '../../providers/MultiProvider'; import { ChainMap, ChainName } from '../../types'; import { objMap } from '../../utils/objects'; @@ -18,7 +18,7 @@ import { BridgeAdapterConfig, BridgeAdapterType, CircleBridgeAdapterConfig, -} from './TokenBridgeRouterDeployer'; +} from './LiquidityLayerRouterDeployer'; const CircleBridgeInterface = ICircleBridge__factory.createInterface(); const CircleBridgeAdapterInterface = @@ -37,11 +37,11 @@ interface CircleBridgeMessage { domain: number; nonceHash: string; } -export class TokenBridgeApp< +export class LiquidityLayerApp< Chain extends ChainName = ChainName, -> extends HyperlaneApp { +> extends HyperlaneApp { constructor( - public readonly contractsMap: ChainMap, + public readonly contractsMap: ChainMap, public readonly multiProvider: MultiProvider, public readonly bridgeAdapterConfigs: ChainMap< Chain, diff --git a/typescript/sdk/src/deploy/middleware/TokenBridgeRouterDeployer.ts b/typescript/sdk/src/deploy/middleware/LiquidityLayerRouterDeployer.ts similarity index 80% rename from typescript/sdk/src/deploy/middleware/TokenBridgeRouterDeployer.ts rename to typescript/sdk/src/deploy/middleware/LiquidityLayerRouterDeployer.ts index 763b3e43b..9db16e985 100644 --- a/typescript/sdk/src/deploy/middleware/TokenBridgeRouterDeployer.ts +++ b/typescript/sdk/src/deploy/middleware/LiquidityLayerRouterDeployer.ts @@ -3,15 +3,15 @@ import { ethers } from 'ethers'; import { CircleBridgeAdapter, CircleBridgeAdapter__factory, - TokenBridgeRouter, - TokenBridgeRouter__factory, + LiquidityLayerRouter, + LiquidityLayerRouter__factory, } from '@hyperlane-xyz/core'; import { HyperlaneCore } from '../../core/HyperlaneCore'; import { - TokenBridgeContracts, - TokenBridgeFactories, - tokenBridgeFactories, + LiquidityLayerContracts, + LiquidityLayerFactories, + liquidityLayerFactories, } from '../../middleware'; import { MultiProvider } from '../../providers/MultiProvider'; import { ChainMap, ChainName } from '../../types'; @@ -36,31 +36,31 @@ export interface CircleBridgeAdapterConfig { export type BridgeAdapterConfig = CircleBridgeAdapterConfig; -export type TokenBridgeConfig = RouterConfig & { +export type LiquidityLayerConfig = RouterConfig & { bridgeAdapterConfigs: BridgeAdapterConfig[]; }; -export class TokenBridgeDeployer< +export class LiquidityLayerDeployer< Chain extends ChainName, > extends HyperlaneRouterDeployer< Chain, - TokenBridgeConfig, - TokenBridgeContracts, - TokenBridgeFactories + LiquidityLayerConfig, + LiquidityLayerContracts, + LiquidityLayerFactories > { constructor( multiProvider: MultiProvider, - configMap: ChainMap, + configMap: ChainMap, protected core: HyperlaneCore, - protected create2salt = 'TokenBridgeDeployerSalt', + protected create2salt = 'LiquidityLayerDeployerSalt', ) { - super(multiProvider, configMap, tokenBridgeFactories, {}); + super(multiProvider, configMap, liquidityLayerFactories, {}); } async enrollRemoteRouters( - contractsMap: ChainMap, + contractsMap: ChainMap, ): Promise { - // Enroll the TokenBridgeRouter with each other + // Enroll the LiquidityLayerRouter with each other await super.enrollRemoteRouters(contractsMap); // Enroll the circle adapters with each other @@ -75,10 +75,10 @@ export class TokenBridgeDeployer< // If no custom logic is needed, call deployContract for the router async deployContracts( chain: Chain, - config: TokenBridgeConfig, - ): Promise { + config: LiquidityLayerConfig, + ): Promise { const initCalldata = - TokenBridgeRouter__factory.createInterface().encodeFunctionData( + LiquidityLayerRouter__factory.createInterface().encodeFunctionData( 'initialize', [config.owner, config.connectionManager, config.interchainGasPaymaster], ); @@ -87,7 +87,7 @@ export class TokenBridgeDeployer< initCalldata, }); - const bridgeAdapters: Partial = {}; + const bridgeAdapters: Partial = {}; for (const adapterConfig of config.bridgeAdapterConfigs) { if (adapterConfig.type === BridgeAdapterType.Circle) { @@ -111,7 +111,7 @@ export class TokenBridgeDeployer< chain: Chain, adapterConfig: CircleBridgeAdapterConfig, owner: string, - router: TokenBridgeRouter, + router: LiquidityLayerRouter, ): Promise { const cc = this.multiProvider.getChainConnection(chain); const initCalldata = @@ -162,9 +162,9 @@ export class TokenBridgeDeployer< ); } - this.logger('Set CircleTokenBridgeAdapter on Router'); + this.logger('Set CircleLiquidityLayerAdapter on Router'); await cc.handleTx( - router.setTokenBridgeAdapter( + router.setLiquidityLayerAdapter( adapterConfig.type, circleBridgeAdapter.address, ), diff --git a/typescript/sdk/src/index.ts b/typescript/sdk/src/index.ts index bce06f9e2..d148d6e8a 100644 --- a/typescript/sdk/src/index.ts +++ b/typescript/sdk/src/index.ts @@ -121,18 +121,18 @@ export { InterchainQueryDeployer, } from './deploy/middleware/deploy'; export { - TokenBridgeDeployer, + LiquidityLayerDeployer, BridgeAdapterType, BridgeAdapterConfig, CircleBridgeAdapterConfig, -} from './deploy/middleware/TokenBridgeRouterDeployer'; -export { TokenBridgeApp } from './deploy/middleware/TokenBridgeApp'; +} from './deploy/middleware/LiquidityLayerRouterDeployer'; +export { LiquidityLayerApp } from './deploy/middleware/LiquidityLayerApp'; export { - TokenBridgeContracts, + LiquidityLayerContracts, interchainAccountFactories, interchainQueryFactories, - tokenBridgeFactories, + liquidityLayerFactories, } from './middleware'; export { RouterConfig } from './deploy/router/types'; export { getTestMultiProvider, getChainToOwnerMap } from './deploy/utils'; diff --git a/typescript/sdk/src/middleware.ts b/typescript/sdk/src/middleware.ts index 9f8d42eaa..1788da295 100644 --- a/typescript/sdk/src/middleware.ts +++ b/typescript/sdk/src/middleware.ts @@ -5,8 +5,8 @@ import { InterchainAccountRouter__factory, InterchainQueryRouter, InterchainQueryRouter__factory, - TokenBridgeRouter, - TokenBridgeRouter__factory, + LiquidityLayerRouter, + LiquidityLayerRouter__factory, } from '@hyperlane-xyz/core'; import { RouterContracts, RouterFactories } from './router'; @@ -29,15 +29,15 @@ export const interchainQueryFactories: InterchainQueryFactories = { export type InterchainQueryContracts = RouterContracts; -export type TokenBridgeFactories = RouterFactories & { +export type LiquidityLayerFactories = RouterFactories & { circleBridgeAdapter: CircleBridgeAdapter__factory; }; -export const tokenBridgeFactories: TokenBridgeFactories = { - router: new TokenBridgeRouter__factory(), +export const liquidityLayerFactories: LiquidityLayerFactories = { + router: new LiquidityLayerRouter__factory(), circleBridgeAdapter: new CircleBridgeAdapter__factory(), }; -export type TokenBridgeContracts = RouterContracts & { +export type LiquidityLayerContracts = RouterContracts & { circleBridgeAdapter?: CircleBridgeAdapter; }; diff --git a/typescript/sdk/src/middleware/tokenbridge.hardhat-test.ts b/typescript/sdk/src/middleware/liquidity-layer.hardhat-test.ts similarity index 81% rename from typescript/sdk/src/middleware/tokenbridge.hardhat-test.ts rename to typescript/sdk/src/middleware/liquidity-layer.hardhat-test.ts index 318e54085..678bbe265 100644 --- a/typescript/sdk/src/middleware/tokenbridge.hardhat-test.ts +++ b/typescript/sdk/src/middleware/liquidity-layer.hardhat-test.ts @@ -3,46 +3,46 @@ import { expect } from 'chai'; import { ethers } from 'hardhat'; import { + LiquidityLayerRouter, MockCircleBridge, MockCircleBridge__factory, MockCircleMessageTransmitter, MockCircleMessageTransmitter__factory, MockToken, MockToken__factory, - TestTokenBridgeMessageRecipient__factory, - TokenBridgeRouter, + TestLiquidityLayerMessageRecipient__factory, } from '@hyperlane-xyz/core'; import { utils } from '@hyperlane-xyz/utils'; import { testChainConnectionConfigs } from '../consts/chainConnectionConfigs'; import { TestCoreApp } from '../core/TestCoreApp'; import { TestCoreDeployer } from '../core/TestCoreDeployer'; -import { TokenBridgeApp } from '../deploy/middleware/TokenBridgeApp'; +import { LiquidityLayerApp } from '../deploy/middleware/LiquidityLayerApp'; import { BridgeAdapterType, CircleBridgeAdapterConfig, - TokenBridgeConfig, - TokenBridgeDeployer, -} from '../deploy/middleware/TokenBridgeRouterDeployer'; + LiquidityLayerConfig, + LiquidityLayerDeployer, +} from '../deploy/middleware/LiquidityLayerRouterDeployer'; import { getChainToOwnerMap, getTestMultiProvider } from '../deploy/utils'; import { ChainNameToDomainId } from '../domains'; import { MultiProvider } from '../providers/MultiProvider'; import { ChainMap, TestChainNames } from '../types'; import { objMap } from '../utils/objects'; -describe('TokenBridgeRouter', async () => { +describe('LiquidityLayerRouter', async () => { const localChain = 'test1'; const remoteChain = 'test2'; const localDomain = ChainNameToDomainId[localChain]; const remoteDomain = ChainNameToDomainId[remoteChain]; let signer: SignerWithAddress; - let local: TokenBridgeRouter; + let local: LiquidityLayerRouter; let multiProvider: MultiProvider; let coreApp: TestCoreApp; - let tokenBridgeApp: TokenBridgeApp; - let config: ChainMap; + let liquidityLayerApp: LiquidityLayerApp; + let config: ChainMap; let mockToken: MockToken; let circleBridge: MockCircleBridge; let messageTransmitter: MockCircleMessageTransmitter; @@ -94,20 +94,24 @@ describe('TokenBridgeRouter', async () => { }); beforeEach(async () => { - const TokenBridge = new TokenBridgeDeployer(multiProvider, config, coreApp); - const contracts = await TokenBridge.deploy(); + const LiquidityLayer = new LiquidityLayerDeployer( + multiProvider, + config, + coreApp, + ); + const contracts = await LiquidityLayer.deploy(); - tokenBridgeApp = new TokenBridgeApp( + liquidityLayerApp = new LiquidityLayerApp( contracts, multiProvider, objMap(config, (_chain, conf) => conf.bridgeAdapterConfigs), ); - local = tokenBridgeApp.getContracts(localChain).router; + local = liquidityLayerApp.getContracts(localChain).router; }); it('can transfer tokens', async () => { - const recipientF = new TestTokenBridgeMessageRecipient__factory(signer); + const recipientF = new TestLiquidityLayerMessageRecipient__factory(signer); const recipient = await recipientF.deploy(); const amount = 1000; @@ -130,7 +134,7 @@ describe('TokenBridgeRouter', async () => { await messageTransmitter.process( nonceId, - tokenBridgeApp.getContracts(remoteChain).circleBridgeAdapter!.address, + liquidityLayerApp.getContracts(remoteChain).circleBridgeAdapter!.address, amount, ); await coreApp.processMessages();