Skip to content

Conversation

@peachbits
Copy link
Contributor

@peachbits peachbits commented Dec 12, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Migrates on‑disk transaction data to tokenId keys, refactors Ethereum update flow for partial status, normalizes Ripple token codes, adds Thorchain rate‑limit backoff, and fixes Zcash balance update recursion.

  • Common:
    • Migrate persisted transaction data from currencyCode keys to tokenId keys with in-engine migration in CurrencyEngine.loadTransactions() and helper migrateCurrencyCodeToTokenId().
    • Initialize transaction caches with null tokenId key '' and include null in sync progress (updateOnAddressesChecked).
  • Ethereum:
    • Refactor EthereumNetwork.acquireUpdates() to build update tasks (balances/txs), run them with error aggregation, and allow partial status updates.
    • Process tx updates for native (tokenId: null) as well in processEthereumNetworkUpdate.
    • Remove deprecated zkSync USDC resync hack and corresponding field from asEthereumWalletOtherData; simplify EthereumEngine.setOtherData.
  • Ripple:
    • Normalize currency codes/denomination names for Gatehub/Bitstamp/Stably USD/EUR tokens to USD/EUR in src/ripple/rippleInfo.ts.
  • Thorchain:
    • Add brief snooze before throwing on non-OK Midgard responses to mitigate rate limits in ThorchainEngine.queryTransactions().
  • Zcash:
    • Fix ZcashEngine.updateBalance to avoid recursive call; directly updates totalBalances[''] and callback.
  • Docs:
    • CHANGELOG: Note migration to tokenId keys and ETH update refactor.

Written by Cursor Bugbot for commit 6b5b582. This will update automatically on new commits. Configure here.


{
name: 'USD.st',
name: 'USD',
multiplier: '1000000000000000000'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Ripple migration loses data due to renamed currency codes

The Ripple token currency codes were changed from unique values (USD.gh, USD.bs, USD.st, EUR.gh, EUR.bs) to duplicated simple values (USD, EUR). The migrateCurrencyCodeToTokenId function looks up tokens by matching currencyCode against stored keys from old data. Since the old currency codes like USD.gh no longer exist in any token definition, the migration will skip these entries (continue at line 359), causing transaction history loss for users with existing Ripple token data stored under the old currency code keys.

Additional Locations (1)

Fix in Cursor Fix in Web

txIdMap[''] == null) ||
(transactionList != null &&
Object.keys(transactionList).length > 0 &&
transactionList[''] == null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Re-migration destroys already-migrated token-only wallet data

The needsMigration heuristic uses data[''] == null to detect unmigrated data, assuming migrated data always has an empty string key for native currency. However, wallets with only token transactions (no native currency transactions) won't have this key after migration. On subsequent loads, the heuristic incorrectly triggers re-migration on already-migrated data. When migrateCurrencyCodeToTokenId processes tokenId keys (like contract addresses), they don't match any token's currencyCode, causing all entries to be silently dropped via the continue statement, resulting in complete transaction history loss.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

@swansontec swansontec Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor makes a fair point. Would it be possible to set txIdList[''] ?= [] and so forth to ensure we never double-migrate? Otherwise, perhaps adding a otherData.tokenIdMigrated flag could prevent double migrations.

@adrewmarkvanz
Copy link

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none
Note

Migrate on‑disk transaction data from currencyCode to tokenId keys, refactor Ethereum update flow for partial progress (including native token), normalize XRP token codes, and add Midgard rate‑limit backoff.

  • Core:

    • Migrate on‑disk transaction data from currencyCode keys to tokenId keys in src/common/CurrencyEngine.ts (with automatic migration on load).
    • Include null tokenId in sync progress calculation (updateOnAddressesChecked).
  • Ethereum:

    • Refactor EthereumNetwork.acquireUpdates to queue update steps and continue on errors (throw first at end) enabling partial status updates.
    • Process native (null) token transactions in processEthereumNetworkUpdate (no longer skipped).
    • Remove zkSync USDC resync hack and zksyncForceResyncUSDC field from EthereumEngine.setOtherData and asEthereumWalletOtherData.
  • Thorchain:

    • Add 1s backoff (snooze) on non‑OK Midgard responses to handle rate‑limits.
  • Ripple (XRP):

    • Normalize Gatehub/Bitstamp/Stably USD/EUR token currencyCode and denomination names (remove suffixes like .gh, .bs, .st).

Written by Cursor Bugbot for commit 63d4743. This will update automatically on new commits. Configure here.

Copy link
Contributor

@swansontec swansontec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good overall, just one safety thing would be good to add.

txIdMap[''] == null) ||
(transactionList != null &&
Object.keys(transactionList).length > 0 &&
transactionList[''] == null)
Copy link
Contributor

@swansontec swansontec Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor makes a fair point. Would it be possible to set txIdList[''] ?= [] and so forth to ensure we never double-migrate? Otherwise, perhaps adding a otherData.tokenIdMigrated flag could prevent double migrations.

@peachbits peachbits force-pushed the matthew/sans-currency-code-fixes branch from a006947 to 6f43ec2 Compare December 16, 2025 20:04
@peachbits peachbits force-pushed the matthew/sans-currency-code-fixes branch from 6f43ec2 to a006a37 Compare December 16, 2025 21:11
@peachbits peachbits enabled auto-merge December 16, 2025 21:11
The transactions have to be queried newest to oldest so the function is written to retry regardless of errors.
This preserves the balance handling that existed prior to the tokenId upgrade
@peachbits peachbits force-pushed the matthew/sans-currency-code-fixes branch from a006a37 to 6b5b582 Compare December 16, 2025 21:44
const currentBalance = this.getBalance({ tokenId })
if (currentBalance == null || !eq(balance, currentBalance)) {
this.updateBalance(tokenId, balance)
this.walletLocalData.totalBalances[''] = balance
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: ZcashEngine ignores tokenId when storing balance

The updateBalance method stores the balance using a hardcoded '' key instead of using the tokenId parameter as tokenId ?? '' like the base class does. This means the tokenId parameter is ignored for storage, and any balance update would incorrectly write to the native token's key regardless of which token was specified. The callback on line 224 correctly uses tokenId, creating an inconsistency where the reported token differs from where the balance is actually stored.

Fix in Cursor Fix in Web

@peachbits peachbits merged commit 6c4cf8f into master Dec 16, 2025
3 checks passed
@peachbits peachbits deleted the matthew/sans-currency-code-fixes branch December 16, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants