45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\WalletAddress;
|
|
use App\Services\Tokenview\TokenviewMonitorService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class EnableAllMonitorsCommand extends Command
|
|
{
|
|
protected $signature = 'coruna:enable-all-monitors';
|
|
|
|
protected $description = 'Turn on monitor=1 for all wallet addresses that should be monitored (Tokenview configured + supported chain). Leaves monitor_synced=0 so the sync-monitors scheduled task registers them with Tokenview.';
|
|
|
|
public function handle(TokenviewMonitorService $svc): int
|
|
{
|
|
$addresses = WalletAddress::query()->where('monitor', 0)->get();
|
|
|
|
if ($addresses->isEmpty()) {
|
|
$this->info('no monitor=0 addresses found.');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$enabled = 0;
|
|
$skipped = 0;
|
|
foreach ($addresses as $addr) {
|
|
if ($svc->shouldMonitor($addr)) {
|
|
$addr->monitor = 1;
|
|
$addr->monitor_synced = false; // will be synced by scheduled task
|
|
$addr->monitor_failures = 0; // reset retry budget
|
|
$addr->save();
|
|
$this->line(" enabled: {$addr->address} ({$addr->chain_type})");
|
|
$enabled++;
|
|
} else {
|
|
$skipped++;
|
|
}
|
|
}
|
|
|
|
$this->info("enabled={$enabled} skipped={$skipped} total=".count($addresses));
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|