Skip to content

Commit

Permalink
Updating README
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Oct 1, 2024
1 parent ace5afd commit 3613bac
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 44 deletions.
47 changes: 43 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,57 @@ yarn add @0xsequence/kit wagmi ethers@6.13.0 viem 0xsequence @tanstack/react-que

#### The 'easy' way

- `createConfig(walletType, options)` method is used to create your initial config and prepare sensible defaults that can be overridden

`walletType` is either 'waas' or 'universal'

```ts
interface CreateConfigOptions {
appName: string
projectAccessKey: string
chainIds?: number[]
defaultChainId?: number
disableAnalytics?: boolean
defaultTheme?: Theme
position?: ModalPosition
signIn?: {
logoUrl?: string
projectName?: string
useMock?: boolean
}
displayedAssets?: Array<{
contractAddress: string
chainId: number
}>
ethAuth?: EthAuthSettings
isDev?: boolean

// optional wagmiConfig overrides
wagmiConfig?: WagmiConfig

walletConnectProjectId: string

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

```js
import { SequenceKit, createConfig } from '@0xsequence/kit'

import Content from './components/Content'

const projectAccessKey = '<your-project-access-key>'

const config = createConfig('waas', {
projectAccessKey,
projectAccessKey: '<your-project-access-key>',
chainIds: [1, 137]
defaultChainId: 1
appName: 'Demo Dapp'
appName: 'Demo Dapp',
waasConfigKey: '<your-waas-config-key>'
})

