Skip to content

Commit

Permalink
Make walletConnect an optional connector (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook authored Oct 2, 2024
1 parent 4da16ba commit eb23934
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface CreateConfigOptions {
// optional wagmiConfig overrides
wagmiConfig?: WagmiConfig

walletConnectProjectId: string
walletConnectProjectId?: string

// embedded wallet (waas) specific connector options
waasConfigKey: string
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface CreateConfigOptions {
// optional wagmiConfig overrides
wagmiConfig?: WagmiConfig

walletConnectProjectId: string
walletConnectProjectId?: string

// embedded wallet (waas) specific connector options
waasConfigKey: string
Expand Down
42 changes: 26 additions & 16 deletions packages/kit/src/config/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { getKitConnectWallets } from '../utils/getKitConnectWallets'
export interface CommonConnectorOptions {
appName: string
projectAccessKey: string
walletConnectProjectId: string
defaultChainId?: number
walletConnectProjectId?: string
}

export interface DefaultWaasConnectorOptions extends CommonConnectorOptions {
Expand Down Expand Up @@ -48,8 +48,8 @@ export const getDefaultConnectors = <T extends WalletType>(walletType: T, option
export const getDefaultWaasConnectors = ({
appName,
projectAccessKey,
walletConnectProjectId,
defaultChainId,
walletConnectProjectId,

waasConfigKey,
googleClientId,
Expand All @@ -70,11 +70,17 @@ export const getDefaultWaasConnectors = ({
}),
coinbaseWallet({
appName
}),
walletConnect({
projectId: walletConnectProjectId
})
]

if (walletConnectProjectId) {
wallets.push(
walletConnect({
projectId: walletConnectProjectId
})
)
}

if (googleClientId) {
wallets.push(
googleWaas({
Expand All @@ -87,6 +93,7 @@ export const getDefaultWaasConnectors = ({
})
)
}

if (appleClientId && appleRedirectURI) {
wallets.push(
appleWaas({
Expand All @@ -101,18 +108,16 @@ export const getDefaultWaasConnectors = ({
)
}

const connectors = getKitConnectWallets(projectAccessKey, wallets)

return connectors
return getKitConnectWallets(projectAccessKey, wallets)
}

export const getDefaultUniversalConnectors = ({
appName,
projectAccessKey,
walletConnectProjectId,
defaultChainId
defaultChainId,
walletConnectProjectId
}: DefaultUniversalConnectorOptions): CreateConnectorFn[] => {
const connectors = getKitConnectWallets(projectAccessKey, [
const wallets: any[] = [
email({
defaultNetwork: defaultChainId,
connect: {
Expand Down Expand Up @@ -148,11 +153,16 @@ export const getDefaultUniversalConnectors = ({
connect: {
app: appName
}
}),
walletConnect({
projectId: walletConnectProjectId
})
])
]

if (walletConnectProjectId) {
wallets.push(
walletConnect({
projectId: walletConnectProjectId
})
)
}

return connectors
return getKitConnectWallets(projectAccessKey, wallets)
}

0 comments on commit eb23934

Please sign in to comment.