Skip to content

refactor(chain): retire etherscan client, use RPC balanceOf - #1457

Merged
tieubao merged 1 commit into
developfrom
refactor/retire-etherscan-client
Jul 9, 2026
Merged

refactor(chain): retire etherscan client, use RPC balanceOf#1457
tieubao merged 1 commit into
developfrom
refactor/retire-etherscan-client

Conversation

@tieubao

@tieubao tieubao commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Final Alchemy-consolidation step: removes the Etherscan dependency from mochi-api entirely.

  • erc20TokenBalance (fund-path balance check) rewired from ch.scan.TokenBalance (etherscan) to the existing RawErc20TokenBalance RPC path (erc20.BalanceOf via eth_call) — same signature/return, callers unchanged. Live-probed: USDC balance for a Circle wallet returns a sane value via RPC.
  • Removed the orphaned Chain.TokenTotalSupply (defi.go moved to Alchemy earlier), the ch.scan etherscan client + its NewClient apiKey param (3 callers updated), the etherscan-api dep (go mod tidy).
  • Removed the already-dead EthereumScanAPIKey + EthereumScan config fields (ETHEREUM_SCAN_API_KEY/ETHEREUM_SCAN env), unused anywhere.
  • Net -85 lines. Audit: rg 'ch.scan|nanmu42/etherscan|ETHEREUM_SCAN' pkg/ go.mod → zero live refs.

ETHEREUM_SCAN_API_KEY can now leave Vault (was already unused by the binary; the etherscan client used the DB chains.api_key column, also now gone). Vault delete is a gated op.

CI baseline-broken (see #1438); 4 baseline entities fails unrelated.

🤖 Generated with Claude Code

erc20TokenBalance now calls the existing RawErc20TokenBalance (on-chain
balanceOf via the RPC client) instead of the etherscan-api TokenBalance
call, mirroring the RPC path already proven in RawErc20TokenBalance /
tokens.go. Chain.TokenTotalSupply is deleted (orphaned; defi.go already
migrated its caller to Alchemy). Drops the scan field, the
etherscan.NewCustomized construction, and the apiKey param from
NewClient; updates its 3 callers (tokens.go, vaultwallet.go,
discordwallet.go) to match. Removes the unused EthereumScan and
EthereumScanAPIKey config fields (ETHEREUM_SCAN / ETHEREUM_SCAN_API_KEY
env bindings) and the now-unused nanmu42/etherscan-api dependency via
go mod tidy.
@tieubao
tieubao merged commit 4527d0b into develop Jul 9, 2026
4 of 5 checks passed
@tieubao
tieubao deleted the refactor/retire-etherscan-client branch July 9, 2026 02:53
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