Skip to content

Commit

Permalink
Merge projectAccessKey into connect options
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Apr 25, 2024
1 parent bd512dd commit af66565
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 30 deletions.
3 changes: 2 additions & 1 deletion packages/connectors/src/connectors/apple/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export const apple = (options: AppleOptions): Wallet => ({
monochromeLogoLight: getAppleMonochromeLogo({ isDarkMode: false }),
// iconBackground: '#fff',
name: 'Apple',
createConnector: () => {
createConnector: projectAccessKey => {
const connector = sequenceWallet({
...options,
connect: {
projectAccessKey,
...options?.connect,
settings: {
...options?.connect?.settings,
Expand Down
3 changes: 2 additions & 1 deletion packages/connectors/src/connectors/discord/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export const discord = (options: DiscordOptions): Wallet => ({
monochromeLogoLight: getDiscordLogo({ isDarkMode: false }),
// iconBackground: '#fff',
name: 'Discord',
createConnector: () => {
createConnector: projectAccessKey => {
const connector = sequenceWallet({
...options,
connect: {
projectAccessKey,
...options?.connect,
settings: {
...options?.connect?.settings,
Expand Down
10 changes: 5 additions & 5 deletions packages/connectors/src/connectors/email/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ export const email = (options: EmailOptions): Wallet => ({
logoLight: getEmailLogo({ isDarkMode: false }),
// iconBackground: '#fff',
name: 'Email',
createConnector: () => {
const email = localStorage.getItem(EMAIL_CONNECTOR_LOCAL_STORAGE_KEY)
createConnector: projectAccessKey => {
//const email = localStorage.getItem(EMAIL_CONNECTOR_LOCAL_STORAGE_KEY)

const connector = sequenceWallet({
...options,
// @ts-ignore
connect: {
projectAccessKey,
...options?.connect,
settings: {
...options?.connect?.settings,
signInOptions: ['email'],
signInWithEmail: email || ''
signInOptions: ['email']
// signInWithEmail: email || ''
}
}
})
Expand Down
3 changes: 2 additions & 1 deletion packages/connectors/src/connectors/facebook/facebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export const facebook = (options: FacebookOptions): Wallet => ({
monochromeLogoLight: getFacebookMonochromeLogo({ isDarkMode: false }),
// iconBackground: '#fff',
name: 'Facebook',
createConnector: () => {
createConnector: projectAccessKey => {
const connector = sequenceWallet({
...options,
connect: {
projectAccessKey,
...options?.connect,
settings: {
...options?.connect?.settings,
Expand Down
4 changes: 2 additions & 2 deletions packages/connectors/src/connectors/google/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const google = (options: GoogleOptions): Wallet => ({
monochromeLogoDark: getMonochromeGoogleLogo({ isDarkMode: true }),
monochromeLogoLight: getMonochromeGoogleLogo({ isDarkMode: false }),
name: 'Google',
createConnector: () => {
createConnector: projectAccessKey => {
const connector = sequenceWallet({
...options,
// @ts-ignore
connect: {
projectAccessKey,
...options?.connect,
settings: {
...options?.connect?.settings,
Expand Down
8 changes: 6 additions & 2 deletions packages/connectors/src/connectors/sequence/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ export const sequence = (options: SequenceOptions): Wallet => ({
logoLight: SequenceLogo,
// iconBackground: '#777',
name: 'Sequence',
createConnector: () => {
createConnector: projectAccessKey => {
const connector = sequenceWallet({
...options
...options,
connect: {
projectAccessKey,
...options.connect
}
})
return connector
}
Expand Down
3 changes: 2 additions & 1 deletion packages/connectors/src/connectors/twitch/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export const twitch = (options: TwitchOptions): Wallet => ({
monochromeLogoLight: getTwitchLogo({ isDarkMode: false }),
// iconBackground: '#fff',
name: 'Twitch',
createConnector: () => {
createConnector: projectAccessKey => {
const connector = sequenceWallet({
...options,
connect: {
projectAccessKey,
...options?.connect,
settings: {
...options?.connect?.settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
let id = 'sequence'
let name = 'Sequence'

const { projectAccessKey } = connect

const signInOptions = params?.connect?.settings?.signInOptions || []
const signInWith = params?.connect?.settings?.signInWith
const signInWithEmail = params?.connect?.settings?.signInWithEmail
Expand Down Expand Up @@ -124,8 +126,6 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {

return provider
} catch (e) {
const projectAccessKey = await config.storage?.getItem(LocalStorageKey.ProjectAccessKey)

if (!projectAccessKey) {
throw 'projectAccessKey not found'
}
Expand Down
14 changes: 4 additions & 10 deletions packages/connectors/src/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,19 @@ export const getDefaultConnectors = ({
email({
defaultNetwork: defaultChainId,
connect: {
app: appName,
projectAccessKey
app: appName
}
}),
google({
defaultNetwork: defaultChainId,
connect: {
app: appName,
projectAccessKey
app: appName
}
}),
facebook({
defaultNetwork: defaultChainId,
connect: {
app: appName,
projectAccessKey
app: appName
}
}),
twitch({
Expand All @@ -56,8 +53,7 @@ export const getDefaultConnectors = ({
sequence({
defaultNetwork: defaultChainId,
connect: {
app: appName,
projectAccessKey
app: appName
}
}),
walletConnect({
Expand All @@ -69,7 +65,6 @@ export const getDefaultConnectors = ({
})
])

/* @ts-ignore-next-line */
return connectors
}

Expand Down Expand Up @@ -129,6 +124,5 @@ export const getDefaultWaasConnectors = ({

const connectors = getKitConnectWallets(projectAccessKey, wallets)

/* @ts-ignore-next-line */
return connectors
}
7 changes: 2 additions & 5 deletions packages/kit/src/utils/getKitConnectWallets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { Connector, CreateConnectorFn } from 'wagmi'

import { LocalStorageKey } from '../constants'
import { LogoProps } from '@0xsequence/kit-connectors'

export interface WalletProperties {
Expand All @@ -17,7 +16,7 @@ export interface WalletProperties {
}

export type Wallet = WalletProperties & {
createConnector: () => CreateConnectorFn
createConnector: (projectAccessKey: string) => CreateConnectorFn
}

export interface WalletField {
Expand All @@ -27,16 +26,14 @@ export interface WalletField {
export type ExtendedConnector = Connector & WalletField

export const getKitConnectWallets = (projectAccessKey: string, wallets: Wallet[]): CreateConnectorFn[] => {
localStorage.setItem(LocalStorageKey.ProjectAccessKey, projectAccessKey)

const connectors: CreateConnectorFn[] = []

wallets.forEach(wallet => {
const { createConnector, ...metaProperties } = wallet
const walletProperties = { ...metaProperties }

const createConnectorOverride = (config: any) => {
const connector = createConnector()
const connector = createConnector(projectAccessKey)

const res = connector(config) as ExtendedConnector
res._wallet = { ...walletProperties }
Expand Down

0 comments on commit af66565

Please sign in to comment.