"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.importFilecoinERC20Tokens = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const fetch_1 = require("../../fetch");
const utils_1 = require("../../utils");
const importFilecoinERC20Tokens = async (outputDir) => {
    try {
        console.log("importing filecoin erc20 tokens...");
        const { tokens, hash } = await (0, fetch_1.fetchTokensFromCALService)({
            chainId: 314,
            standard: "erc20",
        }, [
            "blockchain_name",
            "id",
            "ticker",
            "decimals",
            "name",
            "live_signature",
            "contract_address",
            "delisted",
        ]);
        const { erc20 } = (0, utils_1.getErc20DescriptorsAndSignatures)(tokens, 314);
        const filePath = path_1.default.join(outputDir, "filecoin-erc20");
        fs_1.default.writeFileSync(`${filePath}.json`, JSON.stringify(erc20));
        if (hash) {
            fs_1.default.writeFileSync(`${filePath}-hash.json`, JSON.stringify(hash));
        }
        fs_1.default.writeFileSync(`${filePath}.ts`, `import { ERC20Token } from "../types";

import tokens from "./filecoin-erc20.json";

${hash ? `export { default as hash } from "./filecoin-erc20-hash.json";` : ""}

export default tokens as ERC20Token[];
`);
        console.log("importing filecoin erc20 tokens sucess");
    }
    catch (err) {
        console.error(err);
    }
};
exports.importFilecoinERC20Tokens = importFilecoinERC20Tokens;
//# sourceMappingURL=index.js.map