Add contract explorer link to context menu#1800
Conversation
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.
Summary of ChangesHello, 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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| func onSelectViewContractInExplorer() { | ||
| isPresentingTokenExplorerUrl = contractExplorerUrl?.url | ||
| } |
There was a problem hiding this comment.
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.
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