@fluent.xyz/connect 0.4.2 → 0.5.0
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/INTEGRATION.md +232 -96
- package/README.md +76 -20
- package/dist/fluent-connect.css +1 -1
- package/dist/index.d.ts +305 -56
- package/dist/index.js +1362 -1041
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import './polyfills/buffer.js';
|
|
2
|
-
import { parseAbi, toEventSelector, parseAbiItem, parseEther, defineChain, http, createPublicClient, formatUnits, isAddress, getAddress, parseUnits, BaseError, encodeFunctionData, zeroAddress, numberToHex, hexToBigInt, isHex, toHex, fallback, stringToHex, bytesToHex, HttpRequestError, erc20Abi, padHex
|
|
2
|
+
import { parseAbi, toEventSelector, parseAbiItem, parseEther, defineChain, http, createPublicClient, formatUnits, isAddress, getAddress, parseUnits, BaseError, encodeFunctionData, zeroAddress, numberToHex, hexToBigInt, isHex, toHex, fallback, stringToHex, bytesToHex, HttpRequestError, decodeEventLog, erc20Abi, padHex } from 'viem';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { createContext, forwardRef, useContext, useMemo, useState, useEffect, useCallback, useRef, useLayoutEffect, Fragment as Fragment$1 } from 'react';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
-
import { estimateUserOperationGas } from 'viem/account-abstraction';
|
|
6
|
+
import { estimateUserOperationGas, WaitForUserOperationReceiptTimeoutError, getPaymasterData, getPaymasterStubData } from 'viem/account-abstraction';
|
|
7
7
|
import { toCallPolicy, CallPolicyVersion, toTimestampPolicy, CallType, ParamCondition } from '@zerodev/permissions/policies';
|
|
8
8
|
export { CallType, ParamCondition } from '@zerodev/permissions/policies';
|
|
9
9
|
import { privateKeyToAccount, toAccount, generatePrivateKey } from 'viem/accounts';
|
|
10
|
-
import
|
|
10
|
+
import * as web from '@privy-io/react-auth';
|
|
11
11
|
import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';
|
|
12
12
|
import { toPermissionValidator, serializePermissionAccount, deserializePermissionAccount } from '@zerodev/permissions';
|
|
13
13
|
import { toECDSASigner } from '@zerodev/permissions/signers';
|
|
14
14
|
import { createZeroDevPaymasterClient, getERC20PaymasterApproveCall, createKernelAccountClient, createKernelAccount } from '@zerodev/sdk';
|
|
15
15
|
import { getEntryPoint, KERNEL_V3_3 } from '@zerodev/sdk/constants';
|
|
16
|
+
import { getUserOperationGasPrice } from '@zerodev/sdk/actions';
|
|
17
|
+
import { getBlockNumber, getLogs, getTransactionReceipt } from 'viem/actions';
|
|
16
18
|
import { Toast as Toast$1 } from '@base-ui/react/toast';
|
|
17
19
|
import { clsx } from 'clsx';
|
|
18
20
|
import { twMerge } from 'tailwind-merge';
|
|
19
21
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
20
22
|
import { cva } from 'class-variance-authority';
|
|
21
|
-
import { XIcon, RefreshCw, X, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Loader2, ChevronDownIcon, CheckIcon, AlertTriangle, Layers,
|
|
23
|
+
import { XIcon, Trash2, RefreshCw, X, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Loader2, ChevronDownIcon, CheckIcon, AlertTriangle, Layers, Plus, Loader2Icon, ChevronUpIcon, CircleHelp, LogIn, Send, RotateCw, KeyRound, Mail, Wallet, Check, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
|
|
22
24
|
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
|
|
23
25
|
import { createAppKit, useAppKit } from '@reown/appkit/react';
|
|
24
26
|
import { QueryClient, QueryClientContext, QueryClientProvider, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
@@ -5000,7 +5002,6 @@ function createFluentFamiliesClient(config) {
|
|
|
5000
5002
|
}
|
|
5001
5003
|
|
|
5002
5004
|
// ../connect-sdk/src/index.ts
|
|
5003
|
-
var DEFAULT_AUTHORIZE_URL = "https://connect-preview.vercel.app/authorize";
|
|
5004
5005
|
var DEFAULT_SCOPES = ["openid", "profile", "wallet", "faucet"];
|
|
5005
5006
|
var INSTALLATION_ID_KEY = "fluent:connect:installation-id:v1";
|
|
5006
5007
|
var SESSION_KEY = "fluent:connect:session:v1";
|
|
@@ -5011,13 +5012,6 @@ function getBrowserOrigin() {
|
|
|
5011
5012
|
}
|
|
5012
5013
|
return browserWindow.location.origin;
|
|
5013
5014
|
}
|
|
5014
|
-
function getBrowserRedirectUri() {
|
|
5015
|
-
const browserWindow = globalThis.window;
|
|
5016
|
-
if (!browserWindow?.location?.origin) {
|
|
5017
|
-
throw new Error("redirectUri is required outside a browser");
|
|
5018
|
-
}
|
|
5019
|
-
return `${browserWindow.location.origin}${browserWindow.location.pathname ?? "/"}`;
|
|
5020
|
-
}
|
|
5021
5015
|
function getBrowserStorage() {
|
|
5022
5016
|
return globalThis.window?.localStorage;
|
|
5023
5017
|
}
|
|
@@ -5037,9 +5031,6 @@ function getOrCreateInstallationId(storage) {
|
|
|
5037
5031
|
storage?.setItem(INSTALLATION_ID_KEY, next);
|
|
5038
5032
|
return next;
|
|
5039
5033
|
}
|
|
5040
|
-
function withoutTrailingSlash3(value) {
|
|
5041
|
-
return value.replace(/\/+$/, "");
|
|
5042
|
-
}
|
|
5043
5034
|
var FluentConnectSDK = class {
|
|
5044
5035
|
config;
|
|
5045
5036
|
app;
|
|
@@ -5050,12 +5041,10 @@ var FluentConnectSDK = class {
|
|
|
5050
5041
|
const installationId = getOrCreateInstallationId(storage);
|
|
5051
5042
|
this.config = {
|
|
5052
5043
|
...config,
|
|
5053
|
-
authorizeUrl: config.authorizeUrl ?? DEFAULT_AUTHORIZE_URL,
|
|
5054
5044
|
scopes: config.scopes ?? DEFAULT_SCOPES,
|
|
5055
5045
|
source: config.source ?? "fluent_connect_sdk",
|
|
5056
5046
|
storage,
|
|
5057
|
-
origin
|
|
5058
|
-
redirectUri: config.redirectUri ?? getBrowserRedirectUri()
|
|
5047
|
+
origin
|
|
5059
5048
|
};
|
|
5060
5049
|
this.app = {
|
|
5061
5050
|
mode: config.clientId ? "registered" : "origin",
|
|
@@ -5074,27 +5063,6 @@ var FluentConnectSDK = class {
|
|
|
5074
5063
|
session: this.session
|
|
5075
5064
|
};
|
|
5076
5065
|
}
|
|
5077
|
-
buildAuthorizeUrl(state = randomId()) {
|
|
5078
|
-
const url = new URL(withoutTrailingSlash3(this.config.authorizeUrl), this.app.origin);
|
|
5079
|
-
url.searchParams.set("origin", this.app.origin);
|
|
5080
|
-
url.searchParams.set("installation_id", this.app.installationId);
|
|
5081
|
-
url.searchParams.set("redirect_uri", this.config.redirectUri ?? this.app.origin);
|
|
5082
|
-
url.searchParams.set("scope", this.config.scopes.join(" "));
|
|
5083
|
-
url.searchParams.set("state", state);
|
|
5084
|
-
url.searchParams.set("network", this.config.network);
|
|
5085
|
-
url.searchParams.set("source", this.config.source);
|
|
5086
|
-
if (this.app.clientId) url.searchParams.set("client_id", this.app.clientId);
|
|
5087
|
-
if (this.app.appName) url.searchParams.set("app_name", this.app.appName);
|
|
5088
|
-
if (this.config.campaign) url.searchParams.set("campaign", this.config.campaign);
|
|
5089
|
-
return url;
|
|
5090
|
-
}
|
|
5091
|
-
connect(options = {}) {
|
|
5092
|
-
const url = this.buildAuthorizeUrl(options.state);
|
|
5093
|
-
const browserWindow = globalThis.window;
|
|
5094
|
-
const opener = options.popup ?? (browserWindow?.open ? browserWindow.open.bind(browserWindow) : void 0);
|
|
5095
|
-
opener?.(url, "fluent-connect", "popup,width=460,height=680");
|
|
5096
|
-
return url;
|
|
5097
|
-
}
|
|
5098
5066
|
setSession(session) {
|
|
5099
5067
|
const nextSession = {
|
|
5100
5068
|
...session,
|
|
@@ -5336,10 +5304,13 @@ var FLUENT_CONNECT_TESTNET_SPONSORSHIP_URL = "https://sponsorship.fluent-connect
|
|
|
5336
5304
|
var FLUENT_CONNECT_MAINNET_SPONSORSHIP_URL = "";
|
|
5337
5305
|
var FLUENT_CONNECT_TESTNET_REPUTATION_SIGNUP_URL = "https://connect-preview.vercel.app/signin";
|
|
5338
5306
|
var FLUENT_CONNECT_MAINNET_REPUTATION_SIGNUP_URL = "https://connect.fluent.xyz/signin";
|
|
5339
|
-
var FLUENT_CONNECT_TESTNET_AUTHORIZE_URL = "https://connect-preview.vercel.app/authorize";
|
|
5340
|
-
var FLUENT_CONNECT_MAINNET_AUTHORIZE_URL = "https://connect.fluent.xyz/authorize";
|
|
5341
5307
|
var FLUENT_CONNECT_TESTNET_FAUCET_ENDPOINT = "https://eco-faucet-api.fluent.xyz/fluent-connect/pre-fund";
|
|
5342
5308
|
var FLUENT_CONNECT_DEFAULT_SILENT_SIGNING = true;
|
|
5309
|
+
var FLUENT_CONNECT_DEFAULT_EXECUTION = {
|
|
5310
|
+
feeSource: "chain",
|
|
5311
|
+
receiptSource: "chain",
|
|
5312
|
+
chainCheckBeforeSign: false
|
|
5313
|
+
};
|
|
5343
5314
|
var FLUENT_CONNECT_DEFAULT_PORTAL_BRIDGE_URL = "https://portal.fluent.xyz/user/bridge";
|
|
5344
5315
|
var FLUENT_CONNECT_DEFAULT_SWAPPER_CONFIG = {
|
|
5345
5316
|
enabled: true,
|
|
@@ -5349,7 +5320,6 @@ var FLUENT_CONNECT_DEFAULT_SWAPPER_CONFIG = {
|
|
|
5349
5320
|
};
|
|
5350
5321
|
var FLUENT_CONNECT_NETWORK_ENDPOINTS = {
|
|
5351
5322
|
testnet: {
|
|
5352
|
-
authorizeUrl: FLUENT_CONNECT_TESTNET_AUTHORIZE_URL,
|
|
5353
5323
|
publicApiUrl: FLUENT_CONNECT_TESTNET_PUBLIC_API_URL,
|
|
5354
5324
|
reputationSignupUrl: FLUENT_CONNECT_TESTNET_REPUTATION_SIGNUP_URL,
|
|
5355
5325
|
faucetEndpoint: FLUENT_CONNECT_TESTNET_FAUCET_ENDPOINT,
|
|
@@ -5358,7 +5328,6 @@ var FLUENT_CONNECT_NETWORK_ENDPOINTS = {
|
|
|
5358
5328
|
sponsorshipUrl: FLUENT_CONNECT_TESTNET_SPONSORSHIP_URL
|
|
5359
5329
|
},
|
|
5360
5330
|
mainnet: {
|
|
5361
|
-
authorizeUrl: FLUENT_CONNECT_MAINNET_AUTHORIZE_URL,
|
|
5362
5331
|
publicApiUrl: FLUENT_CONNECT_MAINNET_PUBLIC_API_URL,
|
|
5363
5332
|
reputationSignupUrl: FLUENT_CONNECT_MAINNET_REPUTATION_SIGNUP_URL,
|
|
5364
5333
|
// Mainnet has no faucet.
|
|
@@ -5507,6 +5476,14 @@ function resolveFluentWidgetAuthMethods(enabledAuthMethods) {
|
|
|
5507
5476
|
}
|
|
5508
5477
|
return [...enabled];
|
|
5509
5478
|
}
|
|
5479
|
+
var FluentWidgetConfigError = class extends Error {
|
|
5480
|
+
code;
|
|
5481
|
+
constructor(code, message2) {
|
|
5482
|
+
super(message2);
|
|
5483
|
+
this.name = "FluentWidgetConfigError";
|
|
5484
|
+
this.code = code;
|
|
5485
|
+
}
|
|
5486
|
+
};
|
|
5510
5487
|
var APP_ID_PATTERN = /^app_[0-9a-f]{32}$/;
|
|
5511
5488
|
var APP_ID_HINT = "Pass the app_<32 hex> id from the Fluent Dashboard as appId.";
|
|
5512
5489
|
function resolveCustomOAuthRedirectUrl(value) {
|
|
@@ -5526,7 +5503,82 @@ function resolveCustomOAuthRedirectUrl(value) {
|
|
|
5526
5503
|
}
|
|
5527
5504
|
return redirectUrl;
|
|
5528
5505
|
}
|
|
5506
|
+
function resolveQuickSignWhitelist(addresses) {
|
|
5507
|
+
if (addresses === void 0) return void 0;
|
|
5508
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
5509
|
+
for (const value of addresses) {
|
|
5510
|
+
const address = typeof value === "string" ? value.trim() : "";
|
|
5511
|
+
if (!isAddress(address, { strict: false })) {
|
|
5512
|
+
throw new Error(
|
|
5513
|
+
`FluentWidgetConfig.quickSign.whitelistAddresses contains "${String(value)}", which is not an address. Pass 0x-prefixed 20-byte addresses.`
|
|
5514
|
+
);
|
|
5515
|
+
}
|
|
5516
|
+
resolved.add(address.toLowerCase());
|
|
5517
|
+
}
|
|
5518
|
+
return [...resolved];
|
|
5519
|
+
}
|
|
5520
|
+
var EXECUTION_SOURCES = ["chain", "bundler"];
|
|
5521
|
+
function resolveFluentWidgetExecution(execution) {
|
|
5522
|
+
return {
|
|
5523
|
+
feeSource: resolveExecutionSource(
|
|
5524
|
+
execution?.feeSource,
|
|
5525
|
+
"feeSource",
|
|
5526
|
+
"invalid_fee_source",
|
|
5527
|
+
FLUENT_CONNECT_DEFAULT_EXECUTION.feeSource
|
|
5528
|
+
),
|
|
5529
|
+
receiptSource: resolveExecutionSource(
|
|
5530
|
+
execution?.receiptSource,
|
|
5531
|
+
"receiptSource",
|
|
5532
|
+
"invalid_receipt_source",
|
|
5533
|
+
FLUENT_CONNECT_DEFAULT_EXECUTION.receiptSource
|
|
5534
|
+
),
|
|
5535
|
+
chainCheckBeforeSign: resolveChainCheckBeforeSign(execution?.chainCheckBeforeSign)
|
|
5536
|
+
};
|
|
5537
|
+
}
|
|
5538
|
+
function resolveExecutionSource(value, field, code, fallback2) {
|
|
5539
|
+
if (value === void 0) return fallback2;
|
|
5540
|
+
if (value === "chain" || value === "bundler") return value;
|
|
5541
|
+
throw new FluentWidgetConfigError(
|
|
5542
|
+
code,
|
|
5543
|
+
`FluentWidgetConfig.execution.${field} ${describeRejectedValue(value)} is not supported. Pass one of ${EXECUTION_SOURCES.map((source) => JSON.stringify(source)).join(" or ")}.`
|
|
5544
|
+
);
|
|
5545
|
+
}
|
|
5546
|
+
function resolveChainCheckBeforeSign(value) {
|
|
5547
|
+
if (value === void 0) return FLUENT_CONNECT_DEFAULT_EXECUTION.chainCheckBeforeSign;
|
|
5548
|
+
if (typeof value === "boolean") return value;
|
|
5549
|
+
throw new FluentWidgetConfigError(
|
|
5550
|
+
"invalid_chain_check_before_sign",
|
|
5551
|
+
`FluentWidgetConfig.execution.chainCheckBeforeSign ${describeRejectedValue(value)} is not a boolean. Pass true to read the Signer's chain before every signature, or false.`
|
|
5552
|
+
);
|
|
5553
|
+
}
|
|
5554
|
+
function describeRejectedValue(value) {
|
|
5555
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
5556
|
+
if (value === null) return "null";
|
|
5557
|
+
try {
|
|
5558
|
+
return `${typeof value} ${String(value)}`;
|
|
5559
|
+
} catch {
|
|
5560
|
+
return typeof value;
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5563
|
+
var legacyAuthModeWarned = false;
|
|
5564
|
+
function checkRemovedAuthMode(config) {
|
|
5565
|
+
const authMode = config.authMode;
|
|
5566
|
+
if (authMode === void 0) return;
|
|
5567
|
+
if (authMode === "direct") {
|
|
5568
|
+
if (!legacyAuthModeWarned) {
|
|
5569
|
+
legacyAuthModeWarned = true;
|
|
5570
|
+
console.warn(
|
|
5571
|
+
'FluentWidgetConfig.authMode was removed in 0.5.0 and is ignored. Delete the key: Direct login \u2014 what authMode: "direct" asked for \u2014 is now the only login.'
|
|
5572
|
+
);
|
|
5573
|
+
}
|
|
5574
|
+
return;
|
|
5575
|
+
}
|
|
5576
|
+
throw new Error(
|
|
5577
|
+
`FluentWidgetConfig.authMode: ${JSON.stringify(authMode)} is not supported \u2014 hosted mode was removed in 0.5.0. Delete the authMode key: every user now signs in with Direct login, which needs this App's origin registered on the Privy app client behind privyClientId.`
|
|
5578
|
+
);
|
|
5579
|
+
}
|
|
5529
5580
|
function resolveFluentWidgetConfig(config) {
|
|
5581
|
+
checkRemovedAuthMode(config);
|
|
5530
5582
|
if (config.clientId !== void 0) {
|
|
5531
5583
|
throw new Error(
|
|
5532
5584
|
`FluentWidgetConfig.clientId was removed in 0.2.0. ${APP_ID_HINT} Pass the Privy app client as privyClientId \u2014 both are required.`
|
|
@@ -5572,10 +5624,8 @@ function resolveFluentWidgetConfig(config) {
|
|
|
5572
5624
|
appName: config.appName ?? "Fluent Connect Demo",
|
|
5573
5625
|
appId,
|
|
5574
5626
|
privyClientId,
|
|
5575
|
-
authMode: config.authMode ?? "hosted",
|
|
5576
5627
|
customOAuthRedirectUrl: resolveCustomOAuthRedirectUrl(config.customOAuthRedirectUrl),
|
|
5577
5628
|
authMethods: resolveFluentWidgetAuthMethods(config.enabledAuthMethods),
|
|
5578
|
-
authorizeUrl: endpoints.authorizeUrl,
|
|
5579
5629
|
faucetEndpoint: endpoints.faucetEndpoint,
|
|
5580
5630
|
eventsEndpoint: "",
|
|
5581
5631
|
analyticsHost: endpoints.analyticsHost,
|
|
@@ -5597,6 +5647,10 @@ function resolveFluentWidgetConfig(config) {
|
|
|
5597
5647
|
sponsorship: config.gasPayment?.sponsorship ?? "auto",
|
|
5598
5648
|
ethValueByToken: config.gasPayment?.ethValueByToken
|
|
5599
5649
|
},
|
|
5650
|
+
execution: resolveFluentWidgetExecution(config.execution),
|
|
5651
|
+
quickSign: {
|
|
5652
|
+
whitelistAddresses: resolveQuickSignWhitelist(config.quickSign?.whitelistAddresses)
|
|
5653
|
+
},
|
|
5600
5654
|
reputationEnabled: config.reputationEnabled ?? true,
|
|
5601
5655
|
scopes: config.scopes ?? getFluentWidgetDefaultScopes(network),
|
|
5602
5656
|
source: config.source ?? "fluent_connect_widget",
|
|
@@ -5617,7 +5671,6 @@ function createFluentConnectForWidget(config) {
|
|
|
5617
5671
|
network: resolved.network,
|
|
5618
5672
|
appName: resolved.appName,
|
|
5619
5673
|
clientId: resolved.privyClientId,
|
|
5620
|
-
authorizeUrl: resolved.authorizeUrl,
|
|
5621
5674
|
scopes: resolved.scopes,
|
|
5622
5675
|
source: resolved.source,
|
|
5623
5676
|
campaign: resolved.campaign
|
|
@@ -5666,9 +5719,6 @@ var debugLoggingEnabled = false;
|
|
|
5666
5719
|
function setDebugLogging(enabled) {
|
|
5667
5720
|
debugLoggingEnabled = enabled;
|
|
5668
5721
|
}
|
|
5669
|
-
function isDebugLoggingEnabled() {
|
|
5670
|
-
return debugLoggingEnabled;
|
|
5671
|
-
}
|
|
5672
5722
|
function debugLog(...args) {
|
|
5673
5723
|
if (debugLoggingEnabled) console.log(...args);
|
|
5674
5724
|
}
|
|
@@ -6355,7 +6405,6 @@ var LINK_X_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
6355
6405
|
"user_rejected",
|
|
6356
6406
|
"linked_to_another_user",
|
|
6357
6407
|
"not_authenticated",
|
|
6358
|
-
"hosted_not_supported",
|
|
6359
6408
|
"bad_request",
|
|
6360
6409
|
"link_failed"
|
|
6361
6410
|
]);
|
|
@@ -6393,12 +6442,6 @@ function toLinkXError(err) {
|
|
|
6393
6442
|
return new FluentAuthError("link_failed", err instanceof Error ? err.message : String(err));
|
|
6394
6443
|
}
|
|
6395
6444
|
async function requestLinkX(params) {
|
|
6396
|
-
if (params.authMode === "hosted") {
|
|
6397
|
-
throw new FluentAuthError(
|
|
6398
|
-
"hosted_not_supported",
|
|
6399
|
-
`linkX() needs authMode: "direct" \u2014 in hosted mode the user's Privy session lives on the authorize page, not in this page.`
|
|
6400
|
-
);
|
|
6401
|
-
}
|
|
6402
6445
|
if (params.accountKind === "eoa") {
|
|
6403
6446
|
if (!params.wallet) {
|
|
6404
6447
|
throw new FluentAuthError(
|
|
@@ -6614,9 +6657,44 @@ function getSponsorshipFailure(err) {
|
|
|
6614
6657
|
if (httpError.status === 401) return { reason: "unauthorized", disableSponsorship: false };
|
|
6615
6658
|
return { reason: "unreachable", disableSponsorship: false };
|
|
6616
6659
|
}
|
|
6660
|
+
var FluentUserOperationGasError = class extends Error {
|
|
6661
|
+
constructor(code, message2) {
|
|
6662
|
+
super(message2);
|
|
6663
|
+
this.code = code;
|
|
6664
|
+
this.name = "FluentUserOperationGasError";
|
|
6665
|
+
}
|
|
6666
|
+
code;
|
|
6667
|
+
};
|
|
6617
6668
|
var maxCallGasLimit = (1n << 128n) - 1n;
|
|
6669
|
+
var maxPreVerificationGas = (1n << 256n) - 1n;
|
|
6618
6670
|
function validateUserOperationGas(gas) {
|
|
6619
6671
|
if (!gas) return;
|
|
6672
|
+
if (gas.skipEstimation !== void 0 && typeof gas.skipEstimation !== "boolean") {
|
|
6673
|
+
throw new FluentUserOperationGasError("invalid_policy", "skipEstimation must be a boolean");
|
|
6674
|
+
}
|
|
6675
|
+
if (gas.skipEstimation) {
|
|
6676
|
+
if (gas.callGasBuffer !== void 0) {
|
|
6677
|
+
throw new FluentUserOperationGasError(
|
|
6678
|
+
"invalid_policy",
|
|
6679
|
+
"skipEstimation cannot be combined with callGasBuffer"
|
|
6680
|
+
);
|
|
6681
|
+
}
|
|
6682
|
+
validateFixedLimit("callGasLimit", gas.callGasLimit);
|
|
6683
|
+
validateFixedLimit("verificationGasLimit", gas.verificationGasLimit);
|
|
6684
|
+
validateFixedLimit("preVerificationGas", gas.preVerificationGas, maxPreVerificationGas);
|
|
6685
|
+
if (gas.paymasterVerificationGasLimit !== void 0) {
|
|
6686
|
+
validateFixedLimit("paymasterVerificationGasLimit", gas.paymasterVerificationGasLimit);
|
|
6687
|
+
}
|
|
6688
|
+
if (gas.paymasterPostOpGasLimit !== void 0) {
|
|
6689
|
+
validateFixedLimit(
|
|
6690
|
+
"paymasterPostOpGasLimit",
|
|
6691
|
+
gas.paymasterPostOpGasLimit,
|
|
6692
|
+
maxCallGasLimit,
|
|
6693
|
+
0n
|
|
6694
|
+
);
|
|
6695
|
+
}
|
|
6696
|
+
return;
|
|
6697
|
+
}
|
|
6620
6698
|
if (gas.callGasLimit !== void 0) {
|
|
6621
6699
|
if (gas.callGasBuffer !== void 0) {
|
|
6622
6700
|
throw new Error("Choose callGasLimit or callGasBuffer, not both");
|
|
@@ -6638,6 +6716,7 @@ function validateUserOperationGas(gas) {
|
|
|
6638
6716
|
function withUserOperationGas(client2, args, gas) {
|
|
6639
6717
|
validateUserOperationGas(gas);
|
|
6640
6718
|
if (!gas) return args;
|
|
6719
|
+
if (gas.skipEstimation) return withoutGasEstimation(client2, args, gas);
|
|
6641
6720
|
if (gas.callGasBuffer && (gas.callGasBuffer.percentage ?? 0) === 0 && (gas.callGasBuffer.fixed ?? 0n) === 0n) {
|
|
6642
6721
|
return args;
|
|
6643
6722
|
}
|
|
@@ -6712,8 +6791,84 @@ function withUserOperationGas(client2, args, gas) {
|
|
|
6712
6791
|
}
|
|
6713
6792
|
};
|
|
6714
6793
|
}
|
|
6715
|
-
|
|
6716
|
-
|
|
6794
|
+
function validateFixedLimit(field, value, maximum = maxCallGasLimit, minimum = 1n) {
|
|
6795
|
+
if (typeof value !== "bigint" || value < minimum || value > maximum) {
|
|
6796
|
+
throw new FluentUserOperationGasError(
|
|
6797
|
+
"invalid_policy",
|
|
6798
|
+
`skipEstimation requires ${field} as a bigint between ${minimum} and ${maximum}`
|
|
6799
|
+
);
|
|
6800
|
+
}
|
|
6801
|
+
}
|
|
6802
|
+
function withoutGasEstimation(client2, args, gas) {
|
|
6803
|
+
const paymaster = args.paymaster ?? client2.paymaster;
|
|
6804
|
+
if (paymaster && (gas.paymasterVerificationGasLimit === void 0 || gas.paymasterPostOpGasLimit === void 0)) {
|
|
6805
|
+
throw new FluentUserOperationGasError(
|
|
6806
|
+
"invalid_policy",
|
|
6807
|
+
"skipEstimation requires paymasterVerificationGasLimit and paymasterPostOpGasLimit when a paymaster is used"
|
|
6808
|
+
);
|
|
6809
|
+
}
|
|
6810
|
+
const limits = {
|
|
6811
|
+
callGasLimit: gas.callGasLimit,
|
|
6812
|
+
verificationGasLimit: gas.verificationGasLimit,
|
|
6813
|
+
preVerificationGas: gas.preVerificationGas,
|
|
6814
|
+
...paymaster ? {
|
|
6815
|
+
paymasterVerificationGasLimit: gas.paymasterVerificationGasLimit,
|
|
6816
|
+
paymasterPostOpGasLimit: gas.paymasterPostOpGasLimit
|
|
6817
|
+
} : {}
|
|
6818
|
+
};
|
|
6819
|
+
const adapter = paymaster === true ? {
|
|
6820
|
+
getPaymasterStubData: (operation) => getPaymasterStubData(client2, operation),
|
|
6821
|
+
getPaymasterData: (operation) => getPaymasterData(client2, operation)
|
|
6822
|
+
} : typeof paymaster === "object" ? paymaster : void 0;
|
|
6823
|
+
return {
|
|
6824
|
+
...args,
|
|
6825
|
+
...limits,
|
|
6826
|
+
...adapter ? {
|
|
6827
|
+
paymaster: {
|
|
6828
|
+
async getPaymasterStubData(operation) {
|
|
6829
|
+
const getStub = adapter.getPaymasterStubData ?? adapter.getPaymasterData;
|
|
6830
|
+
const fixedOperation = { ...operation, ...limits };
|
|
6831
|
+
const data = await getStub.call(adapter, fixedOperation);
|
|
6832
|
+
const isFinal = !adapter.getPaymasterStubData || "isFinal" in data && data.isFinal === true;
|
|
6833
|
+
if (isFinal) assertAuthorizedGas(data, limits);
|
|
6834
|
+
return { ...data, ...limits, isFinal };
|
|
6835
|
+
},
|
|
6836
|
+
async getPaymasterData(operation) {
|
|
6837
|
+
const fixedOperation = { ...operation, ...limits };
|
|
6838
|
+
const data = await adapter.getPaymasterData(fixedOperation);
|
|
6839
|
+
assertAuthorizedGas(data, limits);
|
|
6840
|
+
return data;
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
} : {},
|
|
6844
|
+
account: {
|
|
6845
|
+
...args.account,
|
|
6846
|
+
userOperation: {
|
|
6847
|
+
...args.account.userOperation,
|
|
6848
|
+
// Returning every required field keeps viem from invoking the bundler estimator.
|
|
6849
|
+
// The original account hook is deliberately bypassed for this submission alone.
|
|
6850
|
+
estimateGas: async () => limits
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6853
|
+
};
|
|
6854
|
+
}
|
|
6855
|
+
function assertAuthorizedGas(data, limits) {
|
|
6856
|
+
if (!data || typeof data !== "object") {
|
|
6857
|
+
throw new FluentUserOperationGasError(
|
|
6858
|
+
"paymaster_gas_mismatch",
|
|
6859
|
+
"skipEstimation requires a paymaster authorization object"
|
|
6860
|
+
);
|
|
6861
|
+
}
|
|
6862
|
+
for (const [field, value] of Object.entries(limits)) {
|
|
6863
|
+
const authorized = Reflect.get(data, field);
|
|
6864
|
+
if (authorized !== void 0 && authorized !== value) {
|
|
6865
|
+
throw new FluentUserOperationGasError(
|
|
6866
|
+
"paymaster_gas_mismatch",
|
|
6867
|
+
`Paymaster changed ${field} with skipEstimation enabled`
|
|
6868
|
+
);
|
|
6869
|
+
}
|
|
6870
|
+
}
|
|
6871
|
+
}
|
|
6717
6872
|
function createFluentBatchOp(input, executor) {
|
|
6718
6873
|
if (input.calls.length === 0) {
|
|
6719
6874
|
throw new Error("A Fluent batch operation requires at least one call");
|
|
@@ -6742,6 +6897,9 @@ function createFluentBatchOp(input, executor) {
|
|
|
6742
6897
|
confirmation: options?.confirmation ?? activeExecutor.defaultConfirmation ?? "always",
|
|
6743
6898
|
gasPayment: gasPayment ? { ...gasPayment, sponsorship: gasPayment.sponsorship ?? activeExecutor.defaultSponsorship } : void 0
|
|
6744
6899
|
};
|
|
6900
|
+
if (executionOptions.confirmation === "session" && activeExecutor.quickSignWhitelist && !isQuickSignWhitelisted(encodedCalls, activeExecutor.quickSignWhitelist)) {
|
|
6901
|
+
executionOptions.confirmation = "always";
|
|
6902
|
+
}
|
|
6745
6903
|
if (executionOptions.confirmation === "always" && activeExecutor.account?.type !== "eoa") {
|
|
6746
6904
|
await activeExecutor.confirm?.({
|
|
6747
6905
|
id: input.id,
|
|
@@ -6765,6 +6923,10 @@ function createFluentBatchOp(input, executor) {
|
|
|
6765
6923
|
}
|
|
6766
6924
|
};
|
|
6767
6925
|
}
|
|
6926
|
+
function isQuickSignWhitelisted(calls, whitelist) {
|
|
6927
|
+
const allowed = new Set(whitelist.map((address) => address.toLowerCase()));
|
|
6928
|
+
return calls.every((call) => allowed.has(call.to.toLowerCase()));
|
|
6929
|
+
}
|
|
6768
6930
|
function encodeBatchCall(call) {
|
|
6769
6931
|
if (call.data) {
|
|
6770
6932
|
return {
|
|
@@ -6916,146 +7078,99 @@ function buildFluentTransferCall(params) {
|
|
|
6916
7078
|
args: [to, amount]
|
|
6917
7079
|
};
|
|
6918
7080
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
function createFluentHostedSigner(params) {
|
|
6924
|
-
const authorizeOrigin = new URL(params.authorizeUrl, location.href).origin;
|
|
6925
|
-
let signerWindow = null;
|
|
6926
|
-
let activeConfirmation = null;
|
|
6927
|
-
let state = "";
|
|
6928
|
-
let readyPromise = null;
|
|
6929
|
-
let resolveReady = null;
|
|
6930
|
-
let rejectReady = null;
|
|
6931
|
-
let pending2 = null;
|
|
6932
|
-
const close = () => {
|
|
6933
|
-
signerWindow?.close();
|
|
6934
|
-
signerWindow = null;
|
|
6935
|
-
activeConfirmation = null;
|
|
6936
|
-
readyPromise = null;
|
|
6937
|
-
resolveReady = null;
|
|
6938
|
-
rejectReady = null;
|
|
6939
|
-
pending2 = null;
|
|
6940
|
-
};
|
|
6941
|
-
const onMessage = (event) => {
|
|
6942
|
-
if (event.origin !== authorizeOrigin || event.source !== signerWindow) return;
|
|
6943
|
-
const response = event.data;
|
|
6944
|
-
if (!response || response.state !== state) return;
|
|
6945
|
-
if (response.type === "fluent:signer:ready") {
|
|
6946
|
-
resolveReady?.();
|
|
6947
|
-
resolveReady = null;
|
|
6948
|
-
rejectReady = null;
|
|
6949
|
-
return;
|
|
6950
|
-
}
|
|
6951
|
-
if (response.type === "fluent:signer:result") {
|
|
6952
|
-
pending2?.resolve(response.signature);
|
|
6953
|
-
pending2 = null;
|
|
6954
|
-
return;
|
|
6955
|
-
}
|
|
6956
|
-
if (response.type === "fluent:signer:error") {
|
|
6957
|
-
const error = new Error(response.error);
|
|
6958
|
-
if (pending2) {
|
|
6959
|
-
pending2.reject(error);
|
|
6960
|
-
} else {
|
|
6961
|
-
rejectReady?.(error);
|
|
6962
|
-
}
|
|
6963
|
-
pending2 = null;
|
|
6964
|
-
resolveReady = null;
|
|
6965
|
-
rejectReady = null;
|
|
6966
|
-
}
|
|
6967
|
-
};
|
|
6968
|
-
addEventListener("message", onMessage);
|
|
6969
|
-
const prepare = (confirmation = "always") => {
|
|
6970
|
-
if (signerWindow && readyPromise && activeConfirmation === confirmation) return;
|
|
6971
|
-
if (signerWindow || readyPromise) close();
|
|
6972
|
-
state = crypto.randomUUID?.() ?? `${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
|
6973
|
-
const url = new URL(params.authorizeUrl, location.href);
|
|
6974
|
-
url.searchParams.set("action", "fluent_sign");
|
|
6975
|
-
url.searchParams.set("origin", location.origin);
|
|
6976
|
-
url.searchParams.set("state", state);
|
|
6977
|
-
url.searchParams.set("confirmation", confirmation);
|
|
6978
|
-
activeConfirmation = confirmation;
|
|
6979
|
-
signerWindow = window.open(
|
|
6980
|
-
url.toString(),
|
|
6981
|
-
"fluent-connect-signer",
|
|
6982
|
-
"popup=yes,width=520,height=720,resizable=yes,scrollbars=yes"
|
|
6983
|
-
);
|
|
6984
|
-
if (!signerWindow) {
|
|
6985
|
-
close();
|
|
6986
|
-
throw new Error("Allow popups for this app to sign with Fluent Connect");
|
|
6987
|
-
}
|
|
6988
|
-
readyPromise = new Promise((resolve, reject) => {
|
|
6989
|
-
resolveReady = resolve;
|
|
6990
|
-
rejectReady = reject;
|
|
6991
|
-
});
|
|
6992
|
-
readyPromise.catch(() => {
|
|
6993
|
-
});
|
|
6994
|
-
};
|
|
6995
|
-
const requestSignature = async (request) => {
|
|
6996
|
-
prepare(request.confirmation);
|
|
6997
|
-
if (!signerWindow || !readyPromise) {
|
|
6998
|
-
throw new Error("Fluent Connect signer window is unavailable");
|
|
6999
|
-
}
|
|
7000
|
-
try {
|
|
7001
|
-
await withTimeout(
|
|
7002
|
-
readyPromise,
|
|
7003
|
-
READY_TIMEOUT_MS,
|
|
7004
|
-
"Fluent Connect signer did not become ready"
|
|
7005
|
-
);
|
|
7006
|
-
if (signerWindow.closed) throw new Error("Fluent Connect signer window was closed");
|
|
7007
|
-
if (pending2) throw new Error("Another Fluent signature request is already pending");
|
|
7008
|
-
const signature = new Promise((resolve, reject) => {
|
|
7009
|
-
pending2 = { resolve, reject };
|
|
7010
|
-
signerWindow?.postMessage({ ...request, state }, authorizeOrigin);
|
|
7011
|
-
});
|
|
7012
|
-
return await withTimeout(
|
|
7013
|
-
signature,
|
|
7014
|
-
SIGNATURE_TIMEOUT_MS,
|
|
7015
|
-
"Fluent Connect signature request timed out"
|
|
7016
|
-
);
|
|
7017
|
-
} finally {
|
|
7018
|
-
close();
|
|
7019
|
-
}
|
|
7020
|
-
};
|
|
7021
|
-
return {
|
|
7022
|
-
address: params.address,
|
|
7023
|
-
prepare,
|
|
7024
|
-
signMessage: (message2, confirmation = "always") => requestSignature({
|
|
7025
|
-
type: "fluent:signer:request",
|
|
7026
|
-
method: "personal_sign",
|
|
7027
|
-
confirmation,
|
|
7028
|
-
address: params.address,
|
|
7029
|
-
message: message2
|
|
7030
|
-
}),
|
|
7031
|
-
signTypedData: (typedData, confirmation = "always") => requestSignature({
|
|
7032
|
-
type: "fluent:signer:request",
|
|
7033
|
-
method: "eth_signTypedData_v4",
|
|
7034
|
-
confirmation,
|
|
7035
|
-
address: params.address,
|
|
7036
|
-
typedData
|
|
7037
|
-
}),
|
|
7038
|
-
close: () => {
|
|
7039
|
-
removeEventListener("message", onMessage);
|
|
7040
|
-
rejectReady?.(new Error("Fluent Connect signer was closed"));
|
|
7041
|
-
pending2?.reject(new Error("Fluent Connect signer was closed"));
|
|
7042
|
-
close();
|
|
7043
|
-
}
|
|
7044
|
-
};
|
|
7081
|
+
var AdapterContext = createContext(null);
|
|
7082
|
+
function FluentPrivyProvider({ adapter, ...props }) {
|
|
7083
|
+
const Provider = adapter?.PrivyProvider ?? web.PrivyProvider;
|
|
7084
|
+
return /* @__PURE__ */ jsx(AdapterContext.Provider, { value: adapter ?? null, children: /* @__PURE__ */ jsx(Provider, { ...props }) });
|
|
7045
7085
|
}
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7086
|
+
var usePrivy2 = (...args) => {
|
|
7087
|
+
const adapter = useContext(AdapterContext);
|
|
7088
|
+
return (adapter?.usePrivy ?? web.usePrivy)(...args);
|
|
7089
|
+
};
|
|
7090
|
+
var useSignMessage2 = (...args) => {
|
|
7091
|
+
const adapter = useContext(AdapterContext);
|
|
7092
|
+
return (adapter?.useSignMessage ?? web.useSignMessage)(...args);
|
|
7093
|
+
};
|
|
7094
|
+
var useSignTypedData2 = (...args) => {
|
|
7095
|
+
const adapter = useContext(AdapterContext);
|
|
7096
|
+
return (adapter?.useSignTypedData ?? web.useSignTypedData)(...args);
|
|
7097
|
+
};
|
|
7098
|
+
var useWallets2 = (...args) => {
|
|
7099
|
+
const adapter = useContext(AdapterContext);
|
|
7100
|
+
return (adapter?.useWallets ?? web.useWallets)(...args);
|
|
7101
|
+
};
|
|
7102
|
+
var useIdentityToken2 = (...args) => {
|
|
7103
|
+
const adapter = useContext(AdapterContext);
|
|
7104
|
+
return (adapter?.useIdentityToken ?? web.useIdentityToken)(...args);
|
|
7105
|
+
};
|
|
7106
|
+
var useUser2 = (...args) => {
|
|
7107
|
+
const adapter = useContext(AdapterContext);
|
|
7108
|
+
return (adapter?.useUser ?? web.useUser)(...args);
|
|
7109
|
+
};
|
|
7110
|
+
var useLinkAccount2 = (...args) => {
|
|
7111
|
+
const adapter = useContext(AdapterContext);
|
|
7112
|
+
return (adapter?.useLinkAccount ?? web.useLinkAccount)(...args);
|
|
7113
|
+
};
|
|
7114
|
+
var useLoginWithSiwe2 = (...args) => {
|
|
7115
|
+
const adapter = useContext(AdapterContext);
|
|
7116
|
+
return (adapter?.useLoginWithSiwe ?? web.useLoginWithSiwe)(...args);
|
|
7117
|
+
};
|
|
7118
|
+
var useModalStatus2 = (...args) => {
|
|
7119
|
+
const adapter = useContext(AdapterContext);
|
|
7120
|
+
return (adapter?.useModalStatus ?? web.useModalStatus)(...args);
|
|
7121
|
+
};
|
|
7122
|
+
var useCreateWallet2 = (...args) => {
|
|
7123
|
+
const adapter = useContext(AdapterContext);
|
|
7124
|
+
return (adapter?.useCreateWallet ?? web.useCreateWallet)(...args);
|
|
7125
|
+
};
|
|
7126
|
+
var useLoginWithEmail2 = (...args) => {
|
|
7127
|
+
const adapter = useContext(AdapterContext);
|
|
7128
|
+
return (adapter?.useLoginWithEmail ?? web.useLoginWithEmail)(...args);
|
|
7129
|
+
};
|
|
7130
|
+
var useLoginWithOAuth2 = (...args) => {
|
|
7131
|
+
const adapter = useContext(AdapterContext);
|
|
7132
|
+
return (adapter?.useLoginWithOAuth ?? web.useLoginWithOAuth)(...args);
|
|
7133
|
+
};
|
|
7134
|
+
var useLoginWithPasskey2 = (...args) => {
|
|
7135
|
+
const adapter = useContext(AdapterContext);
|
|
7136
|
+
return (adapter?.useLoginWithPasskey ?? web.useLoginWithPasskey)(...args);
|
|
7137
|
+
};
|
|
7138
|
+
var useLinkWithPasskey2 = (...args) => {
|
|
7139
|
+
const adapter = useContext(AdapterContext);
|
|
7140
|
+
return (adapter?.useLinkWithPasskey ?? web.useLinkWithPasskey)(...args);
|
|
7141
|
+
};
|
|
7142
|
+
function Captcha2(props) {
|
|
7143
|
+
const adapter = useContext(AdapterContext);
|
|
7144
|
+
const Component = adapter?.Captcha ?? web.Captcha;
|
|
7145
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
7146
|
+
}
|
|
7147
|
+
var FLUENT_RPC_TIMEOUT_MS = 3e4;
|
|
7148
|
+
var FLUENT_RPC_RETRY_COUNT = 3;
|
|
7149
|
+
var FLUENT_RPC_RETRY_DELAY_MS = 300;
|
|
7150
|
+
function createFluentRpcTransport(chain) {
|
|
7151
|
+
const urls = chain.rpcUrls.default.http;
|
|
7152
|
+
const endpoints = urls.length > 0 ? urls : [void 0];
|
|
7153
|
+
return fallback(
|
|
7154
|
+
endpoints.map(
|
|
7155
|
+
(url) => http(url, {
|
|
7156
|
+
timeout: FLUENT_RPC_TIMEOUT_MS,
|
|
7157
|
+
retryCount: FLUENT_RPC_RETRY_COUNT,
|
|
7158
|
+
retryDelay: FLUENT_RPC_RETRY_DELAY_MS
|
|
7053
7159
|
})
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7160
|
+
),
|
|
7161
|
+
// Each http() already retries; let fallback only rank/fail over between URLs.
|
|
7162
|
+
{ retryCount: 0 }
|
|
7163
|
+
);
|
|
7164
|
+
}
|
|
7165
|
+
function createFluentBundlerTransport(url) {
|
|
7166
|
+
return http(url, {
|
|
7167
|
+
timeout: FLUENT_RPC_TIMEOUT_MS,
|
|
7168
|
+
retryCount: FLUENT_RPC_RETRY_COUNT,
|
|
7169
|
+
retryDelay: FLUENT_RPC_RETRY_DELAY_MS
|
|
7170
|
+
});
|
|
7058
7171
|
}
|
|
7172
|
+
|
|
7173
|
+
// src/core/zerodevPaymaster.ts
|
|
7059
7174
|
var FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY = "selfFunded=true";
|
|
7060
7175
|
var FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT = "0x000000000000000000000000000000000000dEaD";
|
|
7061
7176
|
function getFluentZeroDevErc20PaymasterTokens(network = "testnet") {
|
|
@@ -7087,6 +7202,7 @@ function createFluentZeroDevSponsoredPaymaster(params) {
|
|
|
7087
7202
|
const paymasterClient = createZeroDevPaymasterClient({
|
|
7088
7203
|
chain: params.chain,
|
|
7089
7204
|
transport: http(params.rpcUrl, {
|
|
7205
|
+
timeout: FLUENT_RPC_TIMEOUT_MS,
|
|
7090
7206
|
fetchOptions: { headers: { Authorization: `Bearer ${params.bearerToken}` } }
|
|
7091
7207
|
})
|
|
7092
7208
|
});
|
|
@@ -7113,7 +7229,8 @@ function createFluentZeroDevErc20PaymasterClient(params = {}) {
|
|
|
7113
7229
|
return createZeroDevPaymasterClient({
|
|
7114
7230
|
chain,
|
|
7115
7231
|
transport: http(
|
|
7116
|
-
params.paymasterRpcUrl ?? createFluentZeroDevErc20PaymasterRpcUrl({ chainId: chain.id })
|
|
7232
|
+
params.paymasterRpcUrl ?? createFluentZeroDevErc20PaymasterRpcUrl({ chainId: chain.id }),
|
|
7233
|
+
{ timeout: FLUENT_RPC_TIMEOUT_MS }
|
|
7117
7234
|
)
|
|
7118
7235
|
});
|
|
7119
7236
|
}
|
|
@@ -7180,7 +7297,7 @@ async function sendFluentZeroDevErc20PaymasterDemo(params) {
|
|
|
7180
7297
|
const client2 = createKernelAccountClient({
|
|
7181
7298
|
account: params.kernel.account,
|
|
7182
7299
|
chain,
|
|
7183
|
-
bundlerTransport: http(params.kernel.zeroDevRpcUrl),
|
|
7300
|
+
bundlerTransport: http(params.kernel.zeroDevRpcUrl, { timeout: FLUENT_RPC_TIMEOUT_MS }),
|
|
7184
7301
|
client: params.kernel.publicClient,
|
|
7185
7302
|
paymaster: createFluentZeroDevErc20Paymaster({
|
|
7186
7303
|
chain,
|
|
@@ -7256,6 +7373,7 @@ async function sendWithSponsorship(params) {
|
|
|
7256
7373
|
ownGasClient,
|
|
7257
7374
|
waitFor,
|
|
7258
7375
|
disableSponsorship,
|
|
7376
|
+
isOperationFailure,
|
|
7259
7377
|
log
|
|
7260
7378
|
} = params;
|
|
7261
7379
|
const settle = async (settlementClient, userOpHash, sponsored, sponsorshipReason) => {
|
|
@@ -7286,6 +7404,7 @@ async function sendWithSponsorship(params) {
|
|
|
7286
7404
|
try {
|
|
7287
7405
|
return { ok: true, userOpHash: await sendSponsored(client2) };
|
|
7288
7406
|
} catch (err) {
|
|
7407
|
+
if (isOperationFailure?.(err)) throw err;
|
|
7289
7408
|
const failure = getSponsorshipFailure(err);
|
|
7290
7409
|
if (failure.disableSponsorship) disableSponsorship();
|
|
7291
7410
|
return { ok: false, failure, error: err };
|
|
@@ -7315,98 +7434,449 @@ function isRejectedBearer(failure) {
|
|
|
7315
7434
|
function sponsorshipTokenErrorCode(err) {
|
|
7316
7435
|
return err instanceof FluentAuthError ? err.code : "unknown";
|
|
7317
7436
|
}
|
|
7437
|
+
var FLUENT_CHAIN_FEE_MARGIN_PERCENT = 110n;
|
|
7438
|
+
function quoteFluentChainFees(gasPrice) {
|
|
7439
|
+
return {
|
|
7440
|
+
maxPriorityFeePerGas: gasPrice,
|
|
7441
|
+
maxFeePerGas: gasPrice * FLUENT_CHAIN_FEE_MARGIN_PERCENT / 100n
|
|
7442
|
+
};
|
|
7443
|
+
}
|
|
7444
|
+
var FLUENT_FEE_ATTEMPT = /* @__PURE__ */ Symbol.for("fluent.userOperation.feeAttempt");
|
|
7445
|
+
function withFluentFeeAttempt(account, attempt) {
|
|
7446
|
+
return { ...account, [FLUENT_FEE_ATTEMPT]: attempt };
|
|
7447
|
+
}
|
|
7448
|
+
function readFluentFeeAttempt(account) {
|
|
7449
|
+
if (typeof account !== "object" || account === null) return void 0;
|
|
7450
|
+
const attempt = account[FLUENT_FEE_ATTEMPT];
|
|
7451
|
+
return typeof attempt === "object" && attempt !== null ? attempt : void 0;
|
|
7452
|
+
}
|
|
7453
|
+
async function readFluentBundlerFees(bundlerClient) {
|
|
7454
|
+
return getUserOperationGasPrice(
|
|
7455
|
+
bundlerClient
|
|
7456
|
+
);
|
|
7457
|
+
}
|
|
7458
|
+
function createFluentUserOperationFeeHook(params) {
|
|
7459
|
+
return async ({ account, bundlerClient }) => {
|
|
7460
|
+
const attempt = readFluentFeeAttempt(account);
|
|
7461
|
+
const requested = attempt?.feeSource ?? params.readFeeSource();
|
|
7462
|
+
if (requested === "chain") {
|
|
7463
|
+
try {
|
|
7464
|
+
const fees2 = quoteFluentChainFees(await params.readGasPrice());
|
|
7465
|
+
if (attempt) attempt.settledFeeSource = "chain";
|
|
7466
|
+
debugLog("[fluent user operation fees] chain quote", {
|
|
7467
|
+
maxFeePerGas: fees2.maxFeePerGas.toString(),
|
|
7468
|
+
maxPriorityFeePerGas: fees2.maxPriorityFeePerGas.toString()
|
|
7469
|
+
});
|
|
7470
|
+
return fees2;
|
|
7471
|
+
} catch (err) {
|
|
7472
|
+
debugWarn("[fluent user operation fees] chain gas price unavailable, asking the bundler", {
|
|
7473
|
+
message: err instanceof Error ? err.message : String(err)
|
|
7474
|
+
});
|
|
7475
|
+
}
|
|
7476
|
+
}
|
|
7477
|
+
const fees = await readFluentBundlerFees(bundlerClient);
|
|
7478
|
+
if (attempt) attempt.settledFeeSource = "bundler";
|
|
7479
|
+
return fees;
|
|
7480
|
+
};
|
|
7481
|
+
}
|
|
7482
|
+
var FLUENT_FEE_REJECTION_MESSAGES = [
|
|
7483
|
+
"maxFeePerGas must be at least",
|
|
7484
|
+
"maxPriorityFeePerGas must be at least"
|
|
7485
|
+
];
|
|
7486
|
+
function isFluentFeeRejection(err) {
|
|
7487
|
+
const needles = FLUENT_FEE_REJECTION_MESSAGES.map((message2) => message2.toLowerCase());
|
|
7488
|
+
for (const text of errorTexts(err)) {
|
|
7489
|
+
const lowered = text.toLowerCase();
|
|
7490
|
+
if (needles.some((needle) => lowered.includes(needle))) return true;
|
|
7491
|
+
}
|
|
7492
|
+
return false;
|
|
7493
|
+
}
|
|
7494
|
+
function errorTexts(err) {
|
|
7495
|
+
const texts = [];
|
|
7496
|
+
let current = err;
|
|
7497
|
+
for (let depth = 0; depth < 10 && current !== void 0 && current !== null; depth += 1) {
|
|
7498
|
+
if (current instanceof BaseError) {
|
|
7499
|
+
texts.push(current.shortMessage, current.details, ...current.metaMessages ?? []);
|
|
7500
|
+
}
|
|
7501
|
+
if (current instanceof Error) {
|
|
7502
|
+
texts.push(current.message);
|
|
7503
|
+
current = current.cause;
|
|
7504
|
+
continue;
|
|
7505
|
+
}
|
|
7506
|
+
if (typeof current === "string") texts.push(current);
|
|
7507
|
+
break;
|
|
7508
|
+
}
|
|
7509
|
+
return texts.filter((text) => typeof text === "string" && text.length > 0);
|
|
7510
|
+
}
|
|
7318
7511
|
|
|
7319
7512
|
// src/core/userOperationTiming.ts
|
|
7320
|
-
|
|
7513
|
+
function monotonicNow() {
|
|
7514
|
+
return readClock(() => performance.now());
|
|
7515
|
+
}
|
|
7516
|
+
function epochNow() {
|
|
7517
|
+
return readClock(() => Date.now());
|
|
7518
|
+
}
|
|
7519
|
+
function readClock(read) {
|
|
7520
|
+
try {
|
|
7521
|
+
const value = read();
|
|
7522
|
+
return Number.isFinite(value) ? value : void 0;
|
|
7523
|
+
} catch {
|
|
7524
|
+
return void 0;
|
|
7525
|
+
}
|
|
7526
|
+
}
|
|
7527
|
+
function span(from, to) {
|
|
7528
|
+
return from === void 0 || to === void 0 ? void 0 : to - from;
|
|
7529
|
+
}
|
|
7530
|
+
function guarded(write) {
|
|
7531
|
+
return (...args) => {
|
|
7532
|
+
try {
|
|
7533
|
+
write(...args);
|
|
7534
|
+
} catch {
|
|
7535
|
+
}
|
|
7536
|
+
};
|
|
7537
|
+
}
|
|
7538
|
+
var timingLog = guarded(debugLog);
|
|
7539
|
+
var timingWarn = guarded(debugWarn);
|
|
7540
|
+
async function sendUserOperationWithTiming(client2, args, gas, record, feeAttempt) {
|
|
7321
7541
|
const preparedArgs = withUserOperationGas(client2, args, gas);
|
|
7322
|
-
|
|
7323
|
-
const
|
|
7542
|
+
const startedAt = monotonicNow();
|
|
7543
|
+
const startedAtEpochMs = epochNow();
|
|
7324
7544
|
let signingAt;
|
|
7325
7545
|
let signedAt;
|
|
7546
|
+
let askedToSign = false;
|
|
7547
|
+
let signatureReturned = false;
|
|
7326
7548
|
let success = false;
|
|
7327
7549
|
const account = preparedArgs.account;
|
|
7328
7550
|
const observedAccount = {
|
|
7329
7551
|
...account,
|
|
7330
7552
|
async signUserOperation(operation) {
|
|
7331
|
-
|
|
7332
|
-
|
|
7553
|
+
askedToSign = true;
|
|
7554
|
+
signingAt = monotonicNow();
|
|
7555
|
+
timingLog("[fluent execution stage]", {
|
|
7333
7556
|
stage: "signing",
|
|
7334
|
-
preparationMs: signingAt
|
|
7557
|
+
preparationMs: span(startedAt, signingAt)
|
|
7335
7558
|
});
|
|
7336
7559
|
const signature = await account.signUserOperation(operation);
|
|
7337
|
-
|
|
7338
|
-
|
|
7560
|
+
signatureReturned = true;
|
|
7561
|
+
signedAt = monotonicNow();
|
|
7562
|
+
timingLog("[fluent execution stage]", {
|
|
7339
7563
|
stage: "broadcasting",
|
|
7340
|
-
signingMs: signedAt
|
|
7564
|
+
signingMs: span(signingAt, signedAt)
|
|
7341
7565
|
});
|
|
7342
7566
|
return signature;
|
|
7343
7567
|
}
|
|
7344
7568
|
};
|
|
7345
|
-
|
|
7569
|
+
const submittedAccount = feeAttempt ? withFluentFeeAttempt(observedAccount, feeAttempt) : observedAccount;
|
|
7570
|
+
let closed;
|
|
7571
|
+
const close = () => {
|
|
7572
|
+
if (closed) return closed.measurement;
|
|
7573
|
+
const finishedAt = monotonicNow();
|
|
7574
|
+
const finishedAtEpochMs = epochNow();
|
|
7575
|
+
closed = startedAt === void 0 || startedAtEpochMs === void 0 || finishedAt === void 0 || finishedAtEpochMs === void 0 ? {} : {
|
|
7576
|
+
measurement: {
|
|
7577
|
+
startedAt,
|
|
7578
|
+
startedAtEpochMs,
|
|
7579
|
+
// The attempt's whole span counts as preparation only when preparation is where
|
|
7580
|
+
// it ended; once a signature was asked for, preparation is measured to that
|
|
7581
|
+
// request or not at all.
|
|
7582
|
+
prepareMs: askedToSign ? span(startedAt, signingAt) : finishedAt - startedAt,
|
|
7583
|
+
// Signing that never returned was still running when the attempt ended, so the
|
|
7584
|
+
// attempt's end is its real boundary. Signing that did return, at an unreadable
|
|
7585
|
+
// instant, has no measurable end — and must not borrow the broadcast's.
|
|
7586
|
+
signMs: span(signingAt, signatureReturned ? signedAt : finishedAt),
|
|
7587
|
+
broadcastMs: span(signedAt, finishedAt),
|
|
7588
|
+
finishedAt,
|
|
7589
|
+
finishedAtEpochMs
|
|
7590
|
+
}
|
|
7591
|
+
};
|
|
7592
|
+
return closed.measurement;
|
|
7593
|
+
};
|
|
7594
|
+
let settledUserOpHash;
|
|
7595
|
+
timingLog("[fluent execution stage]", { stage: "preparing" });
|
|
7346
7596
|
try {
|
|
7347
|
-
|
|
7597
|
+
settledUserOpHash = await client2.sendUserOperation({
|
|
7598
|
+
...preparedArgs,
|
|
7599
|
+
account: submittedAccount
|
|
7600
|
+
});
|
|
7348
7601
|
success = true;
|
|
7349
|
-
return
|
|
7602
|
+
return { userOpHash: settledUserOpHash, measurement: close() };
|
|
7350
7603
|
} finally {
|
|
7351
|
-
const
|
|
7352
|
-
|
|
7604
|
+
const measurement = close();
|
|
7605
|
+
try {
|
|
7606
|
+
record?.(
|
|
7607
|
+
settledUserOpHash === void 0 ? { measurement } : { userOpHash: settledUserOpHash, measurement }
|
|
7608
|
+
);
|
|
7609
|
+
} catch {
|
|
7610
|
+
}
|
|
7611
|
+
timingLog("[fluent submission timing]", {
|
|
7353
7612
|
success,
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7613
|
+
// Which source actually quoted this attempt's fees, not which one it asked: a chain
|
|
7614
|
+
// quote that failed is reported as the bundler's, because that is what was paid for.
|
|
7615
|
+
feeSource: feeAttempt?.settledFeeSource,
|
|
7616
|
+
preparationMs: measurement?.prepareMs,
|
|
7617
|
+
signingMs: measurement?.signMs,
|
|
7618
|
+
broadcastMs: measurement?.broadcastMs,
|
|
7619
|
+
// Not `totalMs`: this is one submission, and the send's total runs on to the receipt.
|
|
7620
|
+
// Two different numbers under one name is the confusion this Issue exists to end.
|
|
7621
|
+
submissionMs: span(measurement?.startedAt, measurement?.finishedAt)
|
|
7358
7622
|
});
|
|
7359
7623
|
}
|
|
7360
7624
|
}
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
const
|
|
7365
|
-
|
|
7366
|
-
return fallback(
|
|
7367
|
-
endpoints.map(
|
|
7368
|
-
(url) => http(url, {
|
|
7369
|
-
retryCount: FLUENT_RPC_RETRY_COUNT,
|
|
7370
|
-
retryDelay: FLUENT_RPC_RETRY_DELAY_MS
|
|
7371
|
-
})
|
|
7372
|
-
),
|
|
7373
|
-
// Each http() already retries; let fallback only rank/fail over between URLs.
|
|
7374
|
-
{ retryCount: 0 }
|
|
7625
|
+
async function closeSendTiming(params) {
|
|
7626
|
+
const { attempts, settledUserOpHash, receivedAt, receivedAtEpochMs } = params;
|
|
7627
|
+
const first = attempts[0];
|
|
7628
|
+
const settled = attempts.find(
|
|
7629
|
+
(attempt) => attempt.userOpHash !== void 0 && attempt.userOpHash === settledUserOpHash
|
|
7375
7630
|
);
|
|
7631
|
+
if (!first?.measurement || !settled?.measurement) return void 0;
|
|
7632
|
+
const measurement = settled.measurement;
|
|
7633
|
+
const firstMeasurement = first.measurement;
|
|
7634
|
+
const blockTimestampEpochMs = await readBlockTimestamp(params.getBlock, params.blockNumber);
|
|
7635
|
+
return {
|
|
7636
|
+
prepareMs: measurement.prepareMs,
|
|
7637
|
+
signMs: measurement.signMs,
|
|
7638
|
+
broadcastMs: measurement.broadcastMs,
|
|
7639
|
+
// Signed, unclamped, and across two clocks on purpose — see `FluentExecuteTiming`.
|
|
7640
|
+
inclusionMs: blockTimestampEpochMs === void 0 ? void 0 : blockTimestampEpochMs - measurement.finishedAtEpochMs,
|
|
7641
|
+
detectMs: blockTimestampEpochMs === void 0 ? void 0 : receivedAtEpochMs - blockTimestampEpochMs,
|
|
7642
|
+
// Everything before the settled attempt started: the rejected submissions and the fresh
|
|
7643
|
+
// token exchange between them. One monotonic subtraction, so it cannot go negative.
|
|
7644
|
+
retryMs: measurement.startedAt - firstMeasurement.startedAt,
|
|
7645
|
+
totalMs: receivedAt - firstMeasurement.startedAt,
|
|
7646
|
+
instants: {
|
|
7647
|
+
submittedAtEpochMs: firstMeasurement.startedAtEpochMs,
|
|
7648
|
+
broadcastedAtEpochMs: measurement.finishedAtEpochMs,
|
|
7649
|
+
receivedAtEpochMs,
|
|
7650
|
+
blockTimestampEpochMs,
|
|
7651
|
+
attempts: attempts.length
|
|
7652
|
+
}
|
|
7653
|
+
};
|
|
7376
7654
|
}
|
|
7377
|
-
function
|
|
7378
|
-
|
|
7379
|
-
retryCount: FLUENT_RPC_RETRY_COUNT,
|
|
7380
|
-
retryDelay: FLUENT_RPC_RETRY_DELAY_MS
|
|
7381
|
-
});
|
|
7382
|
-
}
|
|
7383
|
-
|
|
7384
|
-
// src/utils/buildFluentBridgeUrl.ts
|
|
7385
|
-
function buildFluentBridgeUrl(bridgeUrl, recipient) {
|
|
7386
|
-
if (!recipient) return bridgeUrl;
|
|
7655
|
+
async function readBlockTimestamp(getBlock, blockNumber) {
|
|
7656
|
+
if (!getBlock || blockNumber === void 0) return void 0;
|
|
7387
7657
|
try {
|
|
7388
|
-
const
|
|
7389
|
-
|
|
7390
|
-
return
|
|
7658
|
+
const block = await getBlock({ blockNumber });
|
|
7659
|
+
if (typeof block?.timestamp !== "bigint") return void 0;
|
|
7660
|
+
return Number(block.timestamp) * 1e3;
|
|
7391
7661
|
} catch {
|
|
7392
|
-
|
|
7393
|
-
|
|
7662
|
+
timingWarn("[fluent inclusion timing] including block unavailable", {
|
|
7663
|
+
blockNumber: blockNumber.toString()
|
|
7664
|
+
});
|
|
7665
|
+
return void 0;
|
|
7394
7666
|
}
|
|
7395
7667
|
}
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7668
|
+
var FLUENT_INCLUSION_TIMEOUT_MS = 12e4;
|
|
7669
|
+
var FLUENT_INCLUSION_POLL_INTERVAL_MS = 200;
|
|
7670
|
+
var FLUENT_USER_OPERATION_EVENT = {
|
|
7671
|
+
type: "event",
|
|
7672
|
+
name: "UserOperationEvent",
|
|
7673
|
+
inputs: [
|
|
7674
|
+
{ name: "userOpHash", type: "bytes32", indexed: true },
|
|
7675
|
+
{ name: "sender", type: "address", indexed: true },
|
|
7676
|
+
{ name: "paymaster", type: "address", indexed: true },
|
|
7677
|
+
{ name: "nonce", type: "uint256", indexed: false },
|
|
7678
|
+
{ name: "success", type: "bool", indexed: false },
|
|
7679
|
+
{ name: "actualGasCost", type: "uint256", indexed: false },
|
|
7680
|
+
{ name: "actualGasUsed", type: "uint256", indexed: false }
|
|
7681
|
+
]
|
|
7682
|
+
};
|
|
7683
|
+
var FLUENT_USER_OPERATION_REVERT_REASON_EVENT = {
|
|
7684
|
+
type: "event",
|
|
7685
|
+
name: "UserOperationRevertReason",
|
|
7686
|
+
inputs: [
|
|
7687
|
+
{ name: "userOpHash", type: "bytes32", indexed: true },
|
|
7688
|
+
{ name: "sender", type: "address", indexed: true },
|
|
7689
|
+
{ name: "nonce", type: "uint256", indexed: false },
|
|
7690
|
+
{ name: "revertReason", type: "bytes", indexed: false }
|
|
7691
|
+
]
|
|
7692
|
+
};
|
|
7693
|
+
var FLUENT_BEFORE_EXECUTION_EVENT = {
|
|
7694
|
+
type: "event",
|
|
7695
|
+
name: "BeforeExecution",
|
|
7696
|
+
inputs: []
|
|
7697
|
+
};
|
|
7698
|
+
var USER_OPERATION_EVENT_TOPIC = toEventSelector(FLUENT_USER_OPERATION_EVENT).toLowerCase();
|
|
7699
|
+
var USER_OPERATION_REVERT_REASON_TOPIC = toEventSelector(
|
|
7700
|
+
FLUENT_USER_OPERATION_REVERT_REASON_EVENT
|
|
7701
|
+
).toLowerCase();
|
|
7702
|
+
var BEFORE_EXECUTION_TOPIC = toEventSelector(FLUENT_BEFORE_EXECUTION_EVENT).toLowerCase();
|
|
7703
|
+
async function readFluentInclusionAnchor(chainClient) {
|
|
7400
7704
|
try {
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7705
|
+
return await getBlockNumber(chainClient, { cacheTime: 0 });
|
|
7706
|
+
} catch (err) {
|
|
7707
|
+
debugWarn("[fluent inclusion] anchor block unavailable, waiting on the bundler", {
|
|
7708
|
+
message: err instanceof Error ? err.message : String(err)
|
|
7709
|
+
});
|
|
7710
|
+
return void 0;
|
|
7405
7711
|
}
|
|
7406
7712
|
}
|
|
7407
|
-
function
|
|
7408
|
-
|
|
7409
|
-
|
|
7713
|
+
async function waitForFluentUserOperationReceipt(params) {
|
|
7714
|
+
const { bundlerClient, chainClient, hash, entryPoint, anchorBlockNumber, receiptSource } = params;
|
|
7715
|
+
const now = params.now ?? (() => Date.now());
|
|
7716
|
+
const deadlineAt = now() + FLUENT_INCLUSION_TIMEOUT_MS;
|
|
7717
|
+
const reportSource = (source) => {
|
|
7718
|
+
try {
|
|
7719
|
+
params.onReceiptSource?.(source);
|
|
7720
|
+
} catch {
|
|
7721
|
+
}
|
|
7722
|
+
};
|
|
7723
|
+
const waitOnBundler = (timeout = FLUENT_INCLUSION_TIMEOUT_MS) => {
|
|
7724
|
+
reportSource("bundler");
|
|
7725
|
+
return bundlerClient.waitForUserOperationReceipt({
|
|
7726
|
+
hash,
|
|
7727
|
+
pollingInterval: FLUENT_INCLUSION_POLL_INTERVAL_MS,
|
|
7728
|
+
timeout
|
|
7729
|
+
});
|
|
7730
|
+
};
|
|
7731
|
+
const remainingMs = () => Math.max(1, deadlineAt - now());
|
|
7732
|
+
if (receiptSource === "bundler") return waitOnBundler();
|
|
7733
|
+
if (anchorBlockNumber === void 0) return waitOnBundler();
|
|
7734
|
+
const fromBlock = anchorBlockNumber > 0n ? anchorBlockNumber - 1n : 0n;
|
|
7735
|
+
const pollChain = async () => {
|
|
7736
|
+
for (; ; ) {
|
|
7737
|
+
if (now() >= deadlineAt) throw new WaitForUserOperationReceiptTimeoutError({ hash });
|
|
7738
|
+
let events;
|
|
7739
|
+
try {
|
|
7740
|
+
events = await readUserOperationEvents({ chainClient, entryPoint, hash, fromBlock });
|
|
7741
|
+
} catch (err) {
|
|
7742
|
+
debugWarn("[fluent inclusion] chain logs unavailable, waiting on the bundler", {
|
|
7743
|
+
userOpHash: hash,
|
|
7744
|
+
message: err instanceof Error ? err.message : String(err)
|
|
7745
|
+
});
|
|
7746
|
+
return waitOnBundler(remainingMs());
|
|
7747
|
+
}
|
|
7748
|
+
const event = events[0];
|
|
7749
|
+
if (event) {
|
|
7750
|
+
try {
|
|
7751
|
+
const receipt = await buildChainReceipt({
|
|
7752
|
+
chainClient,
|
|
7753
|
+
entryPoint,
|
|
7754
|
+
hash,
|
|
7755
|
+
event
|
|
7756
|
+
});
|
|
7757
|
+
reportSource("chain");
|
|
7758
|
+
debugLog("[fluent inclusion] receipt built from the chain", {
|
|
7759
|
+
userOpHash: hash,
|
|
7760
|
+
transactionHash: receipt.receipt.transactionHash
|
|
7761
|
+
});
|
|
7762
|
+
return receipt;
|
|
7763
|
+
} catch (err) {
|
|
7764
|
+
debugWarn("[fluent inclusion] transaction receipt unavailable, waiting on the bundler", {
|
|
7765
|
+
userOpHash: hash,
|
|
7766
|
+
message: err instanceof Error ? err.message : String(err)
|
|
7767
|
+
});
|
|
7768
|
+
return waitOnBundler(remainingMs());
|
|
7769
|
+
}
|
|
7770
|
+
}
|
|
7771
|
+
await delay(FLUENT_INCLUSION_POLL_INTERVAL_MS);
|
|
7772
|
+
}
|
|
7773
|
+
};
|
|
7774
|
+
return untilDeadline(pollChain(), remainingMs(), hash);
|
|
7775
|
+
}
|
|
7776
|
+
function untilDeadline(work, msLeft, hash) {
|
|
7777
|
+
let timer;
|
|
7778
|
+
const expiry = new Promise((_resolve, reject) => {
|
|
7779
|
+
timer = setTimeout(() => {
|
|
7780
|
+
reject(new WaitForUserOperationReceiptTimeoutError({ hash }));
|
|
7781
|
+
}, msLeft);
|
|
7782
|
+
});
|
|
7783
|
+
return Promise.race([work, expiry]).finally(() => {
|
|
7784
|
+
clearTimeout(timer);
|
|
7785
|
+
});
|
|
7786
|
+
}
|
|
7787
|
+
async function readUserOperationEvents(params) {
|
|
7788
|
+
return getLogs(params.chainClient, {
|
|
7789
|
+
address: params.entryPoint,
|
|
7790
|
+
event: FLUENT_USER_OPERATION_EVENT,
|
|
7791
|
+
args: { userOpHash: params.hash },
|
|
7792
|
+
fromBlock: params.fromBlock,
|
|
7793
|
+
// A log whose data does not decode against this event is not this event: better dropped
|
|
7794
|
+
// than turned into a receipt with absent fields.
|
|
7795
|
+
strict: true
|
|
7796
|
+
});
|
|
7797
|
+
}
|
|
7798
|
+
async function buildChainReceipt(params) {
|
|
7799
|
+
const { chainClient, entryPoint, hash, event } = params;
|
|
7800
|
+
const transactionReceipt = await getTransactionReceipt(chainClient, {
|
|
7801
|
+
hash: event.transactionHash
|
|
7802
|
+
});
|
|
7803
|
+
const built = {
|
|
7804
|
+
userOpHash: hash,
|
|
7805
|
+
entryPoint,
|
|
7806
|
+
sender: event.args.sender,
|
|
7807
|
+
nonce: event.args.nonce,
|
|
7808
|
+
success: event.args.success,
|
|
7809
|
+
// The zero address is the EntryPoint's spelling of "no paymaster", and a bundler's receipt
|
|
7810
|
+
// leaves the field out for it (alto `parseUserOpReceipt`); so does this one, so a reader
|
|
7811
|
+
// of either source sees the same absence when the account paid for itself.
|
|
7812
|
+
paymaster: event.args.paymaster === zeroAddress ? void 0 : event.args.paymaster,
|
|
7813
|
+
actualGasCost: event.args.actualGasCost,
|
|
7814
|
+
actualGasUsed: event.args.actualGasUsed,
|
|
7815
|
+
logs: sliceOperationLogs(transactionReceipt.logs, event.logIndex),
|
|
7816
|
+
reason: readRevertReason(transactionReceipt.logs, hash),
|
|
7817
|
+
receipt: transactionReceipt
|
|
7818
|
+
};
|
|
7819
|
+
return built;
|
|
7820
|
+
}
|
|
7821
|
+
function sliceOperationLogs(logs, logIndex) {
|
|
7822
|
+
const at = logs.findIndex((log) => log.logIndex === logIndex);
|
|
7823
|
+
if (at < 0) return [...logs];
|
|
7824
|
+
let from = 0;
|
|
7825
|
+
for (let index = at - 1; index >= 0; index -= 1) {
|
|
7826
|
+
const topic = logs[index]?.topics[0]?.toLowerCase();
|
|
7827
|
+
if (topic === USER_OPERATION_EVENT_TOPIC || topic === BEFORE_EXECUTION_TOPIC) {
|
|
7828
|
+
from = index + 1;
|
|
7829
|
+
break;
|
|
7830
|
+
}
|
|
7831
|
+
}
|
|
7832
|
+
return logs.slice(from, at);
|
|
7833
|
+
}
|
|
7834
|
+
function readRevertReason(logs, hash) {
|
|
7835
|
+
const target = hash.toLowerCase();
|
|
7836
|
+
for (const log of logs) {
|
|
7837
|
+
if (log.topics[0]?.toLowerCase() !== USER_OPERATION_REVERT_REASON_TOPIC) continue;
|
|
7838
|
+
if (log.topics[1]?.toLowerCase() !== target) continue;
|
|
7839
|
+
const decoded = decodeEventLog({
|
|
7840
|
+
abi: [FLUENT_USER_OPERATION_REVERT_REASON_EVENT],
|
|
7841
|
+
data: log.data,
|
|
7842
|
+
topics: log.topics
|
|
7843
|
+
});
|
|
7844
|
+
return decoded.args.revertReason;
|
|
7845
|
+
}
|
|
7846
|
+
return void 0;
|
|
7847
|
+
}
|
|
7848
|
+
function delay(ms) {
|
|
7849
|
+
return new Promise((resolve) => {
|
|
7850
|
+
setTimeout(resolve, ms);
|
|
7851
|
+
});
|
|
7852
|
+
}
|
|
7853
|
+
|
|
7854
|
+
// src/utils/buildFluentBridgeUrl.ts
|
|
7855
|
+
function buildFluentBridgeUrl(bridgeUrl, recipient) {
|
|
7856
|
+
if (!recipient) return bridgeUrl;
|
|
7857
|
+
try {
|
|
7858
|
+
const url = new URL(bridgeUrl);
|
|
7859
|
+
url.searchParams.set("recipient", recipient);
|
|
7860
|
+
return url.toString();
|
|
7861
|
+
} catch {
|
|
7862
|
+
const join = bridgeUrl.includes("?") ? "&" : "?";
|
|
7863
|
+
return `${bridgeUrl}${join}recipient=${encodeURIComponent(recipient)}`;
|
|
7864
|
+
}
|
|
7865
|
+
}
|
|
7866
|
+
|
|
7867
|
+
// src/utils/clearPrivyRecentLoginMethod.ts
|
|
7868
|
+
function clearPrivyRecentLoginMethod(appId) {
|
|
7869
|
+
if (typeof window === "undefined" || !appId) return;
|
|
7870
|
+
try {
|
|
7871
|
+
window.localStorage.removeItem(`privy:${appId}:recent-login-method`);
|
|
7872
|
+
window.localStorage.removeItem(`privy:${appId}:recent-login-wallet-client`);
|
|
7873
|
+
window.localStorage.removeItem(`privy:${appId}:recent-login-chain-type`);
|
|
7874
|
+
} catch {
|
|
7875
|
+
}
|
|
7876
|
+
}
|
|
7877
|
+
function cn(...inputs) {
|
|
7878
|
+
return twMerge(clsx(inputs));
|
|
7879
|
+
}
|
|
7410
7880
|
var WIDGET_STYLE_SCOPE = "fluent-root dark contents text-foreground";
|
|
7411
7881
|
var TOP_LAYER_STYLE_SCOPE = "fluent-root dark text-foreground";
|
|
7412
7882
|
var FluentPortalContainerContext = createContext(null);
|
|
@@ -7795,7 +8265,6 @@ function createLocalFluentSession(params) {
|
|
|
7795
8265
|
scopes: params.scopes,
|
|
7796
8266
|
issuedAt,
|
|
7797
8267
|
metadata: {
|
|
7798
|
-
authMode: "direct",
|
|
7799
8268
|
origin: params.app.origin
|
|
7800
8269
|
}
|
|
7801
8270
|
};
|
|
@@ -7992,38 +8461,64 @@ function stringifyWithBigInt(value, space) {
|
|
|
7992
8461
|
}
|
|
7993
8462
|
|
|
7994
8463
|
// src/widget/zerodevSession.ts
|
|
8464
|
+
var FLUENT_SIGNER_CHAIN_CHECK = /* @__PURE__ */ Symbol.for("fluent.signer.chainCheck");
|
|
8465
|
+
function carryFluentSignerChainCheck(account, check) {
|
|
8466
|
+
return { ...account, [FLUENT_SIGNER_CHAIN_CHECK]: check };
|
|
8467
|
+
}
|
|
8468
|
+
function readFluentSignerChainCheck(account) {
|
|
8469
|
+
if (typeof account !== "object" || account === null) return void 0;
|
|
8470
|
+
const check = account[FLUENT_SIGNER_CHAIN_CHECK];
|
|
8471
|
+
return typeof check === "function" ? check : void 0;
|
|
8472
|
+
}
|
|
8473
|
+
function withFluentSignerChainCheck(account, signatures, before) {
|
|
8474
|
+
const checked = { ...account };
|
|
8475
|
+
for (const name of signatures) {
|
|
8476
|
+
const sign = account[name];
|
|
8477
|
+
if (typeof sign !== "function") continue;
|
|
8478
|
+
checked[name] = async (...args) => {
|
|
8479
|
+
await before();
|
|
8480
|
+
return sign.apply(account, args);
|
|
8481
|
+
};
|
|
8482
|
+
}
|
|
8483
|
+
return checked;
|
|
8484
|
+
}
|
|
8485
|
+
function toFluentSigningAccount(params) {
|
|
8486
|
+
const check = () => ensureWalletOnFluentChain(params.wallet, params.chain);
|
|
8487
|
+
return withFluentSignerChainCheck(
|
|
8488
|
+
carryFluentSignerChainCheck(params.account, check),
|
|
8489
|
+
["signMessage", "signTypedData"],
|
|
8490
|
+
async () => {
|
|
8491
|
+
if (!params.readExecution().chainCheckBeforeSign) return;
|
|
8492
|
+
await check();
|
|
8493
|
+
}
|
|
8494
|
+
);
|
|
8495
|
+
}
|
|
7995
8496
|
function useFluentZeroDevAccount(hookOptions = {}) {
|
|
7996
8497
|
const { chain, network } = useFluentWidgetNetwork();
|
|
7997
|
-
const { authenticated, login: privyLogin, ready } =
|
|
8498
|
+
const { authenticated, login: privyLogin, ready } = usePrivy2();
|
|
7998
8499
|
const login = hookOptions.login ?? privyLogin;
|
|
7999
|
-
const { signMessage: promptSignMessage } =
|
|
8000
|
-
const { signTypedData: promptSignTypedData } =
|
|
8001
|
-
const { wallets } =
|
|
8500
|
+
const { signMessage: promptSignMessage } = useSignMessage2();
|
|
8501
|
+
const { signTypedData: promptSignTypedData } = useSignTypedData2();
|
|
8502
|
+
const { wallets } = useWallets2();
|
|
8002
8503
|
const [kernels, setKernels] = useState({});
|
|
8003
8504
|
const [error, setError] = useState(null);
|
|
8004
8505
|
const [smartAccountReady, setSmartAccountReady] = useState(false);
|
|
8005
8506
|
const initPromise = useRef({});
|
|
8006
8507
|
const sponsorshipUnavailable = useRef(false);
|
|
8007
8508
|
const embeddedWallet = wallets.find((wallet) => wallet.walletClientType === "privy");
|
|
8008
|
-
const hostedSigner = useMemo(
|
|
8009
|
-
() => hookOptions.allowHostedSigner !== false && hookOptions.authorizeUrl && hookOptions.sessionSignerAddress ? createFluentHostedSigner({
|
|
8010
|
-
address: hookOptions.sessionSignerAddress,
|
|
8011
|
-
authorizeUrl: hookOptions.authorizeUrl
|
|
8012
|
-
}) : null,
|
|
8013
|
-
[
|
|
8014
|
-
hookOptions.allowHostedSigner,
|
|
8015
|
-
hookOptions.authorizeUrl,
|
|
8016
|
-
hookOptions.sessionSignerAddress
|
|
8017
|
-
]
|
|
8018
|
-
);
|
|
8019
8509
|
const activeKernel = kernels.prompt ?? kernels.silent ?? null;
|
|
8510
|
+
const executionRef = useRef(FLUENT_CONNECT_DEFAULT_EXECUTION);
|
|
8511
|
+
executionRef.current = hookOptions.execution ?? FLUENT_CONNECT_DEFAULT_EXECUTION;
|
|
8512
|
+
const readExecution = useCallback(
|
|
8513
|
+
() => executionRef.current,
|
|
8514
|
+
[]
|
|
8515
|
+
);
|
|
8020
8516
|
useEffect(() => {
|
|
8021
8517
|
setKernels({});
|
|
8022
8518
|
setSmartAccountReady(false);
|
|
8023
8519
|
setError(null);
|
|
8024
8520
|
initPromise.current = {};
|
|
8025
8521
|
}, [chain.id]);
|
|
8026
|
-
useEffect(() => () => hostedSigner?.close(), [hostedSigner]);
|
|
8027
8522
|
const initialize2 = useCallback(async (options = {}) => {
|
|
8028
8523
|
const signerMode = options.signerMode ?? "prompt";
|
|
8029
8524
|
const cachedKernel = kernels[signerMode];
|
|
@@ -8048,15 +8543,13 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8048
8543
|
return cachedKernel;
|
|
8049
8544
|
}
|
|
8050
8545
|
const canUseLocalSigner = ready && authenticated && Boolean(embeddedWallet);
|
|
8051
|
-
const canUseHostedSigner = Boolean(hostedSigner);
|
|
8052
8546
|
const canUseAuthorizationSession = signerMode === "silent" && Boolean(hookOptions.authorizationSession?.serializedPermissionAccount) && (hookOptions.authorizationSession?.expiresAt ?? 0) > Math.floor(Date.now() / 1e3);
|
|
8053
|
-
if (!canUseLocalSigner && !
|
|
8547
|
+
if (!canUseLocalSigner && !canUseAuthorizationSession) {
|
|
8054
8548
|
const nextError = new Error(getZeroDevReadinessMessage({
|
|
8055
8549
|
ready,
|
|
8056
8550
|
authenticated,
|
|
8057
8551
|
embeddedWalletCount: wallets.filter((wallet) => wallet.walletClientType === "privy").length,
|
|
8058
|
-
walletCount: wallets.length
|
|
8059
|
-
hostedSignerAvailable: canUseHostedSigner
|
|
8552
|
+
walletCount: wallets.length
|
|
8060
8553
|
}));
|
|
8061
8554
|
debugWarn("[fluent zerodev] initialize blocked", {
|
|
8062
8555
|
message: nextError.message,
|
|
@@ -8079,28 +8572,28 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8079
8572
|
debugLog("[fluent zerodev] initializing", {
|
|
8080
8573
|
signerMode,
|
|
8081
8574
|
embeddedWallet: embeddedWallet?.address,
|
|
8082
|
-
walletClientType: embeddedWallet?.walletClientType
|
|
8083
|
-
hostedSigner: hostedSigner?.address
|
|
8575
|
+
walletClientType: embeddedWallet?.walletClientType
|
|
8084
8576
|
});
|
|
8085
8577
|
const nextKernel = canUseAuthorizationSession ? await createFluentZeroDevAuthorizedSessionKernel(
|
|
8086
8578
|
hookOptions.authorizationSession,
|
|
8087
|
-
chain
|
|
8579
|
+
chain,
|
|
8580
|
+
readExecution
|
|
8088
8581
|
) : await createFluentZeroDevKernel({
|
|
8089
|
-
wallet:
|
|
8090
|
-
hostedSigner: canUseLocalSigner ? void 0 : hostedSigner ?? void 0,
|
|
8582
|
+
wallet: embeddedWallet,
|
|
8091
8583
|
signerMode,
|
|
8092
8584
|
promptedSigners: {
|
|
8093
8585
|
signMessage: promptSignMessage,
|
|
8094
8586
|
signTypedData: promptSignTypedData
|
|
8095
8587
|
},
|
|
8096
|
-
chain
|
|
8588
|
+
chain,
|
|
8589
|
+
readExecution
|
|
8097
8590
|
});
|
|
8098
8591
|
if (hookOptions.sessionSmartAccountAddress && nextKernel.smartAccountAddress.toLowerCase() !== hookOptions.sessionSmartAccountAddress.toLowerCase()) {
|
|
8099
8592
|
throw new Error("Fluent Connect signer does not control the connected smart account");
|
|
8100
8593
|
}
|
|
8101
8594
|
debugLog("[fluent zerodev] ready", {
|
|
8102
8595
|
signerMode,
|
|
8103
|
-
signerAddress: embeddedWallet?.address
|
|
8596
|
+
signerAddress: embeddedWallet?.address,
|
|
8104
8597
|
smartAccountAddress: nextKernel.smartAccountAddress
|
|
8105
8598
|
});
|
|
8106
8599
|
setKernels((current) => ({ ...current, [signerMode]: nextKernel }));
|
|
@@ -8127,12 +8620,12 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8127
8620
|
activeKernel,
|
|
8128
8621
|
authenticated,
|
|
8129
8622
|
embeddedWallet,
|
|
8130
|
-
hostedSigner,
|
|
8131
8623
|
kernels,
|
|
8132
8624
|
hookOptions.sessionSmartAccountAddress,
|
|
8133
8625
|
hookOptions.authorizationSession,
|
|
8134
8626
|
promptSignMessage,
|
|
8135
8627
|
promptSignTypedData,
|
|
8628
|
+
readExecution,
|
|
8136
8629
|
ready
|
|
8137
8630
|
]);
|
|
8138
8631
|
useEffect(() => {
|
|
@@ -8147,9 +8640,6 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8147
8640
|
const sendTransaction = useCallback(
|
|
8148
8641
|
async (request) => {
|
|
8149
8642
|
const cachedKernel = kernels.prompt;
|
|
8150
|
-
if (cachedKernel?.signerSource === "hosted" || !cachedKernel && hostedSigner && !(ready && authenticated && embeddedWallet)) {
|
|
8151
|
-
hostedSigner?.prepare("always");
|
|
8152
|
-
}
|
|
8153
8643
|
const executionKernel = cachedKernel ?? await initialize2({ signerMode: "prompt" });
|
|
8154
8644
|
if (!executionKernel) throw new Error(error?.message ?? "ZeroDev smart account is not ready");
|
|
8155
8645
|
debugLog("[fluent zerodev] sendTransaction", {
|
|
@@ -8174,7 +8664,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8174
8664
|
throw err;
|
|
8175
8665
|
}
|
|
8176
8666
|
},
|
|
8177
|
-
[
|
|
8667
|
+
[error, initialize2, kernels.prompt]
|
|
8178
8668
|
);
|
|
8179
8669
|
const createSponsoredClient = useCallback(
|
|
8180
8670
|
(kernel, sponsorship) => (bearerToken) => buildSponsoredClient({
|
|
@@ -8183,28 +8673,26 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8183
8673
|
sponsorshipUrl: sponsorship.sponsorshipUrl,
|
|
8184
8674
|
appId: sponsorship.appId,
|
|
8185
8675
|
createPaymaster: createFluentZeroDevSponsoredPaymaster,
|
|
8186
|
-
createClient: ({ kernel: target, paymaster }) =>
|
|
8187
|
-
account: target.account,
|
|
8188
|
-
chain: target.chain,
|
|
8189
|
-
bundlerTransport: createFluentBundlerTransport(target.zeroDevRpcUrl),
|
|
8190
|
-
client: target.publicClient,
|
|
8191
|
-
paymaster
|
|
8192
|
-
})
|
|
8676
|
+
createClient: ({ kernel: target, paymaster }) => createFluentZeroDevKernelClient({ kernel: target, readExecution, paymaster })
|
|
8193
8677
|
}),
|
|
8194
|
-
[]
|
|
8678
|
+
[readExecution]
|
|
8195
8679
|
);
|
|
8196
8680
|
const sendCalls = useCallback(
|
|
8197
8681
|
async (calls, options, readyAccount) => {
|
|
8198
|
-
const
|
|
8199
|
-
|
|
8682
|
+
const timingLog2 = (label, line) => {
|
|
8683
|
+
try {
|
|
8684
|
+
debugLog(label, line);
|
|
8685
|
+
} catch {
|
|
8686
|
+
}
|
|
8687
|
+
};
|
|
8688
|
+
const startedAt = monotonicNow();
|
|
8689
|
+
timingLog2("[fluent execution stage]", { stage: "setup" });
|
|
8200
8690
|
validateUserOperationGas(options?.userOperationGas);
|
|
8691
|
+
const execution = readExecution();
|
|
8201
8692
|
const signerMode = confirmationToSignerMode(options?.confirmation ?? "always");
|
|
8202
8693
|
const readyKernel = readyAccount && typeof readyAccount === "object" && readyAccount.signerMode === signerMode ? readyAccount : void 0;
|
|
8203
8694
|
const knownKernel = readyKernel ?? kernels[signerMode];
|
|
8204
|
-
|
|
8205
|
-
if (knownKernel?.signerSource === "hosted" || !knownKernel && !hasAuthorizationSession && hostedSigner && !(ready && authenticated && embeddedWallet)) {
|
|
8206
|
-
hostedSigner?.prepare(options?.confirmation ?? "always");
|
|
8207
|
-
}
|
|
8695
|
+
signerMode === "silent" && Boolean(hookOptions.authorizationSession?.serializedPermissionAccount) && (hookOptions.authorizationSession?.expiresAt ?? 0) > Math.floor(Date.now() / 1e3);
|
|
8208
8696
|
const executionKernel = knownKernel ?? await initialize2({ signerMode, throwOnError: true });
|
|
8209
8697
|
if (!executionKernel) throw new Error(error?.message ?? "ZeroDev smart account is not ready");
|
|
8210
8698
|
const gasToken = options?.gasPayment?.symbol ? getFluentGasTokenAddress(options.gasPayment.symbol, network) : void 0;
|
|
@@ -8233,26 +8721,74 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8233
8721
|
intent: "transaction",
|
|
8234
8722
|
gasTokenSymbol: options?.gasPayment?.symbol
|
|
8235
8723
|
});
|
|
8724
|
+
const signerChainCheck = execution.chainCheckBeforeSign ? readFluentSignerChainCheck(executionKernel.account) : void 0;
|
|
8725
|
+
const signingAccount = signerChainCheck ? withFluentSignerChainCheck(
|
|
8726
|
+
executionKernel.account,
|
|
8727
|
+
["signUserOperation"],
|
|
8728
|
+
signerChainCheck
|
|
8729
|
+
) : executionKernel.account;
|
|
8236
8730
|
try {
|
|
8237
|
-
const submissionStartedAt =
|
|
8731
|
+
const submissionStartedAt = monotonicNow();
|
|
8732
|
+
const submissions = [];
|
|
8733
|
+
const submitOnce = async (client2, feeAttempt) => {
|
|
8734
|
+
const submission = await sendUserOperationWithTiming(
|
|
8735
|
+
client2,
|
|
8736
|
+
callArgs,
|
|
8737
|
+
options?.userOperationGas,
|
|
8738
|
+
(attempt) => {
|
|
8739
|
+
submissions.push(attempt);
|
|
8740
|
+
},
|
|
8741
|
+
feeAttempt
|
|
8742
|
+
);
|
|
8743
|
+
return submission.userOpHash;
|
|
8744
|
+
};
|
|
8745
|
+
let feeRetrySpent = false;
|
|
8746
|
+
const submit = async (client2) => {
|
|
8747
|
+
const feeAttempt = { feeSource: execution.feeSource };
|
|
8748
|
+
try {
|
|
8749
|
+
return await submitOnce(client2, feeAttempt);
|
|
8750
|
+
} catch (err) {
|
|
8751
|
+
if (feeRetrySpent) throw err;
|
|
8752
|
+
if (!isFluentFeeRejection(err)) throw err;
|
|
8753
|
+
feeRetrySpent = true;
|
|
8754
|
+
debugWarn("[fluent zerodev] fee rejected, retrying with the bundler's quote", {
|
|
8755
|
+
feeSource: feeAttempt.settledFeeSource
|
|
8756
|
+
});
|
|
8757
|
+
return await submitOnce(client2, { feeSource: "bundler" });
|
|
8758
|
+
}
|
|
8759
|
+
};
|
|
8760
|
+
let receivedAt;
|
|
8761
|
+
let receivedAtEpochMs;
|
|
8762
|
+
let inclusionAnchor;
|
|
8238
8763
|
const waitForInclusion = async (client2, hash) => {
|
|
8239
|
-
const
|
|
8240
|
-
|
|
8764
|
+
const waitStartedAt = monotonicNow();
|
|
8765
|
+
timingLog2("[fluent execution stage]", { stage: "submitted", userOpHash: hash });
|
|
8766
|
+
let settledReceiptSource;
|
|
8241
8767
|
try {
|
|
8242
|
-
|
|
8768
|
+
const operation = await waitForFluentUserOperationReceipt({
|
|
8769
|
+
bundlerClient: client2,
|
|
8770
|
+
chainClient: executionKernel.publicClient,
|
|
8243
8771
|
hash,
|
|
8244
|
-
|
|
8245
|
-
|
|
8772
|
+
entryPoint: executionKernel.account.entryPoint.address,
|
|
8773
|
+
anchorBlockNumber: inclusionAnchor,
|
|
8774
|
+
receiptSource: execution.receiptSource,
|
|
8775
|
+
onReceiptSource: (source) => {
|
|
8776
|
+
settledReceiptSource = source;
|
|
8777
|
+
}
|
|
8246
8778
|
});
|
|
8779
|
+
receivedAt = monotonicNow();
|
|
8780
|
+
receivedAtEpochMs = epochNow();
|
|
8781
|
+
return operation;
|
|
8247
8782
|
} finally {
|
|
8248
|
-
|
|
8783
|
+
timingLog2("[fluent inclusion timing]", {
|
|
8249
8784
|
userOpHash: hash,
|
|
8250
|
-
|
|
8785
|
+
waitMs: span(waitStartedAt, monotonicNow()),
|
|
8786
|
+
receiptSource: settledReceiptSource
|
|
8251
8787
|
});
|
|
8252
8788
|
}
|
|
8253
8789
|
};
|
|
8254
8790
|
const callArgs = {
|
|
8255
|
-
account:
|
|
8791
|
+
account: signingAccount,
|
|
8256
8792
|
calls: preparedCalls.map((call) => ({
|
|
8257
8793
|
to: call.to,
|
|
8258
8794
|
data: call.data ?? "0x",
|
|
@@ -8261,8 +8797,11 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8261
8797
|
};
|
|
8262
8798
|
const sponsorshipRefused = !gasToken && options?.gasPayment?.sponsorship === "never";
|
|
8263
8799
|
const sponsorship = hookOptions.sponsorshipUrl && hookOptions.appId ? { sponsorshipUrl: hookOptions.sponsorshipUrl, appId: hookOptions.appId } : null;
|
|
8264
|
-
const executionClient = gasToken ? createFluentZeroDevErc20ExecutionClient(executionKernel, gasToken) : executionKernel.client;
|
|
8800
|
+
const executionClient = gasToken ? createFluentZeroDevErc20ExecutionClient(executionKernel, gasToken, readExecution) : executionKernel.client;
|
|
8265
8801
|
const callSponsored = !gasToken && !sponsorshipRefused && sponsorship && !sponsorshipUnavailable.current;
|
|
8802
|
+
if (execution.receiptSource === "chain") {
|
|
8803
|
+
inclusionAnchor = await readFluentInclusionAnchor(executionKernel.publicClient);
|
|
8804
|
+
}
|
|
8266
8805
|
let sponsorshipReason;
|
|
8267
8806
|
let settlementClient = executionClient;
|
|
8268
8807
|
let userOpHash;
|
|
@@ -8278,10 +8817,14 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8278
8817
|
log: sponsorshipLog
|
|
8279
8818
|
}),
|
|
8280
8819
|
buildClient: createSponsoredClient(executionKernel, sponsorship),
|
|
8281
|
-
sendSponsored: (client2) =>
|
|
8282
|
-
sendOwnGas: () =>
|
|
8820
|
+
sendSponsored: (client2) => submit(client2),
|
|
8821
|
+
sendOwnGas: () => submit(executionKernel.client),
|
|
8283
8822
|
ownGasClient: executionKernel.client,
|
|
8284
8823
|
waitFor: ({ client: client2, userOpHash: hash }) => waitForInclusion(client2, hash),
|
|
8824
|
+
// A fee the bundler refused is the operation's, not the paymaster's: `submit` has
|
|
8825
|
+
// already answered it with ZeroDev's own quote, so an own-gas submission here
|
|
8826
|
+
// would be a third operation over a fee the account cannot change.
|
|
8827
|
+
isOperationFailure: isFluentFeeRejection,
|
|
8285
8828
|
disableSponsorship: () => {
|
|
8286
8829
|
sponsorshipUnavailable.current = true;
|
|
8287
8830
|
},
|
|
@@ -8294,7 +8837,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8294
8837
|
else if (!gasToken && sponsorship && sponsorshipUnavailable.current) {
|
|
8295
8838
|
sponsorshipReason = "unauthorized";
|
|
8296
8839
|
}
|
|
8297
|
-
userOpHash = await
|
|
8840
|
+
userOpHash = await submit(executionClient);
|
|
8298
8841
|
debugLog("[fluent zerodev] sendCalls userOp submitted", { userOpHash });
|
|
8299
8842
|
receipt = await waitForInclusion(settlementClient, userOpHash);
|
|
8300
8843
|
}
|
|
@@ -8310,22 +8853,40 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8310
8853
|
paymaster,
|
|
8311
8854
|
sponsorshipReason
|
|
8312
8855
|
});
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8856
|
+
const timing = receivedAt === void 0 || receivedAtEpochMs === void 0 ? (
|
|
8857
|
+
// Only an unreadable clock gets here. Standing in a fresh instant would be worse
|
|
8858
|
+
// than an absent timeline: the stages would still look measured.
|
|
8859
|
+
void 0
|
|
8860
|
+
) : await closeSendTiming({
|
|
8861
|
+
attempts: submissions,
|
|
8862
|
+
settledUserOpHash: userOpHash,
|
|
8863
|
+
receivedAt,
|
|
8864
|
+
receivedAtEpochMs,
|
|
8865
|
+
blockNumber: receipt.receipt.blockNumber,
|
|
8866
|
+
// The widget chain's own public client, the same transport `publicClient` was
|
|
8867
|
+
// built with. Reached only after `receivedAt` was taken, so it inflates no stage.
|
|
8868
|
+
getBlock: ({ blockNumber }) => executionKernel.publicClient.getBlock({ blockNumber })
|
|
8869
|
+
});
|
|
8870
|
+
timingLog2("[fluent execution timing]", {
|
|
8871
|
+
setupMs: span(startedAt, submissionStartedAt),
|
|
8872
|
+
// The whole call including kernel and authentication setup, which `timing.totalMs`
|
|
8873
|
+
// deliberately excludes — the two are different spans and say so.
|
|
8874
|
+
elapsedMs: span(startedAt, monotonicNow()),
|
|
8875
|
+
timing,
|
|
8319
8876
|
userOpHash,
|
|
8320
8877
|
hash: receipt.receipt.transactionHash
|
|
8321
8878
|
});
|
|
8879
|
+
if (!receipt.success) {
|
|
8880
|
+
throw new Error(receipt.reason ?? `UserOperation ${userOpHash} execution failed`);
|
|
8881
|
+
}
|
|
8322
8882
|
return {
|
|
8323
8883
|
hash: receipt.receipt.transactionHash,
|
|
8324
8884
|
receipt: receipt.receipt,
|
|
8325
8885
|
userOpHash,
|
|
8326
8886
|
sponsored,
|
|
8327
8887
|
sponsorshipReason,
|
|
8328
|
-
paymaster
|
|
8888
|
+
paymaster,
|
|
8889
|
+
timing
|
|
8329
8890
|
};
|
|
8330
8891
|
} catch (err) {
|
|
8331
8892
|
debugError("[fluent zerodev] sendCalls failed", err);
|
|
@@ -8339,7 +8900,6 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8339
8900
|
createSponsoredClient,
|
|
8340
8901
|
embeddedWallet,
|
|
8341
8902
|
error,
|
|
8342
|
-
hostedSigner,
|
|
8343
8903
|
hookOptions.authorizationSession,
|
|
8344
8904
|
hookOptions.appId,
|
|
8345
8905
|
hookOptions.sponsorshipTokenSource,
|
|
@@ -8347,6 +8907,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8347
8907
|
initialize2,
|
|
8348
8908
|
kernels,
|
|
8349
8909
|
network,
|
|
8910
|
+
readExecution,
|
|
8350
8911
|
ready
|
|
8351
8912
|
]
|
|
8352
8913
|
);
|
|
@@ -8354,14 +8915,14 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
8354
8915
|
const signerMode = confirmationToSignerMode(options.confirmation ?? "always");
|
|
8355
8916
|
if (kernels[signerMode]) return kernels[signerMode];
|
|
8356
8917
|
if (!ready) throw new Error("Privy wallet context is still loading");
|
|
8357
|
-
if (!authenticated
|
|
8918
|
+
if (!authenticated) {
|
|
8358
8919
|
login();
|
|
8359
8920
|
throw new Error("Complete wallet login, then submit the transaction again");
|
|
8360
8921
|
}
|
|
8361
8922
|
const executionKernel = await initialize2({ signerMode, throwOnError: true });
|
|
8362
8923
|
if (!executionKernel) throw new Error(error?.message ?? "ZeroDev smart account is not ready");
|
|
8363
8924
|
return executionKernel;
|
|
8364
|
-
}, [authenticated, error,
|
|
8925
|
+
}, [authenticated, error, initialize2, kernels, login, ready]);
|
|
8365
8926
|
return {
|
|
8366
8927
|
smartAccountEnabled: Boolean(FLUENT_CONNECT_ZERODEV_PROJECT_ID),
|
|
8367
8928
|
smartAccountReady,
|
|
@@ -8384,7 +8945,7 @@ var sponsorshipLog = {
|
|
|
8384
8945
|
debug: (message2, detail) => debugLog(message2, detail),
|
|
8385
8946
|
warn: (message2, detail) => debugWarn(message2, detail)
|
|
8386
8947
|
};
|
|
8387
|
-
var
|
|
8948
|
+
var USER_OPERATION_EVENT_TOPIC2 = toEventSelector(
|
|
8388
8949
|
parseAbiItem(
|
|
8389
8950
|
"event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed)"
|
|
8390
8951
|
)
|
|
@@ -8392,7 +8953,7 @@ var USER_OPERATION_EVENT_TOPIC = toEventSelector(
|
|
|
8392
8953
|
function readUserOperationPaymaster(receipt) {
|
|
8393
8954
|
if (receipt.paymaster) return getAddress(receipt.paymaster);
|
|
8394
8955
|
const event = receipt.logs.find(
|
|
8395
|
-
(log) => log.topics[0]?.toLowerCase() ===
|
|
8956
|
+
(log) => log.topics[0]?.toLowerCase() === USER_OPERATION_EVENT_TOPIC2 && log.topics[1]?.toLowerCase() === receipt.userOpHash.toLowerCase()
|
|
8396
8957
|
);
|
|
8397
8958
|
const topic = event?.topics[3];
|
|
8398
8959
|
if (!topic || topic.length !== 66) return void 0;
|
|
@@ -8400,7 +8961,6 @@ function readUserOperationPaymaster(receipt) {
|
|
|
8400
8961
|
}
|
|
8401
8962
|
function getZeroDevReadinessMessage(params) {
|
|
8402
8963
|
if (!params.ready) return "Privy wallet context is still loading";
|
|
8403
|
-
if (params.hostedSignerAvailable) return "Fluent hosted signer is preparing";
|
|
8404
8964
|
if (!params.authenticated) return "Fluent session is connected, but Privy embedded wallet is not authenticated on this page";
|
|
8405
8965
|
if (params.embeddedWalletCount === 0) {
|
|
8406
8966
|
return `Privy is authenticated, but no embedded wallet is available (${params.walletCount} linked wallets found)`;
|
|
@@ -8456,7 +9016,25 @@ async function createFluentZeroDevPermissionSession(params) {
|
|
|
8456
9016
|
function confirmationToSignerMode(confirmation) {
|
|
8457
9017
|
return confirmation === "session" ? "silent" : "prompt";
|
|
8458
9018
|
}
|
|
8459
|
-
|
|
9019
|
+
function createFluentZeroDevKernelClient(params) {
|
|
9020
|
+
const { kernel, readExecution, paymaster } = params;
|
|
9021
|
+
return createKernelAccountClient({
|
|
9022
|
+
account: kernel.account,
|
|
9023
|
+
chain: kernel.chain,
|
|
9024
|
+
bundlerTransport: createFluentBundlerTransport(kernel.zeroDevRpcUrl),
|
|
9025
|
+
client: kernel.publicClient,
|
|
9026
|
+
...paymaster ? { paymaster } : {},
|
|
9027
|
+
userOperation: {
|
|
9028
|
+
estimateFeesPerGas: createFluentUserOperationFeeHook({
|
|
9029
|
+
// The widget chain's own public client, so the quote and the account's reads travel
|
|
9030
|
+
// the same transport and its retry policy.
|
|
9031
|
+
readGasPrice: () => kernel.publicClient.getGasPrice(),
|
|
9032
|
+
readFeeSource: () => readExecution().feeSource
|
|
9033
|
+
})
|
|
9034
|
+
}
|
|
9035
|
+
});
|
|
9036
|
+
}
|
|
9037
|
+
async function createFluentZeroDevAuthorizedSessionKernel(authorizationSession, chain, readExecution) {
|
|
8460
9038
|
const zeroDevRpcUrl = `https://rpc.zerodev.app/api/v3/${FLUENT_CONNECT_ZERODEV_PROJECT_ID}/chain/${chain.id}`;
|
|
8461
9039
|
const publicClient = createPublicClient({
|
|
8462
9040
|
chain,
|
|
@@ -8473,11 +9051,9 @@ async function createFluentZeroDevAuthorizedSessionKernel(authorizationSession,
|
|
|
8473
9051
|
authorizationSession.serializedPermissionAccount,
|
|
8474
9052
|
sessionSigner
|
|
8475
9053
|
);
|
|
8476
|
-
const client2 =
|
|
8477
|
-
account,
|
|
8478
|
-
|
|
8479
|
-
bundlerTransport: createFluentBundlerTransport(zeroDevRpcUrl),
|
|
8480
|
-
client: publicClient
|
|
9054
|
+
const client2 = createFluentZeroDevKernelClient({
|
|
9055
|
+
kernel: { account, chain, publicClient, zeroDevRpcUrl },
|
|
9056
|
+
readExecution
|
|
8481
9057
|
});
|
|
8482
9058
|
return {
|
|
8483
9059
|
account,
|
|
@@ -8491,43 +9067,36 @@ async function createFluentZeroDevAuthorizedSessionKernel(authorizationSession,
|
|
|
8491
9067
|
};
|
|
8492
9068
|
}
|
|
8493
9069
|
async function createFluentZeroDevKernel(params) {
|
|
8494
|
-
if (!params.wallet
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
debugLog("[fluent zerodev] Fluent chain ready", params.chain.id);
|
|
8499
|
-
}
|
|
9070
|
+
if (!params.wallet) throw new Error("Fluent signer is unavailable");
|
|
9071
|
+
debugLog("[fluent zerodev] ensuring Fluent chain", params.chain.id);
|
|
9072
|
+
await ensureWalletOnFluentChain(params.wallet, params.chain);
|
|
9073
|
+
debugLog("[fluent zerodev] Fluent chain ready", params.chain.id);
|
|
8500
9074
|
const zeroDevRpcUrl = `https://rpc.zerodev.app/api/v3/${FLUENT_CONNECT_ZERODEV_PROJECT_ID}/chain/${params.chain.id}`;
|
|
8501
9075
|
const publicClient = createPublicClient({
|
|
8502
9076
|
chain: params.chain,
|
|
8503
9077
|
transport: createFluentRpcTransport(params.chain)
|
|
8504
9078
|
});
|
|
8505
9079
|
const entryPoint = getEntryPoint("0.7");
|
|
8506
|
-
|
|
8507
|
-
if (params.hostedSigner) {
|
|
8508
|
-
signer = toHostedSignerLocalAccount(params.hostedSigner, params.signerMode);
|
|
8509
|
-
} else if (params.wallet && params.signerMode === "prompt") {
|
|
8510
|
-
signer = toPromptedPrivyLocalAccount(params.wallet, params.promptedSigners, params.chain);
|
|
8511
|
-
} else if (params.wallet) {
|
|
8512
|
-
signer = toSilentPrivyLocalAccount(params.wallet, params.chain);
|
|
8513
|
-
} else {
|
|
8514
|
-
throw new Error("Fluent signer is unavailable");
|
|
8515
|
-
}
|
|
9080
|
+
const signer = params.signerMode === "prompt" ? toPromptedPrivyLocalAccount(params.wallet, params.promptedSigners) : toSilentPrivyLocalAccount(params.wallet);
|
|
8516
9081
|
const ecdsaValidator = await signerToEcdsaValidator(publicClient, {
|
|
8517
9082
|
signer,
|
|
8518
9083
|
entryPoint,
|
|
8519
9084
|
kernelVersion: KERNEL_V3_3
|
|
8520
9085
|
});
|
|
8521
|
-
const
|
|
9086
|
+
const derivedAccount = await createKernelAccount(publicClient, {
|
|
8522
9087
|
entryPoint,
|
|
8523
9088
|
plugins: { sudo: ecdsaValidator },
|
|
8524
9089
|
kernelVersion: KERNEL_V3_3
|
|
8525
9090
|
});
|
|
8526
|
-
const
|
|
8527
|
-
account,
|
|
9091
|
+
const account = toFluentSigningAccount({
|
|
9092
|
+
account: derivedAccount,
|
|
9093
|
+
wallet: params.wallet,
|
|
8528
9094
|
chain: params.chain,
|
|
8529
|
-
|
|
8530
|
-
|
|
9095
|
+
readExecution: params.readExecution
|
|
9096
|
+
});
|
|
9097
|
+
const client2 = createFluentZeroDevKernelClient({
|
|
9098
|
+
kernel: { account, chain: params.chain, publicClient, zeroDevRpcUrl },
|
|
9099
|
+
readExecution: params.readExecution
|
|
8531
9100
|
});
|
|
8532
9101
|
return {
|
|
8533
9102
|
account,
|
|
@@ -8537,39 +9106,13 @@ async function createFluentZeroDevKernel(params) {
|
|
|
8537
9106
|
zeroDevRpcUrl,
|
|
8538
9107
|
chain: params.chain,
|
|
8539
9108
|
signerMode: params.signerMode,
|
|
8540
|
-
signerSource:
|
|
8541
|
-
};
|
|
8542
|
-
}
|
|
8543
|
-
function toHostedSignerLocalAccount(signer, signerMode) {
|
|
8544
|
-
const confirmation = signerMode === "silent" ? "session" : "always";
|
|
8545
|
-
const source = {
|
|
8546
|
-
address: signer.address,
|
|
8547
|
-
async signMessage({ message: message2 }) {
|
|
8548
|
-
return signer.signMessage(formatSignableMessageForPrivy(message2), confirmation);
|
|
8549
|
-
},
|
|
8550
|
-
async signTransaction() {
|
|
8551
|
-
throw new Error("Fluent ZeroDev signer does not sign raw transactions");
|
|
8552
|
-
},
|
|
8553
|
-
async signTypedData(typedData) {
|
|
8554
|
-
return signer.signTypedData(
|
|
8555
|
-
{
|
|
8556
|
-
domain: typedData.domain,
|
|
8557
|
-
types: typedData.types,
|
|
8558
|
-
primaryType: typedData.primaryType,
|
|
8559
|
-
message: typedData.message
|
|
8560
|
-
},
|
|
8561
|
-
confirmation
|
|
8562
|
-
);
|
|
8563
|
-
}
|
|
9109
|
+
signerSource: "privy"
|
|
8564
9110
|
};
|
|
8565
|
-
return toAccount(source);
|
|
8566
9111
|
}
|
|
8567
|
-
function createFluentZeroDevErc20ExecutionClient(kernel, gasToken) {
|
|
8568
|
-
return
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
bundlerTransport: createFluentBundlerTransport(kernel.zeroDevRpcUrl),
|
|
8572
|
-
client: kernel.publicClient,
|
|
9112
|
+
function createFluentZeroDevErc20ExecutionClient(kernel, gasToken, readExecution) {
|
|
9113
|
+
return createFluentZeroDevKernelClient({
|
|
9114
|
+
kernel,
|
|
9115
|
+
readExecution,
|
|
8573
9116
|
paymaster: createFluentZeroDevErc20Paymaster({
|
|
8574
9117
|
chain: kernel.chain,
|
|
8575
9118
|
gasToken
|
|
@@ -8608,11 +9151,10 @@ function buildPromptSigningUiOptions() {
|
|
|
8608
9151
|
buttonText: "Sign"
|
|
8609
9152
|
};
|
|
8610
9153
|
}
|
|
8611
|
-
function toPromptedPrivyLocalAccount(wallet, promptedSigners
|
|
9154
|
+
function toPromptedPrivyLocalAccount(wallet, promptedSigners) {
|
|
8612
9155
|
const source = {
|
|
8613
9156
|
address: wallet.address,
|
|
8614
9157
|
async signMessage({ message: message2 }) {
|
|
8615
|
-
await ensureWalletOnFluentChain(wallet, chain);
|
|
8616
9158
|
const { signature } = await promptedSigners.signMessage(
|
|
8617
9159
|
{ message: formatSignableMessageForPrivy(message2) },
|
|
8618
9160
|
{
|
|
@@ -8626,7 +9168,6 @@ function toPromptedPrivyLocalAccount(wallet, promptedSigners, chain) {
|
|
|
8626
9168
|
throw new Error("Fluent ZeroDev signer does not sign raw transactions");
|
|
8627
9169
|
},
|
|
8628
9170
|
async signTypedData(typedData) {
|
|
8629
|
-
await ensureWalletOnFluentChain(wallet, chain);
|
|
8630
9171
|
const { signature } = await promptedSigners.signTypedData(
|
|
8631
9172
|
{
|
|
8632
9173
|
domain: typedData.domain,
|
|
@@ -8644,7 +9185,7 @@ function toPromptedPrivyLocalAccount(wallet, promptedSigners, chain) {
|
|
|
8644
9185
|
};
|
|
8645
9186
|
return toAccount(source);
|
|
8646
9187
|
}
|
|
8647
|
-
function toSilentPrivyLocalAccount(wallet
|
|
9188
|
+
function toSilentPrivyLocalAccount(wallet) {
|
|
8648
9189
|
const source = {
|
|
8649
9190
|
address: wallet.address,
|
|
8650
9191
|
async signMessage({ message: message2 }) {
|
|
@@ -8652,7 +9193,6 @@ function toSilentPrivyLocalAccount(wallet, chain) {
|
|
|
8652
9193
|
signerAddress: wallet.address,
|
|
8653
9194
|
messageKind: typeof message2 === "string" ? "string" : "raw" in message2 ? "raw" : typeof message2
|
|
8654
9195
|
});
|
|
8655
|
-
await ensureWalletOnFluentChain(wallet, chain);
|
|
8656
9196
|
const provider = await wallet.getEthereumProvider();
|
|
8657
9197
|
if (!provider?.request) throw new Error("Fluent embedded wallet provider is unavailable");
|
|
8658
9198
|
const formattedMessage = formatSignableMessageForPrivy(message2);
|
|
@@ -8680,7 +9220,6 @@ function toSilentPrivyLocalAccount(wallet, chain) {
|
|
|
8680
9220
|
signerAddress: wallet.address,
|
|
8681
9221
|
primaryType: typedData.primaryType
|
|
8682
9222
|
});
|
|
8683
|
-
await ensureWalletOnFluentChain(wallet, chain);
|
|
8684
9223
|
const provider = await wallet.getEthereumProvider();
|
|
8685
9224
|
if (!provider?.request) throw new Error("Fluent embedded wallet provider is unavailable");
|
|
8686
9225
|
try {
|
|
@@ -8922,14 +9461,6 @@ function createFluentIframeRpcHandler(executor) {
|
|
|
8922
9461
|
throw new FluentIframeRpcError(4100, `${method}: ${candidate} is not the signed-in account`);
|
|
8923
9462
|
}
|
|
8924
9463
|
};
|
|
8925
|
-
const assertDirectMode = () => {
|
|
8926
|
-
if (executor.authMode === "hosted") {
|
|
8927
|
-
throw new FluentAuthError(
|
|
8928
|
-
"hosted_not_supported",
|
|
8929
|
-
'The iframe bridge needs authMode: "direct" \u2014 there is no hosted signer to ask.'
|
|
8930
|
-
);
|
|
8931
|
-
}
|
|
8932
|
-
};
|
|
8933
9464
|
const parseTypedData = (payload, method) => {
|
|
8934
9465
|
const value = typeof payload === "string" ? safeJsonParse(payload) : payload;
|
|
8935
9466
|
if (!value || typeof value !== "object") {
|
|
@@ -8958,26 +9489,22 @@ function createFluentIframeRpcHandler(executor) {
|
|
|
8958
9489
|
return toHex(executor.chainId);
|
|
8959
9490
|
case "eth_signTypedData_v4":
|
|
8960
9491
|
case "eth_signTypedData_v3": {
|
|
8961
|
-
assertDirectMode();
|
|
8962
9492
|
assertOwnAddress(params[0], method);
|
|
8963
9493
|
return executor.sign.signTypedData(parseTypedData(params[1], method));
|
|
8964
9494
|
}
|
|
8965
9495
|
case "eth_signTypedData": {
|
|
8966
|
-
assertDirectMode();
|
|
8967
9496
|
const [first, second] = params;
|
|
8968
9497
|
const addressFirst = typeof first === "string" && isAddress(first);
|
|
8969
9498
|
assertOwnAddress(addressFirst ? first : second, method);
|
|
8970
9499
|
return executor.sign.signTypedData(parseTypedData(addressFirst ? second : first, method));
|
|
8971
9500
|
}
|
|
8972
9501
|
case "personal_sign": {
|
|
8973
|
-
assertDirectMode();
|
|
8974
9502
|
assertOwnAddress(params[1], method);
|
|
8975
9503
|
const message2 = params[0];
|
|
8976
9504
|
if (typeof message2 !== "string") throw invalid(method, "a message");
|
|
8977
9505
|
return executor.sign.signMessage({ message: isHex(message2) ? { raw: message2 } : message2 });
|
|
8978
9506
|
}
|
|
8979
9507
|
case "eth_sendTransaction": {
|
|
8980
|
-
assertDirectMode();
|
|
8981
9508
|
const tx = params[0];
|
|
8982
9509
|
if (!tx || typeof tx !== "object") throw invalid(method, "a transaction object");
|
|
8983
9510
|
const { from, to, data, value } = tx;
|
|
@@ -9058,8 +9585,7 @@ function toRpcError(error) {
|
|
|
9058
9585
|
if (error instanceof FluentIframeRpcError) return { code: error.code, message: error.message };
|
|
9059
9586
|
if (error instanceof FluentReviewRejectedError) return { code: 4001, message: error.message };
|
|
9060
9587
|
if (error instanceof FluentAuthError) {
|
|
9061
|
-
|
|
9062
|
-
return { code, message: `${error.code}: ${error.message}` };
|
|
9588
|
+
return { code: -32603, message: `${error.code}: ${error.message}` };
|
|
9063
9589
|
}
|
|
9064
9590
|
const message2 = error instanceof Error ? error.message : String(error);
|
|
9065
9591
|
return { code: -32603, message: message2 };
|
|
@@ -9078,7 +9604,7 @@ function exactOrigin(candidate) {
|
|
|
9078
9604
|
return origin;
|
|
9079
9605
|
}
|
|
9080
9606
|
function useFluentIframeBridge(iframeRef, { allowedOrigin }) {
|
|
9081
|
-
const { widget
|
|
9607
|
+
const { widget } = useFluentWidget();
|
|
9082
9608
|
const { chain } = useFluentWidgetNetwork();
|
|
9083
9609
|
const widgetRef = useRef(widget);
|
|
9084
9610
|
widgetRef.current = widget;
|
|
@@ -9096,7 +9622,6 @@ function useFluentIframeBridge(iframeRef, { allowedOrigin }) {
|
|
|
9096
9622
|
const bridge = createFluentIframeBridge(iframe, {
|
|
9097
9623
|
allowedOrigin,
|
|
9098
9624
|
executor: {
|
|
9099
|
-
authMode,
|
|
9100
9625
|
account: () => widgetRef.current.account,
|
|
9101
9626
|
chainId: chain.id,
|
|
9102
9627
|
sign: {
|
|
@@ -9113,7 +9638,7 @@ function useFluentIframeBridge(iframeRef, { allowedOrigin }) {
|
|
|
9113
9638
|
bridge.dispose();
|
|
9114
9639
|
bridgeRef.current = null;
|
|
9115
9640
|
};
|
|
9116
|
-
}, [iframeRef, allowedOrigin,
|
|
9641
|
+
}, [iframeRef, allowedOrigin, chain.id, rpc]);
|
|
9117
9642
|
const address = widget.account.address;
|
|
9118
9643
|
useEffect(() => {
|
|
9119
9644
|
bridgeRef.current?.notifyAccountsChanged(address ? [address] : []);
|
|
@@ -9121,7 +9646,7 @@ function useFluentIframeBridge(iframeRef, { allowedOrigin }) {
|
|
|
9121
9646
|
}
|
|
9122
9647
|
|
|
9123
9648
|
// package.json
|
|
9124
|
-
var version = "0.
|
|
9649
|
+
var version = "0.5.0";
|
|
9125
9650
|
|
|
9126
9651
|
// src/core/analytics.ts
|
|
9127
9652
|
var INSTANCE_NAME = "fluent";
|
|
@@ -9205,7 +9730,6 @@ function createTracker(config, getContext) {
|
|
|
9205
9730
|
const base = {
|
|
9206
9731
|
app_id: config.appId,
|
|
9207
9732
|
network: config.network,
|
|
9208
|
-
auth_mode: config.authMode,
|
|
9209
9733
|
source: config.source,
|
|
9210
9734
|
campaign: config.campaign,
|
|
9211
9735
|
sdk_version: version
|
|
@@ -9250,9 +9774,9 @@ async function getBridgeTransactions({
|
|
|
9250
9774
|
}
|
|
9251
9775
|
return await response.json();
|
|
9252
9776
|
}
|
|
9253
|
-
function findBridgeTxBySentHash(
|
|
9777
|
+
function findBridgeTxBySentHash(history, sentTxHash) {
|
|
9254
9778
|
const target = sentTxHash.toLowerCase();
|
|
9255
|
-
return
|
|
9779
|
+
return history.items.find((item) => item.sent_tx_hash?.toLowerCase() === target);
|
|
9256
9780
|
}
|
|
9257
9781
|
var BRIDGE_TX_HISTORY_PAGE_SIZE = 10;
|
|
9258
9782
|
function useBridgeTxHistoryPages({
|
|
@@ -9521,51 +10045,160 @@ function clearInlineOAuth() {
|
|
|
9521
10045
|
} catch {
|
|
9522
10046
|
}
|
|
9523
10047
|
}
|
|
9524
|
-
function
|
|
9525
|
-
return
|
|
10048
|
+
function Dialog({ ...props }) {
|
|
10049
|
+
return /* @__PURE__ */ jsx(Dialog$1.Root, { "data-slot": "dialog", ...props });
|
|
9526
10050
|
}
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
10051
|
+
function DialogTrigger({ ...props }) {
|
|
10052
|
+
return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
10053
|
+
}
|
|
10054
|
+
function DialogPortal({ container, children, ...props }) {
|
|
10055
|
+
return /* @__PURE__ */ jsx(
|
|
10056
|
+
Dialog$1.Portal,
|
|
10057
|
+
{
|
|
10058
|
+
"data-slot": "dialog-portal",
|
|
10059
|
+
container: useFluentModalPortalContainer(container),
|
|
10060
|
+
...props,
|
|
10061
|
+
children: /* @__PURE__ */ jsx(FluentTopLayerSlot, { children })
|
|
10062
|
+
}
|
|
10063
|
+
);
|
|
10064
|
+
}
|
|
10065
|
+
function DialogClose({ ...props }) {
|
|
10066
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, { "data-slot": "dialog-close", ...props });
|
|
10067
|
+
}
|
|
10068
|
+
function DialogOverlay({
|
|
10069
|
+
className,
|
|
10070
|
+
...props
|
|
9531
10071
|
}) {
|
|
9532
|
-
return /* @__PURE__ */
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
"
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
/* @__PURE__ */ jsx(
|
|
9540
|
-
"a",
|
|
9541
|
-
{
|
|
9542
|
-
href: privacyPolicyUrl,
|
|
9543
|
-
target: "_blank",
|
|
9544
|
-
rel: "noopener noreferrer",
|
|
9545
|
-
className: "whitespace-nowrap text-white/70 underline underline-offset-2 hover:text-white",
|
|
9546
|
-
children: "Privacy Policy"
|
|
9547
|
-
}
|
|
10072
|
+
return /* @__PURE__ */ jsx(
|
|
10073
|
+
Dialog$1.Backdrop,
|
|
10074
|
+
{
|
|
10075
|
+
"data-slot": "dialog-overlay",
|
|
10076
|
+
className: cn(
|
|
10077
|
+
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
10078
|
+
className
|
|
9548
10079
|
),
|
|
9549
|
-
|
|
9550
|
-
|
|
10080
|
+
...props
|
|
10081
|
+
}
|
|
10082
|
+
);
|
|
10083
|
+
}
|
|
10084
|
+
function DialogContent({
|
|
10085
|
+
className,
|
|
10086
|
+
children,
|
|
10087
|
+
showCloseButton = true,
|
|
10088
|
+
...props
|
|
10089
|
+
}) {
|
|
10090
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
10091
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
10092
|
+
/* @__PURE__ */ jsxs(
|
|
10093
|
+
Dialog$1.Popup,
|
|
10094
|
+
{
|
|
10095
|
+
"data-slot": "dialog-content",
|
|
10096
|
+
className: cn(
|
|
10097
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-3xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm 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",
|
|
10098
|
+
className
|
|
10099
|
+
),
|
|
10100
|
+
...props,
|
|
10101
|
+
children: [
|
|
10102
|
+
children,
|
|
10103
|
+
showCloseButton && /* @__PURE__ */ jsxs(
|
|
10104
|
+
Dialog$1.Close,
|
|
10105
|
+
{
|
|
10106
|
+
"data-slot": "dialog-close",
|
|
10107
|
+
render: /* @__PURE__ */ jsx(
|
|
10108
|
+
Button,
|
|
10109
|
+
{
|
|
10110
|
+
variant: "ghost",
|
|
10111
|
+
className: "absolute top-3.5 right-3.5 z-50 rounded-full",
|
|
10112
|
+
size: "icon-sm"
|
|
10113
|
+
}
|
|
10114
|
+
),
|
|
10115
|
+
children: [
|
|
10116
|
+
/* @__PURE__ */ jsx(XIcon, {}),
|
|
10117
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
10118
|
+
]
|
|
10119
|
+
}
|
|
10120
|
+
)
|
|
10121
|
+
]
|
|
10122
|
+
}
|
|
10123
|
+
)
|
|
9551
10124
|
] });
|
|
9552
10125
|
}
|
|
9553
|
-
function
|
|
10126
|
+
function DialogHeader({ className, ...props }) {
|
|
10127
|
+
return /* @__PURE__ */ jsx(
|
|
10128
|
+
"div",
|
|
10129
|
+
{
|
|
10130
|
+
"data-slot": "dialog-header",
|
|
10131
|
+
className: cn("flex flex-col gap-2", className),
|
|
10132
|
+
...props
|
|
10133
|
+
}
|
|
10134
|
+
);
|
|
10135
|
+
}
|
|
10136
|
+
function DialogFooter({
|
|
10137
|
+
className,
|
|
10138
|
+
showCloseButton = false,
|
|
10139
|
+
children,
|
|
10140
|
+
...props
|
|
10141
|
+
}) {
|
|
9554
10142
|
return /* @__PURE__ */ jsxs(
|
|
9555
10143
|
"div",
|
|
9556
10144
|
{
|
|
9557
|
-
|
|
9558
|
-
|
|
10145
|
+
"data-slot": "dialog-footer",
|
|
10146
|
+
className: cn(
|
|
10147
|
+
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
|
|
10148
|
+
className
|
|
10149
|
+
),
|
|
10150
|
+
...props,
|
|
9559
10151
|
children: [
|
|
9560
|
-
|
|
9561
|
-
"
|
|
9562
|
-
|
|
10152
|
+
children,
|
|
10153
|
+
showCloseButton && /* @__PURE__ */ jsxs(Dialog$1.Close, { render: /* @__PURE__ */ jsx(Button, { variant: "outline" }), children: [
|
|
10154
|
+
/* @__PURE__ */ jsx(XIcon, { className: "size-4 shrink-0", "aria-hidden": true }),
|
|
10155
|
+
"Close"
|
|
10156
|
+
] })
|
|
9563
10157
|
]
|
|
9564
10158
|
}
|
|
9565
10159
|
);
|
|
9566
10160
|
}
|
|
9567
|
-
function
|
|
9568
|
-
return /* @__PURE__ */ jsx(
|
|
10161
|
+
function DialogTitle({ className, ...props }) {
|
|
10162
|
+
return /* @__PURE__ */ jsx(
|
|
10163
|
+
Dialog$1.Title,
|
|
10164
|
+
{
|
|
10165
|
+
"data-slot": "dialog-title",
|
|
10166
|
+
className: cn(
|
|
10167
|
+
"text-base leading-none font-medium",
|
|
10168
|
+
className
|
|
10169
|
+
),
|
|
10170
|
+
...props
|
|
10171
|
+
}
|
|
10172
|
+
);
|
|
10173
|
+
}
|
|
10174
|
+
function DialogDescription({
|
|
10175
|
+
className,
|
|
10176
|
+
...props
|
|
10177
|
+
}) {
|
|
10178
|
+
return /* @__PURE__ */ jsx(
|
|
10179
|
+
Dialog$1.Description,
|
|
10180
|
+
{
|
|
10181
|
+
"data-slot": "dialog-description",
|
|
10182
|
+
className: cn(
|
|
10183
|
+
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
10184
|
+
className
|
|
10185
|
+
),
|
|
10186
|
+
...props
|
|
10187
|
+
}
|
|
10188
|
+
);
|
|
10189
|
+
}
|
|
10190
|
+
function Label({ className, ...props }) {
|
|
10191
|
+
return /* @__PURE__ */ jsx(
|
|
10192
|
+
"label",
|
|
10193
|
+
{
|
|
10194
|
+
"data-slot": "label",
|
|
10195
|
+
className: cn(
|
|
10196
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
10197
|
+
className
|
|
10198
|
+
),
|
|
10199
|
+
...props
|
|
10200
|
+
}
|
|
10201
|
+
);
|
|
9569
10202
|
}
|
|
9570
10203
|
var icons = {
|
|
9571
10204
|
google: (props) => /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
@@ -9638,177 +10271,89 @@ var icons = {
|
|
|
9638
10271
|
] }),
|
|
9639
10272
|
/* @__PURE__ */ jsxs("linearGradient", { id: "rabby__c", x1: "14.023", x2: "5.231", y1: "16.707", y2: "11.849", gradientUnits: "userSpaceOnUse", children: [
|
|
9640
10273
|
/* @__PURE__ */ jsx("stop", { stopColor: "#8697FF" }),
|
|
9641
|
-
/* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#8697FF", stopOpacity: "0" })
|
|
9642
|
-
] }),
|
|
9643
|
-
/* @__PURE__ */ jsxs("linearGradient", { id: "rabby__d", x1: "9.054", x2: "15.173", y1: "11.617", y2: "19.089", gradientUnits: "userSpaceOnUse", children: [
|
|
9644
|
-
/* @__PURE__ */ jsx("stop", { stopColor: "#fff" }),
|
|
9645
|
-
/* @__PURE__ */ jsx("stop", { offset: ".984", stopColor: "#D1D8FF" })
|
|
9646
|
-
] })
|
|
9647
|
-
] })
|
|
9648
|
-
] })
|
|
9649
|
-
};
|
|
9650
|
-
function Icon({
|
|
9651
|
-
name,
|
|
9652
|
-
className,
|
|
9653
|
-
...props
|
|
9654
|
-
}) {
|
|
9655
|
-
const Render = icons[name];
|
|
9656
|
-
return /* @__PURE__ */ jsx(Render, { className: cn(className), "aria-hidden": "true", ...props });
|
|
9657
|
-
}
|
|
9658
|
-
function Dialog({ ...props }) {
|
|
9659
|
-
return /* @__PURE__ */ jsx(Dialog$1.Root, { "data-slot": "dialog", ...props });
|
|
9660
|
-
}
|
|
9661
|
-
function DialogTrigger({ ...props }) {
|
|
9662
|
-
return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
9663
|
-
}
|
|
9664
|
-
function DialogPortal({ container, children, ...props }) {
|
|
9665
|
-
return /* @__PURE__ */ jsx(
|
|
9666
|
-
Dialog$1.Portal,
|
|
9667
|
-
{
|
|
9668
|
-
"data-slot": "dialog-portal",
|
|
9669
|
-
container: useFluentModalPortalContainer(container),
|
|
9670
|
-
...props,
|
|
9671
|
-
children: /* @__PURE__ */ jsx(FluentTopLayerSlot, { children })
|
|
9672
|
-
}
|
|
9673
|
-
);
|
|
9674
|
-
}
|
|
9675
|
-
function DialogClose({ ...props }) {
|
|
9676
|
-
return /* @__PURE__ */ jsx(Dialog$1.Close, { "data-slot": "dialog-close", ...props });
|
|
9677
|
-
}
|
|
9678
|
-
function DialogOverlay({
|
|
9679
|
-
className,
|
|
9680
|
-
...props
|
|
9681
|
-
}) {
|
|
9682
|
-
return /* @__PURE__ */ jsx(
|
|
9683
|
-
Dialog$1.Backdrop,
|
|
9684
|
-
{
|
|
9685
|
-
"data-slot": "dialog-overlay",
|
|
9686
|
-
className: cn(
|
|
9687
|
-
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
9688
|
-
className
|
|
9689
|
-
),
|
|
9690
|
-
...props
|
|
9691
|
-
}
|
|
9692
|
-
);
|
|
9693
|
-
}
|
|
9694
|
-
function DialogContent({
|
|
9695
|
-
className,
|
|
9696
|
-
children,
|
|
9697
|
-
showCloseButton = true,
|
|
9698
|
-
...props
|
|
9699
|
-
}) {
|
|
9700
|
-
return /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
9701
|
-
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
9702
|
-
/* @__PURE__ */ jsxs(
|
|
9703
|
-
Dialog$1.Popup,
|
|
9704
|
-
{
|
|
9705
|
-
"data-slot": "dialog-content",
|
|
9706
|
-
className: cn(
|
|
9707
|
-
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-3xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm 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",
|
|
9708
|
-
className
|
|
9709
|
-
),
|
|
9710
|
-
...props,
|
|
9711
|
-
children: [
|
|
9712
|
-
children,
|
|
9713
|
-
showCloseButton && /* @__PURE__ */ jsxs(
|
|
9714
|
-
Dialog$1.Close,
|
|
9715
|
-
{
|
|
9716
|
-
"data-slot": "dialog-close",
|
|
9717
|
-
render: /* @__PURE__ */ jsx(
|
|
9718
|
-
Button,
|
|
9719
|
-
{
|
|
9720
|
-
variant: "ghost",
|
|
9721
|
-
className: "absolute top-3.5 right-3.5 z-50 rounded-full",
|
|
9722
|
-
size: "icon-sm"
|
|
9723
|
-
}
|
|
9724
|
-
),
|
|
9725
|
-
children: [
|
|
9726
|
-
/* @__PURE__ */ jsx(XIcon, {}),
|
|
9727
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
9728
|
-
]
|
|
9729
|
-
}
|
|
9730
|
-
)
|
|
9731
|
-
]
|
|
9732
|
-
}
|
|
9733
|
-
)
|
|
9734
|
-
] });
|
|
10274
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#8697FF", stopOpacity: "0" })
|
|
10275
|
+
] }),
|
|
10276
|
+
/* @__PURE__ */ jsxs("linearGradient", { id: "rabby__d", x1: "9.054", x2: "15.173", y1: "11.617", y2: "19.089", gradientUnits: "userSpaceOnUse", children: [
|
|
10277
|
+
/* @__PURE__ */ jsx("stop", { stopColor: "#fff" }),
|
|
10278
|
+
/* @__PURE__ */ jsx("stop", { offset: ".984", stopColor: "#D1D8FF" })
|
|
10279
|
+
] })
|
|
10280
|
+
] })
|
|
10281
|
+
] })
|
|
10282
|
+
};
|
|
10283
|
+
function Icon({
|
|
10284
|
+
name,
|
|
10285
|
+
className,
|
|
10286
|
+
...props
|
|
10287
|
+
}) {
|
|
10288
|
+
const Render = icons[name];
|
|
10289
|
+
return /* @__PURE__ */ jsx(Render, { className: cn(className), "aria-hidden": "true", ...props });
|
|
9735
10290
|
}
|
|
9736
|
-
function
|
|
10291
|
+
function connectDescription(appName) {
|
|
10292
|
+
return `Sign in or create a Fluent Connect account to use ${appName?.trim() || "this app"}.`;
|
|
10293
|
+
}
|
|
10294
|
+
var termsOfUseUrl = "https://cdn.fluent.xyz/docs/fluent-connect-sdk-terms-of-use.pdf";
|
|
10295
|
+
var privacyPolicyUrl = "https://cdn.fluent.xyz/docs/fluent-connect-sdk-privacy-policy.pdf";
|
|
10296
|
+
function ConsentLink({ href, children }) {
|
|
9737
10297
|
return /* @__PURE__ */ jsx(
|
|
9738
|
-
"
|
|
10298
|
+
"a",
|
|
9739
10299
|
{
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
10300
|
+
href,
|
|
10301
|
+
target: "_blank",
|
|
10302
|
+
rel: "noopener noreferrer",
|
|
10303
|
+
className: "whitespace-nowrap text-white/55 underline underline-offset-2 hover:text-white/80",
|
|
10304
|
+
children
|
|
9743
10305
|
}
|
|
9744
10306
|
);
|
|
9745
10307
|
}
|
|
9746
|
-
function
|
|
9747
|
-
className,
|
|
9748
|
-
showCloseButton = false,
|
|
10308
|
+
function FluentBranch({
|
|
9749
10309
|
children,
|
|
9750
|
-
|
|
10310
|
+
className
|
|
9751
10311
|
}) {
|
|
9752
10312
|
return /* @__PURE__ */ jsxs(
|
|
9753
10313
|
"div",
|
|
9754
10314
|
{
|
|
9755
|
-
"data-slot": "dialog-footer",
|
|
9756
10315
|
className: cn(
|
|
9757
|
-
|
|
10316
|
+
// The edge is a 1px gradient ring drawn by ::before and cut out of its own padding box,
|
|
10317
|
+
// with a gap cut from its top run where the badge sits: the badge's width plus 8px a side.
|
|
10318
|
+
// The same cut crosses the bottom run, where the edge has already faded to nothing.
|
|
10319
|
+
// Rounded at the top only; surface and edge both fade to nothing by 70% of the height, so the
|
|
10320
|
+
// panel has no bottom to speak of and its last 30% dissolves into the dialog.
|
|
10321
|
+
"relative mt-3 flex flex-col gap-2 rounded-t-2xl bg-[linear-gradient(to_bottom,rgba(255,255,255,0.08),transparent_70%)] px-5 pt-5 pb-2",
|
|
10322
|
+
"before:pointer-events-none before:absolute before:inset-0 before:rounded-t-2xl before:p-px before:bg-[linear-gradient(to_bottom,rgba(255,255,255,0.2),transparent_70%)]",
|
|
10323
|
+
"before:[mask:linear-gradient(to_right,#000_calc(50%-60px),transparent_calc(50%-60px)_calc(50%+60px),#000_calc(50%+60px))_intersect,linear-gradient(#000_0_0)_content-box_exclude,linear-gradient(#000_0_0)]",
|
|
9758
10324
|
className
|
|
9759
10325
|
),
|
|
9760
|
-
...props,
|
|
9761
10326
|
children: [
|
|
10327
|
+
/* @__PURE__ */ jsx("span", { className: "absolute top-0 left-1/2 w-26 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white/10 py-0.5 text-center text-[10px] font-medium uppercase leading-4 tracking-wider text-white ring-1 ring-inset ring-white/20 shadow-[inset_0_1px_0_rgba(255,255,255,0.25)] backdrop-blur-md", children: "Recommended" }),
|
|
9762
10328
|
children,
|
|
9763
|
-
|
|
9764
|
-
/* @__PURE__ */ jsx(
|
|
9765
|
-
"
|
|
10329
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 pt-0.5 text-center text-[11px] leading-4", children: [
|
|
10330
|
+
/* @__PURE__ */ jsx("p", { className: "text-white/60", children: "Gasless transactions and faster signing." }),
|
|
10331
|
+
/* @__PURE__ */ jsxs("p", { className: "-mx-5 text-balance text-[10px] text-white/40", children: [
|
|
10332
|
+
"By continuing, you agree to our",
|
|
10333
|
+
" ",
|
|
10334
|
+
/* @__PURE__ */ jsx(ConsentLink, { href: termsOfUseUrl, children: "Terms of Use" }),
|
|
10335
|
+
" and",
|
|
10336
|
+
" ",
|
|
10337
|
+
/* @__PURE__ */ jsx(ConsentLink, { href: privacyPolicyUrl, children: "Privacy Policy" }),
|
|
10338
|
+
"."
|
|
10339
|
+
] })
|
|
9766
10340
|
] })
|
|
9767
10341
|
]
|
|
9768
10342
|
}
|
|
9769
10343
|
);
|
|
9770
10344
|
}
|
|
9771
|
-
function
|
|
9772
|
-
return /* @__PURE__ */ jsx(
|
|
9773
|
-
Dialog$1.Title,
|
|
9774
|
-
{
|
|
9775
|
-
"data-slot": "dialog-title",
|
|
9776
|
-
className: cn(
|
|
9777
|
-
"text-base leading-none font-medium",
|
|
9778
|
-
className
|
|
9779
|
-
),
|
|
9780
|
-
...props
|
|
9781
|
-
}
|
|
9782
|
-
);
|
|
9783
|
-
}
|
|
9784
|
-
function DialogDescription({
|
|
9785
|
-
className,
|
|
9786
|
-
...props
|
|
9787
|
-
}) {
|
|
10345
|
+
function BranchDivider() {
|
|
9788
10346
|
return /* @__PURE__ */ jsx(
|
|
9789
|
-
|
|
10347
|
+
"div",
|
|
9790
10348
|
{
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
9794
|
-
className
|
|
9795
|
-
),
|
|
9796
|
-
...props
|
|
10349
|
+
className: "my-1 h-px bg-gradient-to-r from-transparent via-white/15 to-transparent",
|
|
10350
|
+
"aria-hidden": true
|
|
9797
10351
|
}
|
|
9798
10352
|
);
|
|
9799
10353
|
}
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
{
|
|
9804
|
-
"data-slot": "label",
|
|
9805
|
-
className: cn(
|
|
9806
|
-
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
9807
|
-
className
|
|
9808
|
-
),
|
|
9809
|
-
...props
|
|
9810
|
-
}
|
|
9811
|
-
);
|
|
10354
|
+
var walletRowClassName = "bg-transparent text-white/85 ring-1 ring-inset ring-white/10 hover:bg-white/5 hover:text-white";
|
|
10355
|
+
function WalletBranchNote() {
|
|
10356
|
+
return /* @__PURE__ */ jsx("p", { className: "text-center text-[11px] leading-4 text-white/45", children: "Manual signing required. Gas fees may apply." });
|
|
9812
10357
|
}
|
|
9813
10358
|
var buttonIcons = {
|
|
9814
10359
|
x: (props) => /* @__PURE__ */ jsx(Icon, { ...props, name: "x" }),
|
|
@@ -9833,7 +10378,7 @@ function InlineConnectModal(props) {
|
|
|
9833
10378
|
onClose,
|
|
9834
10379
|
onFluentLogin,
|
|
9835
10380
|
onRetry,
|
|
9836
|
-
|
|
10381
|
+
loginError,
|
|
9837
10382
|
wallet,
|
|
9838
10383
|
track,
|
|
9839
10384
|
onExternalWalletSelected,
|
|
@@ -9845,13 +10390,13 @@ function InlineConnectModal(props) {
|
|
|
9845
10390
|
() => resolveFluentWidgetAuthMethods(config?.enabledAuthMethods),
|
|
9846
10391
|
[config?.enabledAuthMethods]
|
|
9847
10392
|
);
|
|
9848
|
-
const { ready, authenticated, user } =
|
|
9849
|
-
const { isOpen: securityPromptOpen } =
|
|
9850
|
-
const { wallets, ready: walletsReady } =
|
|
9851
|
-
const { createWallet } =
|
|
9852
|
-
const { sendCode, loginWithCode } =
|
|
9853
|
-
const { initOAuth, state: oauthState } =
|
|
9854
|
-
const { loginWithPasskey } =
|
|
10393
|
+
const { ready, authenticated, user } = usePrivy2();
|
|
10394
|
+
const { isOpen: securityPromptOpen } = useModalStatus2();
|
|
10395
|
+
const { wallets, ready: walletsReady } = useWallets2();
|
|
10396
|
+
const { createWallet } = useCreateWallet2();
|
|
10397
|
+
const { sendCode, loginWithCode } = useLoginWithEmail2();
|
|
10398
|
+
const { initOAuth, state: oauthState } = useLoginWithOAuth2();
|
|
10399
|
+
const { loginWithPasskey } = useLoginWithPasskey2();
|
|
9855
10400
|
const [step, setStep] = React.useState(
|
|
9856
10401
|
() => hasPendingInlineOAuth() ? "oauth" : "choice"
|
|
9857
10402
|
);
|
|
@@ -9883,7 +10428,7 @@ function InlineConnectModal(props) {
|
|
|
9883
10428
|
active.current = open;
|
|
9884
10429
|
const connecting = step !== "choice" && authenticated;
|
|
9885
10430
|
const screen = connecting ? "connecting" : step;
|
|
9886
|
-
const shownError = error || captchaError || (connecting ? signInRefusal ||
|
|
10431
|
+
const shownError = error || captchaError || (connecting ? signInRefusal || loginError : "");
|
|
9887
10432
|
React.useEffect(() => {
|
|
9888
10433
|
if (!open) {
|
|
9889
10434
|
generation.current++;
|
|
@@ -10166,14 +10711,14 @@ function InlineConnectModal(props) {
|
|
|
10166
10711
|
}),
|
|
10167
10712
|
authMethods.map((method) => /* @__PURE__ */ jsx(React.Fragment, { children: authMethodButton(method) }, method))
|
|
10168
10713
|
] }),
|
|
10169
|
-
/* @__PURE__ */ jsx(
|
|
10170
|
-
showWallets ? /* @__PURE__ */ jsxs(
|
|
10714
|
+
/* @__PURE__ */ jsx(BranchDivider, {}),
|
|
10715
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-5", children: showWallets ? /* @__PURE__ */ jsxs(
|
|
10171
10716
|
"div",
|
|
10172
10717
|
{
|
|
10173
10718
|
className: "flex flex-col gap-2 animate-in fade-in-0 slide-in-from-bottom-1 duration-200 motion-reduce:animate-none",
|
|
10174
10719
|
ref: walletList,
|
|
10175
10720
|
role: "group",
|
|
10176
|
-
"aria-label": "
|
|
10721
|
+
"aria-label": "Connect with other wallets",
|
|
10177
10722
|
children: [
|
|
10178
10723
|
wallet?.choices?.length ? wallet.choices.map((choice) => /* @__PURE__ */ jsxs(
|
|
10179
10724
|
"button",
|
|
@@ -10204,7 +10749,7 @@ function InlineConnectModal(props) {
|
|
|
10204
10749
|
}
|
|
10205
10750
|
) : /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
10206
10751
|
button(
|
|
10207
|
-
"
|
|
10752
|
+
"Connect with other wallets",
|
|
10208
10753
|
() => {
|
|
10209
10754
|
if (!wallet?.connectChoice || !wallet.choices) {
|
|
10210
10755
|
track("connect_method_selected", {
|
|
@@ -10220,18 +10765,11 @@ function InlineConnectModal(props) {
|
|
|
10220
10765
|
{
|
|
10221
10766
|
icon: "wallet",
|
|
10222
10767
|
disabled: busy || !wallet?.configured,
|
|
10223
|
-
className:
|
|
10224
|
-
trailing: /* @__PURE__ */ jsx(
|
|
10225
|
-
ChevronRight,
|
|
10226
|
-
{
|
|
10227
|
-
className: "ml-auto size-4 text-white/50",
|
|
10228
|
-
"aria-hidden": true
|
|
10229
|
-
}
|
|
10230
|
-
)
|
|
10768
|
+
className: walletRowClassName
|
|
10231
10769
|
}
|
|
10232
10770
|
),
|
|
10233
10771
|
/* @__PURE__ */ jsx(WalletBranchNote, {})
|
|
10234
|
-
] })
|
|
10772
|
+
] }) })
|
|
10235
10773
|
] });
|
|
10236
10774
|
} else if (screen === "wallet") {
|
|
10237
10775
|
title = `Connecting to ${walletChoice?.name ?? "wallet"}`;
|
|
@@ -10400,7 +10938,17 @@ function InlineConnectModal(props) {
|
|
|
10400
10938
|
/* @__PURE__ */ jsxs(DialogHeader, { className: "items-center px-4 pt-5 pb-3 text-center", children: [
|
|
10401
10939
|
headerIcon,
|
|
10402
10940
|
/* @__PURE__ */ jsx("div", { ref: heading, tabIndex: -1, className: "outline-none", children: /* @__PURE__ */ jsx(DialogTitle, { children: title }) }),
|
|
10403
|
-
/* @__PURE__ */ jsx(
|
|
10941
|
+
/* @__PURE__ */ jsx(
|
|
10942
|
+
DialogDescription,
|
|
10943
|
+
{
|
|
10944
|
+
className: cn(
|
|
10945
|
+
"break-words text-balance",
|
|
10946
|
+
// Quieter under the lockup, where it sits on the brightest part of the gradient.
|
|
10947
|
+
screen === "choice" && "text-white/60"
|
|
10948
|
+
),
|
|
10949
|
+
children: description
|
|
10950
|
+
}
|
|
10951
|
+
)
|
|
10404
10952
|
] }),
|
|
10405
10953
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-2.5", children: [
|
|
10406
10954
|
content,
|
|
@@ -10424,7 +10972,7 @@ function InlineConnectModal(props) {
|
|
|
10424
10972
|
),
|
|
10425
10973
|
// One captcha instance per login attempt, outside the animated screens.
|
|
10426
10974
|
open && !authenticated && /* @__PURE__ */ jsx(
|
|
10427
|
-
|
|
10975
|
+
Captcha2,
|
|
10428
10976
|
{
|
|
10429
10977
|
onError: () => setCaptchaError("Verification could not load. Please retry."),
|
|
10430
10978
|
onUnsupported: () => setCaptchaError(
|
|
@@ -10453,115 +11001,6 @@ function InlineConnectModal(props) {
|
|
|
10453
11001
|
}
|
|
10454
11002
|
);
|
|
10455
11003
|
}
|
|
10456
|
-
function ConnectChoiceModal(props) {
|
|
10457
|
-
return props.authMode === "direct" ? /* @__PURE__ */ jsx(InlineConnectModal, { ...props }) : /* @__PURE__ */ jsx(HostedConnectChoiceModal, { ...props });
|
|
10458
|
-
}
|
|
10459
|
-
function HostedConnectChoiceModal({
|
|
10460
|
-
track,
|
|
10461
|
-
onExternalWalletSelected,
|
|
10462
|
-
open,
|
|
10463
|
-
wallet,
|
|
10464
|
-
onClose,
|
|
10465
|
-
onFluentLogin,
|
|
10466
|
-
fluentAuthorizeUrl,
|
|
10467
|
-
fluentReady,
|
|
10468
|
-
authMode = "hosted",
|
|
10469
|
-
config,
|
|
10470
|
-
hostedError
|
|
10471
|
-
}) {
|
|
10472
|
-
const directAuth = authMode === "direct";
|
|
10473
|
-
const fluentActionReady = fluentReady && (directAuth || Boolean(fluentAuthorizeUrl));
|
|
10474
|
-
const openWallet = () => {
|
|
10475
|
-
track("connect_method_selected", { method: "external" });
|
|
10476
|
-
onExternalWalletSelected();
|
|
10477
|
-
wallet?.open();
|
|
10478
|
-
onClose();
|
|
10479
|
-
};
|
|
10480
|
-
return /* @__PURE__ */ jsx(
|
|
10481
|
-
Dialog,
|
|
10482
|
-
{
|
|
10483
|
-
open,
|
|
10484
|
-
onOpenChange: (next) => {
|
|
10485
|
-
if (!next) onClose();
|
|
10486
|
-
},
|
|
10487
|
-
children: /* @__PURE__ */ jsxs(
|
|
10488
|
-
DialogContent,
|
|
10489
|
-
{
|
|
10490
|
-
"aria-describedby": void 0,
|
|
10491
|
-
className: "dark text-white antialiased overflow-hidden",
|
|
10492
|
-
children: [
|
|
10493
|
-
/* @__PURE__ */ jsxs("div", { className: "z-20", children: [
|
|
10494
|
-
/* @__PURE__ */ jsxs(DialogHeader, { className: "items-center text-center pt-5 pb-3 px-4", children: [
|
|
10495
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "Connect Wallet" }),
|
|
10496
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: connectDescription(config?.appName) })
|
|
10497
|
-
] }),
|
|
10498
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-2.5", children: [
|
|
10499
|
-
/* @__PURE__ */ jsx(FluentBranch, { children: /* @__PURE__ */ jsxs(
|
|
10500
|
-
Button,
|
|
10501
|
-
{
|
|
10502
|
-
href: directAuth ? void 0 : fluentAuthorizeUrl,
|
|
10503
|
-
target: directAuth ? void 0 : "fluent_connect_popup",
|
|
10504
|
-
rel: directAuth ? void 0 : "opener",
|
|
10505
|
-
"aria-disabled": !fluentActionReady,
|
|
10506
|
-
onClick: (event) => {
|
|
10507
|
-
if (!fluentActionReady) {
|
|
10508
|
-
event.preventDefault();
|
|
10509
|
-
return;
|
|
10510
|
-
}
|
|
10511
|
-
track("connect_method_selected", { method: "fluent" });
|
|
10512
|
-
onFluentLogin();
|
|
10513
|
-
onClose();
|
|
10514
|
-
},
|
|
10515
|
-
children: [
|
|
10516
|
-
/* @__PURE__ */ jsx(Icon, { name: "fluent", className: "size-5 shrink-0", "aria-hidden": true }),
|
|
10517
|
-
"Continue with Fluent Connect"
|
|
10518
|
-
]
|
|
10519
|
-
}
|
|
10520
|
-
) }),
|
|
10521
|
-
/* @__PURE__ */ jsx(OrDivider, {}),
|
|
10522
|
-
/* @__PURE__ */ jsxs(
|
|
10523
|
-
Button,
|
|
10524
|
-
{
|
|
10525
|
-
variant: "secondary",
|
|
10526
|
-
disabled: !wallet?.configured,
|
|
10527
|
-
onClick: openWallet,
|
|
10528
|
-
className: "w-full justify-start",
|
|
10529
|
-
children: [
|
|
10530
|
-
/* @__PURE__ */ jsx(Wallet, { className: "size-4 shrink-0", "aria-hidden": true }),
|
|
10531
|
-
"Other wallets",
|
|
10532
|
-
/* @__PURE__ */ jsx(
|
|
10533
|
-
ChevronRight,
|
|
10534
|
-
{
|
|
10535
|
-
className: "ml-auto size-4 text-white/50",
|
|
10536
|
-
"aria-hidden": true
|
|
10537
|
-
}
|
|
10538
|
-
)
|
|
10539
|
-
]
|
|
10540
|
-
}
|
|
10541
|
-
),
|
|
10542
|
-
/* @__PURE__ */ jsx(WalletBranchNote, {}),
|
|
10543
|
-
!wallet?.configured ? /* @__PURE__ */ jsx("p", { className: "px-2.5 text-xs text-[#ff8fda]", children: "WalletConnect bridge is unavailable." }) : null,
|
|
10544
|
-
hostedError ? /* @__PURE__ */ jsx("p", { className: "px-2.5 text-xs text-[#ff8fda]", children: hostedError }) : null
|
|
10545
|
-
] })
|
|
10546
|
-
] }),
|
|
10547
|
-
/* @__PURE__ */ jsx(
|
|
10548
|
-
"div",
|
|
10549
|
-
{
|
|
10550
|
-
className: "absolute z-[1] inset-1.5 rounded-[18px]",
|
|
10551
|
-
style: {
|
|
10552
|
-
background: "radial-gradient(152.48% 152.48% at 50% 84.8%, #000 25.21%, #5011FF 53.1%)",
|
|
10553
|
-
backgroundSize: "150% auto",
|
|
10554
|
-
backgroundPosition: "center center",
|
|
10555
|
-
backgroundRepeat: "no-repeat"
|
|
10556
|
-
}
|
|
10557
|
-
}
|
|
10558
|
-
)
|
|
10559
|
-
]
|
|
10560
|
-
}
|
|
10561
|
-
)
|
|
10562
|
-
}
|
|
10563
|
-
);
|
|
10564
|
-
}
|
|
10565
11004
|
var Select = Select$1.Root;
|
|
10566
11005
|
function SelectValue({ className, ...props }) {
|
|
10567
11006
|
return /* @__PURE__ */ jsx(
|
|
@@ -13066,23 +13505,23 @@ function useBridgeHistoryRows({
|
|
|
13066
13505
|
}) {
|
|
13067
13506
|
const { address, isConnected } = useAccount();
|
|
13068
13507
|
const wallet = isConnected ? address : void 0;
|
|
13069
|
-
const
|
|
13508
|
+
const history = useBridgeTxHistoryPages({ baseUrl: route.indexerUrl, address: wallet });
|
|
13070
13509
|
const hyperlaneToken = getBridgeTokens(network).find((t) => t.route === "fast-path");
|
|
13071
13510
|
const hyperlane = useHyperlaneTransfers({ address: wallet, route, token: hyperlaneToken });
|
|
13072
13511
|
const rows = useMemo(() => {
|
|
13073
|
-
const fromIndexer = (
|
|
13512
|
+
const fromIndexer = (history.data?.pages ?? []).flatMap((page) => page.items.map(rowFromIndexer));
|
|
13074
13513
|
const fromHyperlane = (hyperlane.data ?? []).map((t) => rowFromHyperlane(t, route, hyperlaneToken));
|
|
13075
13514
|
return sortRows([...fromIndexer, ...fromHyperlane]);
|
|
13076
|
-
}, [
|
|
13515
|
+
}, [history.data, hyperlane.data, hyperlaneToken, route]);
|
|
13077
13516
|
return {
|
|
13078
13517
|
address: wallet,
|
|
13079
13518
|
rows,
|
|
13080
|
-
pending: Boolean(wallet) && (
|
|
13081
|
-
error:
|
|
13519
|
+
pending: Boolean(wallet) && (history.isPending || hyperlane.isPending),
|
|
13520
|
+
error: history.isError ? history.error.message : null,
|
|
13082
13521
|
hyperlaneError: hyperlane.isError,
|
|
13083
|
-
hasNextPage: Boolean(
|
|
13084
|
-
isFetchingNextPage:
|
|
13085
|
-
fetchNextPage: () => void
|
|
13522
|
+
hasNextPage: Boolean(history.hasNextPage),
|
|
13523
|
+
isFetchingNextPage: history.isFetchingNextPage,
|
|
13524
|
+
fetchNextPage: () => void history.fetchNextPage()
|
|
13086
13525
|
};
|
|
13087
13526
|
}
|
|
13088
13527
|
var dayFormat = new Intl.DateTimeFormat(void 0, { dateStyle: "medium" });
|
|
@@ -13494,7 +13933,10 @@ function WalletMenuActionCard({
|
|
|
13494
13933
|
onMintUsdnr,
|
|
13495
13934
|
mintUsdnrBusy = false,
|
|
13496
13935
|
onRevealAccount,
|
|
13497
|
-
gasContext
|
|
13936
|
+
gasContext,
|
|
13937
|
+
onAddPasskey,
|
|
13938
|
+
passkeys = [],
|
|
13939
|
+
onRemovePasskey
|
|
13498
13940
|
}) {
|
|
13499
13941
|
const resolvedConfig = resolveFluentWidgetConfig(config);
|
|
13500
13942
|
const [ownPanel, setOwnPanel] = useState("tokens");
|
|
@@ -13520,6 +13962,8 @@ function WalletMenuActionCard({
|
|
|
13520
13962
|
const [activity, setActivity] = useState(null);
|
|
13521
13963
|
const [reputation, setReputation] = useState({ phase: "disconnected" });
|
|
13522
13964
|
const [actionStatus, setActionStatus] = useState(null);
|
|
13965
|
+
const [addingPasskey, setAddingPasskey] = useState(false);
|
|
13966
|
+
const [removingPasskey, setRemovingPasskey] = useState(null);
|
|
13523
13967
|
const reputationEnabled = resolvedConfig.reputationEnabled;
|
|
13524
13968
|
const client2 = useMemo(() => {
|
|
13525
13969
|
if (!reputationEnabled) return null;
|
|
@@ -13618,6 +14062,34 @@ function WalletMenuActionCard({
|
|
|
13618
14062
|
}
|
|
13619
14063
|
await mint(accountAddress);
|
|
13620
14064
|
};
|
|
14065
|
+
const handleAddPasskey = async (addPasskey) => {
|
|
14066
|
+
if (addingPasskey) return;
|
|
14067
|
+
setActionStatus(null);
|
|
14068
|
+
setAddingPasskey(true);
|
|
14069
|
+
track("wallet_passkey_link_started");
|
|
14070
|
+
try {
|
|
14071
|
+
await addPasskey();
|
|
14072
|
+
track("wallet_passkey_linked");
|
|
14073
|
+
} catch (error) {
|
|
14074
|
+
setActionStatus(error instanceof Error ? error.message : "Could not add a passkey");
|
|
14075
|
+
} finally {
|
|
14076
|
+
setAddingPasskey(false);
|
|
14077
|
+
}
|
|
14078
|
+
};
|
|
14079
|
+
const handleRemovePasskey = async (removePasskey, credentialId) => {
|
|
14080
|
+
if (removingPasskey !== null || addingPasskey) return;
|
|
14081
|
+
setActionStatus(null);
|
|
14082
|
+
setRemovingPasskey(credentialId);
|
|
14083
|
+
track("wallet_passkey_unlink_started");
|
|
14084
|
+
try {
|
|
14085
|
+
await removePasskey(credentialId);
|
|
14086
|
+
track("wallet_passkey_unlinked");
|
|
14087
|
+
} catch (error) {
|
|
14088
|
+
setActionStatus(error instanceof Error ? error.message : "Could not remove the passkey");
|
|
14089
|
+
} finally {
|
|
14090
|
+
setRemovingPasskey(null);
|
|
14091
|
+
}
|
|
14092
|
+
};
|
|
13621
14093
|
const {
|
|
13622
14094
|
balances,
|
|
13623
14095
|
busy: balancesBusy,
|
|
@@ -13741,6 +14213,38 @@ function WalletMenuActionCard({
|
|
|
13741
14213
|
] }),
|
|
13742
14214
|
statusLine ? /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", role: "status", children: statusLine }) : null
|
|
13743
14215
|
] }),
|
|
14216
|
+
onAddPasskey ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
14217
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium opacity-50 uppercase", children: "Security" }),
|
|
14218
|
+
/* @__PURE__ */ jsxs(FieldGroup, { className: "w-full gap-2", children: [
|
|
14219
|
+
passkeys.map((passkey) => /* @__PURE__ */ jsx("div", { className: "rounded-xl bg-white/10", children: /* @__PURE__ */ jsxs(Field, { orientation: "horizontal", className: "px-3.5 py-3", children: [
|
|
14220
|
+
/* @__PURE__ */ jsxs(FieldContent, { children: [
|
|
14221
|
+
/* @__PURE__ */ jsx(FieldTitle, { children: passkey.label }),
|
|
14222
|
+
/* @__PURE__ */ jsx(FieldDescription, { children: removingPasskey === passkey.credentialId ? "Removing\u2026" : passkey.addedOn ? `Added ${passkey.addedOn}` : "Signs you in on this account" })
|
|
14223
|
+
] }),
|
|
14224
|
+
onRemovePasskey ? /* @__PURE__ */ jsx(
|
|
14225
|
+
Button,
|
|
14226
|
+
{
|
|
14227
|
+
variant: "ghost",
|
|
14228
|
+
size: "icon-sm",
|
|
14229
|
+
className: "shrink-0 rounded-full",
|
|
14230
|
+
"aria-label": `Remove passkey: ${passkey.label}`,
|
|
14231
|
+
disabled: removingPasskey !== null || addingPasskey,
|
|
14232
|
+
onClick: () => void handleRemovePasskey(onRemovePasskey, passkey.credentialId),
|
|
14233
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": true })
|
|
14234
|
+
}
|
|
14235
|
+
) : null
|
|
14236
|
+
] }) }, passkey.credentialId)),
|
|
14237
|
+
/* @__PURE__ */ jsx(
|
|
14238
|
+
SettingsActionField,
|
|
14239
|
+
{
|
|
14240
|
+
title: addingPasskey ? "Waiting for your passkey" : "Add passkey",
|
|
14241
|
+
description: passkeys.length > 0 ? "Add another for a different device" : "Sign in without X next time",
|
|
14242
|
+
disabled: addingPasskey || removingPasskey !== null,
|
|
14243
|
+
onClick: () => void handleAddPasskey(onAddPasskey)
|
|
14244
|
+
}
|
|
14245
|
+
)
|
|
14246
|
+
] })
|
|
14247
|
+
] }) : null,
|
|
13744
14248
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
13745
14249
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium opacity-50 uppercase", children: "Developer" }),
|
|
13746
14250
|
/* @__PURE__ */ jsxs(FieldGroup, { className: "w-full gap-2", children: [
|
|
@@ -14759,17 +15263,17 @@ function useBridgeDeposit({
|
|
|
14759
15263
|
const pollIndexer = async () => {
|
|
14760
15264
|
if (!state.hash) return false;
|
|
14761
15265
|
try {
|
|
14762
|
-
const
|
|
15266
|
+
const history = await getBridgeTransactions({
|
|
14763
15267
|
baseUrl: route.indexerUrl,
|
|
14764
15268
|
address,
|
|
14765
15269
|
signal: controller.signal
|
|
14766
15270
|
});
|
|
14767
|
-
const item = findBridgeTxBySentHash(
|
|
15271
|
+
const item = findBridgeTxBySentHash(history, state.hash);
|
|
14768
15272
|
debugLog("[FluentBridge] indexer transactions", {
|
|
14769
15273
|
sentTxHash: state.hash,
|
|
14770
15274
|
matched: item,
|
|
14771
|
-
items:
|
|
14772
|
-
l1RequiredConfirmations:
|
|
15275
|
+
items: history.items.length,
|
|
15276
|
+
l1RequiredConfirmations: history.l1_required_confirmations
|
|
14773
15277
|
});
|
|
14774
15278
|
if (!item || !active) return false;
|
|
14775
15279
|
if (item.received_tx_hash) {
|
|
@@ -15741,9 +16245,7 @@ function deriveWidgetAccount(input) {
|
|
|
15741
16245
|
const {
|
|
15742
16246
|
smartAccount,
|
|
15743
16247
|
wallet,
|
|
15744
|
-
sessionUserId,
|
|
15745
16248
|
sessionSmartAccountAddress,
|
|
15746
|
-
directAuth,
|
|
15747
16249
|
walletUserPrivySession = false
|
|
15748
16250
|
} = input;
|
|
15749
16251
|
const fluentAccountAddress = smartAccount.smartAccountAddress ?? sessionSmartAccountAddress;
|
|
@@ -15756,16 +16258,14 @@ function deriveWidgetAccount(input) {
|
|
|
15756
16258
|
smartAccount.privyReady && smartAccount.privyAuthenticated && smartAccount.embeddedWalletCount > 0
|
|
15757
16259
|
);
|
|
15758
16260
|
const fluentAccountReady = Boolean(
|
|
15759
|
-
smartAccount.smartAccountReady && smartAccount.smartAccountAddress &&
|
|
15760
|
-
);
|
|
15761
|
-
const hasConnectedAccount = Boolean(
|
|
15762
|
-
externalConnected || (directAuth ? fluentAccountReady : sessionUserId || sessionSmartAccountAddress)
|
|
16261
|
+
smartAccount.smartAccountReady && smartAccount.smartAccountAddress && localPrivySignerReady
|
|
15763
16262
|
);
|
|
16263
|
+
const hasConnectedAccount = Boolean(externalConnected || fluentAccountReady);
|
|
15764
16264
|
const connecting = Boolean(
|
|
15765
|
-
!hasConnectedAccount &&
|
|
16265
|
+
!hasConnectedAccount && smartAccount.privyAuthenticated && !walletUserPrivySession && !smartAccount.error
|
|
15766
16266
|
);
|
|
15767
16267
|
const restoring = Boolean(
|
|
15768
|
-
!hasConnectedAccount && !connecting && !smartAccount.error && (
|
|
16268
|
+
!hasConnectedAccount && !connecting && !smartAccount.error && (!smartAccount.privyReady || wallet?.reconnecting)
|
|
15769
16269
|
);
|
|
15770
16270
|
const status = hasConnectedAccount ? "connected" : connecting ? "connecting" : restoring ? "restoring" : "disconnected";
|
|
15771
16271
|
const externalReady = Boolean(externalConnected && wallet?.hasWalletClient);
|
|
@@ -15840,18 +16340,14 @@ function useWidgetAccount(input) {
|
|
|
15840
16340
|
const {
|
|
15841
16341
|
smartAccount,
|
|
15842
16342
|
wallet,
|
|
15843
|
-
sessionUserId,
|
|
15844
16343
|
sessionSmartAccountAddress,
|
|
15845
|
-
directAuth,
|
|
15846
16344
|
walletUserPrivySession = false
|
|
15847
16345
|
} = input;
|
|
15848
16346
|
return useMemo(
|
|
15849
16347
|
() => deriveWidgetAccount({
|
|
15850
16348
|
smartAccount,
|
|
15851
16349
|
wallet,
|
|
15852
|
-
sessionUserId,
|
|
15853
16350
|
sessionSmartAccountAddress,
|
|
15854
|
-
directAuth,
|
|
15855
16351
|
walletUserPrivySession
|
|
15856
16352
|
}),
|
|
15857
16353
|
[
|
|
@@ -15866,9 +16362,7 @@ function useWidgetAccount(input) {
|
|
|
15866
16362
|
wallet?.address,
|
|
15867
16363
|
wallet?.hasWalletClient,
|
|
15868
16364
|
wallet?.reconnecting,
|
|
15869
|
-
sessionUserId,
|
|
15870
16365
|
sessionSmartAccountAddress,
|
|
15871
|
-
directAuth,
|
|
15872
16366
|
walletUserPrivySession
|
|
15873
16367
|
]
|
|
15874
16368
|
);
|
|
@@ -16105,14 +16599,6 @@ function externalWalletSigner(wallet) {
|
|
|
16105
16599
|
};
|
|
16106
16600
|
}
|
|
16107
16601
|
function createFluentSignApi(executor) {
|
|
16108
|
-
const assertDirectMode = () => {
|
|
16109
|
-
if (executor.authMode === "hosted") {
|
|
16110
|
-
throw new FluentAuthError(
|
|
16111
|
-
"hosted_not_supported",
|
|
16112
|
-
'Signing needs authMode: "direct" \u2014 there is no hosted signer to ask.'
|
|
16113
|
-
);
|
|
16114
|
-
}
|
|
16115
|
-
};
|
|
16116
16602
|
const smartAccountSigner = () => ({
|
|
16117
16603
|
address: executor.account.address,
|
|
16118
16604
|
review: !executor.silentSigning,
|
|
@@ -16131,7 +16617,6 @@ function createFluentSignApi(executor) {
|
|
|
16131
16617
|
}
|
|
16132
16618
|
});
|
|
16133
16619
|
const pickSigner = () => {
|
|
16134
|
-
assertDirectMode();
|
|
16135
16620
|
if (executor.account.type === "smart" && executor.account.address) return smartAccountSigner();
|
|
16136
16621
|
if (executor.account.type === "eoa") {
|
|
16137
16622
|
const signer = executor.wallet ? externalWalletSigner(executor.wallet) : null;
|
|
@@ -16215,8 +16700,8 @@ function useWidgetExecution(params) {
|
|
|
16215
16700
|
defaultConfirmationMode,
|
|
16216
16701
|
selectedGasPaymentToken,
|
|
16217
16702
|
defaultSponsorship,
|
|
16703
|
+
quickSignWhitelist,
|
|
16218
16704
|
confirmBatchOperation,
|
|
16219
|
-
authMode,
|
|
16220
16705
|
confirmSignature,
|
|
16221
16706
|
refreshBalances,
|
|
16222
16707
|
track
|
|
@@ -16228,10 +16713,19 @@ function useWidgetExecution(params) {
|
|
|
16228
16713
|
const sendCalls = useCallback(
|
|
16229
16714
|
async (calls, options, readyAccount) => {
|
|
16230
16715
|
if (fluentAccountReady || readyAccount) {
|
|
16231
|
-
const { hash, receipt, userOpHash, sponsored, sponsorshipReason, paymaster } = await smartAccount.sendCalls(calls, options, readyAccount);
|
|
16716
|
+
const { hash, receipt, userOpHash, sponsored, sponsorshipReason, paymaster, timing } = await smartAccount.sendCalls(calls, options, readyAccount);
|
|
16232
16717
|
track("wallet_gas_sponsored", { sponsored, reason: sponsorshipReason });
|
|
16233
16718
|
refreshBalances();
|
|
16234
|
-
return {
|
|
16719
|
+
return {
|
|
16720
|
+
hash,
|
|
16721
|
+
receipt,
|
|
16722
|
+
userOpHash,
|
|
16723
|
+
hashes: [hash],
|
|
16724
|
+
atomic: true,
|
|
16725
|
+
sponsored,
|
|
16726
|
+
paymaster,
|
|
16727
|
+
timing
|
|
16728
|
+
};
|
|
16235
16729
|
}
|
|
16236
16730
|
if (wallet?.connected && wallet.walletClient) {
|
|
16237
16731
|
const result = await sendCallsViaExternalWallet(calls, wallet, chain, eoaPublicClient);
|
|
@@ -16258,6 +16752,7 @@ function useWidgetExecution(params) {
|
|
|
16258
16752
|
defaultConfirmation: defaultConfirmationMode,
|
|
16259
16753
|
defaultGasPayment: selectedGasPaymentToken,
|
|
16260
16754
|
defaultSponsorship,
|
|
16755
|
+
quickSignWhitelist,
|
|
16261
16756
|
confirm: confirmBatchOperation,
|
|
16262
16757
|
sendCalls
|
|
16263
16758
|
}),
|
|
@@ -16269,7 +16764,8 @@ function useWidgetExecution(params) {
|
|
|
16269
16764
|
defaultConfirmationMode,
|
|
16270
16765
|
selectedGasPaymentToken,
|
|
16271
16766
|
confirmBatchOperation,
|
|
16272
|
-
defaultSponsorship
|
|
16767
|
+
defaultSponsorship,
|
|
16768
|
+
quickSignWhitelist
|
|
16273
16769
|
]
|
|
16274
16770
|
);
|
|
16275
16771
|
const permissionApi = useMemo(
|
|
@@ -16281,7 +16777,6 @@ function useWidgetExecution(params) {
|
|
|
16281
16777
|
);
|
|
16282
16778
|
const signApi = useMemo(
|
|
16283
16779
|
() => createFluentSignApi({
|
|
16284
|
-
authMode,
|
|
16285
16780
|
account: widgetAccount,
|
|
16286
16781
|
origin: window.location.origin,
|
|
16287
16782
|
silentSigning: defaultConfirmationMode === "session",
|
|
@@ -16299,7 +16794,6 @@ function useWidgetExecution(params) {
|
|
|
16299
16794
|
wallet: wallet?.connected ? wallet : void 0
|
|
16300
16795
|
}),
|
|
16301
16796
|
[
|
|
16302
|
-
authMode,
|
|
16303
16797
|
widgetAccount,
|
|
16304
16798
|
defaultConfirmationMode,
|
|
16305
16799
|
confirmSignature,
|
|
@@ -16454,7 +16948,7 @@ function useUsdnrMint(params) {
|
|
|
16454
16948
|
return { mintUsdnr, mintingUsdnr: minting };
|
|
16455
16949
|
}
|
|
16456
16950
|
function useZeroDevInitializer(params) {
|
|
16457
|
-
const { smartAccount,
|
|
16951
|
+
const { smartAccount, session, widgetAccount } = params;
|
|
16458
16952
|
const initRequested = useRef(false);
|
|
16459
16953
|
const resetInitialization = useCallback(() => {
|
|
16460
16954
|
initRequested.current = false;
|
|
@@ -16492,7 +16986,6 @@ function useZeroDevInitializer(params) {
|
|
|
16492
16986
|
]);
|
|
16493
16987
|
useEffect(() => {
|
|
16494
16988
|
if (smartAccount.smartAccountReady) return;
|
|
16495
|
-
if (!directAuth && !session) return;
|
|
16496
16989
|
if (!smartAccount.privyAuthenticated || smartAccount.embeddedWalletCount === 0) {
|
|
16497
16990
|
debugWarn("[fluent widget] ZeroDev init skipped: signer unavailable", {
|
|
16498
16991
|
privyReady: smartAccount.privyReady,
|
|
@@ -16512,8 +17005,6 @@ function useZeroDevInitializer(params) {
|
|
|
16512
17005
|
debugWarn("[fluent widget] ZeroDev account initialization failed", error);
|
|
16513
17006
|
});
|
|
16514
17007
|
}, [
|
|
16515
|
-
directAuth,
|
|
16516
|
-
session,
|
|
16517
17008
|
smartAccount.embeddedWalletCount,
|
|
16518
17009
|
smartAccount.privyAuthenticated,
|
|
16519
17010
|
smartAccount.refresh,
|
|
@@ -16540,140 +17031,6 @@ function useConnectStatus() {
|
|
|
16540
17031
|
const [error, setError] = useState(null);
|
|
16541
17032
|
return { status, setStatus, error, setError };
|
|
16542
17033
|
}
|
|
16543
|
-
var FLUENT_WIDGET_AUTH_STATE_STORAGE_KEY = "fluent:widget:auth-state:v1";
|
|
16544
|
-
function useHostedConnect(params) {
|
|
16545
|
-
const {
|
|
16546
|
-
fluentConnect,
|
|
16547
|
-
authorizeUrl,
|
|
16548
|
-
appId,
|
|
16549
|
-
appName,
|
|
16550
|
-
authMode,
|
|
16551
|
-
setSession,
|
|
16552
|
-
resetInitialization,
|
|
16553
|
-
setConnectOpen,
|
|
16554
|
-
setStatus,
|
|
16555
|
-
setError,
|
|
16556
|
-
smartAccountRefresh,
|
|
16557
|
-
track
|
|
16558
|
-
} = params;
|
|
16559
|
-
const [hostedAuthorizeUrl, setHostedAuthorizeUrl] = useState();
|
|
16560
|
-
const hostedConnectWindow = useRef(null);
|
|
16561
|
-
const hostedConnectState = useRef(null);
|
|
16562
|
-
const beginHostedConnect = useCallback(() => {
|
|
16563
|
-
const state = crypto.randomUUID?.() ?? `${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
|
16564
|
-
hostedConnectState.current = state;
|
|
16565
|
-
try {
|
|
16566
|
-
window.sessionStorage.setItem(FLUENT_WIDGET_AUTH_STATE_STORAGE_KEY, state);
|
|
16567
|
-
} catch {
|
|
16568
|
-
}
|
|
16569
|
-
const url = fluentConnect.buildAuthorizeUrl(state).toString();
|
|
16570
|
-
debugLog("[fluent widget] open connect", { state, authorizeUrl: url, appId, appName, authMode });
|
|
16571
|
-
setHostedAuthorizeUrl(url);
|
|
16572
|
-
setConnectOpen(true);
|
|
16573
|
-
}, [appName, authMode, appId, fluentConnect, setConnectOpen]);
|
|
16574
|
-
const acceptHostedResult = useCallback(
|
|
16575
|
-
(data) => {
|
|
16576
|
-
if (!data || typeof data !== "object") return;
|
|
16577
|
-
const payload = data;
|
|
16578
|
-
if (payload.type === "fluent:connect:error") {
|
|
16579
|
-
track("connect_login_failed", { reason: "hosted_error" });
|
|
16580
|
-
setError(typeof payload.error === "string" ? payload.error : "Fluent Connect login failed");
|
|
16581
|
-
hostedConnectWindow.current?.close();
|
|
16582
|
-
hostedConnectWindow.current = null;
|
|
16583
|
-
return;
|
|
16584
|
-
}
|
|
16585
|
-
if (payload.type !== "fluent:connect:session" || !payload.session) return;
|
|
16586
|
-
let expectedState = hostedConnectState.current;
|
|
16587
|
-
try {
|
|
16588
|
-
expectedState ??= window.sessionStorage.getItem(FLUENT_WIDGET_AUTH_STATE_STORAGE_KEY);
|
|
16589
|
-
} catch {
|
|
16590
|
-
}
|
|
16591
|
-
if (!payload.state || !expectedState || payload.state !== expectedState) {
|
|
16592
|
-
track("connect_login_failed", { reason: "state_mismatch" });
|
|
16593
|
-
setError("Fluent Connect login failed state validation");
|
|
16594
|
-
hostedConnectWindow.current?.close();
|
|
16595
|
-
hostedConnectWindow.current = null;
|
|
16596
|
-
return;
|
|
16597
|
-
}
|
|
16598
|
-
if (payload.session.app?.origin && payload.session.app.origin !== fluentConnect.status().app.origin) {
|
|
16599
|
-
track("connect_login_failed", { reason: "origin_mismatch" });
|
|
16600
|
-
setError("Fluent Connect session origin does not match this app");
|
|
16601
|
-
hostedConnectWindow.current?.close();
|
|
16602
|
-
hostedConnectWindow.current = null;
|
|
16603
|
-
return;
|
|
16604
|
-
}
|
|
16605
|
-
if (!payload.session.wallet?.smartAccountAddress) {
|
|
16606
|
-
track("connect_login_failed", { reason: "smart_account_missing" });
|
|
16607
|
-
setError("Fluent smart account is not ready. Reconnect with Fluent ID.");
|
|
16608
|
-
hostedConnectWindow.current?.close();
|
|
16609
|
-
hostedConnectWindow.current = null;
|
|
16610
|
-
return;
|
|
16611
|
-
}
|
|
16612
|
-
const nextIdentityToken = typeof payload.privyIdentityToken === "string" ? payload.privyIdentityToken : null;
|
|
16613
|
-
debugLog("[fluent widget] hosted result accepted", {
|
|
16614
|
-
userId: payload.session.user?.id,
|
|
16615
|
-
signerAddress: payload.session.wallet?.signerAddress,
|
|
16616
|
-
smartAccountAddress: payload.session.wallet?.smartAccountAddress,
|
|
16617
|
-
scopes: payload.session.scopes,
|
|
16618
|
-
hasIdentityToken: Boolean(nextIdentityToken)
|
|
16619
|
-
});
|
|
16620
|
-
setSession(payload.session);
|
|
16621
|
-
track("connect_login_completed");
|
|
16622
|
-
resetInitialization();
|
|
16623
|
-
fluentConnect.setSession(payload.session);
|
|
16624
|
-
const storage = resolveLocalStorage();
|
|
16625
|
-
if (nextIdentityToken) {
|
|
16626
|
-
writeStoredValue(storage, FLUENT_WIDGET_IDENTITY_TOKEN_STORAGE_KEY, nextIdentityToken);
|
|
16627
|
-
} else {
|
|
16628
|
-
removeStoredValue(storage, FLUENT_WIDGET_IDENTITY_TOKEN_STORAGE_KEY);
|
|
16629
|
-
}
|
|
16630
|
-
setStatus("Wallet connected!");
|
|
16631
|
-
setError(null);
|
|
16632
|
-
setConnectOpen(false);
|
|
16633
|
-
hostedConnectState.current = null;
|
|
16634
|
-
try {
|
|
16635
|
-
window.sessionStorage.removeItem(FLUENT_WIDGET_AUTH_STATE_STORAGE_KEY);
|
|
16636
|
-
} catch {
|
|
16637
|
-
}
|
|
16638
|
-
hostedConnectWindow.current?.close();
|
|
16639
|
-
hostedConnectWindow.current = null;
|
|
16640
|
-
window.setTimeout(() => {
|
|
16641
|
-
smartAccountRefresh().catch((error) => {
|
|
16642
|
-
debugWarn("[fluent widget] ZeroDev account not ready after hosted login", error);
|
|
16643
|
-
});
|
|
16644
|
-
}, 250);
|
|
16645
|
-
},
|
|
16646
|
-
[fluentConnect, resetInitialization, setConnectOpen, setError, setSession, setStatus, smartAccountRefresh, track]
|
|
16647
|
-
);
|
|
16648
|
-
useEffect(() => {
|
|
16649
|
-
const hash = new URLSearchParams(location.hash.replace(/^#/, ""));
|
|
16650
|
-
const rawResult = hash.get("fluent_connect_result");
|
|
16651
|
-
if (!rawResult) return;
|
|
16652
|
-
try {
|
|
16653
|
-
acceptHostedResult(JSON.parse(rawResult));
|
|
16654
|
-
} catch {
|
|
16655
|
-
setError("Could not parse Fluent Connect result");
|
|
16656
|
-
} finally {
|
|
16657
|
-
history.replaceState(null, "", `${location.pathname}${location.search}`);
|
|
16658
|
-
}
|
|
16659
|
-
}, [acceptHostedResult, setError]);
|
|
16660
|
-
useEffect(() => {
|
|
16661
|
-
function onMessage(event) {
|
|
16662
|
-
if (event.origin !== new URL(authorizeUrl, location.href).origin) return;
|
|
16663
|
-
if (!event.data) return;
|
|
16664
|
-
acceptHostedResult(event.data);
|
|
16665
|
-
}
|
|
16666
|
-
addEventListener("message", onMessage);
|
|
16667
|
-
return () => removeEventListener("message", onMessage);
|
|
16668
|
-
}, [acceptHostedResult, authorizeUrl]);
|
|
16669
|
-
useEffect(() => {
|
|
16670
|
-
return () => {
|
|
16671
|
-
hostedConnectWindow.current?.close();
|
|
16672
|
-
hostedConnectWindow.current = null;
|
|
16673
|
-
};
|
|
16674
|
-
}, []);
|
|
16675
|
-
return { hostedAuthorizeUrl, beginHostedConnect };
|
|
16676
|
-
}
|
|
16677
17034
|
function useAccountMenu(params) {
|
|
16678
17035
|
const {
|
|
16679
17036
|
accountMenuAddress,
|
|
@@ -16832,16 +17189,15 @@ function settingsAudienceKey(params) {
|
|
|
16832
17189
|
return `${params.publicApiUrl}|${params.appId}`;
|
|
16833
17190
|
}
|
|
16834
17191
|
function resolveSettingsSubject(params) {
|
|
16835
|
-
const {
|
|
16836
|
-
if (authMode === "hosted" && accountType === "smart") return null;
|
|
17192
|
+
const { accountType, privyUserId, walletAddress } = params;
|
|
16837
17193
|
if (accountType === "smart" && privyUserId) return `privy:${privyUserId}`;
|
|
16838
17194
|
if (accountType === "eoa" && walletAddress) return `wallet:${walletAddress.toLowerCase()}`;
|
|
16839
17195
|
return null;
|
|
16840
17196
|
}
|
|
16841
17197
|
function resolveSettingsIdentities(params) {
|
|
16842
|
-
const {
|
|
17198
|
+
const { privyUserId, walletAddress } = params;
|
|
16843
17199
|
const identities = [];
|
|
16844
|
-
if (
|
|
17200
|
+
if (privyUserId) identities.push(`privy:${privyUserId}`);
|
|
16845
17201
|
if (walletAddress) identities.push(`wallet:${walletAddress.toLowerCase()}`);
|
|
16846
17202
|
return identities;
|
|
16847
17203
|
}
|
|
@@ -17104,7 +17460,6 @@ async function requestAuthToken(params, state, options = {}) {
|
|
|
17104
17460
|
const {
|
|
17105
17461
|
publicApiUrl,
|
|
17106
17462
|
appId,
|
|
17107
|
-
authMode,
|
|
17108
17463
|
renewalOffsetSeconds,
|
|
17109
17464
|
accountType,
|
|
17110
17465
|
privyUserId,
|
|
@@ -17114,12 +17469,6 @@ async function requestAuthToken(params, state, options = {}) {
|
|
|
17114
17469
|
walletClient,
|
|
17115
17470
|
origin
|
|
17116
17471
|
} = params;
|
|
17117
|
-
if (authMode === "hosted" && accountType === "smart") {
|
|
17118
|
-
throw new FluentAuthError(
|
|
17119
|
-
"hosted_not_supported",
|
|
17120
|
-
'getAuthToken() for a Fluent ID needs authMode: "direct" \u2014 in hosted mode its Privy session lives on the authorize page, not in this page.'
|
|
17121
|
-
);
|
|
17122
|
-
}
|
|
17123
17472
|
const subject = accountType === "smart" && privyUserId ? `privy:${privyUserId}` : accountType === "eoa" && walletAddress ? `wallet:${walletAddress.toLowerCase()}` : null;
|
|
17124
17473
|
if (!subject) {
|
|
17125
17474
|
throw new FluentAuthError("not_connected", "Connect a Fluent ID or an external wallet first.");
|
|
@@ -17278,7 +17627,6 @@ function useAuthToken(params, state) {
|
|
|
17278
17627
|
const {
|
|
17279
17628
|
publicApiUrl,
|
|
17280
17629
|
appId,
|
|
17281
|
-
authMode,
|
|
17282
17630
|
renewalOffsetSeconds,
|
|
17283
17631
|
accountType,
|
|
17284
17632
|
privyUserId,
|
|
@@ -17295,7 +17643,6 @@ function useAuthToken(params, state) {
|
|
|
17295
17643
|
{
|
|
17296
17644
|
publicApiUrl,
|
|
17297
17645
|
appId,
|
|
17298
|
-
authMode,
|
|
17299
17646
|
renewalOffsetSeconds,
|
|
17300
17647
|
accountType,
|
|
17301
17648
|
privyUserId,
|
|
@@ -17311,7 +17658,6 @@ function useAuthToken(params, state) {
|
|
|
17311
17658
|
),
|
|
17312
17659
|
[
|
|
17313
17660
|
accountType,
|
|
17314
|
-
authMode,
|
|
17315
17661
|
renewalOffsetSeconds,
|
|
17316
17662
|
appId,
|
|
17317
17663
|
getAccessToken,
|
|
@@ -17334,7 +17680,6 @@ function useAuthToken(params, state) {
|
|
|
17334
17680
|
await endAuthSession({
|
|
17335
17681
|
publicApiUrl,
|
|
17336
17682
|
appId,
|
|
17337
|
-
authMode,
|
|
17338
17683
|
accountType,
|
|
17339
17684
|
privyUserId,
|
|
17340
17685
|
walletAddress,
|
|
@@ -17343,7 +17688,6 @@ function useAuthToken(params, state) {
|
|
|
17343
17688
|
}, [
|
|
17344
17689
|
accountType,
|
|
17345
17690
|
appId,
|
|
17346
|
-
authMode,
|
|
17347
17691
|
privyUserId,
|
|
17348
17692
|
publicApiUrl,
|
|
17349
17693
|
storage,
|
|
@@ -17360,7 +17704,6 @@ function useUserSettings(params) {
|
|
|
17360
17704
|
state,
|
|
17361
17705
|
publicApiUrl,
|
|
17362
17706
|
appId,
|
|
17363
|
-
authMode,
|
|
17364
17707
|
network,
|
|
17365
17708
|
defaultGasToken = FLUENT_WIDGET_DEFAULT_GAS_TOKEN,
|
|
17366
17709
|
accountType,
|
|
@@ -17388,8 +17731,8 @@ function useUserSettings(params) {
|
|
|
17388
17731
|
[network]
|
|
17389
17732
|
);
|
|
17390
17733
|
const subject = useMemo(
|
|
17391
|
-
() => resolveSettingsSubject({
|
|
17392
|
-
[
|
|
17734
|
+
() => resolveSettingsSubject({ accountType, privyUserId, walletAddress }),
|
|
17735
|
+
[accountType, privyUserId, walletAddress]
|
|
17393
17736
|
);
|
|
17394
17737
|
const ready = useMemo(
|
|
17395
17738
|
() => isSettingsSubjectReady({ accountType, identityToken, walletAddress, hasWalletClient }),
|
|
@@ -17425,8 +17768,8 @@ function useUserSettings(params) {
|
|
|
17425
17768
|
[appId, publicApiUrl]
|
|
17426
17769
|
);
|
|
17427
17770
|
const identities = useMemo(
|
|
17428
|
-
() => resolveSettingsIdentities({
|
|
17429
|
-
[
|
|
17771
|
+
() => resolveSettingsIdentities({ privyUserId, walletAddress }),
|
|
17772
|
+
[privyUserId, walletAddress]
|
|
17430
17773
|
);
|
|
17431
17774
|
const knownSubjects = useMemo(
|
|
17432
17775
|
() => identities.map(
|
|
@@ -17841,6 +18184,7 @@ function FluentConnectButtonSlot({
|
|
|
17841
18184
|
connected: hasConnectedAccount,
|
|
17842
18185
|
pending: connecting,
|
|
17843
18186
|
addressLabel: connectAddressLabel,
|
|
18187
|
+
userAvatarUrl: userLogoUrl || void 0,
|
|
17844
18188
|
onClick: onTopConnectClick,
|
|
17845
18189
|
openConnect,
|
|
17846
18190
|
openAccount,
|
|
@@ -17849,7 +18193,7 @@ function FluentConnectButtonSlot({
|
|
|
17849
18193
|
return renderConnectButton?.(connectButtonContext) ?? (connectButton === false ? null : connectButton === "inline" ? defaultConnectButton : /* @__PURE__ */ jsx("div", { className: "fixed top-5 right-5 z-50", children: defaultConnectButton }));
|
|
17850
18194
|
}
|
|
17851
18195
|
function DebugPanel(props) {
|
|
17852
|
-
const { session, wallet, walletStatus,
|
|
18196
|
+
const { session, wallet, walletStatus, loginError } = props;
|
|
17853
18197
|
return /* @__PURE__ */ jsxs("section", { className: "overflow-hidden rounded-2xl border border-white/10 bg-black/70 text-white shadow-2xl backdrop-blur-md", children: [
|
|
17854
18198
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-white/10 px-4 py-3.5", children: [
|
|
17855
18199
|
/* @__PURE__ */ jsx("h2", { className: "m-0 text-base font-medium", children: "Host app callback" }),
|
|
@@ -17861,7 +18205,7 @@ function DebugPanel(props) {
|
|
|
17861
18205
|
/* @__PURE__ */ jsx("span", { className: "rounded-full bg-[#49eded]/15 px-2 py-1 text-xs font-medium text-[#49eded]", children: wallet?.connected ? "Reown" : "wallet" })
|
|
17862
18206
|
] }),
|
|
17863
18207
|
/* @__PURE__ */ jsx("pre", { className: "overflow-auto p-4 text-xs", children: formatExternalWallet(wallet, walletStatus) }),
|
|
17864
|
-
|
|
18208
|
+
loginError ? /* @__PURE__ */ jsx("p", { className: "m-0 px-4 pb-4 text-[13px] leading-5 text-[#ff8fda]", children: loginError }) : null
|
|
17865
18209
|
] });
|
|
17866
18210
|
}
|
|
17867
18211
|
var FLUENT_WIDGET_DIRECT_LOGIN_INTENT_KEY = "fluent:widget:direct-login-intent:v1";
|
|
@@ -17937,7 +18281,6 @@ function FluentWidgetContent({
|
|
|
17937
18281
|
requestPrivyLogin,
|
|
17938
18282
|
inlineLoginRequest,
|
|
17939
18283
|
handledInlineLoginRequest,
|
|
17940
|
-
pendingPrivyLoginRef,
|
|
17941
18284
|
authTokenState,
|
|
17942
18285
|
userSettingsRef,
|
|
17943
18286
|
connectedPresentation
|
|
@@ -17952,15 +18295,26 @@ function FluentWidgetContent({
|
|
|
17952
18295
|
login: requestPrivyLogin,
|
|
17953
18296
|
appId: resolvedConfig.appId,
|
|
17954
18297
|
sponsorshipUrl: resolvedConfig.sponsorshipUrl,
|
|
17955
|
-
sponsorshipTokenSource: readSponsorshipTokenSource
|
|
18298
|
+
sponsorshipTokenSource: readSponsorshipTokenSource,
|
|
18299
|
+
// Passed on every render, not captured once: the hook reads these settings at the moment a
|
|
18300
|
+
// send or a signature needs them, so a host that changes them is obeyed by the next one
|
|
18301
|
+
// without the kernel being rebuilt.
|
|
18302
|
+
execution: resolvedConfig.execution
|
|
17956
18303
|
});
|
|
17957
|
-
const {
|
|
17958
|
-
|
|
17959
|
-
|
|
18304
|
+
const {
|
|
18305
|
+
authenticated,
|
|
18306
|
+
getAccessToken,
|
|
18307
|
+
login,
|
|
18308
|
+
logout,
|
|
18309
|
+
ready: privyReady,
|
|
18310
|
+
unlinkPasskey,
|
|
18311
|
+
user
|
|
18312
|
+
} = usePrivy2();
|
|
18313
|
+
const { identityToken } = useIdentityToken2();
|
|
18314
|
+
const { refreshUser } = useUser2();
|
|
17960
18315
|
const activeWallet = wallet ?? internalWallet;
|
|
17961
18316
|
const { chain } = useFluentWidgetNetwork();
|
|
17962
18317
|
const fluentConnect = useMemo(() => createFluentConnectForWidget(config), [config]);
|
|
17963
|
-
const directAuth = resolvedConfig.authMode === "direct";
|
|
17964
18318
|
const directAuthRequested = useRef(
|
|
17965
18319
|
(() => {
|
|
17966
18320
|
try {
|
|
@@ -17971,6 +18325,7 @@ function FluentWidgetContent({
|
|
|
17971
18325
|
})()
|
|
17972
18326
|
);
|
|
17973
18327
|
const directAuthInFlight = useRef(false);
|
|
18328
|
+
const dialogAskedOnThisPage = useRef(false);
|
|
17974
18329
|
const disconnectingRef = useRef(false);
|
|
17975
18330
|
const { session, setSession } = useFluentSession({
|
|
17976
18331
|
reportAnalyticsSession,
|
|
@@ -17979,13 +18334,13 @@ function FluentWidgetContent({
|
|
|
17979
18334
|
const {
|
|
17980
18335
|
status: walletStatus,
|
|
17981
18336
|
setStatus: setWalletStatus,
|
|
17982
|
-
error:
|
|
17983
|
-
setError:
|
|
18337
|
+
error: loginError,
|
|
18338
|
+
setError: setLoginError
|
|
17984
18339
|
} = useConnectStatus();
|
|
17985
18340
|
const [balanceRevisionCounter, setBalanceRevisionCounter] = useState(0);
|
|
17986
18341
|
const [walletMenuPanel, setWalletMenuPanel] = useState("tokens");
|
|
17987
18342
|
const refreshBalances = useCallback(() => setBalanceRevisionCounter((value) => value + 1), []);
|
|
17988
|
-
const [connectOpen, setConnectOpen] = useState(() =>
|
|
18343
|
+
const [connectOpen, setConnectOpen] = useState(() => hasPendingInlineOAuth());
|
|
17989
18344
|
const connectedWalletAddress = activeWallet?.connected ? activeWallet.address : void 0;
|
|
17990
18345
|
const walletClientReady = Boolean(
|
|
17991
18346
|
activeWallet?.address && activeWallet.walletClient?.account?.address?.toLowerCase() === activeWallet.address.toLowerCase()
|
|
@@ -17995,7 +18350,7 @@ function FluentWidgetContent({
|
|
|
17995
18350
|
const linkXSiweLogins = useRef({ pending: false, userIds: /* @__PURE__ */ new Set() });
|
|
17996
18351
|
const siweSignedInOnThisPage = linkXSiweLogins.current.pending || user?.id !== void 0 && linkXSiweLogins.current.userIds.has(user.id);
|
|
17997
18352
|
const dialogSignInUserIds = useRef(/* @__PURE__ */ new Set());
|
|
17998
|
-
if (
|
|
18353
|
+
if (user?.id !== void 0 && !dialogSignInUserIds.current.has(user.id) && privyUserHasExternalWallet(user) && (dialogAskedOnThisPage.current || directLoginDialogMarksPresent()))
|
|
17999
18354
|
dialogSignInUserIds.current.add(user.id);
|
|
18000
18355
|
const dialogSignedInOnThisPage = user?.id !== void 0 && dialogSignInUserIds.current.has(user.id);
|
|
18001
18356
|
const walletUserPrivySession = (privyUserHasExternalWallet(user) || siweSignedInOnThisPage) && !fluentSessionNamesPrivyUser && !(dialogSignedInOnThisPage && !siweSignedInOnThisPage);
|
|
@@ -18020,9 +18375,7 @@ function FluentWidgetContent({
|
|
|
18020
18375
|
hasWalletClient: walletClientReady,
|
|
18021
18376
|
reconnecting: activeWallet.reconnecting
|
|
18022
18377
|
} : null,
|
|
18023
|
-
sessionUserId: session?.user?.id,
|
|
18024
18378
|
sessionSmartAccountAddress: session?.wallet?.smartAccountAddress,
|
|
18025
|
-
directAuth,
|
|
18026
18379
|
walletUserPrivySession
|
|
18027
18380
|
});
|
|
18028
18381
|
const walletConnected = Boolean(activeWallet?.connected);
|
|
@@ -18065,7 +18418,6 @@ function FluentWidgetContent({
|
|
|
18065
18418
|
const { resetInitialization } = useZeroDevInitializer({
|
|
18066
18419
|
// The same count the account model reads: a wallet's own Privy session initializes nothing.
|
|
18067
18420
|
smartAccount: { ...smartAccount, embeddedWalletCount },
|
|
18068
|
-
directAuth,
|
|
18069
18421
|
session,
|
|
18070
18422
|
widgetAccount
|
|
18071
18423
|
});
|
|
@@ -18075,22 +18427,9 @@ function FluentWidgetContent({
|
|
|
18075
18427
|
chainId: activeWallet?.chainId,
|
|
18076
18428
|
track
|
|
18077
18429
|
});
|
|
18078
|
-
const { hostedAuthorizeUrl, beginHostedConnect } = useHostedConnect({
|
|
18079
|
-
fluentConnect,
|
|
18080
|
-
authorizeUrl: resolvedConfig.authorizeUrl,
|
|
18081
|
-
appId: resolvedConfig.appId,
|
|
18082
|
-
appName: resolvedConfig.appName,
|
|
18083
|
-
authMode: resolvedConfig.authMode,
|
|
18084
|
-
setSession,
|
|
18085
|
-
resetInitialization,
|
|
18086
|
-
setConnectOpen,
|
|
18087
|
-
setStatus: setWalletStatus,
|
|
18088
|
-
setError: setHostedError,
|
|
18089
|
-
smartAccountRefresh: smartAccount.refresh,
|
|
18090
|
-
track
|
|
18091
|
-
});
|
|
18092
18430
|
const setDirectAuthRequested = useCallback((pending2) => {
|
|
18093
18431
|
directAuthRequested.current = pending2;
|
|
18432
|
+
dialogAskedOnThisPage.current = pending2;
|
|
18094
18433
|
try {
|
|
18095
18434
|
if (pending2) window.sessionStorage.setItem(FLUENT_WIDGET_DIRECT_LOGIN_INTENT_KEY, "1");
|
|
18096
18435
|
else window.sessionStorage.removeItem(FLUENT_WIDGET_DIRECT_LOGIN_INTENT_KEY);
|
|
@@ -18101,14 +18440,10 @@ function FluentWidgetContent({
|
|
|
18101
18440
|
(trigger = "connect_button") => {
|
|
18102
18441
|
track("connect_opened", { trigger });
|
|
18103
18442
|
setAccountOpen(false);
|
|
18104
|
-
|
|
18105
|
-
|
|
18106
|
-
setConnectOpen(true);
|
|
18107
|
-
return;
|
|
18108
|
-
}
|
|
18109
|
-
beginHostedConnect();
|
|
18443
|
+
setLoginError(null);
|
|
18444
|
+
setConnectOpen(true);
|
|
18110
18445
|
},
|
|
18111
|
-
[
|
|
18446
|
+
[setAccountOpen, setLoginError, track]
|
|
18112
18447
|
);
|
|
18113
18448
|
const handleTopConnectClick = useCallback(() => {
|
|
18114
18449
|
if (hasConnectedAccount) {
|
|
@@ -18131,7 +18466,7 @@ function FluentWidgetContent({
|
|
|
18131
18466
|
fluentConnect.disconnect();
|
|
18132
18467
|
removeStoredValue(resolveLocalStorage(), FLUENT_WIDGET_IDENTITY_TOKEN_STORAGE_KEY);
|
|
18133
18468
|
setWalletStatus("Disconnected");
|
|
18134
|
-
if (
|
|
18469
|
+
if (authenticated) {
|
|
18135
18470
|
try {
|
|
18136
18471
|
await logout();
|
|
18137
18472
|
} catch (error) {
|
|
@@ -18147,7 +18482,7 @@ function FluentWidgetContent({
|
|
|
18147
18482
|
disconnectingRef.current = false;
|
|
18148
18483
|
}
|
|
18149
18484
|
if (awaitAuthSession) await authSessionEnded;
|
|
18150
|
-
}, [activeWallet, authenticated, commitSilentSigningEnabled, connectedPresentation,
|
|
18485
|
+
}, [activeWallet, authenticated, commitSilentSigningEnabled, connectedPresentation, fluentConnect, logout, setDirectAuthRequested, setSession]);
|
|
18151
18486
|
const requestDisconnect = useCallback(() => {
|
|
18152
18487
|
track("wallet_disconnected");
|
|
18153
18488
|
return handleDisconnect({ awaitAuthSession: true });
|
|
@@ -18197,7 +18532,7 @@ function FluentWidgetContent({
|
|
|
18197
18532
|
setStatus: setWalletStatus
|
|
18198
18533
|
});
|
|
18199
18534
|
const completeDirectAuthorization = useCallback(async () => {
|
|
18200
|
-
if (!
|
|
18535
|
+
if (!authenticated || !user?.id || directAuthInFlight.current) return;
|
|
18201
18536
|
if (disconnectingRef.current) return;
|
|
18202
18537
|
if (walletUserPrivySession) return;
|
|
18203
18538
|
if (session && !directAuthRequested.current && session.user?.id === user.id) return;
|
|
@@ -18207,7 +18542,7 @@ function FluentWidgetContent({
|
|
|
18207
18542
|
}
|
|
18208
18543
|
directAuthInFlight.current = true;
|
|
18209
18544
|
setWalletStatus("Preparing Fluent account");
|
|
18210
|
-
|
|
18545
|
+
setLoginError(null);
|
|
18211
18546
|
try {
|
|
18212
18547
|
const kernel = smartAccount.kernel ?? await smartAccount.refresh();
|
|
18213
18548
|
if (!kernel?.smartAccountAddress) {
|
|
@@ -18244,14 +18579,13 @@ function FluentWidgetContent({
|
|
|
18244
18579
|
clearInlineOAuth();
|
|
18245
18580
|
track("connect_login_failed", { reason: "direct_auth_failed" });
|
|
18246
18581
|
debugError("[fluent widget] direct auth failed", error);
|
|
18247
|
-
|
|
18582
|
+
setLoginError(message2);
|
|
18248
18583
|
setWalletStatus(message2);
|
|
18249
18584
|
} finally {
|
|
18250
18585
|
directAuthInFlight.current = false;
|
|
18251
18586
|
}
|
|
18252
18587
|
}, [
|
|
18253
18588
|
authenticated,
|
|
18254
|
-
directAuth,
|
|
18255
18589
|
fluentConnect,
|
|
18256
18590
|
identityToken,
|
|
18257
18591
|
resolvedConfig.scopes,
|
|
@@ -18266,7 +18600,6 @@ function FluentWidgetContent({
|
|
|
18266
18600
|
walletUserPrivySession
|
|
18267
18601
|
]);
|
|
18268
18602
|
useEffect(() => {
|
|
18269
|
-
if (!directAuth) return;
|
|
18270
18603
|
if (disconnectingRef.current) return;
|
|
18271
18604
|
if (!privyReady || !authenticated) return;
|
|
18272
18605
|
if (embeddedWalletCount === 0) return;
|
|
@@ -18274,7 +18607,6 @@ function FluentWidgetContent({
|
|
|
18274
18607
|
}, [
|
|
18275
18608
|
authenticated,
|
|
18276
18609
|
completeDirectAuthorization,
|
|
18277
|
-
directAuth,
|
|
18278
18610
|
embeddedWalletCount,
|
|
18279
18611
|
identityToken,
|
|
18280
18612
|
privyReady,
|
|
@@ -18282,13 +18614,8 @@ function FluentWidgetContent({
|
|
|
18282
18614
|
smartAccount.smartAccountAddress,
|
|
18283
18615
|
smartAccount.smartAccountReady
|
|
18284
18616
|
]);
|
|
18285
|
-
useEffect(() => {
|
|
18286
|
-
if (!pendingPrivyLoginRef.current || !privyReady || authenticated) return;
|
|
18287
|
-
pendingPrivyLoginRef.current = false;
|
|
18288
|
-
login();
|
|
18289
|
-
}, [authenticated, login, pendingPrivyLoginRef, privyReady]);
|
|
18290
18617
|
const startDirectFluentLogin = useCallback(async () => {
|
|
18291
|
-
|
|
18618
|
+
setLoginError(null);
|
|
18292
18619
|
const live = privySessionNow.current;
|
|
18293
18620
|
if (live.authenticated && !live.walletUserPrivySession) {
|
|
18294
18621
|
setWalletStatus("Opening Fluent Connect ID");
|
|
@@ -18304,7 +18631,7 @@ function FluentWidgetContent({
|
|
|
18304
18631
|
const message2 = error instanceof Error ? error.message : "Privy did not sign the previous session out.";
|
|
18305
18632
|
debugWarn("[fluent widget] could not sign the wallet's Privy session out", error);
|
|
18306
18633
|
setDirectAuthRequested(false);
|
|
18307
|
-
|
|
18634
|
+
setLoginError(message2);
|
|
18308
18635
|
setWalletStatus(message2);
|
|
18309
18636
|
throw error instanceof Error ? error : new Error(message2);
|
|
18310
18637
|
}
|
|
@@ -18314,27 +18641,19 @@ function FluentWidgetContent({
|
|
|
18314
18641
|
setConnectOpen(true);
|
|
18315
18642
|
}, [completeDirectAuthorization, setDirectAuthRequested]);
|
|
18316
18643
|
useEffect(() => {
|
|
18317
|
-
if (
|
|
18644
|
+
if (inlineLoginRequest <= handledInlineLoginRequest.current) return;
|
|
18318
18645
|
handledInlineLoginRequest.current = inlineLoginRequest;
|
|
18319
|
-
|
|
18646
|
+
setLoginError(null);
|
|
18320
18647
|
setDirectAuthRequested(true);
|
|
18321
18648
|
setConnectOpen(true);
|
|
18322
|
-
}, [
|
|
18649
|
+
}, [inlineLoginRequest, handledInlineLoginRequest, setDirectAuthRequested]);
|
|
18323
18650
|
const handleConnectWithX = useCallback(async () => {
|
|
18324
18651
|
await handleDisconnect({ awaitAuthSession: false });
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
return;
|
|
18328
|
-
}
|
|
18329
|
-
openConnectFlow();
|
|
18330
|
-
}, [directAuth, handleDisconnect, openConnectFlow, startDirectFluentLogin]);
|
|
18652
|
+
void startDirectFluentLogin().catch(() => void 0);
|
|
18653
|
+
}, [handleDisconnect, startDirectFluentLogin]);
|
|
18331
18654
|
const signInWithFluent = useCallback(() => {
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
return;
|
|
18335
|
-
}
|
|
18336
|
-
openConnectFlow();
|
|
18337
|
-
}, [directAuth, openConnectFlow, startDirectFluentLogin]);
|
|
18655
|
+
void startDirectFluentLogin().catch(() => void 0);
|
|
18656
|
+
}, [startDirectFluentLogin]);
|
|
18338
18657
|
const closeAccountMenu = useCallback(() => setAccountOpen(false), [setAccountOpen]);
|
|
18339
18658
|
const reviewOriginRef = useRef(null);
|
|
18340
18659
|
const openReviewPage = useCallback(() => {
|
|
@@ -18383,7 +18702,7 @@ function FluentWidgetContent({
|
|
|
18383
18702
|
selectedGasPaymentToken,
|
|
18384
18703
|
confirmBatchOperation,
|
|
18385
18704
|
defaultSponsorship: resolvedConfig.gasPayment.sponsorship,
|
|
18386
|
-
|
|
18705
|
+
quickSignWhitelist: resolvedConfig.quickSign.whitelistAddresses,
|
|
18387
18706
|
confirmSignature,
|
|
18388
18707
|
refreshBalances,
|
|
18389
18708
|
track
|
|
@@ -18442,7 +18761,6 @@ function FluentWidgetContent({
|
|
|
18442
18761
|
{
|
|
18443
18762
|
publicApiUrl: resolvedConfig.publicApiUrl,
|
|
18444
18763
|
appId: resolvedConfig.appId,
|
|
18445
|
-
authMode: resolvedConfig.authMode,
|
|
18446
18764
|
renewalOffsetSeconds: resolvedConfig.authTokenRenewalOffsetSeconds,
|
|
18447
18765
|
accountType: widgetAccount.type,
|
|
18448
18766
|
privyUserId: user?.id,
|
|
@@ -18502,7 +18820,7 @@ function FluentWidgetContent({
|
|
|
18502
18820
|
waiting.reject(error);
|
|
18503
18821
|
return true;
|
|
18504
18822
|
}, []);
|
|
18505
|
-
const { linkTwitter } =
|
|
18823
|
+
const { linkTwitter } = useLinkAccount2({
|
|
18506
18824
|
onError: (code) => {
|
|
18507
18825
|
const error = toLinkXPrivyError(code);
|
|
18508
18826
|
debugWarn("[fluent widget] linking X failed", { code, fluentCode: error.code });
|
|
@@ -18742,12 +19060,6 @@ function FluentWidgetContent({
|
|
|
18742
19060
|
[]
|
|
18743
19061
|
);
|
|
18744
19062
|
const linkX = useCallback(async () => {
|
|
18745
|
-
if (resolvedConfig.authMode !== "direct") {
|
|
18746
|
-
throw new FluentAuthError(
|
|
18747
|
-
"hosted_not_supported",
|
|
18748
|
-
`linkX() needs authMode: "direct" \u2014 in hosted mode the user's Privy session lives on the authorize page, not in this page.`
|
|
18749
|
-
);
|
|
18750
|
-
}
|
|
18751
19063
|
const storage = resolveSessionStorage();
|
|
18752
19064
|
const stored = readLinkXMarker(storage);
|
|
18753
19065
|
if (stored.kind === "invalid") {
|
|
@@ -18765,7 +19077,6 @@ function FluentWidgetContent({
|
|
|
18765
19077
|
}
|
|
18766
19078
|
const live = linkXInputs.current;
|
|
18767
19079
|
return requestLinkX({
|
|
18768
|
-
authMode: resolvedConfig.authMode,
|
|
18769
19080
|
accountKind: live.accountKind,
|
|
18770
19081
|
subject: live.privyUserId,
|
|
18771
19082
|
wallet: live.wallet,
|
|
@@ -18822,10 +19133,9 @@ function FluentWidgetContent({
|
|
|
18822
19133
|
awaitLinkXReturn,
|
|
18823
19134
|
linkTwitterForLinkX,
|
|
18824
19135
|
logoutPrivyForLinkX,
|
|
18825
|
-
resolvedConfig.authMode,
|
|
18826
19136
|
resolvedConfig.publicApiUrl
|
|
18827
19137
|
]);
|
|
18828
|
-
const sessionPrivyUserId =
|
|
19138
|
+
const sessionPrivyUserId = session?.user?.id;
|
|
18829
19139
|
const fluentIdRebuilding = Boolean(sessionPrivyUserId) && smartAccount.smartAccountEnabled && !derivedAccount.fluentAccountReady && !smartAccount.error;
|
|
18830
19140
|
const settingsAccountKind = fluentIdRebuilding ? void 0 : widgetAccount.type;
|
|
18831
19141
|
const {
|
|
@@ -18839,7 +19149,6 @@ function FluentWidgetContent({
|
|
|
18839
19149
|
state: userSettingsRef,
|
|
18840
19150
|
publicApiUrl: resolvedConfig.publicApiUrl,
|
|
18841
19151
|
appId: resolvedConfig.appId,
|
|
18842
|
-
authMode: resolvedConfig.authMode,
|
|
18843
19152
|
network: resolvedConfig.network,
|
|
18844
19153
|
accountType: settingsAccountKind,
|
|
18845
19154
|
defaultGasToken: resolvedConfig.gasPayment.defaultToken,
|
|
@@ -18883,10 +19192,34 @@ function FluentWidgetContent({
|
|
|
18883
19192
|
},
|
|
18884
19193
|
[onGasTokenChange, setGasPaymentToken]
|
|
18885
19194
|
);
|
|
19195
|
+
const { linkWithPasskey } = useLinkWithPasskey2();
|
|
19196
|
+
const addPasskey = useCallback(() => linkWithPasskey(), [linkWithPasskey]);
|
|
19197
|
+
const removePasskey = useCallback(
|
|
19198
|
+
async (credentialId) => {
|
|
19199
|
+
await unlinkPasskey(credentialId);
|
|
19200
|
+
},
|
|
19201
|
+
[unlinkPasskey]
|
|
19202
|
+
);
|
|
19203
|
+
const passkeyOffered = settingsAccountKind === "smart" && authenticated && user !== null;
|
|
19204
|
+
const passkeys = useMemo(() => {
|
|
19205
|
+
const accounts = user?.linkedAccounts ?? [];
|
|
19206
|
+
return accounts.filter((account2) => account2.type === "passkey").map((account2) => ({
|
|
19207
|
+
credentialId: account2.credentialId,
|
|
19208
|
+
label: account2.authenticatorName || [account2.createdWithBrowser, account2.createdWithOs].filter(Boolean).join(" on ") || "Passkey",
|
|
19209
|
+
addedOn: account2.firstVerifiedAt ? new Date(account2.firstVerifiedAt).toLocaleDateString(void 0, {
|
|
19210
|
+
year: "numeric",
|
|
19211
|
+
month: "short",
|
|
19212
|
+
day: "numeric"
|
|
19213
|
+
}) : void 0
|
|
19214
|
+
}));
|
|
19215
|
+
}, [user?.linkedAccounts]);
|
|
19216
|
+
const userAvatarUrl = resolvedConfig.avatar.forceDefault || accountMenuIsExternalWallet ? void 0 : getHighResTwitterAvatar(user?.twitter?.profilePictureUrl) || void 0;
|
|
19217
|
+
const defaultLogoUrl = resolvedConfig.avatar.defaultLogoUrl;
|
|
18886
19218
|
const context = useMemo(
|
|
18887
19219
|
() => ({
|
|
18888
19220
|
session,
|
|
18889
19221
|
connectedAddress,
|
|
19222
|
+
userAvatarUrl,
|
|
18890
19223
|
wallet: activeWallet,
|
|
18891
19224
|
widget: widgetApi,
|
|
18892
19225
|
openConnect,
|
|
@@ -18897,12 +19230,12 @@ function FluentWidgetContent({
|
|
|
18897
19230
|
connecting,
|
|
18898
19231
|
refreshBalances,
|
|
18899
19232
|
getAuthToken,
|
|
18900
|
-
linkX
|
|
18901
|
-
authMode: resolvedConfig.authMode
|
|
19233
|
+
linkX
|
|
18902
19234
|
}),
|
|
18903
19235
|
[
|
|
18904
19236
|
session,
|
|
18905
19237
|
connectedAddress,
|
|
19238
|
+
userAvatarUrl,
|
|
18906
19239
|
activeWallet,
|
|
18907
19240
|
widgetApi,
|
|
18908
19241
|
openConnect,
|
|
@@ -18913,12 +19246,9 @@ function FluentWidgetContent({
|
|
|
18913
19246
|
connecting,
|
|
18914
19247
|
refreshBalances,
|
|
18915
19248
|
getAuthToken,
|
|
18916
|
-
linkX
|
|
18917
|
-
resolvedConfig.authMode
|
|
19249
|
+
linkX
|
|
18918
19250
|
]
|
|
18919
19251
|
);
|
|
18920
|
-
const accountAvatarUrl = resolvedConfig.avatar.forceDefault || accountMenuIsExternalWallet ? void 0 : getHighResTwitterAvatar(user?.twitter?.profilePictureUrl);
|
|
18921
|
-
const defaultLogoUrl = resolvedConfig.avatar.defaultLogoUrl;
|
|
18922
19252
|
const widget = /* @__PURE__ */ jsxs(FluentPortalContainerProvider, { children: [
|
|
18923
19253
|
/* @__PURE__ */ jsx(FluentTopLayerBridge, {}),
|
|
18924
19254
|
!session && connectedWalletAddress !== void 0 ? /* @__PURE__ */ jsx(LinkXSiweSource, { source: linkXSiwe }) : null,
|
|
@@ -18935,7 +19265,7 @@ function FluentWidgetContent({
|
|
|
18935
19265
|
subPageTitle: subPage?.title ?? null,
|
|
18936
19266
|
subPageDismiss: subPage?.dismiss,
|
|
18937
19267
|
onCloseSubPage: closeSubPage,
|
|
18938
|
-
userLogoUrl:
|
|
19268
|
+
userLogoUrl: userAvatarUrl,
|
|
18939
19269
|
defaultLogoUrl,
|
|
18940
19270
|
connectButton: /* @__PURE__ */ jsx(
|
|
18941
19271
|
FluentConnectButtonSlot,
|
|
@@ -18950,7 +19280,7 @@ function FluentWidgetContent({
|
|
|
18950
19280
|
openAccount: openAccountMenu,
|
|
18951
19281
|
renderConnectButton,
|
|
18952
19282
|
connectButton,
|
|
18953
|
-
userLogoUrl:
|
|
19283
|
+
userLogoUrl: userAvatarUrl,
|
|
18954
19284
|
defaultLogoUrl
|
|
18955
19285
|
}
|
|
18956
19286
|
),
|
|
@@ -18997,7 +19327,10 @@ function FluentWidgetContent({
|
|
|
18997
19327
|
onMintUsdnr: mintUsdnr,
|
|
18998
19328
|
mintUsdnrBusy: mintingUsdnr,
|
|
18999
19329
|
onRevealAccount: () => setAccountOpen(true),
|
|
19000
|
-
gasContext
|
|
19330
|
+
gasContext,
|
|
19331
|
+
onAddPasskey: passkeyOffered ? addPasskey : void 0,
|
|
19332
|
+
onRemovePasskey: passkeyOffered ? removePasskey : void 0,
|
|
19333
|
+
passkeys
|
|
19001
19334
|
}
|
|
19002
19335
|
) : /* @__PURE__ */ jsx(
|
|
19003
19336
|
BridgeScreen,
|
|
@@ -19018,38 +19351,33 @@ function FluentWidgetContent({
|
|
|
19018
19351
|
session,
|
|
19019
19352
|
wallet: activeWallet,
|
|
19020
19353
|
walletStatus,
|
|
19021
|
-
|
|
19354
|
+
loginError
|
|
19022
19355
|
}
|
|
19023
19356
|
) : null,
|
|
19024
19357
|
/* @__PURE__ */ jsx(
|
|
19025
|
-
|
|
19358
|
+
InlineConnectModal,
|
|
19026
19359
|
{
|
|
19027
19360
|
open: connectOpen,
|
|
19028
19361
|
onClose: () => {
|
|
19029
19362
|
setConnectOpen(false);
|
|
19030
|
-
|
|
19363
|
+
setDirectAuthRequested(false);
|
|
19031
19364
|
},
|
|
19032
19365
|
onRetry: () => {
|
|
19033
|
-
|
|
19366
|
+
setLoginError(null);
|
|
19034
19367
|
void completeDirectAuthorization();
|
|
19035
19368
|
},
|
|
19036
19369
|
wallet: activeWallet,
|
|
19037
|
-
fluentReady: directAuth ? privyReady : true,
|
|
19038
|
-
authMode: resolvedConfig.authMode,
|
|
19039
19370
|
walletUserPrivySession,
|
|
19040
19371
|
signInRefusal: directLoginSignInRefusal,
|
|
19041
19372
|
config,
|
|
19042
|
-
|
|
19043
|
-
hostedError: hostedError ?? smartAccount.error?.message,
|
|
19373
|
+
loginError: loginError ?? smartAccount.error?.message,
|
|
19044
19374
|
track,
|
|
19045
19375
|
onExternalWalletSelected: () => {
|
|
19046
19376
|
externalWalletAnalytics.current.intent = true;
|
|
19047
19377
|
},
|
|
19048
19378
|
onFluentLogin: () => {
|
|
19049
19379
|
track("connect_login_started");
|
|
19050
|
-
|
|
19051
|
-
setWalletStatus("Opening hosted Fluent Connect ID");
|
|
19052
|
-
return void 0;
|
|
19380
|
+
return startDirectFluentLogin();
|
|
19053
19381
|
}
|
|
19054
19382
|
}
|
|
19055
19383
|
),
|
|
@@ -19069,7 +19397,7 @@ function FluentWidgetContent({
|
|
|
19069
19397
|
function LinkXSiweSource({
|
|
19070
19398
|
source
|
|
19071
19399
|
}) {
|
|
19072
|
-
const { generateSiweMessage, loginWithSiwe } =
|
|
19400
|
+
const { generateSiweMessage, loginWithSiwe } = useLoginWithSiwe2();
|
|
19073
19401
|
source.current = { generateSiweMessage, loginWithSiwe };
|
|
19074
19402
|
useEffect(
|
|
19075
19403
|
() => () => {
|
|
@@ -19093,10 +19421,8 @@ function FluentWidget(props) {
|
|
|
19093
19421
|
FLUENT_CONNECT_DEFAULT_SILENT_SIGNING
|
|
19094
19422
|
);
|
|
19095
19423
|
const silentSigningRemountTimer = useRef(null);
|
|
19096
|
-
const [privyEpoch, setPrivyEpoch] = useState(0);
|
|
19097
19424
|
const [inlineLoginRequest, setInlineLoginRequest] = useState(0);
|
|
19098
19425
|
const handledInlineLoginRequest = useRef(0);
|
|
19099
|
-
const pendingPrivyLoginRef = useRef(false);
|
|
19100
19426
|
const [accountOpen, setAccountOpen] = useState(false);
|
|
19101
19427
|
const [walletMenuTab, setWalletMenuTab] = useState("home");
|
|
19102
19428
|
const [gasPaymentToken, setGasPaymentToken] = useState(
|
|
@@ -19199,8 +19525,9 @@ function FluentWidget(props) {
|
|
|
19199
19525
|
}, [flushTabViewOnUnload, pauseTabView, resumeTabView]);
|
|
19200
19526
|
const privyConfig = useMemo(
|
|
19201
19527
|
() => ({
|
|
19202
|
-
//
|
|
19203
|
-
|
|
19528
|
+
// The in-page sign-in dialog owns its captcha. Privy still owns MFA, recovery
|
|
19529
|
+
// and signing UI.
|
|
19530
|
+
headless: true,
|
|
19204
19531
|
...createFluentConnectPrivyConfig({
|
|
19205
19532
|
network: resolvedNetwork,
|
|
19206
19533
|
logo: props.config?.assets?.fluentLogo ?? FLUENT_CONNECT_DEFAULT_ASSETS.fluentLogo,
|
|
@@ -19209,14 +19536,13 @@ function FluentWidget(props) {
|
|
|
19209
19536
|
}),
|
|
19210
19537
|
[
|
|
19211
19538
|
props.config?.assets?.fluentLogo,
|
|
19212
|
-
resolvedConfig.authMode,
|
|
19213
19539
|
resolvedConfig.customOAuthRedirectUrl,
|
|
19214
19540
|
resolvedNetwork
|
|
19215
19541
|
]
|
|
19216
19542
|
);
|
|
19217
19543
|
useLayoutEffect(() => {
|
|
19218
19544
|
clearPrivyRecentLoginMethod(FLUENT_CONNECT_PRIVY_APP_ID);
|
|
19219
|
-
}, [
|
|
19545
|
+
}, []);
|
|
19220
19546
|
const applySilentSigningEnabled = useCallback((enabled) => {
|
|
19221
19547
|
setSilentSigningEnabled(enabled);
|
|
19222
19548
|
}, []);
|
|
@@ -19246,13 +19572,8 @@ function FluentWidget(props) {
|
|
|
19246
19572
|
);
|
|
19247
19573
|
const requestPrivyLogin = useCallback(() => {
|
|
19248
19574
|
clearPrivyRecentLoginMethod(FLUENT_CONNECT_PRIVY_APP_ID);
|
|
19249
|
-
|
|
19250
|
-
|
|
19251
|
-
return;
|
|
19252
|
-
}
|
|
19253
|
-
pendingPrivyLoginRef.current = true;
|
|
19254
|
-
setPrivyEpoch((value) => value + 1);
|
|
19255
|
-
}, [resolvedConfig.authMode]);
|
|
19575
|
+
setInlineLoginRequest((value) => value + 1);
|
|
19576
|
+
}, []);
|
|
19256
19577
|
useEffect(() => {
|
|
19257
19578
|
return () => {
|
|
19258
19579
|
if (silentSigningRemountTimer.current) {
|
|
@@ -19268,8 +19589,9 @@ function FluentWidget(props) {
|
|
|
19268
19589
|
disableAnalytics: resolvedConfig.disableAnalytics,
|
|
19269
19590
|
reconnectOnMount: resolvedConfig.reconnectOnMount,
|
|
19270
19591
|
children: /* @__PURE__ */ jsx(
|
|
19271
|
-
|
|
19592
|
+
FluentPrivyProvider,
|
|
19272
19593
|
{
|
|
19594
|
+
adapter: props.privyAdapter,
|
|
19273
19595
|
appId: FLUENT_CONNECT_PRIVY_APP_ID,
|
|
19274
19596
|
clientId: privyClientId,
|
|
19275
19597
|
config: privyConfig,
|
|
@@ -19293,19 +19615,18 @@ function FluentWidget(props) {
|
|
|
19293
19615
|
requestPrivyLogin,
|
|
19294
19616
|
inlineLoginRequest,
|
|
19295
19617
|
handledInlineLoginRequest,
|
|
19296
|
-
pendingPrivyLoginRef,
|
|
19297
19618
|
authTokenState,
|
|
19298
19619
|
userSettingsRef: userSettings,
|
|
19299
19620
|
connectedPresentation
|
|
19300
19621
|
}
|
|
19301
19622
|
)
|
|
19302
19623
|
},
|
|
19303
|
-
|
|
19624
|
+
resolvedNetwork
|
|
19304
19625
|
)
|
|
19305
19626
|
}
|
|
19306
19627
|
) });
|
|
19307
19628
|
}
|
|
19308
19629
|
|
|
19309
|
-
export { AccountAvatar, 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_DEFAULT_GAS_TOKEN, FLUENT_WIDGET_SESSION_STORAGE_KEY, FLUENT_WIDGET_USER_TOKENS_IMPORT_MARKER_KEY, FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY, FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY, FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT, FluentAccountDrawer, FluentAuthError, FluentIframeRpcError, FluentPortalContainerProvider, FluentReviewRejectedError, FluentSettingsError, FluentSponsorshipFallbackError, FluentWidget, FluentWidgetConnectButton, FluentWidgetNetworkProvider, Icon, Label, Separator, Switch, WIDGET_STYLE_SCOPE, WalletMenuActionCard, buildFluentTransferCall, buttonVariants, checkFluentTransferFee, clearPrivyRecentLoginMethod, createFluentBackendUserTokenStore, createFluentBatchOp, createFluentClient, createFluentFamiliesClient, createFluentIframeBridge, createFluentIframeRpcHandler, createFluentPermissionApi, createFluentPermissionClient, createFluentPermissionPolicyBuilders, createFluentPermissionSession, createFluentSettingsClient, createFluentSponsorshipRpcUrl, createFluentUserTokenStore, createFluentZeroDevErc20Paymaster, createFluentZeroDevErc20PaymasterApprovalCall, createFluentZeroDevErc20PaymasterClient, createFluentZeroDevErc20PaymasterRpcUrl, createFluentZeroDevPermissionSession, createFluentZeroDevRpcUrl, createFluentZeroDevSponsoredPaymaster, deriveFluentGasEthRates, findFluentSymbolCollisions, fluent2 as fluent, apps as fluentApps, fluentBridgeAbi, fluent as fluentChain, fluentChains, fluentDefinitionToViemChain, integrations as fluentIntegrations, l1Chains as fluentL1Chains, fluentMainnet, fluentMainnetTokenDefaults, fluentTestnet, fluentTestnetTokenDefaults, fluentTokenIdentity, fluentTransferAbi, 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, parseFluentTransferAmount, parseFluentTransferRecipient, readFluentTokenBalances, readFluentTokenMetadata, registryVersion, resolveBridgeAddresses, resolveDefaultGasToken, resolveFluentWidgetNetworkFromEnv, resolveFluentZeroDevErc20PaymasterToken, resolveL1Definition, selectFluentGasPaymentToken, sendFluentZeroDevErc20PaymasterDemo, sortFluentGasTokens, useFluentIframeBridge, useFluentUserTokens, useFluentWidget, useFluentWidgetNetwork, useFluentZeroDevAccount, useLinkX, useWidget, withFluentSignaturePrompt };
|
|
19630
|
+
export { AccountAvatar, 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_DEFAULT_GAS_TOKEN, FLUENT_WIDGET_SESSION_STORAGE_KEY, FLUENT_WIDGET_USER_TOKENS_IMPORT_MARKER_KEY, FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY, FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY, FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT, FluentAccountDrawer, FluentAuthError, FluentIframeRpcError, FluentPortalContainerProvider, FluentReviewRejectedError, FluentSettingsError, FluentSponsorshipFallbackError, FluentUserOperationGasError, FluentWidget, FluentWidgetConfigError, FluentWidgetConnectButton, FluentWidgetNetworkProvider, Icon, Label, Separator, Switch, WIDGET_STYLE_SCOPE, WalletMenuActionCard, buildFluentTransferCall, buttonVariants, checkFluentTransferFee, clearPrivyRecentLoginMethod, createFluentBackendUserTokenStore, createFluentBatchOp, createFluentClient, createFluentFamiliesClient, createFluentIframeBridge, createFluentIframeRpcHandler, createFluentPermissionApi, createFluentPermissionClient, createFluentPermissionPolicyBuilders, createFluentPermissionSession, createFluentSettingsClient, createFluentSponsorshipRpcUrl, createFluentUserTokenStore, createFluentZeroDevErc20Paymaster, createFluentZeroDevErc20PaymasterApprovalCall, createFluentZeroDevErc20PaymasterClient, createFluentZeroDevErc20PaymasterRpcUrl, createFluentZeroDevPermissionSession, createFluentZeroDevRpcUrl, createFluentZeroDevSponsoredPaymaster, deriveFluentGasEthRates, findFluentSymbolCollisions, fluent2 as fluent, apps as fluentApps, fluentBridgeAbi, fluent as fluentChain, fluentChains, fluentDefinitionToViemChain, integrations as fluentIntegrations, l1Chains as fluentL1Chains, fluentMainnet, fluentMainnetTokenDefaults, fluentTestnet, fluentTestnetTokenDefaults, fluentTokenIdentity, fluentTransferAbi, 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, parseFluentTransferAmount, parseFluentTransferRecipient, readFluentTokenBalances, readFluentTokenMetadata, registryVersion, resolveBridgeAddresses, resolveDefaultGasToken, resolveFluentWidgetNetworkFromEnv, resolveFluentZeroDevErc20PaymasterToken, resolveL1Definition, selectFluentGasPaymentToken, sendFluentZeroDevErc20PaymasterDemo, sortFluentGasTokens, useFluentIframeBridge, useFluentUserTokens, useFluentWidget, useFluentWidgetNetwork, useFluentZeroDevAccount, useLinkX, useWidget, withFluentSignaturePrompt };
|
|
19310
19631
|
//# sourceMappingURL=index.js.map
|
|
19311
19632
|
//# sourceMappingURL=index.js.map
|