UNPKG

@nomyx/hardhat-adminui

Version:

A comprehensive Hardhat plugin providing a web-based admin UI for deployed smart contracts with Diamond proxy support, contract interaction, event monitoring, and deployment dashboard.

49 lines (48 loc) 1.8 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScenarioHistoryService = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const HISTORY_FILE = '.scenarios-history.json'; class ScenarioHistoryService { constructor(projectRoot) { this.historyPath = path_1.default.join(projectRoot, HISTORY_FILE); this.ensureHistoryFile(); } ensureHistoryFile() { if (!fs_1.default.existsSync(this.historyPath)) { fs_1.default.writeFileSync(this.historyPath, JSON.stringify([])); } } readHistory() { const data = fs_1.default.readFileSync(this.historyPath, 'utf-8'); return JSON.parse(data); } writeHistory(data) { fs_1.default.writeFileSync(this.historyPath, JSON.stringify(data, null, 2)); } getAllExecutions() { return this.readHistory().sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()); } getExecutionById(id) { const history = this.readHistory(); return history.find(exec => exec.id === id); } addExecution(execution) { const history = this.readHistory(); history.unshift(execution); this.writeHistory(history); } updateExecution(id, updatedExecution) { const history = this.readHistory(); const index = history.findIndex(exec => exec.id === id); if (index !== -1) { history[index] = { ...history[index], ...updatedExecution }; this.writeHistory(history); } } } exports.ScenarioHistoryService = ScenarioHistoryService;