Skip to content

fix: resolve deploy tx from receipts table for contract creation info#907

Open
decofe wants to merge 4 commits intomainfrom
centaur/fix-deploy-tx-lookup
Open

fix: resolve deploy tx from receipts table for contract creation info#907
decofe wants to merge 4 commits intomainfrom
centaur/fix-deploy-tx-lookup

Conversation

@decofe
Copy link
Copy Markdown
Member

@decofe decofe commented May 1, 2026

Fixes the bug where deploy tx/deployer/created date do not appear for older contracts, and preserves the Contract tab even when index aggregate queries fail.

Root cause

There were two separate problems:

  1. fetchAddressTxAggregate queried txs WHERE from = addr OR to = addr, but deploy txs have to = NULL, so older contracts could miss creation metadata unless their deploy receipt was consulted.
  2. The address metadata route coupled contract classification to TIDX-backed aggregate queries. If those aggregate queries failed, the route fell back to accountType: empty, which could hide the Contract tab even when eth_getCode showed the address was a contract.

Changes

  1. tempo-queries.ts — add a parallel receipts WHERE contract_address = address LIMIT 1 query inside fetchAddressTxAggregate to fetch the actual deploy tx hash, deployer, and timestamp directly from the indexed receipts table.
  2. metadata/$address.ts — prefer the deploy receipt over the oldest-tx heuristic for createdTxHash, createdBy, and createdTimestamp.
  3. address/$address.tsx — gate the RPC binary-search fallback on !createdTxHash instead of !createdTimestamp, so it still fires when TIDX returns a timestamp from a post-deploy call but no deploy hash.
  4. metadata/$address.ts — derive accountType from eth_getCode up front and preserve that contract/account classification even if aggregate index queries fail, instead of returning accountType: empty.
  5. Add a regression test covering fallback chain id and contract classification surviving aggregate-query failure.

Verification

  • corepack pnpm exec vitest run --config vitest.node.config.ts test/address-metadata.node.test.ts

Notes

  • corepack pnpm check:types in apps/explorer still fails on pre-existing unrelated typing issues in the workspace.
  • There is still a separate devnet preview issue where tx-count / aggregate TIDX queries return Status: 400 for chainId=31318; this PR prevents that backend failure from hiding the Contract tab, but does not resolve the TIDX-side 400 itself.

Companion to #906.

decofe and others added 2 commits May 1, 2026 09:09
The metadata endpoint queried txs WHERE from=addr OR to=addr, but deploy
txs have to=NULL — the deployed address only appears in
receipts.contract_address. This caused January (and any older) deployments
with no post-deploy interactions to show no creation data.

Changes:
- fetchAddressTxAggregate: add parallel receipts query for
  contract_address to find the actual deploy tx hash, deployer, and
  timestamp
- metadata route: prefer deploy receipt data over oldest-tx heuristic
- address page: gate RPC fallback on missing createdTxHash instead of
  createdTimestamp so the fallback fires when TIDX returns a timestamp
  from a post-deploy call but no deploy hash

Amp-Thread-ID: https://ampcode.com/threads/T-019de496-ae30-77a9-8292-f1fbb9f7c49e
Co-authored-by: Amp <amp@ampcode.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Bundle Size Report

Metric Size Δ Change
Total 4.6 MB +411.1 KB (+9.5%)
Gzip 1.3 MB +122.0 KB (+9.8%)
Brotli 1.2 MB +106.7 KB (+9.8%)
Chunk changes (>1KB)
Chunk Change
assets/chains.js (removed) -360.7 KB
assets/export-rate-limit.js (removed) -177.3 KB
assets/wagmi.config.js -29.5 KB
assets/AbiItem.js (removed) -27.1 KB
assets/env.js -9.6 KB
assets/validators.js (removed) -5.1 KB
assets/call.js +1.2 KB
assets/parseAbiItem.js (new) +1.6 KB
assets/.js +1.7 KB
assets/known-event-totals.js (new) +2.0 KB
assets/tempo-queries.js +2.8 KB
assets/_address.js +4.9 KB
assets/Addresses.js (new) +9.1 KB
assets/schemas.js +22.7 KB
assets/structs.js (new) +23.9 KB
assets/queries.js +26.4 KB
assets/Connectors.js (new) +55.5 KB
assets/token.js +56.1 KB
assets/manifest.js (new) +173.8 KB
assets/dist.js (new) +294.0 KB
...and 1 more

Compared against main branch (baseline from 4/27/2026, 4:02:54 PM)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Cloudflare Deployments

App Environment Status Preview
explorer devnet [OK] Deployed View Preview
explorer mainnet [OK] Deployed View Preview
explorer testnet [OK] Deployed View Preview
fee-payer devnet [>>] Skipped No changes
fee-payer moderato [>>] Skipped No changes
fee-payer privy [>>] Skipped No changes
og - [>>] Skipped No changes
perf - [>>] Skipped No changes
tokenlist - [>>] Skipped No changes

fetchBoundaryByField('to', 'desc'),
fetchBoundaryByField('from', 'asc'),
fetchBoundaryByField('to', 'asc'),
fetchDeployReceipt(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am increasingly vary of adding "one more separate query" for features like these. Won't block this if creator wants to land it (can't find the Amp thread) but something we need to be more careful about.

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.

2 participants