Skip to content

Commit

Permalink
fix: Deduplicate EIP6963 wallets from connectors (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
xzilja authored Jan 2, 2024
1 parent 6699133 commit ec4e15d
Show file tree
Hide file tree
Showing 11 changed files with 1,267 additions and 879 deletions.
14 changes: 7 additions & 7 deletions apps/gallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"@web3modal/common": "3.5.3",
"@web3modal/ui": "3.5.3",
"lit": "3.1.0",
"storybook": "7.6.6"
"storybook": "7.6.7"
},
"devDependencies": {
"@storybook/addon-essentials": "7.6.6",
"@storybook/addon-links": "7.6.6",
"@storybook/blocks": "7.6.6",
"@storybook/theming": "7.6.6",
"@storybook/web-components": "7.6.6",
"@storybook/web-components-vite": "7.6.6",
"@storybook/addon-essentials": "7.6.7",
"@storybook/addon-links": "7.6.7",
"@storybook/blocks": "7.6.7",
"@storybook/theming": "7.6.7",
"@storybook/web-components": "7.6.7",
"@storybook/web-components-vite": "7.6.7",
"file-system-cache": "2.4.4"
}
}
6 changes: 3 additions & 3 deletions apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
},
"dependencies": {
"@chakra-ui/react": "2.8.2",
"@emotion/react": "11.11.1",
"@emotion/react": "11.11.3",
"@emotion/styled": "11.11.0",
"@sentry/browser": "7.89.0",
"@sentry/react": "7.89.0",
"@sentry/browser": "7.91.0",
"@sentry/react": "7.91.0",
"@web3modal/ethers": "3.5.3",
"@web3modal/ethers5": "3.5.3",
"@web3modal/wagmi": "3.5.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-ethers5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"ethers": "5.7.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "4.5.2"
"@vitejs/plugin-vue": "5.0.2"
}
}
2 changes: 1 addition & 1 deletion examples/vue-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"@web3modal/wagmi": "3.5.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "4.5.2"
"@vitejs/plugin-vue": "5.0.2"
}
}
2,083 changes: 1,228 additions & 855 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"examples/*"
],
"devDependencies": {
"@types/react": "18.2.45",
"@types/react": "18.2.46",
"@types/react-dom": "18.2.18",
"@typescript-eslint/eslint-plugin": "6.15.0",
"@typescript-eslint/parser": "6.15.0",
"@typescript-eslint/eslint-plugin": "6.17.0",
"@typescript-eslint/parser": "6.17.0",
"danger": "11.3.1",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
Expand All @@ -59,10 +59,10 @@
"react-dom": "18.2.0",
"turbo": "1.11.2",
"typescript": "5.3.3",
"viem": "1.20.3",
"viem": "1.21.4",
"vite": "5.0.10",
"vitest": "1.1.0",
"vue": "3.3.13",
"vitest": "1.1.1",
"vue": "3.4.3",
"wagmi": "1.4.12"
}
}
4 changes: 4 additions & 0 deletions packages/core/src/controllers/ConnectorController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const ConnectorController = {
return state.connectors.find(c => c.type === 'EMAIL') as EmailConnector | undefined
},

getAnnouncedConnectorRdns() {
return state.connectors.filter(c => c.type === 'ANNOUNCED').map(c => c.info?.rdns)
},

getConnectors() {
return state.connectors
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ export const ConstantsUtil = {
'ASIA/MACAO',
'ASIA/BEIJING',
'ASIA/HARBIN'
]
],

CONNECTOR_RDNS_MAP: {
coinbaseWallet: 'com.coinbase.wallet'
} as Record<string, string>
}
2 changes: 1 addition & 1 deletion packages/ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "3.7.2",
"@walletconnect/ethereum-provider": "2.10.6",
"@walletconnect/ethereum-provider": "2.11.0",
"@web3modal/polyfills": "3.5.3",
"@web3modal/scaffold": "3.5.3",
"@web3modal/scaffold-react": "3.5.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/ethers5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "3.7.2",
"@walletconnect/ethereum-provider": "2.10.6",
"@walletconnect/ethereum-provider": "2.11.0",
"@web3modal/polyfills": "3.5.3",
"@web3modal/scaffold": "3.5.3",
"@web3modal/scaffold-react": "3.5.3",
Expand Down
13 changes: 10 additions & 3 deletions packages/scaffold/src/views/w3m-connect-view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
EventsController,
OptionsController,
RouterController,
StorageUtil
StorageUtil,
ConstantsUtil
} from '@web3modal/core'
import { customElement } from '@web3modal/ui'
import { LitElement, html } from 'lit'
Expand Down Expand Up @@ -147,7 +148,7 @@ export class W3mConnectView extends LitElement {
name=${connector.name ?? 'Unknown'}
@click=${() => this.onConnector(connector)}
tagVariant="success"
installed=${true}
.installed=${true}
>
</wui-list-wallet>
`
Expand All @@ -169,7 +170,7 @@ export class W3mConnectView extends LitElement {
return html`
<wui-list-wallet
imageSrc=${ifDefined(AssetUtil.getConnectorImage(connector))}
installed=${Boolean(announced)}
.installed=${Boolean(announced)}
name=${connector.name ?? 'Unknown'}
@click=${() => this.onConnector(connector)}
>
Expand All @@ -179,11 +180,17 @@ export class W3mConnectView extends LitElement {
}

private connectorsTemplate() {
const announcedRdns = ConnectorController.getAnnouncedConnectorRdns()

return this.connectors.map(connector => {
if (['WALLET_CONNECT', 'INJECTED', 'ANNOUNCED', 'EMAIL'].includes(connector.type)) {
return null
}

if (announcedRdns.includes(ConstantsUtil.CONNECTOR_RDNS_MAP[connector.id])) {
return null
}

return html`
<wui-list-wallet
imageSrc=${ifDefined(AssetUtil.getConnectorImage(connector))}
Expand Down

3 comments on commit ec4e15d

@vercel
Copy link

@vercel vercel bot commented on ec4e15d Jan 2, 2024

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on ec4e15d Jan 2, 2024

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on ec4e15d Jan 2, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.