-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added createConfig method and SequenceKit wrapper to simplify dapp setup
- Loading branch information
1 parent
b9e8be6
commit e8134a5
Showing
20 changed files
with
413 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,72 @@ yarn add @0xsequence/kit wagmi [email protected] viem 0xsequence @tanstack/react-que | |
|
||
### Setting up the Library | ||
|
||
#### 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 config = createConfig('waas', { | ||
projectAccessKey: '<your-project-access-key>', | ||
chainIds: [1, 137] | ||
defaultChainId: 1 | ||
appName: 'Demo Dapp', | ||
waasConfigKey: '<your-waas-config-key>' | ||
}) | ||
|
||
function App() { | ||
return ( | ||
<SequenceKit config={config}> | ||
<Content /> | ||
</SequenceKit> | ||
) | ||
} | ||
``` | ||
|
||
#### Need more customization? | ||
|
||
React apps must be wrapped by a Wagmi client and the KitWalletProvider components. It is important that the Wagmi wrapper comes before the Sequence Kit wrapper. | ||
|
||
```js | ||
|
@@ -75,19 +141,23 @@ const connectors = getDefaultConnectors({ | |
}) | ||
*/ | ||
|
||
const config = createConfig({ | ||
const wagmiConfig = createConfig({ | ||
chains, | ||
transports, | ||
connectors | ||
}) | ||
|
||
const kitConfig = { | ||
projectAccessKey: '...' | ||
} | ||
|
||
const queryClient = new QueryClient() | ||
|
||
function App() { | ||
return ( | ||
<WagmiProvider config={config}> | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={queryClient}> | ||
<KitProvider> | ||
<KitProvider config={kitConfig}> | ||
<Content /> | ||
</KitProvider> | ||
</QueryClientProvider> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,23 @@ | ||
import '@0xsequence/design-system/styles.css' | ||
|
||
import { ThemeProvider } from '@0xsequence/design-system' | ||
import { KitProvider } from '@0xsequence/kit' | ||
import { SequenceKit } from '@0xsequence/kit' | ||
import { KitCheckoutProvider } from '@0xsequence/kit-checkout' | ||
import { KitWalletProvider } from '@0xsequence/kit-wallet' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { WagmiProvider } from 'wagmi' | ||
|
||
import { Homepage } from './components/Homepage' | ||
import { kitConfig, wagmiConfig } from './config' | ||
|
||
const queryClient = new QueryClient() | ||
import { config } from './config' | ||
|
||
export const App = () => { | ||
return ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={queryClient}> | ||
<KitProvider config={kitConfig}> | ||
<KitWalletProvider> | ||
<KitCheckoutProvider> | ||
<div id="app"> | ||
<ThemeProvider root="#app" scope="app" theme="dark"> | ||
<Homepage /> | ||
</ThemeProvider> | ||
</div> | ||
</KitCheckoutProvider> | ||
</KitWalletProvider> | ||
</KitProvider> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
<ThemeProvider theme="dark"> | ||
<SequenceKit config={config}> | ||
<KitWalletProvider> | ||
<KitCheckoutProvider> | ||
<Homepage /> | ||
</KitCheckoutProvider> | ||
</KitWalletProvider> | ||
</SequenceKit> | ||
</ThemeProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.