@simbachain/web3-suites
Version:
common code for web3 suite plugins. Code in this repo can be used for truffle or hardhat, but is designed to be applicable to future web3 suite plugins as well.
53 lines • 2.21 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addLib = void 0;
const chalk_1 = __importDefault(require("chalk"));
const prompts_1 = __importDefault(require("prompts"));
const lib_1 = require("../lib");
/**
* add an external library to your project
* @param libName
* @param libAddress
* @returns
*/
async function addLib(libName, libAddress) {
lib_1.SimbaConfig.log.debug(`:: ENTER :`);
if (!libName || !libAddress) {
const promptVals = [
{
type: 'text',
name: 'libraryname',
message: `Please enter the name of your library`,
},
{
type: 'text',
name: 'libraryaddress',
message: 'Please enter the address of your library',
},
];
const chosen = await (0, prompts_1.default)(promptVals);
if (!chosen.libraryname) {
lib_1.SimbaConfig.log.error(`${chalk_1.default.redBright(`\nsimba: EXIT : no library name specified!`)}`);
return;
}
if (!chosen.libraryaddress) {
lib_1.SimbaConfig.log.error(`${chalk_1.default.redBright(`\nsimba: EXIT : no library address specified!`)}`);
return;
}
libName = chosen.libraryname;
libAddress = chosen.libraryaddress;
}
const libs = lib_1.SimbaConfig.ProjectConfigStore.get("library_addresses") ?
lib_1.SimbaConfig.ProjectConfigStore.get("library_addresses") :
{};
libs[libName] = libAddress;
lib_1.SimbaConfig.ProjectConfigStore.set("library_addresses", libs);
lib_1.SimbaConfig.log.info(`${chalk_1.default.cyanBright(`\nsimba: library ${chalk_1.default.greenBright(`${libName}`)} with address ${chalk_1.default.greenBright(`${libAddress}`)} added to your library_addresses field in simba.json. You can now deploy contracts that require this libary as a dependency.`)}`);
lib_1.SimbaConfig.log.debug(`:: EXIT :`);
return;
}
exports.addLib = addLib;
//# sourceMappingURL=addlibrary.js.map