UNPKG

hardhat-deal

Version:

🎩🪄 Easily deal any amount of any ERC20 tokens to any account on the hardhat network

23 lines (22 loc) • 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.saveCache = exports.loadCache = exports.getCachePath = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const getCachePath = (cacheRoot) => path_1.default.join(cacheRoot, "hardhat-deal-cache", `data.json`); exports.getCachePath = getCachePath; const loadCache = (cachePath) => { if (!fs_1.default.existsSync(cachePath)) return {}; return JSON.parse(fs_1.default.readFileSync(cachePath, "utf-8")); }; exports.loadCache = loadCache; const saveCache = (cachePath, slots) => { if (!fs_1.default.existsSync(cachePath)) fs_1.default.mkdirSync(path_1.default.dirname(cachePath), { recursive: true }); fs_1.default.writeFileSync(cachePath, JSON.stringify(slots, undefined, 2)); }; exports.saveCache = saveCache;