UNPKG

@solarity/hardhat-migrate

Version:
81 lines 6.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArtifactStorage = exports.VerificationStorage = exports.TransactionStorage = exports.UserStorage = exports.Reporter = exports.Deployer = void 0; const task_names_1 = require("hardhat/builtin-tasks/task-names"); const config_1 = require("hardhat/config"); require("./type-extensions"); const config_2 = require("./config"); const constants_1 = require("./constants"); const MigrateStorage_1 = require("./tools/storage/MigrateStorage"); const VerificationProcessor_1 = require("./tools/storage/VerificationProcessor"); const Migrator_1 = require("./migrator/Migrator"); const Verifier_1 = require("./verifier/Verifier"); var Deployer_1 = require("./deployer/Deployer"); Object.defineProperty(exports, "Deployer", { enumerable: true, get: function () { return Deployer_1.Deployer; } }); var PublicReporter_1 = require("./tools/reporters/PublicReporter"); Object.defineProperty(exports, "Reporter", { enumerable: true, get: function () { return PublicReporter_1.PublicReporter; } }); var MigrateStorage_2 = require("./tools/storage/MigrateStorage"); Object.defineProperty(exports, "UserStorage", { enumerable: true, get: function () { return MigrateStorage_2.UserStorage; } }); Object.defineProperty(exports, "TransactionStorage", { enumerable: true, get: function () { return MigrateStorage_2.TransactionStorage; } }); Object.defineProperty(exports, "VerificationStorage", { enumerable: true, get: function () { return MigrateStorage_2.VerificationStorage; } }); Object.defineProperty(exports, "ArtifactStorage", { enumerable: true, get: function () { return MigrateStorage_2.ArtifactStorage; } }); (0, config_1.extendConfig)(config_2.migrateConfigExtender); const migrate = async (taskArgs, env) => { env.config.migrate = (0, config_2.mergeConfigs)((0, config_2.convertFlatToNested)(taskArgs), env.config.migrate); (0, config_2.validateConfig)(env.config.migrate); await env.run(task_names_1.TASK_COMPILE, { quiet: true, force: env.config.migrate.execution.force, }); await Migrator_1.Migrator.buildMigrateTaskDeps(env); await new Migrator_1.Migrator(env).migrate(); if (env.config.migrate.verification.verify) { await runMigrateVerify(env, {}); } }; const migrateVerify = async (taskArgs, env) => { await runMigrateVerify(env, taskArgs, true); }; async function runMigrateVerify(env, taskArgs, standalone = false) { const config = (0, config_2.extendVerifyConfigs)(taskArgs); await Verifier_1.Verifier.buildVerifierTaskDeps(env); await new Verifier_1.Verifier(env, config, standalone).verifyBatch(VerificationProcessor_1.VerificationProcessor.restoreSavedVerificationFunctions(config.inputFile)); } (0, config_1.task)(task_names_1.TASK_CLEAN, "Clears the cache and deletes all artifacts").setAction(async (conf, hre, runSuper) => { MigrateStorage_1.DefaultStorage.deleteStateFile(); await runSuper(); }); (0, config_1.task)(constants_1.TASK_MIGRATE, "Deploy contracts via migration files") // Filter params .addOptionalParam("from", "The migration number from which the migration will be applied.", undefined, config_1.types.int) .addOptionalParam("to", "The migration number up to which the migration will be applied.", undefined, config_1.types.int) .addOptionalParam("only", "The number of the migration that will be applied. Overrides from and to parameters.", undefined, config_1.types.int) .addOptionalParam("skip", "The number of migration to skip. Overrides only parameter.", undefined, config_1.types.int) // Execution params .addOptionalParam("wait", "The number of blocks to wait for the transaction to be mined.", undefined, config_1.types.int) .addFlag("force", "The flag indicating whether the compilation is forced.") .addFlag("continue", "The flag indicating whether the previous deployment should be continued.") // Verification params .addOptionalParam("verificationDelay", "The time in milliseconds to wait before the verification process starts.", undefined, config_1.types.int) .addFlag("verify", "The flag indicating whether the contracts should be verified.") .addOptionalParam("verifyParallel", "The size of the batch for verification.", undefined, config_1.types.int) .addOptionalParam("verifyAttempts", "The number of attempts to verify the contract.", undefined, config_1.types.int) // Path params .addOptionalParam("pathToMigrations", "The path to the folder with the specified migrations.", undefined, config_1.types.string) .addOptionalParam("namespace", "The path to the folder where the migration should be done.", undefined, config_1.types.string) // Cast wallet params .addOptionalParam("passwordFile", "File path to the keystore password", undefined, config_1.types.string) .addOptionalParam("keystore", "Use a keystore file or directory", undefined, config_1.types.string) .addOptionalParam("account", "The name of the cast wallet account (when using the default keystore directory)", undefined, config_1.types.string) // Trezor wallet params .addFlag("trezorEnabled", "Enable Trezor hardware wallet for signing transactions") .addOptionalParam("trezorMnemonicIndex", "The mnemonic index for Trezor wallet", undefined, config_1.types.int) .addOptionalParam("reportPath", "The path to directory where the migration report should be saved", undefined, config_1.types.string) .addOptionalParam("reportFormat", "The format of the migration report (json or md)", "md", config_1.types.string) .setAction(migrate); (0, config_1.task)(constants_1.TASK_MIGRATE_VERIFY, "Verify contracts via .storage") .addOptionalParam("inputFile", "The path to the .storage file.", undefined, config_1.types.inputFile) .addOptionalParam("parallel", "The size of the batch for verification.", undefined, config_1.types.int) .addOptionalParam("attempts", "The number of attempts to verify the contract.", undefined, config_1.types.int) .setAction(migrateVerify); //# sourceMappingURL=index.js.map