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

import tokens from "./apt_${standard}.json";

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

export default tokens as AptosToken[];
`);
        console.log(`importing aptos ${standard} tokens success`);
    }
    catch (err) {
        console.error(err);
    }
};
exports.importAptosTokens = importAptosTokens;
//# sourceMappingURL=index.js.map