Skip to content

Add "View on Explorer" button and contract address display after deployment (#1610)#1623

Open
ytfahim29 wants to merge 5 commits into
genlayerlabs:mainfrom
ytfahim29:main
Open

Add "View on Explorer" button and contract address display after deployment (#1610)#1623
ytfahim29 wants to merge 5 commits into
genlayerlabs:mainfrom
ytfahim29:main

Conversation

@ytfahim29
Copy link
Copy Markdown

@ytfahim29 ytfahim29 commented May 9, 2026

Fixes #1610

What

  • Added a "View on Explorer" link in the ContractItem.vue component.
  • The link dynamically opens the GenLayer Explorer for deployed contracts.

Why

  • to fix a bug
  • To provide users with a quick way to verify their contract address and details on the explorer directly from the studio.

Testing done

  • Verified that the link only appears when a contract has a valid address.
  • Checked the link structure to ensure it correctly redirects to the GenLayer explorer.

Decisions made

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR
  • I have set a descriptive PR title compliant with conventional commits

Reviewing tips

#Added a direct link to view deployed contracts on the GenLayer Explorer.

Summary by CodeRabbit

  • New Features
    • Added a "View Explorer" link beside contract names to open contract details on the blockchain explorer. The link appears only when a contract address is available and the app is connected to a non-local network, and it opens in a new tab for safe, convenient navigation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

📝 Walkthrough

Walkthrough

ContractItem.vue now imports the network store and Vue computed, derives a network-aware explorer URL from contract?.address, and conditionally renders a "View Explorer" link that opens the explorer in a new tab when an address exists and the network is not local.

Changes

Contract Explorer Link

Layer / File(s) Summary
Imports & Primitives
frontend/src/components/Simulator/ContractItem.vue
Adds useNetworkStore import and computed to Vue imports.
Computed Values
frontend/src/components/Simulator/ContractItem.vue
Adds isLocalNetwork and explorerUrl computed values based on networkStore.network and props.contract?.address, building https://explorer-asimov.genlayer.com/contract/<address>.
Template Anchor
frontend/src/components/Simulator/ContractItem.vue
Conditionally renders a "View Explorer" <a> when contract?.address exists and network is not local; opens in new tab with rel="noopener noreferrer".

Sequence Diagram(s)

sequenceDiagram
  participant UI
  participant NetworkStore
  participant Explorer
  UI->>NetworkStore: query current network
  UI->>UI: compute isLocalNetwork & explorerUrl (if address)
  alt explorerUrl present and not local
    UI->>Explorer: open explorer URL in new tab
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A tiny link hops into view,
From network state it learns what's true,
If not local, click—a new tab's begun,
Explorer awaits the contract's sun,
Hop, click, discover—deployments anew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements only a partial solution. It adds the explorer link UI component but misses the post-deployment success panel, persistence, sidebar display, copy buttons, and network-aware behavior for local networks. Implement the complete post-deployment success panel with all required features: panel persistence, copy buttons for address/hash, conditional explorer link based on network type, sidebar address display, and local state persistence.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: adding a View on Explorer button and contract address display functionality.
Description check ✅ Passed The PR description covers the main sections (What, Why, Testing done) but lacks detail in Decisions made and Reviewing tips sections. Overall mostly complete.
Out of Scope Changes check ✅ Passed All changes are focused on adding the explorer link functionality to ContractItem.vue, which is directly related to the issue requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/Simulator/ContractItem.vue`:
- Around line 145-152: The link currently always renders when contract?.address
exists; update ContractItem.vue to be network-aware by reading the current
network (e.g., from the existing chain/network store or config — reference the
store getter like currentNetwork or a prop if present) and implement a computed
property (e.g., explorerBase or explorerUrl) and a boolean (e.g.,
isLocalNetwork) that: 1) returns the correct base URL for Asimov vs Bradbury
testnets and constructs the full URL for the anchor when on supported networks,
2) hides the anchor or replaces it with the text "Explorer not available for
local networks" when isLocalNetwork is true (local/studionet), and 3) keeps
existing behavior for other networks; then use these computed values in the
template instead of the unconditional v-if contract?.address check.
- Line 148: The anchor in ContractItem.vue that uses target="_blank" must
include security attributes to prevent window.opener access; update the <a>
element (the anchor with target="_blank") to add rel="noopener noreferrer" so
external links open in a new tab safely and avoid exposing the opener to the new
page.
- Line 147: Update the explorer link in ContractItem.vue: the current :href uses
the wrong domain and path; change it so the URL uses the -asimov subdomain and
the /contract/ path (i.e., build the href from
"https://explorer-asimov.genlayer.com/contract/" + contract.address) so tests
and issue `#1610` expectations are satisfied.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6307e77d-2de1-4249-ae7c-a15a56ebd704

📥 Commits

Reviewing files that changed from the base of the PR and between 6736a15 and 93032a8.

📒 Files selected for processing (1)
  • frontend/src/components/Simulator/ContractItem.vue

Comment thread frontend/src/components/Simulator/ContractItem.vue Outdated
Comment thread frontend/src/components/Simulator/ContractItem.vue Outdated
Comment thread frontend/src/components/Simulator/ContractItem.vue
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
frontend/src/components/Simulator/ContractItem.vue (1)

53-57: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Explorer URL is hardcoded to Asimov and not network-aware.

The current hardcoded URL only works for Testnet Asimov. Other networks (Testnet Bradbury, etc.) have different explorer subdomains and will produce broken explorer links.

A getExplorerUrl() utility already exists at frontend/src/utils/explorerUrl.ts and is used by other components (TransactionItem.vue, ContractInfo.vue) to handle network-aware explorer URLs. Use this utility instead of hardcoding:

🔧 Proposed fix
 import { getExplorerUrl } from '@/utils/explorerUrl';

 const explorerUrl = computed(() => {
   const address = props.contract?.address;
   if (!address) return '';
-  return `https://explorer-asimov.genlayer.com/contract/${address}`;
+  return `${getExplorerUrl()}/contract/${address}`;
 });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/Simulator/ContractItem.vue` around lines 53 - 57,
Replace the hardcoded Asimov explorer URL in the computed explorerUrl inside
ContractItem.vue with the shared network-aware utility getExplorerUrl: import
getExplorerUrl from frontend/src/utils/explorerUrl.ts, and call it with the
contract address (e.g. getExplorerUrl(props.contract?.address)) so explorer
links respect the current network; update the computed const explorerUrl to
return '' when address is missing and otherwise return the value from
getExplorerUrl.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@frontend/src/components/Simulator/ContractItem.vue`:
- Around line 53-57: Replace the hardcoded Asimov explorer URL in the computed
explorerUrl inside ContractItem.vue with the shared network-aware utility
getExplorerUrl: import getExplorerUrl from frontend/src/utils/explorerUrl.ts,
and call it with the contract address (e.g.
getExplorerUrl(props.contract?.address)) so explorer links respect the current
network; update the computed const explorerUrl to return '' when address is
missing and otherwise return the value from getExplorerUrl.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2b1dae6a-885b-442f-95d8-e03810be81e4

📥 Commits

Reviewing files that changed from the base of the PR and between 93032a8 and fe96e5a.

📒 Files selected for processing (1)
  • frontend/src/components/Simulator/ContractItem.vue

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.

Add "View on Explorer" button and contract address display after deployment

1 participant