Skip to content

Commit 1f88927

Browse files
authored
Merge pull request #206 from Apillon/staging
Staging
2 parents 20fe7ef + d66ada4 commit 1f88927

File tree

1 file changed

+72
-21
lines changed

1 file changed

+72
-21
lines changed

build/12-embedded-wallets-integration.md

+72-21
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default defineConfig({
4545
To use the Embedded wallet UI, your Next app has to be in `app router` mode. When in `pages routing` mode, global CSS file imports throw an error. [Github Discussion](https://github.com/vercel/next.js/discussions/27953)
4646

4747
Embedded wallet relies on browser APIs and it doesn't make sense to run it server-side.
48-
To avoid errors, the component including `<WalletWidget />` should be marked with `'use client';`
48+
To avoid errors, the component including `<EmbeddedWallet />` should be marked with `'use client';`
4949

5050
HTTPS needs to be configured even for localhost, so that authentication can work accross multiple domains.
5151
In Next.js you can do this by adding `--experimental-https` to dev command.
@@ -87,7 +87,7 @@ To avoid errors, wrap the wallet with `<ClientOnly />`.
8787
```vue
8888
<template>
8989
<ClientOnly>
90-
<WalletWidget clientId="..." />
90+
<EmbeddedWallet clientId="..." />
9191
</ClientOnly>
9292
</template>
9393
```
@@ -154,9 +154,9 @@ Replace the parameters with however you wish to setup your wallet.
154154
<CodeGroupItem title="React / Next.js" active>
155155

156156
```tsx
157-
import { WalletWidget } from "@apillon/wallet-react";
157+
import { EmbeddedWallet } from "@apillon/wallet-react";
158158

159-
<WalletWidget
159+
<EmbeddedWallet
160160
clientId={"YOUR INTEGRATION UUID HERE"}
161161
defaultNetworkId={1287}
162162
networks={[
@@ -175,9 +175,9 @@ import { WalletWidget } from "@apillon/wallet-react";
175175
<CodeGroupItem title="Vue / Nuxt">
176176

177177
```tsx
178-
import { WalletWidget } from "@apillon/wallet-vue";
178+
import { EmbeddedWallet } from "@apillon/wallet-vue";
179179

180-
<WalletWidget
180+
<EmbeddedWallet
181181
clientId="YOUR INTEGRATION UUID HERE"
182182
:defaultNetworkId="1287"
183183
:networks="[
@@ -218,14 +218,24 @@ EmbeddedWalletUI("#wallet", {
218218

219219
### Parameters
220220

221-
| Field | Type | Required | Description |
222-
| ---------------------------- | ----------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
223-
| clientId | `string` | Yes | UUID of the integration that you obtain when creating it on the [Apillon embedded wallet dashboard](https://app.apillon.io/dashboard/service/embedded-wallet). |
224-
| defaultNetworkId | `number` | No | Chain ID set as default when opening wallet. |
225-
| networks | `Network[]` | No | Array of network specifications |
226-
| broadcastAfterSign | `boolean` | No | Automatically broadcast with SDK after confirming a transaction. |
227-
| disableDefaultActivatorStyle | `boolean` | No | Remove styles from "open wallet" button |
228-
| authFormPlaceholder | `string` | No | Placeholder displayed in input for username/email |
221+
| Field | Type | Required | Description |
222+
| ---------------------------- | ----------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
223+
| clientId | `string` | Yes | UUID of the integration that you obtain when creating it on the [Apillon embedded wallet dashboard](https://app.apillon.io/dashboard/service/embedded-wallet). |
224+
| passkeyAuthMode | `AuthPasskeyMode` | No | Method for authenticating with passkey to make it global. Default is `redirect` |
225+
| defaultNetworkId | `number` | No | Chain ID set as default when opening wallet. |
226+
| networks | `Network[]` | No | Array of network specifications |
227+
| broadcastAfterSign | `boolean` | No | Automatically broadcast with SDK after confirming a transaction. |
228+
| disableDefaultActivatorStyle | `boolean` | No | Remove styles from "open wallet" button |
229+
| authFormPlaceholder | `string` | No | Placeholder displayed in input for username/email |
230+
231+
#### AuthPasskeyMode
232+
233+
| Option | Description |
234+
| ------------- | -------------------------------------------- |
235+
| `redirect` | Open registration form in the same tab |
236+
| `tab_form` | Open registration form in a new tab |
237+
| `tab_process` | Process registration in a new tab |
238+
| `popup` | Process registration in a new browser window |
229239

230240
#### Network Object
231241

@@ -235,12 +245,15 @@ The Network Object defines the properties required to connect to a blockchain ne
235245
To find the information for your desired network, visit [chainlist.org](https://chainlist.org).
236246
:::
237247

238-
| Field | Type | Description |
239-
| ----------- | -------- | --------------------------------------- |
240-
| name | `string` | The name of the network |
241-
| id | `number` | The unique Chain ID of the network |
242-
| rpcUrl | `string` | The URL to the network's RPC server |
243-
| explorerUrl | `string` | The URL to the network's block explorer |
248+
| Field | Type | Description |
249+
| ---------------- | -------- | ------------------------------------------------------------------- |
250+
| name | `string` | The name of the network |
251+
| id | `number` | The unique Chain ID of the network |
252+
| rpcUrl | `string` | The URL to the network's RPC server |
253+
| explorerUrl | `string` | The URL to the network's block explorer |
254+
| imageUrl | `string` | Optional. Icon of the chain for display in UI |
255+
| currencySymbol | `string` | Optional. Symbol of the native currency (default is 'ETH') |
256+
| currencyDecimals | `number` | Optional. Number of decimals of the native currency (default is 18) |
244257

245258
### Button style
246259

@@ -380,6 +393,25 @@ const signer = new EmbeddedEthersSigner();
380393
await signer.signMessage("test message");
381394
```
382395

396+
::: warning
397+
Beware when changing wallet chain after initializing any ethers object (e.g. `const myContract = new ethers.Contract(..., signer);`).
398+
These objects are not reactive by default, so the previous chain will be used.
399+
400+
Events `'chainChanged'` and `'dataUpdated'` on `embeddedWallet.events` are emitted when wallet chain is updated, you can use these events to reinitialize any stale objects.
401+
:::
402+
403+
::: details Chain change event handler example
404+
405+
```js
406+
getEmbeddedWallet()?.events.on("dataUpdated", ({ name, newValue }) => {
407+
if (name === "defaultNetworkId") {
408+
// ...
409+
}
410+
});
411+
```
412+
413+
:::
414+
383415
### Viem
384416
385417
To use [viem](https://viem.sh/) we provide a specialized Viem adapter.
@@ -415,6 +447,25 @@ await walletClient.sendRawTransaction({
415447
});
416448
```
417449
450+
::: warning
451+
Beware when changing wallet chain after initializing any viem object with a specific chain (e.g. `const walletClient = createWalletClient(...);`).
452+
If not changed, this chain will be used even after changing chain in the wallet.
453+
454+
Events `'chainChanged'` and `'dataUpdated'` on `embeddedWallet.events` are emitted when wallet chain is updated, you can use these events to reinitialize any stale objects (or update reactive state e.g.).
455+
:::
456+
457+
::: details Chain change event handler example
458+
459+
```js
460+
getEmbeddedWallet()?.events.on("dataUpdated", ({ name, newValue }) => {
461+
if (name === "defaultNetworkId") {
462+
// ...
463+
}
464+
});
465+
```
466+
467+
:::
468+
418469
### Wagmi
419470
420471
We provide an **EIP-1193** provider that can be used with [Wagmi](https://wagmi.sh/) or any other integration that supports it.
@@ -545,7 +596,7 @@ document
545596
546597
## Create custom UI
547598
548-
All the functionalities of embedded wallets are contained in base package `@apillon/wallet-sdk`. The SDK exposes all the core methods of the wallet and you can create completely custom UI of the wallet on top of it.
599+
All the functionalities of embedded wallets are contained in base package `@apillon/wallet-sdk`. The SDK exposes all the core methods of the wallet and you can create a completely custom UI of the wallet on top of it.
549600
550601
::: tip
551602
For detailed technical documentation about the embedded wallet SDK, visit [the github repository](https://github.com/Apillon/embedded-wallet/tree/main/packages/sdk)

0 commit comments

Comments
 (0)