-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: ethers/ethers5 infinite requests #3086
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
'@reown/appkit-adapter-ethers5': patch | ||
'@reown/appkit-adapter-ethers': patch | ||
'@apps/demo': patch | ||
'@apps/gallery': patch | ||
'@apps/laboratory': patch | ||
'@reown/appkit-adapter-polkadot': patch | ||
'@reown/appkit-adapter-solana': patch | ||
'@reown/appkit-adapter-wagmi': patch | ||
'@reown/appkit': patch | ||
'@reown/appkit-utils': patch | ||
'@reown/appkit-cdn': 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-ui': patch | ||
'@reown/appkit-wallet': patch | ||
--- | ||
|
||
Fixes an issue where ethers and ethers5 adapters were causing infinite network requests |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -631,9 +631,12 @@ export class EthersAdapter { | |
if (provider) { | ||
const { addresses, chainId } = await EthersHelpersUtil.getUserInfo(provider) | ||
const firstAddress = addresses?.[0] | ||
const caipAddress = `${this.chainNamespace}:${chainId}:${firstAddress}` as CaipAddress | ||
const caipNetwork = this.caipNetworks.find(c => c.id === chainId) ?? this.caipNetworks[0] | ||
const caipAddress = | ||
`${this.chainNamespace}:${caipNetwork?.id}:${firstAddress}` as CaipAddress | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use the caipNetwork id directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I meant (unsure about proper names but you get what I mean) |
||
|
||
if (firstAddress && chainId) { | ||
if (firstAddress && caipNetwork) { | ||
this.appKit?.setCaipNetwork(caipNetwork) | ||
this.appKit?.setCaipAddress(caipAddress, this.chainNamespace) | ||
ProviderUtil.setProviderId('eip155', providerId) | ||
ProviderUtil.setProvider<Provider>('eip155', provider) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why source the infor from here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because during the construct of the adapter we'd need to get the address and chain id directly from the provider so users are still connected even if they refresh the page. The logic happens here.