UNPKG

@newos/cli

Version:
47 lines 2.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = require("lodash"); const transpiler_1 = require("../transpiler"); const Compiler_1 = require("../models/compiler/Compiler"); const ProjectFile_1 = __importDefault(require("../models/files/ProjectFile")); const NetworkController_1 = __importDefault(require("../models/network/NetworkController")); const naming_1 = require("../utils/naming"); const Dependency_1 = __importDefault(require("../models/dependency/Dependency")); async function push({ contracts, network, deployDependencies, deployProxyAdmin, deployProxyFactory, reupload = false, force = false, txParams = {}, networkFile, }) { if (!contracts || contracts.length === 0) { if (!!networkFile) { contracts = networkFile.projectFile.contracts; } else { contracts = new ProjectFile_1.default().contracts; } } const depsContracts = deployDependencies ? lodash_1.flatten(lodash_1.map(new ProjectFile_1.default().dependencies, (version, dep) => new Dependency_1.default(dep, version).projectFile.contracts)) : []; if (!!depsContracts.length || !!contracts.length) { // Transpile contract to upgradeable version and save it in contracts folder. await transpiler_1.transpileAndSave([...contracts, ...depsContracts]); // Compile new contracts. await Compiler_1.compile(undefined, undefined, true); } const controller = new NetworkController_1.default(network, txParams, networkFile); try { if (deployDependencies) await controller.deployDependencies(); if (deployProxyAdmin) await controller.deployProxyAdmin(); if (deployProxyFactory) await controller.deployProxyFactory(); const projectContracts = contracts === null || contracts === void 0 ? void 0 : contracts.map(naming_1.fromContractFullName).filter(({ package: packageName }) => packageName === undefined || packageName === controller.projectFile.name).map(({ contractName }) => contractName); await controller.push(projectContracts, { reupload, force }); } finally { controller.writeNetworkPackageIfNeeded(); } } exports.default = push; //# sourceMappingURL=push.js.map