Skip to content

fix: throw when getExplorerLink has no block explorer URL available#426

Open
gabitoesmiapodo wants to merge 1 commit intotest/utilsfrom
fix/explorer-link-missing-explorer
Open

fix: throw when getExplorerLink has no block explorer URL available#426
gabitoesmiapodo wants to merge 1 commit intotest/utilsfrom
fix/explorer-link-missing-explorer

Conversation

@gabitoesmiapodo
Copy link
Collaborator

Summary

  • getExplorerLink previously produced undefined/address/... or undefined/tx/... when called without explorerUrl on a chain that has no blockExplorers configured
  • Extracts baseUrl before building the URL and throws 'No block explorer URL available for this chain' when neither source provides a URL
  • Adds a test covering the new throw behavior

Test plan

  • pnpm test src/utils/getExplorerLink.test.ts — 5 tests pass
  • Existing callers that always provide a chain with block explorers (or an explicit explorerUrl) are unaffected
  • pnpm build passes

Copilot AI review requested due to automatic review settings March 25, 2026 18:22
@vercel
Copy link

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components.dappbooster Ready Ready Preview, Comment Mar 25, 2026 7:16pm
demo.dappbooster Ready Ready Preview, Comment Mar 25, 2026 7:16pm
docs.dappbooster Ready Ready Preview, Comment Mar 25, 2026 7:16pm

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens getExplorerLink by preventing generation of malformed explorer URLs when a chain has no configured block explorer and no explicit explorerUrl is provided.

Changes:

  • Extracts a baseUrl once and throws when no explorer base URL is available.
  • Simplifies URL construction for address/tx paths using the extracted baseUrl.
  • Adds a Vitest suite covering the new throw behavior and existing URL generation paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/utils/getExplorerLink.ts Centralizes explorer base URL selection and throws a clear error when missing.
src/utils/getExplorerLink.test.ts Adds tests for address/tx URL generation, custom explorer override, and missing-explorer error case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gabitoesmiapodo gabitoesmiapodo changed the base branch from feat/ai-integration to test/utils March 25, 2026 19:10
@gabitoesmiapodo gabitoesmiapodo self-assigned this Mar 25, 2026
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.

3 participants