var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import fs from "fs";
import path from "path";
import { fetchTokensFromCDN } from "../../fetch";
export const importEIP712 = (outputDir) => __awaiter(void 0, void 0, void 0, function* () {
    console.log("importing EIP712....");
    try {
        const [eip712, hash] = yield fetchTokensFromCDN("eip712.json");
        if (eip712) {
            const filePath = path.join(outputDir, "eip712");
            fs.writeFileSync(`${filePath}.json`, JSON.stringify(eip712));
            if (hash) {
                fs.writeFileSync(`${filePath}-hash.json`, JSON.stringify(hash));
            }
            const tsContent = `import EIP712 from "./eip712.json";
${hash ? `export { default as hash } from "./eip712-hash.json";` : ""}
export default EIP712;
`;
            fs.writeFileSync(`${filePath}.ts`, tsContent);
            console.log("importing EIP712 sucess");
        }
    }
    catch (err) {
        console.error(err);
    }
});
export const importEIP712v2 = (outputDir) => __awaiter(void 0, void 0, void 0, function* () {
    console.log("importing EIP712 V2....");
    try {
        const [eip712, hash] = yield fetchTokensFromCDN("eip712_v2.json");
        if (eip712) {
            const filePath = path.join(outputDir, "eip712_v2");
            fs.writeFileSync(`${filePath}.json`, JSON.stringify(eip712));
            if (hash) {
                fs.writeFileSync(`${filePath}-hash.json`, JSON.stringify(hash));
            }
            const tsContent = `import EIP712 from "./eip712_v2.json";
${hash ? `export { default as hash } from "./eip712_v2-hash.json";` : ""}
export default EIP712;
`;
            fs.writeFileSync(`${filePath}.ts`, tsContent);
            console.log("importing EIP712 V2 sucess");
        }
    }
    catch (err) {
        console.error(err);
    }
});
//# sourceMappingURL=index.js.map