@fluent.xyz/connect 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -0
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/docs/api.md +2 -0
- package/docs/concepts.md +3 -1
- package/docs/experimental.md +21 -0
- package/docs/getting-started.md +3 -1
- package/package.json +1 -1
package/docs/api.md
CHANGED
|
@@ -110,6 +110,7 @@ export type FluentWidgetRenderContext = {
|
|
|
110
110
|
widget: FluentBatchApi;
|
|
111
111
|
openConnect: () => void;
|
|
112
112
|
openAccount: () => void;
|
|
113
|
+
renderBridge: (onClose: () => void) => ReactNode;
|
|
113
114
|
disconnect: () => Promise<void>;
|
|
114
115
|
hasConnectedAccount: boolean;
|
|
115
116
|
status: FluentWidgetStatus;
|
|
@@ -129,6 +130,7 @@ export type FluentWidgetRenderContext = {
|
|
|
129
130
|
| `widget` | `FluentBatchApi` | no | no | The Widget API: the account, Batch operations, signatures and the current Gas payment. |
|
|
130
131
|
| `openConnect` | `() => void` | no | no | Opens the sign-in dialog, the same one the connect button opens. A click event passed to it is ignored, so it can be handed straight to `onClick`. |
|
|
131
132
|
| `openAccount` | `() => void` | no | no | Opens the account drawer, as the connect button does once a Widget account is connected. |
|
|
133
|
+
| `renderBridge` | `(onClose: () => void) => ReactNode` | no | **yes** | Renders the drawer's Swap page, where a Deposit is made, as the App's own element: in a modal or a page of its own, shown when the App decides. It is the page the drawer shows, on both Networks and for either account kind, in the widget's own style scope so it draws as in the drawer inside any element, and it connects the External wallet that pays by itself. `onClose` is called by the page's own ways back to the wallet: "Back to wallet" once a Deposit has landed or while its funds are on their way, and "Back to Home" on a Two-step deposit's status screen. The form itself offers no way back, which the App's own element provides. **Experimental.** May change or be removed in a minor release: an App that draws the Swap page itself is not a 0.8.3 commitment. |
|
|
132
134
|
| `disconnect` | `() => Promise<void>` | no | no | Disconnects the Widget account, the same teardown the account menu's "Disconnect" runs. The Widget session and the stored identity token are cleared before it resolves, so an App can await it before resetting its own state. It also asks the service to revoke the Service session, and any Service session that a `getAuthToken()` still out at the disconnect opens later, and resolves once those requests have been answered or have failed, so it can take as long as that `getAuthToken()` does. A failed revocation is not retried: the promise resolving does not prove the service ended the Service session. |
|
|
133
135
|
| `hasConnectedAccount` | `boolean` | no | no | Whether a Widget account, a Fluent ID or an External wallet, is connected now. `false` while a stored session is still being restored: branch on `status` to tell that apart. |
|
|
134
136
|
| `status` | `FluentWidgetStatus` | no | no | The connection state as one value, meaningful on every render including the first, before a stored session has been restored. Branch on it rather than on `hasConnectedAccount` alone: `"restoring"` and `"disconnected"` both have `hasConnectedAccount === false`, and treating them alike shows a Connect button to a person who is signed in. The account's address is `widget.account.address`. |
|
package/docs/concepts.md
CHANGED
|
@@ -126,7 +126,9 @@ sends that over the bridge instead. The service's URL is the experimental
|
|
|
126
126
|
The page connects the External wallet that holds the funds by itself, on both
|
|
127
127
|
networks. A desktop browser offers the wallet extensions it announces; a phone
|
|
128
128
|
offers MetaMask, Trust Wallet and Rainbow, each opened through a link that
|
|
129
|
-
carries the WalletConnect pairing.
|
|
129
|
+
carries the WalletConnect pairing. An App that wants the page outside the drawer,
|
|
130
|
+
in a modal of its own, gets the same page from the render context's experimental
|
|
131
|
+
`renderBridge(onClose)` ([experimental.md](experimental.md#renderbridge)).
|
|
130
132
|
|
|
131
133
|
Five consequences reach your integration:
|
|
132
134
|
|
package/docs/experimental.md
CHANGED
|
@@ -12,6 +12,7 @@ applies to: a Fluent ID, an External wallet, or both. The exact types are in [ap
|
|
|
12
12
|
|---|---|---|
|
|
13
13
|
| `privyAdapter`, `FluentPrivyAdapter` | `FluentWidgetProps` | [`privyAdapter`](#privyadapter) |
|
|
14
14
|
| `wallet`, `FluentExternalWalletState`, `FluentWalletChoice` | `FluentWidgetProps`, `FluentWidgetRenderContext` | [`wallet`](#wallet) |
|
|
15
|
+
| `renderBridge` | `FluentWidgetRenderContext` | [`renderBridge`](#renderbridge) |
|
|
15
16
|
| `execution`, `FluentWidgetExecution`, `FluentWidgetExecutionSource` | `FluentWidgetConfig` | [`execution`](#execution) |
|
|
16
17
|
| `userOperationGas`, `FluentUserOperationGas`, `FluentFixedAccountGas`, `FluentFixedPaymasterGas`, `FluentUserOperationGasError`, `FluentUserOperationGasErrorCode` | `FluentBatchOperationExecuteOptions` | [`userOperationGas`](#useroperationgas) |
|
|
17
18
|
| `paymaster`, `timing`, `FluentExecuteTiming`, `FluentExecuteTimingInstants` | `FluentExecuteResult` | [`paymaster` and `timing`](#paymaster-and-timing) |
|
|
@@ -65,6 +66,26 @@ connects itself ([api.md](api.md#fluentexternalwalletstate)).
|
|
|
65
66
|
widget is using: the host's when the prop is passed, the widget's own otherwise
|
|
66
67
|
([api.md](api.md#fluentwidgetrendercontext)).
|
|
67
68
|
|
|
69
|
+
## `renderBridge`
|
|
70
|
+
|
|
71
|
+
`FluentWidgetRenderContext.renderBridge(onClose)` returns the drawer's Swap page, where a
|
|
72
|
+
Deposit is made, as an element for the App to place: in a modal, a sheet or a page of its own
|
|
73
|
+
([api.md](api.md#fluentwidgetrendercontext)).
|
|
74
|
+
|
|
75
|
+
- **What it does**: renders the page the account drawer shows under Swap, with the drawer's own
|
|
76
|
+
state and in the widget's own style scope (`.fluent-root.dark`), so it draws as in the drawer
|
|
77
|
+
inside any element, a Deposit started in the App's element is the one the drawer follows, and a
|
|
78
|
+
Two-step deposit keeps its place in `localStorage` as it does there. The page connects the
|
|
79
|
+
External wallet that pays by itself. `onClose` is called by the page's own ways back to the
|
|
80
|
+
wallet: "Back to wallet" once a Deposit has landed or while its funds are on their way, and
|
|
81
|
+
"Back to Home" on a Two-step deposit's status screen. The form itself offers no way back,
|
|
82
|
+
which the App's own element provides.
|
|
83
|
+
- **Default**: none. An App that does not call it gets the page in the drawer alone.
|
|
84
|
+
- **When to use it**: an App with `connectButton={false}` that draws its own account screens
|
|
85
|
+
and wants Deposits beside them rather than in the drawer.
|
|
86
|
+
- **Applies to**: a Fluent ID and an External wallet, on both Networks, as the drawer's page.
|
|
87
|
+
With nobody signed in the page asks for a Fluent ID to credit, as it does in the drawer.
|
|
88
|
+
|
|
68
89
|
## `execution`
|
|
69
90
|
|
|
70
91
|
`FluentWidgetConfig.execution` takes a `FluentWidgetExecution`, every field optional
|
package/docs/getting-started.md
CHANGED
|
@@ -201,7 +201,9 @@ export function Root() {
|
|
|
201
201
|
With `connectButton={false}`, open the screens from your own content with the render context's
|
|
202
202
|
`openConnect` (the connect dialog) and `openAccount` (the account drawer). `openConnect` ignores
|
|
203
203
|
a click event passed to it, so it can be handed straight to `onClick`. The example after the
|
|
204
|
-
next section shows both.
|
|
204
|
+
next section shows both. The drawer's Swap page, where a Deposit is made, can also be drawn in
|
|
205
|
+
your own element instead of the drawer: the experimental `renderBridge(onClose)` returns it
|
|
206
|
+
([experimental.md](experimental.md#renderbridge)).
|
|
205
207
|
|
|
206
208
|
## Reading the account
|
|
207
209
|
|
package/package.json
CHANGED