Skip to content

Decouple domain dependencies for modal#54

Merged
elenamik merged 1 commit intomainfrom
next
Sep 22, 2025
Merged

Decouple domain dependencies for modal#54
elenamik merged 1 commit intomainfrom
next

Conversation

@elenamik
Copy link
Copy Markdown
Contributor

Pull Request

Checklist

  • If this PR changes a package, I’ve added an entry to the CHANGELOG.md

Description

* rm hooks from main page use

* decouple main page from hooks

* put back cosmos config

* update doc

* fix build

* update modal changelog
@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 22, 2025

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

Project Deployment Preview Updated (UTC)
valence-ts-example Ready Ready Preview Sep 22, 2025 6:13pm

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @elenamik, 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 refactors the modal component's dependency management to enhance modularity and efficiency. It streamlines configuration by allowing direct passing of domain settings to the modal provider, which then intelligently loads only the necessary domain-specific code. This enhancement improves the overall application bundle size by enabling better tree-shaking for unused blockchain ecosystems.

Highlights

  • Modal Dependency Decoupling: The DomainModalProvider now directly accepts the DomainClientsConfig and internally manages the DomainClientsProvider. This simplifies the application's root provider setup by removing the need for explicit DomainClientsProvider instantiation.
  • Improved Tree-Shakeability: Domain-specific dependencies within the modal are now omitted from the final bundle if their corresponding ecosystems are not included in the configuration. This significantly reduces bundle size and improves loading performance.
  • Optional Domain Configuration: The hide property for individual domain configurations (evm, solana, cosmos) is now optional. This allows developers to easily exclude unused blockchain ecosystems from the modal without requiring placeholder configurations.
  • Simplified Example Application: The example application has been updated to reflect the new simplified provider setup and dynamically renders domain-specific operations based on the provided configuration, showcasing the benefits of the decoupling.
  • Documentation Updates: The README.md has been comprehensively updated with new installation instructions, clearer guidance on peer dependencies, and examples that align with the decoupled architecture.
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

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.

@elenamik elenamik merged commit 6b80dd6 into main Sep 22, 2025
6 checks passed
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 effectively decouples domain dependencies for the modal, simplifying the public API for consumers. The changes involve moving the DomainClientsProvider inside the DomainModalProvider, making the hide configuration property optional, and refactoring UI components for better encapsulation and clarity. The documentation and example app have been updated accordingly. My review includes a few suggestions to fix typos in the README and clarify some comments in the new components to improve developer experience.

Comment thread README.md
} from '@valence-protocol/domain-clients-react/solana';

// component
const solanaSigningClient = useSolanaSigningClient({clusterId:'solana:devent'})
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

There are a couple of typos in this code example that could confuse users:

  1. The imported hook is useSigningSolanaClient, but it's called as useSolanaSigningClient.
  2. The clusterId is 'solana:devent', which is likely a typo for 'solana:devnet'.

Suggesting a fix for consistency and correctness.

Suggested change
const solanaSigningClient = useSolanaSigningClient({clusterId:'solana:devent'})
const solanaSigningClient = useSigningSolanaClient({clusterId:'solana:devnet'})

Comment thread README.md
} from '@valence-protocol/domain-clients-react/solana';
} from '@valence-protocol/domain-clients-react';

const solananClient = useSolanaClient({ clusterId });
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

There's a typo in the variable name. It should be solanaClient instead of solananClient.

Suggested change
const solananClient = useSolanaClient({ clusterId });
const solanaClient = useSolanaClient({ clusterId });

Comment thread README.md
### Domain-specific hooks

Use various domain-specific utils as needed. They will work as expected because we render their providers under the hod. The implementation and naming for each varies. You can dig into the tool-specific docs as needed.
Use various domain-specific hooks and utils as needed. They will work as expected because we render their providers under the hod. The implementation and naming for each varies. You can find some examples of how these are used in the example app, but it is suggested to consult the individual docs.
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

There's a typo here. It should be under the hood instead of under the hod.

Suggested change
Use various domain-specific hooks and utils as needed. They will work as expected because we render their providers under the hod. The implementation and naming for each varies. You can find some examples of how these are used in the example app, but it is suggested to consult the individual docs.
Use various domain-specific hooks and utils as needed. They will work as expected because we render their providers under the hood. The implementation and naming for each varies. You can find some examples of how these are used in the example app, but it is suggested to consult the individual docs.

throw new Error(
'CosmosConnection component should only be used when the user is connected to a cosmos wallet'
);
// this is intentional, it lets us optimistically render the component and avoids tree-shaking issues when some domain configs are not set
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

This comment is a bit confusing. The term 'optimistically render' isn't quite right here, as the component is simply choosing not to render anything. The part about tree-shaking is also unclear, especially since the consumer (MainPage.tsx) already checks for the domain config's existence.

A clearer comment might explain that returning undefined allows for declarative use without the consumer needing to check for connection status.

This same comment pattern appears in ConnectCosmosButton.tsx, EvmConnection.tsx, ConnectEthereumButton.tsx, SolanaConnection.tsx, and ConnectSolanaButton.tsx. Consider updating it in all those places for clarity.

Here's a suggested alternative:

Suggested change
// this is intentional, it lets us optimistically render the component and avoids tree-shaking issues when some domain configs are not set
// This component renders nothing if the wallet is not connected.
// This allows for a cleaner declarative usage in parent components.

@elenamik elenamik deleted the next branch September 23, 2025 18:07
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.

1 participant