Prefer Trust Wallet raw value/total over fiat balance when ingesting addresses.

Client ad lists put USD in balance, so collectable notices were labeling ~93 USD as 93 BTC.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
root
2026-10-12 15:05:12 +00:00
parent c97a61d51f
commit c894f498b8
4 changed files with 95 additions and 4 deletions
+39
View File
@@ -58,6 +58,45 @@ class WalletSourceTest extends TestCase
$this->assertSame('i', WalletSource::tagForLabel('Phantom'));
}
#[Test]
public function trust_wallet_prefers_raw_value_over_fiat_balance(): void
{
$raw = WalletSource::clientAssetAmount([
'symbol' => 'BTC',
'decimals' => 8,
'balance' => 93.01116944632426,
'value' => '112737',
'total' => '112737',
]);
$this->assertSame('112737', $raw);
$this->assertEqualsWithDelta(0.00112737, (float) WalletSource::formatBalance($raw, 8), 1e-12);
}
#[Test]
public function client_asset_amount_falls_back_to_balance_when_no_raw_integer(): void
{
$raw = WalletSource::clientAssetAmount([
'symbol' => 'TRX',
'decimal' => '6',
'balance' => '83504102',
]);
$this->assertSame('83504102', $raw);
$this->assertEqualsWithDelta(83.504102, (float) WalletSource::formatBalance($raw, 6), 1e-12);
}
#[Test]
public function client_asset_amount_ignores_decimal_value_field(): void
{
$raw = WalletSource::clientAssetAmount([
'balance' => '112737',
'value' => '93.01',
]);
$this->assertSame('112737', $raw);
}
#[Test]
public function mnemonic_source_options_are_wallets_plus_manual(): void
{