@fluent.xyz/connect 0.6.2-rc.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +33 -16
- package/dist/index.js.map +1 -1
- package/docs/getting-started.md +7 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5612,7 +5612,7 @@ function createFluentConnectForWidget(config) {
|
|
|
5612
5612
|
}
|
|
5613
5613
|
|
|
5614
5614
|
// package.json
|
|
5615
|
-
var version = "0.6.2
|
|
5615
|
+
var version = "0.6.2";
|
|
5616
5616
|
|
|
5617
5617
|
// src/core/analytics.ts
|
|
5618
5618
|
var INSTANCE_NAME = "fluent";
|
|
@@ -7053,6 +7053,7 @@ function InlineConnectModal(props) {
|
|
|
7053
7053
|
onClose,
|
|
7054
7054
|
onFluentLogin,
|
|
7055
7055
|
onRetry,
|
|
7056
|
+
onSignerCreationError,
|
|
7056
7057
|
loginError,
|
|
7057
7058
|
wallet,
|
|
7058
7059
|
track,
|
|
@@ -7093,7 +7094,16 @@ function InlineConnectModal(props) {
|
|
|
7093
7094
|
const operation = React.useRef(null);
|
|
7094
7095
|
const generation = React.useRef(0);
|
|
7095
7096
|
const attemptedWallet = React.useRef(null);
|
|
7096
|
-
const
|
|
7097
|
+
const [signerError, setSignerError] = React.useState(null);
|
|
7098
|
+
const signerUserId = authenticated && !walletUserPrivySession ? user?.id : void 0;
|
|
7099
|
+
if (attemptedWallet.current?.userId !== signerUserId) attemptedWallet.current = null;
|
|
7100
|
+
const mounted = React.useRef(false);
|
|
7101
|
+
React.useEffect(() => {
|
|
7102
|
+
mounted.current = true;
|
|
7103
|
+
return () => {
|
|
7104
|
+
mounted.current = false;
|
|
7105
|
+
};
|
|
7106
|
+
}, []);
|
|
7097
7107
|
const fluentChosen = React.useRef(false);
|
|
7098
7108
|
const fluentGate = React.useRef(void 0);
|
|
7099
7109
|
const heading = React.useRef(null);
|
|
@@ -7101,9 +7111,9 @@ function InlineConnectModal(props) {
|
|
|
7101
7111
|
const walletList = React.useRef(null);
|
|
7102
7112
|
const active = React.useRef(open);
|
|
7103
7113
|
active.current = open;
|
|
7104
|
-
const connecting = step !== "choice"
|
|
7114
|
+
const connecting = authenticated && (step !== "choice" || !walletUserPrivySession);
|
|
7105
7115
|
const screen = connecting ? "connecting" : step;
|
|
7106
|
-
const shownError = error || captchaError || (connecting ? signInRefusal || loginError : "");
|
|
7116
|
+
const shownError = error || captchaError || (signerError?.attempt === attemptedWallet.current ? signerError?.message : "") || (connecting ? signInRefusal || loginError : "");
|
|
7107
7117
|
React.useEffect(() => {
|
|
7108
7118
|
if (!open || !shownError) return;
|
|
7109
7119
|
const id = toast.add({ type: "error", title: shownError });
|
|
@@ -7162,31 +7172,34 @@ function InlineConnectModal(props) {
|
|
|
7162
7172
|
return () => clearTimeout(timer);
|
|
7163
7173
|
}, [open, connecting, step, walletAttempt]);
|
|
7164
7174
|
React.useEffect(() => {
|
|
7165
|
-
if (!
|
|
7175
|
+
if (!ready || !authenticated || !walletsReady || !user?.id || walletUserPrivySession) return;
|
|
7166
7176
|
clearInlineOAuth();
|
|
7167
7177
|
const embedded = (account) => account.walletClientType === "privy" && (!account.chainType || account.chainType === "ethereum");
|
|
7168
7178
|
if (wallets.some(embedded) || user.linkedAccounts?.some(
|
|
7169
7179
|
(account) => account.type === "wallet" && embedded(account)
|
|
7170
7180
|
))
|
|
7171
7181
|
return;
|
|
7172
|
-
if (attemptedWallet.current === user.id) return;
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7182
|
+
if (attemptedWallet.current?.userId === user.id) return;
|
|
7183
|
+
const attempt = { userId: user.id, failed: false };
|
|
7184
|
+
attemptedWallet.current = attempt;
|
|
7185
|
+
setSignerError(null);
|
|
7176
7186
|
void createWallet().catch((failure) => {
|
|
7177
|
-
if (
|
|
7178
|
-
|
|
7179
|
-
|
|
7187
|
+
if (!mounted.current || attemptedWallet.current !== attempt) return;
|
|
7188
|
+
attempt.failed = true;
|
|
7189
|
+
const detail = message(failure);
|
|
7190
|
+
setSignerError({ attempt, message: detail });
|
|
7191
|
+
onSignerCreationError?.();
|
|
7180
7192
|
});
|
|
7181
7193
|
}, [
|
|
7182
|
-
|
|
7183
|
-
|
|
7194
|
+
ready,
|
|
7195
|
+
authenticated,
|
|
7184
7196
|
walletsReady,
|
|
7185
7197
|
wallets,
|
|
7186
7198
|
user,
|
|
7187
7199
|
createWallet,
|
|
7188
7200
|
walletAttempt,
|
|
7189
|
-
walletUserPrivySession
|
|
7201
|
+
walletUserPrivySession,
|
|
7202
|
+
onSignerCreationError
|
|
7190
7203
|
]);
|
|
7191
7204
|
const run = async (action, needsPrivy = true) => {
|
|
7192
7205
|
if (operation.current || needsPrivy && !ready) return;
|
|
@@ -7342,7 +7355,7 @@ function InlineConnectModal(props) {
|
|
|
7342
7355
|
setStep("choice");
|
|
7343
7356
|
return;
|
|
7344
7357
|
}
|
|
7345
|
-
if (
|
|
7358
|
+
if (attemptedWallet.current?.failed) attemptedWallet.current = null;
|
|
7346
7359
|
setWalletAttempt((value) => value + 1);
|
|
7347
7360
|
onRetry?.();
|
|
7348
7361
|
};
|
|
@@ -20293,6 +20306,7 @@ function FluentWidgetContent({
|
|
|
20293
20306
|
if (!authenticated || !user?.id || directAuthInFlight.current) return;
|
|
20294
20307
|
if (disconnectingRef.current) return;
|
|
20295
20308
|
if (walletUserPrivySession) return;
|
|
20309
|
+
if (!privyReady || embeddedWalletCount === 0) return;
|
|
20296
20310
|
if (session && !directAuthRequested.current && session.user?.id === user.id) return;
|
|
20297
20311
|
if (!identityToken) {
|
|
20298
20312
|
setWalletStatus("Waiting for Privy identity token");
|
|
@@ -20342,6 +20356,8 @@ function FluentWidgetContent({
|
|
|
20342
20356
|
}
|
|
20343
20357
|
}, [
|
|
20344
20358
|
authenticated,
|
|
20359
|
+
privyReady,
|
|
20360
|
+
embeddedWalletCount,
|
|
20345
20361
|
fluentConnect,
|
|
20346
20362
|
identityToken,
|
|
20347
20363
|
resolvedConfig.scopes,
|
|
@@ -21177,6 +21193,7 @@ function FluentWidgetContent({
|
|
|
21177
21193
|
InlineConnectModal,
|
|
21178
21194
|
{
|
|
21179
21195
|
open: connectOpen,
|
|
21196
|
+
onSignerCreationError: () => setConnectOpen(true),
|
|
21180
21197
|
onClose: () => {
|
|
21181
21198
|
setConnectOpen(false);
|
|
21182
21199
|
setDirectAuthRequested(false);
|