UNPKG

truffle

Version:

Truffle - Simple development framework for Ethereum

1,556 lines (1,316 loc) 57.4 kB
#!/usr/bin/env node /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 76463: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { module.exports = { run: __webpack_require__(30999), meta: __webpack_require__(42285) }; /***/ }), /***/ 42285: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const OS = __webpack_require__(22037); module.exports = { command: "debug", description: "Interactively debug any transaction on the blockchain", builder: { "url": { describe: "Use specified URL for provider", type: "string" }, "_": { type: "string" }, "fetch-external": { describe: "Allow debugging of external contracts", alias: "x", type: "boolean", default: false }, "compile-tests": { describe: "Allow debugging of Solidity test contracts", type: "boolean", default: false }, "compile-all": { describe: "Force debugger to compile all contracts for extra safety", type: "boolean", default: false }, "compile-none": { describe: "Force debugger to skip compilation (dangerous!)", type: "boolean", default: false }, "no-ens": { describe: "Turns off ens reverse resolution", type: "boolean", default: false }, "registry": { describe: "Allows setting a custom address for the ENS registry", type: "string" } }, help: { usage: "truffle debug [<transaction_hash>] [--fetch-external|-x]" + OS.EOL + " [--network <network>|--url <provider_url>]" + OS.EOL + " [--no-ens|--registry <registry_address>]" + OS.EOL + " [--compile-tests|--compile-all|--compile-none]", options: [ { option: "<transaction_hash>", description: "Transaction ID to use for debugging. Mandatory if --fetch-external is passed." }, { option: "--fetch-external|-x", description: "Allows debugging of external contracts with verified sources." }, { option: "--network", description: "The network to connect to, as specified in the Truffle config." }, { option: "--url", description: "Connects to a specified provider given via URL, ignoring networks in config. This option allows using the debugger outside of a Truffle project." }, { option: "--no-ens", description: "Disables ENS reverse resolution when decoding addresses." }, { option: "--registry", description: "Allows setting a custom registry for performing reverse ENS resolution, or setting such a registry at all on lesser-known networks." }, { option: "--compile-tests", description: "Allows debugging of Solidity test contracts from the test directory. Implies --compile-all." }, { option: "--compile-all", description: "Forces the debugger to recompile all contracts even if it detects that it can use the artifacts." }, { option: "--compile-none", description: "Forces the debugger to use artifacts even if it detects a problem. Dangerous; may cause errors." } ], allowedGlobalOptions: ["config"] //although network is an allowed global option, it isn't listed here because listing it here would cause //it to be tacked on to the end of usage, which would prevent us from doing the thing above where we //combine its usage instructions with url to show that they're mutually exclusive. so as a workaround //we've excluded network from here, and added it manually above. } }; /***/ }), /***/ 30999: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { module.exports = async function (options) { const OS = __webpack_require__(22037); const { promisify } = __webpack_require__(73837); const loadConfig = __webpack_require__(932); const { Environment } = __webpack_require__(76765); const FromHardhat = __webpack_require__(36052); const Codec = __webpack_require__(20102); const TruffleError = __webpack_require__(73321); const { CLIDebugger } = __webpack_require__(9941); const { utils: Web3Utils } = __webpack_require__(3283); if (options.url && options.network) { const message = "" + "Mutually exclusive options, --url and --network detected!" + OS.EOL + "Please use either --url or --network and try again." + OS.EOL + "See: https://trufflesuite.com/docs/truffle/reference/truffle-commands/#debug" + OS.EOL; throw new TruffleError(message); } if (options.registry && options.noEns) { throw new TruffleError( "The --no-ens options and --registry options are mutually exclusive; please remove one and try again." ); } if (options.registry) { if (!Web3Utils.isAddress(options.registry)) { throw new TruffleError( "The specified registry is not a valid address. It may have an incorrect checksum or be otherwise invalid." ); } } let config; let compilations; try { config = loadConfig(options); } catch (configError) { // if we can't load config, check to see if this is a hardhat project try { await FromHardhat.expectHardhat(); config = await FromHardhat.prepareConfig(); config.merge(options); compilations = Codec.Compilations.Utils.shimCompilations( await FromHardhat.prepareCompilations() ); } catch (hardhatError) { // if it's not a hardhat project, throw the original error // otherwise, throw whatever error we got when process hardhat const error = hardhatError instanceof FromHardhat.NotHardhatError ? configError : hardhatError; throw error; } } await Environment.detect(config); const txHash = config._[0]; //may be undefined if (config.fetchExternal && txHash === undefined) { throw new Error( "Fetch-external mode requires a specific transaction to debug" ); } if (config.compileTests) { config.compileAll = true; } if (config.compileAll && config.compileNone) { throw new Error("Incompatible options passed regarding what to compile"); } const interpreter = await new CLIDebugger(config, { txHash, compilations }).run(); return await promisify(interpreter.start.bind(interpreter))(); }; /***/ }), /***/ 9941: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { CLIDebugger } = __webpack_require__(458); module.exports = { CLIDebugger }; /***/ }), /***/ 932: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { module.exports = function (options) { const Config = __webpack_require__(20553); const TruffleError = __webpack_require__(73321); const mergeConfigNetwork = __webpack_require__(22173); let config; try { config = Config.detect(options); config = mergeConfigNetwork(config, options); } catch (error) { if (error instanceof TruffleError && options.url) { config = Config.default(); config = mergeConfigNetwork(config, options); // in case config file is not detected (exception thrown) AND url is provided in the options, // We use default config and set compileNone to true. Since there are is no config files and url is provided, // It is assumed that truffle debug/console is being used for analysis and debugging and that there is nothing to compile. // E.g. analysing/debugging a single transaction of an external project config.compileNone = true; config.configFileSkipped = true; } else { throw error; } } return config; }; /***/ }), /***/ 22173: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { URL } = __webpack_require__(57310); module.exports = function (config, options) { if (options.url) { const url = new URL(options.url); config.networks[url.host] = { url: options.url, network_id: "*" }; config.network = url.host; } config.merge(options); return config; }; /***/ }), /***/ 95614: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const Config = __webpack_require__(20553); const analytics = { send: function(eventObject) { const userConfig = Config.getUserConfig(); if (!userConfig.get("enableAnalytics")) { // don't bother with creating a new process if we already // know the user doesn't want to send analytics return; } let analyticsPath; const path = __webpack_require__(71017); if (true) { analyticsPath = path.join(__dirname, "analytics.bundled.js"); } else {} const cp = __webpack_require__(32081); const child = cp.fork(analyticsPath, { silent: true }); child.send(eventObject); } }; module.exports = analytics; /***/ }), /***/ 86927: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { IPC } = __webpack_require__(39813); const path = __webpack_require__(71017); const { spawn } = __webpack_require__(32081); const debug = __webpack_require__(15158); const chalk = __webpack_require__(34061); const Develop = { start: async function (ipcNetwork, ganacheOptions = {}) { let chainPath; // The path to the dev env process depends on whether or not // we're running in the bundled version. If not, use chain.js // directly, otherwise let the bundle point at the bundled version. if (true) { // Remember: In the bundled version, __dirname refers to the // build directory where cli.bundled.js and cli.chain.js live. chainPath = path.join(__dirname, "chain.bundled.js"); } else {} const logger = ganacheOptions.logger || console; //check that genesis-time config option passed through the //truffle-config.js file is a valid time. if (ganacheOptions.time && isNaN(Date.parse(ganacheOptions.time))) { ganacheOptions.time = Date.now(); logger.log( "\x1b[31m%s\x1b[0m", "Invalid Date passed to genesis-time, using current Date instead", "\x1b[0m" ); } const stringifiedOptions = JSON.stringify(ganacheOptions); const optionsBuffer = Buffer.from(stringifiedOptions); const base64OptionsString = optionsBuffer.toString("base64"); return spawn("node", [chainPath, ipcNetwork, base64OptionsString], { detached: true, stdio: "ignore" }); }, /** * Connect to an existing Ganache server or start a new one. * @param {object} options * @param {object} options.ipcOptions - options for IPC connection * @param {boolean} options.ipcOptions.log - whether to log IPC messages. Defaults to false. * @param {string} options.ipcOptions.network - network name. Defaults to "develop". * @param {boolean} options.ipcOptions.retry - whether to retry connection. Defaults to false. * @param {string} options.solidityLogDisplayPrefix - prefix to display before solidity log messages. Defaults to "". * @returns {Promise<(): void>} - IPC disconnection function. */ connect: function ({ ipcOptions, solidityLogDisplayPrefix }) { const debugServer = debug("develop:ipc:server"); const debugClient = debug("develop:ipc:client"); const debugRPC = debug("develop:ganache"); const ganacheColor = { hex: "#ffaf5f", // ganache's color in hex xterm: 215 // Xterm's number equivalent }; debugRPC.color = ganacheColor.xterm; ipcOptions.retry = ipcOptions.retry || false; ipcOptions.log = ipcOptions.log || false; ipcOptions.network = ipcOptions.network || "develop"; solidityLogDisplayPrefix = solidityLogDisplayPrefix || ""; var ipcNetwork = ipcOptions.network; var ipc = new IPC(); ipc.config.appspace = "truffle."; // set connectPath explicitly var dirname = ipc.config.socketRoot; var basename = `${ipc.config.appspace}${ipcNetwork}`; var connectPath = path.join(dirname, basename); var loggers = {}; ipc.config.silent = !debugClient.enabled; ipc.config.logger = debugClient; const sanitizeAndCallFn = fn => (...args) => { // HACK-y: replace `{}` that is getting logged instead of "" if ( args.length === 1 && typeof args[0] === "object" && Object.keys(args[0]).length === 0 ) { args[0] = ""; } fn.apply(undefined, args); }; if (debugServer.enabled) { loggers.ipc = debugServer; } // create a logger to present Ganache's console log messages const createSolidityLogger = prefix => { return maybeMultipleLines => maybeMultipleLines.split("\n").forEach( // decorate each line's prefix. line => console.log(chalk.hex(ganacheColor.hex)(` ${prefix}`), line) ); }; // enable output/logger for solidity console.log loggers.solidity = sanitizeAndCallFn( createSolidityLogger(solidityLogDisplayPrefix) ); if (ipcOptions.log) { debugRPC.enabled = true; loggers.ganache = sanitizeAndCallFn(debugRPC); } if (!ipcOptions.retry) { ipc.config.maxRetries = 0; } var disconnect = function () { ipc.disconnect(ipcNetwork); }; return new Promise((resolve, reject) => { ipc.connectTo(ipcNetwork, connectPath, function () { ipc.of[ipcNetwork].on("destroy", function () { reject(new Error("IPC connection destroyed")); }); ipc.of[ipcNetwork].on("truffle.ready", function () { resolve(disconnect); }); Object.keys(loggers).forEach(function (key) { var log = loggers[key]; if (log) { var message = `truffle.${key}.log`; ipc.of[ipcNetwork].on(message, log); } }); }); }); }, /** * Connect to a managed Ganache service. This will connect to an existing * Ganache service if one exists, or, create a new one to connect to. * * @param {Object} ipcOptions - IPC connection options. * @param {string} ipcOptions.network - the network name. * @param {Object} ganacheOptions - Ganache options if service is necessary. * @param {string} solidityLogDisplayPrefix - solidity log messages prefix. * @returns {Promise<Object>} - object with `disconnect` function and * `started` boolean. The `disconnect` function is used to disconnect * from the Ganache service. The `started` boolean is true if a new * Ganache service was started, false otherwise. */ connectOrStart: async function ( ipcOptions, ganacheOptions, solidityLogDisplayPrefix = "" ) { ipcOptions.retry = false; const ipcNetwork = ipcOptions.network || "develop"; let started = false; let disconnect; try { disconnect = await this.connect({ ipcOptions, solidityLogDisplayPrefix }); } catch (_error) { await this.start(ipcNetwork, ganacheOptions); ipcOptions.retry = true; disconnect = await this.connect({ ipcOptions, solidityLogDisplayPrefix }); started = true; } finally { return { disconnect, started }; } } }; module.exports = Develop; /***/ }), /***/ 53234: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const Web3 = __webpack_require__(3283); const { createInterfaceAdapter } = __webpack_require__(36339); const expect = __webpack_require__(14096); const TruffleError = __webpack_require__(73321); const { Resolver } = __webpack_require__(48511); const Artifactor = __webpack_require__(29463); const Ganache = __webpack_require__(11651); const Provider = __webpack_require__(509); const Environment = { // It's important config is a Config object and not a vanilla object detect: async function (config) { expect.options(config, ["networks"]); helpers.setUpConfig(config); helpers.validateNetworkConfig(config); const interfaceAdapter = createInterfaceAdapter({ provider: config.provider, networkType: config.network_config.type }); await Provider.testConnection(config); await helpers.detectAndSetNetworkId(config, interfaceAdapter); await helpers.setFromOnConfig(config, interfaceAdapter); }, // Ensure you call Environment.detect() first. fork: async function (config, ganacheOptions) { expect.options(config, ["from", "provider", "networks", "network"]); const interfaceAdapter = createInterfaceAdapter({ provider: config.provider, networkType: config.network_config.type }); let accounts; try { accounts = await interfaceAdapter.getAccounts(); } catch { // don't prevent Truffle from working if user doesn't provide some way // to sign transactions (e.g. no reason to disallow debugging) accounts = []; } const block = await interfaceAdapter.getBlock("latest"); const upstreamNetwork = config.network; const upstreamConfig = config.networks[upstreamNetwork]; const forkedNetwork = config.network + "-fork"; ganacheOptions = { ...ganacheOptions, fork: config.provider, miner: { ...ganacheOptions.miner, blockGasLimit: block.gasLimit } }; if (accounts.length > 0) ganacheOptions.unlocked_accounts = accounts; config.networks[forkedNetwork] = { network_id: config.network_id, provider: Ganache.provider(ganacheOptions), from: config.from, gas: upstreamConfig.gas, gasPrice: upstreamConfig.gasPrice }; config.network = forkedNetwork; }, develop: async (config, ganacheOptions) => { expect.options(config, ["networks"]); const network = config.network || "develop"; const url = `http://${ganacheOptions.host}:${ganacheOptions.port}/`; config.networks[network] = { ...config.networks[network], network_id: ganacheOptions.network_id, provider: function () { return new Web3.providers.HttpProvider(url, { keepAlive: false }); } }; config.network = network; return await Environment.detect(config); } }; const helpers = { setFromOnConfig: async (config, interfaceAdapter) => { if (config.from) return; try { const accounts = await interfaceAdapter.getAccounts(); config.networks[config.network].from = accounts[0]; } catch { // don't prevent Truffle from working if user doesn't provide some way // to sign transactions (e.g. no reason to disallow debugging) } }, detectAndSetNetworkId: async (config, interfaceAdapter) => { const configNetworkId = config.networks[config.network].network_id; const providerNetworkId = await interfaceAdapter.getNetworkId(); if (configNetworkId !== "*") { // Ensure the network id matches the one in the config for safety if (providerNetworkId.toString() !== configNetworkId.toString()) { const error = `The network id specified in the truffle config ` + `(${configNetworkId}) does not match the one returned by the network ` + `(${providerNetworkId}). Ensure that both the network and the ` + `provider are properly configured.`; throw new Error(error); } } else { // We have a "*" network. Get the current network and replace it with the real one. // TODO: Should we replace this with the blockchain uri? config.networks[config.network].network_id = providerNetworkId; } }, validateNetworkConfig: config => { const networkConfig = config.network_config; if (!networkConfig) { throw new TruffleError( `Unknown network "${config.network}` + `". See your Truffle configuration file for available networks.` ); } const configNetworkId = config.network_config.network_id; if (configNetworkId == null) { throw new Error( `You must specify a network_id in your '` + `${config.network}' configuration in order to use this network.` ); } }, setUpConfig: config => { if (!config.resolver) { config.resolver = new Resolver(config); } if (!config.artifactor) { config.artifactor = new Artifactor(config.contracts_build_directory); } if (!config.network) { if (config.networks["development"]) { config.network = "development"; } else { config.network = "ganache"; config.networks[config.network] = { host: "127.0.0.1", port: 7545, network_id: 5777 }; } } const currentNetworkSettings = config.networks[config.network]; if ( currentNetworkSettings && currentNetworkSettings.ens && currentNetworkSettings.ens.registry ) { config.ens.registryAddress = currentNetworkSettings.ens.registry.address; } } }; module.exports = Environment; /***/ }), /***/ 76765: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const Environment = __webpack_require__(53234); const Develop = __webpack_require__(86927); module.exports = { Environment, Develop }; /***/ }), /***/ 32007: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; 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; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.IncompatibleHardhatBuildInfoFormatError = exports.prepareCompilations = exports.prepareConfig = exports.IncompatibleHardhatVersionError = exports.NotHardhatError = exports.expectHardhat = void 0; const fs_1 = __webpack_require__(57147); const semver_1 = __importDefault(__webpack_require__(81249)); const constants_1 = __webpack_require__(65716); const Compilation = __importStar(__webpack_require__(20897)); const Config = __importStar(__webpack_require__(35783)); const ask_hardhat_1 = __webpack_require__(21700); /** * Checks for the existence of a Hardhat project configuration and asserts * that the local installed version of Hardhat matches this package's * supported version range. * * @param options to control process environment (e.g. working directory) * @return Promise<void> when expectation holds * @throws NotHardhatError when not in a Hardhat project directory * @throws IncompatibleHardhatError if Hardhat has unsupported version */ const expectHardhat = (options) => __awaiter(void 0, void 0, void 0, function* () { const isHardhat = yield (0, ask_hardhat_1.checkHardhat)(options); if (!isHardhat) { throw new NotHardhatError(); } const hardhatVersion = yield (0, ask_hardhat_1.askHardhatVersion)(options); if (!semver_1.default.satisfies(hardhatVersion, constants_1.supportedHardhatVersionRange)) { throw new IncompatibleHardhatVersionError(hardhatVersion); } }); exports.expectHardhat = expectHardhat; /** * Thrown when no Hardhat project is found */ class NotHardhatError extends Error { constructor() { super("Current working directory is not part of a Hardhat project"); } } exports.NotHardhatError = NotHardhatError; /** * Thrown when Hardhat was detected but with an incompatible version */ class IncompatibleHardhatVersionError extends Error { constructor(detectedVersion) { super(`Expected Hardhat version compatible with ${constants_1.supportedHardhatVersionRange}, got: ${detectedVersion}`); } } exports.IncompatibleHardhatVersionError = IncompatibleHardhatVersionError; /** * Constructs a @truffle/config object based on the Hardhat config. * * WARNING: except for fields documented here, the values present on the * returned @truffle/config object MUST be regarded as unsafe to use. * * The returned `config` is defined to contain the following: * * - `config.networks` with configurations for all Hardhat-configured * networks, provided: * - The configured network is not the built-in `hardhat` network * - The configured network defines a `url` property * * Note: this function ignores all properties other than `url`, * including any information that can be used for computing * cryptographic signatures. THIS FUNCTION DOES NOT READ PRIVATE KEYS. * * Suffice to say: * * THIS FUNCTION'S BEHAVIOR IS EXPERIMENTAL AND SHOULD ONLY BE USED IN * SPECIFICALLY KNOWN-SUPPORTED USE CASES (like reading for configured * network urls) * * @param options to control process environment (e.g. working directory) * @return Promise<TruffleConfig> * * @dev This function shells out to `npx hardhat console` to ask the Hardhat * runtime environment for the Hardhat config info that Truffle needs. */ const prepareConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { // define a function to grab only the networks and fields we need. // // this duplicates the transformation behavior in src/config.ts for safe // measure, since these two components may differ in requirements in the // future. const extractNetworks = (hre) => ({ networks: Object.entries(hre.config.networks) .filter((pair) => pair[0] !== "hardhat" && "url" in pair[1]) .map(([networkName, { url }]) => ({ [networkName]: { url } })) .reduce((a, b) => (Object.assign(Object.assign({}, a), b)), {}) }); const hardhatConfig = (yield (0, ask_hardhat_1.askHardhatConsole)( // stringify the function hooray `(${extractNetworks.toString()})(hre)`, options)); return Config.fromHardhatConfig(hardhatConfig); }); exports.prepareConfig = prepareConfig; /** * Constructs an array of @truffle/compile-common `Compilation` objects * corresponding one-to-one with Hardhat's persisted results of each solc * compilation. * * WARNING: this function only supports Hardhat projects written entirely * in solc-compatible languages (Solidity, Yul). Behavior of this function * for Hardhat projects using other languages is undefined. * * @param options to control process environment (e.g. working directory) * @return Promise<Compilation[]> from @truffle/compile-common * * @dev This function shells out to `npx hardhat console` to ask the Hardhat * runtime environment for the location of the project build info * files */ const prepareCompilations = (options) => __awaiter(void 0, void 0, void 0, function* () { const compilations = []; const buildInfoPaths = (yield (0, ask_hardhat_1.askHardhatConsole)(`artifacts.getBuildInfoPaths()`, options)); for (const buildInfoPath of buildInfoPaths) { const buildInfo = JSON.parse((yield fs_1.promises.readFile(buildInfoPath)).toString()); const { _format } = buildInfo; if (!constants_1.supportedHardhatBuildInfoFormats.has(_format)) { throw new IncompatibleHardhatBuildInfoFormatError(_format); } const compilation = Compilation.fromBuildInfo(buildInfo); compilations.push(compilation); } return compilations; }); exports.prepareCompilations = prepareCompilations; /** * Thrown when the build-info format detected has an incompatible version */ class IncompatibleHardhatBuildInfoFormatError extends Error { constructor(detectedFormat) { super(`Expected build-info to be one of ["${[ ...constants_1.supportedHardhatBuildInfoFormats ].join('", "')}"], got: "${detectedFormat}"`); } } exports.IncompatibleHardhatBuildInfoFormatError = IncompatibleHardhatBuildInfoFormatError; //# sourceMappingURL=api.js.map /***/ }), /***/ 21700: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.askHardhatConsole = exports.askHardhatVersion = exports.checkHardhat = void 0; const child_process_1 = __webpack_require__(32081); const find_up_1 = __importDefault(__webpack_require__(29859)); const constants_1 = __webpack_require__(65716); const options_1 = __webpack_require__(88504); /** * Returns a Promise to a boolean that is true if and only if * the detected or specified environment is part of a Hardhat project. * * (i.e., if the working directory or any of its parents has a Hardhat config) */ const checkHardhat = (options) => __awaiter(void 0, void 0, void 0, function* () { const { workingDirectory } = (0, options_1.withDefaultEnvironmentOptions)(options); // search recursively up for a hardhat config const hardhatConfigPath = yield (0, find_up_1.default)(constants_1.validHardhatConfigFilenames, { cwd: workingDirectory }); return !!hardhatConfigPath; }); exports.checkHardhat = checkHardhat; /** * Reads version information via `npx hardhat --version` */ const askHardhatVersion = (options) => __awaiter(void 0, void 0, void 0, function* () { return new Promise((accept, reject) => { const { workingDirectory } = (0, options_1.withDefaultEnvironmentOptions)(options); const hardhat = (0, child_process_1.spawn)(`npx`, ["hardhat", "--version"], { stdio: ["pipe", "pipe", "inherit"], cwd: workingDirectory, shell: true }); let output = ""; hardhat.stdout.on("data", data => { output = `${output}${data}`; }); hardhat.once("close", code => { if (code !== 0) { return reject(new Error(`Hardhat exited with non-zero code ${code}`)); } return accept(output); }); }); }); exports.askHardhatVersion = askHardhatVersion; const askHardhatConsole = (expression, _a = {}) => __awaiter(void 0, void 0, void 0, function* () { var { raw = false } = _a, options = __rest(_a, ["raw"]); return new Promise((accept, reject) => { const { workingDirectory } = (0, options_1.withDefaultEnvironmentOptions)(options); // Latin-1 Supplemental block control codes const sos = String.fromCodePoint(0x0098); // start of string const st = String.fromCodePoint(0x009c); // string terminator const prefix = `${sos}truffle-start${st}`; const suffix = `${sos}truffle-end${st}`; // note the hardhat console instance is spawned with --no-compile which causes it to skip the initial (default) compilation step const hardhat = (0, child_process_1.spawn)(`npx`, ["hardhat", "console", "--no-compile"], { stdio: ["pipe", "pipe", "inherit"], cwd: workingDirectory, shell: true }); // we'll capture the stdout let output = ""; hardhat.stdout.on("data", data => { output = `${output}${data}`; }); // setup close event before writing to stdin because we're sending eof hardhat.once("close", code => { if (code !== 0) { return reject(new Error(`Hardhat exited with non-zero code ${code}`)); } const data = output.slice(output.indexOf(prefix) + prefix.length, output.indexOf(suffix)); if (raw) { return accept(data); } try { const result = JSON.parse(data); return accept(result); } catch (error) { return reject(error); } }); // write to stdin to ask for requested data. this does a few things: // - wrap the expression into something that resolves as a Promise. // this ensures that we can handle raw synchronous expressions as well // as Promise-returning expressions. // - write the resolved value to the console, using the prefix/suffix // sentinels to ensure Truffle knows what stdout comes from this process, // vs. whatever stdout Hardhat may produce on its own. // - unless `raw` is turned on, stringify the resolved value as JSON. hardhat.stdin.write(` Promise.resolve(${expression}) .then(${raw ? `(resolved) => console.log( \`${prefix}$\{resolved}${suffix}\` )` : `(resolved) => console.log( \`${prefix}$\{JSON.stringify(resolved)}${suffix}\` )`}) `); hardhat.stdin.end(); }); }); exports.askHardhatConsole = askHardhatConsole; //# sourceMappingURL=ask-hardhat.js.map /***/ }), /***/ 20897: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; 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.fromBuildInfo = void 0; const CompileSolidity = __importStar(__webpack_require__(4273)); const fromBuildInfo = (buildInfo) => { const sourceIndexes = SourceIndexes.fromBuildInfo(buildInfo); return { sourceIndexes, sources: Sources.fromBuildInfo(buildInfo, sourceIndexes), contracts: Contracts.fromBuildInfo(buildInfo), compiler: { name: "solc", version: buildInfo.solcLongVersion } }; }; exports.fromBuildInfo = fromBuildInfo; var SourceIndexes; (function (SourceIndexes) { SourceIndexes.fromBuildInfo = (buildInfo) => { const sourceIndexes = []; for (const { index, sourcePath } of Object.entries(buildInfo.output.sources).map(([sourcePath, source]) => ({ index: source.id, sourcePath }))) { sourceIndexes[index] = sourcePath; } return sourceIndexes; }; })(SourceIndexes || (SourceIndexes = {})); var Sources; (function (Sources) { Sources.fromBuildInfo = (buildInfo, sourceIndexes) => sourceIndexes.map(sourcePath => { const inputSource = buildInfo.input.sources[sourcePath]; const outputSource = buildInfo.output.sources[sourcePath]; return { sourcePath, contents: inputSource.content, ast: outputSource.ast, language: buildInfo.input.language }; }); })(Sources || (Sources = {})); var Contracts; (function (Contracts) { Contracts.fromBuildInfo = (buildInfo) => { const contracts = []; for (const [sourcePath, sourceContracts] of Object.entries(buildInfo.output.contracts)) { for (const [contractName, compilerOutputContract] of Object.entries(sourceContracts)) { const contract = { contractName, sourcePath, source: buildInfo.input.sources[sourcePath].content, sourceMap: compilerOutputContract.evm.bytecode.sourceMap, deployedSourceMap: compilerOutputContract.evm.deployedBytecode.sourceMap, legacyAST: undefined, ast: buildInfo.output.sources[sourcePath].ast, abi: compilerOutputContract.abi, metadata: compilerOutputContract.metadata, bytecode: CompileSolidity.Shims.zeroLinkReferences({ bytes: compilerOutputContract.evm.bytecode.object, linkReferences: CompileSolidity.Shims.formatLinkReferences(compilerOutputContract.evm.bytecode.linkReferences) }), deployedBytecode: CompileSolidity.Shims.zeroLinkReferences({ bytes: compilerOutputContract.evm.deployedBytecode.object, linkReferences: CompileSolidity.Shims.formatLinkReferences(compilerOutputContract.evm.deployedBytecode.linkReferences) }), compiler: { name: "solc", version: buildInfo.solcLongVersion }, devdoc: undefined, userdoc: undefined, immutableReferences: compilerOutputContract.evm.deployedBytecode.immutableReferences, generatedSources: compilerOutputContract.evm.bytecode .generatedSources, deployedGeneratedSources: compilerOutputContract.evm.deployedBytecode.generatedSources }; contracts.push(contract); } } return contracts; }; })(Contracts || (Contracts = {})); //# sourceMappingURL=compilation.js.map /***/ }), /***/ 35783: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.fromHardhatConfig = void 0; const config_1 = __importDefault(__webpack_require__(20553)); const fromHardhatConfig = (hardhatConfig) => { return config_1.default.default().merge({ networks: Networks.fromHardhatConfig(hardhatConfig) }); }; exports.fromHardhatConfig = fromHardhatConfig; var Networks; (function (Networks) { Networks.fromHardhatConfig = (hardhatConfig) => Object.entries(hardhatConfig.networks) .flatMap(([networkName, networkConfig]) => { // exclude hardhat network as not supported if (networkName === "hardhat") { return []; } // only accept netowrks that specify `url` if (!networkConfig || !("url" in networkConfig)) { return []; } const { url } = networkConfig; return [ { [networkName]: { url, network_id: "*" } } ]; }) .reduce((a, b) => (Object.assign(Object.assign({}, a), b)), {}); })(Networks || (Networks = {})); //# sourceMappingURL=config.js.map /***/ }), /***/ 65716: /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.supportedHardhatBuildInfoFormats = exports.supportedHardhatVersionRange = exports.validHardhatConfigFilenames = void 0; exports.validHardhatConfigFilenames = [ "hardhat.config.js", "hardhat.config.ts" ]; exports.supportedHardhatVersionRange = "^2.10.1"; exports.supportedHardhatBuildInfoFormats = new Set([ "hh-sol-build-info-1" ]); //# sourceMappingURL=constants.js.map /***/ }), /***/ 36052: /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prepareCompilations = exports.prepareConfig = exports.IncompatibleHardhatBuildInfoFormatError = exports.IncompatibleHardhatVersionError = exports.NotHardhatError = exports.expectHardhat = void 0; var api_1 = __webpack_require__(32007); Object.defineProperty(exports, "expectHardhat", ({ enumerable: true, get: function () { return api_1.expectHardhat; } })); Object.defineProperty(exports, "NotHardhatError", ({ enumerable: true, get: function () { return api_1.NotHardhatError; } })); Object.defineProperty(exports, "IncompatibleHardhatVersionError", ({ enumerable: true, get: function () { return api_1.IncompatibleHardhatVersionError; } })); Object.defineProperty(exports, "IncompatibleHardhatBuildInfoFormatError", ({ enumerable: true, get: function () { return api_1.IncompatibleHardhatBuildInfoFormatError; } })); Object.defineProperty(exports, "prepareConfig", ({ enumerable: true, get: function () { return api_1.prepareConfig; } })); Object.defineProperty(exports, "prepareCompilations", ({ enumerable: true, get: function () { return api_1.prepareCompilations; } })); //# sourceMappingURL=index.js.map /***/ }), /***/ 88504: /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.withDefaultEnvironmentOptions = void 0; const withDefaultEnvironmentOptions = ({ workingDirectory = process.cwd() } = {}) => ({ workingDirectory }); exports.withDefaultEnvironmentOptions = withDefaultEnvironmentOptions; //# sourceMappingURL=options.js.map /***/ }), /***/ 48511: /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.Resolver = void 0; const resolver_1 = __webpack_require__(43563); Object.defineProperty(exports, "Resolver", ({ enumerable: true, get: function () { return resolver_1.Resolver; } })); exports["default"] = resolver_1.Resolver; //# sourceMappingURL=index.js.map /***/ }), /***/ 70972: /***/ ((module) => { "use strict"; module.exports = require("@truffle/db-loader"); /***/ }), /***/ 92851: /***/ ((module) => { "use strict"; module.exports = require("@truffle/debugger"); /***/ }), /***/ 11651: /***/ ((module) => { "use strict"; module.exports = require("ganache"); /***/ }), /***/ 44516: /***/ ((module) => { "use strict"; module.exports = require("original-require"); /***/ }), /***/ 39491: /***/ ((module) => { "use strict"; module.exports = require("assert"); /***/ }), /***/ 50852: /***/ ((module) => { "use strict"; module.exports = require("async_hooks"); /***/ }), /***/ 14300: /***/ ((module) => { "use strict"; module.exports = require("buffer"); /***/ }), /***/ 32081: /***/ ((module) => { "use strict"; module.exports = require("child_process"); /***/ }), /***/ 22057: /***/ ((module) => { "use strict"; module.exports = require("constants"); /***/ }), /***/ 6113: /***/ ((module) => { "use strict"; module.exports = require("crypto"); /***/ }), /***/ 71891: /***/ ((module) => { "use strict"; module.exports = require("dgram"); /***/ }), /***/ 82361: /***/ ((module) => { "use strict"; module.exports = require("events"); /***/ }), /***/ 57147: /***/ ((module) => { "use strict"; module.exports = require("fs"); /***/ }), /***/ 73292: /***/ ((module) => { "use strict"; module.exports = require("fs/promises"); /***/ }), /***/ 13685: /***/ ((module) => { "use strict"; module.exports = require("http"); /***/ }), /***/ 95687: /***/ ((module) => { "use strict"; module.exports = require("https"); /***/ }), /***/ 98188: /***/ ((module) => { "use strict"; module.exports = require("module"); /***/ }), /***/ 41808: /***/ ((module) => { "use strict"; module.exports = require("net"); /***/ }), /***/ 22037: /***/ ((module) => { "use strict"; module.exports = require("os"); /***/ }), /***/ 71017: /***/ ((module) => { "use strict"; module.exports = require("path"); /***/ }), /***/ 85477: /***/ ((module) => { "use strict"; module.exports = require("punycode"); /***/ }), /***/ 63477: /***/ ((module) => { "use strict"; module.exports = require("querystring"); /***/ }), /***/ 14521: /***/ ((module) => { "use strict"; module.exports = require("readline"); /***/ }), /***/ 38102: /***/ ((module) => { "use strict"; module.exports = require("repl"); /***/ }), /***/ 12781: /***/ ((module) => { "use strict"; module.exports = require("stream"); /***/ }), /***/ 71576: /***/ ((module) => { "use strict"; module.exports = require("string_decoder"); /***/ }), /***/ 39512: /***/ ((module) => { "use strict"; module.exports = require("timers"); /***/ }), /***/ 24404: /***/ ((module) => { "use strict"; module.exports = require("tls"); /***/ }), /***/ 76224: /***/ ((module) => { "use strict"; module.exports = require("tty"); /***/ }), /***/ 57310: /***/ ((module) => { "use strict"; module.exports = require("url"); /***/ }), /***/ 73837: /***/ ((module) => { "use strict"; module.exports = require("util"); /***/ }), /***/ 59796: /***/ ((module) => { "use strict"; module.exports = require("zlib"); /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ id: moduleId, /******/ loaded: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = __webpack_modules__; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = __webpack_module_cache__; /******/ /******/ // the startup function /******/ __webpack_require__.x = () => { /******/ // Load entry module and return exports /******/ var __webpack_exports__ = __webpack_require__.O(undefined, [5158,9129,6127,5674,6674,439,406,7657,6434,1503,1698,1833,1071,9612,3613,8834,8100,794,9813,7941,7768,553,4273,102,3077,7017,5523,458], () => (__webpack_require__(76463))) /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); /******/ return __webpack_exports__; /******/ }; /******/ /************************************************************************/ /******/ /* webpack/runtime/amd options */ /******/ (() => { /******/ __webpack_require__.amdO = {}; /******/ })(); /******/ /******/ /* webpack/runtime/chunk loaded */ /******/ (() => { /******/ var deferred = []; /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { /******/