Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails if @magic-ext/algorand is not installed #135

Closed
drichar opened this issue Jan 31, 2024 · 0 comments · Fixed by #136
Closed

Build fails if @magic-ext/algorand is not installed #135

drichar opened this issue Jan 31, 2024 · 0 comments · Fixed by #136
Assignees
Labels
bug Something isn't working

Comments

@drichar
Copy link
Collaborator

drichar commented Jan 31, 2024

Apps that have installed https://github.com/TxnLab/use-wallet/releases/tag/v2.6.0 or https://github.com/TxnLab/use-wallet/releases/tag/v2.6.1 will encounter build failures if @magic-ext/algorand is not installed, even if they are not configured to support the Magic.link provider.

Although the Magic SDK is passed to the useInitializeProviders configuration object via the clientStatic or getDynamicClient properties, the Algorand extension is directly imported by the Magic provider client, making it a required dependency.

It must also be passed to the configuration object:

const getDynamicMagicSdk = async () => {
  const Magic = (await import('magic-sdk')).Magic
  return Magic
}

const getDynamicAlgoExtension = async () => {
  const AlgorandExtension = (await import('@magic-ext/algorand')).AlgorandExtension
  return AlgorandExtension
}

const providers = useInitializeProviders({
  providers: [
    {
      id: PROVIDER_ID.MAGIC,
      getDynamicClient: getDynamicMagicSdk,
      getDynamicExtension: getDynamicAlgoExtension,
      clientOptions: { apiKey: '<API_KEY>' }
    },
    // ... other provider configurations
  ],
})

The library should not import any SDKs/dependencies for wallet providers (besides type imports). This should be handled by the consuming application on an opt-in basis, depending on which wallets it supports.

Apps that support the Magic.link provider are unaffected, since they must install its dependencies for it to work.

@drichar drichar added the bug Something isn't working label Jan 31, 2024
@drichar drichar self-assigned this Jan 31, 2024
drichar added a commit that referenced this issue Jan 31, 2024
The library should not import any SDKs/dependencies for wallet providers (besides type imports). This should be handled by the consuming application on an opt-in basis, depending on which wallets it supports.

The Magic Algorand extension is now (optionally) passed to the `useInitializeProviders` hook's configuration object.

Closes: Build fails if @magic-ext/algorand is not installed #135
drichar added a commit that referenced this issue Jan 31, 2024
* fix(magic): remove non-type Magic.link imports

The library should not import any SDKs/dependencies for wallet providers (besides type imports). This should be handled by the consuming application on an opt-in basis, depending on which wallets it supports.

The Magic Algorand extension is now (optionally) passed to the `useInitializeProviders` hook's configuration object.

Closes: Build fails if @magic-ext/algorand is not installed #135

* docs: update README full config example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant