Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Add contract explorer link to context menu#1800

Merged
DRadmir merged 1 commit intomainfrom
1797-add-view-contract-for-nft
Mar 17, 2026
Merged

Add contract explorer link to context menu#1800
DRadmir merged 1 commit intomainfrom
1797-add-view-contract-for-nft

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented Mar 17, 2026

Expose a contractExplorerUrl and include a "View on " item in the contract context menu (filtered when nil). Refactor explorer presentation: onSelectViewTokenInExplorer now assigns the tokenExplorerUrl?.url directly, and a new onSelectViewContractInExplorer presents the contract explorer URL. This enables opening the contract in a block explorer when available.

Close: #1797

Expose a contractExplorerUrl and include a "View on <explorer>" item in the contract context menu (filtered when nil). Refactor explorer presentation: onSelectViewTokenInExplorer now assigns the tokenExplorerUrl?.url directly, and a new onSelectViewContractInExplorer presents the contract explorer URL. This enables opening the contract in a block explorer when available.
@DRadmir DRadmir self-assigned this Mar 17, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience by integrating direct access to contract information on block explorers from the collectible's context menu. It introduces a new option to view contracts on their respective explorers and refactors the underlying URL handling to be more consistent and efficient for both tokens and contracts.

Highlights

  • Contract Explorer Link: Added a 'View on ' option to the contract context menu, allowing users to directly open the contract in a block explorer.
  • Explorer URL Refactoring: Refactored the presentation logic for explorer URLs, streamlining how both token and contract explorer links are handled internally.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • Features/NFT/Sources/ViewModels/CollectibleViewModel.swift
    • Added a new computed property contractExplorerUrl to determine the block explorer link for a contract.
    • Modified the contractContextMenu to include a 'View on ' item, which is conditionally displayed if a contract explorer URL is available.
    • Refactored the onSelectViewTokenInExplorer function to directly assign the token explorer URL.
    • Introduced a new function onSelectViewContractInExplorer to handle opening the contract's explorer URL.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a useful feature to view a contract on a block explorer from the context menu and refactors the presentation logic for explorer links. The implementation is mostly solid, but I have a couple of suggestions to improve code clarity and robustness against potential crashes.

guard let explorerLink = tokenExplorerUrl else { return }
guard let url = URL(string: explorerLink.link) else { return }
isPresentingTokenExplorerUrl = url
isPresentingTokenExplorerUrl = tokenExplorerUrl?.url
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This line now relies on the url computed property on BlockExplorerLink. The implementation of this property appears to use a force-unwrap (URL(string: link)!). While ExplorerService currently seems to ensure link is a valid URL string, this creates a potential crash risk if a BlockExplorerLink instance is ever created with an invalid string elsewhere. To improve robustness, I recommend modifying the url property to return an optional URL? to avoid force-unwrapping. The call site here would not need to change.

Comment on lines +242 to 244
func onSelectViewContractInExplorer() {
isPresentingTokenExplorerUrl = contractExplorerUrl?.url
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

With the addition of this function, the property isPresentingTokenExplorerUrl is now used for both token and contract explorer URLs, which can be confusing. For better code clarity and maintainability, consider renaming it to something more generic, like isPresentingExplorerUrl. This would also require updating its declaration and usage in CollectibleScene.swift.

@DRadmir DRadmir merged commit 93b2d2d into main Mar 17, 2026
1 of 2 checks passed
@DRadmir DRadmir deleted the 1797-add-view-contract-for-nft branch March 17, 2026 16:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add view contract for nft

2 participants