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

import tokens from "./ton-jetton.json";

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

export default tokens as TonJettonToken[];
`);
        console.log("importing ton jetton tokens success");
    }
    catch (err) {
        console.error(err);
    }
};
exports.importTonJettonTokens = importTonJettonTokens;
//# sourceMappingURL=index.js.map