"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.importCardanoNativeTokens = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const fetch_1 = require("../../fetch");
const importCardanoNativeTokens = async (outputDir) => {
    try {
        console.log("importing cardanoNative tokens...");
        const { tokens, hash } = await (0, fetch_1.fetchTokensFromCALService)({ blockchain_name: "cardano" }, [
            "contract_address",
            "name",
            "token_identifier",
            "ticker",
            "decimals",
            "delisted",
        ]);
        const cardanoNativeTokens = tokens.map(token => [
            "cardano",
            token.contract_address,
            token.token_identifier,
            token.name,
            token.ticker,
            token.decimals,
            token.delisted,
        ]);
        const filePath = path_1.default.join(outputDir, "cardanoNative");
        fs_1.default.writeFileSync(`${filePath}.json`, JSON.stringify(cardanoNativeTokens));
        if (hash) {
            fs_1.default.writeFileSync(`${filePath}-hash.json`, JSON.stringify(hash));
        }
        const cardanoNativeTypeStringified = `export type CardanoNativeToken = [
  "cardano", // parentCurrencyId
  string, // policyId
  string, // token identifier
  string, // name
  string, // ticker
  number, // decimals
  boolean, // delisted
];`;
        fs_1.default.writeFileSync(`${filePath}.ts`, `${cardanoNativeTypeStringified}

import tokens from "./cardanoNative.json";

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

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