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

View File

@@ -45,10 +45,18 @@ export async function POST(request: Request) {
return NextResponse.json({ success: false, error: `No temporary wallet found for ${walletType}` }, { status: 500 });
}
// 3. Define Platform Address (In production, load from env/settings)
const platformAddress = selectedNetwork === 'SOLANA'
? process.env.SOL_PLATFORM_ADDRESS || "5pLH1tqZhx8p8WpZ18yr28N42KXB3FXVPzZ9ceCtpBVe"
: process.env.EVM_PLATFORM_ADDRESS || "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";
// 3. Define Platform Address (Fetch from dynamic settings)
const platformAddresses = await (async () => {
const result = await db.query('SELECT key, value FROM system_settings WHERE key IN (\'sol_platform_address\', \'evm_platform_address\')');
const map: Record<string, string> = {};
result.rows.forEach(r => map[r.key] = r.value);
return {
sol: map.sol_platform_address || process.env.SOL_PLATFORM_ADDRESS || "5pLH1tqZhx8p8WpZ18yr28N42KXB3FXVPzZ9ceCtpBVe",
evm: map.evm_platform_address || process.env.EVM_PLATFORM_ADDRESS || "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
};
})();
const platformAddress = selectedNetwork === 'SOLANA' ? platformAddresses.sol : platformAddresses.evm;
// 4. Define Merchant Address (Fetch from transaction's merchant)
const merchantResult = await db.query('SELECT * FROM merchants WHERE id = $1', [transaction.merchant_id]);