Skip to content

Commit

Permalink
fix: remove browser wallet when injected provider is not detected (#3220
Browse files Browse the repository at this point in the history
)
  • Loading branch information
magiziz authored Nov 10, 2024
1 parent f4ce9d4 commit 898c3b4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .changeset/twelve-kings-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@reown/appkit-adapter-wagmi': patch
'@apps/demo': patch
'@apps/gallery': patch
'@apps/laboratory': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-polkadot': patch
'@reown/appkit-adapter-solana': 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-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
---

Fixes an issue where the connect modal on mobile was always showing 'Browser Wallet' option when the injected provider wasn't detected.
6 changes: 3 additions & 3 deletions packages/adapters/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,16 +939,16 @@ export class WagmiAdapter implements ChainAdapter {
// Auth connector is initialized separately
const shouldSkip = ConstantsUtil.AUTH_CONNECTOR_ID === id
if (!shouldSkip) {
const injectedConnector = id === ConstantsUtil.INJECTED_CONNECTOR_ID

w3mConnectors.push({
id,
explorerId: PresetsUtil.ConnectorExplorerIds[id],
imageUrl: this.options?.connectorImages?.[id] ?? icon,
name: PresetsUtil.ConnectorNamesMap[id] ?? name,
imageId: PresetsUtil.ConnectorImageIds[id],
type: PresetsUtil.ConnectorTypesMap[type] ?? 'EXTERNAL',
info: {
rdns: id
},
info: injectedConnector ? undefined : { rdns: id },
chain: this.chainNamespace
})
}
Expand Down
14 changes: 14 additions & 0 deletions packages/adapters/wagmi/src/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,20 @@ describe('Wagmi Client', () => {
mockAuthConnector
)
})

it('should not set info property for injected connector', () => {
const mockConnectors = [
{ id: 'injected', name: 'Injected Connector', type: 'injected', info: { rdns: 'injected' } }
]

;(mockWagmiClient as any).syncConnectors(mockConnectors)

const setConnectorsCalls = (mockAppKit.setConnectors as any).mock.calls
const syncedConnectors = setConnectorsCalls[0][0]
const injectedConnector = syncedConnectors.filter((c: any) => c.id === 'injected')[0]

expect(injectedConnector.info).toBeUndefined()
})
})
describe('Wagmi Client - Listen Auth Connector', () => {
let mockProvider: any
Expand Down

0 comments on commit 898c3b4

Please sign in to comment.