Skip to content

Commit

Permalink
Refactor connector enabling/disabling options (#159)
Browse files Browse the repository at this point in the history
* Refactor connector enabling/disabling options

* Updating README and examples for new connector config
  • Loading branch information
corbanbrook authored Oct 3, 2024
1 parent eb23934 commit 4b94056
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 132 deletions.
79 changes: 60 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,35 @@ interface CreateConfigOptions {
ethAuth?: EthAuthSettings
isDev?: boolean

// optional wagmiConfig overrides
wagmiConfig?: WagmiConfig
wagmiConfig?: WagmiConfig // optional wagmiConfig overrides

walletConnectProjectId?: string

// embedded wallet (waas) specific connector options
waasConfigKey: string
googleClientId?: string
appleClientId?: string
appleRedirectURI?: string
enableConfirmationModal?: boolean
legacyEmailAuth?: boolean

walletConnect?:
| boolean
| {
projectId: string
}

google?:
| boolean
| {
clientId: string
}

apple?:
| boolean
| {
clientId: string
rediretURI: string
}

email?:
| boolean
| {
legacyEmailAuth?: boolean
}
}
```

Expand All @@ -83,7 +100,20 @@ const config = createConfig('waas', {
chainIds: [1, 137]
defaultChainId: 1
appName: 'Demo Dapp',
waasConfigKey: '<your-waas-config-key>'
waasConfigKey: '<your-waas-config-key>',

google: {
clientId: '<your-google-client-id>'
},

apple: {
clientId: '<your-apple-client-id>',
redirectUrl: '...'
},

walletConnect: {
projectId: '<your-wallet-connect-id>'
}
})

function App() {
Expand Down Expand Up @@ -119,25 +149,36 @@ chains.forEach(chain => {
})

// Universal wallet configuration
const connectors = getDefaultConnectors({
const connectors = getDefaultConnectors('universal', {
projectAccessKey,
walletConnectProjectId: '<your-wallet-connect-id>',
appName: 'Demo Dapp',
defaultChainId: 137,
appName: 'Demo Dapp'

walletConnect: {
projectId: '<your-wallet-connect-id>'
}
})

/*
// ...or for Embedded wallet configuration
const connectors = getDefaultWaasConnectors({
const connectors = getDefaultWaasConnectors('{
projectAccessKey,
walletConnectProjectId: '<your-wallet-connect-id>',
defaultChainId: 137,
appName: 'Demo Dapp',
waasConfigKey: '<your-waas-config-key>',
googleClientId,
appleClientId,
appleRedirectUrl
google: {
clientId
},
apple: {
clientId,
redirectUrl
},
walletConnect: {
projectId: '<your-wallet-connect-id>'
}
})
*/

Expand Down
15 changes: 11 additions & 4 deletions examples/next/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,24 @@ export const kitConfig: KitConfig = {
export const config = createConfig('waas', {
...kitConfig,
appName: 'Kit Demo',
walletConnectProjectId: 'c65a6cb1aa83c4e24500130f23a437d8',
chainIds: [ChainId.ARBITRUM_NOVA, ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON],
defaultChainId: ChainId.ARBITRUM_NOVA,

// Waas specific config options
waasConfigKey: 'eyJwcm9qZWN0SWQiOjE2ODE1LCJycGNTZXJ2ZXIiOiJodHRwczovL3dhYXMuc2VxdWVuY2UuYXBwIn0=',
googleClientId: '970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com',
appleClientId: 'com.horizon.sequence.waas',
appleRedirectURI: 'http://localhost:3000',
enableConfirmationModal: false,

google: {
clientId: '970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com'
},
apple: {
clientId: 'com.horizon.sequence.waas',
redirectURI: 'http://localhost:3000'
},
walletConnect: {
projectId: 'c65a6cb1aa83c4e24500130f23a437d8'
},

wagmiConfig: {
// Next.js doesn't support localStorage in SSR
storage: createStorage({ storage: cookieStorage }),
Expand Down
28 changes: 19 additions & 9 deletions examples/react/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,33 @@ export const config =
? createConfig('waas', {
...kitConfig,
appName: 'Kit Demo',
walletConnectProjectId,
chainIds: [ChainId.ARBITRUM_NOVA, ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON],
defaultChainId: ChainId.ARBITRUM_NOVA,
waasConfigKey: isDebugMode
? 'eyJwcm9qZWN0SWQiOjY5NCwicnBjU2VydmVyIjoiaHR0cHM6Ly9kZXYtd2Fhcy5zZXF1ZW5jZS5hcHAiLCJlbWFpbFJlZ2lvbiI6ImNhLWNlbnRyYWwtMSIsImVtYWlsQ2xpZW50SWQiOiI1NGF0bjV1cGk2M3FjNTlhMWVtM3ZiaHJzbiJ9'
: 'eyJwcm9qZWN0SWQiOjE2ODE1LCJlbWFpbFJlZ2lvbiI6ImNhLWNlbnRyYWwtMSIsImVtYWlsQ2xpZW50SWQiOiI2N2V2NXVvc3ZxMzVmcGI2OXI3NnJoYnVoIiwicnBjU2VydmVyIjoiaHR0cHM6Ly93YWFzLnNlcXVlbmNlLmFwcCJ9',
googleClientId: isDebugMode
? '603294233249-6h5saeg2uiu8akpcbar3r2aqjp6j7oem.apps.googleusercontent.com'
: '970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com',
appleClientId: 'com.horizon.sequence.waas',
appleRedirectURI: window.location.origin + window.location.pathname,
enableConfirmationModal: localStorage.getItem('confirmationEnabled') === 'true'
enableConfirmationModal: localStorage.getItem('confirmationEnabled') === 'true',

google: {
clientId: isDebugMode
? '603294233249-6h5saeg2uiu8akpcbar3r2aqjp6j7oem.apps.googleusercontent.com'
: '970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com'
},
apple: {
clientId: 'com.horizon.sequence.waas',
redirectURI: window.location.origin + window.location.pathname
},
walletConnect: {
projectId: walletConnectProjectId
}
})
: createConfig('universal', {
...kitConfig,
appName: 'Kit Demo',
walletConnectProjectId,
chainIds: [ChainId.ARBITRUM_NOVA, ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON],
defaultChainId: ChainId.ARBITRUM_NOVA
defaultChainId: ChainId.ARBITRUM_NOVA,

walletConnect: {
projectId: walletConnectProjectId
}
})
61 changes: 47 additions & 14 deletions packages/kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,35 @@ interface CreateConfigOptions {
ethAuth?: EthAuthSettings
isDev?: boolean

// optional wagmiConfig overrides
wagmiConfig?: WagmiConfig
wagmiConfig?: WagmiConfig // optional wagmiConfig overrides

walletConnectProjectId?: string

// embedded wallet (waas) specific connector options
waasConfigKey: string
googleClientId?: string
appleClientId?: string
appleRedirectURI?: string
enableConfirmationModal?: boolean
legacyEmailAuth?: boolean

walletConnect?:
| boolean
| {
projectId: string
}

google?:
| boolean
| {
clientId: string
}

apple?:
| boolean
| {
clientId: string
rediretURI: string
}

email?:
| boolean
| {
legacyEmailAuth?: boolean
}
}
```

Expand All @@ -82,7 +99,20 @@ const config = createConfig('waas', {
chainIds: [1, 137]
defaultChainId: 1
appName: 'Demo Dapp',
waasConfigKey: '<your-waas-config-key>'
waasConfigKey: '<your-waas-config-key>',

google: {
clientId: '<your-google-client-id>'
},

apple: {
clientId: '<your-apple-client-id>',
redirectUrl: '...'
},

walletConnect: {
projectId: '<your-wallet-connect-id>'
}
})

function App() {
Expand Down Expand Up @@ -117,11 +147,14 @@ chains.forEach(chain => {
transports[chain.id] = http()
})

const connectors = getDefaultConnectors({
walletConnectProjectId: 'wallet-connect-id',
defaultChainId: 137,
const connectors = getDefaultConnectors('universal', {
projectAccessKey,
appName: 'demo app',
projectAccessKey
defaultChainId: 137,

walletConnect: {
projectId: '<your-wallet-connect-project-id>'
}
})

const config = createConfig({
Expand Down
Loading

0 comments on commit 4b94056

Please sign in to comment.