From 25194019f4cd27d0ff6f573988fa73468d51444f Mon Sep 17 00:00:00 2001 From: Corban Riley Date: Thu, 30 May 2024 14:45:51 -0400 Subject: [PATCH] Adding immutable to default connectors --- .../src/connectors/immutable/immutable.ts | 4 +- packages/connectors/src/defaultConnectors.ts | 155 ++++++++++++++++++ .../wagmiConnectors/immutableConnector.ts | 9 +- 3 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 packages/connectors/src/defaultConnectors.ts diff --git a/packages/connectors/src/connectors/immutable/immutable.ts b/packages/connectors/src/connectors/immutable/immutable.ts index 656da211..ee9b684c 100644 --- a/packages/connectors/src/connectors/immutable/immutable.ts +++ b/packages/connectors/src/connectors/immutable/immutable.ts @@ -1,10 +1,10 @@ import type { Wallet } from '@0xsequence/kit' -import { immutableConnector, BaseSequenceConnectorOptions } from '../wagmiConnectors' +import { immutableConnector } from '../wagmiConnectors' import { ImmutableLogo } from './ImmutableLogo' -export interface ImmutableOptions extends BaseSequenceConnectorOptions {} +export interface ImmutableOptions {} export const immutable = (options: ImmutableOptions): Wallet => ({ id: 'immutable', diff --git a/packages/connectors/src/defaultConnectors.ts b/packages/connectors/src/defaultConnectors.ts new file mode 100644 index 00000000..8cee9e98 --- /dev/null +++ b/packages/connectors/src/defaultConnectors.ts @@ -0,0 +1,155 @@ +import { getKitConnectWallets } from '@0xsequence/kit' +import { CreateConnectorFn } from 'wagmi' + +import { apple } from './connectors/apple' +import { appleWaas } from './connectors/apple/appleWaas' +import { coinbaseWallet } from './connectors/coinbaseWallet' +import { email } from './connectors/email' +import { emailWaas } from './connectors/email/emailWaas' +import { facebook } from './connectors/facebook' +import { google } from './connectors/google' +import { googleWaas } from './connectors/google/googleWaas' +import { immutable } from './connectors/immutable' +import { metamask } from './connectors/metamask' +import { sequence } from './connectors/sequence' +import { twitch } from './connectors/twitch' +import { walletConnect } from './connectors/walletConnect' + +interface GetDefaultConnectors { + walletConnectProjectId: string + projectAccessKey: string + appName: string + defaultChainId?: number +} + +export const getDefaultConnectors = ({ + walletConnectProjectId, + defaultChainId, + projectAccessKey, + appName +}: GetDefaultConnectors): CreateConnectorFn[] => { + const connectors = getKitConnectWallets(projectAccessKey, [ + immutable({}), + email({ + defaultNetwork: defaultChainId, + connect: { + app: appName + } + }), + google({ + defaultNetwork: defaultChainId, + connect: { + app: appName + } + }), + facebook({ + defaultNetwork: defaultChainId, + connect: { + app: appName + } + }), + twitch({ + defaultNetwork: defaultChainId, + connect: { + app: appName + } + }), + apple({ + defaultNetwork: defaultChainId, + connect: { + app: appName + } + }), + sequence({ + defaultNetwork: defaultChainId, + connect: { + app: appName + } + }), + walletConnect({ + projectId: walletConnectProjectId + }), + metamask() + // coinbaseWallet({ + // appName + // }) + ]) + + return connectors +} + +interface GetDefaultWaasConnectors { + projectAccessKey: string + waasConfigKey: string + googleClientId?: string + appleClientId?: string + appleRedirectURI?: string + + walletConnectProjectId: string + + appName: string + defaultChainId?: number + + enableConfirmationModal?: boolean + + isDev?: boolean +} + +export const getDefaultWaasConnectors = ({ + projectAccessKey, + waasConfigKey, + googleClientId, + appleClientId, + appleRedirectURI, + walletConnectProjectId, + appName, + defaultChainId, + enableConfirmationModal, + isDev = false +}: GetDefaultWaasConnectors): CreateConnectorFn[] => { + const wallets: any[] = [ + emailWaas({ + projectAccessKey, + waasConfigKey, + enableConfirmationModal, + network: defaultChainId, + isDev + }), + coinbaseWallet({ + appName + }), + metamask(), + walletConnect({ + projectId: walletConnectProjectId + }) + ] + if (googleClientId) { + wallets.push( + googleWaas({ + projectAccessKey, + googleClientId, + waasConfigKey, + enableConfirmationModal, + network: defaultChainId, + isDev + }) + ) + } + if (appleClientId && appleRedirectURI) { + wallets.push( + appleWaas({ + projectAccessKey, + appleClientId, + appleRedirectURI, + waasConfigKey, + enableConfirmationModal, + network: defaultChainId, + isDev + }) + ) + } + + const connectors = getKitConnectWallets(projectAccessKey, wallets) + + return connectors +} diff --git a/packages/kit/src/connectors/wagmiConnectors/immutableConnector.ts b/packages/kit/src/connectors/wagmiConnectors/immutableConnector.ts index 53fcda57..b9c2c704 100644 --- a/packages/kit/src/connectors/wagmiConnectors/immutableConnector.ts +++ b/packages/kit/src/connectors/wagmiConnectors/immutableConnector.ts @@ -5,14 +5,13 @@ export interface BaseImmutableConnectorOptions {} immutableConnector.type = 'immutable' as const export function immutableConnector(params: BaseImmutableConnectorOptions) { - type Provider = undefined + type Provider = any type Properties = { params: BaseImmutableConnectorOptions - setEmail: (email: string) => void } type StorageItem = {} - let provider = undefined + let provider: any = undefined return createConnector(config => ({ id: 'immutable', @@ -26,6 +25,8 @@ export function immutableConnector(params: BaseImmutableConnectorOptions) { async connect() { const provider = await this.getProvider() + + return { accounts: [], chainId: 1 } }, async disconnect() { @@ -46,7 +47,7 @@ export function immutableConnector(params: BaseImmutableConnectorOptions) { } // return the immutable passport provider - provider = undefined + provider = {} }, async isAuthorized() {