function App() {
Expand Down
14 changes: 5 additions & 9 deletions packages/checkout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@ import { KitCheckoutProvider } from '@0xsequence/kit-checkout'

const App = () => {
return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<KitProvider>
<KitCheckoutProvider>
<Page />
</KitCheckoutProvider>
</KitProvider>
</QueryClientProvider>
</WagmiProvider>
<SequenceKit config={config}>
<KitCheckoutProvider>
<Page />
</KitCheckoutProvider>
</SequenceKit>
)
}
```
Expand Down
47 changes: 43 additions & 4 deletions packages/kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,57 @@ yarn add @0xsequence/kit wagmi ethers@6.13.0 viem 0xsequence @tanstack/react-que

#### The 'easy' way

- `createConfig(walletType, options)` method is used to create your initial config and prepare sensible defaults that can be overridden

`walletType` is either 'waas' or 'universal'

```ts
interface CreateConfigOptions {
appName: string
projectAccessKey: string
chainIds?: number[]
defaultChainId?: number
disableAnalytics?: boolean
defaultTheme?: Theme
position?: ModalPosition
signIn?: {
logoUrl?: string
projectName?: string
useMock?: boolean
}
displayedAssets?: Array<{
contractAddress: string
chainId: number
}>
ethAuth?: EthAuthSettings
isDev?: boolean

// optional wagmiConfig overrides
wagmiConfig?: WagmiConfig

walletConnectProjectId: string

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

```js
import { SequenceKit, createConfig } from '@0xsequence/kit'

import Content from './components/Content'

const projectAccessKey = '<your-project-access-key>'

const config = createConfig('waas', {
projectAccessKey,
projectAccessKey: '<your-project-access-key>',
chainIds: [1, 137]
defaultChainId: 1
appName: 'Demo Dapp'
appName: 'Demo Dapp',
waasConfigKey: '<your-waas-config-key>'
})

function App() {
Expand Down
12 changes: 6 additions & 6 deletions packages/kit/src/config/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createConfig as createWagmiConfig, type CreateConfigParameters, type Co
import { KitConfig, WalletType } from '../types'

import { getDefaultChains } from './defaultChains'
import { DefaultConnectorsProps, getDefaultConnectors } from './defaultConnectors'
import { DefaultConnectorOptions, getDefaultConnectors } from './defaultConnectors'
import { getDefaultTransports } from './defaultTransports'

type DefaultConfigProps<T extends WalletType> = KitConfig &
DefaultConnectorsProps<T> & {
export type CreateConfigOptions<T extends WalletType> = KitConfig &
DefaultConnectorOptions<T> & {
chainIds?: number[]
wagmiConfig?: Partial<Omit<CreateConfigParameters, 'client'>>
}
Expand All @@ -17,12 +17,12 @@ export interface SequenceKitConfig {
kitConfig: KitConfig
}

export const createConfig = <T extends WalletType>(walletType: T, props: DefaultConfigProps<T>): SequenceKitConfig => {
const { projectAccessKey, chainIds, wagmiConfig, ...rest } = props
export const createConfig = <T extends WalletType>(walletType: T, options: CreateConfigOptions<T>): SequenceKitConfig => {
const { projectAccessKey, chainIds, wagmiConfig, ...rest } = options

const chains = wagmiConfig?.chains || getDefaultChains(chainIds)
const transports = wagmiConfig?.transports || getDefaultTransports(chains)
const connectors = wagmiConfig?.connectors || getDefaultConnectors(walletType, props)
const connectors = wagmiConfig?.connectors || getDefaultConnectors(walletType, options)

return {
kitConfig: {
Expand Down
22 changes: 11 additions & 11 deletions packages/kit/src/config/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { walletConnect } from '../connectors/walletConnect'
import { WalletType } from '../types'
import { getKitConnectWallets } from '../utils/getKitConnectWallets'

export interface CommonConnectorsProps {
export interface CommonConnectorOptions {
appName: string
projectAccessKey: string
walletConnectProjectId: string
defaultChainId?: number
}

export interface DefaultWaasConnectorsProps extends CommonConnectorsProps {
export interface DefaultWaasConnectorOptions extends CommonConnectorOptions {
waasConfigKey: string
googleClientId?: string
appleClientId?: string
Expand All @@ -31,17 +31,17 @@ export interface DefaultWaasConnectorsProps extends CommonConnectorsProps {
isDev?: boolean
}

export interface DefaultUniversalConnectorsProps extends CommonConnectorsProps {}
export interface DefaultUniversalConnectorOptions extends CommonConnectorOptions {}

export type DefaultConnectorsProps<T extends WalletType> = T extends 'waas'
? DefaultWaasConnectorsProps
: DefaultUniversalConnectorsProps
export type DefaultConnectorOptions<T extends WalletType> = T extends 'waas'
? DefaultWaasConnectorOptions
: DefaultUniversalConnectorOptions

export const getDefaultConnectors = <T extends WalletType>(walletType: T, props: DefaultConnectorsProps<T>) => {
export const getDefaultConnectors = <T extends WalletType>(walletType: T, options: DefaultConnectorOptions<T>) => {
if (walletType === 'waas') {
return getDefaultWaasConnectors(props as DefaultWaasConnectorsProps)
return getDefaultWaasConnectors(options as DefaultWaasConnectorOptions)
} else if (walletType === 'universal') {
return getDefaultUniversalConnectors(props as DefaultUniversalConnectorsProps)
return getDefaultUniversalConnectors(options as DefaultUniversalConnectorOptions)
}
}

Expand All @@ -58,7 +58,7 @@ export const getDefaultWaasConnectors = ({
enableConfirmationModal,
legacyEmailAuth = false,
isDev = false
}: DefaultWaasConnectorsProps): CreateConnectorFn[] => {
}: DefaultWaasConnectorOptions): CreateConnectorFn[] => {
const wallets: any[] = [
emailWaas({
projectAccessKey,
Expand Down Expand Up @@ -111,7 +111,7 @@ export const getDefaultUniversalConnectors = ({
projectAccessKey,
walletConnectProjectId,
defaultChainId
}: DefaultUniversalConnectorsProps): CreateConnectorFn[] => {
}: DefaultUniversalConnectorOptions): CreateConnectorFn[] => {
const connectors = getKitConnectWallets(projectAccessKey, [
email({
defaultNetwork: defaultChainId,
Expand Down
11 changes: 9 additions & 2 deletions packages/kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ export type {
export type { SwapQuotesWithCurrencyInfo } from './hooks/data'

// Config
export { createConfig } from './config/createConfig'
export { getDefaultConnectors, getDefaultWaasConnectors } from './config/defaultConnectors'
export { createConfig, type CreateConfigOptions } from './config/createConfig'
export {
getDefaultConnectors,
getDefaultWaasConnectors,
getDefaultUniversalConnectors,
type DefaultConnectorOptions,
type DefaultWaasConnectorOptions,
type DefaultUniversalConnectorOptions
} from './config/defaultConnectors'
export { getDefaultChains } from './config/defaultChains'
export { getDefaultTransports } from './config/defaultTransports'

Expand Down
12 changes: 4 additions & 8 deletions packages/wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ import { KitWalletProvider } from '@0xsequence/kit-wallet'

const App = () => {
return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<KitProvider>
<KitWalletProvider>
<Page />
</KitWalletProvider>
</KitProvider>
</QueryClientProvider>
<SequenceKit config={config}>
<KitWalletProvider>
<Page />
</KitWalletProvider>
</WagmiProvider>
)
}
Expand Down

0 comments on commit 3613bac

Please sign in to comment.