33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const fs = require("fs")
|
|
|
|
function loadConfig() {
|
|
const configPath = "./config.json";
|
|
if (!fs.existsSync(configPath)) {
|
|
throw new Error("Configuration file not found: " + configPath);
|
|
}
|
|
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
if (!configContent) {
|
|
throw new Error("Configuration file is empty: " + configPath);
|
|
}
|
|
try {
|
|
return JSON.parse(configContent);
|
|
} catch (error) {
|
|
throw new Error("Error parsing configuration file: " + error.message);
|
|
}
|
|
}
|
|
|
|
class App {
|
|
constructor(){
|
|
const config = loadConfig();
|
|
this.ethNodeUrl = config.nodesUrl.ETH.url
|
|
this.ETH_API_KEY = config.nodesUrl.ETH.key
|
|
const usdterc20_abi = JSON.parse(fs.readFileSync(config.abiPath.usdt_erc20_abi, "utf-8"));
|
|
const usdcerc20_abi = JSON.parse(fs.readFileSync(config.abiPath.usdc_erc20_abi, "utf-8"));
|
|
const usdttrc20_abi = JSON.parse(fs.readFileSync(config.abiPath.usdt_trc20_abi, "utf-8"));
|
|
this.abis = {usdcerc20_abi, usdterc20_abi, usdttrc20_abi};
|
|
}
|
|
}
|
|
|
|
const app = new App();
|
|
|
|
module.exports = app; |