// Define a simple class in file1.js
const path = require("path");
const fs = require("fs-extra")


class BaseClass {
    constructor(scriptDirectory, scriptfile = null) {
        this.scriptfilename = path.basename(scriptfile);

        this.src_directory = path.dirname(scriptDirectory); // 上一级目录

        this.project_directory = path.dirname(this.src_directory);

        // 注意 正确的应该是.join(,"/file")=root/file
        // 但是目前是.join(,"/file/")=root/file/ 多了一个/ 是因为实际操作中存在 `${baseclass.xxx_path}script.js` 以后在改
        this.code_path = path.join(this.project_directory, "src/code/");
        this.librarydata_path = path.join(this.project_directory, "src/librarydata/");

        this.newpair_from_dexscreener_path = path.join(this.librarydata_path, "newpair_from_dexscreener/");
        this.newpair_merge_path = path.join(this.librarydata_path, "newpair_merge/");
        this.topdalao_from_dexscreener_path = path.join(this.librarydata_path, "topdalao_from_dexscreener/");

        this.dalao_merge_path = path.join(this.librarydata_path, "dalao_merge/");
        this.topdalao_signatures_path = path.join(this.librarydata_path, "topdalao_signatures/");
        this.topdalao_transaction_path = path.join(this.librarydata_path, "topdalao_transaction/");
        this.topdalao_st_path = path.join(this.librarydata_path, "topdalao_st/");


      




    }
    makedirpath(mkpath) {
        if (!fs.existsSync(mkpath)) {
            fs.mkdirSync(mkpath);
        }
    }
    rmfolder(mkpath) {
        // fs.removeSync()
        fs.removeSync(mkpath);

    }
    sleep(sleepdelay) {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(sleepdelay);
            }, sleepdelay);
        })
    }


}

module.exports = BaseClass;