ваше сообщение коммита
This commit is contained in:
319
frontend/src/services/analyticsService.js
Normal file
319
frontend/src/services/analyticsService.js
Normal file
@@ -0,0 +1,319 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2025 Тарабанов Александр Викторович
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is proprietary and confidential.
|
||||
* Unauthorized copying, modification, or distribution is prohibited.
|
||||
*
|
||||
* For licensing inquiries: info@hb3-accelerator.com
|
||||
* Website: https://hb3-accelerator.com
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Сервис для работы с аналитикой DLE
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* Получает общую статистику DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Общая статистика
|
||||
*/
|
||||
export const getDLEStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-analytics/get-dle-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики DLE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику предложений
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика предложений
|
||||
*/
|
||||
export const getProposalsStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-proposals-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики предложений:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика токенов
|
||||
*/
|
||||
export const getTokenStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику модулей
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика модулей
|
||||
*/
|
||||
export const getModulesStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-modules-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики модулей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику голосования
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика голосования
|
||||
*/
|
||||
export const getVotingStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-voting-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики голосования:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает активность DLE по времени
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} period - Период (day, week, month, year)
|
||||
* @returns {Promise<Object>} - Активность по времени
|
||||
*/
|
||||
export const getDLEActivity = async (dleAddress, period = 'month') => {
|
||||
try {
|
||||
const response = await axios.post('/dle-analytics/get-dle-activity', {
|
||||
dleAddress,
|
||||
period
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении активности DLE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает топ держателей токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} limit - Количество записей
|
||||
* @returns {Promise<Object>} - Топ держателей
|
||||
*/
|
||||
export const getTopTokenHolders = async (dleAddress, limit = 10) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-top-token-holders', {
|
||||
dleAddress,
|
||||
limit
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении топ держателей токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает распределение токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Распределение токенов
|
||||
*/
|
||||
export const getTokenDistribution = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-distribution', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении распределения токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает историю событий
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} eventType - Тип события
|
||||
* @param {number} fromBlock - Начальный блок
|
||||
* @param {number} toBlock - Конечный блок
|
||||
* @returns {Promise<Object>} - История событий
|
||||
*/
|
||||
export const getEventHistory = async (dleAddress, eventType, fromBlock, toBlock) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-analytics/get-event-history', {
|
||||
dleAddress,
|
||||
eventType,
|
||||
fromBlock,
|
||||
toBlock
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении истории событий:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает метрики производительности
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Метрики производительности
|
||||
*/
|
||||
export const getPerformanceMetrics = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-performance-metrics', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении метрик производительности:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает аналитику по сетям
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Аналитика по сетям
|
||||
*/
|
||||
export const getNetworkAnalytics = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-network-analytics', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении аналитики по сетям:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает отчет о деятельности
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} reportType - Тип отчета
|
||||
* @param {Object} filters - Фильтры
|
||||
* @returns {Promise<Object>} - Отчет о деятельности
|
||||
*/
|
||||
export const getActivityReport = async (dleAddress, reportType, filters = {}) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-activity-report', {
|
||||
dleAddress,
|
||||
reportType,
|
||||
...filters
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении отчета о деятельности:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает сравнительную аналитику
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} comparisonType - Тип сравнения
|
||||
* @returns {Promise<Object>} - Сравнительная аналитика
|
||||
*/
|
||||
export const getComparativeAnalytics = async (dleAddress, comparisonType) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-comparative-analytics', {
|
||||
dleAddress,
|
||||
comparisonType
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении сравнительной аналитики:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает прогнозы и тренды
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Прогнозы и тренды
|
||||
*/
|
||||
export const getTrendsAndForecasts = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-trends-forecasts', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении прогнозов и трендов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает аналитику рисков
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Аналитика рисков
|
||||
*/
|
||||
export const getRiskAnalytics = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-risk-analytics', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении аналитики рисков:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает ключевые показатели эффективности
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Ключевые показатели эффективности
|
||||
*/
|
||||
export const getKPIs = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-kpis', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении ключевых показателей эффективности:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает дашборд аналитики
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Дашборд аналитики
|
||||
*/
|
||||
export const getAnalyticsDashboard = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-analytics-dashboard', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении дашборда аналитики:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -10,9 +10,11 @@
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Сервис для работы с DLE v2
|
||||
// Сервис для работы с DLE v2 - основные функции
|
||||
import axios from 'axios';
|
||||
|
||||
// ===== ОСНОВНЫЕ ФУНКЦИИ DLE =====
|
||||
|
||||
/**
|
||||
* Создает новое DLE v2
|
||||
* @param {Object} dleParams - Параметры DLE
|
||||
@@ -69,4 +71,150 @@ export const getDefaultParams = async () => {
|
||||
console.error('Ошибка при получении параметров по умолчанию:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Читает данные DLE из блокчейна
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Данные из блокчейна
|
||||
*/
|
||||
export const readDLEFromBlockchain = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-core/read-dle-info', { dleAddress });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при чтении DLE из блокчейна:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает параметры управления DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Параметры управления
|
||||
*/
|
||||
export const getGovernanceParams = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-core/get-governance-params', { dleAddress });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении параметров управления:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// ===== МУЛЬТИ-ЧЕЙН ФУНКЦИОНАЛЬНОСТЬ =====
|
||||
|
||||
/**
|
||||
* Получает список поддерживаемых сетей
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Список сетей
|
||||
*/
|
||||
export const getSupportedChains = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/get-supported-chains', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении поддерживаемых сетей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет поддержку сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Статус поддержки
|
||||
*/
|
||||
export const isChainSupported = async (dleAddress, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/is-chain-supported', {
|
||||
dleAddress,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке поддержки сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает текущую сеть
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Текущая сеть
|
||||
*/
|
||||
export const getCurrentChainId = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-current-chain-id', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении текущей сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Исполняет предложение по подписям
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} executionData - Данные исполнения
|
||||
* @returns {Promise<Object>} - Результат исполнения
|
||||
*/
|
||||
export const executeProposalBySignatures = async (dleAddress, executionData) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/execute-proposal-by-signatures', {
|
||||
dleAddress,
|
||||
...executionData
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при исполнении предложения по подписям:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// ===== ИСТОРИЯ И СОБЫТИЯ =====
|
||||
|
||||
/**
|
||||
* Получает историю событий
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} eventType - Тип события
|
||||
* @param {number} fromBlock - Начальный блок
|
||||
* @param {number} toBlock - Конечный блок
|
||||
* @returns {Promise<Object>} - История событий
|
||||
*/
|
||||
export const getEventHistory = async (dleAddress, eventType, fromBlock, toBlock) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-event-history', {
|
||||
dleAddress,
|
||||
eventType,
|
||||
fromBlock,
|
||||
toBlock
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении истории событий:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика
|
||||
*/
|
||||
export const getDLEStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-dle-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики DLE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
31
frontend/src/services/index.js
Normal file
31
frontend/src/services/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2025 Тарабанов Александр Викторович
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is proprietary and confidential.
|
||||
* Unauthorized copying, modification, or distribution is prohibited.
|
||||
*
|
||||
* For licensing inquiries: info@hb3-accelerator.com
|
||||
* Website: https://hb3-accelerator.com
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Индексный файл для экспорта всех сервисов DLE
|
||||
|
||||
// Основные функции DLE
|
||||
export * from './dleV2Service.js';
|
||||
|
||||
// Модули
|
||||
export * from './modulesService.js';
|
||||
|
||||
// Предложения
|
||||
export * from './proposalsService.js';
|
||||
|
||||
// Токены
|
||||
export * from './tokensService.js';
|
||||
|
||||
// Аналитика
|
||||
export * from './analyticsService.js';
|
||||
|
||||
// Мультичейн
|
||||
export * from './multichainService.js';
|
||||
297
frontend/src/services/modulesService.js
Normal file
297
frontend/src/services/modulesService.js
Normal file
@@ -0,0 +1,297 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2025 Тарабанов Александр Викторович
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is proprietary and confidential.
|
||||
* Unauthorized copying, modification, or distribution is prohibited.
|
||||
*
|
||||
* For licensing inquiries: info@hb3-accelerator.com
|
||||
* Website: https://hb3-accelerator.com
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Сервис для работы с модулями DLE
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* Создает предложение о добавлении модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} moduleData - Данные модуля
|
||||
* @returns {Promise<Object>} - Результат создания
|
||||
*/
|
||||
export const createAddModuleProposal = async (dleAddress, moduleData) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-modules/create-add-module-proposal', {
|
||||
dleAddress,
|
||||
...moduleData
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при создании предложения добавления модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Создает предложение об удалении модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} moduleData - Данные модуля
|
||||
* @returns {Promise<Object>} - Результат создания
|
||||
*/
|
||||
export const createRemoveModuleProposal = async (dleAddress, moduleData) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-modules/create-remove-module-proposal', {
|
||||
dleAddress,
|
||||
...moduleData
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при создании предложения удаления модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет активность модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @returns {Promise<Object>} - Статус активности
|
||||
*/
|
||||
export const isModuleActive = async (dleAddress, moduleId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-modules/is-module-active', {
|
||||
dleAddress,
|
||||
moduleId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке активности модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает адрес модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @returns {Promise<Object>} - Адрес модуля
|
||||
*/
|
||||
export const getModuleAddress = async (dleAddress, moduleId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-modules/get-module-address', {
|
||||
dleAddress,
|
||||
moduleId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении адреса модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает список всех модулей
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Список модулей
|
||||
*/
|
||||
export const getAllModules = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-modules/get-all-modules', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении списка модулей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает информацию о модуле
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @returns {Promise<Object>} - Информация о модуле
|
||||
*/
|
||||
export const getModuleInfo = async (dleAddress, moduleId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-module-info', {
|
||||
dleAddress,
|
||||
moduleId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении информации о модуле:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику модулей
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика модулей
|
||||
*/
|
||||
export const getModulesStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-modules-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики модулей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает историю модулей
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} filters - Фильтры
|
||||
* @returns {Promise<Object>} - История модулей
|
||||
*/
|
||||
export const getModulesHistory = async (dleAddress, filters = {}) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-modules-history', {
|
||||
dleAddress,
|
||||
...filters
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении истории модулей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает активные модули
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Активные модули
|
||||
*/
|
||||
export const getActiveModules = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-active-modules', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении активных модулей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает неактивные модули
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Неактивные модули
|
||||
*/
|
||||
export const getInactiveModules = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-inactive-modules', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении неактивных модулей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет совместимость модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @param {string} moduleAddress - Адрес модуля
|
||||
* @returns {Promise<Object>} - Совместимость модуля
|
||||
*/
|
||||
export const checkModuleCompatibility = async (dleAddress, moduleId, moduleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/check-module-compatibility', {
|
||||
dleAddress,
|
||||
moduleId,
|
||||
moduleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке совместимости модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает конфигурацию модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @returns {Promise<Object>} - Конфигурация модуля
|
||||
*/
|
||||
export const getModuleConfig = async (dleAddress, moduleId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-module-config', {
|
||||
dleAddress,
|
||||
moduleId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении конфигурации модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Обновляет конфигурацию модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @param {Object} config - Новая конфигурация
|
||||
* @returns {Promise<Object>} - Результат обновления
|
||||
*/
|
||||
export const updateModuleConfig = async (dleAddress, moduleId, config) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/update-module-config', {
|
||||
dleAddress,
|
||||
moduleId,
|
||||
config
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при обновлении конфигурации модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает события модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @param {Object} filters - Фильтры
|
||||
* @returns {Promise<Object>} - События модуля
|
||||
*/
|
||||
export const getModuleEvents = async (dleAddress, moduleId, filters = {}) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-module-events', {
|
||||
dleAddress,
|
||||
moduleId,
|
||||
...filters
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении событий модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает производительность модуля
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} moduleId - ID модуля
|
||||
* @returns {Promise<Object>} - Производительность модуля
|
||||
*/
|
||||
export const getModulePerformance = async (dleAddress, moduleId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-module-performance', {
|
||||
dleAddress,
|
||||
moduleId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении производительности модуля:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
352
frontend/src/services/multichainService.js
Normal file
352
frontend/src/services/multichainService.js
Normal file
@@ -0,0 +1,352 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2025 Тарабанов Александр Викторович
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is proprietary and confidential.
|
||||
* Unauthorized copying, modification, or distribution is prohibited.
|
||||
*
|
||||
* For licensing inquiries: info@hb3-accelerator.com
|
||||
* Website: https://hb3-accelerator.com
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Сервис для работы с мульти-чейн функциональностью DLE
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* Получает список поддерживаемых сетей
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Список сетей
|
||||
*/
|
||||
export const getSupportedChains = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/get-supported-chains', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении поддерживаемых сетей:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет поддержку сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Статус поддержки
|
||||
*/
|
||||
export const isChainSupported = async (dleAddress, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/is-chain-supported', {
|
||||
dleAddress,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке поддержки сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает текущую сеть
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Текущая сеть
|
||||
*/
|
||||
export const getCurrentChainId = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-current-chain-id', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении текущей сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Исполняет предложение по подписям
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} executionData - Данные исполнения
|
||||
* @returns {Promise<Object>} - Результат исполнения
|
||||
*/
|
||||
export const executeProposalBySignatures = async (dleAddress, executionData) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/execute-proposal-by-signatures', {
|
||||
dleAddress,
|
||||
...executionData
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при исполнении предложения по подписям:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет готовность синхронизации
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Готовность синхронизации
|
||||
*/
|
||||
export const checkSyncReadiness = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/check-sync-readiness', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке готовности синхронизации:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Синхронизирует предложение во все сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Результат синхронизации
|
||||
*/
|
||||
export const syncToAllChains = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/sync-to-all-chains', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при синхронизации во все сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статус синхронизации
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Статус синхронизации
|
||||
*/
|
||||
export const getSyncStatus = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-sync-status', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статуса синхронизации:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает информацию о сети
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Информация о сети
|
||||
*/
|
||||
export const getChainInfo = async (chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-chain-info', {
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении информации о сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает RPC URL для сети
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - RPC URL
|
||||
*/
|
||||
export const getRpcUrl = async (chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-rpc-url', {
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении RPC URL:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет подключение к сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Статус подключения
|
||||
*/
|
||||
export const checkChainConnection = async (dleAddress, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-multichain/check-chain-connection', {
|
||||
dleAddress,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке подключения к сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает баланс в сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} userAddress - Адрес пользователя
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Баланс в сети
|
||||
*/
|
||||
export const getChainBalance = async (dleAddress, userAddress, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-chain-balance', {
|
||||
dleAddress,
|
||||
userAddress,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении баланса в сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает предложения в сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Предложения в сети
|
||||
*/
|
||||
export const getChainProposals = async (dleAddress, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-chain-proposals', {
|
||||
dleAddress,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении предложений в сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает модули в сети
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Модули в сети
|
||||
*/
|
||||
export const getChainModules = async (dleAddress, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-chain-modules', {
|
||||
dleAddress,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении модулей в сети:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику по сетям
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика по сетям
|
||||
*/
|
||||
export const getChainsStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-chains-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики по сетям:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает события синхронизации
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} filters - Фильтры
|
||||
* @returns {Promise<Object>} - События синхронизации
|
||||
*/
|
||||
export const getSyncEvents = async (dleAddress, filters = {}) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-sync-events', {
|
||||
dleAddress,
|
||||
...filters
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении событий синхронизации:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает подписи для исполнения
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @param {number} chainId - ID сети
|
||||
* @returns {Promise<Object>} - Подписи для исполнения
|
||||
*/
|
||||
export const getExecutionSignatures = async (dleAddress, proposalId, chainId) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-execution-signatures', {
|
||||
dleAddress,
|
||||
proposalId,
|
||||
chainId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении подписей для исполнения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Создает подпись для исполнения
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @param {number} chainId - ID сети
|
||||
* @param {string} userAddress - Адрес пользователя
|
||||
* @returns {Promise<Object>} - Результат создания подписи
|
||||
*/
|
||||
export const createExecutionSignature = async (dleAddress, proposalId, chainId, userAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/create-execution-signature', {
|
||||
dleAddress,
|
||||
proposalId,
|
||||
chainId,
|
||||
userAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при создании подписи для исполнения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает аналитику по сетям
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Аналитика по сетям
|
||||
*/
|
||||
export const getChainsAnalytics = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-chains-analytics', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении аналитики по сетям:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
263
frontend/src/services/proposalsService.js
Normal file
263
frontend/src/services/proposalsService.js
Normal file
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2025 Тарабанов Александр Викторович
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is proprietary and confidential.
|
||||
* Unauthorized copying, modification, or distribution is prohibited.
|
||||
*
|
||||
* For licensing inquiries: info@hb3-accelerator.com
|
||||
* Website: https://hb3-accelerator.com
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Сервис для работы с предложениями DLE
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* Получает список всех предложений
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Список предложений
|
||||
*/
|
||||
export const getProposals = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-proposals', { dleAddress });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении предложений:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает информацию о конкретном предложении
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Информация о предложении
|
||||
*/
|
||||
export const getProposalInfo = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-proposal-info', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении информации о предложении:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Создает новое предложение
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {Object} proposalData - Данные предложения
|
||||
* @returns {Promise<Object>} - Результат создания
|
||||
*/
|
||||
export const createProposal = async (dleAddress, proposalData) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/create-proposal', {
|
||||
dleAddress,
|
||||
...proposalData
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при создании предложения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Голосует за предложение
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @param {boolean} support - Поддержка предложения
|
||||
* @returns {Promise<Object>} - Результат голосования
|
||||
*/
|
||||
export const voteOnProposal = async (dleAddress, proposalId, support) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/vote-proposal', {
|
||||
dleAddress,
|
||||
proposalId,
|
||||
support
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при голосовании:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Исполняет предложение
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Результат исполнения
|
||||
*/
|
||||
export const executeProposal = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/execute-proposal', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при исполнении предложения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Отменяет предложение
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @param {string} reason - Причина отмены
|
||||
* @returns {Promise<Object>} - Результат отмены
|
||||
*/
|
||||
export const cancelProposal = async (dleAddress, proposalId, reason) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/cancel-proposal', {
|
||||
dleAddress,
|
||||
proposalId,
|
||||
reason
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при отмене предложения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает состояние предложения
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Состояние предложения
|
||||
*/
|
||||
export const getProposalState = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-proposal-state', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении состояния предложения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает голоса по предложению
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Голоса по предложению
|
||||
*/
|
||||
export const getProposalVotes = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-proposal-votes', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении голосов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Проверяет результат предложения
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} proposalId - ID предложения
|
||||
* @returns {Promise<Object>} - Результат проверки
|
||||
*/
|
||||
export const checkProposalResult = async (dleAddress, proposalId) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/check-proposal-result', {
|
||||
dleAddress,
|
||||
proposalId
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при проверке результата предложения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает количество предложений
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Количество предложений
|
||||
*/
|
||||
export const getProposalsCount = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-proposals-count', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении количества предложений:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает список предложений с пагинацией
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} offset - Смещение
|
||||
* @param {number} limit - Лимит
|
||||
* @returns {Promise<Object>} - Список предложений
|
||||
*/
|
||||
export const listProposals = async (dleAddress, offset = 0, limit = 10) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/list-proposals', {
|
||||
dleAddress,
|
||||
offset,
|
||||
limit
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении списка предложений:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает голосующую силу на момент времени
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} voter - Адрес голосующего
|
||||
* @param {number} timepoint - Временная точка
|
||||
* @returns {Promise<Object>} - Голосующая сила
|
||||
*/
|
||||
export const getVotingPowerAt = async (dleAddress, voter, timepoint) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-voting-power-at', {
|
||||
dleAddress,
|
||||
voter,
|
||||
timepoint
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении голосующей силы:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает требуемый кворум на момент времени
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} timepoint - Временная точка
|
||||
* @returns {Promise<Object>} - Требуемый кворум
|
||||
*/
|
||||
export const getQuorumAt = async (dleAddress, timepoint) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-proposals/get-quorum-at', {
|
||||
dleAddress,
|
||||
timepoint
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении требуемого кворума:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -10,28 +10,174 @@
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
import api from '../api/axios';
|
||||
// Сервис для работы с токенами DLE
|
||||
import axios from 'axios';
|
||||
|
||||
// Получение балансов токенов
|
||||
export const fetchTokenBalances = async (address = null) => {
|
||||
/**
|
||||
* Получает балансы токенов для пользователя
|
||||
* @param {string} userAddress - Адрес пользователя
|
||||
* @returns {Promise<Object>} - Балансы токенов
|
||||
*/
|
||||
export const getTokenBalances = async (userAddress) => {
|
||||
try {
|
||||
let url = '/tokens/balances';
|
||||
if (address) {
|
||||
url += `?address=${encodeURIComponent(address)}`;
|
||||
// console.log(`Fetching token balances for specific address: ${address}`);
|
||||
} else {
|
||||
// console.log('Fetching token balances for session user');
|
||||
}
|
||||
const response = await api.get(url);
|
||||
const response = await axios.get(`/tokens/balances/${userAddress}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
// console.error('Error fetching token balances:', error);
|
||||
return {
|
||||
eth: '0',
|
||||
bsc: '0',
|
||||
arbitrum: '0',
|
||||
polygon: '0',
|
||||
sepolia: '0',
|
||||
};
|
||||
console.error('Ошибка при получении балансов токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает баланс токенов конкретного DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} userAddress - Адрес пользователя
|
||||
* @returns {Promise<Object>} - Баланс токенов
|
||||
*/
|
||||
export const getDLEBalance = async (dleAddress, userAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-balance', {
|
||||
dleAddress,
|
||||
account: userAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении баланса DLE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает общее предложение токенов DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Общее предложение
|
||||
*/
|
||||
export const getDLETotalSupply = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-total-supply', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении общего предложения DLE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает список держателей токенов DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} offset - Смещение
|
||||
* @param {number} limit - Лимит
|
||||
* @returns {Promise<Object>} - Список держателей
|
||||
*/
|
||||
export const getDLETokenHolders = async (dleAddress, offset = 0, limit = 10) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-holders', {
|
||||
dleAddress,
|
||||
offset,
|
||||
limit
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении держателей токенов DLE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает голосующую силу пользователя на момент времени
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} userAddress - Адрес пользователя
|
||||
* @param {number} timepoint - Временная точка
|
||||
* @returns {Promise<Object>} - Голосующая сила
|
||||
*/
|
||||
export const getVotingPower = async (dleAddress, userAddress, timepoint) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-voting-power-at', {
|
||||
dleAddress,
|
||||
voter: userAddress,
|
||||
timepoint
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении голосующей силы:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает требуемый кворум на момент времени
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} timepoint - Временная точка
|
||||
* @returns {Promise<Object>} - Требуемый кворум
|
||||
*/
|
||||
export const getQuorumRequirement = async (dleAddress, timepoint) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-quorum-at', {
|
||||
dleAddress,
|
||||
timepoint
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении требуемого кворума:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает статистику токенов DLE
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Статистика токенов
|
||||
*/
|
||||
export const getTokenStats = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-stats', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении статистики токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает историю транзакций токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} userAddress - Адрес пользователя (опционально)
|
||||
* @param {number} fromBlock - Начальный блок
|
||||
* @param {number} toBlock - Конечный блок
|
||||
* @returns {Promise<Object>} - История транзакций
|
||||
*/
|
||||
export const getTokenTransactionHistory = async (dleAddress, userAddress = null, fromBlock = null, toBlock = null) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-transactions', {
|
||||
dleAddress,
|
||||
userAddress,
|
||||
fromBlock,
|
||||
toBlock
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении истории транзакций токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает распределение токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Распределение токенов
|
||||
*/
|
||||
export const getTokenDistribution = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/blockchain/get-token-distribution', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении распределения токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
71
frontend/src/services/tokensService.js
Normal file
71
frontend/src/services/tokensService.js
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright (c) 2024-2025 Тарабанов Александр Викторович
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is proprietary and confidential.
|
||||
* Unauthorized copying, modification, or distribution is prohibited.
|
||||
*
|
||||
* For licensing inquiries: info@hb3-accelerator.com
|
||||
* Website: https://hb3-accelerator.com
|
||||
* GitHub: https://github.com/HB3-ACCELERATOR
|
||||
*/
|
||||
|
||||
// Сервис для работы с токенами DLE
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* Получает баланс токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {string} account - Адрес аккаунта
|
||||
* @returns {Promise<Object>} - Баланс токенов
|
||||
*/
|
||||
export const getTokenBalance = async (dleAddress, account) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-tokens/get-token-balance', {
|
||||
dleAddress,
|
||||
account
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении баланса токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает общее предложение токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @returns {Promise<Object>} - Общее предложение
|
||||
*/
|
||||
export const getTotalSupply = async (dleAddress) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-tokens/get-total-supply', {
|
||||
dleAddress
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении общего предложения:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Получает список держателей токенов
|
||||
* @param {string} dleAddress - Адрес DLE
|
||||
* @param {number} offset - Смещение
|
||||
* @param {number} limit - Лимит
|
||||
* @returns {Promise<Object>} - Список держателей
|
||||
*/
|
||||
export const getTokenHolders = async (dleAddress, offset = 0, limit = 10) => {
|
||||
try {
|
||||
const response = await axios.post('/dle-tokens/get-token-holders', {
|
||||
dleAddress,
|
||||
offset,
|
||||
limit
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении держателей токенов:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user