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

${hashStringified}

${exchangesStringified}

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