@fluent.xyz/connect 0.6.2-rc.1 → 0.6.3
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 +18 -9
- package/dist/index.js +476 -221
- package/dist/index.js.map +1 -1
- package/docs/api.md +16 -8
- package/docs/errors.md +10 -4
- package/docs/getting-started.md +9 -0
- package/docs/guides/transactions.md +9 -0
- package/package.json +1 -1
package/docs/api.md
CHANGED
|
@@ -631,7 +631,7 @@ export type FluentBatchOperation = {
|
|
|
631
631
|
| `calls` | `readonly FluentBatchCallInput[]` | no | no | The calls as the host passed them. |
|
|
632
632
|
| `encodedCalls` | `FluentEncodedBatchCall[]` | no | no | The same calls encoded, in order: what `execute()` sends. |
|
|
633
633
|
| `canExecute` | `boolean` | no | no | Whether the widget could send the operation when it was built: the Widget account ready, or able to prepare itself when `execute()` is called. Not updated afterwards; read `widget.account.executionReady` for the live value. |
|
|
634
|
-
| `execute` | `(options?: FluentBatchOperationExecuteOptions) => Promise<FluentExecuteResult>` | no | no | Executes the operation for the Widget account and resolves once it is included. **Throws** `FluentReviewRejectedError` with `code` `transaction_review_rejected` when the person dismisses the Review, which a Fluent ID shows in Prompt mode; an External wallet's refusal in its own prompt rejects with the wallet's error. **Throws** `FluentSponsorshipFallbackError` when a Fluent ID asked for Sponsorship, a sponsored submission failed, and the submission in which the account pays its own gas failed too; its `code` says why Sponsorship failed: `denied`, `unauthorized`, `unreachable` or `no_token`. A failure while waiting for an operation's inclusion is not wrapped: it rejects with its own error, and an operation whose wait failed was submitted. What else is not wrapped: [guides/sponsorship.md](guides/sponsorship.md#both-failed-fluentsponsorshipfallbackerror). **Throws** `FluentUserOperationGasError` (experimental) with `code` `invalid_policy` for a `skipEstimation` policy that cannot be used (other invalid `userOperationGas` values throw a plain `Error`), and `paymaster_gas_mismatch` when, with estimation skipped, the paymaster's authorization of a Gas token payment does not match the fixed gas limits. Under Sponsorship, a failed check of the paymaster's gas fails the sponsored submission instead, and the account pays its own gas. **Throws** `FluentGasPaymentError`
|
|
634
|
+
| `execute` | `(options?: FluentBatchOperationExecuteOptions) => Promise<FluentExecuteResult>` | no | no | Executes the operation for the Widget account and resolves once it is included. **Throws** `FluentReviewRejectedError` with `code` `transaction_review_rejected` when the person dismisses the Review, which a Fluent ID shows in Prompt mode; an External wallet's refusal in its own prompt rejects with the wallet's error. **Throws** `FluentSponsorshipFallbackError` when a Fluent ID asked for Sponsorship, a sponsored submission failed, and the submission in which the account pays its own gas failed too; its `code` says why Sponsorship failed: `denied`, `unauthorized`, `unreachable` or `no_token`. A failure while waiting for an operation's inclusion is not wrapped: it rejects with its own error, and an operation whose wait failed was submitted. What else is not wrapped: [guides/sponsorship.md](guides/sponsorship.md#both-failed-fluentsponsorshipfallbackerror). **Throws** `FluentUserOperationGasError` (experimental) with `code` `invalid_policy` for a `skipEstimation` policy that cannot be used (other invalid `userOperationGas` values throw a plain `Error`), and `paymaster_gas_mismatch` when, with estimation skipped, the paymaster's authorization of a Gas token payment does not match the fixed gas limits. Under Sponsorship, a failed check of the paymaster's gas fails the sponsored submission instead, and the account pays its own gas. **Throws** `FluentGasPaymentError` when a Fluent ID's operation is paid in a Gas token and cannot be prepared; nothing has been signed or sent. Its `code` is `paymaster_unavailable` when the address of the paymaster to approve the Gas token to cannot be read, `insufficient_gas_token` when the account's balance of the Gas token is below the fee the paymaster quotes for the operation or the paymaster's simulation cannot charge the fee in it, and `paymaster_rejected` when the paymaster refuses to charge the fee in the Gas token for another reason. |
|
|
635
635
|
|
|
636
636
|
### `FluentBatchOperationExecuteOptions`
|
|
637
637
|
|
|
@@ -1120,9 +1120,11 @@ Literals: `denied`, `no_token`, `not_requested`, `unauthorized`, `unreachable`.
|
|
|
1120
1120
|
*value*
|
|
1121
1121
|
|
|
1122
1122
|
A Gas token payment the widget could not prepare. Thrown by `execute()` of a Fluent ID's Batch
|
|
1123
|
-
operation paid in a Gas token, before any signature is requested and before anything is sent
|
|
1124
|
-
|
|
1125
|
-
|
|
1123
|
+
operation paid in a Gas token, before any signature is requested and before anything is sent.
|
|
1124
|
+
`code`, a `FluentGasPaymentErrorCode`, identifies the failure, and `message` names the Gas
|
|
1125
|
+
token for `insufficient_gas_token` and `paymaster_rejected`; `cause` holds the error of the
|
|
1126
|
+
failed request when there was one. Paying in ETH (`gasPayment: { symbol: "ETH" }`) avoids every
|
|
1127
|
+
code.
|
|
1126
1128
|
|
|
1127
1129
|
```ts declaration
|
|
1128
1130
|
export class FluentGasPaymentError extends Error {
|
|
@@ -1144,14 +1146,20 @@ export class FluentGasPaymentError extends Error {
|
|
|
1144
1146
|
|
|
1145
1147
|
Why a `FluentGasPaymentError` was thrown. `paymaster_unavailable`: the request for the address
|
|
1146
1148
|
of the paymaster that charges Gas tokens on the operation's Network failed, or its answer held
|
|
1147
|
-
no address, so the widget has no spender to approve the Gas token to.
|
|
1148
|
-
|
|
1149
|
+
no address, so the widget has no spender to approve the Gas token to.
|
|
1150
|
+
`insufficient_gas_token`: the account's balance of the Gas token is below the fee the paymaster
|
|
1151
|
+
quotes for the operation, or the paymaster's simulation could not charge the fee in it.
|
|
1152
|
+
`paymaster_rejected`: the paymaster refused to charge the fee in the Gas token for another
|
|
1153
|
+
reason. Keep a `default` branch in a `switch` over it: a later release may add a code.
|
|
1149
1154
|
|
|
1150
1155
|
```ts declaration
|
|
1151
|
-
export type FluentGasPaymentErrorCode =
|
|
1156
|
+
export type FluentGasPaymentErrorCode =
|
|
1157
|
+
| "paymaster_unavailable"
|
|
1158
|
+
| "insufficient_gas_token"
|
|
1159
|
+
| "paymaster_rejected";
|
|
1152
1160
|
```
|
|
1153
1161
|
|
|
1154
|
-
Literals: `paymaster_unavailable`.
|
|
1162
|
+
Literals: `insufficient_gas_token`, `paymaster_rejected`, `paymaster_unavailable`.
|
|
1155
1163
|
|
|
1156
1164
|
## Link X
|
|
1157
1165
|
|
package/docs/errors.md
CHANGED
|
@@ -206,14 +206,20 @@ measured.
|
|
|
206
206
|
|
|
207
207
|
A Fluent ID's Batch operation paid in a Gas token could not be prepared. Before the operation is
|
|
208
208
|
signed, the widget reads the address of the paymaster that charges Gas tokens, because the
|
|
209
|
-
approval it may add to the operation names that paymaster as the spender
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
approval it may add to the operation names that paymaster as the spender; it compares the
|
|
210
|
+
account's balance of the Gas token with the fee the paymaster quotes for the operation; and it
|
|
211
|
+
asks the paymaster to charge the fee in the token. It throws before any signature is requested and
|
|
212
|
+
before anything is sent. A balance or quote the widget cannot read does not throw: the operation
|
|
213
|
+
goes to the paymaster as it is. `cause` holds the error of the failed request when there was one,
|
|
214
|
+
and `message` names the Gas token for `insufficient_gas_token` and `paymaster_rejected`. An
|
|
215
|
+
External wallet pays its own gas and an operation paid in ETH has no Gas token, so neither throws
|
|
216
|
+
it.
|
|
213
217
|
|
|
214
218
|
| `code` | Thrown by | What it means | What to do |
|
|
215
219
|
|---|---|---|---|
|
|
216
220
|
| `paymaster_unavailable` | `execute()` | The request for the paymaster's address on the operation's Network failed, or its answer held no address, so the widget has no spender to approve the Gas token to. | Try again later, or pay in ETH (`gasPayment: { symbol: "ETH" }`). |
|
|
221
|
+
| `insufficient_gas_token` | `execute()` | The account's balance of the Gas token is below the fee the paymaster quotes for the operation, or the paymaster's simulation of the operation could not charge the fee in the token. | Ask the person to pay the fee in ETH (`gasPayment: { symbol: "ETH" }`) or to add more of the Gas token, then send the operation again. The widget's own flows say "Not enough {symbol} to pay the network fee. Pay the fee in ETH or add {symbol}." |
|
|
222
|
+
| `paymaster_rejected` | `execute()` | The paymaster refused to charge the fee in the Gas token for another reason; `cause` holds its answer. | Pay in ETH (`gasPayment: { symbol: "ETH" }`) or try again later; report `cause` if it persists. |
|
|
217
223
|
|
|
218
224
|
## `FluentUserOperationGasError`
|
|
219
225
|
|
package/docs/getting-started.md
CHANGED
|
@@ -85,6 +85,15 @@ export const config: FluentWidgetConfig = {
|
|
|
85
85
|
Keep `config` stable: a module constant, as here, or a memo. The widget resolves `config` again
|
|
86
86
|
on every render that passes a new object, and such a render can throw too.
|
|
87
87
|
|
|
88
|
+
After Direct login authenticates a Fluent ID, the widget prepares its Signer even when the
|
|
89
|
+
return from X or Google did not restore the connect dialog. Creation does not wait for the
|
|
90
|
+
connected-wallet list to become ready: the authenticated user's linked Signer records identify
|
|
91
|
+
an existing Signer. The Widget account becomes ready after that Signer loads and its smart
|
|
92
|
+
account initializes. A Signer creation failure opens the
|
|
93
|
+
dialog with the provider's error and a **Try again** action; retrying preparation does not start
|
|
94
|
+
another X or Google redirect. A restored External wallet's authentication is not prepared as a
|
|
95
|
+
Fluent ID.
|
|
96
|
+
|
|
88
97
|
## Mount the widget
|
|
89
98
|
|
|
90
99
|
`<FluentWidget>` renders the connect button, the connect dialog and the account drawer, and
|
|
@@ -180,6 +180,15 @@ allowance the widget cannot read counts as none, and when ZeroDev cannot name th
|
|
|
180
180
|
amount instead, whatever the allowance. The Review lists the operation's own calls, not the
|
|
181
181
|
approval, and an operation paid in ETH or sent by an External wallet gets none.
|
|
182
182
|
|
|
183
|
+
Before an operation paid in a Gas token is signed, the widget also compares the account's balance
|
|
184
|
+
of that token with the fee the paymaster quotes for the operation. A balance below it rejects
|
|
185
|
+
`execute()` with a `FluentGasPaymentError` whose `code` is `insufficient_gas_token` and whose
|
|
186
|
+
`message` names the token; so does a paymaster whose simulation cannot charge the fee in the token,
|
|
187
|
+
and any other refusal by the paymaster rejects with `code` `paymaster_rejected`. Nothing has been
|
|
188
|
+
signed or sent in either case: offer the person the fee in ETH (`gasPayment: { symbol: "ETH" }`)
|
|
189
|
+
or ask them to add more of the token. A balance or quote the widget cannot read does not stop the
|
|
190
|
+
operation. The full list is in [errors.md](../errors.md#fluentgaspaymenterror).
|
|
191
|
+
|
|
183
192
|
Gas limits can be fixed by hand with the experimental `userOperationGas` option
|
|
184
193
|
([experimental.md](../experimental.md#useroperationgas)); leaving it out lets the widget
|
|
185
194
|
estimate.
|
package/package.json
CHANGED