Skip to content

feat: expose WalletConnect.initializeProvider for independent inialization#472

Merged
jannik-stacks merged 4 commits intostx-labs:mainfrom
jfstn:feat/wallet-connect-initialize
Jan 15, 2026
Merged

feat: expose WalletConnect.initializeProvider for independent inialization#472
jannik-stacks merged 4 commits intostx-labs:mainfrom
jfstn:feat/wallet-connect-initialize

Conversation

@jfstn
Copy link
Copy Markdown
Contributor

@jfstn jfstn commented Nov 5, 2025

Description

As a Stacks Connect developer, I would like to initialize WalletConnect independently from the request flow so that I can provide a better user experience in my application. This is needed because the current implementation forces WalletConnect initialization to happen during the request() call, which ties initialization to user actions and limits UX control.

Motivation for change

Previously, WalletConnect could only be initialized by passing walletConnect or walletConnectProjectId options to the request() function. This meant consumers using the library as an abstraction layer had no way to pre-initialize WalletConnect, resulting in initialization delays during critical user interactions.

What was changed

  1. Exported the initializeProvider function from the WalletConnect namespace
  2. Re-exported config constants (Networks, Chains, Default) from walletconnect/index.ts
  3. Updated main index.ts to export the full WalletConnect module instead of just config
  4. Added JSDoc documentation with usage examples

How does this impact application developers

Application developers can now:

  • Initialize WalletConnect at application startup or any time before making requests
  • Provide a smoother UX by separating initialization from user actions
  • Continue using the existing pattern (backward compatible)

Examples of use cases

Initializing at app startup:

import { WalletConnect } from '@stacks/connect';

// In your app initialization
await WalletConnect.initializeProvider('your-project-id');

With full configuration:

import { WalletConnect } from '@stacks/connect';

await WalletConnect.initializeProvider({
  projectId: 'your-project-id',
  metadata: {
    name: 'My Stacks App',
    description: 'A decentralized application',
    url: 'https://myapp.com',
    icons: ['https://myapp.com/icon.png']
  },
  networks: [WalletConnect.Networks.Stacks]
});

Making requests after initialization:

import { request } from '@stacks/connect';

// WalletConnect is already initialized, just make the request
const result = await request('getAddresses');

Acceptance criteria

  • WalletConnect.initializeProvider() is accessible from @stacks/connect
  • ✅ Function accepts both string (projectId) and full config object
  • ✅ Existing walletConnect option in request() continues to work
  • ✅ Config constants (Networks, Chains, Default) remain accessible

Link to relevant documentation

JSDoc examples added in the code provide inline documentation for developers.

Type of Change

  • New feature

Does this introduce a breaking change?

No breaking changes. This PR is fully backward compatible:

  • Existing code using walletConnect options in request() continues to work unchanged
  • Only adds new functionality, doesn't modify or remove existing APIs

Checklist

  • Code is commented where needed
  • Unit test coverage for new or modified code paths
  • Changelog is updated
  • Tag @janniks for review

@janniks

jannik-stacks
jannik-stacks previously approved these changes Nov 25, 2025
Copy link
Copy Markdown
Collaborator

@jannik-stacks jannik-stacks left a comment

Choose a reason for hiding this comment

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

Looks great — will need a second review from @hugo-stacks

@jfstn
Copy link
Copy Markdown
Contributor Author

jfstn commented Dec 23, 2025

@hugo-stacks can you check this PR? ty

@hugo-stacks hugo-stacks self-requested a review December 24, 2025 11:07
hugo-stacks
hugo-stacks previously approved these changes Dec 24, 2025
Copy link
Copy Markdown

@hugo-stacks hugo-stacks left a comment

Choose a reason for hiding this comment

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

lgtm!

@jannik-stacks jannik-stacks force-pushed the feat/wallet-connect-initialize branch from dbf18e2 to 96003ce Compare December 30, 2025 12:17
@jannik-stacks jannik-stacks dismissed stale reviews from hugo-stacks and themself via dbf18e2 December 30, 2025 12:50
@jannik-stacks jannik-stacks force-pushed the feat/wallet-connect-initialize branch from 96003ce to dbf18e2 Compare December 30, 2025 12:50
jfstn and others added 4 commits January 15, 2026 13:28
…ization

- Export initializeProvider function from WalletConnect namespace
- Re-export Networks, Chains, and Default config from walletconnect/index
- Update main index.ts to export from walletconnect/index instead of config
- Add JSDoc examples for new initialization pattern

This allows consumers to initialize WalletConnect outside of the request
flow for better UX control, while maintaining backward compatibility.
@jannik-stacks jannik-stacks force-pushed the feat/wallet-connect-initialize branch from 869783f to 33e7bff Compare January 15, 2026 12:34
@jannik-stacks jannik-stacks merged commit 8074b1c into stx-labs:main Jan 15, 2026
3 checks passed
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