Skip to content

Commit

Permalink
chore: remove coinbase SDK de-duplication (#2768)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Sep 2, 2024
1 parent 480a096 commit 6b95ad8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 150 deletions.
9 changes: 1 addition & 8 deletions packages/base/adapters/evm/ethers/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,15 +1566,8 @@ export class EVMEthersClient {
const { info, provider } = event.detail
const connectors = this.appKit?.getConnectors()
const existingConnector = connectors?.find(c => c.name === info.name)
const coinbaseConnector = connectors?.find(
c => c.id === ConstantsUtil.COINBASE_SDK_CONNECTOR_ID
)
const isCoinbaseDuplicated =
coinbaseConnector &&
event.detail.info.rdns ===
ConstantsUtil.CONNECTOR_RDNS_MAP[ConstantsUtil.COINBASE_SDK_CONNECTOR_ID]

if (!existingConnector && !isCoinbaseDuplicated) {
if (!existingConnector) {
const type = PresetsUtil.ConnectorTypesMap[ConstantsUtil.EIP6963_CONNECTOR_ID]
if (type) {
this.appKit?.addConnector({
Expand Down
9 changes: 1 addition & 8 deletions packages/base/adapters/evm/ethers5/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1152,15 +1152,8 @@ export class EVMEthers5Client {
const { info, provider } = event.detail
const connectors = this.appKit?.getConnectors()
const existingConnector = connectors?.find(c => c.name === info.name)
const coinbaseConnector = connectors?.find(
c => c.id === ConstantsUtil.COINBASE_SDK_CONNECTOR_ID
)
const isCoinbaseDuplicated =
coinbaseConnector &&
event.detail.info.rdns ===
ConstantsUtil.CONNECTOR_RDNS_MAP[ConstantsUtil.COINBASE_SDK_CONNECTOR_ID]

if (!existingConnector && !isCoinbaseDuplicated) {
if (!existingConnector) {
const type = PresetsUtil.ConnectorTypesMap[ConstantsUtil.EIP6963_CONNECTOR_ID]
if (type) {
this.appKit?.addConnector({
Expand Down
12 changes: 2 additions & 10 deletions packages/base/adapters/evm/wagmi/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,17 +643,9 @@ export class EVMWagmiClient {

const w3mConnectors: Connector[] = []

const coinbaseSDKId = ConstantsUtil.COINBASE_SDK_CONNECTOR_ID

// Check if coinbase injected connector is present
const coinbaseConnector = filteredConnectors.find(c => c.id === coinbaseSDKId)

filteredConnectors.forEach(({ id, name, type, icon }) => {
// If coinbase injected connector is present, skip coinbase sdk connector.
const isCoinbaseRepeated =
coinbaseConnector &&
id === ConstantsUtil.CONNECTOR_RDNS_MAP[ConstantsUtil.COINBASE_CONNECTOR_ID]
const shouldSkip = isCoinbaseRepeated || ConstantsUtil.AUTH_CONNECTOR_ID === id
// Auth connector is initialized separately
const shouldSkip = ConstantsUtil.AUTH_CONNECTOR_ID === id
if (!shouldSkip) {
w3mConnectors.push({
id,
Expand Down
1 change: 0 additions & 1 deletion packages/scaffold-ui/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export * from '../src/partials/w3m-connect-custom-widget/index.js'
export * from '../src/partials/w3m-connect-featured-widget/index.js'
export * from '../src/partials/w3m-connect-injected-widget/index.js'
export * from '../src/partials/w3m-connect-multi-chain-widget/index.js'
export * from '../src/partials/w3m-connect-coinbase-widget/index.js'
export * from '../src/partials/w3m-connect-external-widget/index.js'
export * from '../src/partials/w3m-connect-recent-widget/index.js'
export * from '../src/partials/w3m-connect-recommended-widget/index.js'
Expand Down
106 changes: 0 additions & 106 deletions packages/scaffold-ui/src/partials/w3m-connect-coinbase-widget/index.ts

This file was deleted.

19 changes: 2 additions & 17 deletions packages/scaffold-ui/src/partials/w3m-connector-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '@web3modal/core'
import { ConstantsUtil as CommonConstantsUtil } from '@web3modal/common'
import { state } from 'lit/decorators.js'
import { ConstantsUtil } from '@web3modal/scaffold-utils'
import { WalletUtil } from '../../utils/WalletUtil.js'
@customElement('w3m-connector-list')
export class W3mConnectorList extends LitElement {
Expand All @@ -36,17 +35,8 @@ export class W3mConnectorList extends LitElement {

// -- Render -------------------------------------------- //
public override render() {
const {
custom,
recent,
announced,
coinbase,
injected,
multiChain,
recommended,
featured,
external
} = this.getConnectorsByType()
const { custom, recent, announced, injected, multiChain, recommended, featured, external } =
this.getConnectorsByType()

return html`
<wui-flex flexDirection="column" gap="xs">
Expand All @@ -65,7 +55,6 @@ export class W3mConnectorList extends LitElement {
? html`<w3m-connect-featured-widget></w3m-connect-featured-widget>`
: null}
${custom?.length ? html`<w3m-connect-custom-widget></w3m-connect-custom-widget>` : null}
${coinbase ? html`<w3m-connect-coinbase-widget></w3m-connect-coinbase-widget>` : null}
${external.length
? html`<w3m-connect-external-widget></w3m-connect-external-widget>`
: null}
Expand All @@ -88,16 +77,12 @@ export class W3mConnectorList extends LitElement {
const announced = this.connectors.filter(connector => connector.type === 'ANNOUNCED')
const injected = this.connectors.filter(connector => connector.type === 'INJECTED')
const external = this.connectors.filter(connector => connector.type === 'EXTERNAL')
const coinbase = this.connectors.find(
connector => connector.id === ConstantsUtil.COINBASE_SDK_CONNECTOR_ID
)
const isEVM = ChainController.state.activeChain === CommonConstantsUtil.CHAIN.EVM
const includeAnnouncedAndInjected = isEVM ? OptionsController.state.enableEIP6963 : true

return {
custom,
recent,
coinbase,
external,
multiChain,
announced: includeAnnouncedAndInjected ? announced : [],
Expand Down

0 comments on commit 6b95ad8

Please sign in to comment.