This commit is contained in:
aozhiwei 2023-06-13 19:16:47 +08:00
parent 2d24984588
commit 0d9ce62ef6
2 changed files with 9 additions and 2 deletions

View File

@ -26,13 +26,14 @@ class BlockChain {
async init() {
this.web3Conf = metaFactory.getWeb3Conf(this.netId);
this.contractsConf = metaFactory.getContractsConf(this.netId);
this.netDir = metaFactory.getNetDir(this.netId);
this.web3 = new Web3(this.getRpcUrl());
this.web3.eth.handleRevert = true;
this.web3.eth.accounts.wallet.add(this.getPrivateKey());
for (const data of this.contractsConf) {
this[`${data.name}Instance`] = await this.initInstance
(this.getUserAddress(), data.address, data.json);
(this.getUserAddress(), data.address, this.netDir + data.json);
}
event.emitEvent(C.BC_INITIALIZED_EVENT);
}

View File

@ -5,6 +5,7 @@ const log = require('j7/log');
const metaClassList = [];
const metaClasses = {};
const web3ConfHash = {};
let configDir = './config/';
function registerMetaClass(fileName, primKey, wrapClass) {
const metaClass = {
@ -68,7 +69,7 @@ function load() {
}
function init() {
let configDir = './config/';
configDir = './config/';
if (utils.isOnlineEnv()) {
configDir = '../config/';
} else if (utils.getArgv('env') == 'dev'){
@ -150,6 +151,11 @@ function getWeb3Conf(netId) {
}
function getNetDir(netId) {
const netDir = configDir + 'nets/' + netId + '/';
return netDir;
}
exports.init = init;
exports.getMetaByKey = getMetaByKey;