Skip to content

Commit

Permalink
Merge pull request omurovec#17 from shafu0x/main
Browse files Browse the repository at this point in the history
natspec
  • Loading branch information
omurovec authored Apr 6, 2023
2 parents 87e8545 + 60f7e12 commit 08b8b05
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
9 changes: 6 additions & 3 deletions script/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "era-contracts/ethereum/contracts/zksync/interfaces/IMailbox.sol";
import "era-contracts/ethereum/contracts/common/L2ContractAddresses.sol";
import "era-contracts/ethereum/contracts/common/libraries/L2ContractHelper.sol";
import "era-contracts/zksync/contracts/vendor/AddressAliasHelper.sol";
import "./interfaces/IDeployer.sol";

import {
L2_TX_MAX_GAS_LIMIT,
Expand All @@ -20,7 +21,7 @@ interface IContractDeployer {
function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input) external;
}

contract Deployer {
contract Deployer is IDeployer {
using strings for *;

VmSafe _vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Expand All @@ -40,15 +41,17 @@ contract Deployer {
constructor(string memory _zksolcVersion, address _diamondProxy) {
///@notice install bin compiler
projectRoot = _vm.projectRoot();
zksolcPath = _installCompiler(_zksolcVersion);
zksolcPath = _downloadCompiler(_zksolcVersion);

diamondProxy = _diamondProxy;
}

/// @inheritdoc IDeployer
function deployFromL1(string memory fileName, bytes calldata params, bytes32 salt) public returns (address) {
return deployFromL1(fileName, params, salt, L2_TX_MAX_GAS_LIMIT, DEFAULT_L2_GAS_PRICE_PER_PUBDATA);
}

/// @inheritdoc IDeployer
function deployFromL1(
string memory fileName,
bytes calldata params,
Expand Down Expand Up @@ -136,7 +139,7 @@ contract Deployer {
}

///@notice Ensure correct compiler bin is installed
function _installCompiler(string memory version) internal returns (string memory path) {
function _downloadCompiler(string memory version) internal returns (string memory path) {
SystemInfo memory systemInfo = _detectSystemInfo();

///@notice Construct urls/paths
Expand Down
39 changes: 39 additions & 0 deletions script/interfaces/IDeployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.13;

interface IDeployer {
/**
* @dev Deploys a contract from L1 to L2 using default gas limit and gas per
pubdata byte values.
* @param fileName The name of the Solidity file containing the contract code
to be compiled.
* @param params The initialization parameters for the contract.
* @param salt A unique salt value used to derive the contract's address.
* @return The deployed contract's address.
*/
function deployFromL1(
string memory fileName,
bytes calldata params,
bytes32 salt
) external returns (address);

/**
* @dev Deploys a contract from L1 to L2.
* @param fileName The name of the Solidity file containing the contract code
to be compiled.
* @param params The initialization parameters for the contract.
* @param salt A unique salt value used to derive the contract's address.
* @param gasLimit The maximum amount of gas to be used for the L2 deployment
transaction.
* @param l2GasPerPubdataByteLimit The maximum amount of gas to be used per
pubdata byte.
* @return The deployed contract's address.
*/
function deployFromL1(
string memory fileName,
bytes calldata params,
bytes32 salt,
uint256 gasLimit,
uint256 l2GasPerPubdataByteLimit
) external returns (address);
}

0 comments on commit 08b8b05

Please sign in to comment.