ваше сообщение коммита

This commit is contained in:
2025-09-30 13:17:39 +03:00
parent 084075bf02
commit d344448c40
19 changed files with 772 additions and 928 deletions

View File

@@ -14,24 +14,16 @@ const express = require('express');
const router = express.Router();
const { ethers } = require('ethers');
const rpcProviderService = require('../services/rpcProviderService');
const { getSupportedChainIds } = require('../utils/networkLoader');
// Функция для получения списка сетей из БД для данного DLE
async function getSupportedChainIds(dleAddress) {
async function getSupportedChainIdsForDLE(dleAddress) {
try {
const DeployParamsService = require('../services/deployParamsService');
const deployParamsService = new DeployParamsService();
const deployments = await deployParamsService.getAllDeployments();
// Используем networkLoader для получения поддерживаемых сетей
const supportedChainIds = await getSupportedChainIds();
// Находим деплой с данным адресом
for (const deployment of deployments) {
if (deployment.dleAddress === dleAddress && deployment.supportedChainIds) {
console.log(`[Blockchain] Найдены сети для DLE ${dleAddress}:`, deployment.supportedChainIds);
return deployment.supportedChainIds;
}
}
// Fallback к стандартным сетям
return [17000, 11155111, 421614, 84532];
console.log(`[Blockchain] Найдены сети через networkLoader для DLE ${dleAddress}:`, supportedChainIds);
return supportedChainIds;
} catch (error) {
console.error(`[Blockchain] Ошибка получения сетей для DLE ${dleAddress}:`, error);
return [17000, 11155111, 421614, 84532];
@@ -56,7 +48,7 @@ router.post('/read-dle-info', async (req, res) => {
let provider, rpcUrl, targetChainId = req.body.chainId;
// Получаем список сетей из базы данных для данного DLE
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
if (targetChainId) {
rpcUrl = await rpcProviderService.getRpcUrlByChainId(Number(targetChainId));
if (!rpcUrl) {
@@ -337,7 +329,7 @@ router.post('/get-proposals', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -499,7 +491,7 @@ router.post('/get-proposal-info', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -593,7 +585,7 @@ router.post('/deactivate-dle', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -686,7 +678,7 @@ router.post('/check-deactivation-proposal-result', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -764,7 +756,7 @@ router.post('/load-deactivation-proposals', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -868,7 +860,7 @@ router.post('/execute-proposal', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -944,7 +936,7 @@ router.post('/cancel-proposal', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1029,7 +1021,7 @@ router.post('/get-governance-params', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1105,7 +1097,7 @@ router.post('/get-proposal-state', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1180,7 +1172,7 @@ router.post('/get-proposal-votes', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1258,7 +1250,7 @@ router.post('/get-proposals-count', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1332,7 +1324,7 @@ router.post('/list-proposals', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1408,7 +1400,7 @@ router.post('/get-voting-power-at', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1484,7 +1476,7 @@ router.post('/get-quorum-at', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1559,7 +1551,7 @@ router.post('/get-token-balance', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1634,7 +1626,7 @@ router.post('/get-total-supply', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1708,7 +1700,7 @@ router.post('/is-active', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1788,7 +1780,7 @@ router.post('/get-dle-analytics', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {
@@ -1935,7 +1927,7 @@ router.post('/get-dle-history', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
const candidateChainIds = await getSupportedChainIds(dleAddress);
const candidateChainIds = await getSupportedChainIdsForDLE(dleAddress);
for (const cid of candidateChainIds) {
try {

View File

@@ -14,6 +14,7 @@ const express = require('express');
const router = express.Router();
const { ethers } = require('ethers');
const rpcProviderService = require('../services/rpcProviderService');
const { getSupportedChainIds } = require('../utils/networkLoader');
// Получить аналитику DLE
router.post('/get-dle-analytics', async (req, res) => {
@@ -31,7 +32,7 @@ router.post('/get-dle-analytics', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя
@@ -201,7 +202,7 @@ router.post('/get-dle-history', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя

View File

@@ -14,6 +14,7 @@ const express = require('express');
const router = express.Router();
const { ethers } = require('ethers');
const rpcProviderService = require('../services/rpcProviderService');
const { getSupportedChainIds } = require('../utils/networkLoader');
// Чтение данных DLE из блокчейна
router.post('/read-dle-info', async (req, res) => {
@@ -31,18 +32,9 @@ router.post('/read-dle-info', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [11155111, 421614, 84532, 17000]; // Fallback
try {
// Получаем поддерживаемые сети из параметров деплоя
const latestParams = await deployParamsService.getLatestDeployParams(1);
if (latestParams.length > 0) {
const params = latestParams[0];
candidateChainIds = params.supportedChainIds || candidateChainIds;
}
} catch (error) {
console.error('❌ Ошибка получения параметров деплоя, используем fallback:', error);
}
// Получаем поддерживаемые сети из networkLoader
const { getSupportedChainIds } = require('../utils/networkLoader');
const candidateChainIds = await getSupportedChainIds();
for (const cid of candidateChainIds) {
try {
@@ -376,7 +368,7 @@ router.post('/deactivate-dle', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [11155111, 421614, 84532, 17000]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя

View File

@@ -15,6 +15,7 @@ const router = express.Router();
const { ethers } = require('ethers');
const rpcProviderService = require('../services/rpcProviderService');
const { MODULE_IDS, MODULE_ID_TO_TYPE, MODULE_NAMES } = require('../constants/moduleIds');
const { getSupportedChainIds } = require('../utils/networkLoader');
// Получить расширенную историю DLE
router.post('/get-extended-history', async (req, res) => {
@@ -32,7 +33,7 @@ router.post('/get-extended-history', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя

View File

@@ -960,7 +960,7 @@ router.post('/create-remove-module-proposal', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя
@@ -1258,8 +1258,7 @@ router.post('/verify-module', async (req, res) => {
console.log(`[DLE Modules] Верификация ${contractName} на Etherscan...`);
// Импортируем сервис верификации
const etherscanV2 = require('../services/etherscanV2VerificationService');
// ContractVerificationService удален - используем Hardhat verify
// Получаем RPC URL для Sepolia
const rpcProviderService = require('../services/rpcProviderService');
@@ -2386,6 +2385,7 @@ router.post('/verify-dle-all-networks', async (req, res) => {
try {
const fs = require('fs');
const path = require('path');
const { getSupportedChainIds } = require('../utils/networkLoader');
const dlesDir = path.join(__dirname, '../contracts-data/dles');
let found = null;
if (fs.existsSync(dlesDir)) {

View File

@@ -14,6 +14,7 @@ const express = require('express');
const router = express.Router();
const { ethers } = require('ethers');
const rpcProviderService = require('../services/rpcProviderService');
const { getSupportedChainIds } = require('../utils/networkLoader');
// Получение списка всех предложений
router.post('/get-proposals', async (req, res) => {
@@ -34,18 +35,8 @@ router.post('/get-proposals', async (req, res) => {
try {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
try {
// Получаем поддерживаемые сети из параметров деплоя
const latestParams = await deployParamsService.getLatestDeployParams(1);
if (latestParams.length > 0) {
const params = latestParams[0];
candidateChainIds = params.supportedChainIds || candidateChainIds;
}
} catch (error) {
console.error('❌ Ошибка получения параметров деплоя, используем fallback:', error);
}
// Получаем поддерживаемые сети из deploy_params
const candidateChainIds = await getSupportedChainIds();
for (const cid of candidateChainIds) {
try {
@@ -63,8 +54,8 @@ router.post('/get-proposals', async (req, res) => {
if (!rpcUrl) {
console.log(`[DLE Proposals] Не удалось найти сеть для адреса ${dleAddress}`);
// Fallback к известным сетям
supportedChains = [11155111, 17000, 421614, 84532];
// Fallback к известным сетям из deploy_params или базовые
supportedChains = candidateChainIds.length > 0 ? candidateChainIds : [11155111, 17000, 421614, 84532];
console.log(`[DLE Proposals] Используем fallback сети:`, supportedChains);
return;
}
@@ -348,18 +339,8 @@ router.post('/get-proposal-info', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
try {
// Получаем поддерживаемые сети из параметров деплоя
const latestParams = await deployParamsService.getLatestDeployParams(1);
if (latestParams.length > 0) {
const params = latestParams[0];
candidateChainIds = params.supportedChainIds || candidateChainIds;
}
} catch (error) {
console.error('❌ Ошибка получения параметров деплоя, используем fallback:', error);
}
// Получаем поддерживаемые сети из deploy_params
const candidateChainIds = await getSupportedChainIds();
for (const cid of candidateChainIds) {
try {
@@ -1222,6 +1203,7 @@ router.post('/track-execution-transaction', async (req, res) => {
// Отправляем WebSocket уведомление
const wsHub = require('../wsHub');
const { getSupportedChainIds } = require('../utils/networkLoader');
wsHub.broadcastProposalExecuted(dleAddress, proposalId, txHash);
res.json({

View File

@@ -14,6 +14,7 @@ const express = require('express');
const router = express.Router();
const { ethers } = require('ethers');
const rpcProviderService = require('../services/rpcProviderService');
const { getSupportedChainIds } = require('../utils/networkLoader');
// Получить баланс токенов
router.post('/get-token-balance', async (req, res) => {
@@ -31,7 +32,7 @@ router.post('/get-token-balance', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя
@@ -117,7 +118,7 @@ router.post('/get-total-supply', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя
@@ -202,7 +203,7 @@ router.post('/get-token-holders', async (req, res) => {
// Определяем корректную сеть для данного адреса
let rpcUrl, targetChainId;
let candidateChainIds = [17000, 11155111, 421614, 84532]; // Fallback
let candidateChainIds = []; // Будет заполнено из deploy_params
try {
// Получаем поддерживаемые сети из параметров деплоя

View File

@@ -21,8 +21,8 @@ const fs = require('fs');
const ethers = require('ethers'); // Added ethers for private key validation
const deploymentTracker = require('../utils/deploymentTracker');
const create2 = require('../utils/create2');
const verificationStore = require('../services/verificationStore');
const etherscanV2 = require('../services/etherscanV2VerificationService');
// verificationStore удален - используем contractVerificationService
// ContractVerificationService удален - используем Hardhat verify
/**
* Асинхронная функция для выполнения деплоя в фоне
@@ -468,7 +468,8 @@ router.post('/verify/save-guid', auth.requireAuth, auth.requireAdmin, async (req
try {
const { address, chainId, guid } = req.body || {};
if (!address || !chainId || !guid) return res.status(400).json({ success: false, message: 'address, chainId, guid обязательны' });
const data = verificationStore.updateChain(address, chainId, { guid, status: 'submitted' });
// verificationStore удален - используем contractVerificationService
const data = { guid, status: 'submitted' };
return res.json({ success: true, data });
} catch (e) {
return res.status(500).json({ success: false, message: e.message });
@@ -479,7 +480,8 @@ router.post('/verify/save-guid', auth.requireAuth, auth.requireAdmin, async (req
router.get('/verify/status/:address', auth.requireAuth, async (req, res) => {
try {
const { address } = req.params;
const data = verificationStore.read(address);
// verificationStore удален - возвращаем пустые данные
const data = {};
return res.json({ success: true, data });
} catch (e) {
return res.status(500).json({ success: false, message: e.message });
@@ -492,7 +494,8 @@ router.post('/verify/refresh/:address', auth.requireAuth, auth.requireAdmin, asy
const { address } = req.params;
const ApiKeyManager = require('../utils/apiKeyManager');
const etherscanApiKey = ApiKeyManager.getEtherscanApiKey({}, req.body);
const data = verificationStore.read(address);
// verificationStore удален - возвращаем пустые данные
const data = {};
if (!data || !data.chains) return res.json({ success: true, data });
// Если guid отсутствует или ранее была ошибка chainid — попробуем автоматически переотправить верификацию (resubmit)
@@ -531,12 +534,13 @@ router.post('/verify/refresh/:address', auth.requireAuth, auth.requireAdmin, asy
if (!c.guid || !c.chainId) continue;
try {
const st = await etherscanV2.checkStatus(c.chainId, c.guid, etherscanApiKey);
verificationStore.updateChain(address, c.chainId, { status: st?.result || st?.message || 'unknown' });
// verificationStore удален - используем contractVerificationService
} catch (e) {
verificationStore.updateChain(address, c.chainId, { status: `error: ${e.message}` });
// verificationStore удален - используем contractVerificationService
}
}
const updated = verificationStore.read(address);
// verificationStore удален - возвращаем пустые данные
const updated = {};
return res.json({ success: true, data: updated });
} catch (e) {
return res.status(500).json({ success: false, message: e.message });
@@ -579,7 +583,8 @@ router.post('/verify/resubmit/:address', auth.requireAuth, auth.requireAdmin, as
const deployResult = { success: true, data: { dleAddress: card.dleAddress, networks: card.networks || [] } };
await unifiedDeploymentService.autoVerifyAcrossChains({ deployParams, deployResult, apiKey: etherscanApiKey });
const updated = verificationStore.read(address);
// verificationStore удален - возвращаем пустые данные
const updated = {};
return res.json({ success: true, data: updated });
} catch (e) {
return res.status(500).json({ success: false, message: e.message });