@fluent.xyz/connect 0.1.5 → 0.2.1

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.js CHANGED
@@ -1,6 +1,6 @@
1
- import { defineChain, http, createPublicClient, formatUnits, encodeFunctionData, parseUnits, numberToHex, fallback, isHex, stringToHex, bytesToHex } from 'viem';
1
+ import { toEventSelector, parseAbiItem, defineChain, http, createPublicClient, formatUnits, isAddress, getAddress, encodeFunctionData, parseUnits, zeroAddress, numberToHex, BaseError, HttpRequestError, fallback, isHex, stringToHex, bytesToHex } from 'viem';
2
2
  import * as React2 from 'react';
3
- import { createContext, forwardRef, useContext, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect } from 'react';
3
+ import { createContext, forwardRef, useContext, useMemo, useState, useCallback, useRef, useEffect, useLayoutEffect } from 'react';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { toCallPolicy, CallPolicyVersion, toTimestampPolicy, CallType, ParamCondition } from '@zerodev/permissions/policies';
6
6
  export { CallType, ParamCondition } from '@zerodev/permissions/policies';
@@ -11,23 +11,23 @@ import { toPermissionValidator, serializePermissionAccount, deserializePermissio
11
11
  import { toECDSASigner } from '@zerodev/permissions/signers';
12
12
  import { createZeroDevPaymasterClient, getERC20PaymasterApproveCall, createKernelAccountClient, createKernelAccount } from '@zerodev/sdk';
13
13
  import { getEntryPoint, KERNEL_V3_3 } from '@zerodev/sdk/constants';
14
+ import { Toast as Toast$1 } from '@base-ui/react/toast';
15
+ import { clsx } from 'clsx';
16
+ import { twMerge } from 'tailwind-merge';
17
+ import { Button as Button$1 } from '@base-ui/react/button';
18
+ import { cva } from 'class-variance-authority';
19
+ import { XIcon, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Loader2, ChevronDownIcon, CheckIcon, AlertTriangle, Trash2, Plus, Loader2Icon, ChevronUpIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
14
20
  import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
15
21
  import { createAppKit, useAppKit } from '@reown/appkit/react';
16
22
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
17
23
  import { WagmiProvider, useAccount, useDisconnect, useWalletClient, useSwitchChain } from 'wagmi';
18
24
  import { coinbaseWallet, baseAccount } from 'wagmi/connectors';
19
- import { Button as Button$1 } from '@base-ui/react/button';
20
- import { cva } from 'class-variance-authority';
21
- import { clsx } from 'clsx';
22
- import { twMerge } from 'tailwind-merge';
23
25
  import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
24
- import { XIcon, Loader2, ChevronLeft, ExternalLink, Copy, Settings, LogOut, ChevronDownIcon, CheckIcon, Loader2Icon, ChevronUpIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
25
26
  import { openSwapperModal } from '@swapper-finance/deposit-sdk';
26
27
  import { Separator as Separator$1 } from '@base-ui/react/separator';
27
28
  import { Select as Select$1 } from '@base-ui/react/select';
28
29
  import { Switch as Switch$1 } from '@base-ui/react/switch';
29
30
  import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
30
- import { Toast as Toast$1 } from '@base-ui/react/toast';
31
31
  import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
32
32
  import { Drawer as Drawer$1 } from '@base-ui/react/drawer';
33
33
 
@@ -4606,76 +4606,65 @@ function createFluentPermissionClient(config) {
4606
4606
  }
4607
4607
  };
4608
4608
  }
4609
+ function isFluentNativeToken(token) {
4610
+ return token.native === true;
4611
+ }
4612
+ function fluentTokenIdentity(token) {
4613
+ const target = isFluentNativeToken(token) ? "native" : token.address?.toLowerCase() ?? "unknown";
4614
+ return `${token.chainId}:${target}`;
4615
+ }
4609
4616
  var fluentTestnetTokenDefaults = {
4610
4617
  ETH: {
4611
4618
  chainId: 20994,
4612
4619
  symbol: "ETH",
4613
4620
  name: "Ether",
4614
- decimals: 18
4621
+ decimals: 18,
4622
+ native: true,
4623
+ gasPriority: 3
4615
4624
  },
4616
4625
  USDnr: {
4617
4626
  chainId: 20994,
4618
4627
  symbol: "USDnr",
4619
4628
  name: "USDnr",
4620
4629
  decimals: 18,
4621
- address: "0x092AE7564C6611a114C20C6df766B5B35A52334A"
4630
+ address: "0x092AE7564C6611a114C20C6df766B5B35A52334A",
4631
+ gasPriority: 2
4622
4632
  },
4623
4633
  BLEND: {
4624
4634
  chainId: 20994,
4625
4635
  symbol: "BLEND",
4626
4636
  name: "Mock Blend",
4627
4637
  decimals: 18,
4628
- address: "0x83Fed707A8dDDC2535aE591CF19fB6C91D542D8E"
4629
- },
4630
- USDC: {
4631
- chainId: 20994,
4632
- symbol: "USDC",
4633
- name: "USD Coin",
4634
- decimals: 6,
4635
- address: "0xC8Ebbf08Cb2A87aB90cC8EeC34C721764b7755e9"
4636
- },
4637
- USDT: {
4638
- chainId: 20994,
4639
- symbol: "USDT",
4640
- name: "USDT",
4641
- decimals: 6,
4642
- address: "0xD80Ca465c268e76F0d897D44a35fC97Db75AB797"
4638
+ address: "0x83Fed707A8dDDC2535aE591CF19fB6C91D542D8E",
4639
+ gasPriority: 1
4643
4640
  }
4644
4641
  };
4645
- var fluentTestnetWidgetTokens = [
4646
- fluentTestnetTokenDefaults.ETH,
4647
- fluentTestnetTokenDefaults.USDnr,
4648
- fluentTestnetTokenDefaults.BLEND,
4649
- fluentTestnetTokenDefaults.USDC,
4650
- fluentTestnetTokenDefaults.USDT
4651
- ];
4652
4642
  var fluentMainnetTokenDefaults = {
4653
4643
  ETH: {
4654
4644
  chainId: 25363,
4655
4645
  symbol: "ETH",
4656
4646
  name: "Ether",
4657
- decimals: 18
4647
+ decimals: 18,
4648
+ native: true,
4649
+ gasPriority: 3
4658
4650
  },
4659
4651
  USDnr: {
4660
4652
  chainId: 25363,
4661
4653
  symbol: "USDnr",
4662
4654
  name: "USDnr",
4663
4655
  decimals: 18,
4664
- address: "0xD48e565561416dE59DA1050ED70b8d75e8eF28f9"
4656
+ address: "0xD48e565561416dE59DA1050ED70b8d75e8eF28f9",
4657
+ gasPriority: 2
4665
4658
  },
4666
4659
  BLEND: {
4667
4660
  chainId: 25363,
4668
4661
  symbol: "BLEND",
4669
4662
  name: "Fluent",
4670
4663
  decimals: 18,
4671
- address: "0x1385b8f55a84f2bda13eed4099d29eae03d553b2"
4664
+ address: "0x1385b8f55a84f2bda13eed4099d29eae03d553b2",
4665
+ gasPriority: 1
4672
4666
  }
4673
4667
  };
4674
- var fluentMainnetWidgetTokens = [
4675
- fluentMainnetTokenDefaults.ETH,
4676
- fluentMainnetTokenDefaults.USDnr,
4677
- fluentMainnetTokenDefaults.BLEND
4678
- ];
4679
4668
  function getFluentTokenDefaultsForNetwork(network) {
4680
4669
  switch (network) {
4681
4670
  case "mainnet":
@@ -4684,9 +4673,31 @@ function getFluentTokenDefaultsForNetwork(network) {
4684
4673
  return fluentTestnetTokenDefaults;
4685
4674
  }
4686
4675
  }
4676
+ var fluentDefaultTokenIdentities = new Set(
4677
+ [
4678
+ ...Object.values(fluentTestnetTokenDefaults),
4679
+ ...Object.values(fluentMainnetTokenDefaults)
4680
+ ].map(fluentTokenIdentity)
4681
+ );
4682
+ function isFluentDefaultToken(token) {
4683
+ return fluentDefaultTokenIdentities.has(fluentTokenIdentity(token));
4684
+ }
4685
+ function sortFluentGasTokens(tokens) {
4686
+ return tokens.filter((token) => token.gasPriority !== void 0).sort((left, right) => left.gasPriority - right.gasPriority);
4687
+ }
4688
+ var displayTokensByNetwork = {
4689
+ testnet: Object.freeze(Object.values(fluentTestnetTokenDefaults)),
4690
+ mainnet: Object.freeze(Object.values(fluentMainnetTokenDefaults))
4691
+ };
4692
+ var gasTokensByNetwork = {
4693
+ testnet: Object.freeze(sortFluentGasTokens(displayTokensByNetwork.testnet)),
4694
+ mainnet: Object.freeze(sortFluentGasTokens(displayTokensByNetwork.mainnet))
4695
+ };
4696
+ function getFluentDefaultWidgetDisplayTokens(network) {
4697
+ return displayTokensByNetwork[network];
4698
+ }
4687
4699
  function getFluentDefaultWidgetGasTokens(network) {
4688
- const defaults = getFluentTokenDefaultsForNetwork(network);
4689
- return [defaults.USDnr, defaults.BLEND, defaults.ETH];
4700
+ return gasTokensByNetwork[network];
4690
4701
  }
4691
4702
  var balanceOfAbi = [
4692
4703
  {
@@ -4700,7 +4711,8 @@ var balanceOfAbi = [
4700
4711
  async function readFluentTokenBalances(params) {
4701
4712
  return Promise.all(
4702
4713
  params.tokens.map(async (token) => {
4703
- if (token.symbol !== "ETH" && !token.address) {
4714
+ const native = isFluentNativeToken(token);
4715
+ if (!native && !token.address) {
4704
4716
  return {
4705
4717
  ...token,
4706
4718
  raw: null,
@@ -4709,7 +4721,7 @@ async function readFluentTokenBalances(params) {
4709
4721
  };
4710
4722
  }
4711
4723
  try {
4712
- const raw = token.symbol === "ETH" ? await params.client.getBalance({ address: params.account }) : await params.client.readContract({
4724
+ const raw = native ? await params.client.getBalance({ address: params.account }) : await params.client.readContract({
4713
4725
  address: token.address,
4714
4726
  abi: balanceOfAbi,
4715
4727
  functionName: "balanceOf",
@@ -4733,6 +4745,111 @@ async function readFluentTokenBalances(params) {
4733
4745
  })
4734
4746
  );
4735
4747
  }
4748
+ var erc20MetadataAbi = [
4749
+ {
4750
+ type: "function",
4751
+ name: "name",
4752
+ stateMutability: "view",
4753
+ inputs: [],
4754
+ outputs: [{ name: "", type: "string" }]
4755
+ },
4756
+ {
4757
+ type: "function",
4758
+ name: "symbol",
4759
+ stateMutability: "view",
4760
+ inputs: [],
4761
+ outputs: [{ name: "", type: "string" }]
4762
+ },
4763
+ {
4764
+ type: "function",
4765
+ name: "decimals",
4766
+ stateMutability: "view",
4767
+ inputs: [],
4768
+ outputs: [{ name: "", type: "uint8" }]
4769
+ }
4770
+ ];
4771
+ var FLUENT_MAX_TOKEN_SYMBOL_LENGTH = 16;
4772
+ var FLUENT_MAX_TOKEN_NAME_LENGTH = 64;
4773
+ var FLUENT_MAX_TOKEN_DECIMALS = 36;
4774
+ function isFluentTokenDecimals(value) {
4775
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= FLUENT_MAX_TOKEN_DECIMALS;
4776
+ }
4777
+ async function readFluentTokenMetadata(params) {
4778
+ const trimmed = params.address.trim();
4779
+ if (!isAddress(trimmed)) return { status: "invalid-address" };
4780
+ const address = getAddress(trimmed);
4781
+ const read = (functionName) => params.client.readContract({
4782
+ address,
4783
+ abi: erc20MetadataAbi,
4784
+ functionName
4785
+ });
4786
+ let symbol;
4787
+ let decimals;
4788
+ let name;
4789
+ try {
4790
+ const [symbolResult, decimalsResult, nameResult] = await Promise.all([
4791
+ read("symbol"),
4792
+ read("decimals"),
4793
+ read("name").catch(() => void 0)
4794
+ ]);
4795
+ symbol = String(symbolResult).trim();
4796
+ decimals = Number(decimalsResult);
4797
+ name = nameResult === void 0 ? void 0 : String(nameResult).trim();
4798
+ } catch (error) {
4799
+ return {
4800
+ status: "unreadable",
4801
+ reason: error instanceof Error ? error.message : "Could not read the contract"
4802
+ };
4803
+ }
4804
+ if (!symbol) return { status: "unreadable", reason: "Contract reports no symbol" };
4805
+ if (!isFluentTokenDecimals(decimals)) {
4806
+ return { status: "unreadable", reason: "Contract reports invalid decimals" };
4807
+ }
4808
+ return {
4809
+ status: "ok",
4810
+ token: {
4811
+ chainId: params.chainId,
4812
+ address,
4813
+ symbol: symbol.slice(0, FLUENT_MAX_TOKEN_SYMBOL_LENGTH),
4814
+ name: (name || symbol).slice(0, FLUENT_MAX_TOKEN_NAME_LENGTH),
4815
+ decimals
4816
+ }
4817
+ };
4818
+ }
4819
+
4820
+ // ../connect-sdk/src/tokenSources.ts
4821
+ function withoutCapabilities(token) {
4822
+ const { gasPriority: _gasPriority, native: _native, ...rest } = token;
4823
+ return rest;
4824
+ }
4825
+ function mergeFluentDisplayTokens(params) {
4826
+ const merged = [];
4827
+ const seen = /* @__PURE__ */ new Set();
4828
+ const take = (tokens, source) => {
4829
+ const trusted = source === "default";
4830
+ for (const raw of tokens) {
4831
+ const token = trusted ? raw : withoutCapabilities(raw);
4832
+ const identity = fluentTokenIdentity(token);
4833
+ if (seen.has(identity)) continue;
4834
+ seen.add(identity);
4835
+ merged.push({ ...token, source, identity });
4836
+ }
4837
+ };
4838
+ take(params.defaults, "default");
4839
+ take(params.integrator ?? [], "integrator");
4840
+ take(params.user ?? [], "user");
4841
+ return merged;
4842
+ }
4843
+ function findFluentSymbolCollisions(tokens) {
4844
+ const countBySymbol = /* @__PURE__ */ new Map();
4845
+ for (const token of tokens) {
4846
+ const symbol = token.symbol.toLowerCase();
4847
+ countBySymbol.set(symbol, (countBySymbol.get(symbol) ?? 0) + 1);
4848
+ }
4849
+ return new Set(
4850
+ [...countBySymbol.entries()].filter(([, count]) => count > 1).map(([symbol]) => symbol)
4851
+ );
4852
+ }
4736
4853
 
4737
4854
  // ../connect-sdk/src/families.ts
4738
4855
  function withoutTrailingSlash2(value) {
@@ -4986,22 +5103,13 @@ function getFluentChainForNetwork(network) {
4986
5103
  function getFluentTokenDefaults(network) {
4987
5104
  return getFluentTokenDefaultsForNetwork(network);
4988
5105
  }
4989
- function getFluentDefaultGasTokens(network) {
4990
- return getFluentDefaultWidgetGasTokens(network);
4991
- }
4992
- function getFluentErc20PaymasterTokenAddresses(network) {
4993
- const defaults = getFluentTokenDefaults(network);
4994
- return {
4995
- BLEND: defaults.BLEND.address,
4996
- USDnr: defaults.USDnr.address
4997
- };
4998
- }
4999
5106
  function getFluentExplorerBaseUrl(network) {
5000
5107
  return getFluentChainForNetwork(network).blockExplorers?.default.url;
5001
5108
  }
5002
5109
 
5003
5110
  // src/core/storageKeys.ts
5004
5111
  var FLUENT_WIDGET_SESSION_STORAGE_KEY = "fluent:widget:session:v1";
5112
+ var FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY = "fluent:widget:tokens:v1";
5005
5113
 
5006
5114
  // src/core/config.ts
5007
5115
  var FLUENT_CONNECT_PRIVY_APP_ID = "cmi7li7v901yojv0dmtfuf0v4";
@@ -5012,11 +5120,14 @@ var FLUENT_CONNECT_TESTNET_PUBLIC_API_URL = "https://api.fluent-connect.dev.gble
5012
5120
  var FLUENT_CONNECT_MAINNET_PUBLIC_API_URL = "https://fluent-connect.api.fluent.xyz/api/v1";
5013
5121
  var FLUENT_CONNECT_TESTNET_ANALYTICS_HOST = "https://api.fluent-connect.dev.gblend.xyz/ingest";
5014
5122
  var FLUENT_CONNECT_MAINNET_ANALYTICS_HOST = "";
5123
+ var FLUENT_CONNECT_TESTNET_SPONSORSHIP_URL = "https://sponsorship.fluent-connect.dev.gblend.xyz";
5124
+ var FLUENT_CONNECT_MAINNET_SPONSORSHIP_URL = "";
5015
5125
  var FLUENT_CONNECT_TESTNET_REPUTATION_SIGNUP_URL = "https://connect-preview.vercel.app/signin";
5016
5126
  var FLUENT_CONNECT_MAINNET_REPUTATION_SIGNUP_URL = "https://connect.fluent.xyz/signin";
5017
5127
  var FLUENT_CONNECT_TESTNET_AUTHORIZE_URL = "https://connect-preview.vercel.app/authorize";
5018
5128
  var FLUENT_CONNECT_MAINNET_AUTHORIZE_URL = "https://connect.fluent.xyz/authorize";
5019
5129
  var FLUENT_CONNECT_TESTNET_FAUCET_ENDPOINT = "https://eco-faucet-api.fluent.xyz/fluent-connect/pre-fund";
5130
+ var FLUENT_CONNECT_DEFAULT_SILENT_SIGNING = true;
5020
5131
  var FLUENT_CONNECT_DEFAULT_PORTAL_BRIDGE_URL = "https://portal.fluent.xyz/user/bridge";
5021
5132
  var FLUENT_CONNECT_DEFAULT_SWAPPER_CONFIG = {
5022
5133
  enabled: true,
@@ -5031,7 +5142,8 @@ var FLUENT_CONNECT_NETWORK_ENDPOINTS = {
5031
5142
  reputationSignupUrl: FLUENT_CONNECT_TESTNET_REPUTATION_SIGNUP_URL,
5032
5143
  faucetEndpoint: FLUENT_CONNECT_TESTNET_FAUCET_ENDPOINT,
5033
5144
  bridgeUrl: FLUENT_CONNECT_DEFAULT_PORTAL_BRIDGE_URL,
5034
- analyticsHost: FLUENT_CONNECT_TESTNET_ANALYTICS_HOST
5145
+ analyticsHost: FLUENT_CONNECT_TESTNET_ANALYTICS_HOST,
5146
+ sponsorshipUrl: FLUENT_CONNECT_TESTNET_SPONSORSHIP_URL
5035
5147
  },
5036
5148
  mainnet: {
5037
5149
  authorizeUrl: FLUENT_CONNECT_MAINNET_AUTHORIZE_URL,
@@ -5040,7 +5152,8 @@ var FLUENT_CONNECT_NETWORK_ENDPOINTS = {
5040
5152
  // Mainnet has no faucet.
5041
5153
  faucetEndpoint: "",
5042
5154
  bridgeUrl: FLUENT_CONNECT_DEFAULT_PORTAL_BRIDGE_URL,
5043
- analyticsHost: FLUENT_CONNECT_MAINNET_ANALYTICS_HOST
5155
+ analyticsHost: FLUENT_CONNECT_MAINNET_ANALYTICS_HOST,
5156
+ sponsorshipUrl: FLUENT_CONNECT_MAINNET_SPONSORSHIP_URL
5044
5157
  }
5045
5158
  };
5046
5159
  function getFluentWidgetNetworkEndpoints(network) {
@@ -5150,10 +5263,36 @@ var FLUENT_FAMILY_TIER_PROGRESS = {
5150
5263
  D: 0
5151
5264
  };
5152
5265
  function resolveFluentWidgetConfig(config) {
5153
- const clientId = config.clientId.trim();
5154
- if (!clientId) {
5266
+ if (config.clientId !== void 0) {
5267
+ throw new Error(
5268
+ "FluentWidgetConfig.clientId was replaced in the PartnerId cutover. Pass partnerId (the partner_<32 hex> id from the Fluent console) and the Privy app client as privyClientId \u2014 both are required."
5269
+ );
5270
+ }
5271
+ const partnerId = (config.partnerId ?? "").trim();
5272
+ if (!partnerId) {
5273
+ throw new Error(
5274
+ "FluentWidgetConfig.partnerId is required. Pass the partner_<32 hex> id from the Fluent console."
5275
+ );
5276
+ }
5277
+ if (partnerId.startsWith("client-")) {
5278
+ throw new Error(
5279
+ `FluentWidgetConfig.partnerId "${partnerId}" is a Privy app client, not a partner id. Pass the partner_<32 hex> id as partnerId and the Privy client as privyClientId.`
5280
+ );
5281
+ }
5282
+ const privyClientId = (config.privyClientId ?? "").trim();
5283
+ if (!privyClientId) {
5284
+ throw new Error(
5285
+ "FluentWidgetConfig.privyClientId is required. Pass the Privy app client issued by Fluent for this partner."
5286
+ );
5287
+ }
5288
+ if (privyClientId.startsWith("partner_")) {
5289
+ throw new Error(
5290
+ `FluentWidgetConfig.privyClientId "${privyClientId}" is a partner id, not a Privy app client. Swap the two: partnerId takes the partner_<32 hex> id, privyClientId the client-\u2026 value.`
5291
+ );
5292
+ }
5293
+ if (!privyClientId.startsWith("client-")) {
5155
5294
  throw new Error(
5156
- "FluentWidgetConfig.clientId is required. Pass the Fluent Connect app clientId from the host application."
5295
+ `FluentWidgetConfig.privyClientId "${privyClientId}" does not look like a Privy app client \u2014 expected the client-\u2026 value issued by Fluent.`
5157
5296
  );
5158
5297
  }
5159
5298
  const network = config.network ?? resolveFluentWidgetNetworkFromEnv() ?? "testnet";
@@ -5161,12 +5300,15 @@ function resolveFluentWidgetConfig(config) {
5161
5300
  return {
5162
5301
  network,
5163
5302
  appName: config.appName ?? "Fluent Connect Demo",
5164
- clientId,
5303
+ partnerId,
5304
+ privyClientId,
5165
5305
  authMode: config.authMode ?? "hosted",
5166
5306
  authorizeUrl: endpoints.authorizeUrl,
5167
5307
  faucetEndpoint: endpoints.faucetEndpoint,
5168
5308
  eventsEndpoint: "",
5169
5309
  analyticsHost: endpoints.analyticsHost,
5310
+ sponsorshipUrl: config.sponsorshipUrl ?? endpoints.sponsorshipUrl,
5311
+ authTokenRenewalOffsetSeconds: config.authTokenRenewalOffsetSeconds ?? 30,
5170
5312
  disableAnalytics: config.disableAnalytics ?? false,
5171
5313
  publicApiUrl: endpoints.publicApiUrl,
5172
5314
  reputationSignupUrl: endpoints.reputationSignupUrl,
@@ -5194,7 +5336,7 @@ function createFluentConnectForWidget(config) {
5194
5336
  return fluent2.initialize({
5195
5337
  network: resolved.network,
5196
5338
  appName: resolved.appName,
5197
- clientId: resolved.clientId,
5339
+ clientId: resolved.privyClientId,
5198
5340
  authorizeUrl: resolved.authorizeUrl,
5199
5341
  scopes: resolved.scopes,
5200
5342
  source: resolved.source,
@@ -5238,6 +5380,246 @@ function useFluentWidget() {
5238
5380
  function useWidget() {
5239
5381
  return useFluentWidget().widget;
5240
5382
  }
5383
+ var FLUENT_USER_TOKEN_LIMIT = 50;
5384
+ function parsePayload(raw) {
5385
+ if (!raw) return [];
5386
+ let parsed;
5387
+ try {
5388
+ parsed = JSON.parse(raw);
5389
+ } catch {
5390
+ return [];
5391
+ }
5392
+ if (typeof parsed !== "object" || parsed === null) return [];
5393
+ const tokens = parsed.tokens;
5394
+ if (!Array.isArray(tokens)) return [];
5395
+ const valid = [];
5396
+ const seen = /* @__PURE__ */ new Set();
5397
+ for (const entry of tokens) {
5398
+ const token = validateStoredToken(entry);
5399
+ if (!token) continue;
5400
+ const key = fluentTokenIdentity(token);
5401
+ if (seen.has(key)) continue;
5402
+ seen.add(key);
5403
+ valid.push(token);
5404
+ }
5405
+ return valid;
5406
+ }
5407
+ function validateStoredToken(entry) {
5408
+ if (typeof entry !== "object" || entry === null) return null;
5409
+ const candidate = entry;
5410
+ const { chainId, address, symbol, name, decimals } = candidate;
5411
+ if (typeof chainId !== "number" || !Number.isInteger(chainId)) return null;
5412
+ if (typeof address !== "string" || !isAddress(address)) return null;
5413
+ if (typeof symbol !== "string" || symbol.length === 0) return null;
5414
+ if (typeof name !== "string" || name.length === 0) return null;
5415
+ if (!isFluentTokenDecimals(decimals)) return null;
5416
+ return {
5417
+ chainId,
5418
+ address: getAddress(address),
5419
+ symbol,
5420
+ name,
5421
+ decimals
5422
+ };
5423
+ }
5424
+ function resolveStorage(storage) {
5425
+ if (storage) return storage;
5426
+ try {
5427
+ return globalThis.localStorage ?? null;
5428
+ } catch {
5429
+ return null;
5430
+ }
5431
+ }
5432
+ function createFluentUserTokenStore(options) {
5433
+ const key = options?.key ?? FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY;
5434
+ const storage = resolveStorage(options?.storage);
5435
+ let memory = [];
5436
+ const readAll = () => {
5437
+ if (!storage) return memory;
5438
+ try {
5439
+ return parsePayload(storage.getItem(key));
5440
+ } catch {
5441
+ return memory;
5442
+ }
5443
+ };
5444
+ const writeAll = (tokens) => {
5445
+ memory = tokens;
5446
+ if (!storage) return;
5447
+ const payload = { version: 1, tokens };
5448
+ try {
5449
+ storage.setItem(key, JSON.stringify(payload));
5450
+ } catch {
5451
+ }
5452
+ };
5453
+ return {
5454
+ list(chainId) {
5455
+ return readAll().filter((token) => token.chainId === chainId);
5456
+ },
5457
+ add(token) {
5458
+ const all = readAll();
5459
+ const tokenKey = fluentTokenIdentity(token);
5460
+ if (all.some((existing) => fluentTokenIdentity(existing) === tokenKey)) {
5461
+ return { status: "already-present" };
5462
+ }
5463
+ const onChain = all.filter((existing) => existing.chainId === token.chainId);
5464
+ if (onChain.length >= FLUENT_USER_TOKEN_LIMIT) {
5465
+ return { status: "at-capacity", limit: FLUENT_USER_TOKEN_LIMIT };
5466
+ }
5467
+ const stored = validateStoredToken(token);
5468
+ if (!stored) return { status: "invalid" };
5469
+ writeAll([...all, stored]);
5470
+ return { status: "added" };
5471
+ },
5472
+ remove(token) {
5473
+ const tokenKey = fluentTokenIdentity(token);
5474
+ writeAll(readAll().filter((existing) => fluentTokenIdentity(existing) !== tokenKey));
5475
+ }
5476
+ };
5477
+ }
5478
+
5479
+ // src/hooks/useFluentUserTokens.ts
5480
+ function useFluentUserTokens(options) {
5481
+ const { chain } = useFluentWidgetNetwork();
5482
+ const injectedStore = options?.store;
5483
+ const store = useMemo(
5484
+ () => injectedStore ?? createFluentUserTokenStore(),
5485
+ [injectedStore]
5486
+ );
5487
+ const [revision, setRevision] = useState(0);
5488
+ const tokens = useMemo(
5489
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- `revision` is the invalidation signal
5490
+ () => store.list(chain.id),
5491
+ [store, chain.id, revision]
5492
+ );
5493
+ const add = useCallback(
5494
+ (token) => {
5495
+ const result = store.add(token);
5496
+ if (result.status === "added") setRevision((value) => value + 1);
5497
+ return result;
5498
+ },
5499
+ [store]
5500
+ );
5501
+ const remove = useCallback(
5502
+ (token) => {
5503
+ store.remove(token);
5504
+ setRevision((value) => value + 1);
5505
+ },
5506
+ [store]
5507
+ );
5508
+ return { tokens, add, remove };
5509
+ }
5510
+
5511
+ // src/utils/postJson.ts
5512
+ var HttpError = class extends Error {
5513
+ constructor(status, body) {
5514
+ super(body?.message ?? body?.error ?? `Request failed with ${status}`);
5515
+ this.status = status;
5516
+ this.body = body;
5517
+ this.name = "HttpError";
5518
+ }
5519
+ status;
5520
+ body;
5521
+ };
5522
+ async function postJson(url, body, headers = {}) {
5523
+ const response = await fetch(url, {
5524
+ method: "POST",
5525
+ headers: {
5526
+ "Content-Type": "application/json",
5527
+ ...headers
5528
+ },
5529
+ body: JSON.stringify(body)
5530
+ });
5531
+ if (!response.ok) {
5532
+ let errorBody;
5533
+ try {
5534
+ errorBody = await response.json();
5535
+ } catch {
5536
+ errorBody = void 0;
5537
+ }
5538
+ throw new HttpError(response.status, errorBody);
5539
+ }
5540
+ return response.json();
5541
+ }
5542
+
5543
+ // src/core/authToken.ts
5544
+ var FluentAuthError = class extends Error {
5545
+ constructor(code, message, status) {
5546
+ super(message);
5547
+ this.code = code;
5548
+ this.status = status;
5549
+ this.name = "FluentAuthError";
5550
+ }
5551
+ code;
5552
+ status;
5553
+ };
5554
+ var RETRY_ONCE = /* @__PURE__ */ new Set([
5555
+ "signature_prefix_rejected",
5556
+ "nonce_expired",
5557
+ "nonce_used"
5558
+ ]);
5559
+ function toAuthError(err) {
5560
+ if (err instanceof FluentAuthError) return err;
5561
+ if (err instanceof HttpError) {
5562
+ const code = err.body?.code ?? "request_failed";
5563
+ return new FluentAuthError(code, err.message, err.status);
5564
+ }
5565
+ return new FluentAuthError("request_failed", err instanceof Error ? err.message : String(err));
5566
+ }
5567
+ async function exchangePrivyAuthToken(params) {
5568
+ try {
5569
+ const { token } = await postJson(`${params.publicApiUrl}/auth/exchange/privy`, {
5570
+ partnerId: params.partnerId,
5571
+ accessToken: params.accessToken,
5572
+ identityToken: params.identityToken
5573
+ });
5574
+ return token;
5575
+ } catch (err) {
5576
+ throw toAuthError(err);
5577
+ }
5578
+ }
5579
+ async function exchangeWalletAuthToken(params) {
5580
+ const attempt = async () => {
5581
+ const challenge = await postJson(`${params.publicApiUrl}/auth/challenge`, {
5582
+ partnerId: params.partnerId,
5583
+ address: params.address
5584
+ });
5585
+ if (challenge.typedData.message.origin !== params.origin) {
5586
+ throw new FluentAuthError(
5587
+ "origin_mismatch",
5588
+ `Challenge origin ${challenge.typedData.message.origin} does not match ${params.origin}`
5589
+ );
5590
+ }
5591
+ const signature = await params.walletClient.signTypedData({
5592
+ account: params.address,
5593
+ ...challenge.typedData
5594
+ });
5595
+ const { token } = await postJson(`${params.publicApiUrl}/auth/exchange/wallet`, {
5596
+ partnerId: params.partnerId,
5597
+ nonce: challenge.nonce,
5598
+ signature
5599
+ });
5600
+ return token;
5601
+ };
5602
+ try {
5603
+ return await attempt();
5604
+ } catch (first) {
5605
+ const err = toAuthError(first);
5606
+ if (!RETRY_ONCE.has(err.code)) throw err;
5607
+ try {
5608
+ return await attempt();
5609
+ } catch (second) {
5610
+ throw toAuthError(second);
5611
+ }
5612
+ }
5613
+ }
5614
+ function readAuthTokenExpiry(token) {
5615
+ try {
5616
+ const [, body = ""] = token.split(".");
5617
+ const payload = JSON.parse(atob(body.replace(/-/g, "+").replace(/_/g, "/")));
5618
+ return typeof payload.exp === "number" ? payload.exp * 1e3 : void 0;
5619
+ } catch {
5620
+ return void 0;
5621
+ }
5622
+ }
5241
5623
  function createFluentBatchOp(input, executor) {
5242
5624
  if (input.calls.length === 0) {
5243
5625
  throw new Error("A Fluent batch operation requires at least one call");
@@ -5312,11 +5694,13 @@ function encodeBatchCall(call) {
5312
5694
  })
5313
5695
  };
5314
5696
  }
5315
- var FLUENT_GAS_PAYMENT_PRIORITY = ["USDnr", "BLEND", "ETH"];
5316
5697
  function getFluentGasTokenAddress(symbol, network) {
5317
- if (symbol === "ETH") return void 0;
5318
- const addresses = getFluentErc20PaymasterTokenAddresses(network);
5319
- return symbol === "BLEND" ? addresses.BLEND : addresses.USDnr;
5698
+ const wanted = symbol.toUpperCase();
5699
+ const token = getFluentDefaultWidgetGasTokens(network).find(
5700
+ (candidate) => candidate.symbol.toUpperCase() === wanted
5701
+ );
5702
+ if (!token || isFluentNativeToken(token)) return void 0;
5703
+ return token.address;
5320
5704
  }
5321
5705
  var FLUENT_GAS_PAYMENT_DEFAULT_ETH_RATES = {
5322
5706
  ETH: "1"
@@ -5329,12 +5713,11 @@ function selectFluentGasPaymentToken(params) {
5329
5713
  balance: null
5330
5714
  };
5331
5715
  }
5332
- for (const symbol of FLUENT_GAS_PAYMENT_PRIORITY) {
5333
- const balance = params.balances.find((item) => item.symbol === symbol);
5334
- if (balance?.status === "ready" && balance.raw !== null && balance.raw > 0n) {
5716
+ for (const balance of getFluentGasPaymentTokens(params.balances)) {
5717
+ if (balance.status === "ready" && balance.raw !== null && balance.raw > 0n) {
5335
5718
  return {
5336
5719
  status: "ready",
5337
- symbol,
5720
+ symbol: balance.symbol,
5338
5721
  balance
5339
5722
  };
5340
5723
  }
@@ -5346,7 +5729,7 @@ function selectFluentGasPaymentToken(params) {
5346
5729
  };
5347
5730
  }
5348
5731
  function getFluentGasPaymentTokens(tokens) {
5349
- return FLUENT_GAS_PAYMENT_PRIORITY.map((symbol) => tokens.find((token) => token.symbol === symbol)).filter((token) => Boolean(token));
5732
+ return sortFluentGasTokens(tokens.filter(isFluentDefaultToken));
5350
5733
  }
5351
5734
  function getFluentGasPaymentEthValue(params) {
5352
5735
  const balance = params.balance;
@@ -5383,39 +5766,6 @@ function getFluentGasPaymentValueTier(ethValueWei) {
5383
5766
  if (ethValueWei > 0n) return "neutral";
5384
5767
  return "neutral";
5385
5768
  }
5386
- var GAS_BALANCE_MAX_FRACTION_DIGITS = 6;
5387
- function roundToFractionDigits(raw, decimals, digits) {
5388
- const discardedScale = 10n ** BigInt(decimals - digits);
5389
- return (raw + discardedScale / 2n) / discardedScale;
5390
- }
5391
- function formatFluentGasTokenBalance(balance, maximumFractionDigits = 1) {
5392
- if (balance.raw === null || balance.formatted === null) return null;
5393
- if (maximumFractionDigits < 0 || !Number.isInteger(maximumFractionDigits)) {
5394
- throw new Error("maximumFractionDigits must be a non-negative integer");
5395
- }
5396
- if (balance.decimals <= maximumFractionDigits) {
5397
- return formatFluentLocaleAmount(balance.formatted, maximumFractionDigits);
5398
- }
5399
- const maxDigits = Math.max(
5400
- maximumFractionDigits,
5401
- Math.min(balance.decimals, GAS_BALANCE_MAX_FRACTION_DIGITS)
5402
- );
5403
- for (let digits = maximumFractionDigits; digits <= maxDigits; digits += 1) {
5404
- const rounded = roundToFractionDigits(balance.raw, balance.decimals, digits);
5405
- if (rounded > 0n || balance.raw === 0n) {
5406
- return formatFluentLocaleAmount(formatUnits(rounded, digits), digits);
5407
- }
5408
- }
5409
- return formatFluentLocaleAmount(0, maximumFractionDigits);
5410
- }
5411
- function formatFluentLocaleAmount(value, maximumFractionDigits = 2) {
5412
- const amount = typeof value === "number" ? value : Number(value);
5413
- if (!Number.isFinite(amount)) return typeof value === "string" ? value : String(value);
5414
- return amount.toLocaleString("de-DE", {
5415
- minimumFractionDigits: 0,
5416
- maximumFractionDigits
5417
- });
5418
- }
5419
5769
  function formatEthValue(ethValueWei) {
5420
5770
  if (ethValueWei === 0n) return "0 ETH";
5421
5771
  const formatted = formatUnits(ethValueWei, 18);
@@ -5563,22 +5913,26 @@ async function withTimeout(promise, timeoutMs, message) {
5563
5913
  if (timer) clearTimeout(timer);
5564
5914
  }
5565
5915
  }
5916
+ function getSponsorshipFailure(err) {
5917
+ const httpError = err instanceof BaseError ? err.walk((e) => e instanceof HttpRequestError) : null;
5918
+ if (!httpError) return { reason: "denied", disableSponsorship: false };
5919
+ if (httpError.status === 403) return { reason: "unauthorized", disableSponsorship: true };
5920
+ if (httpError.status === 401) return { reason: "unauthorized", disableSponsorship: false };
5921
+ return { reason: "unreachable", disableSponsorship: false };
5922
+ }
5566
5923
  var FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY = "selfFunded=true";
5567
5924
  var FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT = "0x000000000000000000000000000000000000dEaD";
5568
5925
  function getFluentZeroDevErc20PaymasterTokens(network = "testnet") {
5569
- const addresses = getFluentErc20PaymasterTokenAddresses(network);
5570
- return {
5571
- BLEND: {
5572
- address: addresses.BLEND,
5573
- decimals: 18,
5574
- symbol: "BLEND"
5575
- },
5576
- USDNR: {
5577
- address: addresses.USDnr,
5578
- decimals: 18,
5579
- symbol: "USDnr"
5580
- }
5581
- };
5926
+ return Object.fromEntries(
5927
+ getFluentDefaultWidgetGasTokens(network).filter((token) => !isFluentNativeToken(token) && token.address).map((token) => [
5928
+ token.symbol.toUpperCase(),
5929
+ {
5930
+ address: token.address,
5931
+ decimals: token.decimals,
5932
+ symbol: token.symbol
5933
+ }
5934
+ ])
5935
+ );
5582
5936
  }
5583
5937
  function createFluentZeroDevRpcUrl(params = {}) {
5584
5938
  const chainId = params.chainId ?? fluentTestnet.id;
@@ -5589,10 +5943,34 @@ function createFluentZeroDevRpcUrl(params = {}) {
5589
5943
  function createFluentZeroDevErc20PaymasterRpcUrl(params = {}) {
5590
5944
  return createFluentZeroDevRpcUrl({ ...params, selfFunded: true });
5591
5945
  }
5946
+ function createFluentSponsorshipRpcUrl(params) {
5947
+ const base = params.sponsorshipUrl.replace(/\/+$/, "");
5948
+ return `${base}/paymaster/${encodeURIComponent(params.partnerId)}`;
5949
+ }
5950
+ function createFluentZeroDevSponsoredPaymaster(params) {
5951
+ const paymasterClient = createZeroDevPaymasterClient({
5952
+ chain: params.chain,
5953
+ transport: http(params.rpcUrl, {
5954
+ fetchOptions: { headers: { Authorization: `Bearer ${params.accessToken}` } }
5955
+ })
5956
+ });
5957
+ return {
5958
+ getPaymasterData: (userOperation) => paymasterClient.sponsorUserOperation({
5959
+ userOperation: withoutChainMetadata(userOperation)
5960
+ })
5961
+ };
5962
+ }
5592
5963
  function resolveFluentZeroDevErc20PaymasterToken(token = "BLEND", network = "testnet") {
5593
5964
  if (typeof token === "object") return token;
5594
5965
  if (token.startsWith("0x")) return { address: token };
5595
- return getFluentZeroDevErc20PaymasterTokens(network)[token];
5966
+ const tokens = getFluentZeroDevErc20PaymasterTokens(network);
5967
+ const resolved = tokens[token.toUpperCase()];
5968
+ if (!resolved) {
5969
+ throw new Error(
5970
+ `"${token}" cannot pay gas on ${network}. Paymaster tokens: ${Object.keys(tokens).join(", ") || "none"}`
5971
+ );
5972
+ }
5973
+ return resolved;
5596
5974
  }
5597
5975
  function createFluentZeroDevErc20PaymasterClient(params = {}) {
5598
5976
  const chain = params.chain ?? fluentTestnet;
@@ -5747,7 +6125,7 @@ function createFluentBundlerTransport(url) {
5747
6125
  // src/widget/zerodevSession.ts
5748
6126
  function useFluentZeroDevAccount(hookOptions = {}) {
5749
6127
  const { chain, network } = useFluentWidgetNetwork();
5750
- const { authenticated, login: privyLogin, ready } = usePrivy();
6128
+ const { authenticated, getAccessToken, login: privyLogin, ready } = usePrivy();
5751
6129
  const login = hookOptions.login ?? privyLogin;
5752
6130
  const { signMessage: promptSignMessage } = useSignMessage();
5753
6131
  const { signTypedData: promptSignTypedData } = useSignTypedData();
@@ -5756,6 +6134,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
5756
6134
  const [error, setError] = useState(null);
5757
6135
  const [smartAccountReady, setSmartAccountReady] = useState(false);
5758
6136
  const initPromise = useRef({});
6137
+ const sponsorshipUnavailable = useRef(false);
5759
6138
  const embeddedWallet = wallets.find((wallet) => wallet.walletClientType === "privy");
5760
6139
  const hostedSigner = useMemo(
5761
6140
  () => hookOptions.allowHostedSigner !== false && hookOptions.authorizeUrl && hookOptions.sessionSignerAddress ? createFluentHostedSigner({
@@ -5928,6 +6307,26 @@ function useFluentZeroDevAccount(hookOptions = {}) {
5928
6307
  },
5929
6308
  [authenticated, embeddedWallet, error, hostedSigner, initialize2, kernels.prompt, ready]
5930
6309
  );
6310
+ const createSponsoredClient = useCallback(async (kernel) => {
6311
+ if (!hookOptions.sponsorshipUrl || !hookOptions.partnerId) return null;
6312
+ if (sponsorshipUnavailable.current) return null;
6313
+ const accessToken = await getAccessToken();
6314
+ if (!accessToken) return null;
6315
+ return createKernelAccountClient({
6316
+ account: kernel.account,
6317
+ chain: kernel.chain,
6318
+ bundlerTransport: createFluentBundlerTransport(kernel.zeroDevRpcUrl),
6319
+ client: kernel.publicClient,
6320
+ paymaster: createFluentZeroDevSponsoredPaymaster({
6321
+ chain: kernel.chain,
6322
+ accessToken,
6323
+ rpcUrl: createFluentSponsorshipRpcUrl({
6324
+ sponsorshipUrl: hookOptions.sponsorshipUrl,
6325
+ partnerId: hookOptions.partnerId
6326
+ })
6327
+ })
6328
+ });
6329
+ }, [getAccessToken, hookOptions.partnerId, hookOptions.sponsorshipUrl]);
5931
6330
  const sendCalls = useCallback(
5932
6331
  async (calls, options) => {
5933
6332
  const signerMode = confirmationToSignerMode(options?.confirmation ?? "always");
@@ -5952,6 +6351,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
5952
6351
  smartAccountAddress: executionKernel.smartAccountAddress,
5953
6352
  gasToken,
5954
6353
  gasTokenSymbol: options?.gasPayment?.symbol,
6354
+ sponsorship: options?.gasPayment?.sponsorship ?? "auto",
5955
6355
  approvalIncluded: Boolean(gasToken && options?.gasPayment?.includeApproval),
5956
6356
  calls: preparedCalls.map((call) => ({
5957
6357
  to: call.to,
@@ -5963,29 +6363,63 @@ function useFluentZeroDevAccount(hookOptions = {}) {
5963
6363
  gasTokenSymbol: options?.gasPayment?.symbol
5964
6364
  });
5965
6365
  try {
5966
- const executionClient = gasToken ? createFluentZeroDevErc20ExecutionClient(executionKernel, gasToken) : executionKernel.client;
5967
- const userOpHash = await executionClient.sendUserOperation({
6366
+ const callArgs = {
5968
6367
  account: executionKernel.account,
5969
6368
  calls: preparedCalls.map((call) => ({
5970
6369
  to: call.to,
5971
6370
  data: call.data ?? "0x",
5972
6371
  value: call.value ?? 0n
5973
6372
  }))
5974
- });
6373
+ };
6374
+ const sponsorshipRefused = !gasToken && options?.gasPayment?.sponsorship === "never";
6375
+ const sponsoredClient = gasToken || sponsorshipRefused ? null : await createSponsoredClient(executionKernel);
6376
+ const executionClient = gasToken ? createFluentZeroDevErc20ExecutionClient(executionKernel, gasToken) : sponsoredClient ?? executionKernel.client;
6377
+ let sponsorshipReason;
6378
+ if (sponsorshipRefused) {
6379
+ sponsorshipReason = "not_requested";
6380
+ } else if (!gasToken && !sponsoredClient && hookOptions.sponsorshipUrl && hookOptions.partnerId) {
6381
+ sponsorshipReason = sponsorshipUnavailable.current ? "unauthorized" : "no_token";
6382
+ }
6383
+ let settlementClient = executionClient;
6384
+ let userOpHash;
6385
+ try {
6386
+ userOpHash = await executionClient.sendUserOperation(callArgs);
6387
+ } catch (err) {
6388
+ if (!sponsoredClient) throw err;
6389
+ const failure = getSponsorshipFailure(err);
6390
+ sponsorshipReason = failure.reason;
6391
+ if (failure.disableSponsorship) sponsorshipUnavailable.current = true;
6392
+ debugWarn("[fluent zerodev] sponsorship unavailable, paying own gas", {
6393
+ reason: sponsorshipReason
6394
+ });
6395
+ settlementClient = executionKernel.client;
6396
+ userOpHash = await executionKernel.client.sendUserOperation(callArgs);
6397
+ }
5975
6398
  debugLog("[fluent zerodev] sendCalls userOp submitted", { userOpHash });
5976
- const receipt = await executionClient.waitForUserOperationReceipt({
6399
+ const receipt = await settlementClient.waitForUserOperationReceipt({
5977
6400
  hash: userOpHash
5978
6401
  });
6402
+ const paymaster = readUserOperationPaymaster(receipt);
6403
+ const sponsored = gasToken ? false : paymaster ? paymaster !== zeroAddress : Boolean(sponsoredClient);
6404
+ if (!gasToken && sponsoredClient && !sponsored) sponsorshipReason ??= "denied";
5979
6405
  debugLog("[fluent zerodev] sendCalls receipt", {
5980
6406
  userOpHash,
5981
6407
  success: receipt.success,
5982
6408
  reason: receipt.reason,
5983
- transactionHash: receipt.receipt.transactionHash
6409
+ transactionHash: receipt.receipt.transactionHash,
6410
+ sponsored,
6411
+ paymaster,
6412
+ sponsorshipReason
5984
6413
  });
5985
6414
  if (!receipt.success) {
5986
6415
  throw new Error(receipt.reason ?? `UserOperation ${userOpHash} execution failed`);
5987
6416
  }
5988
- return receipt.receipt.transactionHash;
6417
+ return {
6418
+ hash: receipt.receipt.transactionHash,
6419
+ sponsored,
6420
+ sponsorshipReason,
6421
+ paymaster
6422
+ };
5989
6423
  } catch (err) {
5990
6424
  debugError("[fluent zerodev] sendCalls failed", err);
5991
6425
  throw err;
@@ -5995,10 +6429,13 @@ function useFluentZeroDevAccount(hookOptions = {}) {
5995
6429
  },
5996
6430
  [
5997
6431
  authenticated,
6432
+ createSponsoredClient,
5998
6433
  embeddedWallet,
5999
6434
  error,
6000
6435
  hostedSigner,
6001
6436
  hookOptions.authorizationSession,
6437
+ hookOptions.partnerId,
6438
+ hookOptions.sponsorshipUrl,
6002
6439
  initialize2,
6003
6440
  kernels,
6004
6441
  network,
@@ -6035,6 +6472,20 @@ function useFluentZeroDevAccount(hookOptions = {}) {
6035
6472
  refresh: () => initialize2({ throwOnError: true, signerMode: "prompt" })
6036
6473
  };
6037
6474
  }
6475
+ var USER_OPERATION_EVENT_TOPIC = toEventSelector(
6476
+ parseAbiItem(
6477
+ "event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed)"
6478
+ )
6479
+ ).toLowerCase();
6480
+ function readUserOperationPaymaster(receipt) {
6481
+ if (receipt.paymaster) return getAddress(receipt.paymaster);
6482
+ const event = receipt.logs.find(
6483
+ (log) => log.topics[0]?.toLowerCase() === USER_OPERATION_EVENT_TOPIC && log.topics[1]?.toLowerCase() === receipt.userOpHash.toLowerCase()
6484
+ );
6485
+ const topic = event?.topics[3];
6486
+ if (!topic || topic.length !== 66) return void 0;
6487
+ return getAddress(`0x${topic.slice(26)}`);
6488
+ }
6038
6489
  function getZeroDevReadinessMessage(params) {
6039
6490
  if (!params.ready) return "Privy wallet context is still loading";
6040
6491
  if (params.hostedSignerAvailable) return "Fluent hosted signer is preparing";
@@ -6494,7 +6945,7 @@ function toUnixSeconds(value) {
6494
6945
  }
6495
6946
 
6496
6947
  // package.json
6497
- var version = "0.1.5";
6948
+ var version = "0.2.1";
6498
6949
 
6499
6950
  // src/core/analytics.ts
6500
6951
  var INSTANCE_NAME = "fluent";
@@ -6576,7 +7027,7 @@ function createTracker(config, getContext) {
6576
7027
  const enabled = analyticsEnabled(config);
6577
7028
  if (enabled) initFluentAnalytics(config);
6578
7029
  const base = {
6579
- client_id: config.clientId,
7030
+ partner_id: config.partnerId,
6580
7031
  network: config.network,
6581
7032
  auth_mode: config.authMode,
6582
7033
  source: config.source,
@@ -6597,14 +7048,504 @@ function trackWidgetLoadedOnce(track, properties) {
6597
7048
  if (track.live) widgetLoadedTracked = true;
6598
7049
  }
6599
7050
 
6600
- // src/utils/hasStoredWidgetSession.ts
6601
- function hasStoredWidgetSession(storage = globalThis.window?.localStorage) {
6602
- if (!storage) return false;
7051
+ // src/utils/buildFluentBridgeUrl.ts
7052
+ function buildFluentBridgeUrl(bridgeUrl, recipient) {
7053
+ if (!recipient) return bridgeUrl;
6603
7054
  try {
6604
- return Boolean(storage.getItem(FLUENT_WIDGET_SESSION_STORAGE_KEY));
7055
+ const url = new URL(bridgeUrl);
7056
+ url.searchParams.set("recipient", recipient);
7057
+ return url.toString();
6605
7058
  } catch {
6606
- return false;
6607
- }
7059
+ const join = bridgeUrl.includes("?") ? "&" : "?";
7060
+ return `${bridgeUrl}${join}recipient=${encodeURIComponent(recipient)}`;
7061
+ }
7062
+ }
7063
+
7064
+ // src/utils/clearPrivyRecentLoginMethod.ts
7065
+ function clearPrivyRecentLoginMethod(appId) {
7066
+ if (typeof window === "undefined" || !appId) return;
7067
+ try {
7068
+ window.localStorage.removeItem(`privy:${appId}:recent-login-method`);
7069
+ window.localStorage.removeItem(`privy:${appId}:recent-login-wallet-client`);
7070
+ window.localStorage.removeItem(`privy:${appId}:recent-login-chain-type`);
7071
+ } catch {
7072
+ }
7073
+ }
7074
+ function cn(...inputs) {
7075
+ return twMerge(clsx(inputs));
7076
+ }
7077
+ var WIDGET_STYLE_SCOPE = "fluent-root dark contents text-foreground";
7078
+ var FluentPortalContainerContext = createContext(null);
7079
+ function FluentPortalContainerProvider({ children }) {
7080
+ const [container, setContainer] = useState(null);
7081
+ useLayoutEffect(() => {
7082
+ const element = document.createElement("div");
7083
+ element.setAttribute("data-fluent-portal-root", "");
7084
+ element.className = WIDGET_STYLE_SCOPE;
7085
+ document.body.appendChild(element);
7086
+ setContainer(element);
7087
+ return () => {
7088
+ element.remove();
7089
+ setContainer(null);
7090
+ };
7091
+ }, []);
7092
+ return /* @__PURE__ */ jsx(FluentPortalContainerContext.Provider, { value: container, children });
7093
+ }
7094
+ function useFluentPortalContainer(override) {
7095
+ const container = useContext(FluentPortalContainerContext);
7096
+ return override ?? container ?? void 0;
7097
+ }
7098
+ var buttonVariants = cva(
7099
+ "group/button inline-flex shrink-0 items-center justify-center rounded-xl border border-transparent bg-clip-padding font-medium whitespace-nowrap transition-all duration-75 outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
7100
+ {
7101
+ variants: {
7102
+ variant: {
7103
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
7104
+ outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
7105
+ secondary: "bg-button text-button-foreground hover:bg-button-hover aria-expanded:bg-button aria-expanded:text-button-foreground",
7106
+ ghost: "hover:bg-primary/10 hover:text-foreground dark:hover:bg-primary/10",
7107
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
7108
+ link: "text-primary underline-offset-4 hover:underline"
7109
+ },
7110
+ size: {
7111
+ default: "h-10 gap-1.5 px-3.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 text-sm",
7112
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
7113
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
7114
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
7115
+ icon: "size-8",
7116
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
7117
+ "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
7118
+ "icon-lg": "size-9"
7119
+ }
7120
+ },
7121
+ defaultVariants: {
7122
+ variant: "default",
7123
+ size: "default"
7124
+ }
7125
+ }
7126
+ );
7127
+ var Button = forwardRef(function Button2({ className, variant = "default", size = "default", href, target, rel, render, ...props }, ref) {
7128
+ const isLink = href !== void 0;
7129
+ return /* @__PURE__ */ jsx(
7130
+ Button$1,
7131
+ {
7132
+ ref,
7133
+ "data-slot": "button",
7134
+ nativeButton: isLink ? false : void 0,
7135
+ className: cn(buttonVariants({ variant, size, className })),
7136
+ render: isLink ? /* @__PURE__ */ jsx("a", { href, target, rel }) : render,
7137
+ ...props
7138
+ }
7139
+ );
7140
+ });
7141
+ var toast = Toast$1.createToastManager();
7142
+ function ToastProvider({ ...props }) {
7143
+ return /* @__PURE__ */ jsx(Toast$1.Provider, { ...props });
7144
+ }
7145
+ function ToastPortal({ container, ...props }) {
7146
+ return /* @__PURE__ */ jsx(
7147
+ Toast$1.Portal,
7148
+ {
7149
+ "data-slot": "toast-portal",
7150
+ container: useFluentPortalContainer(container),
7151
+ ...props
7152
+ }
7153
+ );
7154
+ }
7155
+ function ToastViewport({ className, ...props }) {
7156
+ return /* @__PURE__ */ jsx(
7157
+ Toast$1.Viewport,
7158
+ {
7159
+ "data-slot": "toast-viewport",
7160
+ className: cn(
7161
+ "dark pointer-events-none fixed inset-x-4 bottom-4 z-[100] mx-auto w-[min(100%,368px)] max-w-[368px] text-foreground outline-none sm:right-4 sm:left-auto sm:mx-0",
7162
+ className
7163
+ ),
7164
+ ...props
7165
+ }
7166
+ );
7167
+ }
7168
+ function Toast({ className, style, ...props }) {
7169
+ return /* @__PURE__ */ jsx(
7170
+ Toast$1.Root,
7171
+ {
7172
+ "data-slot": "toast",
7173
+ style: { maxWidth: 368, ...style },
7174
+ className: cn(
7175
+ "group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full max-w-[368px] origin-bottom rounded-2xl border border-white/20 bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-border focus-visible:ring-[3px] focus-visible:ring-ring/50",
7176
+ "[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]",
7177
+ "h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]",
7178
+ "after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
7179
+ "data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
7180
+ "data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]",
7181
+ "[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
7182
+ "data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
7183
+ "data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
7184
+ "data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
7185
+ "data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
7186
+ "data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
7187
+ "data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
7188
+ "data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
7189
+ "data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
7190
+ className
7191
+ ),
7192
+ ...props
7193
+ }
7194
+ );
7195
+ }
7196
+ function ToastContent({ className, ...props }) {
7197
+ return /* @__PURE__ */ jsx(
7198
+ Toast$1.Content,
7199
+ {
7200
+ "data-slot": "toast-content",
7201
+ className: cn(
7202
+ "flex h-full items-start gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100",
7203
+ className
7204
+ ),
7205
+ ...props
7206
+ }
7207
+ );
7208
+ }
7209
+ function ToastTitle({ className, ...props }) {
7210
+ return /* @__PURE__ */ jsx(
7211
+ Toast$1.Title,
7212
+ {
7213
+ "data-slot": "toast-title",
7214
+ className: cn("text-sm font-medium", className),
7215
+ ...props
7216
+ }
7217
+ );
7218
+ }
7219
+ function ToastDescription({
7220
+ className,
7221
+ ...props
7222
+ }) {
7223
+ return /* @__PURE__ */ jsx(
7224
+ Toast$1.Description,
7225
+ {
7226
+ "data-slot": "toast-description",
7227
+ className: cn("text-sm text-muted-foreground", className),
7228
+ ...props
7229
+ }
7230
+ );
7231
+ }
7232
+ function ToastAction({
7233
+ className,
7234
+ render = /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm" }),
7235
+ ...props
7236
+ }) {
7237
+ return /* @__PURE__ */ jsx(
7238
+ Toast$1.Action,
7239
+ {
7240
+ "data-slot": "toast-action",
7241
+ render,
7242
+ className: cn("shrink-0", className),
7243
+ ...props
7244
+ }
7245
+ );
7246
+ }
7247
+ function ToastClose({
7248
+ className,
7249
+ children,
7250
+ render = /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon-sm" }),
7251
+ ...props
7252
+ }) {
7253
+ return /* @__PURE__ */ jsx(
7254
+ Toast$1.Close,
7255
+ {
7256
+ "data-slot": "toast-close",
7257
+ "aria-label": "Close toast",
7258
+ render,
7259
+ className: cn(
7260
+ "relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground",
7261
+ className
7262
+ ),
7263
+ ...props,
7264
+ children: children ?? /* @__PURE__ */ jsx(XIcon, { "aria-hidden": "true" })
7265
+ }
7266
+ );
7267
+ }
7268
+ function ToastIcon({ type }) {
7269
+ let icon = null;
7270
+ if (type === "success") {
7271
+ icon = /* @__PURE__ */ jsx(CircleCheckIcon, { "aria-hidden": "true" });
7272
+ }
7273
+ if (type === "info") {
7274
+ icon = /* @__PURE__ */ jsx(InfoIcon, { "aria-hidden": "true" });
7275
+ }
7276
+ if (type === "warning") {
7277
+ icon = /* @__PURE__ */ jsx(TriangleAlertIcon, { "aria-hidden": "true" });
7278
+ }
7279
+ if (type === "error") {
7280
+ icon = /* @__PURE__ */ jsx(OctagonXIcon, { className: "text-destructive", "aria-hidden": "true" });
7281
+ }
7282
+ if (type === "loading") {
7283
+ icon = /* @__PURE__ */ jsx(Loader2Icon, { className: "animate-spin", "aria-hidden": "true" });
7284
+ }
7285
+ if (!icon) {
7286
+ return null;
7287
+ }
7288
+ return /* @__PURE__ */ jsx(
7289
+ "span",
7290
+ {
7291
+ "data-slot": "toast-icon",
7292
+ className: "shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
7293
+ children: icon
7294
+ }
7295
+ );
7296
+ }
7297
+ function ToastList() {
7298
+ const { toasts } = Toast$1.useToastManager();
7299
+ return toasts.map((toastItem) => /* @__PURE__ */ jsx(Toast, { toast: toastItem, children: /* @__PURE__ */ jsxs(ToastContent, { children: [
7300
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
7301
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
7302
+ /* @__PURE__ */ jsx(ToastIcon, { type: toastItem.type }),
7303
+ /* @__PURE__ */ jsx(ToastTitle, {})
7304
+ ] }),
7305
+ /* @__PURE__ */ jsx(ToastDescription, {})
7306
+ ] }),
7307
+ /* @__PURE__ */ jsx(ToastAction, {}),
7308
+ /* @__PURE__ */ jsx(ToastClose, {})
7309
+ ] }) }, toastItem.id));
7310
+ }
7311
+ function Toaster({
7312
+ children,
7313
+ toastManager = toast,
7314
+ ...props
7315
+ }) {
7316
+ return /* @__PURE__ */ jsxs(ToastProvider, { toastManager, ...props, children: [
7317
+ children,
7318
+ /* @__PURE__ */ jsx(ToastPortal, { children: /* @__PURE__ */ jsx(ToastViewport, { children: /* @__PURE__ */ jsx(ToastList, {}) }) })
7319
+ ] });
7320
+ }
7321
+ Toast$1.createToastManager;
7322
+ Toast$1.useToastManager;
7323
+
7324
+ // src/utils/formatAddress.ts
7325
+ function formatAddress(address) {
7326
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
7327
+ }
7328
+
7329
+ // src/utils/copyAddress.ts
7330
+ async function copyAddressToClipboard(address) {
7331
+ try {
7332
+ await navigator.clipboard.writeText(address);
7333
+ toast.add({
7334
+ type: "success",
7335
+ title: "Address copied",
7336
+ description: formatAddress(address)
7337
+ });
7338
+ } catch (error) {
7339
+ debugWarn("[fluent connect] Failed to copy address", error);
7340
+ toast.add({
7341
+ type: "error",
7342
+ title: "Copy failed",
7343
+ description: "Could not copy address to clipboard."
7344
+ });
7345
+ }
7346
+ }
7347
+
7348
+ // src/utils/createLocalFluentSession.ts
7349
+ function createLocalFluentSession(params) {
7350
+ const issuedAt = Math.floor(Date.now() / 1e3);
7351
+ const payload = {
7352
+ iss: typeof location !== "undefined" ? location.origin : "fluent-local",
7353
+ aud: params.partnerId,
7354
+ sub: params.userId,
7355
+ app: params.app,
7356
+ scopes: params.scopes,
7357
+ iat: issuedAt
7358
+ };
7359
+ return {
7360
+ app: params.app,
7361
+ partnerId: params.partnerId,
7362
+ idToken: `mock.${btoa(JSON.stringify(payload))}.signature`,
7363
+ user: {
7364
+ id: params.userId,
7365
+ email: params.email
7366
+ },
7367
+ wallet: {
7368
+ signerAddress: params.signerAddress,
7369
+ smartAccountAddress: params.smartAccountAddress
7370
+ },
7371
+ scopes: params.scopes,
7372
+ issuedAt,
7373
+ metadata: {
7374
+ authMode: "direct",
7375
+ origin: params.app.origin
7376
+ }
7377
+ };
7378
+ }
7379
+
7380
+ // src/utils/explorerAddress.ts
7381
+ function explorerAddress(address, network) {
7382
+ const baseUrl = getFluentExplorerBaseUrl(network ?? "testnet");
7383
+ return `${baseUrl}/address/${address}`;
7384
+ }
7385
+
7386
+ // src/utils/faucetToast.ts
7387
+ function normalize(value) {
7388
+ return (value ?? "").trim().toLowerCase();
7389
+ }
7390
+ function isAlreadyClaimed(status, message) {
7391
+ const statusNorm = normalize(status);
7392
+ const messageNorm = normalize(message);
7393
+ return statusNorm.includes("already") || messageNorm.includes("already");
7394
+ }
7395
+ function toastFaucetSuccess(receipt) {
7396
+ if (isAlreadyClaimed(receipt.status, receipt.message)) {
7397
+ toast.add({
7398
+ type: "info",
7399
+ title: "Already claimed",
7400
+ description: receipt.message || "BLEND faucet was already claimed for this account."
7401
+ });
7402
+ return;
7403
+ }
7404
+ toast.add({
7405
+ type: "success",
7406
+ title: "Faucet claimed",
7407
+ description: receipt.message || (receipt.txHash ? `Transaction ${receipt.txHash}` : "BLEND was sent to your wallet.")
7408
+ });
7409
+ }
7410
+ function toastFaucetError(error) {
7411
+ if (error instanceof HttpError) {
7412
+ if (isAlreadyClaimed(error.body?.status, error.message) || error.status === 409) {
7413
+ toast.add({
7414
+ type: "info",
7415
+ title: "Already claimed",
7416
+ description: error.message || "BLEND faucet was already claimed for this account."
7417
+ });
7418
+ return;
7419
+ }
7420
+ if (error.status === 429) {
7421
+ toast.add({
7422
+ type: "warning",
7423
+ title: "Too many requests",
7424
+ description: error.message || "Please wait a moment and try again."
7425
+ });
7426
+ return;
7427
+ }
7428
+ toast.add({
7429
+ type: "error",
7430
+ title: "Faucet request failed",
7431
+ description: error.message || `Request failed with ${error.status}`
7432
+ });
7433
+ return;
7434
+ }
7435
+ toast.add({
7436
+ type: "error",
7437
+ title: "Faucet request failed",
7438
+ description: error instanceof Error ? error.message : "Something went wrong."
7439
+ });
7440
+ }
7441
+
7442
+ // src/utils/formatExternalWallet.ts
7443
+ function formatExternalWallet(wallet, status) {
7444
+ return JSON.stringify(
7445
+ {
7446
+ status: status ?? "Waiting for wallet connection",
7447
+ wallet: wallet ? {
7448
+ provider: "Reown AppKit",
7449
+ configured: wallet.configured,
7450
+ connected: wallet.connected,
7451
+ address: wallet.address,
7452
+ chainId: wallet.chainId
7453
+ } : null,
7454
+ walletConnectEnabled: Boolean(wallet?.configured)
7455
+ },
7456
+ null,
7457
+ 2
7458
+ );
7459
+ }
7460
+
7461
+ // src/utils/formatFluentLocaleAmount.ts
7462
+ var FLUENT_AMOUNT_LOCALE = "en-US";
7463
+ var FLUENT_DECIMAL_SEPARATOR = new Intl.NumberFormat(FLUENT_AMOUNT_LOCALE).formatToParts(1.1).find((part) => part.type === "decimal")?.value ?? ".";
7464
+ function formatFluentLocaleAmount(value, maximumFractionDigits = 2) {
7465
+ const amount = typeof value === "number" ? value : Number(value);
7466
+ if (!Number.isFinite(amount)) return typeof value === "string" ? value : String(value);
7467
+ return amount.toLocaleString(FLUENT_AMOUNT_LOCALE, {
7468
+ minimumFractionDigits: 0,
7469
+ maximumFractionDigits
7470
+ });
7471
+ }
7472
+
7473
+ // src/utils/formatFluentGasTokenBalance.ts
7474
+ var GAS_BALANCE_MAX_FRACTION_DIGITS = 6;
7475
+ function roundToFractionDigits(raw, decimals, digits) {
7476
+ const discardedScale = 10n ** BigInt(decimals - digits);
7477
+ return (raw + discardedScale / 2n) / discardedScale;
7478
+ }
7479
+ function formatFluentGasTokenBalance(balance, maximumFractionDigits = 1) {
7480
+ if (balance.raw === null || balance.formatted === null) return null;
7481
+ if (maximumFractionDigits < 0 || !Number.isInteger(maximumFractionDigits)) {
7482
+ throw new Error("maximumFractionDigits must be a non-negative integer");
7483
+ }
7484
+ if (balance.decimals <= maximumFractionDigits) {
7485
+ return formatFluentLocaleAmount(balance.formatted, maximumFractionDigits);
7486
+ }
7487
+ const maxDigits = Math.max(
7488
+ maximumFractionDigits,
7489
+ Math.min(balance.decimals, GAS_BALANCE_MAX_FRACTION_DIGITS)
7490
+ );
7491
+ for (let digits = maximumFractionDigits; digits <= maxDigits; digits += 1) {
7492
+ const rounded = roundToFractionDigits(balance.raw, balance.decimals, digits);
7493
+ if (rounded > 0n || balance.raw === 0n) {
7494
+ return formatFluentLocaleAmount(formatUnits(rounded, digits), digits);
7495
+ }
7496
+ }
7497
+ return formatFluentLocaleAmount(0, maximumFractionDigits);
7498
+ }
7499
+
7500
+ // src/utils/formatSession.ts
7501
+ function formatSession(session) {
7502
+ if (!session) return "Waiting for Fluent login";
7503
+ return JSON.stringify(
7504
+ {
7505
+ app: {
7506
+ mode: session.app.mode,
7507
+ origin: session.app.origin,
7508
+ installationId: session.app.installationId,
7509
+ clientId: session.app.clientId,
7510
+ appName: session.app.appName
7511
+ },
7512
+ user: session.user,
7513
+ wallet: {
7514
+ smartAccountAddress: session.wallet.smartAccountAddress
7515
+ },
7516
+ scopes: session.scopes,
7517
+ issuedAt: session.issuedAt,
7518
+ idToken: session.idToken
7519
+ },
7520
+ null,
7521
+ 2
7522
+ );
7523
+ }
7524
+
7525
+ // src/utils/getAnonymousId.ts
7526
+ function getAnonymousId() {
7527
+ const storageKey = "fluent_demo_visitor_id";
7528
+ const existing = localStorage.getItem(storageKey);
7529
+ if (existing) return existing;
7530
+ const next = crypto.randomUUID?.() ?? `visitor_${Date.now()}_${Math.random().toString(16).slice(2)}`;
7531
+ localStorage.setItem(storageKey, next);
7532
+ return next;
7533
+ }
7534
+
7535
+ // src/utils/getHighResTwitterAvatar.ts
7536
+ function getHighResTwitterAvatar(url) {
7537
+ if (!url) return "";
7538
+ return url.replace("_normal", "");
7539
+ }
7540
+
7541
+ // src/utils/hasStoredWidgetSession.ts
7542
+ function hasStoredWidgetSession(storage = globalThis.window?.localStorage) {
7543
+ if (!storage) return false;
7544
+ try {
7545
+ return Boolean(storage.getItem(FLUENT_WIDGET_SESSION_STORAGE_KEY));
7546
+ } catch {
7547
+ return false;
7548
+ }
6608
7549
  }
6609
7550
  var REOWN_PROJECT_ID = FLUENT_CONNECT_REOWN_PROJECT_ID;
6610
7551
  var queryClient = new QueryClient();
@@ -6700,73 +7641,6 @@ function useReownWallet() {
6700
7641
  [isConnected, address, chainId, walletClient, status, openWallet, disconnect, switchChain]
6701
7642
  );
6702
7643
  }
6703
- function cn(...inputs) {
6704
- return twMerge(clsx(inputs));
6705
- }
6706
- var buttonVariants = cva(
6707
- "group/button inline-flex shrink-0 items-center justify-center rounded-xl border border-transparent bg-clip-padding font-medium whitespace-nowrap transition-all duration-75 outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
6708
- {
6709
- variants: {
6710
- variant: {
6711
- default: "bg-primary text-primary-foreground hover:bg-primary/80",
6712
- outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
6713
- secondary: "bg-primary/10 text-secondary-foreground hover:bg-primary/15 aria-expanded:bg-primary/10 aria-expanded:text-secondary-foreground",
6714
- ghost: "hover:bg-primary/10 hover:text-foreground dark:hover:bg-primary/10",
6715
- destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
6716
- link: "text-primary underline-offset-4 hover:underline"
6717
- },
6718
- size: {
6719
- default: "h-10 gap-1.5 px-3.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 text-sm",
6720
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
6721
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
6722
- lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
6723
- icon: "size-8",
6724
- "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
6725
- "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
6726
- "icon-lg": "size-9"
6727
- }
6728
- },
6729
- defaultVariants: {
6730
- variant: "default",
6731
- size: "default"
6732
- }
6733
- }
6734
- );
6735
- var Button = forwardRef(function Button2({ className, variant = "default", size = "default", href, target, rel, render, ...props }, ref) {
6736
- const isLink = href !== void 0;
6737
- return /* @__PURE__ */ jsx(
6738
- Button$1,
6739
- {
6740
- ref,
6741
- "data-slot": "button",
6742
- nativeButton: isLink ? false : void 0,
6743
- className: cn(buttonVariants({ variant, size, className })),
6744
- render: isLink ? /* @__PURE__ */ jsx("a", { href, target, rel }) : render,
6745
- ...props
6746
- }
6747
- );
6748
- });
6749
- var WIDGET_STYLE_SCOPE = "fluent-root dark contents text-white";
6750
- var FluentPortalContainerContext = createContext(null);
6751
- function FluentPortalContainerProvider({ children }) {
6752
- const [container, setContainer] = useState(null);
6753
- useLayoutEffect(() => {
6754
- const element = document.createElement("div");
6755
- element.setAttribute("data-fluent-portal-root", "");
6756
- element.className = WIDGET_STYLE_SCOPE;
6757
- document.body.appendChild(element);
6758
- setContainer(element);
6759
- return () => {
6760
- element.remove();
6761
- setContainer(null);
6762
- };
6763
- }, []);
6764
- return /* @__PURE__ */ jsx(FluentPortalContainerContext.Provider, { value: container, children });
6765
- }
6766
- function useFluentPortalContainer(override) {
6767
- const container = useContext(FluentPortalContainerContext);
6768
- return override ?? container ?? void 0;
6769
- }
6770
7644
  function Dialog({ ...props }) {
6771
7645
  return /* @__PURE__ */ jsx(Dialog$1.Root, { "data-slot": "dialog", ...props });
6772
7646
  }
@@ -6905,10 +7779,6 @@ function DialogDescription({
6905
7779
  }
6906
7780
  );
6907
7781
  }
6908
-
6909
- // src/assets/token-icon-urls.ts
6910
- var USDT_ICON_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAALd0lEQVR4AeydS47bRhCGW8oVZmVfwEBmae8CxD5BPKvJGRzkCIFt5AhBcoZkZeUEcYDssp0BcoFk5TN40p+oGrUokuKjutlN1oC/+e6u+vtTjYYi5a2zH3MgggMGVgRTrUnnDCyjIIoDBlYUW61RA8sYiOKAgRXFVmvUwFoLA4nzNLASG76W7gystYx04jyTg/X6w08vTek9SMxV2utYrz/8/M5fOvvDtE3uQeV9OrxSV6y36VKznmoOvOU3RW1btNVkYKV+xURzrOiGty9Thb9N1ZHvx6qVN+E4zbKUbAySgGXVahaIGjtNNRZJwPIZJnul+L5s6nYgyVhEByvVK6TbS9sbOpBiTKKD5RNK8grx/djU24HN170PHXlgVLBSvDJG5r3y0x72F6ljmhAVLB+4VStvQp7TF1HHJhpYBVarPMc/WlRxq1Y0sLwfUV8Rvn2bJjsQr2pFAcuq1eQRT9RAvKoVBaxErlg3Kg7EqVrqYB2qlf0aVBn0FI3EqVrqYKWwwvrQdkC/aqmCZdVKe8BTtadftVTB0rbh+uqp+/bZC1ODB3ij67du1dIGS/W91fXVE3frTTW9aPDhuS5XTrdqqYF1+DWonKw1l9YBvaqlBpY3QLVa+fZsSu6AXtVSAcuqVXICInaoU7VUwPJZWrXyJixjelC5L34yWFatloFTmIXGmA4DK+z9uGzV6ujFUpYmj+kksDTIXspILC2PqWM7CSxv5mSyfRs25enApLEdDdZUovP00qIKHZjy5PRosHwAk4j259uUvQPjLz2MAsuqVfZEKAU4/oLpKLB81FatvAkLnoLUxlWtwWBZtQo8X8XiuKo1GCzvpVUrb8K6puFVaxBYVq3WhdMx2+FVaxBYx45saX0ODKtavcE6VKukvwZ//edvd7P7Jbp+8/1ogUJbKWL+4a/ftULu2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8B/ucFOS8+pT9BSnQu4yxjGQPmPF9SWz2RmIlZmKX51A3k8v4hqyPbCKI1Z4u/5BRCnTL4vwZF8ml5EybmZ+3xv+uTPz/TPQOiBwWqXrB5wFiIBZiIjZiJFZirjqg1P4mjljtgHEpWfij2X9ZmN9+3eLe2d9ZnJ995dTU1CnWTJ3jvf+gFPoGY8zfWmMekkvp07JdbrH26dyW2MQ2Pqz4wie+iYFYiInYzAS/JppYver20J5tDy/Mb7tL3k+7Rgr9fin46xbmZ3/WmOc22SU/w2hivXmDEOO3pP/7vM8+6L35sGxfhrBNm2y/Dx108z7SFxvYwia28YEvfIr+hCy6NP4fAAD//56guDcAAAAGSURBVAMAF2A0uqPlZg0AAAAASUVORK5CYII=";
6912
7782
  var icons = {
6913
7783
  x: (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M10.4883 14.651L15.25 21H22.25L14.3917 10.5223L20.9308 3H18.2808L13.1643 8.88578L8.75 3H1.75L9.26086 13.0145L2.31915 21H4.96917L10.4883 14.651ZM16.25 19L5.75 5H7.75L18.25 19H16.25Z" }) }),
6914
7784
  "arrow-right-s-line": (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z" }) }),
@@ -6924,8 +7794,6 @@ var icons = {
6924
7794
  /* @__PURE__ */ jsx("path", { d: "m11.944 15.349 6.722-3.937-6.722-3.003v6.94z", opacity: "0.2" }),
6925
7795
  /* @__PURE__ */ jsx("path", { d: "m5.222 11.412 6.722 3.937v-6.94l-6.722 3.003z", opacity: "0.6" })
6926
7796
  ] }),
6927
- usdc: ({ className }) => /* @__PURE__ */ jsx("img", { src: USDC_ICON_DATA_URL, alt: "", "aria-hidden": "true", className: cn(className) }),
6928
- usdt: ({ className }) => /* @__PURE__ */ jsx("img", { src: USDT_ICON_DATA_URL, alt: "", "aria-hidden": "true", className: cn(className) }),
6929
7797
  usdnr: (props) => /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 75 75", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
6930
7798
  /* @__PURE__ */ jsx("path", { d: "M36.8,58.23c-.18-.12-.36-.24-.53-.36l-.34-.24-1.38,17.22,.23,.03c.34,.04,.68,.08,1.02,.1l.25,.02,.89-16.69-.12-.08Zm2.73,1.55c-.14-.07-.29-.14-.43-.21l-.37-.19,.86,15.63,.25-.02c.31-.03,.62-.06,.93-.1l.23-.03-1.2-14.95-.13-.06-.14-.07Zm-5.17-3.37c-.16-.14-.32-.28-.48-.42l-.31-.28-3.94,17.99,.21,.07c.35,.12,.7,.23,1.05,.33l.25,.07,3.33-17.67-.11-.09Zm8.46,4.67c-.15-.05-.29-.09-.44-.14l-.39-.13,2.57,13.32,.25-.07c.27-.08,.54-.16,.81-.25l.21-.07-2.72-12.56-.14-.04-.15-.05Zm3.68,.85c-.15-.02-.29-.05-.44-.07l-.4-.07,3.56,10.49,.25-.13c.22-.12,.44-.24,.66-.36l.18-.1-3.52-9.71-.14-.02-.15-.02Zm-15.82-9.4c-.13-.16-.25-.33-.37-.5l-.23-.31-9,16.93,.14,.13c.31,.28,.63,.55,.95,.81l.23,.19,8.36-17.13-.09-.12Zm19.96,9.67c-.18,0-.68,0-.87,0h-.41s4.02,7.36,4.02,7.36l.22-.18c.17-.14,.34-.28,.5-.43l.14-.13-3.47-6.62h-.15Zm-21.28-11.59c-.11-.17-.21-.35-.31-.52l-.19-.32-11.05,15.3,.11,.14c.26,.34,.53,.68,.81,1.02l.21,.24,10.5-15.73-.08-.13Zm28.05,14.86l.11-.14-2.55-3.59-.15,.03c-.17,.03-.33,.06-.5,.09l-.37,.06,2.9,4.24,.2-.25c.12-.15,.24-.29,.35-.44Zm-29.11-16.75c-.09-.18-.18-.36-.27-.55l-.15-.32-12.54,13.16,.07,.15c.2,.4,.41,.8,.63,1.19l.17,.3,12.16-13.79-.07-.15Zm31.71,12.66l-.82-.89-.15,.06c-.14,.05-.28,.11-.42,.16l-.48,.19,1.23,1.63c.08-.14,.58-1.01,.65-1.15Zm-32.54-14.53c-.07-.19-.15-.37-.22-.56l-.12-.31-13.39,10.73,.04,.15c.12,.44,.26,.89,.41,1.32l.11,.34,13.23-11.51-.06-.16Zm-.64-1.8c-.06-.19-.11-.38-.17-.57l-.09-.3-13.61,8.15v.15c.06,.47,.11,.93,.18,1.39l.06,.37,13.68-9.02-.05-.17Zm-.46-1.72c-.04-.19-.09-.38-.13-.57l-.06-.29-13.22,5.63v.15c-.05,.47-.07,.93-.08,1.4v.39s13.53-6.51,13.53-6.51l-.04-.19Zm-.33-1.67c-.03-.2-.06-.39-.09-.59l-.04-.27-12.3,3.35-.03,.14c-.11,.45-.21,.91-.29,1.36l-.07,.4,12.86-4.17-.03-.2Zm-.21-1.65c-.02-.21-.04-.41-.05-.62l-.02-.26-10.98,1.43-.05,.13c-.17,.42-.34,.85-.49,1.28l-.14,.39,11.73-2.13-.02-.22Zm-.04-3.95l.02-.22-7.59-1.08-.09,.11c-.27,.34-.52,.68-.76,1.03l-.24,.34,8.62,.75v-.25c.02-.22,.03-.45,.05-.67Zm.18-1.68l.03-.21-5.79-1.65-.1,.1c-.29,.29-.57,.59-.84,.89l-.28,.31,6.87,1.53,.03-.27c.03-.24,.05-.47,.09-.71Zm.3-1.7l.04-.19-4.07-1.78-.11,.09c-.3,.24-.6,.5-.89,.75l-.3,.27,5.13,1.89,.05-.28c.04-.25,.09-.5,.15-.75Zm.44-1.73l.05-.18-2.49-1.53-.13,.08c-.31,.2-.61,.41-.91,.63l-.31,.23,3.5,1.86,.07-.3c.07-.27,.14-.53,.22-.79Zm.6-1.79l.06-.16-1.11-.91-.14,.07c-.31,.17-.62,.34-.93,.52l-.32,.19,2.03,1.46,.1-.31c.1-.29,.2-.57,.3-.86Zm.38-.95c.06-.14,.12-.29,.19-.43l.26-.58-.58,.26c-.15,.07-.29,.13-.44,.2l-.32,.15,.76,.71,.13-.32Zm-1.95,10.17c0-.22,0-.43,0-.65v-.24l-9.36-.06-.07,.12s-.01,.02-.02,.03c0,.01-.02,.03-.05,.09h0c-.2,.35-.39,.69-.57,1.04l-.19,.37,10.28-.48v-.24Zm6.16,15.65c.14,.16,.28,.31,.43,.47l.1,.1-5.89,17.81-.25-.13c-.35-.18-.69-.37-1.03-.57l-.17-.1,6.56-17.88,.27,.3Z" }),
6931
7799
  /* @__PURE__ */ jsx("path", { d: "M58.26,38.26c-.12,.18-.24,.36-.36,.53l-.24,.34,17.19,1.39,.03-.23c.04-.34,.08-.68,.1-1.02l.02-.25-16.67-.89-.08,.12Zm1.54-2.74c-.07,.14-.14,.29-.21,.43l-.19,.37,15.6-.86-.02-.25c-.03-.31-.06-.62-.1-.93l-.03-.23-14.92,1.2-.06,.13-.07,.14Zm-3.36,5.18c-.14,.16-.28,.32-.42,.49l-.28,.31,17.96,3.95,.07-.21c.12-.35,.23-.7,.33-1.06l.07-.25-17.64-3.33-.09,.11Zm4.66-8.48c-.05,.15-.09,.3-.14,.44l-.13,.39,13.3-2.57-.07-.25c-.08-.27-.16-.54-.25-.81l-.07-.21-12.54,2.72-.04,.14-.05,.15Zm.85-3.69c-.02,.15-.05,.29-.07,.44l-.07,.4,10.47-3.56-.13-.25c-.12-.22-.24-.44-.36-.66l-.1-.18-9.7,3.52-.02,.14-.02,.15Zm-9.39,15.85c-.16,.13-.33,.25-.5,.37l-.31,.23,16.91,9.01,.13-.14c.28-.31,.55-.63,.81-.95l.19-.24-17.1-8.37-.12,.09Zm9.65-19.99c0,.18,0,.68,0,.87v.41s7.35-4.03,7.35-4.03l-.18-.22c-.14-.17-.28-.34-.43-.5l-.12-.14-6.61,3.47v.15Zm-11.57,21.32c-.17,.11-.35,.21-.52,.31l-.32,.19,15.28,11.07,.14-.11c.34-.26,.68-.53,1.02-.82l.24-.21-15.7-10.52-.13,.08Zm14.83-28.1l-.14-.11-3.59,2.55,.03,.15c.03,.17,.06,.34,.09,.5l.06,.37,4.23-2.91-.25-.2c-.15-.12-.29-.24-.44-.35Zm-16.73,29.16c-.18,.09-.36,.18-.54,.27l-.32,.15,13.14,12.56,.15-.07c.4-.2,.8-.41,1.19-.63l.3-.17-13.77-12.18-.15,.07Zm12.64-31.76l-.88,.82,.06,.15c.05,.14,.11,.28,.16,.42l.19,.49,1.62-1.24c-.14-.08-1.01-.58-1.15-.65Zm-14.5,32.6c-.19,.07-.37,.15-.56,.22l-.31,.12,10.71,13.42,.15-.04c.44-.12,.88-.26,1.32-.41l.34-.12-11.49-13.25-.16,.06Zm-1.79,.64c-.19,.06-.38,.11-.57,.17l-.3,.09,8.13,13.63h.15c.46-.06,.93-.11,1.39-.18l.37-.06-9.01-13.7-.17,.05Zm-1.72,.47c-.19,.04-.38,.09-.57,.13l-.29,.06,5.62,13.24h.15c.47,.05,.93,.07,1.4,.08h.39s-6.5-13.55-6.5-13.55l-.19,.04Zm-1.67,.33c-.2,.03-.39,.06-.59,.09l-.27,.04,3.34,12.32,.14,.03c.45,.11,.9,.21,1.36,.29l.4,.07-4.17-12.88-.2,.03Zm-1.64,.21c-.21,.02-.41,.04-.61,.05l-.26,.02,1.43,10.99,.13,.05c.42,.17,.85,.34,1.28,.49l.39,.14-2.13-11.75-.22,.02Zm-3.95,.04l-.22-.02-1.08,7.6,.11,.09c.34,.27,.68,.52,1.03,.77l.34,.24,.75-8.63h-.25c-.22-.02-.45-.03-.67-.05Zm-1.68-.18l-.21-.03-1.64,5.8,.1,.1c.29,.29,.59,.57,.89,.85l.31,.28,1.53-6.88-.27-.03c-.24-.03-.47-.05-.71-.09Zm-1.69-.3l-.19-.04-1.78,4.08,.09,.11c.24,.3,.49,.6,.75,.89l.27,.3,1.89-5.14-.28-.05c-.25-.04-.5-.09-.74-.15Zm-1.73-.44l-.18-.05-1.53,2.49,.08,.13c.2,.31,.41,.61,.63,.91l.23,.31,1.86-3.51-.3-.07c-.27-.07-.53-.14-.79-.22Zm-1.79-.6l-.16-.06-.91,1.11,.07,.14c.17,.31,.34,.62,.52,.93l.19,.32,1.45-2.03-.31-.1c-.29-.1-.57-.2-.85-.31Zm-.95-.38c-.14-.06-.29-.12-.43-.19l-.58-.26,.26,.58c.07,.15,.13,.29,.2,.44l.15,.32,.71-.76-.32-.13Zm10.15,1.95c-.22,0-.43,0-.65,0h-.24l-.06,9.37,.12,.07s.02,.01,.03,.02c.01,0,.03,.02,.09,.05h0c.34,.2,.69,.39,1.04,.57l.37,.19-.48-10.29h-.23Zm15.63-6.17c.16-.14,.31-.28,.47-.43l.1-.1,17.78,5.9-.13,.25c-.18,.35-.37,.69-.57,1.04l-.1,.18-17.85-6.57,.3-.27Z" }),
@@ -7120,25 +7988,6 @@ function ConnectChoiceModal({
7120
7988
  }
7121
7989
  );
7122
7990
  }
7123
-
7124
- // src/utils/buildFluentBridgeUrl.ts
7125
- function buildFluentBridgeUrl(bridgeUrl, recipient) {
7126
- if (!recipient) return bridgeUrl;
7127
- try {
7128
- const url = new URL(bridgeUrl);
7129
- url.searchParams.set("recipient", recipient);
7130
- return url.toString();
7131
- } catch {
7132
- const join = bridgeUrl.includes("?") ? "&" : "?";
7133
- return `${bridgeUrl}${join}recipient=${encodeURIComponent(recipient)}`;
7134
- }
7135
- }
7136
-
7137
- // src/utils/explorerAddress.ts
7138
- function explorerAddress(address, network) {
7139
- const baseUrl = getFluentExplorerBaseUrl(network ?? "testnet");
7140
- return `${baseUrl}/address/${address}`;
7141
- }
7142
7991
  function Label({ className, ...props }) {
7143
7992
  return /* @__PURE__ */ jsx(
7144
7993
  "label",
@@ -7335,7 +8184,7 @@ function SelectContent({
7335
8184
  {
7336
8185
  "data-slot": "select-content",
7337
8186
  "data-align-trigger": alignItemWithTrigger,
7338
- className: cn("dark relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1 border border-white/15 text-popover-foreground shadow-xl duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
8187
+ className: cn("dark relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1 border border-foreground/15 text-popover-foreground shadow-xl duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
7339
8188
  ...props,
7340
8189
  children: [
7341
8190
  /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
@@ -7357,7 +8206,7 @@ function SelectItem({
7357
8206
  {
7358
8207
  "data-slot": "select-item",
7359
8208
  className: cn(
7360
- "relative flex w-full cursor-default items-center gap-2 rounded-lg py-2 pr-8 pl-2.5 text-sm outline-hidden select-none focus:bg-white/10 focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
8209
+ "relative flex w-full cursor-default items-center gap-2 rounded-lg py-2 pr-8 pl-2.5 text-sm outline-hidden select-none focus:bg-foreground/10 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
7361
8210
  className
7362
8211
  ),
7363
8212
  ...props,
@@ -7458,7 +8307,7 @@ function Switch({
7458
8307
  Switch$1.Thumb,
7459
8308
  {
7460
8309
  "data-slot": "switch-thumb",
7461
- className: "pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"
8310
+ className: "pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-primary"
7462
8311
  }
7463
8312
  )
7464
8313
  }
@@ -7483,11 +8332,11 @@ function Tabs({
7483
8332
  );
7484
8333
  }
7485
8334
  var tabsListVariants = cva(
7486
- "group/tabs-list inline-flex w-fit items-center justify-center rounded-xl p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
8335
+ "group/tabs-list inline-flex w-fit items-center justify-center rounded-xl p-[3px] text-tabs-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
7487
8336
  {
7488
8337
  variants: {
7489
8338
  variant: {
7490
- default: "bg-white/10",
8339
+ default: "bg-tabs",
7491
8340
  line: "gap-1 bg-transparent"
7492
8341
  }
7493
8342
  },
@@ -7517,9 +8366,9 @@ function TabsTrigger({ className, ...props }) {
7517
8366
  {
7518
8367
  "data-slot": "tabs-trigger",
7519
8368
  className: cn(
7520
- "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-lg border border-transparent px-1.5 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8369
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-lg border border-transparent px-1.5 py-1 text-sm font-medium whitespace-nowrap text-tabs-foreground transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-tabs-active-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
7521
8370
  "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
7522
- "data-active:bg-background data-active:text-foreground dark:data-active:bg-white/10 dark:data-active:text-foreground",
8371
+ "data-active:bg-tabs-active data-active:text-tabs-active-foreground",
7523
8372
  "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
7524
8373
  className
7525
8374
  ),
@@ -7540,10 +8389,22 @@ function TabsContent({ className, ...props }) {
7540
8389
  function useFluentTokenBalances(params) {
7541
8390
  const { network, chain } = useFluentWidgetNetwork();
7542
8391
  const defaultTokens = useMemo(
7543
- () => getFluentDefaultWidgetGasTokens(network),
8392
+ () => getFluentDefaultWidgetDisplayTokens(network),
7544
8393
  [network]
7545
8394
  );
7546
- const tokens = params.tokens ?? defaultTokens;
8395
+ const {
8396
+ tokens: userTokens,
8397
+ add: addUserToken,
8398
+ remove: removeUserToken
8399
+ } = useFluentUserTokens({ store: params.userTokenStore });
8400
+ const displayTokens = useMemo(
8401
+ () => mergeFluentDisplayTokens({
8402
+ defaults: defaultTokens,
8403
+ integrator: params.tokens,
8404
+ user: userTokens
8405
+ }),
8406
+ [defaultTokens, params.tokens, userTokens]
8407
+ );
7547
8408
  const publicClient = useMemo(
7548
8409
  () => createPublicClient({
7549
8410
  chain,
@@ -7551,7 +8412,7 @@ function useFluentTokenBalances(params) {
7551
8412
  }),
7552
8413
  [chain]
7553
8414
  );
7554
- const gasTokens = useMemo(() => getFluentGasPaymentTokens(tokens), [tokens]);
8415
+ const gasTokens = useMemo(() => getFluentGasPaymentTokens(displayTokens), [displayTokens]);
7555
8416
  const [balances, setBalances] = useState([]);
7556
8417
  const [busy, setBusy] = useState(false);
7557
8418
  const [status, setStatus] = useState("Connect a Fluent account");
@@ -7567,16 +8428,16 @@ function useFluentTokenBalances(params) {
7567
8428
  return;
7568
8429
  }
7569
8430
  setBusy(true);
7570
- setStatus("Checking gas token balances");
8431
+ setStatus("Checking token balances");
7571
8432
  try {
7572
8433
  const next = await readFluentTokenBalances({
7573
8434
  client: publicClient,
7574
8435
  account: params.accountAddress,
7575
- tokens: gasTokens
8436
+ tokens: displayTokens
7576
8437
  });
7577
8438
  if (signal.aborted) return;
7578
8439
  setBalances(next);
7579
- setStatus("Gas route updated");
8440
+ setStatus("Balances updated");
7580
8441
  } catch {
7581
8442
  if (signal.aborted) return;
7582
8443
  setBalances([]);
@@ -7584,11 +8445,11 @@ function useFluentTokenBalances(params) {
7584
8445
  } finally {
7585
8446
  if (!signal.aborted) setBusy(false);
7586
8447
  }
7587
- }, [gasTokens, params.accountAddress, publicClient]);
8448
+ }, [displayTokens, params.accountAddress, publicClient]);
7588
8449
  useEffect(() => {
7589
8450
  setBalances([]);
7590
8451
  setStatus(
7591
- params.accountAddress ? "Checking gas token balances" : "Connect a Fluent account"
8452
+ params.accountAddress ? "Checking token balances" : "Connect a Fluent account"
7592
8453
  );
7593
8454
  }, [params.accountAddress]);
7594
8455
  useEffect(() => {
@@ -7596,20 +8457,25 @@ function useFluentTokenBalances(params) {
7596
8457
  return () => inFlight.current?.abort();
7597
8458
  }, [refresh, params.revisionCounter]);
7598
8459
  return {
8460
+ /** Balances for every display token, in display order. */
7599
8461
  balances,
7600
8462
  busy,
8463
+ /** The resolved display-token list the balances correspond to. */
8464
+ displayTokens,
8465
+ /** The gas-capable subset, in paymaster priority order. */
7601
8466
  gasTokens,
7602
8467
  refresh,
7603
- status
8468
+ status,
8469
+ addUserToken,
8470
+ removeUserToken
7604
8471
  };
7605
8472
  }
7606
- var fluentDefaultGasTokens = getFluentDefaultWidgetGasTokens("testnet");
7607
8473
  function sumFluentTokenBalancesUsd(balances, usdPrices) {
7608
8474
  let sum = 0;
7609
8475
  let hasPriced = false;
7610
8476
  for (const balance of balances) {
7611
8477
  if (balance.status !== "ready" || balance.formatted === null) continue;
7612
- const price = usdPrices[balance.symbol];
8478
+ const price = usdPrices[fluentTokenIdentity(balance)];
7613
8479
  if (price === void 0) continue;
7614
8480
  const amount = Number(balance.formatted);
7615
8481
  if (!Number.isFinite(amount)) continue;
@@ -7621,7 +8487,7 @@ function sumFluentTokenBalancesUsd(balances, usdPrices) {
7621
8487
  function formatFluentPortfolioTotal(total) {
7622
8488
  const [wholeRaw, fraction = "00"] = total.toFixed(2).split(".");
7623
8489
  const whole = formatFluentLocaleAmount(Number(wholeRaw), 0);
7624
- return { whole, fraction };
8490
+ return { whole, fraction, separator: FLUENT_DECIMAL_SEPARATOR };
7625
8491
  }
7626
8492
  function getFluentPortfolioPnl(params) {
7627
8493
  const { currentTotal, previousTotal } = params;
@@ -7631,9 +8497,9 @@ function getFluentPortfolioPnl(params) {
7631
8497
  return { delta, percent };
7632
8498
  }
7633
8499
  function formatFluentPortfolioPnlAbsolute(delta) {
7634
- const { whole, fraction } = formatFluentPortfolioTotal(Math.abs(delta));
8500
+ const { whole, fraction, separator } = formatFluentPortfolioTotal(Math.abs(delta));
7635
8501
  const sign = delta >= 0 ? "+" : "\u2212";
7636
- return `$ ${sign}${whole},${fraction}`;
8502
+ return `$ ${sign}${whole}${separator}${fraction}`;
7637
8503
  }
7638
8504
  function formatFluentPortfolioPnlPercent(percent) {
7639
8505
  return `${formatFluentLocaleAmount(Math.abs(percent), 2)}%`;
@@ -7642,9 +8508,7 @@ function formatFluentPortfolioPnlPercent(percent) {
7642
8508
  // src/core/tokenPrices.ts
7643
8509
  var COINGECKO_API = "https://api.coingecko.com/api/v3";
7644
8510
  var FIXED_USD_PRICES = {
7645
- USDnr: 1,
7646
- USDC: 1,
7647
- USDT: 1
8511
+ USDnr: 1
7648
8512
  };
7649
8513
  var COINBASE_BASE_BY_SYMBOL = {
7650
8514
  ETH: "ETH",
@@ -7760,243 +8624,193 @@ function splitFluentTokenUsdPricePoints(points) {
7760
8624
  prices[symbol] = point.current;
7761
8625
  prices24hAgo[symbol] = point.price24hAgo;
7762
8626
  }
7763
- return { prices, prices24hAgo };
7764
- }
7765
-
7766
- // src/hooks/useFluentTokenUsdPrices.ts
7767
- function useFluentTokenUsdPrices(symbols) {
7768
- const symbolKey = useMemo(() => [...new Set(symbols)].sort().join(","), [symbols]);
7769
- const [prices, setPrices] = useState({});
7770
- const [pricesYesterday, setPricesYesterday] = useState({});
7771
- const [busy, setBusy] = useState(() => Boolean(symbolKey));
7772
- useEffect(() => {
7773
- if (!symbolKey) {
7774
- setPrices({});
7775
- setPricesYesterday({});
7776
- setBusy(false);
7777
- return;
7778
- }
7779
- let active = true;
7780
- setBusy(true);
7781
- fetchFluentTokenUsdPricePoints(symbolKey.split(",")).then((points) => {
7782
- if (!active) return;
7783
- const next = splitFluentTokenUsdPricePoints(points);
7784
- setPrices(next.prices);
7785
- setPricesYesterday(next.prices24hAgo);
7786
- setBusy(false);
7787
- });
7788
- return () => {
7789
- active = false;
7790
- };
7791
- }, [symbolKey]);
7792
- return { prices, pricesYesterday, busy };
7793
- }
7794
- var toast = Toast$1.createToastManager();
7795
- function ToastProvider({ ...props }) {
7796
- return /* @__PURE__ */ jsx(Toast$1.Provider, { ...props });
7797
- }
7798
- function ToastPortal({ container, ...props }) {
7799
- return /* @__PURE__ */ jsx(
7800
- Toast$1.Portal,
7801
- {
7802
- "data-slot": "toast-portal",
7803
- container: useFluentPortalContainer(container),
7804
- ...props
7805
- }
7806
- );
7807
- }
7808
- function ToastViewport({ className, ...props }) {
7809
- return /* @__PURE__ */ jsx(
7810
- Toast$1.Viewport,
7811
- {
7812
- "data-slot": "toast-viewport",
7813
- className: cn(
7814
- "dark pointer-events-none fixed inset-x-4 bottom-4 z-[100] mx-auto w-[min(100%,368px)] max-w-[368px] text-foreground outline-none sm:right-4 sm:left-auto sm:mx-0",
7815
- className
7816
- ),
7817
- ...props
7818
- }
7819
- );
7820
- }
7821
- function Toast({ className, style, ...props }) {
7822
- return /* @__PURE__ */ jsx(
7823
- Toast$1.Root,
7824
- {
7825
- "data-slot": "toast",
7826
- style: { maxWidth: 368, ...style },
7827
- className: cn(
7828
- "group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full max-w-[368px] origin-bottom rounded-2xl border border-white/20 bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-border focus-visible:ring-[3px] focus-visible:ring-ring/50",
7829
- "[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]",
7830
- "h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]",
7831
- "after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
7832
- "data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
7833
- "data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]",
7834
- "[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
7835
- "data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
7836
- "data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
7837
- "data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
7838
- "data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
7839
- "data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
7840
- "data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
7841
- "data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
7842
- "data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
7843
- className
7844
- ),
7845
- ...props
7846
- }
7847
- );
7848
- }
7849
- function ToastContent({ className, ...props }) {
7850
- return /* @__PURE__ */ jsx(
7851
- Toast$1.Content,
7852
- {
7853
- "data-slot": "toast-content",
7854
- className: cn(
7855
- "flex h-full items-start gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100",
7856
- className
7857
- ),
7858
- ...props
7859
- }
7860
- );
8627
+ return { prices, prices24hAgo };
7861
8628
  }
7862
- function ToastTitle({ className, ...props }) {
7863
- return /* @__PURE__ */ jsx(
7864
- Toast$1.Title,
7865
- {
7866
- "data-slot": "toast-title",
7867
- className: cn("text-sm font-medium", className),
7868
- ...props
7869
- }
7870
- );
8629
+ function getFluentPriceableSymbols(tokens) {
8630
+ return tokens.filter(isFluentDefaultToken).map((token) => token.symbol);
7871
8631
  }
7872
- function ToastDescription({
7873
- className,
7874
- ...props
7875
- }) {
7876
- return /* @__PURE__ */ jsx(
7877
- Toast$1.Description,
7878
- {
7879
- "data-slot": "toast-description",
7880
- className: cn("text-sm text-muted-foreground", className),
7881
- ...props
7882
- }
7883
- );
8632
+ function mapFluentPricesToTokenIdentities(tokens, pricesBySymbol) {
8633
+ const byIdentity = {};
8634
+ for (const token of tokens) {
8635
+ if (!isFluentDefaultToken(token)) continue;
8636
+ const price = pricesBySymbol[token.symbol];
8637
+ if (price === void 0) continue;
8638
+ byIdentity[fluentTokenIdentity(token)] = price;
8639
+ }
8640
+ return byIdentity;
7884
8641
  }
7885
- function ToastAction({
7886
- className,
7887
- render = /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm" }),
7888
- ...props
7889
- }) {
7890
- return /* @__PURE__ */ jsx(
7891
- Toast$1.Action,
7892
- {
7893
- "data-slot": "toast-action",
7894
- render,
7895
- className: cn("shrink-0", className),
7896
- ...props
8642
+
8643
+ // src/hooks/useFluentTokenUsdPrices.ts
8644
+ function useFluentTokenUsdPrices(tokens) {
8645
+ const symbolKey = useMemo(
8646
+ () => getFluentPriceableSymbols(tokens).sort().join(","),
8647
+ [tokens]
8648
+ );
8649
+ const [pricesBySymbol, setPricesBySymbol] = useState({});
8650
+ const [pricesBySymbolYesterday, setPricesBySymbolYesterday] = useState({});
8651
+ const [busy, setBusy] = useState(() => Boolean(symbolKey));
8652
+ useEffect(() => {
8653
+ if (!symbolKey) {
8654
+ setPricesBySymbol({});
8655
+ setPricesBySymbolYesterday({});
8656
+ setBusy(false);
8657
+ return;
7897
8658
  }
8659
+ let active = true;
8660
+ setBusy(true);
8661
+ fetchFluentTokenUsdPricePoints(symbolKey.split(",")).then((points) => {
8662
+ if (!active) return;
8663
+ const next = splitFluentTokenUsdPricePoints(points);
8664
+ setPricesBySymbol(next.prices);
8665
+ setPricesBySymbolYesterday(next.prices24hAgo);
8666
+ setBusy(false);
8667
+ });
8668
+ return () => {
8669
+ active = false;
8670
+ };
8671
+ }, [symbolKey]);
8672
+ const prices = useMemo(
8673
+ () => mapFluentPricesToTokenIdentities(tokens, pricesBySymbol),
8674
+ [tokens, pricesBySymbol]
8675
+ );
8676
+ const pricesYesterday = useMemo(
8677
+ () => mapFluentPricesToTokenIdentities(tokens, pricesBySymbolYesterday),
8678
+ [tokens, pricesBySymbolYesterday]
7898
8679
  );
8680
+ return { prices, pricesYesterday, busy };
7899
8681
  }
7900
- function ToastClose({
7901
- className,
7902
- children,
7903
- render = /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon-sm" }),
7904
- ...props
8682
+ function AddTokenForm({
8683
+ existingSymbols,
8684
+ listedIdentities,
8685
+ onAdd,
8686
+ onClose
7905
8687
  }) {
7906
- return /* @__PURE__ */ jsx(
7907
- Toast$1.Close,
7908
- {
7909
- "data-slot": "toast-close",
7910
- "aria-label": "Close toast",
7911
- render,
7912
- className: cn(
7913
- "relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground",
7914
- className
7915
- ),
7916
- ...props,
7917
- children: children ?? /* @__PURE__ */ jsx(XIcon, { "aria-hidden": "true" })
7918
- }
8688
+ const { chain } = useFluentWidgetNetwork();
8689
+ const [address, setAddress] = useState("");
8690
+ const [lookup, setLookup] = useState({ phase: "idle" });
8691
+ const [addError, setAddError] = useState(null);
8692
+ const publicClient = useMemo(
8693
+ () => createPublicClient({ chain, transport: createFluentRpcTransport(chain) }),
8694
+ [chain]
7919
8695
  );
7920
- }
7921
- function ToastIcon({ type }) {
7922
- let icon = null;
7923
- if (type === "success") {
7924
- icon = /* @__PURE__ */ jsx(CircleCheckIcon, { "aria-hidden": "true" });
7925
- }
7926
- if (type === "info") {
7927
- icon = /* @__PURE__ */ jsx(InfoIcon, { "aria-hidden": "true" });
7928
- }
7929
- if (type === "warning") {
7930
- icon = /* @__PURE__ */ jsx(TriangleAlertIcon, { "aria-hidden": "true" });
7931
- }
7932
- if (type === "error") {
7933
- icon = /* @__PURE__ */ jsx(OctagonXIcon, { className: "text-destructive", "aria-hidden": "true" });
7934
- }
7935
- if (type === "loading") {
7936
- icon = /* @__PURE__ */ jsx(Loader2Icon, { className: "animate-spin", "aria-hidden": "true" });
7937
- }
7938
- if (!icon) {
7939
- return null;
7940
- }
7941
- return /* @__PURE__ */ jsx(
7942
- "span",
8696
+ useEffect(() => {
8697
+ const trimmed = address.trim();
8698
+ if (!trimmed) {
8699
+ setLookup({ phase: "idle" });
8700
+ return;
8701
+ }
8702
+ if (!isAddress(trimmed)) {
8703
+ setLookup({ phase: "rejected", message: "That is not a contract address." });
8704
+ return;
8705
+ }
8706
+ let cancelled = false;
8707
+ setLookup({ phase: "loading" });
8708
+ void readFluentTokenMetadata({
8709
+ client: publicClient,
8710
+ address: trimmed,
8711
+ chainId: chain.id
8712
+ }).then((result) => {
8713
+ if (cancelled) return;
8714
+ if (result.status === "ok") {
8715
+ setLookup({ phase: "found", token: result.token });
8716
+ return;
8717
+ }
8718
+ setLookup({
8719
+ phase: "rejected",
8720
+ message: result.status === "invalid-address" ? "That is not a contract address." : `No token found at this address. ${result.reason}`
8721
+ });
8722
+ });
8723
+ return () => {
8724
+ cancelled = true;
8725
+ };
8726
+ }, [address, chain.id, publicClient]);
8727
+ const token = lookup.phase === "found" ? lookup.token : null;
8728
+ const collides = token ? existingSymbols.has(token.symbol.toLowerCase()) : false;
8729
+ const alreadyListed = token ? listedIdentities.has(fluentTokenIdentity(token)) : false;
8730
+ const handleAdd = () => {
8731
+ if (!token) return;
8732
+ const result = onAdd(token);
8733
+ switch (result.status) {
8734
+ case "added":
8735
+ onClose();
8736
+ return;
8737
+ case "already-present":
8738
+ setAddError("This token is already on your list.");
8739
+ return;
8740
+ case "at-capacity":
8741
+ setAddError(`You can add up to ${result.limit} tokens per network.`);
8742
+ return;
8743
+ default:
8744
+ setAddError("This token could not be added.");
8745
+ }
8746
+ };
8747
+ return /* @__PURE__ */ jsxs(
8748
+ "div",
7943
8749
  {
7944
- "data-slot": "toast-icon",
7945
- className: "shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
7946
- children: icon
8750
+ className: "flex flex-col gap-3 rounded-xl bg-white/5 p-3",
8751
+ "aria-label": "Add a token",
8752
+ children: [
8753
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
8754
+ "Paste the token's contract address on ",
8755
+ chain.name,
8756
+ ". Its name and decimals are read from the contract."
8757
+ ] }),
8758
+ /* @__PURE__ */ jsx(
8759
+ "input",
8760
+ {
8761
+ "aria-label": "Token contract address",
8762
+ className: "w-full rounded-lg bg-black/30 px-2.5 py-2 font-mono text-xs leading-5 ring-1 ring-foreground/10 outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-foreground/30",
8763
+ placeholder: "0x\u2026",
8764
+ spellCheck: false,
8765
+ autoComplete: "off",
8766
+ autoFocus: true,
8767
+ value: address,
8768
+ onChange: (event) => {
8769
+ setAddError(null);
8770
+ setAddress(event.target.value);
8771
+ }
8772
+ }
8773
+ ),
8774
+ lookup.phase === "loading" ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Reading the contract\u2026" }) : null,
8775
+ lookup.phase === "rejected" ? /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: lookup.message }) : null,
8776
+ token ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 rounded-lg bg-black/30 p-2.5", children: [
8777
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [
8778
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: token.symbol }),
8779
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
8780
+ token.decimals,
8781
+ " decimals"
8782
+ ] })
8783
+ ] }),
8784
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: token.name }),
8785
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-[11px] leading-4 break-all text-muted-foreground", children: token.address })
8786
+ ] }) : null,
8787
+ alreadyListed ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "This token is already on your list." }) : null,
8788
+ collides && !alreadyListed ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2 rounded-lg bg-destructive/10 p-2.5 text-xs text-destructive", children: [
8789
+ /* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }),
8790
+ /* @__PURE__ */ jsxs("span", { children: [
8791
+ "A token called ",
8792
+ token?.symbol,
8793
+ " is already on your list. Check the address above matches the token you mean \u2014 anyone can deploy a token using someone else's symbol."
8794
+ ] })
8795
+ ] }) : null,
8796
+ addError ? /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: addError }) : null,
8797
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
8798
+ /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", className: "rounded-full px-3", onClick: onClose, children: "Cancel" }),
8799
+ /* @__PURE__ */ jsx(
8800
+ Button,
8801
+ {
8802
+ size: "sm",
8803
+ className: "rounded-full px-3",
8804
+ disabled: !token || alreadyListed,
8805
+ onClick: handleAdd,
8806
+ children: collides && !alreadyListed ? "Add anyway" : "Add token"
8807
+ }
8808
+ )
8809
+ ] })
8810
+ ]
7947
8811
  }
7948
8812
  );
7949
8813
  }
7950
- function ToastList() {
7951
- const { toasts } = Toast$1.useToastManager();
7952
- return toasts.map((toastItem) => /* @__PURE__ */ jsx(Toast, { toast: toastItem, children: /* @__PURE__ */ jsxs(ToastContent, { children: [
7953
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
7954
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
7955
- /* @__PURE__ */ jsx(ToastIcon, { type: toastItem.type }),
7956
- /* @__PURE__ */ jsx(ToastTitle, {})
7957
- ] }),
7958
- /* @__PURE__ */ jsx(ToastDescription, {})
7959
- ] }),
7960
- /* @__PURE__ */ jsx(ToastAction, {}),
7961
- /* @__PURE__ */ jsx(ToastClose, {})
7962
- ] }) }, toastItem.id));
7963
- }
7964
- function Toaster({
7965
- children,
7966
- toastManager = toast,
7967
- ...props
7968
- }) {
7969
- return /* @__PURE__ */ jsxs(ToastProvider, { toastManager, ...props, children: [
7970
- children,
7971
- /* @__PURE__ */ jsx(ToastPortal, { children: /* @__PURE__ */ jsx(ToastViewport, { children: /* @__PURE__ */ jsx(ToastList, {}) }) })
7972
- ] });
7973
- }
7974
- Toast$1.createToastManager;
7975
- Toast$1.useToastManager;
7976
-
7977
- // src/utils/formatAddress.ts
7978
- function formatAddress(address) {
7979
- return `${address.slice(0, 6)}...${address.slice(-4)}`;
7980
- }
7981
-
7982
- // src/utils/copyAddress.ts
7983
- async function copyAddressToClipboard(address) {
7984
- try {
7985
- await navigator.clipboard.writeText(address);
7986
- toast.add({
7987
- type: "success",
7988
- title: "Address copied",
7989
- description: formatAddress(address)
7990
- });
7991
- } catch (error) {
7992
- debugWarn("[fluent connect] Failed to copy address", error);
7993
- toast.add({
7994
- type: "error",
7995
- title: "Copy failed",
7996
- description: "Could not copy address to clipboard."
7997
- });
7998
- }
7999
- }
8000
8814
  var TooltipProvider = Tooltip$1.Provider;
8001
8815
  var Tooltip = Tooltip$1.Root;
8002
8816
  function TooltipTrigger({ className, ...props }) {
@@ -8041,139 +8855,201 @@ function TooltipContent({
8041
8855
  }
8042
8856
  ) });
8043
8857
  }
8044
- var tokenIcons = {
8045
- ETH: "eth",
8046
- USDnr: "usdnr",
8047
- BLEND: "fluent"
8048
- };
8049
- var tokenIconClassName = {
8050
- ETH: "size-6 text-white",
8051
- USDnr: "size-6 text-white",
8052
- BLEND: "size-4"
8858
+ var VISUAL_BY_DEFAULT_SYMBOL = {
8859
+ // ETH/USDnr glyphs sit on fixed brand-colored tiles, so they stay white
8860
+ // regardless of the host's foreground override.
8861
+ ETH: { icon: "eth", iconClassName: "size-6 text-white", bgClassName: "bg-[#627EEA]" },
8862
+ USDnr: { icon: "usdnr", iconClassName: "size-6 text-white", bgClassName: "bg-[#7f52d0]" },
8863
+ BLEND: { icon: "fluent", iconClassName: "size-4", bgClassName: "bg-[#FFFFFF]/10" }
8053
8864
  };
8054
- var tokenBgClassName = {
8055
- ETH: "bg-[#627EEA]",
8056
- USDnr: "bg-[#7f52d0]",
8057
- BLEND: "bg-[#FFFFFF]/10"
8058
- };
8059
- function WalletMenuGasPayment({
8865
+ function WalletMenuTokenList({
8060
8866
  accountAddress,
8061
8867
  balances,
8062
8868
  busy,
8063
8869
  usdPrices = {},
8064
- bridgeUrl: _bridgeUrl,
8065
- ethValueByToken: _ethValueByToken,
8066
- tokens = fluentDefaultGasTokens,
8067
- selectedSymbol
8870
+ tokens,
8871
+ selectedSymbol,
8872
+ onAddUserToken,
8873
+ onRemoveUserToken
8068
8874
  }) {
8069
- const gasTokens = useMemo(() => getFluentGasPaymentTokens(tokens), [tokens]);
8875
+ const [addOpen, setAddOpen] = useState(false);
8876
+ const gasTokenIdentities = useMemo(
8877
+ () => new Set(getFluentGasPaymentTokens(tokens).map((token) => token.identity)),
8878
+ [tokens]
8879
+ );
8880
+ const collidingSymbols = useMemo(() => findFluentSymbolCollisions(tokens), [tokens]);
8881
+ const existingSymbols = useMemo(
8882
+ () => new Set(tokens.map((token) => token.symbol.toLowerCase())),
8883
+ [tokens]
8884
+ );
8885
+ const listedIdentities = useMemo(() => new Set(tokens.map((token) => token.identity)), [tokens]);
8886
+ const balanceByIdentity = useMemo(
8887
+ () => new Map(balances.map((balance) => [fluentTokenIdentity(balance), balance])),
8888
+ [balances]
8889
+ );
8070
8890
  const sortedRows = useMemo(
8071
- () => gasTokens.map((token, index) => ({
8072
- token,
8073
- balance: balances.find((item) => item.symbol === token.symbol),
8074
- index
8075
- })).sort((left, right) => {
8076
- const leftRaw = getComparableBalance(left.balance);
8077
- const rightRaw = getComparableBalance(right.balance);
8078
- if (leftRaw === rightRaw) return left.index - right.index;
8079
- return rightRaw > leftRaw ? 1 : -1;
8891
+ () => tokens.map((token, index) => {
8892
+ const balance = balanceByIdentity.get(token.identity);
8893
+ return { token, balance, index, comparable: getComparableBalance(balance) };
8894
+ }).sort((left, right) => {
8895
+ if (left.comparable === right.comparable) return left.index - right.index;
8896
+ return right.comparable > left.comparable ? 1 : -1;
8080
8897
  }),
8081
- [balances, gasTokens]
8898
+ [balanceByIdentity, tokens]
8082
8899
  );
8083
- return /* @__PURE__ */ jsx(TooltipProvider, { delay: 200, children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", "aria-label": "Gas payment tokens", children: sortedRows.map(({ token, balance }) => {
8084
- const symbol = token.symbol;
8085
- const unavailable = balance?.status === "not-configured";
8086
- const failed = balance?.status === "error";
8087
- const iconName = tokenIcons[symbol];
8088
- const active = selectedSymbol === symbol;
8089
- const formatted = balance?.status === "ready" ? formatFluentGasTokenBalance(balance, 0) ?? (balance.formatted ? formatFluentLocaleAmount(balance.formatted, 0) : null) : null;
8090
- const usdValueLabel = formatTokenUsdValue(balance, usdPrices[symbol]);
8091
- const exactBalance = balance?.status === "ready" && balance.formatted?.includes(".") ? balance.formatted : null;
8092
- return /* @__PURE__ */ jsxs(
8093
- "div",
8094
- {
8095
- className: "flex w-full items-center gap-3 rounded-xl",
8096
- children: [
8097
- /* @__PURE__ */ jsx(
8098
- "span",
8099
- {
8100
- className: `flex size-10 shrink-0 items-center justify-center rounded-lg ${tokenBgClassName[symbol] ?? "bg-white/10"}`,
8101
- children: iconName ? /* @__PURE__ */ jsx(
8102
- Icon,
8103
- {
8104
- name: iconName,
8105
- className: tokenIconClassName[symbol] ?? "size-6 text-foreground"
8106
- }
8107
- ) : /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: symbol.slice(0, 1) })
8108
- }
8109
- ),
8110
- /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col items-start gap-0.5", children: [
8111
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-sm font-medium leading-4", children: [
8112
- symbol,
8113
- active && /* @__PURE__ */ jsx("span", { className: "rounded-md bg-white/15 px-1.5 leading-[18px] text-[10px] font-normal text-muted-foreground -my-px", children: "Gas" })
8114
- ] }),
8115
- token.address ? /* @__PURE__ */ jsxs(
8116
- Select,
8900
+ return /* @__PURE__ */ jsx(TooltipProvider, { delay: 200, children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", "aria-label": "Token balances", children: [
8901
+ sortedRows.map(({ token, balance }) => {
8902
+ const identity = token.identity;
8903
+ const symbol = token.symbol;
8904
+ const unavailable = balance?.status === "not-configured";
8905
+ const failed = balance?.status === "error";
8906
+ const visual = isFluentDefaultToken(token) ? VISUAL_BY_DEFAULT_SYMBOL[token.symbol] : void 0;
8907
+ const active = selectedSymbol === symbol && gasTokenIdentities.has(identity);
8908
+ const formatted = balance?.status === "ready" ? formatFluentGasTokenBalance(balance, 0) ?? (balance.formatted ? formatFluentLocaleAmount(balance.formatted, 0) : null) : null;
8909
+ const usdValueLabel = formatTokenUsdValue(balance, usdPrices[identity]);
8910
+ const exactBalance = balance?.status === "ready" && balance.formatted?.includes(".") ? balance.formatted : null;
8911
+ return /* @__PURE__ */ jsxs(
8912
+ "div",
8913
+ {
8914
+ className: "flex w-full items-center gap-3 rounded-xl",
8915
+ children: [
8916
+ /* @__PURE__ */ jsx(
8917
+ "span",
8117
8918
  {
8118
- value: null,
8119
- onValueChange: (value) => {
8120
- if (value === "copy" && token.address) {
8121
- void copyAddressToClipboard(token.address);
8122
- }
8123
- },
8124
- children: [
8919
+ className: `flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg ${visual?.bgClassName ?? "bg-foreground/10"}`,
8920
+ children: visual ? /* @__PURE__ */ jsx(Icon, { name: visual.icon, className: visual.iconClassName }) : token.logoURI ? (
8921
+ // Rendered as an <img>, never inlined: a logo URL is data from
8922
+ // an integrator or a stranger's contract, and inlining SVG
8923
+ // from either would execute their markup in the widget.
8125
8924
  /* @__PURE__ */ jsx(
8126
- SelectTrigger,
8925
+ "img",
8127
8926
  {
8128
- "aria-label": `Token address actions for ${symbol}`,
8129
- className: "!h-auto max-w-full gap-0.5 border-0 bg-transparent p-0 text-xs leading-4 opacity-100 shadow-none hover:opacity-80 dark:bg-transparent dark:hover:bg-transparent [&_svg]:size-3 [&_svg]:opacity-0 hover:[&_svg]:opacity-70 aria-expanded:opacity-80 aria-expanded:[&_svg]:opacity-70",
8130
- children: /* @__PURE__ */ jsx("span", { className: "truncate", children: formatAddress(token.address) })
8927
+ src: token.logoURI,
8928
+ alt: "",
8929
+ "aria-hidden": "true",
8930
+ loading: "lazy",
8931
+ decoding: "async",
8932
+ className: "size-10 object-contain"
8131
8933
  }
8132
- ),
8133
- /* @__PURE__ */ jsx(SelectContent, { align: "start", alignItemWithTrigger: false, children: /* @__PURE__ */ jsxs(SelectItem, { value: "copy", children: [
8134
- /* @__PURE__ */ jsx(Copy, { className: "size-4" }),
8135
- "Copy address"
8136
- ] }) })
8137
- ]
8934
+ )
8935
+ ) : /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: symbol.slice(0, 1) })
8138
8936
  }
8139
- ) : /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs leading-4 text-muted-foreground", children: symbol === "ETH" ? "Native" : "No address" })
8140
- ] }),
8141
- /* @__PURE__ */ jsxs("span", { className: "flex flex-col items-end gap-0.5 tabular-nums", children: [
8142
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium leading-4", children: exactBalance ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8143
- /* @__PURE__ */ jsx(
8144
- TooltipTrigger,
8937
+ ),
8938
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col items-start gap-0.5", children: [
8939
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-sm font-medium leading-4", children: [
8940
+ symbol,
8941
+ active && /* @__PURE__ */ jsx("span", { className: "rounded-md bg-foreground/15 px-1.5 leading-[18px] text-[10px] font-normal text-muted-foreground -my-px", children: "Gas" }),
8942
+ token.source === "user" && /* @__PURE__ */ jsx("span", { className: "rounded-md bg-foreground/15 px-1.5 leading-[18px] text-[10px] font-normal text-muted-foreground -my-px", children: "Added by you" }),
8943
+ collidingSymbols.has(symbol.toLowerCase()) && /* @__PURE__ */ jsxs(Tooltip, { children: [
8944
+ /* @__PURE__ */ jsx(
8945
+ TooltipTrigger,
8946
+ {
8947
+ tabIndex: 0,
8948
+ "aria-label": `More than one token on this list calls itself ${symbol}`,
8949
+ render: /* @__PURE__ */ jsx("span", { className: "cursor-default rounded-sm" }),
8950
+ children: /* @__PURE__ */ jsx(AlertTriangle, { className: "size-3.5 text-destructive" })
8951
+ }
8952
+ ),
8953
+ /* @__PURE__ */ jsxs(TooltipContent, { children: [
8954
+ "More than one token here calls itself ",
8955
+ symbol,
8956
+ ". Check the address."
8957
+ ] })
8958
+ ] })
8959
+ ] }),
8960
+ token.address ? /* @__PURE__ */ jsxs(
8961
+ Select,
8145
8962
  {
8146
- tabIndex: 0,
8147
- "aria-label": `${symbol} balance: ${exactBalance}`,
8148
- render: /* @__PURE__ */ jsx("span", { className: "cursor-default rounded-sm" }),
8149
- children: renderBalanceLabel({
8150
- formatted,
8151
- unavailable,
8152
- failed,
8153
- isLoading: busy,
8154
- hasAccount: Boolean(accountAddress)
8155
- })
8963
+ value: null,
8964
+ onValueChange: (value) => {
8965
+ if (value === "copy" && token.address) {
8966
+ copyAddressToClipboard(token.address);
8967
+ }
8968
+ if (value === "remove" && token.address) {
8969
+ onRemoveUserToken?.({ chainId: token.chainId, address: token.address });
8970
+ }
8971
+ },
8972
+ children: [
8973
+ /* @__PURE__ */ jsx(
8974
+ SelectTrigger,
8975
+ {
8976
+ "aria-label": `Token address actions for ${symbol}`,
8977
+ className: "!h-auto max-w-full gap-0.5 border-0 bg-transparent p-0 text-xs leading-4 opacity-100 shadow-none hover:opacity-80 dark:bg-transparent dark:hover:bg-transparent [&_svg]:size-3 [&_svg]:opacity-0 hover:[&_svg]:opacity-70 aria-expanded:opacity-80 aria-expanded:[&_svg]:opacity-70",
8978
+ children: /* @__PURE__ */ jsx("span", { className: "truncate", children: formatAddress(token.address) })
8979
+ }
8980
+ ),
8981
+ /* @__PURE__ */ jsxs(SelectContent, { align: "start", alignItemWithTrigger: false, children: [
8982
+ /* @__PURE__ */ jsxs(SelectItem, { value: "copy", children: [
8983
+ /* @__PURE__ */ jsx(Copy, { className: "size-4" }),
8984
+ "Copy address"
8985
+ ] }),
8986
+ token.source === "user" && onRemoveUserToken ? /* @__PURE__ */ jsxs(SelectItem, { value: "remove", children: [
8987
+ /* @__PURE__ */ jsx(Trash2, { className: "size-4" }),
8988
+ "Remove token"
8989
+ ] }) : null
8990
+ ] })
8991
+ ]
8156
8992
  }
8157
- ),
8158
- /* @__PURE__ */ jsxs(TooltipContent, { className: "tabular-nums break-all", children: [
8159
- exactBalance,
8160
- " ",
8161
- symbol
8162
- ] })
8163
- ] }) : renderBalanceLabel({
8164
- formatted,
8165
- unavailable,
8166
- failed,
8167
- isLoading: busy,
8168
- hasAccount: Boolean(accountAddress)
8169
- }) }),
8170
- usdValueLabel ? /* @__PURE__ */ jsx("span", { className: "text-xs leading-4 opacity-50", children: usdValueLabel }) : null
8171
- ] })
8993
+ ) : /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs leading-4 text-muted-foreground", children: isFluentNativeToken(token) ? "Native" : "No address" })
8994
+ ] }),
8995
+ /* @__PURE__ */ jsxs("span", { className: "flex flex-col items-end gap-0.5 tabular-nums", children: [
8996
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium leading-4", children: exactBalance ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8997
+ /* @__PURE__ */ jsx(
8998
+ TooltipTrigger,
8999
+ {
9000
+ tabIndex: 0,
9001
+ "aria-label": `${symbol} balance: ${exactBalance}`,
9002
+ render: /* @__PURE__ */ jsx("span", { className: "cursor-default rounded-sm" }),
9003
+ children: renderBalanceLabel({
9004
+ formatted,
9005
+ unavailable,
9006
+ failed,
9007
+ isLoading: busy,
9008
+ hasAccount: Boolean(accountAddress)
9009
+ })
9010
+ }
9011
+ ),
9012
+ /* @__PURE__ */ jsxs(TooltipContent, { className: "tabular-nums break-all", children: [
9013
+ exactBalance,
9014
+ " ",
9015
+ symbol
9016
+ ] })
9017
+ ] }) : renderBalanceLabel({
9018
+ formatted,
9019
+ unavailable,
9020
+ failed,
9021
+ isLoading: busy,
9022
+ hasAccount: Boolean(accountAddress)
9023
+ }) }),
9024
+ usdValueLabel ? /* @__PURE__ */ jsx("span", { className: "text-xs leading-4 opacity-50", children: usdValueLabel }) : null
9025
+ ] })
9026
+ ]
9027
+ },
9028
+ identity
9029
+ );
9030
+ }),
9031
+ onAddUserToken && !addOpen ? /* @__PURE__ */ jsxs(
9032
+ "button",
9033
+ {
9034
+ type: "button",
9035
+ onClick: () => setAddOpen(true),
9036
+ className: "flex w-full items-center gap-3 rounded-xl text-left hover:opacity-80",
9037
+ children: [
9038
+ /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center rounded-lg bg-foreground/10", children: /* @__PURE__ */ jsx(Plus, { className: "size-4" }) }),
9039
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium leading-4", children: "Add token" })
8172
9040
  ]
8173
- },
8174
- symbol
8175
- );
8176
- }) }) }) });
9041
+ }
9042
+ ) : null,
9043
+ onAddUserToken && addOpen ? /* @__PURE__ */ jsx(
9044
+ AddTokenForm,
9045
+ {
9046
+ existingSymbols,
9047
+ listedIdentities,
9048
+ onAdd: onAddUserToken,
9049
+ onClose: () => setAddOpen(false)
9050
+ }
9051
+ ) : null
9052
+ ] }) }) });
8177
9053
  }
