Feature: Implemented Dynamic Admin Settings for Platform Addresses and Security Guidelines for Private Keys

This commit is contained in:
mstfyldz
2026-03-12 23:53:23 +03:00
parent 1e460d0072
commit 8f9b600828
4 changed files with 250 additions and 119 deletions

19
lib/settings.ts Normal file
View File

@@ -0,0 +1,19 @@
import { db } from './db';
export async function getSystemSetting(key: string, defaultValue: string = ''): Promise<string> {
try {
const result = await db.query('SELECT value FROM system_settings WHERE key = $1', [key]);
if (result.rows.length > 0) {
return result.rows[0].value;
}
} catch (err) {
console.error(`[Settings] Failed to fetch key ${key}:`, err);
}
return defaultValue;
}
export async function getPlatformAddresses() {
const sol = await getSystemSetting('sol_platform_address', process.env.SOL_PLATFORM_ADDRESS || '');
const evm = await getSystemSetting('evm_platform_address', process.env.EVM_PLATFORM_ADDRESS || '');
return { sol, evm };
}