feat: ds
This commit is contained in:
@@ -83,6 +83,9 @@ class TokenviewMonitorService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tokenSymbol = strtoupper(trim((string) ($payload['tokenSymbol'] ?? '')));
|
$tokenSymbol = strtoupper(trim((string) ($payload['tokenSymbol'] ?? '')));
|
||||||
|
if (in_array($coin, ['TRX', 'TRON'], true) && ! in_array($tokenSymbol, ['TRX', 'USDT'], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$value = $payload['value'] ?? null;
|
$value = $payload['value'] ?? null;
|
||||||
$tokenValue = $payload['tokenValue'] ?? null;
|
$tokenValue = $payload['tokenValue'] ?? null;
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,35 @@ class TokenviewWebhookTest extends TestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function webhook_ignores_tron_when_token_is_not_trx_or_usdt(): void
|
||||||
|
{
|
||||||
|
config(['coruna.tokenview.sign_key' => '']);
|
||||||
|
$addr = $this->seedMonitoredAddress([
|
||||||
|
'address' => 'TKKyetwdwuv6fTWVMPsdQUZYwB7yiNwRp6',
|
||||||
|
'chain_type' => 'TRON',
|
||||||
|
'trx' => 1.0,
|
||||||
|
'usdt' => 10.0,
|
||||||
|
'eth' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'address' => 'TKKyetwdwuv6fTWVMPsdQUZYwB7yiNwRp6',
|
||||||
|
'txid' => 'tron-txid-usdc-skip-1',
|
||||||
|
'coin' => 'TRX',
|
||||||
|
'tokenSymbol' => 'USDC',
|
||||||
|
'tokenValue' => '99',
|
||||||
|
'value' => '0.1',
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->postJson('/hooks/tokenview', $payload)->assertOk()->assertSee('ok');
|
||||||
|
|
||||||
|
$addr->refresh();
|
||||||
|
$this->assertEqualsWithDelta(1.0, (float) $addr->trx, 0.0000001);
|
||||||
|
$this->assertEqualsWithDelta(10.0, (float) $addr->usdt, 0.0000001);
|
||||||
|
$this->assertSame(0, TokenviewEvent::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
public function webhook_ignores_address_when_monitor_off(): void
|
public function webhook_ignores_address_when_monitor_off(): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user