8178
9054
  function formatTokenUsdValue(balance, usdPrice) {
8179
9055
  if (!balance || balance.status !== "ready" || balance.formatted === null) return null;
@@ -8196,7 +9072,7 @@ function renderBalanceLabel({
8196
9072
  return /* @__PURE__ */ jsx(
8197
9073
  "span",
8198
9074
  {
8199
- className: "inline-block h-4 w-16 animate-pulse rounded-md bg-white/10",
9075
+ className: "inline-block h-4 w-16 animate-pulse rounded-md bg-foreground/10",
8200
9076
  "aria-label": "Loading balance"
8201
9077
  }
8202
9078
  );
@@ -8256,22 +9132,22 @@ function ReputationFamilyCard({ family, tier }) {
8256
9132
  const accent = FLUENT_FAMILY_ACCENTS[family] ?? FLUENT_FAMILY_FALLBACK_ACCENT;
8257
9133
  const labels = FLUENT_FAMILY_LABELS[family];
8258
9134
  const progress = FLUENT_FAMILY_TIER_PROGRESS[tier] ?? 0;
8259
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5 rounded-xl border border-white/15 bg-black/40 p-3", children: [
8260
- /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium uppercase tracking-[0.06em] text-white/60", children: FLUENT_FAMILY_DISPLAY_NAMES[family] ?? family }),
9135
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5 rounded-xl border border-foreground/15 bg-background/40 p-3", children: [
9136
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium uppercase tracking-[0.06em] text-foreground/60", children: FLUENT_FAMILY_DISPLAY_NAMES[family] ?? family }),
8261
9137
  /* @__PURE__ */ jsx(
8262
9138
  "div",
8263
9139
  {
8264
- className: "flex w-fit max-w-full items-center rounded-full border-[0.5px] border-white/20 px-2.5 py-0.5",
9140
+ className: "flex w-fit max-w-full items-center rounded-full border-[0.5px] border-foreground/20 px-2.5 py-0.5",
8265
9141
  style: { backgroundImage: `linear-gradient(90deg, ${accent.from}28, ${accent.to}28)` },
8266
- children: /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-medium uppercase leading-5 text-white/85", children: labels?.[tier] ?? "Reputation signal" })
9142
+ children: /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-medium uppercase leading-5 text-foreground/85", children: labels?.[tier] ?? "Reputation signal" })
8267
9143
  }
8268
9144
  ),
8269
9145
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
8270
9146
  labels ? /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-3", children: [
8271
- /* @__PURE__ */ jsx("span", { className: "truncate text-[9px] font-medium uppercase tracking-[0.06em] text-white/40", children: labels.D }),
8272
- /* @__PURE__ */ jsx("span", { className: "truncate text-[9px] font-medium uppercase tracking-[0.06em] text-white/70", children: labels.A })
9147
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[9px] font-medium uppercase tracking-[0.06em] text-foreground/40", children: labels.D }),
9148
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[9px] font-medium uppercase tracking-[0.06em] text-foreground/70", children: labels.A })
8273
9149
  ] }) : null,
8274
- /* @__PURE__ */ jsx("div", { className: "h-1.5 w-full overflow-hidden rounded-full bg-white/15", children: /* @__PURE__ */ jsx(
9150
+ /* @__PURE__ */ jsx("div", { className: "h-1.5 w-full overflow-hidden rounded-full bg-foreground/15", children: /* @__PURE__ */ jsx(
8275
9151
  "div",
8276
9152
  {
8277
9153
  className: "h-full rounded-full",
@@ -8290,7 +9166,7 @@ function ReputationNotice({
8290
9166
  description,
8291
9167
  action
8292
9168
  }) {
8293
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 rounded-xl bg-white/5 px-4 py-8 text-center", children: [
9169
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 rounded-xl bg-foreground/5 px-4 py-8 text-center", children: [
8294
9170
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
8295
9171
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: title }),
8296
9172
  /* @__PURE__ */ jsx("span", { className: "text-xs opacity-50", children: description })
@@ -8405,13 +9281,19 @@ function WalletMenuActionCard({
8405
9281
  openExternalUrl(explorerAddress(actionAddress, resolvedConfig.network), "explorer", track);
8406
9282
  };
8407
9283
  const accountAddress = connectedAddress ?? actionAddress;
8408
- const { balances, busy: balancesBusy, gasTokens } = useFluentTokenBalances({
9284
+ const {
9285
+ balances,
9286
+ busy: balancesBusy,
9287
+ displayTokens,
9288
+ gasTokens,
9289
+ addUserToken,
9290
+ removeUserToken
9291
+ } = useFluentTokenBalances({
8409
9292
  accountAddress,
8410
9293
  tokens,
8411
9294
  revisionCounter: balanceRevisionCounter
8412
9295
  });
8413
- const priceSymbols = useMemo(() => gasTokens.map((token) => token.symbol), [gasTokens]);
8414
- const { prices, pricesYesterday, busy: pricesBusy } = useFluentTokenUsdPrices(priceSymbols);
9296
+ const { prices, pricesYesterday, busy: pricesBusy } = useFluentTokenUsdPrices(displayTokens);
8415
9297
  const portfolioTotal = useMemo(
8416
9298
  () => sumFluentTokenBalancesUsd(balances, prices),
8417
9299
  [balances, prices]
@@ -8480,7 +9362,7 @@ function WalletMenuActionCard({
8480
9362
  children: /* @__PURE__ */ jsx(SelectValue, {})
8481
9363
  }
8482
9364
  ),
8483
- /* @__PURE__ */ jsx(SelectContent, { align: "end", alignItemWithTrigger: false, children: FLUENT_GAS_PAYMENT_PRIORITY.map((symbol) => /* @__PURE__ */ jsx(SelectItem, { value: symbol, children: symbol }, symbol)) })
9365
+ /* @__PURE__ */ jsx(SelectContent, { align: "end", alignItemWithTrigger: false, children: gasTokens.map((token) => /* @__PURE__ */ jsx(SelectItem, { value: token.symbol, children: token.symbol }, token.symbol)) })
8484
9366
  ]
8485
9367
  }
8486
9368
  )
@@ -8519,12 +9401,12 @@ function WalletMenuActionCard({
8519
9401
  ] }),
8520
9402
  /* @__PURE__ */ jsxs(TabsContent, { value: "home", className: "flex flex-col gap-4 pt-2", children: [
8521
9403
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
8522
- /* @__PURE__ */ jsx("div", { className: "relative overflow-hidden rounded-xl px-4 py-8 bg-white/5", children: /* @__PURE__ */ jsxs("div", { className: "relative z-10 flex flex-col items-center gap-1", children: [
9404
+ /* @__PURE__ */ jsx("div", { className: "relative overflow-hidden rounded-xl px-4 py-8 bg-foreground/5", children: /* @__PURE__ */ jsxs("div", { className: "relative z-10 flex flex-col items-center gap-1", children: [
8523
9405
  /* @__PURE__ */ jsx("div", { className: "tracking-[.05em] leading-none", children: portfolioDisplay ? /* @__PURE__ */ jsxs(Fragment, { children: [
8524
9406
  /* @__PURE__ */ jsx("span", { className: "mr-1 text-3xl font-semibold", children: "$" }),
8525
9407
  /* @__PURE__ */ jsx("span", { className: "text-3xl font-semibold", children: portfolioDisplay.whole }),
8526
9408
  /* @__PURE__ */ jsxs("span", { className: "text-lg font-semibold opacity-50", children: [
8527
- ",",
9409
+ portfolioDisplay.separator,
8528
9410
  portfolioDisplay.fraction
8529
9411
  ] })
8530
9412
  ] }) : portfolioLoading ? /* @__PURE__ */ jsxs(
@@ -8537,9 +9419,12 @@ function WalletMenuActionCard({
8537
9419
  /* @__PURE__ */ jsxs("span", { className: "invisible", "aria-hidden": "true", children: [
8538
9420
  /* @__PURE__ */ jsx("span", { className: "mr-1 text-3xl font-semibold", children: "$" }),
8539
9421
  /* @__PURE__ */ jsx("span", { className: "text-3xl font-semibold", children: "0" }),
8540
- /* @__PURE__ */ jsx("span", { className: "text-lg font-semibold", children: ",00" })
9422
+ /* @__PURE__ */ jsxs("span", { className: "text-lg font-semibold", children: [
9423
+ FLUENT_DECIMAL_SEPARATOR,
9424
+ "00"
9425
+ ] })
8541
9426
  ] }),
8542
- /* @__PURE__ */ jsx("span", { className: "absolute inset-0 animate-pulse rounded-md bg-white/10" })
9427
+ /* @__PURE__ */ jsx("span", { className: "absolute inset-0 animate-pulse rounded-md bg-foreground/10" })
8543
9428
  ]
8544
9429
  }
8545
9430
  ) : portfolioUnavailable ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -8548,7 +9433,10 @@ function WalletMenuActionCard({
8548
9433
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
8549
9434
  /* @__PURE__ */ jsx("span", { className: "mr-1 text-3xl font-semibold", children: "$" }),
8550
9435
  /* @__PURE__ */ jsx("span", { className: "text-3xl font-semibold", children: "0" }),
8551
- /* @__PURE__ */ jsx("span", { className: "text-lg font-semibold opacity-50", children: ",00" })
9436
+ /* @__PURE__ */ jsxs("span", { className: "text-lg font-semibold opacity-50", children: [
9437
+ FLUENT_DECIMAL_SEPARATOR,
9438
+ "00"
9439
+ ] })
8552
9440
  ] }) }),
8553
9441
  /* @__PURE__ */ jsx("div", { className: "flex min-h-4 items-center gap-1.5 text-xs font-medium leading-none", children: portfolioPnl ? /* @__PURE__ */ jsxs(Fragment, { children: [
8554
9442
  /* @__PURE__ */ jsx("span", { className: "inline-flex items-center gap-0.5", children: formatFluentPortfolioPnlAbsolute(portfolioPnl.delta) }),
@@ -8576,20 +9464,36 @@ function WalletMenuActionCard({
8576
9464
  "aria-label": "Loading portfolio pnl",
8577
9465
  children: [
8578
9466
  /* @__PURE__ */ jsxs("span", { className: "invisible inline-flex items-center gap-1.5", "aria-hidden": "true", children: [
8579
- /* @__PURE__ */ jsx("span", { className: "inline-flex items-center gap-0.5", children: "$ +0,00" }),
9467
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-0.5", children: [
9468
+ "$ +0",
9469
+ FLUENT_DECIMAL_SEPARATOR,
9470
+ "00"
9471
+ ] }),
8580
9472
  /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center", children: [
8581
9473
  /* @__PURE__ */ jsx(Icon, { name: "arrow-up-s-fill", className: "size-3.5" }),
8582
- /* @__PURE__ */ jsx("span", { children: "0,00%" })
9474
+ /* @__PURE__ */ jsxs("span", { children: [
9475
+ "0",
9476
+ FLUENT_DECIMAL_SEPARATOR,
9477
+ "00%"
9478
+ ] })
8583
9479
  ] })
8584
9480
  ] }),
8585
- /* @__PURE__ */ jsx("span", { className: "absolute inset-0 animate-pulse rounded-md bg-white/10" })
9481
+ /* @__PURE__ */ jsx("span", { className: "absolute inset-0 animate-pulse rounded-md bg-foreground/10" })
8586
9482
  ]
8587
9483
  }
8588
9484
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
8589
- /* @__PURE__ */ jsx("span", { className: "inline-flex items-center gap-0.5", children: "$ +0,00" }),
9485
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-0.5", children: [
9486
+ "$ +0",
9487
+ FLUENT_DECIMAL_SEPARATOR,
9488
+ "00"
9489
+ ] }),
8590
9490
  /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center text-green-400", children: [
8591
9491
  /* @__PURE__ */ jsx(Icon, { name: "arrow-up-s-fill", className: "size-3.5" }),
8592
- /* @__PURE__ */ jsx("span", { children: "0,00%" })
9492
+ /* @__PURE__ */ jsxs("span", { children: [
9493
+ "0",
9494
+ FLUENT_DECIMAL_SEPARATOR,
9495
+ "00%"
9496
+ ] })
8593
9497
  ] })
8594
9498
  ] }) })
8595
9499
  ] }) }),
@@ -8614,16 +9518,16 @@ function WalletMenuActionCard({
8614
9518
  ] })
8615
9519
  ] }),
