"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.importAsaTokens = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const fetch_1 = require("../../fetch");
const importAsaTokens = async (outputDir) => {
    try {
        console.log("importing asa tokens...");
        const { tokens, hash } = await (0, fetch_1.fetchTokensFromCALService)({
            blockchain_name: "algorand",
        }, ["contract_address", "token_identifier", "decimals", "name", "ticker", "live_signature"]);
        const asaTokens = tokens.map(token => [
            token.token_identifier,
            token.ticker,
            token.name,
            token.contract_address,
            token.decimals,
        ]);
        const filePath = path_1.default.join(outputDir, "asa");
        fs_1.default.writeFileSync(`${filePath}.json`, JSON.stringify(asaTokens));
        if (hash) {
            fs_1.default.writeFileSync(`${filePath}-hash.json`, JSON.stringify(hash));
        }
        fs_1.default.writeFileSync(`${filePath}.ts`, `export type AlgorandASAToken = [
  string, // id
  string, // abbr
  string, // name
  string, // contractAddress
  number, // precision
];

import tokens from "./asa.json";

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

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