@fluent.xyz/connect 0.6.3 → 0.6.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/README.md +2 -0
- package/dist/batchOperation-BXn9nmvk.d.ts +524 -0
- package/dist/index.d.ts +4 -505
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +293 -0
- package/dist/internal.js +4781 -0
- package/dist/internal.js.map +1 -0
- package/docs/internal.md +109 -0
- package/docs/upgrading-0.5.md +40 -8
- package/package.json +5 -1
package/docs/internal.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Internal entry
|
|
2
|
+
|
|
3
|
+
> **Nothing on this page is promised.** `@fluent.xyz/connect/internal` is the Internal entry:
|
|
4
|
+
> the helpers the widget is built from, importable by name. Any of them may change or go in any
|
|
5
|
+
> release, a patch included, and none is in [api.md](api.md). The root entry,
|
|
6
|
+
> `@fluent.xyz/connect`, is what is kept after 0.6.0; [experimental.md](experimental.md) says
|
|
7
|
+
> which of its names may still change. Import from here only where you can read this page at
|
|
8
|
+
> every upgrade.
|
|
9
|
+
|
|
10
|
+
The entry exists so that an App which needs the widget's own helpers, such as a wallet
|
|
11
|
+
dashboard that reads balances or builds a transfer without the widget's Send form, imports them
|
|
12
|
+
instead of copying their source, which drifts from the SDK silently. A name an App comes to rely
|
|
13
|
+
on is moved to the root entry, where it becomes a promise; ask for it.
|
|
14
|
+
|
|
15
|
+
| Name | What it is |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `fluentTestnetTokenDefaults`, `fluentMainnetTokenDefaults`, `getFluentTokenDefaultsForNetwork` | The Default tokens of a Network, by symbol. |
|
|
18
|
+
| `getFluentDefaultWidgetDisplayTokens` | The Default tokens in the order the widget shows them. |
|
|
19
|
+
| `isFluentNativeToken`, `fluentTokenIdentity` | Whether a token is the chain's own currency; a token's Token identity. |
|
|
20
|
+
| `readFluentTokenBalances`, `FluentTokenBalance` | One account's balance of each token, read through a viem public client. |
|
|
21
|
+
| `FluentTokenDefinition` | The widget's own token shape, with `native` and `gasPriority`; see below. |
|
|
22
|
+
| `parseFluentTransferRecipient`, `parseFluentTransferAmount`, `FluentTransferRecipient`, `FluentTransferAmount` | The validation of the widget's Send form: a recipient, an amount. |
|
|
23
|
+
| `buildFluentTransferCall`, `fluentTransferAbi` | The one call of a Batch operation that moves a token, and the ERC-20 ABI it encodes with. |
|
|
24
|
+
| `isFaucetNetwork`, `getFluentExplorerBaseUrl` | Whether a Network has a faucet; its block explorer URL. |
|
|
25
|
+
| `normalizeFluentWidgetNetwork` | The Network an App's own setting names (`"prod"`, `"Development"`, …), or `undefined`; the widget reads no environment variable, so the App passes the result as `network`. |
|
|
26
|
+
| `createFluentFamiliesClient`, `FluentFamilies`, `FluentFamily`, `FluentFamilyTier`, `FluentFamilyType`, `FluentFamiliesClient`, `FluentFamiliesClientConfig` | A client of the service's families endpoint, read by the person's Privy DID. |
|
|
27
|
+
| `buildFluentBridgeUrl` | The portal bridge URL with a recipient, for an App that links out to the bridge. |
|
|
28
|
+
|
|
29
|
+
## Two `FluentTokenDefinition`s
|
|
30
|
+
|
|
31
|
+
The root entry's `FluentTokenDefinition` is an Integrator token: what an App passes in `tokens`,
|
|
32
|
+
with no `native` and no `gasPriority`, because the widget grants neither to a token it did not
|
|
33
|
+
declare itself. The Internal entry's `FluentTokenDefinition` is a Default token as the widget
|
|
34
|
+
declares it, and carries both; the helpers above take and return that one. An App that imports
|
|
35
|
+
both renames one:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import type { FluentTokenDefinition } from "@fluent.xyz/connect";
|
|
39
|
+
import type { FluentTokenDefinition as FluentDefaultToken } from "@fluent.xyz/connect/internal";
|
|
40
|
+
|
|
41
|
+
export function isNative(token: FluentDefaultToken): boolean {
|
|
42
|
+
return token.native === true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function integratorToken(token: FluentDefaultToken): FluentTokenDefinition {
|
|
46
|
+
const { native: _native, gasPriority: _gasPriority, ...rest } = token;
|
|
47
|
+
return rest;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Reading balances
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { createPublicClient, http, type Address } from "viem";
|
|
55
|
+
import { fluentTestnet } from "@fluent.xyz/connect";
|
|
56
|
+
import {
|
|
57
|
+
getFluentDefaultWidgetDisplayTokens,
|
|
58
|
+
readFluentTokenBalances,
|
|
59
|
+
} from "@fluent.xyz/connect/internal";
|
|
60
|
+
|
|
61
|
+
const client = createPublicClient({ chain: fluentTestnet, transport: http() });
|
|
62
|
+
|
|
63
|
+
export async function balancesOf(account: Address) {
|
|
64
|
+
const balances = await readFluentTokenBalances({
|
|
65
|
+
client,
|
|
66
|
+
account,
|
|
67
|
+
tokens: getFluentDefaultWidgetDisplayTokens("testnet"),
|
|
68
|
+
});
|
|
69
|
+
return balances.filter((balance) => balance.status === "ready");
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Building a transfer
|
|
74
|
+
|
|
75
|
+
The call goes to the Widget API's `execute()` like any other; the widget's Send form does the
|
|
76
|
+
same.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import type { FluentBatchCallInput } from "@fluent.xyz/connect";
|
|
80
|
+
import {
|
|
81
|
+
buildFluentTransferCall,
|
|
82
|
+
fluentMainnetTokenDefaults,
|
|
83
|
+
parseFluentTransferAmount,
|
|
84
|
+
parseFluentTransferRecipient,
|
|
85
|
+
} from "@fluent.xyz/connect/internal";
|
|
86
|
+
|
|
87
|
+
export function transferCall(params: {
|
|
88
|
+
from: `0x${string}`;
|
|
89
|
+
to: string;
|
|
90
|
+
amount: string;
|
|
91
|
+
balance: bigint;
|
|
92
|
+
}): FluentBatchCallInput | string {
|
|
93
|
+
const token = fluentMainnetTokenDefaults.BLEND;
|
|
94
|
+
const recipient = parseFluentTransferRecipient({
|
|
95
|
+
input: params.to,
|
|
96
|
+
self: params.from,
|
|
97
|
+
contracts: new Set([token.address.toLowerCase()]),
|
|
98
|
+
});
|
|
99
|
+
if (recipient.status !== "ok") return recipient.status === "empty" ? "" : recipient.message;
|
|
100
|
+
const amount = parseFluentTransferAmount({
|
|
101
|
+
input: params.amount,
|
|
102
|
+
symbol: token.symbol,
|
|
103
|
+
decimals: token.decimals,
|
|
104
|
+
balance: params.balance,
|
|
105
|
+
});
|
|
106
|
+
if (amount.status !== "ok") return amount.status === "empty" ? "" : amount.message;
|
|
107
|
+
return buildFluentTransferCall({ token, to: recipient.address, amount: amount.raw });
|
|
108
|
+
}
|
|
109
|
+
```
|
package/docs/upgrading-0.5.md
CHANGED
|
@@ -165,7 +165,8 @@ export function chainDefinitionOf(network: FluentWidgetNetwork) {
|
|
|
165
165
|
#### Recipe: `getFluentExplorerBaseUrl`
|
|
166
166
|
|
|
167
167
|
0.5's `getFluentExplorerBaseUrl(network)` was this expression. Like it, it returns testnet's
|
|
168
|
-
explorer for any value other than `"mainnet"`.
|
|
168
|
+
explorer for any value other than `"mainnet"`. The Internal entry exports the function itself
|
|
169
|
+
([Recipe: the Internal entry](#recipe-the-internal-entry)).
|
|
169
170
|
|
|
170
171
|
```ts
|
|
171
172
|
import { getFluentChainForNetwork, type FluentWidgetNetwork } from "@fluent.xyz/connect";
|
|
@@ -179,9 +180,10 @@ export function explorerBaseUrlOf(network: FluentWidgetNetwork): string | undefi
|
|
|
179
180
|
|
|
180
181
|
| Removed | Kind | Use instead |
|
|
181
182
|
|---|---|---|
|
|
182
|
-
| `normalizeFluentWidgetNetwork` |
|
|
183
|
+
| `normalizeFluentWidgetNetwork` | recipe | [Recipe: the Internal entry](#recipe-the-internal-entry) |
|
|
183
184
|
| `resolveFluentWidgetNetworkFromEnv` | none | The widget reads no environment variable; the App passes `network`. |
|
|
184
|
-
| `FluentWidgetNetworkProvider`, `useFluentWidgetNetwork
|
|
185
|
+
| `FluentWidgetNetworkProvider`, `useFluentWidgetNetwork` | none | Internal: the App passes `network` itself, so it already knows it. |
|
|
186
|
+
| `isFaucetNetwork` | recipe | [Recipe: the Internal entry](#recipe-the-internal-entry) |
|
|
185
187
|
| `ResolvedFluentWidgetConfig`, `ResolvedFluentWidgetExecution` | none | There is no public resolved config. |
|
|
186
188
|
| `FLUENT_CONNECT_DEFAULT_ASSETS` | none | The widget's default images are internal. |
|
|
187
189
|
|
|
@@ -198,16 +200,45 @@ export function explorerBaseUrlOf(network: FluentWidgetNetwork): string | undefi
|
|
|
198
200
|
|
|
199
201
|
| Removed | Kind | Use instead |
|
|
200
202
|
|---|---|---|
|
|
201
|
-
| `fluent`, `createFluentClient`, `FluentClient`, `FluentClientConfig
|
|
203
|
+
| `fluent`, `createFluentClient`, `FluentClient`, `FluentClientConfig` | none | The feature is removed: the standalone client. |
|
|
204
|
+
| `createFluentFamiliesClient`, `FluentFamilies`, `FluentFamiliesClient`, `FluentFamiliesClientConfig`, `FluentFamily`, `FluentFamilyTier`, `FluentFamilyType` | recipe | [Recipe: the Internal entry](#recipe-the-internal-entry) |
|
|
202
205
|
|
|
203
206
|
### Tokens and balances
|
|
204
207
|
|
|
205
208
|
| Removed | Kind | Use instead |
|
|
206
209
|
|---|---|---|
|
|
207
|
-
| `
|
|
208
|
-
| `
|
|
210
|
+
| `getFluentTokenDefaults`, `getFluentDefaultWidgetGasTokens`, `isFluentDefaultToken`, `mergeFluentDisplayTokens`, `findFluentSymbolCollisions` | none | The widget does this itself: it lists its Default tokens beside the App's `tokens`. |
|
|
211
|
+
| `fluentMainnetTokenDefaults`, `fluentTestnetTokenDefaults`, `getFluentTokenDefaultsForNetwork`, `getFluentDefaultWidgetDisplayTokens`, `isFluentNativeToken`, `fluentTokenIdentity` | recipe | [Recipe: the Internal entry](#recipe-the-internal-entry) |
|
|
212
|
+
| `readFluentTokenMetadata` | none | The widget reads balances itself; `refreshBalances` refetches them. |
|
|
213
|
+
| `readFluentTokenBalances`, `FluentTokenBalance` | recipe | [Recipe: the Internal entry](#recipe-the-internal-entry) |
|
|
209
214
|
| `FLUENT_USER_TOKEN_LIMIT`, `createFluentUserTokenStore`, `createFluentBackendUserTokenStore`, `useFluentUserTokens`, `UserTokenStore`, `BackendUserTokenStore`, `FluentUserTokenAddResult` | none | The widget keeps the person's User tokens itself. |
|
|
210
215
|
|
|
216
|
+
#### Recipe: the Internal entry
|
|
217
|
+
|
|
218
|
+
Every row that points here names a helper 0.6.0 removed from the root entry and the package
|
|
219
|
+
publishes again, promised nothing, as the Internal entry, `@fluent.xyz/connect/internal`
|
|
220
|
+
([internal.md](internal.md)): the name is the same, so the import path is all that changes. A
|
|
221
|
+
name there may change or go in any release; read that page at every upgrade.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { createPublicClient, http, type Address } from "viem";
|
|
225
|
+
import { fluentTestnet } from "@fluent.xyz/connect";
|
|
226
|
+
import {
|
|
227
|
+
getFluentDefaultWidgetDisplayTokens,
|
|
228
|
+
readFluentTokenBalances,
|
|
229
|
+
} from "@fluent.xyz/connect/internal";
|
|
230
|
+
|
|
231
|
+
const client = createPublicClient({ chain: fluentTestnet, transport: http() });
|
|
232
|
+
|
|
233
|
+
export function balancesOf(account: Address) {
|
|
234
|
+
return readFluentTokenBalances({
|
|
235
|
+
client,
|
|
236
|
+
account,
|
|
237
|
+
tokens: getFluentDefaultWidgetDisplayTokens("testnet"),
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
211
242
|
### Gas payment
|
|
212
243
|
|
|
213
244
|
| Removed | Kind | Use instead |
|
|
@@ -219,7 +250,8 @@ export function explorerBaseUrlOf(network: FluentWidgetNetwork): string | undefi
|
|
|
219
250
|
|
|
220
251
|
| Removed | Kind | Use instead |
|
|
221
252
|
|---|---|---|
|
|
222
|
-
| `
|
|
253
|
+
| `checkFluentTransferFee`, `FluentTokenTransferOutcome`, `FluentTokenTransferRequest`, `FluentTokenTransferSender`, `FluentTransferFee` | none | Internal to the widget's Send form. |
|
|
254
|
+
| `buildFluentTransferCall`, `fluentTransferAbi`, `parseFluentTransferAmount`, `parseFluentTransferRecipient`, `FluentTransferAmount`, `FluentTransferRecipient` | recipe | [Recipe: the Internal entry](#recipe-the-internal-entry) |
|
|
223
255
|
|
|
224
256
|
### User settings
|
|
225
257
|
|
|
@@ -301,7 +333,7 @@ export function signingModeOf(confirmation: "always" | "session"): FluentSigning
|
|
|
301
333
|
|
|
302
334
|
| Member | Kind | Use instead |
|
|
303
335
|
|---|---|---|
|
|
304
|
-
| `FluentTokenDefinition.gasPriority`, `FluentTokenDefinition.native` | none | The widget already ignored both on a token the App passed: only a Default token can be a Gas token or the chain's own currency. |
|
|
336
|
+
| `FluentTokenDefinition.gasPriority`, `FluentTokenDefinition.native` | none | The widget already ignored both on a token the App passed: only a Default token can be a Gas token or the chain's own currency. The Internal entry's `FluentTokenDefinition`, the Default token's shape, keeps both ([internal.md](internal.md#two-fluenttokendefinitions)). |
|
|
305
337
|
|
|
306
338
|
### `FluentWidgetAccount`
|
|
307
339
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluent.xyz/connect",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Fluent Connect React widget \u2014 Privy login, ZeroDev smart account, batch operations, and wallet UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
"types": "./dist/index.d.ts",
|
|
42
42
|
"import": "./dist/index.js"
|
|
43
43
|
},
|
|
44
|
+
"./internal": {
|
|
45
|
+
"types": "./dist/internal.d.ts",
|
|
46
|
+
"import": "./dist/internal.js"
|
|
47
|
+
},
|
|
44
48
|
"./styles.css": "./dist/fluent-connect.css",
|
|
45
49
|
"./package.json": "./package.json"
|
|
46
50
|
},
|