8616
9520
  /* @__PURE__ */ jsx(
8617
- WalletMenuGasPayment,
9521
+ WalletMenuTokenList,
8618
9522
  {
8619
9523
  accountAddress,
8620
9524
  balances,
8621
9525
  busy: balancesBusy,
8622
9526
  usdPrices: prices,
8623
- bridgeUrl: resolvedConfig.bridgeUrl,
8624
- ethValueByToken: resolvedConfig.gasPayment.ethValueByToken,
8625
- tokens,
8626
- selectedSymbol: gasPaymentToken
9527
+ tokens: displayTokens,
9528
+ selectedSymbol: gasPaymentToken,
9529
+ onAddUserToken: addUserToken,
9530
+ onRemoveUserToken: removeUserToken
8627
9531
  }
8628
9532
  )
8629
9533
  ] }),
@@ -8639,10 +9543,10 @@ function WalletMenuActionCard({
8639
9543
  reputation.phase === "loading" ? /* @__PURE__ */ jsx(
8640
9544
  "div",
8641
9545
  {
8642
- className: "flex items-center justify-center rounded-xl bg-white/5 px-4 py-8",
9546
+ className: "flex items-center justify-center rounded-xl bg-foreground/5 px-4 py-8",
8643
9547
  "aria-busy": "true",
8644
9548
  "aria-label": "Loading reputation",
8645
- children: /* @__PURE__ */ jsx(Spinner, { className: "size-5 text-white/70" })
9549
+ children: /* @__PURE__ */ jsx(Spinner, { className: "size-5 text-foreground/70" })
8646
9550
  }
8647
9551
  ) : null,
8648
9552
  reputation.phase === "disconnected" ? /* @__PURE__ */ jsx(
@@ -8682,49 +9586,6 @@ function useIsMobile() {
8682
9586
  }, []);
8683
9587
  return !!isMobile;
8684
9588
  }
8685
-
8686
- // src/utils/clearPrivyRecentLoginMethod.ts
8687
- function clearPrivyRecentLoginMethod(appId) {
8688
- if (typeof window === "undefined" || !appId) return;
8689
- try {
8690
- window.localStorage.removeItem(`privy:${appId}:recent-login-method`);
8691
- window.localStorage.removeItem(`privy:${appId}:recent-login-wallet-client`);
8692
- window.localStorage.removeItem(`privy:${appId}:recent-login-chain-type`);
8693
- } catch {
8694
- }
8695
- }
8696
-
8697
- // src/utils/createLocalFluentSession.ts
8698
- function createLocalFluentSession(params) {
8699
- const issuedAt = Math.floor(Date.now() / 1e3);
8700
- const payload = {
8701
- iss: typeof location !== "undefined" ? location.origin : "fluent-local",
8702
- aud: params.app.clientId ?? params.app.origin,
8703
- sub: params.userId,
8704
- app: params.app,
8705
- scopes: params.scopes,
8706
- iat: issuedAt
8707
- };
8708
- return {
8709
- app: params.app,
8710
- clientId: params.app.clientId,
8711
- idToken: `mock.${btoa(JSON.stringify(payload))}.signature`,
8712
- user: {
8713
- id: params.userId,
8714
- email: params.email
8715
- },
8716
- wallet: {
8717
- signerAddress: params.signerAddress,
8718
- smartAccountAddress: params.smartAccountAddress
8719
- },
8720
- scopes: params.scopes,
8721
- issuedAt,
8722
- metadata: {
8723
- authMode: "direct",
8724
- origin: params.app.origin
8725
- }
8726
- };
8727
- }
8728
9589
  function BatchOperationReviewModal({
8729
9590
  operation,
8730
9591
  onConfirm,
@@ -8885,17 +9746,14 @@ function resolveGasPaymentSelection(params) {
8885
9746
  };
8886
9747
  }
8887
9748
  function useGasPaymentSelection(params) {
8888
- const { gasPaymentToken, tokens, network, silentSigningEnabled } = params;
8889
- const defaultGasTokens = useMemo(
8890
- () => getFluentDefaultGasTokens(network),
9749
+ const { gasPaymentToken, network, silentSigningEnabled } = params;
9750
+ const availableTokens = useMemo(
9751
+ () => getFluentDefaultWidgetGasTokens(network),
8891
9752
  [network]
8892
9753
  );
8893
9754
  const selectedGasPaymentToken = useMemo(
8894
- () => resolveGasPaymentSelection({
8895
- gasPaymentToken,
8896
- availableTokens: tokens ?? defaultGasTokens
8897
- }),
8898
- [gasPaymentToken, tokens, defaultGasTokens]
9755
+ () => resolveGasPaymentSelection({ gasPaymentToken, availableTokens }),
9756
+ [gasPaymentToken, availableTokens]
8899
9757
  );
8900
9758
  const defaultConfirmationMode = silentSigningEnabled ? "session" : "always";
8901
9759
  return { selectedGasPaymentToken, defaultConfirmationMode };
@@ -8936,106 +9794,6 @@ function useBatchReview(options) {
8936
9794
  );
8937
9795
  return { batchReview, confirmBatchOperation, acceptBatchReview, rejectBatchReview };
8938
9796
  }
8939
-
8940
- // src/utils/postJson.ts
8941
- var HttpError = class extends Error {
8942
- constructor(status, body) {
8943
- super(body?.message ?? body?.error ?? `Request failed with ${status}`);
8944
- this.status = status;
8945
- this.body = body;
8946
- this.name = "HttpError";
8947
- }
8948
- status;
8949
- body;
8950
- };
8951
- async function postJson(url, body, headers = {}) {
8952
- const response = await fetch(url, {
8953
- method: "POST",
8954
- headers: {
8955
- "Content-Type": "application/json",
8956
- ...headers
8957
- },
8958
- body: JSON.stringify(body)
8959
- });
8960
- if (!response.ok) {
8961
- let errorBody;
8962
- try {
8963
- errorBody = await response.json();
8964
- } catch {
8965
- errorBody = void 0;
8966
- }
8967
- throw new HttpError(response.status, errorBody);
8968
- }
8969
- return response.json();
8970
- }
8971
-
8972
- // src/utils/faucetToast.ts
8973
- function normalize(value) {
8974
- return (value ?? "").trim().toLowerCase();
8975
- }
8976
- function isAlreadyClaimed(status, message) {
8977
- const statusNorm = normalize(status);
8978
- const messageNorm = normalize(message);
8979
- return statusNorm.includes("already") || messageNorm.includes("already");
8980
- }
8981
- function toastFaucetSuccess(receipt) {
8982
- if (isAlreadyClaimed(receipt.status, receipt.message)) {
8983
- toast.add({
8984
- type: "info",
8985
- title: "Already claimed",
8986
- description: receipt.message || "BLEND faucet was already claimed for this account."
8987
- });
8988
- return;
8989
- }
8990
- toast.add({
8991
- type: "success",
8992
- title: "Faucet claimed",
8993
- description: receipt.message || (receipt.txHash ? `Transaction ${receipt.txHash}` : "BLEND was sent to your wallet.")
8994
- });
8995
- }
8996
- function toastFaucetError(error) {
8997
- if (error instanceof HttpError) {
8998
- if (isAlreadyClaimed(error.body?.status, error.message) || error.status === 409) {
8999
- toast.add({
9000
- type: "info",
9001
- title: "Already claimed",
9002
- description: error.message || "BLEND faucet was already claimed for this account."
9003
- });
9004
- return;
9005
- }
9006
- if (error.status === 429) {
9007
- toast.add({
9008
- type: "warning",
9009
- title: "Too many requests",
9010
- description: error.message || "Please wait a moment and try again."
9011
- });
9012
- return;
9013
- }
9014
- toast.add({
9015
- type: "error",
9016
- title: "Faucet request failed",
9017
- description: error.message || `Request failed with ${error.status}`
9018
- });
9019
- return;
9020
- }
9021
- toast.add({
9022
- type: "error",
9023
- title: "Faucet request failed",
9024
- description: error instanceof Error ? error.message : "Something went wrong."
9025
- });
9026
- }
9027
-
9028
- // src/utils/getAnonymousId.ts
9029
- function getAnonymousId() {
9030
- const storageKey = "fluent_demo_visitor_id";
9031
- const existing = localStorage.getItem(storageKey);
9032
- if (existing) return existing;
9033
- const next = crypto.randomUUID?.() ?? `visitor_${Date.now()}_${Math.random().toString(16).slice(2)}`;
9034
- localStorage.setItem(storageKey, next);
9035
- return next;
9036
- }
9037
-
9038
- // src/widget/hooks/useFaucet.ts
9039
9797
  function useFaucet(params) {
9040
9798
  const {
9041
9799
  session,
@@ -9187,7 +9945,7 @@ async function sendCallsViaExternalWallet(calls, wallet, chain, publicClient) {
9187
9945
  }
9188
9946
  const hash = hashes[hashes.length - 1];
9189
9947
  if (!hash) throw new Error("A Fluent batch operation requires at least one call");
9190
- return { hash, hashes, atomic: false };
9948
+ return { hash, hashes, atomic: false, sponsored: false };
9191
9949
  }
9192
9950
 
9193
9951
  // src/widget/hooks/useWidgetExecution.ts
@@ -9201,7 +9959,8 @@ function useWidgetExecution(params) {
9201
9959
  defaultConfirmationMode,
9202
9960
  selectedGasPaymentToken,
9203
9961
  confirmBatchOperation,
9204
- refreshBalances
9962
+ refreshBalances,
9963
+ track
9205
9964
  } = params;
9206
9965
  const eoaPublicClient = useMemo(
9207
9966
  () => createPublicClient({ chain, transport: createFluentRpcTransport(chain) }),
@@ -9210,9 +9969,10 @@ function useWidgetExecution(params) {
9210
9969
  const sendCalls = useCallback(
9211
9970
  async (calls, options) => {
9212
9971
  if (fluentAccountReady) {
9213
- const hash = await smartAccount.sendCalls(calls, options);
9972
+ const { hash, sponsored, sponsorshipReason, paymaster } = await smartAccount.sendCalls(calls, options);
9973
+ track("wallet_gas_sponsored", { sponsored, reason: sponsorshipReason });
9214
9974
  refreshBalances();
9215
- return { hash, hashes: [hash], atomic: true };
9975
+ return { hash, hashes: [hash], atomic: true, sponsored, paymaster };
9216
9976
  }
9217
9977
  if (wallet?.connected && wallet.walletClient) {
9218
9978
  const result = await sendCallsViaExternalWallet(calls, wallet, chain, eoaPublicClient);
@@ -9221,7 +9981,15 @@ function useWidgetExecution(params) {
9221
9981
  }
9222
9982
  throw new Error("No Fluent account is available to execute this operation");
9223
9983
  },
9224
- [wallet, chain, eoaPublicClient, fluentAccountReady, refreshBalances, smartAccount.sendCalls]
9984
+ [
9985
+ wallet,
9986
+ chain,
9987
+ eoaPublicClient,
9988
+ fluentAccountReady,
9989
+ refreshBalances,
9990
+ smartAccount.sendCalls,
9991
+ track
9992
+ ]
9225
9993
  );
9226
9994
  const createBatchOp = useCallback(
9227
9995
  (input) => createFluentBatchOp(input, {
@@ -9353,7 +10121,7 @@ function useHostedConnect(params) {
9353
10121
  const {
9354
10122
  fluentConnect,
9355
10123
  authorizeUrl,
9356
- clientId,
10124
+ partnerId,
9357
10125
  appName,
9358
10126
  authMode,
9359
10127
  setSession,
@@ -9375,10 +10143,10 @@ function useHostedConnect(params) {
9375
10143
  } catch {
9376
10144
  }
9377
10145
  const url = fluentConnect.buildAuthorizeUrl(state).toString();
9378
- debugLog("[fluent widget] open connect", { state, authorizeUrl: url, clientId, appName, authMode });
10146
+ debugLog("[fluent widget] open connect", { state, authorizeUrl: url, partnerId, appName, authMode });
9379
10147
  setHostedAuthorizeUrl(url);
9380
10148
  setConnectOpen(true);
9381
- }, [appName, authMode, clientId, fluentConnect, setConnectOpen]);
10149
+ }, [appName, authMode, partnerId, fluentConnect, setConnectOpen]);
9382
10150
  const acceptHostedResult = useCallback(
9383
10151
  (data) => {
9384
10152
  if (!data || typeof data !== "object") return;
@@ -9528,6 +10296,87 @@ function useAccountMenu(params) {
9528
10296
  }, [hasConnectedAccount, setAccountOpen]);
9529
10297
  return { openAccountMenu, handleAccountMenuAction };
9530
10298
  }
10299
+ function authTokenCacheKey(params) {
10300
+ return `${params.publicApiUrl}|${params.partnerId}|${params.subject}`;
10301
+ }
10302
+ function useAuthToken(params) {
10303
+ const {
10304
+ publicApiUrl,
10305
+ partnerId,
10306
+ authMode,
10307
+ renewalOffsetSeconds,
10308
+ accountType,
10309
+ privyUserId,
10310
+ getAccessToken,
10311
+ identityToken,
10312
+ walletAddress,
10313
+ walletClient
10314
+ } = params;
10315
+ const cache = useRef(null);
10316
+ const inFlight = useRef(null);
10317
+ return useCallback(async () => {
10318
+ if (authMode === "hosted") {
10319
+ throw new FluentAuthError(
10320
+ "hosted_not_supported",
10321
+ 'getAuthToken() needs authMode: "direct" \u2014 the hosted bridge does not hand over the Privy access token.'
10322
+ );
10323
+ }
10324
+ const subject = accountType === "smart" && privyUserId ? `privy:${privyUserId}` : accountType === "eoa" && walletAddress ? `wallet:${walletAddress.toLowerCase()}` : null;
10325
+ if (!subject) {
10326
+ throw new FluentAuthError("not_connected", "Connect a Fluent ID or an external wallet first.");
10327
+ }
10328
+ const key = authTokenCacheKey({ publicApiUrl, partnerId, subject });
10329
+ const cached = cache.current;
10330
+ if (cached?.key === key && cached.expiresAt - renewalOffsetSeconds * 1e3 > Date.now()) {
10331
+ return cached.token;
10332
+ }
10333
+ if (inFlight.current?.key === key) return inFlight.current.promise;
10334
+ const promise = (async () => {
10335
+ let token;
10336
+ if (subject.startsWith("privy:")) {
10337
+ const accessToken = await getAccessToken();
10338
+ if (!accessToken || !identityToken) {
10339
+ throw new FluentAuthError(
10340
+ "privy_token_missing",
10341
+ "Privy session is not ready; sign in again."
10342
+ );
10343
+ }
10344
+ token = await exchangePrivyAuthToken({ publicApiUrl, partnerId, accessToken, identityToken });
10345
+ } else {
10346
+ if (!walletClient) {
10347
+ throw new FluentAuthError("not_connected", "External wallet has no signer.");
10348
+ }
10349
+ token = await exchangeWalletAuthToken({
10350
+ publicApiUrl,
10351
+ partnerId,
10352
+ walletClient,
10353
+ address: walletAddress,
10354
+ origin: window.location.origin
10355
+ });
10356
+ }
10357
+ const expiresAt = readAuthTokenExpiry(token);
10358
+ if (expiresAt) cache.current = { key, token, expiresAt };
10359
+ return token;
10360
+ })();
10361
+ inFlight.current = { key, promise };
10362
+ try {
10363
+ return await promise;
10364
+ } finally {
10365
+ if (inFlight.current?.promise === promise) inFlight.current = null;
10366
+ }
10367
+ }, [
10368
+ accountType,
10369
+ authMode,
10370
+ renewalOffsetSeconds,
10371
+ partnerId,
10372
+ getAccessToken,
10373
+ identityToken,
10374
+ privyUserId,
10375
+ publicApiUrl,
10376
+ walletAddress,
10377
+ walletClient
10378
+ ]);
10379
+ }
9531
10380
  var DrawerContext = React2.createContext(null);
9532
10381
  function useDrawer() {
9533
10382
  const context = React2.useContext(DrawerContext);
@@ -9625,7 +10474,7 @@ function DrawerContent({
9625
10474
  "data-snap-points": hasSnapPoints ? "" : void 0,
9626
10475
  className: cn(
9627
10476
  // Base.
9628
- "group/drawer-popup pointer-events-auto fixed z-50 m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col rounded-[min(var(--radius-4xl),24px)] border border-white/10 bg-popover text-sm text-popover-foreground shadow-xl transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none select-none [--drawer-bleed-background:transparent] [--drawer-inset:--spacing(2)] [--drawer-stacked-shadow:0_-20px_25px_-5px_rgb(0_0_0/0.1),0_-8px_10px_-6px_rgb(0_0_0/0.1)] [interpolate-size:allow-keywords] data-[swipe-direction=down]:data-nested-drawer-open:shadow-(--drawer-stacked-shadow)",
10477
+ "group/drawer-popup pointer-events-auto fixed z-50 m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col rounded-[min(var(--radius-4xl),24px)] border border-foreground/10 bg-popover text-sm text-popover-foreground shadow-xl transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none select-none [--drawer-bleed-background:transparent] [--drawer-inset:--spacing(2)] [--drawer-stacked-shadow:0_-20px_25px_-5px_rgb(0_0_0/0.1),0_-8px_10px_-6px_rgb(0_0_0/0.1)] [interpolate-size:allow-keywords] data-[swipe-direction=down]:data-nested-drawer-open:shadow-(--drawer-stacked-shadow)",
9629
10478
  // Nested.
9630
10479
  "data-nested-drawer-open:overflow-hidden data-nested-drawer-open:brightness-95",
9631
10480
  // Bleed.
@@ -9696,49 +10545,60 @@ function DrawerTitle({ className, ...props }) {
9696
10545
  }
9697
10546
  );
9698
10547
  }
9699
- function FluentAccountDrawer(props) {
9700
- const {
9701
- accountOpen,
9702
- setAccountOpen,
9703
- hasConnectedAccount,
9704
- isMobile,
9705
- connectButton,
9706
- accountMenuAddress,
9707
- onAccountMenuAction,
9708
- settingsOpen = false,
9709
- onCloseSettings,
9710
- children
9711
- } = props;
10548
+ function FluentAccountDrawer({
10549
+ accountOpen,
10550
+ setAccountOpen,
10551
+ hasConnectedAccount,
10552
+ isMobile,
10553
+ connectButton,
10554
+ accountMenuAddress,
10555
+ onAccountMenuAction,
10556
+ settingsOpen,
10557
+ onCloseSettings,
10558
+ modal,
10559
+ disablePointerDismissal,
10560
+ children,
10561
+ userLogoUrl
10562
+ }) {
9712
10563
  return /* @__PURE__ */ jsxs(
9713
10564
  Drawer,
9714
10565
  {
9715
10566
  open: hasConnectedAccount && accountOpen,
9716
10567
  onOpenChange: setAccountOpen,
9717
10568
  swipeDirection: isMobile ? "down" : "right",
10569
+ modal,
10570
+ disablePointerDismissal,
9718
10571
  children: [
9719
10572
  connectButton,
9720
- hasConnectedAccount ? /* @__PURE__ */ jsxs(DrawerContent, { "aria-label": "Connected account", className: "dark text-white antialiased sm:w-96", children: [
10573
+ hasConnectedAccount ? /* @__PURE__ */ jsxs(DrawerContent, { "aria-label": "Connected account", className: "dark text-foreground antialiased sm:w-96", children: [
9721
10574
  /* @__PURE__ */ jsx(DrawerHeader, { className: "items-stretch p-4 pb-0", children: settingsOpen ? /* @__PURE__ */ jsxs("div", { className: "relative flex h-11 items-center justify-center", children: [
9722
10575
  /* @__PURE__ */ jsx(
9723
10576
  "button",
9724
10577
  {
9725
10578
  type: "button",
9726
10579
  "aria-label": "Back",
9727
- className: "absolute left-0 inline-flex size-8 items-center justify-center rounded-lg text-white/70 transition-colors hover:bg-white/5 hover:text-white",
10580
+ className: "absolute left-0 inline-flex size-8 items-center justify-center rounded-lg text-foreground/70 transition-colors hover:bg-foreground/5 hover:text-foreground",
9728
10581
  onClick: onCloseSettings,
9729
10582
  children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-5" })
9730
10583
  }
9731
10584
  ),
9732
- /* @__PURE__ */ jsx(DrawerTitle, { className: "text-sm font-medium leading-none text-white", children: "Settings" })
10585
+ /* @__PURE__ */ jsx(DrawerTitle, { className: "text-sm font-medium leading-none text-foreground", children: "Settings" })
9733
10586
  ] }) : accountMenuAddress ? /* @__PURE__ */ jsxs(Select, { value: null, onValueChange: onAccountMenuAction, children: [
9734
10587
  /* @__PURE__ */ jsxs(
9735
10588
  SelectTrigger,
9736
10589
  {
9737
10590
  "aria-label": "Account actions",
9738
- className: "!h-auto w-full gap-2 overflow-hidden rounded-xl border border-white/10 !bg-transparent p-1.5 pr-3 hover:border-white/20 hover:!bg-white/5 aria-expanded:border-white/20 aria-expanded:!bg-white/5",
10591
+ className: "!h-auto w-full gap-2 overflow-hidden rounded-xl border border-foreground/10 !bg-transparent p-1.5 pr-3 hover:border-foreground/20 hover:!bg-foreground/5 aria-expanded:border-foreground/20 aria-expanded:!bg-foreground/5",
9739
10592
  children: [
9740
- /* @__PURE__ */ jsx("div", { className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-white/10 text-white", children: /* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-3" }) }),
9741
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-left text-sm font-medium leading-none text-white", children: formatAddress(accountMenuAddress) })
10593
+ /* @__PURE__ */ jsx("div", { className: "flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-md bg-foreground/10 text-foreground", children: userLogoUrl ? /* @__PURE__ */ jsx(
10594
+ "img",
10595
+ {
10596
+ src: userLogoUrl,
10597
+ alt: "User logo",
10598
+ className: "size-full rounded-md object-cover"
10599
+ }
10600
+ ) : /* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-3" }) }),
10601
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-left text-sm font-medium leading-none text-foreground", children: formatAddress(accountMenuAddress) })
9742
10602
  ]
9743
10603
  }
9744
10604
  ),
@@ -9762,8 +10622,8 @@ function FluentAccountDrawer(props) {
9762
10622
  "Disconnect"
9763
10623
  ] })
9764
10624
  ] })
9765
- ] }) : /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-2 overflow-hidden rounded-xl border border-white/10 p-2 pr-3 shadow-2xl", children: [
9766
- /* @__PURE__ */ jsx("div", { className: "relative z-10 flex size-8 items-center justify-center rounded-md bg-white/10", children: /* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-3" }) }),
10625
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-2 overflow-hidden rounded-xl border border-foreground/10 p-2 pr-3 shadow-2xl", children: [
10626
+ /* @__PURE__ */ jsx("div", { className: "relative z-10 flex size-8 items-center justify-center rounded-md bg-foreground/10", children: /* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-3" }) }),
9767
10627
  /* @__PURE__ */ jsx("div", { className: "relative z-10 text-sm font-medium leading-none", children: "Connected" })
9768
10628
  ] }) }),
9769
10629
  /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-4", children })
@@ -9777,25 +10637,34 @@ function FluentWidgetConnectButton({
9777
10637
  pending: pending2 = false,
9778
10638
  addressLabel,
9779
10639
  onClick,
9780
- className
10640
+ className,
10641
+ userLogoUrl
9781
10642
  }) {
10643
+ const userLogo = userLogoUrl ? /* @__PURE__ */ jsx(
10644
+ "img",
10645
+ {
10646
+ src: userLogoUrl,
10647
+ alt: "User logo",
10648
+ className: "size-full rounded-md object-cover"
10649
+ }
10650
+ ) : /* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-3" });
9782
10651
  return /* @__PURE__ */ jsxs(
9783
10652
  "button",
9784
10653
  {
9785
10654
  type: "button",
9786
- className: className ?? "bg-black p-1.5 pr-3 rounded-xl flex items-center gap-2 text-white overflow-hidden relative group",
10655
+ className: className ?? "bg-background p-1.5 pr-3 rounded-xl flex items-center gap-2 text-foreground overflow-hidden relative group",
9787
10656
  "aria-expanded": connected || void 0,
9788
10657
  "aria-busy": pending2 || void 0,
9789
10658
  disabled: pending2,
9790
10659
  onClick,
9791
10660
  children: [
9792
- /* @__PURE__ */ jsx("div", { className: "size-8 bg-white/5 rounded-md flex items-center justify-center relative z-10 ", children: pending2 ? /* @__PURE__ */ jsx(Loader2, { className: "w-full animate-spin" }) : /* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-3" }) }),
10661
+ /* @__PURE__ */ jsx("div", { className: "size-8 bg-foreground/5 rounded-md flex items-center justify-center relative z-10 ", children: pending2 ? /* @__PURE__ */ jsx(Loader2, { className: "w-full animate-spin" }) : userLogo }),
9793
10662
  /* @__PURE__ */ jsx(
9794
10663
  "div",
9795
10664
  {
9796
10665
  className: "absolute z-[1] inset-0 h-[200%] opacity-25 group-hover:opacity-50 transition-all duration-250 ease-in-out -translate-y-0 group-hover:-translate-y-5 group-hover:h-[300%]",
9797
10666
  style: {
9798
- background: "radial-gradient(152.48% 152.48% at 50% 84.8%, #000 25.21%, #5011FF 53.1%)",
10667
+ background: "radial-gradient(152.48% 152.48% at 50% 84.8%, var(--background) 25.21%, var(--brand) 53.1%)",
9799
10668
  backgroundSize: "150% auto",
9800
10669
  backgroundPosition: "center center",
9801
10670
  backgroundRepeat: "no-repeat"
@@ -9807,19 +10676,19 @@ function FluentWidgetConnectButton({
9807
10676
  }
9808
10677
  );
9809
10678
  }
9810
- function FluentConnectButtonSlot(props) {
9811
- const {
9812
- hasConnectedAccount,
9813
- connecting,
9814
- externalWalletConnected,
9815
- connectedAddress,
9816
- fluentAccountAddress,
9817
- onTopConnectClick,
9818
- openConnect,
9819
- openAccount,
9820
- renderConnectButton,
9821
- connectButton
9822
- } = props;
10679
+ function FluentConnectButtonSlot({
10680
+ hasConnectedAccount,
10681
+ connecting,
10682
+ externalWalletConnected,
10683
+ connectedAddress,
10684
+ fluentAccountAddress,
10685
+ onTopConnectClick,
10686
+ openConnect,
10687
+ openAccount,
10688
+ renderConnectButton,
10689
+ connectButton,
10690
+ userLogoUrl
10691
+ }) {
9823
10692
  const connectAddressLabel = hasConnectedAccount ? externalWalletConnected ? connectedAddress ? formatAddress(connectedAddress) : "Connected" : fluentAccountAddress ? formatAddress(fluentAccountAddress) : "Connected" : void 0;
9824
10693
  const defaultConnectButton = /* @__PURE__ */ jsx(
9825
10694
  FluentWidgetConnectButton,
@@ -9827,7 +10696,8 @@ function FluentConnectButtonSlot(props) {
9827
10696
  connected: hasConnectedAccount,
9828
10697
  pending: connecting,
9829
10698
  addressLabel: connectAddressLabel,
9830
- onClick: onTopConnectClick
10699
+ onClick: onTopConnectClick,
10700
+ userLogoUrl
9831
10701
  }
9832
10702
  );
9833
10703
  const connectButtonContext = {
@@ -9841,50 +10711,6 @@ function FluentConnectButtonSlot(props) {
9841
10711
  };
9842
10712
  return renderConnectButton?.(connectButtonContext) ?? (connectButton === false ? null : connectButton === "inline" ? defaultConnectButton : /* @__PURE__ */ jsx("div", { className: "fixed top-5 right-5 z-50", children: defaultConnectButton }));
9843
10713
  }
9844
-
9845
- // src/utils/formatExternalWallet.ts
9846
- function formatExternalWallet(wallet, status) {
9847
- return JSON.stringify(
9848
- {
9849
- status: status ?? "Waiting for wallet connection",
9850
- wallet: wallet ? {
9851
- provider: "Reown AppKit",
9852
- configured: wallet.configured,
9853
- connected: wallet.connected,
9854
- address: wallet.address,
9855
- chainId: wallet.chainId
9856
- } : null,
9857
- walletConnectEnabled: Boolean(wallet?.configured)
9858
- },
9859
- null,
9860
- 2
9861
- );
9862
- }
9863
-
9864
- // src/utils/formatSession.ts
9865
- function formatSession(session) {
9866
- if (!session) return "Waiting for Fluent login";
9867
- return JSON.stringify(
9868
- {
9869
- app: {
9870
- mode: session.app.mode,
9871
- origin: session.app.origin,
9872
- installationId: session.app.installationId,
9873
- clientId: session.app.clientId,
9874
- appName: session.app.appName
9875
- },
9876
- user: session.user,
9877
- wallet: {
9878
- smartAccountAddress: session.wallet.smartAccountAddress
9879
- },
9880
- scopes: session.scopes,
9881
- issuedAt: session.issuedAt,
9882
- idToken: session.idToken
9883
- },
9884
- null,
9885
- 2
9886
- );
9887
- }
9888
10714
  function DebugPanel(props) {
9889
10715
  const { session, wallet, walletStatus, hostedError } = props;
9890
10716
  return /* @__PURE__ */ jsxs("section", { className: "overflow-hidden rounded-2xl border border-white/10 bg-black/70 text-white shadow-2xl backdrop-blur-md", children: [
@@ -9931,13 +10757,17 @@ function FluentWidgetContent({
9931
10757
  }) {
9932
10758
  const internalWallet = useReownWallet();
9933
10759
  const isMobile = useIsMobile();
9934
- const smartAccount = useFluentZeroDevAccount({ login: requestPrivyLogin });
9935
- const { authenticated, login, logout, ready: privyReady, user } = usePrivy();
10760
+ const resolvedConfig = useMemo(() => resolveFluentWidgetConfig(config), [config]);
10761
+ const smartAccount = useFluentZeroDevAccount({
10762
+ login: requestPrivyLogin,
10763
+ partnerId: resolvedConfig.partnerId,
10764
+ sponsorshipUrl: resolvedConfig.sponsorshipUrl
10765
+ });
10766
+ const { authenticated, getAccessToken, login, logout, ready: privyReady, user } = usePrivy();
9936
10767
  const { identityToken } = useIdentityToken();
9937
10768
  const { refreshUser } = useUser();
9938
10769
  const activeWallet = wallet ?? internalWallet;
9939
10770
  const { chain } = useFluentWidgetNetwork();
9940
- const resolvedConfig = useMemo(() => resolveFluentWidgetConfig(config), [config]);
9941
10771
  const fluentConnect = useMemo(() => createFluentConnectForWidget(config), [config]);
9942
10772
  const directAuth = resolvedConfig.authMode === "direct";
9943
10773
  const directAuthRequested = useRef(
@@ -9995,7 +10825,6 @@ function FluentWidgetContent({
9995
10825
  });
9996
10826
  const { selectedGasPaymentToken, defaultConfirmationMode } = useGasPaymentSelection({
9997
10827
  gasPaymentToken,
9998
- tokens,
9999
10828
  network: resolvedConfig.network,
10000
10829
  silentSigningEnabled
10001
10830
  });
@@ -10014,7 +10843,7 @@ function FluentWidgetContent({
10014
10843
  const { hostedAuthorizeUrl, beginHostedConnect } = useHostedConnect({
10015
10844
  fluentConnect,
10016
10845
  authorizeUrl: resolvedConfig.authorizeUrl,
10017
- clientId: resolvedConfig.clientId,
10846
+ partnerId: resolvedConfig.partnerId,
10018
10847
  appName: resolvedConfig.appName,
10019
10848
  authMode: resolvedConfig.authMode,
10020
10849
  setSession,
@@ -10058,7 +10887,7 @@ function FluentWidgetContent({
10058
10887
  disconnectingRef.current = true;
10059
10888
  try {
10060
10889
  setAccountOpen(false);
10061
- commitSilentSigningEnabled(false);
10890
+ commitSilentSigningEnabled(FLUENT_CONNECT_DEFAULT_SILENT_SIGNING);
10062
10891
  setSession(null);
10063
10892
  resetInitialization();
10064
10893
  setDirectAuthRequested(false);
@@ -10134,6 +10963,7 @@ function FluentWidgetContent({
10134
10963
  const app = fluentConnect.status().app;
10135
10964
  const nextSession = createLocalFluentSession({
10136
10965
  app,
10966
+ partnerId: resolvedConfig.partnerId,
10137
10967
  scopes: resolvedConfig.scopes,
10138
10968
  userId: user.id,
10139
10969
  email: typeof user.email?.address === "string" ? user.email.address : void 0,
@@ -10229,7 +11059,20 @@ function FluentWidgetContent({
10229
11059
  defaultConfirmationMode,
10230
11060
  selectedGasPaymentToken,
10231
11061
  confirmBatchOperation,
10232
- refreshBalances
11062
+ refreshBalances,
11063
+ track
11064
+ });
11065
+ const getAuthToken = useAuthToken({
11066
+ publicApiUrl: resolvedConfig.publicApiUrl,
11067
+ partnerId: resolvedConfig.partnerId,
11068
+ authMode: resolvedConfig.authMode,
11069
+ renewalOffsetSeconds: resolvedConfig.authTokenRenewalOffsetSeconds,
11070
+ accountType: widgetAccount.type,
11071
+ privyUserId: user?.id,
11072
+ getAccessToken,
11073
+ identityToken,
11074
+ walletAddress: activeWallet?.address,
11075
+ walletClient: activeWallet?.walletClient
10233
11076
  });
10234
11077
  const context = useMemo(
10235
11078
  () => ({
@@ -10243,7 +11086,8 @@ function FluentWidgetContent({
10243
11086
  hasConnectedAccount,
10244
11087
  status,
10245
11088
  connecting,
10246
- refreshBalances
11089
+ refreshBalances,
11090
+ getAuthToken
10247
11091
  }),
10248
11092
  [
10249
11093
  session,
@@ -10256,7 +11100,8 @@ function FluentWidgetContent({
10256
11100
  hasConnectedAccount,
10257
11101
  status,
10258
11102
  connecting,
10259
- refreshBalances
11103
+ refreshBalances,
11104
+ getAuthToken
10260
11105
  ]
10261
11106
  );
10262
11107
  const widget = /* @__PURE__ */ jsx(FluentPortalContainerProvider, { children: /* @__PURE__ */ jsxs(Toaster, { children: [
@@ -10271,6 +11116,7 @@ function FluentWidgetContent({
10271
11116
  onAccountMenuAction: handleAccountMenuAction,
10272
11117
  settingsOpen: walletMenuTab === "settings",
10273
11118
  onCloseSettings: closeSettings,
11119
+ userLogoUrl: getHighResTwitterAvatar(user?.twitter?.profilePictureUrl),
10274
11120
  connectButton: /* @__PURE__ */ jsx(
10275
11121
  FluentConnectButtonSlot,
10276
11122
  {
@@ -10283,7 +11129,8 @@ function FluentWidgetContent({
10283
11129
  openConnect,
10284
11130
  openAccount: openAccountMenu,
10285
11131
  renderConnectButton,
10286
- connectButton
11132
+ connectButton,
11133
+ userLogoUrl: getHighResTwitterAvatar(user?.twitter?.profilePictureUrl)
10287
11134
  }
10288
11135
  ),
10289
11136
  children: /* @__PURE__ */ jsx(
@@ -10361,8 +11208,12 @@ function FluentWidgetContent({
10361
11208
  var SILENT_SIGNING_REMOUNT_MS = 220;
10362
11209
  function FluentWidget(props) {
10363
11210
  setDebugLogging(props.debugLogging ?? false);
10364
- const [silentSigningEnabled, setSilentSigningEnabled] = useState(false);
10365
- const [silentSigningChecked, setSilentSigningChecked] = useState(false);
11211
+ const [silentSigningEnabled, setSilentSigningEnabled] = useState(
11212
+ FLUENT_CONNECT_DEFAULT_SILENT_SIGNING
11213
+ );
11214
+ const [silentSigningChecked, setSilentSigningChecked] = useState(
11215
+ FLUENT_CONNECT_DEFAULT_SILENT_SIGNING
11216
+ );
10366
11217
  const silentSigningRemountTimer = useRef(null);
10367
11218
  const [privyEpoch, setPrivyEpoch] = useState(0);
10368
11219
  const pendingPrivyLoginRef = useRef(false);
@@ -10374,13 +11225,7 @@ function FluentWidget(props) {
10374
11225
  [props.config]
10375
11226
  );
10376
11227
  const resolvedNetwork = resolvedConfig.network;
10377
- const privyClientId = resolvedConfig.clientId.startsWith("client-") ? resolvedConfig.clientId : void 0;
10378
- useEffect(() => {
10379
- if (resolvedConfig.authMode !== "direct" || privyClientId) return;
10380
- console.warn(
10381
- `[fluent widget] clientId "${resolvedConfig.clientId}" is not a Privy app client. authMode: "direct" will fail with invalid_origin outside Fluent origins \u2014 use the client id issued by Fluent, or authMode: "hosted".`
10382
- );
10383
- }, [privyClientId, resolvedConfig.authMode, resolvedConfig.clientId]);
11228
+ const privyClientId = resolvedConfig.privyClientId;
10384
11229
  const analyticsContext = useRef({});
10385
11230
  const externalWallet = useRef({ intent: false, connected: false });
10386
11231
  const track = useMemo(
@@ -10549,6 +11394,6 @@ function FluentWidget(props) {
10549
11394
  ) });
10550
11395
  }
10551
11396
 
10552
- export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FLUENT_CONNECT_DEFAULT_ASSETS, FLUENT_GAS_PAYMENT_DEFAULT_ETH_RATES, FLUENT_GAS_PAYMENT_PRIORITY, FLUENT_WIDGET_SESSION_STORAGE_KEY, FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY, FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT, FluentWidget, FluentWidgetConnectButton, FluentWidgetNetworkProvider, Icon, Separator, buttonVariants, clearPrivyRecentLoginMethod, createFluentBatchOp, createFluentClient, createFluentFamiliesClient, createFluentPermissionApi, createFluentPermissionClient, createFluentPermissionPolicyBuilders, createFluentPermissionSession, createFluentZeroDevErc20Paymaster, createFluentZeroDevErc20PaymasterApprovalCall, createFluentZeroDevErc20PaymasterClient, createFluentZeroDevErc20PaymasterRpcUrl, createFluentZeroDevPermissionSession, createFluentZeroDevRpcUrl, fluent2 as fluent, apps as fluentApps, fluentBridgeAbi, fluent as fluentChain, fluentChains, fluentDefinitionToViemChain, integrations as fluentIntegrations, l1Chains as fluentL1Chains, fluentMainnet, fluentMainnetTokenDefaults, fluentMainnetWidgetTokens, fluentTestnet, fluentTestnetTokenDefaults, fluentTestnetWidgetTokens, fluentZeroDevChainIds, formatFluentGasTokenBalance, formatFluentLocaleAmount, getApp, getContractAddressFromChain, getFluentChain, getFluentChainByChainId, getFluentChainForNetwork, getFluentDefaultGasTokens, getFluentDefaultWidgetGasTokens, getFluentExplorerBaseUrl, getFluentGasPaymentEthValue, getFluentGasPaymentTokens, getFluentGasPaymentValueTier, getFluentGasTokenAddress, getFluentTokenDefaults, getFluentTokenDefaultsForNetwork, getFluentZeroDevErc20PaymasterTokens, getL1Chain, getL1ForFluentChain, getZeroDevRpcUrl, getZerodevIntegration, isFaucetNetwork, isFluentZeroDevChain, l1DefinitionToViemChain, normalizeFluentWidgetNetwork, readFluentTokenBalances, registryVersion, resolveBridgeAddresses, resolveFluentWidgetNetworkFromEnv, resolveFluentZeroDevErc20PaymasterToken, resolveL1Definition, selectFluentGasPaymentToken, sendFluentZeroDevErc20PaymasterDemo, useFluentWidget, useFluentWidgetNetwork, useFluentZeroDevAccount, useWidget };
11397
+ export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FLUENT_CONNECT_DEFAULT_ASSETS, FLUENT_GAS_PAYMENT_DEFAULT_ETH_RATES, FLUENT_USER_TOKEN_LIMIT, FLUENT_WIDGET_SESSION_STORAGE_KEY, FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY, FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY, FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT, FluentAccountDrawer, FluentAuthError, FluentPortalContainerProvider, FluentWidget, FluentWidgetConnectButton, FluentWidgetNetworkProvider, Icon, Label, Separator, WIDGET_STYLE_SCOPE, WalletMenuActionCard, buttonVariants, clearPrivyRecentLoginMethod, createFluentBatchOp, createFluentClient, createFluentFamiliesClient, createFluentPermissionApi, createFluentPermissionClient, createFluentPermissionPolicyBuilders, createFluentPermissionSession, createFluentSponsorshipRpcUrl, createFluentUserTokenStore, createFluentZeroDevErc20Paymaster, createFluentZeroDevErc20PaymasterApprovalCall, createFluentZeroDevErc20PaymasterClient, createFluentZeroDevErc20PaymasterRpcUrl, createFluentZeroDevPermissionSession, createFluentZeroDevRpcUrl, createFluentZeroDevSponsoredPaymaster, findFluentSymbolCollisions, fluent2 as fluent, apps as fluentApps, fluentBridgeAbi, fluent as fluentChain, fluentChains, fluentDefinitionToViemChain, integrations as fluentIntegrations, l1Chains as fluentL1Chains, fluentMainnet, fluentMainnetTokenDefaults, fluentTestnet, fluentTestnetTokenDefaults, fluentTokenIdentity, fluentZeroDevChainIds, getApp, getContractAddressFromChain, getFluentChain, getFluentChainByChainId, getFluentChainForNetwork, getFluentDefaultWidgetDisplayTokens, getFluentDefaultWidgetGasTokens, getFluentExplorerBaseUrl, getFluentGasPaymentEthValue, getFluentGasPaymentTokens, getFluentGasPaymentValueTier, getFluentGasTokenAddress, getFluentTokenDefaults, getFluentTokenDefaultsForNetwork, getFluentZeroDevErc20PaymasterTokens, getL1Chain, getL1ForFluentChain, getZeroDevRpcUrl, getZerodevIntegration, isFaucetNetwork, isFluentDefaultToken, isFluentNativeToken, isFluentZeroDevChain, l1DefinitionToViemChain, mergeFluentDisplayTokens, normalizeFluentWidgetNetwork, readFluentTokenBalances, readFluentTokenMetadata, registryVersion, resolveBridgeAddresses, resolveFluentWidgetNetworkFromEnv, resolveFluentZeroDevErc20PaymasterToken, resolveL1Definition, selectFluentGasPaymentToken, sendFluentZeroDevErc20PaymasterDemo, sortFluentGasTokens, useFluentUserTokens, useFluentWidget, useFluentWidgetNetwork, useFluentZeroDevAccount, useWidget };
10553
11398
  //# sourceMappingURL=index.js.map
10554
11399
  //# sourceMappingURL=index.js.map