@simbachain/hardhat
Version:
Simba Chain plugin for hardhat
149 lines • 5.16 kB
JavaScript
"use strict";
/*
NOTE:
this file will actually come from the standalone web3 repo
it is just included here for now for testing purposes
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimbaConfig = void 0;
const lib_1 = require("../lib");
const process_1 = require("process");
const path = __importStar(require("path"));
const configstore_1 = __importDefault(require("configstore"));
const authentication_1 = require("./authentication");
// const fsPromises = require("fs").promises;
class SimbaConfig {
constructor() {
const confstore = this.ConfigStore;
const projconfstore = this.ProjectConfigStore;
const w3Suite = this.web3Suite;
const app = this.application;
const org = this.organisation;
const authStr = this.authStore;
const buildDir = this.buildDirectory;
const constructorParams = {
confstore,
projconfstore,
app,
org,
authStr,
w3Suite,
buildDir,
};
lib_1.log.debug(`:: ENTER : SimbaConfig constructor params : ${JSON.stringify(constructorParams)}`);
}
static get ConfigStore() {
if (!this._configStore) {
this._configStore = new configstore_1.default(`/${this._web3Suite}`, null, {
configPath: path.join(process_1.cwd(), 'authconfig.json'),
});
}
return this._configStore;
}
get ConfigStore() {
return SimbaConfig.ConfigStore;
}
static get ProjectConfigStore() {
if (!this._projectConfigStore) {
this._projectConfigStore = new configstore_1.default(`/${this._web3Suite}`, null, {
configPath: path.join(process_1.cwd(), 'simba.json'),
});
}
return this._projectConfigStore;
}
get ProjectConfigStore() {
return SimbaConfig.ProjectConfigStore;
}
static get authStore() {
lib_1.log.debug(`:: ENTER :`);
if (!this._authStore) {
lib_1.log.debug(`:: instantiating new authStore`);
this._authStore = new authentication_1.KeycloakHandler(this._configStore, this._projectConfigStore);
}
lib_1.log.debug(`:: EXIT :`);
return this._authStore;
}
get authStore() {
return SimbaConfig.authStore;
}
static get artifactDirectory() {
return this.ProjectConfigStore.get('artifact_directory');
}
get artifactDirectory() {
return SimbaConfig.artifactDirectory;
}
static get buildInfoDirectory() {
return SimbaConfig.artifactDirectory + "/build-info";
}
get buildInfoDirectory() {
return SimbaConfig.buildInfoDirectory;
}
static get buildDirectory() {
return SimbaConfig.artifactDirectory + "/contracts";
}
get buildDirectory() {
return SimbaConfig.buildDirectory;
}
static get web3Suite() {
return this.ProjectConfigStore.get('web3Suite');
}
get web3Suite() {
return SimbaConfig.web3Suite;
}
static set web3Suite(_w3Suite) {
this._projectConfigStore.set('web3Suite', _w3Suite);
}
set web3Suite(_w3Suite) {
SimbaConfig.web3Suite = _w3Suite;
}
static get organisation() {
const org = this.ProjectConfigStore.get('organisation') ? this.ProjectConfigStore.get('organisation') : this.ProjectConfigStore.get('organization');
return org;
}
get organisation() {
return SimbaConfig.organisation;
}
static set organisation(org) {
this.ProjectConfigStore.set('organisation', org);
}
set organisation(org) {
SimbaConfig.organisation = org;
}
static get application() {
return this.ProjectConfigStore.get('application');
}
get application() {
return SimbaConfig.application;
}
static set application(app) {
this.ProjectConfigStore.set('application', app);
}
set application(app) {
SimbaConfig.application = app;
}
}
exports.SimbaConfig = SimbaConfig;
SimbaConfig.help = false;
//# sourceMappingURL=config.js.map