@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.
100 lines (99 loc) • 4.14 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScenarioService = void 0;
const discovery_1 = require("../scenario-runner/core/discovery");
const engine_1 = require("../scenario-runner/core/engine");
const scenario_history_service_1 = require("./scenario-history-service");
const path = __importStar(require("path"));
class ScenarioService {
constructor(hre) {
this.hre = hre;
const scenariosPath = path.join(this.hre.config.paths.root, "scenarios");
this.discovery = new discovery_1.ScenarioDiscovery(scenariosPath);
this.engine = new engine_1.ScenarioEngine(this.hre);
this.historyService = new scenario_history_service_1.ScenarioHistoryService(this.hre.config.paths.root);
}
async listScenarios() {
return this.discovery.listScenarios();
}
async getScenario(name) {
return this.discovery.loadScenario(name);
}
async runScenario(name) {
const scenario = await this.discovery.loadScenario(name);
return this.engine.run(scenario);
}
async runScenarioBatch(scenarioNames, executionId) {
const scenarios = await Promise.all(scenarioNames.map(name => this.discovery.loadScenario(name)));
const execution = {
id: executionId,
timestamp: new Date().toISOString(),
status: 'running',
summary: {
total: scenarios.length,
passed: 0,
failed: 0,
running: scenarios.length,
pending: 0,
},
scenarios: scenarios.map(s => ({
name: s.metadata.name,
status: 'running',
steps: [],
})),
};
this.historyService.addExecution(execution);
const results = await this.engine.runBatch(scenarios);
const finalExecution = this.historyService.getExecutionById(executionId);
if (finalExecution) {
finalExecution.status = results.some(r => r.status === 'failed') ? 'failed' : 'completed';
finalExecution.scenarios = results;
finalExecution.summary = {
total: results.length,
passed: results.filter(r => r.status === 'passed').length,
failed: results.filter(r => r.status === 'failed').length,
running: 0,
pending: 0,
};
finalExecution.duration = new Date().getTime() - new Date(finalExecution.timestamp).getTime();
this.historyService.updateExecution(executionId, finalExecution);
}
}
async saveScenario(name, content) {
return this.discovery.saveScenario(name, content);
}
}
exports.ScenarioService = ScenarioService;