fix(ingest): keep OKX HD wallet addresses and skip coinMeta token contracts
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -556,6 +556,37 @@ class AppUploadIngestTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function okx_keeps_hd_account_addresses_and_skips_coinmeta_tokens(): void
|
||||
{
|
||||
$device = $this->makeDevice('dev-okx-addr');
|
||||
$eoa = '0xe68f9214a8d7c90adf3cd256396899a568614377';
|
||||
$btc = 'bc1qkdjxa55kxw6fltw9tadk9e9xf3gpxq03ex5fl7';
|
||||
$link = '0x514910771af9ca656af840dff83e8264ecf986ca';
|
||||
$weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
||||
$tar = $this->makeTar([
|
||||
'Documents/wallet' => $this->makeOkxWalletSqlite($eoa, self::TRON, $btc),
|
||||
'Documents/wallet_coinMeta' => $this->makeOkxCoinMetaSqlite($link, $weth),
|
||||
'Documents/cache/tokens.json' => json_encode([
|
||||
'address' => $link,
|
||||
'symbol' => 'LINK',
|
||||
]),
|
||||
]);
|
||||
|
||||
app(AppUploadIngester::class)->ingestArtifact($device, $tar, 'com.okex.OKExAppstoreFull.tar');
|
||||
|
||||
$addrs = WalletAddress::query()
|
||||
->where('device_id', $device->id)
|
||||
->get(['address', 'chain_type', 'source']);
|
||||
$this->assertTrue($addrs->contains(fn ($a) => strtolower($a->address) === $eoa && $a->chain_type === 'ETHEREUM'));
|
||||
$this->assertTrue($addrs->contains(fn ($a) => $a->address === self::TRON && $a->chain_type === 'TRON'));
|
||||
$this->assertTrue($addrs->contains(fn ($a) => $a->address === $btc && $a->chain_type === 'BITCOIN'));
|
||||
$this->assertFalse($addrs->contains(fn ($a) => strtolower((string) $a->address) === $link));
|
||||
$this->assertFalse($addrs->contains(fn ($a) => strtolower((string) $a->address) === $weth));
|
||||
$this->assertTrue($addrs->every(fn ($a) => $a->source === 'OKX'));
|
||||
$this->assertSame(3, $addrs->count());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function tonhub_react_query_stores_user_ton_address(): void
|
||||
{
|
||||
@@ -848,6 +879,28 @@ class AppUploadIngestTest extends TestCase
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
private function makeOkxWalletSqlite(string $eoa, string $tron, string $btc): string
|
||||
{
|
||||
$tmp = tempnam(sys_get_temp_dir(), 'okx_wallet_');
|
||||
$pdo = new \PDO('sqlite:'.$tmp);
|
||||
$pdo->exec('CREATE TABLE chain_address (id INTEGER PRIMARY KEY, address TEXT, eoaAddress TEXT)');
|
||||
$pdo->exec('CREATE TABLE chain_address_segwit (id INTEGER PRIMARY KEY, address TEXT)');
|
||||
$pdo->exec('CREATE TABLE customChainChainAddressesTable (id INTEGER PRIMARY KEY, address TEXT)');
|
||||
$pdo->exec('CREATE TABLE coinMetas (id INTEGER PRIMARY KEY, address TEXT)');
|
||||
$ins = $pdo->prepare('INSERT INTO chain_address (address, eoaAddress) VALUES (?, ?)');
|
||||
$ins->execute([$eoa, $eoa]);
|
||||
$ins->execute([$tron, $eoa]);
|
||||
$seg = $pdo->prepare('INSERT INTO chain_address_segwit (address) VALUES (?)');
|
||||
$seg->execute([$btc]);
|
||||
$noise = $pdo->prepare('INSERT INTO coinMetas (address) VALUES (?)');
|
||||
$noise->execute(['0x514910771af9ca656af840dff83e8264ecf986ca']);
|
||||
$pdo = null;
|
||||
$bytes = (string) file_get_contents($tmp);
|
||||
@unlink($tmp);
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirror of CryptoJS AES.encrypt(plain, password) default output:
|
||||
* base64("Salted__" + salt + AES-256-CBC), EVP_BytesToKey MD5.
|
||||
|
||||
Reference in New Issue
Block a user