diff --git a/.changeset/six-fans-turn.md b/.changeset/six-fans-turn.md new file mode 100644 index 0000000000..fd0b7c91b1 --- /dev/null +++ b/.changeset/six-fans-turn.md @@ -0,0 +1,24 @@ +--- +'@reown/appkit-adapter-ethers5': patch +'@reown/appkit-adapter-ethers': patch +'@reown/appkit-adapter-wagmi': patch +'@apps/demo': patch +'@apps/gallery': patch +'@apps/laboratory': 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 +--- + +Don't show browser wallet when injected provider is not detected diff --git a/packages/adapters/ethers/src/client.ts b/packages/adapters/ethers/src/client.ts index 8e1fda213b..2a7cf24827 100644 --- a/packages/adapters/ethers/src/client.ts +++ b/packages/adapters/ethers/src/client.ts @@ -261,6 +261,9 @@ export class EthersAdapter extends AdapterBlueprint { connectors.forEach(connector => { const key = connector === 'coinbase' ? 'coinbaseWalletSDK' : connector + + const injectedConnector = connector === ConstantsUtil.INJECTED_CONNECTOR_ID + if (this.namespace) { this.addConnector({ id: connector, @@ -269,7 +272,7 @@ export class EthersAdapter extends AdapterBlueprint { name: PresetsUtil.ConnectorNamesMap[key], imageId: PresetsUtil.ConnectorImageIds[key], type: PresetsUtil.ConnectorTypesMap[key] ?? 'EXTERNAL', - info: { rdns: key }, + info: injectedConnector ? undefined : { rdns: key }, chain: this.namespace, chains: [], provider: this.ethersConfig?.[connector as keyof ProviderType] as Provider diff --git a/packages/adapters/ethers/src/tests/client.test.ts b/packages/adapters/ethers/src/tests/client.test.ts index 63b2af4083..33dcec2faa 100644 --- a/packages/adapters/ethers/src/tests/client.test.ts +++ b/packages/adapters/ethers/src/tests/client.test.ts @@ -79,6 +79,23 @@ describe('EthersAdapter', () => { expect(adapter.adapterType).toBe('ethers') expect(adapter.namespace).toBe('eip155') }) + + it('should not set info property for injected connector', () => { + const mockConnectors = [ + { + id: 'Browser Wallet', + name: 'Browser Wallet', + type: 'injected', + info: { rdns: 'Browser Wallet' } + } + ] + + ;(adapter as any).syncConnectors(mockConnectors) + + const injectedConnector = mockConnectors.filter((c: any) => c.id === 'injected')[0] + + expect(injectedConnector?.info).toBeUndefined() + }) }) describe('EthersAdapter - signMessage', () => { diff --git a/packages/adapters/ethers5/src/client.ts b/packages/adapters/ethers5/src/client.ts index e5a879244f..2e18c2b2b5 100644 --- a/packages/adapters/ethers5/src/client.ts +++ b/packages/adapters/ethers5/src/client.ts @@ -262,6 +262,9 @@ export class Ethers5Adapter extends AdapterBlueprint { connectors.forEach(connector => { const key = connector === 'coinbase' ? 'coinbaseWalletSDK' : connector + + const injectedConnector = connector === ConstantsUtil.INJECTED_CONNECTOR_ID + if (this.namespace) { this.addConnector({ id: connector, @@ -270,7 +273,7 @@ export class Ethers5Adapter extends AdapterBlueprint { name: PresetsUtil.ConnectorNamesMap[key], imageId: PresetsUtil.ConnectorImageIds[key], type: PresetsUtil.ConnectorTypesMap[key] ?? 'EXTERNAL', - info: { rdns: key }, + info: injectedConnector ? undefined : { rdns: key }, chain: this.namespace, chains: [], provider: this.ethersConfig?.[connector as keyof ProviderType] as Provider diff --git a/packages/adapters/ethers5/src/tests/client.test.ts b/packages/adapters/ethers5/src/tests/client.test.ts index 59b6494f17..780b5551a5 100644 --- a/packages/adapters/ethers5/src/tests/client.test.ts +++ b/packages/adapters/ethers5/src/tests/client.test.ts @@ -81,6 +81,23 @@ describe('Ethers5Adapter', () => { expect(adapter.adapterType).toBe('ethers') expect(adapter.namespace).toBe('eip155') }) + + it('should not set info property for injected connector', () => { + const mockConnectors = [ + { + id: 'Browser Wallet', + name: 'Browser Wallet', + type: 'injected', + info: { rdns: 'Browser Wallet' } + } + ] + + ;(adapter as any).syncConnectors(mockConnectors) + + const injectedConnector = mockConnectors.filter((c: any) => c.id === 'injected')[0] + + expect(injectedConnector?.info).toBeUndefined() + }) }) describe('Ethers5Adapter - signMessage', () => { diff --git a/packages/adapters/wagmi/src/client.ts b/packages/adapters/wagmi/src/client.ts index e95a57951b..26cc65a846 100644 --- a/packages/adapters/wagmi/src/client.ts +++ b/packages/adapters/wagmi/src/client.ts @@ -332,6 +332,8 @@ export class WagmiAdapter extends AdapterBlueprint { filteredConnectors.forEach(connector => { const shouldSkip = ConstantsUtil.AUTH_CONNECTOR_ID === connector.id + const injectedConnector = connector.id === ConstantsUtil.INJECTED_CONNECTOR_ID + if (!shouldSkip && this.namespace) { this.addConnector({ id: connector.id, @@ -340,7 +342,7 @@ export class WagmiAdapter extends AdapterBlueprint { name: PresetsUtil.ConnectorNamesMap[connector.id] ?? connector.name, imageId: PresetsUtil.ConnectorImageIds[connector.id], type: PresetsUtil.ConnectorTypesMap[connector.type] ?? 'EXTERNAL', - info: { rdns: connector.id }, + info: injectedConnector ? undefined : { rdns: connector.id }, chain: this.namespace, chains: [] }) diff --git a/packages/adapters/wagmi/src/tests/client.test.ts b/packages/adapters/wagmi/src/tests/client.test.ts index 3b9c93317a..9c70de027d 100644 --- a/packages/adapters/wagmi/src/tests/client.test.ts +++ b/packages/adapters/wagmi/src/tests/client.test.ts @@ -91,6 +91,23 @@ describe('WagmiAdapter', () => { expect(adapter.adapterType).toBe('wagmi') expect(adapter.namespace).toBe('eip155') }) + + it('should not set info property for injected connector', () => { + const mockConnectors = [ + { + id: 'Browser Wallet', + name: 'Browser Wallet', + type: 'injected', + info: { rdns: 'Browser Wallet' } + } + ] + + ;(adapter as any).syncConnectors(mockConnectors) + + const injectedConnector = mockConnectors.filter((c: any) => c.id === 'injected')[0] + + expect(injectedConnector?.info).toBeUndefined() + }) }) describe('WagmiAdapter - signMessage', () => {