@matterlabs/hardhat-zksync-deploy
Version:
Hardhat plugin to deploy smart contracts into the ZKsync network
58 lines • 2.93 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deployer = void 0;
const zk = __importStar(require("zksync-ethers"));
const deployer_helper_1 = require("./deployer-helper");
/**
* An entity capable of deploying contracts to the ZKsync network.
*/
class Deployer {
constructor(_hre, zkWallet) {
this._hre = _hre;
// Initalize two providers: one for the Ethereum RPC (layer 1), and one for the ZKsync RPC (layer 2).
const { ethWeb3Provider, zkWeb3Provider } = (0, deployer_helper_1.createProviders)(_hre.config.networks, _hre.network);
const l2Provider = zkWallet.provider === null ? zkWeb3Provider : zkWallet.provider;
this.zkWallet = zkWallet.connect(l2Provider).connectToL1(ethWeb3Provider);
this.ethWallet = this.zkWallet.ethWallet();
}
static fromEthWallet(hre, ethWallet) {
return new Deployer(hre, new zk.Wallet(ethWallet.privateKey));
}
async estimateDeployFee(artifact, constructorArguments) {
return await (0, deployer_helper_1.estimateDeployFee)(this._hre, artifact, constructorArguments, this.zkWallet);
}
async estimateDeployGas(artifact, constructorArguments, deploymentType) {
return await (0, deployer_helper_1.estimateDeployGas)(this._hre, artifact, constructorArguments, this.zkWallet, deploymentType);
}
async loadArtifact(contractNameOrFullyQualifiedName) {
return await (0, deployer_helper_1.loadArtifact)(this._hre, contractNameOrFullyQualifiedName);
}
async deploy(contractNameOrArtifact, constructorArguments = [], deploymentType, overrides, additionalFactoryDeps) {
return await (0, deployer_helper_1.deploy)(this._hre, contractNameOrArtifact, constructorArguments, this.zkWallet, deploymentType, overrides, additionalFactoryDeps);
}
}
exports.Deployer = Deployer;
//# sourceMappingURL=deployer.js.map