Feature: Implemented Dynamic Admin Settings for Platform Addresses and Security Guidelines for Private Keys
This commit is contained in:
19
lib/settings.ts
Normal file
19
lib/settings.ts
Normal 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 };
|
||||
}
|
||||
Reference in New Issue
Block a user