Skip to content

Fix EVM wallets stuck at 50% sync when only evmScanApiKey is configured - #6115

Open
j0ntz wants to merge 1 commit into
developfrom
jon/fix/evm-sync-etherscan-key
Open

Fix EVM wallets stuck at 50% sync when only evmScanApiKey is configured#6115
j0ntz wants to merge 1 commit into
developfrom
jon/fix/evm-sync-etherscan-key

Conversation

@j0ntz

@j0ntz j0ntz commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

This is a stopgap for EdgeApp/edge-currency-accountbased#1078, which fixes the same defect at its source. Remove this shim once the app depends on a release carrying that fix.

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

No visual changes. Tested on the iOS simulator because the fix is only observable as wallet sync behavior.

Description

Asana task

Coinhub reported that ETH will not sync, sitting at 50% for both new and existing ETH wallets, and that resyncing does not help. It survived a full rebase of their branch onto develop because it was never a code defect in that branch, it is a configuration trap.

edge-currency-accountbased's getEvmScanApiKey resolves the Etherscan key for api.etherscan.io from the deprecated etherscanApiKey init option, and throws before it considers evmScanApiKey, which is the option this repo declares and cleans in src/envConfig.ts:

if (serverUrl.includes('etherscan.io')) {
  if (etherscanApiKey == null)
    throw new Error(`Missing etherscanApiKey for etherscan.io`)
  return etherscanApiKey
}
if (evmScanApiKey != null) return evmScanApiKey   // never reached for etherscan.io

So a build box whose env.json carries only the documented evmScanApiKey sends no key at all, and Etherscan V2 rejects keyless requests:

{"status":"0","message":"NOTOK","result":"Missing/Invalid API Key"}

EvmScanAdapter is the only adapter with a non-null fetchTxs on the 15 EVM networks routed through that host (RpcAdapter, BlockbookAdapter and AmberdataAdapter all set it to null), so transaction history never completes. The plugin's makeTokenSyncTracker averages balance and history progress, so a wallet with a complete balance and no history reports exactly 0.5, which the app renders as a wallet permanently stuck at 50%.

Edge's own env.json still carries the legacy etherscanApiKey, which is why the Edge app is unaffected and why this only surfaced on a white-label build. Any build box provisioned from the key set this repo documents hits it.

This supplies the deprecated option from the supported one at the env layer, which takes effect without waiting on a plugin release. An explicitly configured etherscanApiKey still wins, and an empty evmScanApiKey adds nothing.

Testing

Verified end to end on the iOS simulator against an env.json shaped like a build box (only evmScanApiKey, no etherscanApiKey), on the same account and the same ETH wallet in both passes:

  • Before: resyncing the ETH wallet left it at Loading Transactions... 49.9% Complete with an empty transaction list, exactly as reported.
  • After: with only this commit applied and the same env.json, the transaction list fully repopulated and the sync indicator cleared.

Screenshots of both states are attached in a comment below.

Also:

  • New unit tests in src/__tests__/envConfig.test.ts cover the derivation, an explicit etherscanApiKey winning, an unconfigured evmScanApiKey adding nothing, the behavior applying to every EVM plugin init, and a disabled plugin init staying false.
  • tsc --noEmit: clean.
  • jest --ci: 94 suites, 567 tests, 107 snapshots, all passing. Also re-run green under APP_CONFIG=coinhub (93 suites, 562 tests) on the coinhub branch, where this commit is cherry-picked.

Note

Low Risk
Configuration-layer shim with explicit precedence rules and unit tests; no auth or payment logic; temporary until the currency plugin fix ships.

Overview
Stopgap for EVM wallets stuck at ~50% sync when env.json only sets evmScanApiKey (no legacy etherscanApiKey). The account-based currency plugin still resolves Etherscan keys for api.etherscan.io from etherscanApiKey only, so keyless V2 requests fail and transaction history never completes—balance sync finishes while history stays empty, which averages to ~50% in the UI.

At env load, asEvmApiKeys now copies evmScanApiKey into etherscanApiKey when the deprecated field is missing or empty; an explicit etherscanApiKey still wins, and empty evmScanApiKey adds nothing. Applies to all EVM plugin init blocks (not only Ethereum). New tests in envConfig.test.ts cover derivation, precedence, and disabled plugins. CHANGELOG updated. Remove this shim after the app depends on a plugin release with the upstream fix.

Reviewed by Cursor Bugbot for commit 030444b. Bugbot is set up for automated code reviews on this repo. Configure here.

edge-currency-accountbased resolves the Etherscan API key for
api.etherscan.io from the deprecated etherscanApiKey init option and throws
before it considers evmScanApiKey, the option this repo documents and
cleans. A build whose env.json carries only evmScanApiKey therefore sends a
keyless request, which Etherscan V2 rejects with 'Missing/Invalid API Key'.

The EvmScan adapter is the only adapter with a non-null fetchTxs on the 15
EVM networks routed through that host, so the rejected request leaves
transaction history permanently unsynced. The token sync tracker averages
balance and history progress, so a wallet with a complete balance and no
history reports exactly 0.5 and the app shows it stuck at 50% forever.

Supply the deprecated option from the supported one at the env layer, which
takes effect without waiting on a plugin release. An explicitly configured
etherscanApiKey still wins, and an empty evmScanApiKey adds nothing.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@j0ntz

j0ntz commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence: ETH sync before vs after

eth stuck 50 prefix

eth stuck 50 prefix

eth synced postfix

eth synced postfix

Captured by the agent's in-app test run (build-and-test).

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.

1 participant