"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.importERC20Exchange = void 0;
const fs_1 = __importDefault(require("fs"));
const fetch_1 = require("../fetch");
const importERC20Exchange = async (outputDir) => {
    console.log("importing ERC20 exchange...");
    try {
        const [erc20Exchange, hash] = await (0, fetch_1.fetchTokensFromCDN)("exchange/erc20.json");
        fs_1.default.writeFileSync(`${outputDir}/exchange/erc20.json`, JSON.stringify(erc20Exchange));
        if (hash) {
            fs_1.default.writeFileSync(`${outputDir}/exchange/erc20-hash.json`, JSON.stringify(hash));
        }
        const erc20typeStringified = `export type ERC20Exchange = [string, string, string];`;
        const hashStringified = hash ? `export { default as hash } from "./erc20-hash.json";` : "";
        const tokensStringified = `import exchanges from "./erc20.json";`;
        const exportStringified = `export default exchanges as ERC20Exchange[];`;
        fs_1.default.writeFileSync(`${outputDir}/exchange/erc20.ts`, `${erc20typeStringified}

${hashStringified}

${tokensStringified}

${exportStringified}
`);
        console.log("importing ERC20 exchange success");
    }
    catch (err) {
        console.error(err);
    }
};
exports.importERC20Exchange = importERC20Exchange;
//# sourceMappingURL=erc20.js.map