"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.importStellarTokens = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const fetch_1 = require("../../fetch");
const importStellarTokens = async (outputDir) => {
    try {
        console.log("importing stellar tokens...");
        const { tokens, hash } = await (0, fetch_1.fetchTokensFromCALService)({ blockchain_name: "stellar" }, [
            "ticker",
            "contract_address",
            "name",
            "decimals",
        ]);
        const stellarTokens = tokens.map(token => [
            token.ticker.toLowerCase(),
            token.contract_address.toLowerCase(),
            "stellar",
            token.name,
            token.decimals,
        ]);
        const filePath = path_1.default.join(outputDir, "stellar");
        const stellarTypeStringified = `export type StellarToken = [
  string, // assetCode
  string, // assetIssuer
  "stellar", // assetType (note: only used in Receive asset message and always should be "Stellar")
  string, // name
  number, // precision
];`;
        fs_1.default.writeFileSync(`${filePath}.json`, JSON.stringify(stellarTokens));
        if (hash) {
            fs_1.default.writeFileSync(`${filePath}-hash.json`, JSON.stringify(hash));
        }
        fs_1.default.writeFileSync(`${filePath}.ts`, `${stellarTypeStringified}

import tokens from "./stellar.json";

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

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