sdsf
All checks were successful
Deploy / deploy-staging (push) Successful in 25s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-22 00:12:32 +02:00
parent 5c615aa878
commit 650a0bd11a
10 changed files with 413 additions and 34 deletions

View File

@@ -271,6 +271,20 @@ final class Router
Http::json(['data' => $this->saveWalletSnapshot($projectKey, Http::input())], 201);
}
if ($resource === 'wallet-withdrawals' && $method === 'GET') {
Http::json(['data' => $this->walletWithdrawals($projectKey)]);
}
if ($resource === 'wallet-withdrawals' && $method === 'POST') {
$this->repository()->ensureProject($projectKey);
Http::json(['data' => $this->saveWalletWithdrawal($projectKey, Http::input())], 201);
}
if (preg_match('~^wallet-withdrawals/(\d+)$~', $resource, $matches) && $method === 'DELETE') {
$this->deleteWalletWithdrawal($projectKey, (int) $matches[1]);
Http::json(['data' => ['deleted' => true]]);
}
if ($resource === 'miner-offers' && $method === 'GET') {
Http::json(['data' => $this->minerOffers($projectKey)]);
}
@@ -343,6 +357,7 @@ final class Router
'cost_plans' => [],
'currencies' => [],
'payouts' => [],
'wallet_withdrawals' => [],
'miner_offers' => [],
'purchased_miners' => [],
'measurement_rates' => [],
@@ -1161,6 +1176,7 @@ final class Router
$includeCostPlans = !array_key_exists('cost_plans', $options) || (bool) $options['cost_plans'];
$includeCurrencies = !array_key_exists('currencies', $options) || (bool) $options['currencies'];
$includePayouts = !array_key_exists('payouts', $options) || (bool) $options['payouts'];
$includeWalletWithdrawals = !array_key_exists('wallet_withdrawals', $options) || (bool) $options['wallet_withdrawals'];
$includeMinerOffers = !array_key_exists('miner_offers', $options) || (bool) $options['miner_offers'];
$includePurchasedMiners = !array_key_exists('purchased_miners', $options) || (bool) $options['purchased_miners'];
@@ -1177,6 +1193,7 @@ final class Router
'module_theme_mode' => 'inherit',
'module_theme_accent' => 'teal',
'preferred_currencies' => $this->preferredCurrencies(),
'wallet_withdrawals' => [],
];
if (!$this->isValidTimezone((string) ($base['display_timezone'] ?? ''))) {
$base['display_timezone'] = nexus_display_timezone_name();
@@ -1192,6 +1209,7 @@ final class Router
$base['currencies'] = $includeCurrencies ? $this->currencies() : [];
$base['preferred_currencies'] = $this->preferredCurrencies($base['preferred_currencies'] ?? null);
$base['payouts'] = $includePayouts ? $this->payouts($projectKey) : [];
$base['wallet_withdrawals'] = $includeWalletWithdrawals ? $this->walletWithdrawals($projectKey) : [];
$base['miner_offers'] = $includeMinerOffers ? $this->minerOffers($projectKey) : [];
$base['purchased_miners'] = $includePurchasedMiners ? $this->purchasedMiners($projectKey) : [];
$base['measurement_rates'] = [];
@@ -1378,8 +1396,9 @@ final class Router
],
'wallet' => [
'cost_plans' => false,
'currencies' => false,
'payouts' => false,
'currencies' => true,
'payouts' => true,
'wallet_withdrawals' => true,
'miner_offers' => false,
'purchased_miners' => false,
],
@@ -1806,6 +1825,32 @@ final class Router
return $this->repository()->saveWalletSnapshot($projectKey, $payload);
}
private function walletWithdrawals(string $projectKey): array
{
if (!$this->repository()->tableExists('wallet_withdrawals')) {
return [];
}
return $this->repository()->listWalletWithdrawals($projectKey);
}
private function saveWalletWithdrawal(string $projectKey, array $input): array
{
$payload = [
'withdrawal_at' => $this->requiredDateTime($input['withdrawal_at'] ?? null, 'withdrawal_at', $this->projectTimezone($projectKey)),
'coins_amount' => $this->requiredDecimal($input['coins_amount'] ?? null, 'coins_amount'),
'withdrawal_currency' => $this->requiredCurrency($input['withdrawal_currency'] ?? 'DOGE', 'withdrawal_currency'),
'note' => $this->optionalString($input['note'] ?? null, 1000),
];
return $this->repository()->saveWalletWithdrawal($projectKey, $payload);
}
private function deleteWalletWithdrawal(string $projectKey, int $withdrawalId): void
{
$this->repository()->deleteWalletWithdrawal($projectKey, $withdrawalId);
}
private function saveMinerOffer(string $projectKey, array $input): array
{
$paymentType = $this->enumValue($input['payment_type'] ?? 'fiat', ['fiat', 'crypto'], 'payment_type');