@simbachain/hardhat
Version:
Simba Chain plugin for hardhat
75 lines • 3.47 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const web3_suites_1 = require("@simbachain/web3-suites");
/**
* when pulling your contracts from your blocks organisation, you can "pull" them
* into two locations: your local contracts folder (or contracts/simbaimports), and/or
* your simba.json
*
* pulling makes sure that, when working with teams, everyone is working
* with the most recent versions of contracts that have been exported to blocks
* @param designID
* @param contractName
* @param pullSourceCode - pull source code to your simba.json
* @param pullSolFiles - pull .sol files to your contracts or contracts/simbaimports directory
* @param interactive
* @param useSimbaPath - pull to contracts/simbaimports
* @returns
*/
const pull = async (designID, contractName, pullSourceCode = true, pullSolFiles = false, interactive = false, useSimbaPath = true) => {
web3_suites_1.SimbaConfig.log.debug(`:: ENTER :`);
if (designID && contractName) {
const message = `${chalk_1.default.redBright(`\nsimba: designid and contractname were both specified. Only one of these parameters can be passed.`)}`;
web3_suites_1.SimbaConfig.log.error(message);
return;
}
if (designID && interactive) {
const message = `${chalk_1.default.redBright(`\nsimba: designid cannot be specified in interactive mode.`)}`;
web3_suites_1.SimbaConfig.log.error(message);
return;
}
if (contractName && interactive) {
const message = `${chalk_1.default.redBright(`\nsimba: contractname cannot be specified in interactive mode.`)}`;
web3_suites_1.SimbaConfig.log.error(message);
return;
}
if (designID) {
const contractDesign = await (0, web3_suites_1.pullContractFromDesignId)(designID, useSimbaPath);
if (pullSourceCode && contractDesign) {
(0, web3_suites_1.pullSourceCodeForSimbaJson)(contractDesign);
}
web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`);
return;
}
if (contractName) {
if (pullSolFiles && pullSourceCode) {
await (0, web3_suites_1.pullMostRecentFromContractName)(contractName, undefined, useSimbaPath);
web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`);
return;
}
if (pullSolFiles) {
await (0, web3_suites_1.pullMostRecentRecentSolFileFromContractName)(contractName, undefined, useSimbaPath);
web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`);
return;
}
if (pullSourceCode) {
await (0, web3_suites_1.pullMostRecentSourceCodeFromContractName)(contractName);
web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`);
return;
}
// default to pulling sol files and source code for simba.json
await (0, web3_suites_1.pullMostRecentFromContractName)(contractName, undefined, useSimbaPath);
web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`);
return;
}
if (interactive) {
pullSolFiles = true;
}
await (0, web3_suites_1.pullAllMostRecentSolFilesAndSourceCode)(pullSourceCode, pullSolFiles, interactive, useSimbaPath);
};
exports.default = pull;
//# sourceMappingURL=pullcontract.js.map