diff --git a/src/factory/ImmutableMultiChainDeployer.sol b/src/factory/ImmutableMultiChainDeployer.sol index ca3d0c4..bf7bb84 100644 --- a/src/factory/ImmutableMultiChainDeployer.sol +++ b/src/factory/ImmutableMultiChainDeployer.sol @@ -8,6 +8,7 @@ import {RateLimiter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/utils/Ra import {IImmutableMultiChainDeployer} from "@interfaces/IImmutableMultiChainDeployer.sol"; import {L2YnOFTAdapterUpgradeable} from "@adapters/L2YnOFTAdapterUpgradeable.sol"; import {L2YnERC20Upgradeable} from "@adapters/L2YnERC20Upgradeable.sol"; +import "forge-std/console.sol"; contract ImmutableMultiChainDeployer is IImmutableMultiChainDeployer { event ContractCreated(address deployedAddress); @@ -67,11 +68,11 @@ contract ImmutableMultiChainDeployer is IImmutableMultiChainDeployer { address _lzEndpoint, address _owner, RateLimiter.RateLimitConfig[] calldata _rateLimitConfigs, - address _proxyController + address _proxyController, + bytes memory _l2YnOFTAdapterBytecode ) public returns (address _deployedContract) { - bytes memory bytecode = type(L2YnOFTAdapterUpgradeable).creationCode; bytes memory constructorParams = abi.encode(_token, _lzEndpoint); - bytes memory contractCode = abi.encodePacked(bytecode, constructorParams); + bytes memory contractCode = abi.encodePacked(_l2YnOFTAdapterBytecode, constructorParams); address adapterImpl = deploy(_implSalt, contractCode); _deployedContract = deployProxy(_proxySalt, adapterImpl, _proxyController); @@ -85,9 +86,10 @@ contract ImmutableMultiChainDeployer is IImmutableMultiChainDeployer { string memory _name, string memory _symbol, address _owner, - address _proxyController + address _proxyController, + bytes memory _l2YnERC20UpgradeableByteCode ) public returns (address _deployedContract) { - address adapterImpl = deploy(_implSalt, type(L2YnERC20Upgradeable).creationCode); + address adapterImpl = deploy(_implSalt, _l2YnERC20UpgradeableByteCode); _deployedContract = deployProxy(_proxySalt, adapterImpl, _proxyController); L2YnERC20Upgradeable(_deployedContract).initialize(_name, _symbol, _owner); } diff --git a/src/interfaces/IImmutableMultiChainDeployer.sol b/src/interfaces/IImmutableMultiChainDeployer.sol index cca3a8d..32dfe74 100644 --- a/src/interfaces/IImmutableMultiChainDeployer.sol +++ b/src/interfaces/IImmutableMultiChainDeployer.sol @@ -31,7 +31,8 @@ interface IImmutableMultiChainDeployer { address _lzEndpoint, address _owner, RateLimiter.RateLimitConfig[] calldata _rateLimitConfigs, - address _proxyController + address _proxyController, + bytes memory _l2YnOFTAdapterBytecode ) external returns (address deployed); /// @notice Deploys a deployYnERC20 contract using CREATE3 and initializes in the same call @@ -49,7 +50,8 @@ interface IImmutableMultiChainDeployer { string memory _name, string memory _symbol, address _owner, - address _proxyController + address _proxyController, + bytes memory _l2YnOFTAdapterBytecode ) external returns (address deployed); /// @notice Predicts the address of a deployed contract diff --git a/test/CrossChainBaseTest.t.sol b/test/CrossChainBaseTest.t.sol index c623b85..8bb2289 100644 --- a/test/CrossChainBaseTest.t.sol +++ b/test/CrossChainBaseTest.t.sol @@ -35,6 +35,10 @@ contract CrossChainBaseTest is TestHelper { L2YnERC20Upgradeable public optimismERC20; L2YnERC20Upgradeable public arbitrumERC20; + bytes public l2YnOFTAdapterByteCode = type(L2YnOFTAdapterUpgradeable).creationCode; + bytes public l1YnOFTAdapterByteCode = type(L1YnOFTAdapterUpgradeable).creationCode; + bytes public l2YnERC20ByteCode = type(L2YnERC20Upgradeable).creationCode; + address mainnetOFTAdapterImpl; uint256 optimismFork; @@ -86,7 +90,13 @@ contract CrossChainBaseTest is TestHelper { bytes32 optimismERC20ProxySalt = createSalt(_deployer, "ERC20Proxy"); optimismERC20 = L2YnERC20Upgradeable( optimismDeployer.deployL2YnERC20( - optimismERC20Salt, optimismERC20ProxySalt, "Test Token", "TEST", _owner, _controller + optimismERC20Salt, + optimismERC20ProxySalt, + "Test Token", + "TEST", + _owner, + _controller, + l2YnERC20ByteCode ) ); bytes32 optimismOFTAdapterSalt = createSalt(_deployer, "OFTAdapter"); @@ -99,7 +109,8 @@ contract CrossChainBaseTest is TestHelper { address(optimismLzEndpoint), _owner, _rateLimitConfigs, - _controller + _controller, + l2YnOFTAdapterByteCode ) ); } @@ -111,7 +122,13 @@ contract CrossChainBaseTest is TestHelper { bytes32 arbitrumERC20ProxySalt = createSalt(_deployer, "ERC20Proxy"); arbitrumERC20 = L2YnERC20Upgradeable( arbitrumDeployer.deployL2YnERC20( - arbitrumERC20Salt, arbitrumERC20ProxySalt, "Test Token", "TEST", _owner, _controller + arbitrumERC20Salt, + arbitrumERC20ProxySalt, + "Test Token", + "TEST", + _owner, + _controller, + l2YnERC20ByteCode ) ); bytes32 arbitrumOFTAdapterSalt = createSalt(_deployer, "OFTAdapter"); @@ -124,7 +141,8 @@ contract CrossChainBaseTest is TestHelper { address(arbitrumLzEndpoint), _owner, _rateLimitConfigs, - _controller + _controller, + l2YnOFTAdapterByteCode ) ); } diff --git a/test/MultiChainDeployer.t.sol b/test/MultiChainDeployer.t.sol index 6328a67..c9aaec7 100644 --- a/test/MultiChainDeployer.t.sol +++ b/test/MultiChainDeployer.t.sol @@ -35,7 +35,8 @@ contract Test_ImmutableMultiChainDeployer is CrossChainBaseTest { address(arbitrumLzEndpoint), _owner, _rateLimitConfigs, - _controller + _controller, + l2YnOFTAdapterByteCode ) ); }