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

fix: ProviderUtil.getProvider('eip155') returns undefined when using wagmi adapter #3672

Merged
merged 7 commits into from
Jan 20, 2025

Conversation

magiziz
Copy link
Contributor

@magiziz magiziz commented Jan 16, 2025

Description

Fixed an issue where ProviderUtil.getProvider('eip155') returned undefined for wagmi adapter when connected to a wallet.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-2041

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

linear bot commented Jan 16, 2025

Copy link

changeset-bot bot commented Jan 16, 2025

🦋 Changeset detected

Latest commit: 3fe7109

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@reown/appkit-adapter-wagmi Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit Patch
@reown/appkit-utils Patch
@reown/appkit-cdn Patch
@reown/appkit-cli Patch
@reown/appkit-common Patch
@reown/appkit-core Patch
@reown/appkit-experimental Patch
@reown/appkit-polyfills Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-ui Patch
@reown/appkit-wallet Patch
@reown/appkit-wallet-button Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 10:15am
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 10:15am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-vue-solana ⬜️ Ignored (Inspect) Jan 20, 2025 10:15am
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Jan 20, 2025 10:15am
vue-wagmi-example ⬜️ Ignored (Inspect) Jan 20, 2025 10:15am

Copy link
Contributor

github-actions bot commented Jan 16, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 68.48% 19486 / 28453
🔵 Statements 68.48% 19486 / 28453
🔵 Functions 59.12% 1697 / 2870
🔵 Branches 79.72% 3429 / 4301
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/adapters/wagmi/src/client.ts 73.8% 61.95% 73.52% 73.8% 124-150, 175, 236-240, 246-249, 280, 282, 311-312, 363-366, 371-372, 382-383, 422-423, 459, 464-479, 482-513, 523-524, 528-529, 546-557, 596, 600-601, 622-623, 631-632, 637-638, 642-647, 654-655, 663-664, 669-670, 679-680, 688-689, 694-695, 701-708
Generated in workflow #9015 for commit 3fe7109 by the Vitest Coverage Report Action

@@ -422,6 +422,8 @@ export class WagmiAdapter extends AdapterBlueprint {
return
}

const provider = (await connector.getProvider().catch(() => undefined)) as Provider | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have to use as Provider | undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like wagmi's provider type doesn't match with our provider type. It's throwing this error:

Type 'unknown' is not assignable to type 'Provider | W3mFrameProvider | UniversalProvider | undefined'.ts(2322)

Copy link
Collaborator

Choose a reason for hiding this comment

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

should we even add the connector if it's undefined? Seems like a case where things would bug out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should add connector even if there is no provider. Because wagmi has internal logic when it comes to connecting to a connector since we do this in the wagmi adapter.

await connect(this.wagmiConfig, { connector })

@swan-of-bodom
Copy link

Hi i'm also running into this issue. It worked fine in 1.2.0, then upgraded to 1.6.2 and seeing this issue.

For some reason if the user is connected and we refresh page, then walletProvider shows correctly. However if you land on the site and then connect, the walletProvider is undefined.

@tomiir tomiir merged commit 98ad777 into main Jan 20, 2025
19 checks passed
@tomiir tomiir deleted the fix/provider-not-set branch January 20, 2025 10:30
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.

4 participants