@swype-org/react-sdk 0.1.226 → 0.1.228
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.cjs +591 -672
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +591 -673
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1935,9 +1935,7 @@ function deriveSourceTypeAndId(state) {
|
|
|
1935
1935
|
return { sourceType: "accountId", sourceId: "" };
|
|
1936
1936
|
}
|
|
1937
1937
|
function createInitialState(config) {
|
|
1938
|
-
const isReturningUser = config.activeCredentialId != null;
|
|
1939
1938
|
return {
|
|
1940
|
-
step: isReturningUser ? "login" : "wallet-picker",
|
|
1941
1939
|
error: null,
|
|
1942
1940
|
providers: [],
|
|
1943
1941
|
accounts: [],
|
|
@@ -1953,6 +1951,7 @@ function createInitialState(config) {
|
|
|
1953
1951
|
registeringPasskey: false,
|
|
1954
1952
|
verifyingPasskeyPopup: false,
|
|
1955
1953
|
passkeyPopupNeeded: config.passkeyPopupNeeded,
|
|
1954
|
+
passkeyConfigLoaded: false,
|
|
1956
1955
|
activeCredentialId: config.activeCredentialId,
|
|
1957
1956
|
knownCredentialIds: [],
|
|
1958
1957
|
verificationTarget: null,
|
|
@@ -1960,12 +1959,13 @@ function createInitialState(config) {
|
|
|
1960
1959
|
mobileFlow: false,
|
|
1961
1960
|
deeplinkUri: null,
|
|
1962
1961
|
increasingLimit: false,
|
|
1963
|
-
previousStep: null,
|
|
1964
1962
|
isGuestFlow: false,
|
|
1965
1963
|
guestTransferId: null,
|
|
1966
1964
|
guestSessionToken: null,
|
|
1967
1965
|
guestPreauthAccountId: null,
|
|
1968
|
-
activePublicKey: null
|
|
1966
|
+
activePublicKey: null,
|
|
1967
|
+
userIntent: null,
|
|
1968
|
+
loginRequested: false
|
|
1969
1969
|
};
|
|
1970
1970
|
}
|
|
1971
1971
|
function paymentReducer(state, action) {
|
|
@@ -1976,20 +1976,20 @@ function paymentReducer(state, action) {
|
|
|
1976
1976
|
...state,
|
|
1977
1977
|
verificationTarget: action.target,
|
|
1978
1978
|
error: null,
|
|
1979
|
-
|
|
1979
|
+
loginRequested: false
|
|
1980
1980
|
};
|
|
1981
1981
|
case "BACK_TO_LOGIN":
|
|
1982
1982
|
return {
|
|
1983
1983
|
...state,
|
|
1984
1984
|
verificationTarget: null,
|
|
1985
|
-
error: null
|
|
1986
|
-
step: "login"
|
|
1985
|
+
error: null
|
|
1987
1986
|
};
|
|
1988
1987
|
// ── Passkey ──────────────────────────────────────────────────
|
|
1989
1988
|
case "PASSKEY_CONFIG_LOADED":
|
|
1990
1989
|
return {
|
|
1991
1990
|
...state,
|
|
1992
1991
|
knownCredentialIds: action.knownIds,
|
|
1992
|
+
passkeyConfigLoaded: true,
|
|
1993
1993
|
oneTapLimit: action.oneTapLimit ?? state.oneTapLimit
|
|
1994
1994
|
};
|
|
1995
1995
|
case "PASSKEY_ACTIVATED":
|
|
@@ -2023,9 +2023,6 @@ function paymentReducer(state, action) {
|
|
|
2023
2023
|
next.mobileFlow = false;
|
|
2024
2024
|
next.deeplinkUri = null;
|
|
2025
2025
|
}
|
|
2026
|
-
if (action.resolvedStep !== void 0) {
|
|
2027
|
-
next.step = action.resolvedStep;
|
|
2028
|
-
}
|
|
2029
2026
|
return next;
|
|
2030
2027
|
}
|
|
2031
2028
|
case "DATA_LOAD_END":
|
|
@@ -2049,7 +2046,8 @@ function paymentReducer(state, action) {
|
|
|
2049
2046
|
selectedProviderId: action.providerId,
|
|
2050
2047
|
selectedAccountId: null,
|
|
2051
2048
|
selectedWalletId: null,
|
|
2052
|
-
selectedTokenSymbol: null
|
|
2049
|
+
selectedTokenSymbol: null,
|
|
2050
|
+
userIntent: null
|
|
2053
2051
|
};
|
|
2054
2052
|
case "SELECT_ACCOUNT":
|
|
2055
2053
|
return {
|
|
@@ -2057,24 +2055,24 @@ function paymentReducer(state, action) {
|
|
|
2057
2055
|
selectedAccountId: action.accountId,
|
|
2058
2056
|
selectedWalletId: action.walletId,
|
|
2059
2057
|
selectedTokenSymbol: null,
|
|
2060
|
-
|
|
2058
|
+
userIntent: null
|
|
2061
2059
|
};
|
|
2062
2060
|
case "SELECT_TOKEN":
|
|
2063
2061
|
return {
|
|
2064
2062
|
...state,
|
|
2065
2063
|
selectedWalletId: action.walletId,
|
|
2066
2064
|
selectedTokenSymbol: action.tokenSymbol,
|
|
2067
|
-
|
|
2065
|
+
userIntent: null
|
|
2068
2066
|
};
|
|
2069
2067
|
// ── Transfer lifecycle ───────────────────────────────────────
|
|
2070
2068
|
case "PAY_STARTED":
|
|
2071
2069
|
return {
|
|
2072
2070
|
...state,
|
|
2073
|
-
step: action.isSetupRedirect ? "open-wallet" : "processing",
|
|
2074
2071
|
error: null,
|
|
2075
2072
|
creatingTransfer: true,
|
|
2076
2073
|
deeplinkUri: null,
|
|
2077
|
-
mobileFlow: false
|
|
2074
|
+
mobileFlow: false,
|
|
2075
|
+
userIntent: null
|
|
2078
2076
|
};
|
|
2079
2077
|
case "PAY_ENDED":
|
|
2080
2078
|
return { ...state, creatingTransfer: false };
|
|
@@ -2082,7 +2080,7 @@ function paymentReducer(state, action) {
|
|
|
2082
2080
|
return {
|
|
2083
2081
|
...state,
|
|
2084
2082
|
error: action.error,
|
|
2085
|
-
|
|
2083
|
+
creatingTransfer: false
|
|
2086
2084
|
};
|
|
2087
2085
|
case "TRANSFER_CREATED":
|
|
2088
2086
|
return { ...state, transfer: action.transfer };
|
|
@@ -2092,7 +2090,6 @@ function paymentReducer(state, action) {
|
|
|
2092
2090
|
return {
|
|
2093
2091
|
...state,
|
|
2094
2092
|
transfer: action.transfer,
|
|
2095
|
-
step: "success",
|
|
2096
2093
|
mobileFlow: false,
|
|
2097
2094
|
deeplinkUri: null
|
|
2098
2095
|
};
|
|
@@ -2101,17 +2098,20 @@ function paymentReducer(state, action) {
|
|
|
2101
2098
|
...state,
|
|
2102
2099
|
transfer: action.transfer,
|
|
2103
2100
|
error: action.error,
|
|
2104
|
-
step: "success",
|
|
2105
2101
|
mobileFlow: false,
|
|
2106
2102
|
deeplinkUri: null
|
|
2107
2103
|
};
|
|
2108
2104
|
case "PROCESSING_TIMEOUT":
|
|
2109
|
-
return {
|
|
2105
|
+
return {
|
|
2106
|
+
...state,
|
|
2107
|
+
error: action.error,
|
|
2108
|
+
transfer: null,
|
|
2109
|
+
creatingTransfer: false
|
|
2110
|
+
};
|
|
2110
2111
|
case "CONFIRM_SIGN_SUCCESS":
|
|
2111
2112
|
return {
|
|
2112
2113
|
...state,
|
|
2113
2114
|
transfer: action.transfer,
|
|
2114
|
-
step: "processing",
|
|
2115
2115
|
mobileFlow: false,
|
|
2116
2116
|
deeplinkUri: null
|
|
2117
2117
|
};
|
|
@@ -2120,8 +2120,7 @@ function paymentReducer(state, action) {
|
|
|
2120
2120
|
return {
|
|
2121
2121
|
...state,
|
|
2122
2122
|
mobileFlow: true,
|
|
2123
|
-
deeplinkUri: action.deeplinkUri
|
|
2124
|
-
step: "open-wallet"
|
|
2123
|
+
deeplinkUri: action.deeplinkUri
|
|
2125
2124
|
};
|
|
2126
2125
|
case "MOBILE_SETUP_COMPLETE":
|
|
2127
2126
|
return {
|
|
@@ -2129,8 +2128,7 @@ function paymentReducer(state, action) {
|
|
|
2129
2128
|
transfer: action.transfer ?? state.transfer,
|
|
2130
2129
|
error: null,
|
|
2131
2130
|
mobileFlow: false,
|
|
2132
|
-
deeplinkUri: null
|
|
2133
|
-
step: "deposit"
|
|
2131
|
+
deeplinkUri: null
|
|
2134
2132
|
};
|
|
2135
2133
|
case "MOBILE_SIGN_READY":
|
|
2136
2134
|
return {
|
|
@@ -2138,8 +2136,7 @@ function paymentReducer(state, action) {
|
|
|
2138
2136
|
transfer: action.transfer,
|
|
2139
2137
|
error: null,
|
|
2140
2138
|
mobileFlow: false,
|
|
2141
|
-
deeplinkUri: null
|
|
2142
|
-
step: "confirm-sign"
|
|
2139
|
+
deeplinkUri: null
|
|
2143
2140
|
};
|
|
2144
2141
|
case "CLEAR_MOBILE_STATE":
|
|
2145
2142
|
return { ...state, mobileFlow: false, deeplinkUri: null };
|
|
@@ -2149,8 +2146,7 @@ function paymentReducer(state, action) {
|
|
|
2149
2146
|
mobileFlow: true,
|
|
2150
2147
|
deeplinkUri: action.deeplinkUri,
|
|
2151
2148
|
selectedProviderId: action.providerId ?? state.selectedProviderId,
|
|
2152
|
-
error: action.error ?? null
|
|
2153
|
-
step: "open-wallet"
|
|
2149
|
+
error: action.error ?? null
|
|
2154
2150
|
};
|
|
2155
2151
|
case "MOBILE_RESUME_SUCCESS":
|
|
2156
2152
|
return {
|
|
@@ -2158,8 +2154,7 @@ function paymentReducer(state, action) {
|
|
|
2158
2154
|
transfer: action.transfer,
|
|
2159
2155
|
error: null,
|
|
2160
2156
|
mobileFlow: false,
|
|
2161
|
-
deeplinkUri: null
|
|
2162
|
-
step: "success"
|
|
2157
|
+
deeplinkUri: null
|
|
2163
2158
|
};
|
|
2164
2159
|
case "MOBILE_RESUME_FAILED":
|
|
2165
2160
|
return {
|
|
@@ -2167,8 +2162,7 @@ function paymentReducer(state, action) {
|
|
|
2167
2162
|
transfer: action.transfer,
|
|
2168
2163
|
error: "Transfer failed.",
|
|
2169
2164
|
mobileFlow: false,
|
|
2170
|
-
deeplinkUri: null
|
|
2171
|
-
step: "success"
|
|
2165
|
+
deeplinkUri: null
|
|
2172
2166
|
};
|
|
2173
2167
|
case "MOBILE_RESUME_PROCESSING":
|
|
2174
2168
|
return {
|
|
@@ -2176,8 +2170,7 @@ function paymentReducer(state, action) {
|
|
|
2176
2170
|
transfer: action.transfer,
|
|
2177
2171
|
error: null,
|
|
2178
2172
|
mobileFlow: false,
|
|
2179
|
-
deeplinkUri: null
|
|
2180
|
-
step: "processing"
|
|
2173
|
+
deeplinkUri: null
|
|
2181
2174
|
};
|
|
2182
2175
|
// ── Increase limit ───────────────────────────────────────────
|
|
2183
2176
|
case "SET_INCREASING_LIMIT":
|
|
@@ -2199,14 +2192,12 @@ function paymentReducer(state, action) {
|
|
|
2199
2192
|
guestSessionToken: action.guestSessionToken,
|
|
2200
2193
|
selectedAccountId: null,
|
|
2201
2194
|
selectedWalletId: null,
|
|
2202
|
-
selectedTokenSymbol: null
|
|
2203
|
-
step: "token-picker"
|
|
2195
|
+
selectedTokenSymbol: null
|
|
2204
2196
|
};
|
|
2205
2197
|
case "GUEST_TRANSFER_COMPLETED":
|
|
2206
2198
|
return {
|
|
2207
2199
|
...state,
|
|
2208
2200
|
transfer: action.transfer,
|
|
2209
|
-
step: "success",
|
|
2210
2201
|
mobileFlow: false,
|
|
2211
2202
|
deeplinkUri: null,
|
|
2212
2203
|
isGuestFlow: true,
|
|
@@ -2215,27 +2206,32 @@ function paymentReducer(state, action) {
|
|
|
2215
2206
|
case "GUEST_PREAUTH_DETECTED":
|
|
2216
2207
|
return {
|
|
2217
2208
|
...state,
|
|
2218
|
-
guestPreauthAccountId: action.accountId
|
|
2219
|
-
step: "login"
|
|
2209
|
+
guestPreauthAccountId: action.accountId
|
|
2220
2210
|
};
|
|
2221
2211
|
case "ACCOUNT_OWNER_SET":
|
|
2222
2212
|
return {
|
|
2223
2213
|
...state,
|
|
2224
2214
|
guestPreauthAccountId: null,
|
|
2225
2215
|
activePublicKey: null,
|
|
2226
|
-
step: "deposit",
|
|
2227
2216
|
error: null
|
|
2228
2217
|
};
|
|
2229
|
-
// ──
|
|
2230
|
-
case "
|
|
2231
|
-
return { ...state,
|
|
2218
|
+
// ── User intent & error ──────────────────────────────────────
|
|
2219
|
+
case "SET_USER_INTENT":
|
|
2220
|
+
return { ...state, userIntent: action.intent };
|
|
2221
|
+
case "REQUEST_LOGIN":
|
|
2222
|
+
return {
|
|
2223
|
+
...state,
|
|
2224
|
+
loginRequested: true,
|
|
2225
|
+
transfer: null,
|
|
2226
|
+
isGuestFlow: false,
|
|
2227
|
+
creatingTransfer: false
|
|
2228
|
+
};
|
|
2232
2229
|
case "SET_ERROR":
|
|
2233
2230
|
return { ...state, error: action.error };
|
|
2234
2231
|
// ── Lifecycle ────────────────────────────────────────────────
|
|
2235
2232
|
case "NEW_PAYMENT":
|
|
2236
2233
|
return {
|
|
2237
2234
|
...state,
|
|
2238
|
-
step: state.isGuestFlow ? "wallet-picker" : "deposit",
|
|
2239
2235
|
transfer: null,
|
|
2240
2236
|
error: null,
|
|
2241
2237
|
amount: action.depositAmount != null ? action.depositAmount.toString() : "",
|
|
@@ -2248,7 +2244,9 @@ function paymentReducer(state, action) {
|
|
|
2248
2244
|
guestTransferId: null,
|
|
2249
2245
|
guestSessionToken: null,
|
|
2250
2246
|
guestPreauthAccountId: null,
|
|
2251
|
-
activePublicKey: null
|
|
2247
|
+
activePublicKey: null,
|
|
2248
|
+
userIntent: null,
|
|
2249
|
+
loginRequested: false
|
|
2252
2250
|
};
|
|
2253
2251
|
case "LOGOUT":
|
|
2254
2252
|
return {
|
|
@@ -2316,6 +2314,87 @@ function isMobileUserAgent(userAgent) {
|
|
|
2316
2314
|
function shouldUseWalletConnector(options) {
|
|
2317
2315
|
return options.useWalletConnector ?? !isMobileUserAgent(options.userAgent);
|
|
2318
2316
|
}
|
|
2317
|
+
|
|
2318
|
+
// src/resolveScreen.ts
|
|
2319
|
+
function hasActiveWallet(accounts) {
|
|
2320
|
+
return accounts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
|
|
2321
|
+
}
|
|
2322
|
+
function isTransferTerminal(transfer) {
|
|
2323
|
+
return transfer?.status === "COMPLETED" || transfer?.status === "FAILED";
|
|
2324
|
+
}
|
|
2325
|
+
function isTransferInFlight(transfer) {
|
|
2326
|
+
if (!transfer) return false;
|
|
2327
|
+
return ["CREATED", "SENDING", "SENT"].includes(transfer.status);
|
|
2328
|
+
}
|
|
2329
|
+
function isSetupTransfer(transfer) {
|
|
2330
|
+
if (!transfer) return false;
|
|
2331
|
+
return transfer.sources?.some(
|
|
2332
|
+
(s) => s.wallets && Array.isArray(s.wallets) && s.wallets.length === 0
|
|
2333
|
+
) ?? false;
|
|
2334
|
+
}
|
|
2335
|
+
function resolveScreen(state) {
|
|
2336
|
+
if (!state.privyReady) {
|
|
2337
|
+
return "loading";
|
|
2338
|
+
}
|
|
2339
|
+
if (state.authenticated && !state.activeCredentialId && !state.passkeyConfigLoaded) {
|
|
2340
|
+
return "loading";
|
|
2341
|
+
}
|
|
2342
|
+
if (!state.authenticated && !state.verificationTarget && !state.isGuestFlow && (state.isReturningUser || state.guestPreauthRedirect || state.loginRequested)) {
|
|
2343
|
+
return "login";
|
|
2344
|
+
}
|
|
2345
|
+
if (!state.authenticated && state.verificationTarget != null) {
|
|
2346
|
+
return "otp-verify";
|
|
2347
|
+
}
|
|
2348
|
+
if (state.authenticated && !state.activeCredentialId && state.passkeyConfigLoaded && (state.knownCredentialIds.length === 0 || !state.passkeyPopupNeeded)) {
|
|
2349
|
+
return "create-passkey";
|
|
2350
|
+
}
|
|
2351
|
+
if (state.authenticated && !state.activeCredentialId && state.passkeyConfigLoaded && state.knownCredentialIds.length > 0 && state.passkeyPopupNeeded) {
|
|
2352
|
+
return "verify-passkey";
|
|
2353
|
+
}
|
|
2354
|
+
if (isTransferTerminal(state.transfer)) {
|
|
2355
|
+
return "success";
|
|
2356
|
+
}
|
|
2357
|
+
if (state.creatingTransfer || state.transfer != null && isTransferInFlight(state.transfer)) {
|
|
2358
|
+
return "processing";
|
|
2359
|
+
}
|
|
2360
|
+
if (state.transfer?.status === "AUTHORIZED" && !state.isDesktop && !isSetupTransfer(state.transfer)) {
|
|
2361
|
+
return "confirm-sign";
|
|
2362
|
+
}
|
|
2363
|
+
if (state.pendingSelectSource != null) {
|
|
2364
|
+
return state.isDesktop ? "setup" : "select-source";
|
|
2365
|
+
}
|
|
2366
|
+
if (state.pendingOneTapSetup != null && !state.oneTapLimitAlreadySaved) {
|
|
2367
|
+
return "setup";
|
|
2368
|
+
}
|
|
2369
|
+
if (state.mobileFlow || state.inlineAuthorizationExecuting) {
|
|
2370
|
+
return state.isDesktop ? "setup-status" : "open-wallet";
|
|
2371
|
+
}
|
|
2372
|
+
if (state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestSettingSender) {
|
|
2373
|
+
return "guest-token-picker";
|
|
2374
|
+
}
|
|
2375
|
+
if (state.activeCredentialId && !hasActiveWallet(state.accounts) && !state.mobileFlow || !state.authenticated && !state.isReturningUser && !state.isGuestFlow) {
|
|
2376
|
+
return "wallet-picker";
|
|
2377
|
+
}
|
|
2378
|
+
if (state.loadingData && state.activeCredentialId != null && hasActiveWallet(state.accounts)) {
|
|
2379
|
+
return "loading";
|
|
2380
|
+
}
|
|
2381
|
+
if (state.userIntent === "pick-token" && state.selectedAccount != null) {
|
|
2382
|
+
return "token-picker";
|
|
2383
|
+
}
|
|
2384
|
+
if (state.userIntent === "configure-one-tap") {
|
|
2385
|
+
return "setup";
|
|
2386
|
+
}
|
|
2387
|
+
if (state.userIntent === "switch-wallet") {
|
|
2388
|
+
return "wallet-picker";
|
|
2389
|
+
}
|
|
2390
|
+
if (state.activeCredentialId != null && hasActiveWallet(state.accounts) && !state.loadingData) {
|
|
2391
|
+
return "deposit";
|
|
2392
|
+
}
|
|
2393
|
+
if (state.isGuestFlow) {
|
|
2394
|
+
return "wallet-picker";
|
|
2395
|
+
}
|
|
2396
|
+
return "wallet-picker";
|
|
2397
|
+
}
|
|
2319
2398
|
var MUTED = "#7fa4b0";
|
|
2320
2399
|
var LOGO_SIZE = 48;
|
|
2321
2400
|
function BlinkLoadingScreen() {
|
|
@@ -5783,7 +5862,7 @@ var emptyStyle = (color) => ({
|
|
|
5783
5862
|
padding: "32px 0",
|
|
5784
5863
|
lineHeight: 1.5
|
|
5785
5864
|
});
|
|
5786
|
-
var
|
|
5865
|
+
var LINK_SCREENS = /* @__PURE__ */ new Set([
|
|
5787
5866
|
"create-passkey",
|
|
5788
5867
|
"verify-passkey",
|
|
5789
5868
|
"wallet-picker",
|
|
@@ -5792,27 +5871,57 @@ var LINK_STEPS = /* @__PURE__ */ new Set([
|
|
|
5792
5871
|
"setup",
|
|
5793
5872
|
"confirm-sign"
|
|
5794
5873
|
]);
|
|
5795
|
-
var
|
|
5874
|
+
var DEPOSIT_SCREENS = /* @__PURE__ */ new Set([
|
|
5796
5875
|
"deposit",
|
|
5797
|
-
"low-balance",
|
|
5798
5876
|
"processing",
|
|
5799
5877
|
"success"
|
|
5800
5878
|
]);
|
|
5801
|
-
function getFlowPhase(
|
|
5802
|
-
if (
|
|
5803
|
-
if (
|
|
5804
|
-
if (
|
|
5805
|
-
return
|
|
5879
|
+
function getFlowPhase(screen, userIntent) {
|
|
5880
|
+
if (LINK_SCREENS.has(screen)) return "link";
|
|
5881
|
+
if (DEPOSIT_SCREENS.has(screen)) return "deposit";
|
|
5882
|
+
if (screen === "token-picker" || screen === "select-source" || screen === "guest-token-picker") {
|
|
5883
|
+
return userIntent === "configure-one-tap" ? "link" : "deposit";
|
|
5806
5884
|
}
|
|
5807
5885
|
return null;
|
|
5808
5886
|
}
|
|
5809
5887
|
function StepRenderer(props) {
|
|
5810
|
-
const
|
|
5811
|
-
|
|
5888
|
+
const isDesktop = shouldUseWalletConnector({
|
|
5889
|
+
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
5890
|
+
});
|
|
5891
|
+
const isReturningUser = props.state.activeCredentialId != null || typeof window !== "undefined" && window.localStorage.getItem("blink_active_credential") != null;
|
|
5892
|
+
const screenState = {
|
|
5893
|
+
privyReady: props.ready,
|
|
5894
|
+
authenticated: props.authenticated,
|
|
5895
|
+
verificationTarget: props.state.verificationTarget,
|
|
5896
|
+
activeCredentialId: props.state.activeCredentialId,
|
|
5897
|
+
knownCredentialIds: props.state.knownCredentialIds,
|
|
5898
|
+
passkeyConfigLoaded: props.state.passkeyConfigLoaded,
|
|
5899
|
+
passkeyPopupNeeded: props.state.passkeyPopupNeeded,
|
|
5900
|
+
accounts: props.state.accounts,
|
|
5901
|
+
isGuestFlow: props.state.isGuestFlow,
|
|
5902
|
+
selectedProviderId: props.state.selectedProviderId,
|
|
5903
|
+
mobileFlow: props.state.mobileFlow,
|
|
5904
|
+
inlineAuthorizationExecuting: props.inlineAuthorizationExecuting,
|
|
5905
|
+
creatingTransfer: props.state.creatingTransfer,
|
|
5906
|
+
transfer: props.state.transfer,
|
|
5907
|
+
pendingSelectSource: props.pendingSelectSource,
|
|
5908
|
+
pendingOneTapSetup: props.pendingOneTapSetup,
|
|
5909
|
+
oneTapLimitAlreadySaved: props.oneTapLimitAlreadySaved,
|
|
5910
|
+
loadingData: props.state.loadingData,
|
|
5911
|
+
isDesktop,
|
|
5912
|
+
isReturningUser,
|
|
5913
|
+
guestPreauthRedirect: props.state.guestPreauthAccountId != null,
|
|
5914
|
+
loginRequested: props.state.loginRequested,
|
|
5915
|
+
userIntent: props.state.userIntent,
|
|
5916
|
+
selectedAccount: props.selectedAccount,
|
|
5917
|
+
guestSettingSender: props.guestSettingSender
|
|
5918
|
+
};
|
|
5919
|
+
const screen = resolveScreen(screenState);
|
|
5920
|
+
const phase = getFlowPhase(screen, props.state.userIntent);
|
|
5921
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FlowPhaseProvider, { phase, children: /* @__PURE__ */ jsxRuntime.jsx(StepRendererContent, { ...props, screen, isDesktop }) });
|
|
5812
5922
|
}
|
|
5813
5923
|
function StepRendererContent({
|
|
5814
5924
|
state,
|
|
5815
|
-
ready,
|
|
5816
5925
|
authenticated,
|
|
5817
5926
|
activeOtpStatus,
|
|
5818
5927
|
pollingTransfer,
|
|
@@ -5842,204 +5951,204 @@ function StepRendererContent({
|
|
|
5842
5951
|
onBack,
|
|
5843
5952
|
onDismiss,
|
|
5844
5953
|
depositAmount,
|
|
5845
|
-
handlers
|
|
5954
|
+
handlers,
|
|
5955
|
+
screen,
|
|
5956
|
+
isDesktop
|
|
5846
5957
|
}) {
|
|
5847
|
-
const { step } = state;
|
|
5848
5958
|
const selectedWallet = selectedAccount?.wallets.find((w) => w.id === state.selectedWalletId);
|
|
5849
5959
|
const selectedSourceLabel = selectedSource && selectedWallet ? `${selectedSource.token.symbol} on ${selectedWallet.chain.name}` : void 0;
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
}
|
|
5853
|
-
if (step === "login") {
|
|
5854
|
-
if (authenticated) {
|
|
5960
|
+
switch (screen) {
|
|
5961
|
+
case "loading":
|
|
5855
5962
|
return /* @__PURE__ */ jsxRuntime.jsx(BlinkLoadingScreen, {});
|
|
5963
|
+
case "login":
|
|
5964
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5965
|
+
LoginScreen,
|
|
5966
|
+
{
|
|
5967
|
+
authInput,
|
|
5968
|
+
onAuthInputChange: handlers.onSetAuthInput,
|
|
5969
|
+
onSubmit: handlers.onSendLoginCode,
|
|
5970
|
+
sending: activeOtpStatus === "sending-code",
|
|
5971
|
+
error: state.error,
|
|
5972
|
+
onBack,
|
|
5973
|
+
merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
|
|
5974
|
+
}
|
|
5975
|
+
);
|
|
5976
|
+
case "otp-verify":
|
|
5977
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5978
|
+
OtpVerifyScreen,
|
|
5979
|
+
{
|
|
5980
|
+
maskedIdentifier: state.verificationTarget ? maskAuthIdentifier(state.verificationTarget) : "",
|
|
5981
|
+
otpCode,
|
|
5982
|
+
onOtpChange: (code) => {
|
|
5983
|
+
handlers.onSetOtpCode(code);
|
|
5984
|
+
},
|
|
5985
|
+
onVerify: handlers.onVerifyLoginCode,
|
|
5986
|
+
onResend: handlers.onResendLoginCode,
|
|
5987
|
+
onBack: handlers.onBackFromOtp,
|
|
5988
|
+
verifying: activeOtpStatus === "submitting-code" || authenticated,
|
|
5989
|
+
error: state.error
|
|
5990
|
+
}
|
|
5991
|
+
);
|
|
5992
|
+
case "create-passkey":
|
|
5993
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5994
|
+
PasskeyScreen,
|
|
5995
|
+
{
|
|
5996
|
+
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5997
|
+
onBack: handlers.onLogout,
|
|
5998
|
+
onLogout: handlers.onLogout,
|
|
5999
|
+
creating: state.registeringPasskey,
|
|
6000
|
+
error: state.error,
|
|
6001
|
+
popupFallback: state.passkeyPopupNeeded,
|
|
6002
|
+
onCreatePasskeyViaPopup: handlers.onCreatePasskeyViaPopup
|
|
6003
|
+
}
|
|
6004
|
+
);
|
|
6005
|
+
case "verify-passkey":
|
|
6006
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6007
|
+
PasskeyScreen,
|
|
6008
|
+
{
|
|
6009
|
+
onCreatePasskey: handlers.onRegisterPasskey,
|
|
6010
|
+
onBack: handlers.onLogout,
|
|
6011
|
+
onLogout: handlers.onLogout,
|
|
6012
|
+
creating: state.verifyingPasskeyPopup,
|
|
6013
|
+
error: state.error,
|
|
6014
|
+
popupFallback: true,
|
|
6015
|
+
onCreatePasskeyViaPopup: handlers.onVerifyPasskeyViaPopup
|
|
6016
|
+
}
|
|
6017
|
+
);
|
|
6018
|
+
case "wallet-picker": {
|
|
6019
|
+
const isEntryPoint = !state.isGuestFlow && !authenticated;
|
|
6020
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6021
|
+
WalletPickerScreen,
|
|
6022
|
+
{
|
|
6023
|
+
providers: state.providers,
|
|
6024
|
+
pendingConnections,
|
|
6025
|
+
loading: state.creatingTransfer,
|
|
6026
|
+
useDeeplink: !isDesktop,
|
|
6027
|
+
onPrepareProvider: handlers.onPrepareProvider,
|
|
6028
|
+
onSelectProvider: handlers.onSelectProvider,
|
|
6029
|
+
onContinueConnection: handlers.onContinueConnection,
|
|
6030
|
+
onBack: isEntryPoint ? onBack : () => handlers.onSetUserIntent(null),
|
|
6031
|
+
onLogout: authenticated ? handlers.onLogout : void 0,
|
|
6032
|
+
onLogin: handlers.onLogin,
|
|
6033
|
+
showLoginOption: isEntryPoint
|
|
6034
|
+
}
|
|
6035
|
+
);
|
|
5856
6036
|
}
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
OtpVerifyScreen,
|
|
5873
|
-
{
|
|
5874
|
-
maskedIdentifier: state.verificationTarget ? maskAuthIdentifier(state.verificationTarget) : "",
|
|
5875
|
-
otpCode,
|
|
5876
|
-
onOtpChange: (code) => {
|
|
5877
|
-
handlers.onSetOtpCode(code);
|
|
5878
|
-
},
|
|
5879
|
-
onVerify: handlers.onVerifyLoginCode,
|
|
5880
|
-
onResend: handlers.onResendLoginCode,
|
|
5881
|
-
onBack: handlers.onBackFromOtp,
|
|
5882
|
-
verifying: activeOtpStatus === "submitting-code" || authenticated,
|
|
5883
|
-
error: state.error
|
|
5884
|
-
}
|
|
5885
|
-
);
|
|
5886
|
-
}
|
|
5887
|
-
if (step === "create-passkey") {
|
|
5888
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5889
|
-
PasskeyScreen,
|
|
5890
|
-
{
|
|
5891
|
-
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5892
|
-
onBack: handlers.onLogout,
|
|
5893
|
-
onLogout: handlers.onLogout,
|
|
5894
|
-
creating: state.registeringPasskey,
|
|
5895
|
-
error: state.error,
|
|
5896
|
-
popupFallback: state.passkeyPopupNeeded,
|
|
5897
|
-
onCreatePasskeyViaPopup: handlers.onCreatePasskeyViaPopup
|
|
5898
|
-
}
|
|
5899
|
-
);
|
|
5900
|
-
}
|
|
5901
|
-
if (step === "verify-passkey") {
|
|
5902
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5903
|
-
PasskeyScreen,
|
|
5904
|
-
{
|
|
5905
|
-
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5906
|
-
onBack: handlers.onLogout,
|
|
5907
|
-
onLogout: handlers.onLogout,
|
|
5908
|
-
creating: state.verifyingPasskeyPopup,
|
|
5909
|
-
error: state.error,
|
|
5910
|
-
popupFallback: true,
|
|
5911
|
-
onCreatePasskeyViaPopup: handlers.onVerifyPasskeyViaPopup
|
|
5912
|
-
}
|
|
5913
|
-
);
|
|
5914
|
-
}
|
|
5915
|
-
if (step === "wallet-picker") {
|
|
5916
|
-
if (state.isGuestFlow && state.selectedProviderId && state.activeCredentialId) {
|
|
5917
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BlinkLoadingScreen, {});
|
|
6037
|
+
case "open-wallet": {
|
|
6038
|
+
const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
|
|
6039
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6040
|
+
OpenWalletScreen,
|
|
6041
|
+
{
|
|
6042
|
+
walletName: providerName,
|
|
6043
|
+
deeplinkUri: state.deeplinkUri ?? "",
|
|
6044
|
+
loading: !isDesktop ? state.creatingTransfer || !state.deeplinkUri : state.creatingTransfer,
|
|
6045
|
+
useDeeplink: !isDesktop,
|
|
6046
|
+
error: state.error || (!isDesktop ? pollingError : authExecutorError),
|
|
6047
|
+
onRetryStatus: !isDesktop ? handlers.onRetryMobileStatus : void 0,
|
|
6048
|
+
onBack: !isDesktop ? handlers.onBackFromOpenWallet : void 0,
|
|
6049
|
+
onLogout: handlers.onLogout
|
|
6050
|
+
}
|
|
6051
|
+
);
|
|
5918
6052
|
}
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
}
|
|
5956
|
-
);
|
|
5957
|
-
}
|
|
5958
|
-
if (step === "setup-status") {
|
|
5959
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5960
|
-
SetupStatusScreen,
|
|
5961
|
-
{
|
|
5962
|
-
complete: false,
|
|
5963
|
-
limit: state.oneTapLimit,
|
|
5964
|
-
tokensApproved: 0,
|
|
5965
|
-
merchantName,
|
|
5966
|
-
onContinue: () => handlers.onNavigate("setup"),
|
|
5967
|
-
onLogout: handlers.onLogout,
|
|
5968
|
-
error: state.error || authExecutorError
|
|
5969
|
-
}
|
|
5970
|
-
);
|
|
5971
|
-
}
|
|
5972
|
-
if (step === "setup") {
|
|
5973
|
-
const selectSourceTokenCount = selectSourceChoices.reduce(
|
|
5974
|
-
(sum, chain) => sum + chain.tokens.length,
|
|
5975
|
-
0
|
|
5976
|
-
);
|
|
5977
|
-
const effectiveTokenCount = tokenCount > 0 ? tokenCount : selectSourceTokenCount;
|
|
5978
|
-
const effectiveSourceLabel = selectedSourceLabel ?? (selectSourceChainName && selectSourceTokenSymbol ? `${selectSourceTokenSymbol} on ${selectSourceChainName}` : void 0);
|
|
5979
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5980
|
-
SetupScreen,
|
|
5981
|
-
{
|
|
5982
|
-
availableBalance: selectedSource ? selectedSource.balance.available.amount : selectSourceAvailableBalance > 0 ? selectSourceAvailableBalance : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
|
|
5983
|
-
tokenCount: effectiveTokenCount,
|
|
5984
|
-
sourceName,
|
|
5985
|
-
onSetupOneTap: handlers.onSetupOneTap,
|
|
5986
|
-
onBack: () => handlers.onNavigate("deposit"),
|
|
5987
|
-
onLogout: handlers.onLogout,
|
|
5988
|
-
onAdvanced: handlers.onSelectToken,
|
|
5989
|
-
selectedSourceLabel: effectiveSourceLabel,
|
|
5990
|
-
loading: savingOneTapLimit,
|
|
5991
|
-
error: state.error,
|
|
5992
|
-
selectedTokenSymbol: selectedSource?.token.symbol ?? selectSourceTokenSymbol
|
|
5993
|
-
}
|
|
5994
|
-
);
|
|
5995
|
-
}
|
|
5996
|
-
if (step === "confirm-sign") {
|
|
5997
|
-
const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
|
|
5998
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5999
|
-
ConfirmSignScreen,
|
|
6000
|
-
{
|
|
6001
|
-
walletName: providerName,
|
|
6002
|
-
signing: transferSigningSigning,
|
|
6003
|
-
error: state.error || transferSigningError,
|
|
6004
|
-
onSign: handlers.onConfirmSign,
|
|
6005
|
-
onLogout: handlers.onLogout
|
|
6006
|
-
}
|
|
6007
|
-
);
|
|
6008
|
-
}
|
|
6009
|
-
if (step === "deposit") {
|
|
6010
|
-
if (state.loadingData) {
|
|
6011
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BlinkLoadingScreen, {});
|
|
6053
|
+
case "setup-status":
|
|
6054
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6055
|
+
SetupStatusScreen,
|
|
6056
|
+
{
|
|
6057
|
+
complete: false,
|
|
6058
|
+
limit: state.oneTapLimit,
|
|
6059
|
+
tokensApproved: 0,
|
|
6060
|
+
merchantName,
|
|
6061
|
+
onContinue: () => handlers.onSetUserIntent("configure-one-tap"),
|
|
6062
|
+
onLogout: handlers.onLogout,
|
|
6063
|
+
error: state.error || authExecutorError
|
|
6064
|
+
}
|
|
6065
|
+
);
|
|
6066
|
+
case "setup": {
|
|
6067
|
+
const selectSourceTokenCount = selectSourceChoices.reduce(
|
|
6068
|
+
(sum, chain) => sum + chain.tokens.length,
|
|
6069
|
+
0
|
|
6070
|
+
);
|
|
6071
|
+
const effectiveTokenCount = tokenCount > 0 ? tokenCount : selectSourceTokenCount;
|
|
6072
|
+
const effectiveSourceLabel = selectedSourceLabel ?? (selectSourceChainName && selectSourceTokenSymbol ? `${selectSourceTokenSymbol} on ${selectSourceChainName}` : void 0);
|
|
6073
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6074
|
+
SetupScreen,
|
|
6075
|
+
{
|
|
6076
|
+
availableBalance: selectedSource ? selectedSource.balance.available.amount : selectSourceAvailableBalance > 0 ? selectSourceAvailableBalance : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
|
|
6077
|
+
tokenCount: effectiveTokenCount,
|
|
6078
|
+
sourceName,
|
|
6079
|
+
onSetupOneTap: handlers.onSetupOneTap,
|
|
6080
|
+
onBack: () => handlers.onSetUserIntent(null),
|
|
6081
|
+
onLogout: handlers.onLogout,
|
|
6082
|
+
onAdvanced: handlers.onSelectToken,
|
|
6083
|
+
selectedSourceLabel: effectiveSourceLabel,
|
|
6084
|
+
loading: savingOneTapLimit,
|
|
6085
|
+
error: state.error,
|
|
6086
|
+
selectedTokenSymbol: selectedSource?.token.symbol ?? selectSourceTokenSymbol
|
|
6087
|
+
}
|
|
6088
|
+
);
|
|
6012
6089
|
}
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6090
|
+
case "confirm-sign": {
|
|
6091
|
+
const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
|
|
6092
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6093
|
+
ConfirmSignScreen,
|
|
6094
|
+
{
|
|
6095
|
+
walletName: providerName,
|
|
6096
|
+
signing: transferSigningSigning,
|
|
6097
|
+
error: state.error || transferSigningError,
|
|
6098
|
+
onSign: handlers.onConfirmSign,
|
|
6099
|
+
onLogout: handlers.onLogout
|
|
6100
|
+
}
|
|
6101
|
+
);
|
|
6102
|
+
}
|
|
6103
|
+
case "deposit": {
|
|
6104
|
+
const parsedAmt = depositAmount != null ? depositAmount : 5;
|
|
6105
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6106
|
+
DepositScreen,
|
|
6107
|
+
{
|
|
6108
|
+
merchantName,
|
|
6109
|
+
availableBalance: selectedSource ? selectedSource.balance.available.amount : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
|
|
6110
|
+
remainingLimit: selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null,
|
|
6111
|
+
tokenCount,
|
|
6112
|
+
initialAmount: parsedAmt,
|
|
6113
|
+
processing: state.creatingTransfer,
|
|
6114
|
+
error: state.error,
|
|
6115
|
+
onDeposit: handlers.onPay,
|
|
6116
|
+
onSwitchWallet: () => handlers.onSetUserIntent("switch-wallet"),
|
|
6117
|
+
onBack: onBack ?? (() => handlers.onLogout()),
|
|
6118
|
+
onLogout: handlers.onLogout,
|
|
6119
|
+
onIncreaseLimit: handlers.onIncreaseLimit,
|
|
6120
|
+
increasingLimit: state.increasingLimit,
|
|
6121
|
+
accounts: depositEligibleAccounts,
|
|
6122
|
+
selectedAccountId: state.selectedAccountId,
|
|
6123
|
+
onSelectAccount: handlers.onSelectAccount,
|
|
6124
|
+
onAuthorizeAccount: handlers.onContinueConnection,
|
|
6125
|
+
onAddProvider: () => handlers.onSetUserIntent("switch-wallet"),
|
|
6126
|
+
onSelectToken: handlers.onSelectToken,
|
|
6127
|
+
selectedSourceLabel,
|
|
6128
|
+
selectedTokenSymbol: selectedSource?.token.symbol
|
|
6129
|
+
}
|
|
6130
|
+
);
|
|
6131
|
+
}
|
|
6132
|
+
case "token-picker": {
|
|
6133
|
+
if (!selectedAccount) {
|
|
6134
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlinkLoadingScreen, {});
|
|
6038
6135
|
}
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6136
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6137
|
+
TokenPickerScreen,
|
|
6138
|
+
{
|
|
6139
|
+
account: selectedAccount,
|
|
6140
|
+
chains: state.chains,
|
|
6141
|
+
onSelectAuthorized: handlers.onSelectAuthorizedToken,
|
|
6142
|
+
onAuthorizeToken: handlers.onAuthorizeToken,
|
|
6143
|
+
onBack: () => handlers.onSetUserIntent(null),
|
|
6144
|
+
onLogout: handlers.onLogout,
|
|
6145
|
+
depositAmount: depositAmount ?? void 0,
|
|
6146
|
+
selectedTokenSymbol: selectedSource?.token.symbol,
|
|
6147
|
+
selectedWalletId: state.selectedWalletId ?? void 0
|
|
6148
|
+
}
|
|
6149
|
+
);
|
|
6150
|
+
}
|
|
6151
|
+
case "guest-token-picker":
|
|
6043
6152
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6044
6153
|
GuestTokenPickerScreen,
|
|
6045
6154
|
{
|
|
@@ -6049,107 +6158,60 @@ function StepRendererContent({
|
|
|
6049
6158
|
depositAmount: depositAmount ?? void 0,
|
|
6050
6159
|
error: state.error,
|
|
6051
6160
|
onSelect: handlers.onSelectGuestToken,
|
|
6052
|
-
onBack: () => handlers.
|
|
6161
|
+
onBack: () => handlers.onSetUserIntent(null)
|
|
6162
|
+
}
|
|
6163
|
+
);
|
|
6164
|
+
case "processing": {
|
|
6165
|
+
const polledStatus = pollingTransfer?.status;
|
|
6166
|
+
const transferPhase = state.creatingTransfer ? "creating" : polledStatus === "SENDING" || polledStatus === "SENT" ? "sent" : "verifying";
|
|
6167
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6168
|
+
TransferStatusScreen,
|
|
6169
|
+
{
|
|
6170
|
+
phase: transferPhase,
|
|
6171
|
+
error: state.error || authExecutorError || transferSigningError || pollingError,
|
|
6172
|
+
onLogout: handlers.onLogout
|
|
6053
6173
|
}
|
|
6054
6174
|
);
|
|
6055
6175
|
}
|
|
6056
|
-
|
|
6057
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6176
|
+
case "select-source":
|
|
6177
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6178
|
+
SelectSourceScreen,
|
|
6179
|
+
{
|
|
6180
|
+
choices: selectSourceChoices,
|
|
6181
|
+
selectedChainName: selectSourceChainName,
|
|
6182
|
+
selectedTokenSymbol: selectSourceTokenSymbol,
|
|
6183
|
+
recommended: selectSourceRecommended,
|
|
6184
|
+
onChainChange: handlers.onSelectSourceChainChange,
|
|
6185
|
+
onTokenChange: handlers.onSetSelectSourceTokenSymbol,
|
|
6186
|
+
onConfirm: handlers.onConfirmSelectSource,
|
|
6187
|
+
onLogout: handlers.onLogout
|
|
6188
|
+
}
|
|
6189
|
+
);
|
|
6190
|
+
case "success": {
|
|
6191
|
+
const succeeded = state.transfer?.status === "COMPLETED";
|
|
6192
|
+
const displayAmount = state.transfer?.amount?.amount ?? 0;
|
|
6193
|
+
const displayCurrency = state.transfer?.amount?.currency ?? "USD";
|
|
6194
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6195
|
+
SuccessScreen,
|
|
6196
|
+
{
|
|
6197
|
+
amount: displayAmount,
|
|
6198
|
+
currency: displayCurrency,
|
|
6199
|
+
succeeded,
|
|
6200
|
+
error: state.error,
|
|
6201
|
+
merchantName,
|
|
6202
|
+
sourceName,
|
|
6203
|
+
remainingLimit: succeeded ? (() => {
|
|
6204
|
+
const limit = selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null;
|
|
6205
|
+
if (limit == null) return null;
|
|
6206
|
+
return limit > displayAmount ? limit - displayAmount : 0;
|
|
6207
|
+
})() : void 0,
|
|
6208
|
+
onDone: onDismiss ?? handlers.onNewPayment,
|
|
6209
|
+
onLogout: handlers.onLogout,
|
|
6210
|
+
onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0
|
|
6211
|
+
}
|
|
6212
|
+
);
|
|
6058
6213
|
}
|
|
6059
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6060
|
-
TokenPickerScreen,
|
|
6061
|
-
{
|
|
6062
|
-
account: selectedAccount,
|
|
6063
|
-
chains: state.chains,
|
|
6064
|
-
onSelectAuthorized: handlers.onSelectAuthorizedToken,
|
|
6065
|
-
onAuthorizeToken: handlers.onAuthorizeToken,
|
|
6066
|
-
onBack: () => handlers.onNavigate(state.previousStep === "setup" ? "setup" : "deposit"),
|
|
6067
|
-
onLogout: handlers.onLogout,
|
|
6068
|
-
depositAmount: depositAmount ?? void 0,
|
|
6069
|
-
selectedTokenSymbol: selectedSource?.token.symbol,
|
|
6070
|
-
selectedWalletId: state.selectedWalletId
|
|
6071
|
-
}
|
|
6072
|
-
);
|
|
6073
|
-
}
|
|
6074
|
-
if (step === "processing") {
|
|
6075
|
-
const polledStatus = pollingTransfer?.status;
|
|
6076
|
-
const transferPhase = state.creatingTransfer ? "creating" : polledStatus === "SENDING" || polledStatus === "SENT" ? "sent" : "verifying";
|
|
6077
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6078
|
-
TransferStatusScreen,
|
|
6079
|
-
{
|
|
6080
|
-
phase: transferPhase,
|
|
6081
|
-
error: state.error || authExecutorError || transferSigningError || pollingError,
|
|
6082
|
-
onLogout: handlers.onLogout
|
|
6083
|
-
}
|
|
6084
|
-
);
|
|
6085
|
-
}
|
|
6086
|
-
if (step === "select-source") {
|
|
6087
|
-
const cameFromSetup = state.previousStep === "setup";
|
|
6088
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6089
|
-
SelectSourceScreen,
|
|
6090
|
-
{
|
|
6091
|
-
choices: selectSourceChoices,
|
|
6092
|
-
selectedChainName: selectSourceChainName,
|
|
6093
|
-
selectedTokenSymbol: selectSourceTokenSymbol,
|
|
6094
|
-
recommended: selectSourceRecommended,
|
|
6095
|
-
onChainChange: handlers.onSelectSourceChainChange,
|
|
6096
|
-
onTokenChange: handlers.onSetSelectSourceTokenSymbol,
|
|
6097
|
-
onConfirm: cameFromSetup ? () => handlers.onNavigate("setup") : handlers.onConfirmSelectSource,
|
|
6098
|
-
onBack: cameFromSetup ? () => handlers.onNavigate("setup") : void 0,
|
|
6099
|
-
onLogout: handlers.onLogout
|
|
6100
|
-
}
|
|
6101
|
-
);
|
|
6102
|
-
}
|
|
6103
|
-
if (step === "success") {
|
|
6104
|
-
const succeeded = state.transfer?.status === "COMPLETED";
|
|
6105
|
-
const displayAmount = state.transfer?.amount?.amount ?? 0;
|
|
6106
|
-
const displayCurrency = state.transfer?.amount?.currency ?? "USD";
|
|
6107
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6108
|
-
SuccessScreen,
|
|
6109
|
-
{
|
|
6110
|
-
amount: displayAmount,
|
|
6111
|
-
currency: displayCurrency,
|
|
6112
|
-
succeeded,
|
|
6113
|
-
error: state.error,
|
|
6114
|
-
merchantName,
|
|
6115
|
-
sourceName,
|
|
6116
|
-
remainingLimit: succeeded ? (() => {
|
|
6117
|
-
const limit = selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null;
|
|
6118
|
-
if (limit == null) return null;
|
|
6119
|
-
return limit > displayAmount ? limit - displayAmount : 0;
|
|
6120
|
-
})() : void 0,
|
|
6121
|
-
onDone: onDismiss ?? handlers.onNewPayment,
|
|
6122
|
-
onLogout: handlers.onLogout,
|
|
6123
|
-
onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0
|
|
6124
|
-
}
|
|
6125
|
-
);
|
|
6126
|
-
}
|
|
6127
|
-
if (step === "low-balance") {
|
|
6128
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6129
|
-
DepositScreen,
|
|
6130
|
-
{
|
|
6131
|
-
merchantName,
|
|
6132
|
-
availableBalance: 0,
|
|
6133
|
-
remainingLimit: selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null,
|
|
6134
|
-
tokenCount,
|
|
6135
|
-
initialAmount: depositAmount ?? 5,
|
|
6136
|
-
processing: false,
|
|
6137
|
-
error: state.error,
|
|
6138
|
-
onDeposit: handlers.onPay,
|
|
6139
|
-
onSwitchWallet: () => handlers.onNavigate("wallet-picker"),
|
|
6140
|
-
onBack: onBack ?? (() => handlers.onLogout()),
|
|
6141
|
-
onLogout: handlers.onLogout,
|
|
6142
|
-
accounts: depositEligibleAccounts,
|
|
6143
|
-
selectedAccountId: state.selectedAccountId,
|
|
6144
|
-
onSelectAccount: handlers.onSelectAccount,
|
|
6145
|
-
onAuthorizeAccount: handlers.onContinueConnection,
|
|
6146
|
-
onAddProvider: () => handlers.onNavigate("wallet-picker"),
|
|
6147
|
-
selectedSourceLabel,
|
|
6148
|
-
selectedTokenSymbol: selectedSource?.token.symbol
|
|
6149
|
-
}
|
|
6150
|
-
);
|
|
6151
6214
|
}
|
|
6152
|
-
return null;
|
|
6153
6215
|
}
|
|
6154
6216
|
|
|
6155
6217
|
// src/sentry.ts
|
|
@@ -6386,52 +6448,6 @@ function useAuthHandlers(dispatch, verificationTarget) {
|
|
|
6386
6448
|
handleResendLoginCode
|
|
6387
6449
|
};
|
|
6388
6450
|
}
|
|
6389
|
-
|
|
6390
|
-
// src/mobileFlow.ts
|
|
6391
|
-
function hasActiveWallet(accounts) {
|
|
6392
|
-
return accounts.some((account) => account.wallets.some((wallet) => wallet.status === "ACTIVE"));
|
|
6393
|
-
}
|
|
6394
|
-
function resolvePostAuthStep(state) {
|
|
6395
|
-
if (!state.hasPasskey) {
|
|
6396
|
-
return { step: "create-passkey", clearPersistedFlow: false };
|
|
6397
|
-
}
|
|
6398
|
-
if (state.persistedMobileFlow) {
|
|
6399
|
-
if (state.persistedMobileFlow.isReauthorization) {
|
|
6400
|
-
return { step: "open-wallet", clearPersistedFlow: false };
|
|
6401
|
-
}
|
|
6402
|
-
if (state.persistedMobileFlow.isSetup && hasActiveWallet(state.accounts)) {
|
|
6403
|
-
return { step: "deposit", clearPersistedFlow: true };
|
|
6404
|
-
}
|
|
6405
|
-
return { step: "open-wallet", clearPersistedFlow: false };
|
|
6406
|
-
}
|
|
6407
|
-
if (state.mobileSetupInProgress && !hasActiveWallet(state.accounts)) {
|
|
6408
|
-
return { step: "open-wallet", clearPersistedFlow: false };
|
|
6409
|
-
}
|
|
6410
|
-
if ((state.accounts.length === 0 || !hasActiveWallet(state.accounts)) && !state.connectingNewAccount) {
|
|
6411
|
-
return { step: "wallet-picker", clearPersistedFlow: false };
|
|
6412
|
-
}
|
|
6413
|
-
return { step: "deposit", clearPersistedFlow: false };
|
|
6414
|
-
}
|
|
6415
|
-
function resolveRestoredMobileFlow(transferStatus, isSetup) {
|
|
6416
|
-
if (transferStatus === "AUTHORIZED") {
|
|
6417
|
-
return isSetup ? { kind: "resume-setup-deposit", step: "deposit", clearPersistedFlow: true } : { kind: "resume-confirm-sign", step: "confirm-sign", clearPersistedFlow: true };
|
|
6418
|
-
}
|
|
6419
|
-
if (transferStatus === "COMPLETED") {
|
|
6420
|
-
return { kind: "resume-success", step: "success", clearPersistedFlow: true };
|
|
6421
|
-
}
|
|
6422
|
-
if (transferStatus === "FAILED") {
|
|
6423
|
-
return { kind: "resume-failed", step: "success", clearPersistedFlow: true };
|
|
6424
|
-
}
|
|
6425
|
-
if (transferStatus === "SENDING" || transferStatus === "SENT") {
|
|
6426
|
-
return { kind: "resume-processing", step: "processing", clearPersistedFlow: true };
|
|
6427
|
-
}
|
|
6428
|
-
if (isSetup) {
|
|
6429
|
-
return { kind: "resume-stale-setup", step: "wallet-picker", clearPersistedFlow: true };
|
|
6430
|
-
}
|
|
6431
|
-
return { kind: "resume-open-wallet", step: "open-wallet", clearPersistedFlow: false };
|
|
6432
|
-
}
|
|
6433
|
-
|
|
6434
|
-
// src/hooks/usePasskeyHandlers.ts
|
|
6435
6451
|
function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef, guestPreauthAccountId) {
|
|
6436
6452
|
const { user, getAccessToken } = reactAuth.usePrivy();
|
|
6437
6453
|
const checkingPasskeyRef = react.useRef(false);
|
|
@@ -6443,35 +6459,14 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6443
6459
|
reportPasskeyActivity(apiBaseUrl, token, credentialId).catch(() => {
|
|
6444
6460
|
});
|
|
6445
6461
|
}
|
|
6446
|
-
|
|
6447
|
-
hasPasskey: true,
|
|
6448
|
-
accounts,
|
|
6449
|
-
persistedMobileFlow: loadMobileFlowState(),
|
|
6450
|
-
mobileSetupInProgress: mobileSetupFlowRef.current,
|
|
6451
|
-
connectingNewAccount: false
|
|
6452
|
-
});
|
|
6453
|
-
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
6454
|
-
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
6455
|
-
}, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
|
|
6462
|
+
}, [getAccessToken, apiBaseUrl, dispatch]);
|
|
6456
6463
|
const completePasskeyRegistration = react.useCallback(async (credentialId, publicKey) => {
|
|
6457
6464
|
const token = await getAccessToken();
|
|
6458
6465
|
if (!token) throw new Error("Not authenticated");
|
|
6459
6466
|
await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
|
|
6460
6467
|
dispatch({ type: "PASSKEY_ACTIVATED", credentialId, publicKey });
|
|
6461
6468
|
window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
|
|
6462
|
-
|
|
6463
|
-
return;
|
|
6464
|
-
}
|
|
6465
|
-
const resolved = resolvePostAuthStep({
|
|
6466
|
-
hasPasskey: true,
|
|
6467
|
-
accounts,
|
|
6468
|
-
persistedMobileFlow: loadMobileFlowState(),
|
|
6469
|
-
mobileSetupInProgress: mobileSetupFlowRef.current,
|
|
6470
|
-
connectingNewAccount: false
|
|
6471
|
-
});
|
|
6472
|
-
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
6473
|
-
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
6474
|
-
}, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, guestPreauthAccountId, dispatch]);
|
|
6469
|
+
}, [getAccessToken, apiBaseUrl, dispatch]);
|
|
6475
6470
|
const handleRegisterPasskey = react.useCallback(async () => {
|
|
6476
6471
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
|
|
6477
6472
|
dispatch({ type: "SET_ERROR", error: null });
|
|
@@ -6535,15 +6530,6 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6535
6530
|
const { credentialId } = await createPasskeyViaPopup(popupOptions);
|
|
6536
6531
|
dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
|
|
6537
6532
|
localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
|
|
6538
|
-
const resolved = resolvePostAuthStep({
|
|
6539
|
-
hasPasskey: true,
|
|
6540
|
-
accounts,
|
|
6541
|
-
persistedMobileFlow: loadMobileFlowState(),
|
|
6542
|
-
mobileSetupInProgress: mobileSetupFlowRef.current,
|
|
6543
|
-
connectingNewAccount: false
|
|
6544
|
-
});
|
|
6545
|
-
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
6546
|
-
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
6547
6533
|
} catch (err) {
|
|
6548
6534
|
captureException(err);
|
|
6549
6535
|
dispatch({
|
|
@@ -6553,7 +6539,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6553
6539
|
} finally {
|
|
6554
6540
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
|
|
6555
6541
|
}
|
|
6556
|
-
}, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential,
|
|
6542
|
+
}, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential, dispatch]);
|
|
6557
6543
|
const handleVerifyPasskeyViaPopup = react.useCallback(async () => {
|
|
6558
6544
|
dispatch({ type: "SET_VERIFYING_PASSKEY", value: true });
|
|
6559
6545
|
dispatch({ type: "SET_ERROR", error: null });
|
|
@@ -6572,15 +6558,6 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6572
6558
|
reportPasskeyActivity(apiBaseUrl, token, matched).catch(() => {
|
|
6573
6559
|
});
|
|
6574
6560
|
}
|
|
6575
|
-
const resolved = resolvePostAuthStep({
|
|
6576
|
-
hasPasskey: true,
|
|
6577
|
-
accounts,
|
|
6578
|
-
persistedMobileFlow: loadMobileFlowState(),
|
|
6579
|
-
mobileSetupInProgress: mobileSetupFlowRef.current,
|
|
6580
|
-
connectingNewAccount: false
|
|
6581
|
-
});
|
|
6582
|
-
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
6583
|
-
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
6584
6561
|
} else {
|
|
6585
6562
|
dispatch({
|
|
6586
6563
|
type: "SET_ERROR",
|
|
@@ -6596,7 +6573,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6596
6573
|
} finally {
|
|
6597
6574
|
dispatch({ type: "SET_VERIFYING_PASSKEY", value: false });
|
|
6598
6575
|
}
|
|
6599
|
-
}, [knownCredentialIds, getAccessToken, apiBaseUrl,
|
|
6576
|
+
}, [knownCredentialIds, getAccessToken, apiBaseUrl, dispatch]);
|
|
6600
6577
|
return {
|
|
6601
6578
|
handleRegisterPasskey,
|
|
6602
6579
|
handleCreatePasskeyViaPopup,
|
|
@@ -6649,10 +6626,9 @@ function useTransferHandlers(deps) {
|
|
|
6649
6626
|
}
|
|
6650
6627
|
if (!activeCredentialId) {
|
|
6651
6628
|
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6652
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6653
6629
|
return;
|
|
6654
6630
|
}
|
|
6655
|
-
dispatch({ type: "PAY_STARTED"
|
|
6631
|
+
dispatch({ type: "PAY_STARTED" });
|
|
6656
6632
|
processingStartedAtRef.current = Date.now();
|
|
6657
6633
|
try {
|
|
6658
6634
|
if (transfer?.status === "AUTHORIZED") {
|
|
@@ -6699,7 +6675,7 @@ function useTransferHandlers(deps) {
|
|
|
6699
6675
|
} catch (err) {
|
|
6700
6676
|
captureException(err);
|
|
6701
6677
|
const msg = err instanceof Error ? err.message : "Transfer failed";
|
|
6702
|
-
dispatch({ type: "PAY_ERROR", error: msg
|
|
6678
|
+
dispatch({ type: "PAY_ERROR", error: msg });
|
|
6703
6679
|
onError?.(msg);
|
|
6704
6680
|
} finally {
|
|
6705
6681
|
dispatch({ type: "PAY_ENDED" });
|
|
@@ -6749,7 +6725,6 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
|
6749
6725
|
const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
|
|
6750
6726
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
|
|
6751
6727
|
const initializedSelectSourceActionRef = react.useRef(null);
|
|
6752
|
-
const preSelectSourceStepRef = react.useRef(null);
|
|
6753
6728
|
const pendingSelectSourceAction = authExecutor.pendingSelectSource;
|
|
6754
6729
|
const selectSourceChoices = react.useMemo(() => {
|
|
6755
6730
|
if (!pendingSelectSourceAction) return [];
|
|
@@ -6807,8 +6782,7 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
|
6807
6782
|
handleSelectSourceChainChange,
|
|
6808
6783
|
handleConfirmSelectSource,
|
|
6809
6784
|
pendingSelectSourceAction,
|
|
6810
|
-
initializedSelectSourceActionRef
|
|
6811
|
-
preSelectSourceStepRef
|
|
6785
|
+
initializedSelectSourceActionRef
|
|
6812
6786
|
};
|
|
6813
6787
|
}
|
|
6814
6788
|
function useMobileFlowHandlers(dispatch, polling, reloadAccounts, pollingTransferIdRef, stateTransfer, refs, onComplete) {
|
|
@@ -6827,7 +6801,7 @@ function useMobileFlowHandlers(dispatch, polling, reloadAccounts, pollingTransfe
|
|
|
6827
6801
|
guestPollingActiveRef.current = true;
|
|
6828
6802
|
let cancelled = false;
|
|
6829
6803
|
const POLL_INTERVAL_MS = 3e3;
|
|
6830
|
-
dispatch({ type: "
|
|
6804
|
+
dispatch({ type: "SET_ERROR", error: null });
|
|
6831
6805
|
const poll = async () => {
|
|
6832
6806
|
if (cancelled) return;
|
|
6833
6807
|
try {
|
|
@@ -6961,7 +6935,6 @@ function useProviderHandlers(deps) {
|
|
|
6961
6935
|
}
|
|
6962
6936
|
if (!activeCredentialId) {
|
|
6963
6937
|
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6964
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6965
6938
|
return null;
|
|
6966
6939
|
}
|
|
6967
6940
|
const provider = providers.find((p) => p.id === providerId);
|
|
@@ -6982,7 +6955,7 @@ function useProviderHandlers(deps) {
|
|
|
6982
6955
|
} catch (err) {
|
|
6983
6956
|
captureException(err);
|
|
6984
6957
|
const msg = err instanceof Error ? err.message : "Failed to set up wallet";
|
|
6985
|
-
dispatch({ type: "PAY_ERROR", error: msg
|
|
6958
|
+
dispatch({ type: "PAY_ERROR", error: msg });
|
|
6986
6959
|
onError?.(msg);
|
|
6987
6960
|
return null;
|
|
6988
6961
|
}
|
|
@@ -6990,7 +6963,7 @@ function useProviderHandlers(deps) {
|
|
|
6990
6963
|
const handleGuestSelectProvider = react.useCallback(async (providerId) => {
|
|
6991
6964
|
if (!merchantAuthorization || !destination) {
|
|
6992
6965
|
const msg = "Missing payment configuration for guest checkout.";
|
|
6993
|
-
dispatch({ type: "PAY_ERROR", error: msg
|
|
6966
|
+
dispatch({ type: "PAY_ERROR", error: msg });
|
|
6994
6967
|
onError?.(msg);
|
|
6995
6968
|
return;
|
|
6996
6969
|
}
|
|
@@ -7012,7 +6985,7 @@ function useProviderHandlers(deps) {
|
|
|
7012
6985
|
});
|
|
7013
6986
|
if (isMobile) {
|
|
7014
6987
|
if (!result.uri) {
|
|
7015
|
-
dispatch({ type: "PAY_ERROR", error: "This wallet is not available on mobile."
|
|
6988
|
+
dispatch({ type: "PAY_ERROR", error: "This wallet is not available on mobile." });
|
|
7016
6989
|
return;
|
|
7017
6990
|
}
|
|
7018
6991
|
persistMobileFlowState({
|
|
@@ -7030,7 +7003,7 @@ function useProviderHandlers(deps) {
|
|
|
7030
7003
|
if (!account.isConnected) {
|
|
7031
7004
|
const connector = connectors.find((c) => c.type === "injected") ?? connectors[0];
|
|
7032
7005
|
if (!connector) {
|
|
7033
|
-
dispatch({ type: "PAY_ERROR", error: "No wallet extension found. Please install a supported wallet."
|
|
7006
|
+
dispatch({ type: "PAY_ERROR", error: "No wallet extension found. Please install a supported wallet." });
|
|
7034
7007
|
return;
|
|
7035
7008
|
}
|
|
7036
7009
|
await connectAsync({ connector });
|
|
@@ -7045,7 +7018,7 @@ function useProviderHandlers(deps) {
|
|
|
7045
7018
|
} catch (err) {
|
|
7046
7019
|
captureException(err);
|
|
7047
7020
|
const msg = err instanceof Error ? err.message : "Failed to start guest checkout";
|
|
7048
|
-
dispatch({ type: "PAY_ERROR", error: msg
|
|
7021
|
+
dispatch({ type: "PAY_ERROR", error: msg });
|
|
7049
7022
|
onError?.(msg);
|
|
7050
7023
|
}
|
|
7051
7024
|
}, [
|
|
@@ -7068,7 +7041,6 @@ function useProviderHandlers(deps) {
|
|
|
7068
7041
|
dispatch({ type: "SELECT_PROVIDER", providerId });
|
|
7069
7042
|
if (!activeCredentialId) {
|
|
7070
7043
|
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
7071
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7072
7044
|
return;
|
|
7073
7045
|
}
|
|
7074
7046
|
const provider = providers.find((p) => p.id === providerId);
|
|
@@ -7078,8 +7050,7 @@ function useProviderHandlers(deps) {
|
|
|
7078
7050
|
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
7079
7051
|
});
|
|
7080
7052
|
if (!isMobile) {
|
|
7081
|
-
dispatch({ type: "PAY_STARTED"
|
|
7082
|
-
dispatch({ type: "NAVIGATE", step: "open-wallet" });
|
|
7053
|
+
dispatch({ type: "PAY_STARTED" });
|
|
7083
7054
|
}
|
|
7084
7055
|
try {
|
|
7085
7056
|
let accountId;
|
|
@@ -7121,12 +7092,11 @@ function useProviderHandlers(deps) {
|
|
|
7121
7092
|
} else {
|
|
7122
7093
|
await authExecutor.executeSessionById(sessionId);
|
|
7123
7094
|
await reloadAccounts();
|
|
7124
|
-
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
7125
7095
|
}
|
|
7126
7096
|
} catch (err) {
|
|
7127
7097
|
captureException(err);
|
|
7128
7098
|
const msg = err instanceof Error ? err.message : "Failed to set up wallet";
|
|
7129
|
-
dispatch({ type: "PAY_ERROR", error: msg
|
|
7099
|
+
dispatch({ type: "PAY_ERROR", error: msg });
|
|
7130
7100
|
onError?.(msg);
|
|
7131
7101
|
} finally {
|
|
7132
7102
|
if (!isMobile) {
|
|
@@ -7190,7 +7160,6 @@ function useProviderHandlers(deps) {
|
|
|
7190
7160
|
}
|
|
7191
7161
|
if (!activeCredentialId) {
|
|
7192
7162
|
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
7193
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7194
7163
|
return;
|
|
7195
7164
|
}
|
|
7196
7165
|
const acct = accounts.find((a) => a.id === selectedAccountId);
|
|
@@ -7236,10 +7205,8 @@ function useProviderHandlers(deps) {
|
|
|
7236
7205
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
7237
7206
|
triggerDeeplink(session.uri);
|
|
7238
7207
|
} else {
|
|
7239
|
-
dispatch({ type: "NAVIGATE", step: "open-wallet" });
|
|
7240
7208
|
await authExecutor.executeSessionById(session.id);
|
|
7241
7209
|
await reloadAccounts();
|
|
7242
|
-
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
7243
7210
|
}
|
|
7244
7211
|
} catch (err) {
|
|
7245
7212
|
captureException(err);
|
|
@@ -7271,12 +7238,8 @@ function useProviderHandlers(deps) {
|
|
|
7271
7238
|
reauthTokenRef
|
|
7272
7239
|
]);
|
|
7273
7240
|
const handleNavigateToTokenPicker = react.useCallback(() => {
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
} else {
|
|
7277
|
-
dispatch({ type: "NAVIGATE", step: "token-picker" });
|
|
7278
|
-
}
|
|
7279
|
-
}, [dispatch, authExecutor.pendingSelectSource]);
|
|
7241
|
+
dispatch({ type: "SET_USER_INTENT", intent: "pick-token" });
|
|
7242
|
+
}, [dispatch]);
|
|
7280
7243
|
const handleSelectAuthorizedToken = react.useCallback((walletId, tokenSymbol) => {
|
|
7281
7244
|
dispatch({ type: "SELECT_TOKEN", walletId, tokenSymbol });
|
|
7282
7245
|
}, [dispatch]);
|
|
@@ -7287,7 +7250,6 @@ function useProviderHandlers(deps) {
|
|
|
7287
7250
|
}
|
|
7288
7251
|
if (!activeCredentialId) {
|
|
7289
7252
|
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
7290
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7291
7253
|
return;
|
|
7292
7254
|
}
|
|
7293
7255
|
const acct = accounts.find((a) => a.id === selectedAccountId);
|
|
@@ -7329,7 +7291,6 @@ function useProviderHandlers(deps) {
|
|
|
7329
7291
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
7330
7292
|
triggerDeeplink(session.uri);
|
|
7331
7293
|
} else {
|
|
7332
|
-
dispatch({ type: "NAVIGATE", step: "open-wallet" });
|
|
7333
7294
|
await authExecutor.executeSessionById(session.id);
|
|
7334
7295
|
await reloadAccounts();
|
|
7335
7296
|
dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
|
|
@@ -7401,7 +7362,6 @@ function useGuestTransferHandlers(deps) {
|
|
|
7401
7362
|
isGuestFlow,
|
|
7402
7363
|
guestTransferId,
|
|
7403
7364
|
guestSessionToken,
|
|
7404
|
-
step,
|
|
7405
7365
|
onComplete,
|
|
7406
7366
|
onError
|
|
7407
7367
|
} = deps;
|
|
@@ -7415,8 +7375,7 @@ function useGuestTransferHandlers(deps) {
|
|
|
7415
7375
|
const fetchedRef = react.useRef(false);
|
|
7416
7376
|
const selectedGuestTokenRef = react.useRef(null);
|
|
7417
7377
|
react.useEffect(() => {
|
|
7418
|
-
if (!isGuestFlow ||
|
|
7419
|
-
if (!guestTransferId || !guestSessionToken) return;
|
|
7378
|
+
if (!isGuestFlow || !guestTransferId || !guestSessionToken || fetchedRef.current) return;
|
|
7420
7379
|
const account = getAccount(wagmiConfig2);
|
|
7421
7380
|
if (!account.address) return;
|
|
7422
7381
|
fetchedRef.current = true;
|
|
@@ -7430,7 +7389,7 @@ function useGuestTransferHandlers(deps) {
|
|
|
7430
7389
|
captureException(err);
|
|
7431
7390
|
dispatch({ type: "SET_ERROR", error: "Failed to fetch token balances." });
|
|
7432
7391
|
}).finally(() => setLoadingBalances(false));
|
|
7433
|
-
}, [isGuestFlow,
|
|
7392
|
+
}, [isGuestFlow, guestTransferId, guestSessionToken, apiBaseUrl, wagmiConfig2, dispatch]);
|
|
7434
7393
|
react.useEffect(() => {
|
|
7435
7394
|
if (!isGuestFlow) {
|
|
7436
7395
|
fetchedRef.current = false;
|
|
@@ -7459,7 +7418,6 @@ function useGuestTransferHandlers(deps) {
|
|
|
7459
7418
|
entry.tokenAddress
|
|
7460
7419
|
);
|
|
7461
7420
|
selectedGuestTokenRef.current = entry;
|
|
7462
|
-
dispatch({ type: "NAVIGATE", step: "processing" });
|
|
7463
7421
|
} catch (err) {
|
|
7464
7422
|
captureException(err);
|
|
7465
7423
|
const msg = err instanceof Error ? err.message : "Failed to set transfer sender";
|
|
@@ -7470,9 +7428,10 @@ function useGuestTransferHandlers(deps) {
|
|
|
7470
7428
|
}
|
|
7471
7429
|
}, [guestTransferId, guestSessionToken, wagmiConfig2, apiBaseUrl, dispatch, onError]);
|
|
7472
7430
|
react.useEffect(() => {
|
|
7473
|
-
if (!isGuestFlow ||
|
|
7431
|
+
if (!isGuestFlow || !guestTransferId || !guestSessionToken || !selectedGuestTokenRef.current) return;
|
|
7474
7432
|
if (executingBridgeRef.current) return;
|
|
7475
7433
|
executingBridgeRef.current = true;
|
|
7434
|
+
dispatch({ type: "PAY_STARTED" });
|
|
7476
7435
|
const execute = async () => {
|
|
7477
7436
|
try {
|
|
7478
7437
|
let signPayload = null;
|
|
@@ -7484,7 +7443,7 @@ function useGuestTransferHandlers(deps) {
|
|
|
7484
7443
|
break;
|
|
7485
7444
|
}
|
|
7486
7445
|
if (transfer.status === "FAILED") {
|
|
7487
|
-
dispatch({ type: "PAY_ERROR", error: "Transfer failed."
|
|
7446
|
+
dispatch({ type: "PAY_ERROR", error: "Transfer failed." });
|
|
7488
7447
|
return;
|
|
7489
7448
|
}
|
|
7490
7449
|
await new Promise((r) => setTimeout(r, GUEST_SIGN_POLL_MS));
|
|
@@ -7492,8 +7451,7 @@ function useGuestTransferHandlers(deps) {
|
|
|
7492
7451
|
if (!signPayload) {
|
|
7493
7452
|
dispatch({
|
|
7494
7453
|
type: "PAY_ERROR",
|
|
7495
|
-
error: "Timed out waiting for bridge quote. Please try again."
|
|
7496
|
-
fallbackStep: "wallet-picker"
|
|
7454
|
+
error: "Timed out waiting for bridge quote. Please try again."
|
|
7497
7455
|
});
|
|
7498
7456
|
return;
|
|
7499
7457
|
}
|
|
@@ -7513,7 +7471,7 @@ function useGuestTransferHandlers(deps) {
|
|
|
7513
7471
|
const walletClient = await getWalletClient(wagmiConfig2);
|
|
7514
7472
|
const sender = account.address;
|
|
7515
7473
|
if (!sender) {
|
|
7516
|
-
dispatch({ type: "PAY_ERROR", error: "Wallet not connected."
|
|
7474
|
+
dispatch({ type: "PAY_ERROR", error: "Wallet not connected." });
|
|
7517
7475
|
return;
|
|
7518
7476
|
}
|
|
7519
7477
|
let lastTxHash = null;
|
|
@@ -7538,7 +7496,7 @@ function useGuestTransferHandlers(deps) {
|
|
|
7538
7496
|
lastTxHash = txHash;
|
|
7539
7497
|
}
|
|
7540
7498
|
if (!lastTxHash) {
|
|
7541
|
-
dispatch({ type: "PAY_ERROR", error: "No bridge transactions were executed."
|
|
7499
|
+
dispatch({ type: "PAY_ERROR", error: "No bridge transactions were executed." });
|
|
7542
7500
|
return;
|
|
7543
7501
|
}
|
|
7544
7502
|
console.info(`[blink-sdk] type=guest Submitting originTxHash: ${lastTxHash}`);
|
|
@@ -7559,22 +7517,22 @@ function useGuestTransferHandlers(deps) {
|
|
|
7559
7517
|
}
|
|
7560
7518
|
dispatch({
|
|
7561
7519
|
type: "PAY_ERROR",
|
|
7562
|
-
error: "Transfer is taking longer than expected. It may still complete."
|
|
7563
|
-
fallbackStep: "wallet-picker"
|
|
7520
|
+
error: "Transfer is taking longer than expected. It may still complete."
|
|
7564
7521
|
});
|
|
7565
7522
|
} catch (err) {
|
|
7566
7523
|
captureException(err);
|
|
7567
7524
|
const msg = err instanceof Error ? err.message : "Bridge execution failed";
|
|
7568
7525
|
console.error("[blink-sdk] type=guest Bridge execution error:", err);
|
|
7569
7526
|
const displayMsg = isUserRejection2(msg) ? "You rejected the transaction. Please approve in your wallet to continue." : msg;
|
|
7570
|
-
dispatch({ type: "PAY_ERROR", error: displayMsg
|
|
7527
|
+
dispatch({ type: "PAY_ERROR", error: displayMsg });
|
|
7571
7528
|
onError?.(displayMsg);
|
|
7572
7529
|
} finally {
|
|
7573
7530
|
executingBridgeRef.current = false;
|
|
7531
|
+
dispatch({ type: "PAY_ENDED" });
|
|
7574
7532
|
}
|
|
7575
7533
|
};
|
|
7576
7534
|
execute();
|
|
7577
|
-
}, [isGuestFlow,
|
|
7535
|
+
}, [isGuestFlow, guestTransferId, guestSessionToken, settingSender, apiBaseUrl, wagmiConfig2, switchChainAsync, dispatch, onComplete, onError]);
|
|
7578
7536
|
return {
|
|
7579
7537
|
guestTokenEntries,
|
|
7580
7538
|
loadingBalances,
|
|
@@ -7615,12 +7573,10 @@ function useOneTapSetupHandlers(deps) {
|
|
|
7615
7573
|
}
|
|
7616
7574
|
oneTapLimitSavedDuringSetupRef.current = true;
|
|
7617
7575
|
authExecutor.resolveSelectSource({ chainName, tokenSymbol });
|
|
7618
|
-
dispatch({ type: "NAVIGATE", step: "open-wallet" });
|
|
7619
7576
|
} else if (authExecutor.pendingOneTapSetup) {
|
|
7620
7577
|
authExecutor.resolveOneTapSetup();
|
|
7621
|
-
} else {
|
|
7622
|
-
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
7623
7578
|
}
|
|
7579
|
+
dispatch({ type: "SET_USER_INTENT", intent: null });
|
|
7624
7580
|
} catch (err) {
|
|
7625
7581
|
captureException(err);
|
|
7626
7582
|
dispatch({
|
|
@@ -7641,12 +7597,11 @@ function useOneTapSetupHandlers(deps) {
|
|
|
7641
7597
|
// src/dataLoading.ts
|
|
7642
7598
|
function resolveDataLoadAction({
|
|
7643
7599
|
authenticated,
|
|
7644
|
-
step,
|
|
7645
7600
|
accountsCount,
|
|
7646
7601
|
hasActiveCredential,
|
|
7647
7602
|
loading
|
|
7648
7603
|
}) {
|
|
7649
|
-
if (!authenticated ||
|
|
7604
|
+
if (!authenticated || accountsCount > 0 || !hasActiveCredential) {
|
|
7650
7605
|
return "reset";
|
|
7651
7606
|
}
|
|
7652
7607
|
if (loading) {
|
|
@@ -7693,7 +7648,6 @@ function usePaymentEffects(deps) {
|
|
|
7693
7648
|
authenticated,
|
|
7694
7649
|
apiBaseUrl,
|
|
7695
7650
|
depositAmount,
|
|
7696
|
-
useWalletConnectorProp,
|
|
7697
7651
|
onComplete,
|
|
7698
7652
|
onError,
|
|
7699
7653
|
polling,
|
|
@@ -7720,7 +7674,6 @@ function usePaymentEffects(deps) {
|
|
|
7720
7674
|
setSelectSourceChainName,
|
|
7721
7675
|
setSelectSourceTokenSymbol,
|
|
7722
7676
|
initializedSelectSourceActionRef,
|
|
7723
|
-
preSelectSourceStepRef,
|
|
7724
7677
|
oneTapLimitSavedDuringSetupRef,
|
|
7725
7678
|
handleAuthorizedMobileReturn
|
|
7726
7679
|
} = deps;
|
|
@@ -7740,27 +7693,27 @@ function usePaymentEffects(deps) {
|
|
|
7740
7693
|
}
|
|
7741
7694
|
}, [depositAmount, dispatch]);
|
|
7742
7695
|
react.useEffect(() => {
|
|
7743
|
-
if (authenticated || state.
|
|
7696
|
+
if (authenticated || !state.verificationTarget) return;
|
|
7744
7697
|
if (activeOtpErrorMessage) dispatch({ type: "SET_ERROR", error: activeOtpErrorMessage });
|
|
7745
|
-
}, [activeOtpErrorMessage, authenticated, state.
|
|
7698
|
+
}, [activeOtpErrorMessage, authenticated, state.verificationTarget, dispatch]);
|
|
7746
7699
|
react.useEffect(() => {
|
|
7747
|
-
if (state.
|
|
7700
|
+
if (state.verificationTarget && !authenticated && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus === "awaiting-code-input") {
|
|
7748
7701
|
handleVerifyLoginCode();
|
|
7749
7702
|
}
|
|
7750
|
-
}, [otpCode, state.
|
|
7703
|
+
}, [otpCode, state.verificationTarget, authenticated, activeOtpStatus, handleVerifyLoginCode]);
|
|
7751
7704
|
react.useEffect(() => {
|
|
7752
7705
|
if (!ready || !authenticated) {
|
|
7753
7706
|
checkingPasskeyRef.current = false;
|
|
7754
7707
|
return;
|
|
7755
7708
|
}
|
|
7756
|
-
if (state.
|
|
7709
|
+
if (state.passkeyConfigLoaded || state.activeCredentialId) return;
|
|
7757
7710
|
if (checkingPasskeyRef.current) return;
|
|
7758
7711
|
checkingPasskeyRef.current = true;
|
|
7759
7712
|
let cancelled = false;
|
|
7760
7713
|
dispatch({ type: "SET_ERROR", error: null });
|
|
7761
7714
|
setAuthInput("");
|
|
7762
7715
|
setOtpCode("");
|
|
7763
|
-
const
|
|
7716
|
+
const restoreState = async (credId, token) => {
|
|
7764
7717
|
const persisted = loadMobileFlowState();
|
|
7765
7718
|
let accts = [];
|
|
7766
7719
|
try {
|
|
@@ -7768,117 +7721,118 @@ function usePaymentEffects(deps) {
|
|
|
7768
7721
|
if (cancelled) return;
|
|
7769
7722
|
} catch {
|
|
7770
7723
|
}
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
accounts: accts,
|
|
7774
|
-
persistedMobileFlow: persisted,
|
|
7775
|
-
mobileSetupInProgress: false,
|
|
7776
|
-
connectingNewAccount: false
|
|
7777
|
-
});
|
|
7778
|
-
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
7779
|
-
if (resolved.step === "deposit" && persisted && persisted.isSetup && persisted.transferId) {
|
|
7780
|
-
try {
|
|
7781
|
-
const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
|
|
7782
|
-
if (cancelled) return;
|
|
7783
|
-
if (existingTransfer.status === "AUTHORIZED") {
|
|
7784
|
-
await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
|
|
7785
|
-
return;
|
|
7786
|
-
}
|
|
7787
|
-
} catch {
|
|
7788
|
-
}
|
|
7789
|
-
}
|
|
7790
|
-
if (resolved.step === "open-wallet" && persisted && persisted.isReauthorization && persisted.sessionId) {
|
|
7791
|
-
try {
|
|
7792
|
-
const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
|
|
7793
|
-
if (cancelled) return;
|
|
7794
|
-
if (session.status === "AUTHORIZED") {
|
|
7795
|
-
clearMobileFlowState();
|
|
7796
|
-
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
7797
|
-
if (persisted.reauthorizationToken) {
|
|
7798
|
-
dispatch({ type: "SELECT_TOKEN", walletId: persisted.reauthorizationToken.walletId, tokenSymbol: persisted.reauthorizationToken.tokenSymbol });
|
|
7799
|
-
}
|
|
7800
|
-
return;
|
|
7801
|
-
}
|
|
7802
|
-
} catch {
|
|
7803
|
-
}
|
|
7804
|
-
reauthSessionIdRef.current = persisted.sessionId;
|
|
7805
|
-
reauthTokenRef.current = persisted.reauthorizationToken ?? null;
|
|
7806
|
-
mobileSetupFlowRef.current = true;
|
|
7807
|
-
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
7808
|
-
dispatch({
|
|
7809
|
-
type: "ENTER_MOBILE_FLOW",
|
|
7810
|
-
deeplinkUri: persisted.deeplinkUri,
|
|
7811
|
-
providerId: persisted.providerId
|
|
7812
|
-
});
|
|
7813
|
-
return;
|
|
7814
|
-
}
|
|
7815
|
-
if (resolved.step === "open-wallet" && persisted && persisted.accountId && !persisted.transferId) {
|
|
7816
|
-
if (persisted.sessionId) {
|
|
7724
|
+
if (persisted) {
|
|
7725
|
+
if (persisted.isReauthorization && persisted.sessionId) {
|
|
7817
7726
|
try {
|
|
7818
7727
|
const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
|
|
7819
7728
|
if (cancelled) return;
|
|
7820
7729
|
if (session.status === "AUTHORIZED") {
|
|
7821
7730
|
clearMobileFlowState();
|
|
7822
|
-
|
|
7731
|
+
if (persisted.reauthorizationToken) {
|
|
7732
|
+
dispatch({ type: "SELECT_TOKEN", walletId: persisted.reauthorizationToken.walletId, tokenSymbol: persisted.reauthorizationToken.tokenSymbol });
|
|
7733
|
+
}
|
|
7823
7734
|
return;
|
|
7824
7735
|
}
|
|
7825
7736
|
} catch {
|
|
7826
7737
|
}
|
|
7738
|
+
reauthSessionIdRef.current = persisted.sessionId;
|
|
7739
|
+
reauthTokenRef.current = persisted.reauthorizationToken ?? null;
|
|
7740
|
+
mobileSetupFlowRef.current = true;
|
|
7741
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
7742
|
+
dispatch({
|
|
7743
|
+
type: "ENTER_MOBILE_FLOW",
|
|
7744
|
+
deeplinkUri: persisted.deeplinkUri,
|
|
7745
|
+
providerId: persisted.providerId
|
|
7746
|
+
});
|
|
7747
|
+
return;
|
|
7827
7748
|
}
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
if (resolved.step === "open-wallet" && persisted && persisted.transferId) {
|
|
7838
|
-
try {
|
|
7839
|
-
const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
|
|
7840
|
-
if (cancelled) return;
|
|
7841
|
-
const mobileResolution = resolveRestoredMobileFlow(
|
|
7842
|
-
existingTransfer.status,
|
|
7843
|
-
persisted.isSetup
|
|
7844
|
-
);
|
|
7845
|
-
if (mobileResolution.kind === "resume-setup-deposit") {
|
|
7846
|
-
await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
|
|
7847
|
-
return;
|
|
7848
|
-
}
|
|
7849
|
-
if (mobileResolution.kind === "resume-confirm-sign") {
|
|
7850
|
-
await handleAuthorizedMobileReturnRef.current(existingTransfer, false);
|
|
7851
|
-
return;
|
|
7852
|
-
}
|
|
7853
|
-
if (mobileResolution.kind === "resume-success") {
|
|
7854
|
-
clearMobileFlowState();
|
|
7855
|
-
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
7856
|
-
onCompleteRef.current?.(existingTransfer);
|
|
7857
|
-
return;
|
|
7858
|
-
}
|
|
7859
|
-
if (mobileResolution.kind === "resume-failed") {
|
|
7860
|
-
clearMobileFlowState();
|
|
7861
|
-
dispatch({ type: "MOBILE_RESUME_FAILED", transfer: existingTransfer });
|
|
7862
|
-
return;
|
|
7749
|
+
if (persisted.isSetup && persisted.transferId) {
|
|
7750
|
+
try {
|
|
7751
|
+
const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
|
|
7752
|
+
if (cancelled) return;
|
|
7753
|
+
if (existingTransfer.status === "AUTHORIZED") {
|
|
7754
|
+
await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
|
|
7755
|
+
return;
|
|
7756
|
+
}
|
|
7757
|
+
} catch {
|
|
7863
7758
|
}
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7759
|
+
}
|
|
7760
|
+
if (persisted.isSetup && accts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"))) {
|
|
7761
|
+
clearMobileFlowState();
|
|
7762
|
+
return;
|
|
7763
|
+
}
|
|
7764
|
+
if (persisted.accountId && !persisted.transferId) {
|
|
7765
|
+
if (persisted.sessionId) {
|
|
7766
|
+
try {
|
|
7767
|
+
const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
|
|
7768
|
+
if (cancelled) return;
|
|
7769
|
+
if (session.status === "AUTHORIZED") {
|
|
7770
|
+
clearMobileFlowState();
|
|
7771
|
+
return;
|
|
7772
|
+
}
|
|
7773
|
+
} catch {
|
|
7774
|
+
}
|
|
7869
7775
|
}
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7776
|
+
mobileSetupFlowRef.current = true;
|
|
7777
|
+
setupAccountIdRef.current = persisted.accountId;
|
|
7778
|
+
dispatch({
|
|
7779
|
+
type: "ENTER_MOBILE_FLOW",
|
|
7780
|
+
deeplinkUri: persisted.deeplinkUri,
|
|
7781
|
+
providerId: persisted.providerId
|
|
7782
|
+
});
|
|
7783
|
+
return;
|
|
7784
|
+
}
|
|
7785
|
+
if (persisted.transferId) {
|
|
7786
|
+
try {
|
|
7787
|
+
const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
|
|
7788
|
+
if (cancelled) return;
|
|
7789
|
+
if (existingTransfer.status === "COMPLETED") {
|
|
7790
|
+
clearMobileFlowState();
|
|
7791
|
+
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
7792
|
+
onCompleteRef.current?.(existingTransfer);
|
|
7793
|
+
return;
|
|
7794
|
+
}
|
|
7795
|
+
if (existingTransfer.status === "FAILED") {
|
|
7796
|
+
clearMobileFlowState();
|
|
7797
|
+
dispatch({ type: "MOBILE_RESUME_FAILED", transfer: existingTransfer });
|
|
7798
|
+
return;
|
|
7799
|
+
}
|
|
7800
|
+
if (existingTransfer.status === "SENDING" || existingTransfer.status === "SENT") {
|
|
7801
|
+
clearMobileFlowState();
|
|
7802
|
+
dispatch({ type: "MOBILE_RESUME_PROCESSING", transfer: existingTransfer });
|
|
7803
|
+
pollingRef.current.startPolling(existingTransfer.id);
|
|
7804
|
+
return;
|
|
7805
|
+
}
|
|
7806
|
+
if (existingTransfer.status === "AUTHORIZED") {
|
|
7807
|
+
if (persisted.isSetup) {
|
|
7808
|
+
await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
|
|
7809
|
+
} else {
|
|
7810
|
+
await handleAuthorizedMobileReturnRef.current(existingTransfer, false);
|
|
7811
|
+
}
|
|
7812
|
+
return;
|
|
7813
|
+
}
|
|
7814
|
+
if (persisted.isSetup) {
|
|
7815
|
+
clearMobileFlowState();
|
|
7816
|
+
return;
|
|
7817
|
+
}
|
|
7818
|
+
} catch (err) {
|
|
7819
|
+
if (cancelled) return;
|
|
7820
|
+
dispatch({
|
|
7821
|
+
type: "ENTER_MOBILE_FLOW",
|
|
7822
|
+
deeplinkUri: persisted.deeplinkUri,
|
|
7823
|
+
providerId: persisted.providerId,
|
|
7824
|
+
error: err instanceof Error ? err.message : "Unable to refresh wallet authorization status."
|
|
7825
|
+
});
|
|
7826
|
+
pollingTransferIdRef.current = persisted.transferId ?? null;
|
|
7827
|
+
mobileSetupFlowRef.current = persisted.isSetup;
|
|
7828
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
7829
|
+
if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
|
|
7873
7830
|
return;
|
|
7874
7831
|
}
|
|
7875
|
-
} catch (err) {
|
|
7876
|
-
if (cancelled) return;
|
|
7877
7832
|
dispatch({
|
|
7878
7833
|
type: "ENTER_MOBILE_FLOW",
|
|
7879
7834
|
deeplinkUri: persisted.deeplinkUri,
|
|
7880
|
-
providerId: persisted.providerId
|
|
7881
|
-
error: err instanceof Error ? err.message : "Unable to refresh wallet authorization status."
|
|
7835
|
+
providerId: persisted.providerId
|
|
7882
7836
|
});
|
|
7883
7837
|
pollingTransferIdRef.current = persisted.transferId ?? null;
|
|
7884
7838
|
mobileSetupFlowRef.current = persisted.isSetup;
|
|
@@ -7886,18 +7840,7 @@ function usePaymentEffects(deps) {
|
|
|
7886
7840
|
if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
|
|
7887
7841
|
return;
|
|
7888
7842
|
}
|
|
7889
|
-
dispatch({
|
|
7890
|
-
type: "ENTER_MOBILE_FLOW",
|
|
7891
|
-
deeplinkUri: persisted.deeplinkUri,
|
|
7892
|
-
providerId: persisted.providerId
|
|
7893
|
-
});
|
|
7894
|
-
pollingTransferIdRef.current = persisted.transferId ?? null;
|
|
7895
|
-
mobileSetupFlowRef.current = persisted.isSetup;
|
|
7896
|
-
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
7897
|
-
if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
|
|
7898
|
-
return;
|
|
7899
7843
|
}
|
|
7900
|
-
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
7901
7844
|
};
|
|
7902
7845
|
const checkPasskey = async () => {
|
|
7903
7846
|
try {
|
|
@@ -7907,11 +7850,7 @@ function usePaymentEffects(deps) {
|
|
|
7907
7850
|
if (token || cancelled) break;
|
|
7908
7851
|
await new Promise((r) => setTimeout(r, 1e3));
|
|
7909
7852
|
}
|
|
7910
|
-
if (!token)
|
|
7911
|
-
if (!cancelled) dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7912
|
-
return;
|
|
7913
|
-
}
|
|
7914
|
-
if (cancelled) return;
|
|
7853
|
+
if (!token || cancelled) return;
|
|
7915
7854
|
const { config } = await fetchUserConfig(apiBaseUrl, token);
|
|
7916
7855
|
if (cancelled) return;
|
|
7917
7856
|
const allPasskeys = config.passkeys ?? (config.passkey ? [config.passkey] : []);
|
|
@@ -7921,11 +7860,10 @@ function usePaymentEffects(deps) {
|
|
|
7921
7860
|
oneTapLimit: config.defaultAllowance ?? void 0
|
|
7922
7861
|
});
|
|
7923
7862
|
if (allPasskeys.length === 0) {
|
|
7924
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7925
7863
|
return;
|
|
7926
7864
|
}
|
|
7927
7865
|
if (state.activeCredentialId && allPasskeys.some((p) => p.credentialId === state.activeCredentialId)) {
|
|
7928
|
-
await
|
|
7866
|
+
await restoreState(state.activeCredentialId, token);
|
|
7929
7867
|
return;
|
|
7930
7868
|
}
|
|
7931
7869
|
if (cancelled) return;
|
|
@@ -7947,12 +7885,9 @@ function usePaymentEffects(deps) {
|
|
|
7947
7885
|
window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, matched);
|
|
7948
7886
|
reportPasskeyActivity(apiBaseUrl, token, matched).catch(() => {
|
|
7949
7887
|
});
|
|
7950
|
-
await
|
|
7951
|
-
return;
|
|
7888
|
+
await restoreState(matched, token);
|
|
7952
7889
|
}
|
|
7953
|
-
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7954
7890
|
} catch {
|
|
7955
|
-
if (!cancelled) dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
7956
7891
|
}
|
|
7957
7892
|
};
|
|
7958
7893
|
checkPasskey();
|
|
@@ -7960,11 +7895,10 @@ function usePaymentEffects(deps) {
|
|
|
7960
7895
|
cancelled = true;
|
|
7961
7896
|
checkingPasskeyRef.current = false;
|
|
7962
7897
|
};
|
|
7963
|
-
}, [ready, authenticated, state.
|
|
7898
|
+
}, [ready, authenticated, apiBaseUrl, state.activeCredentialId, state.passkeyConfigLoaded]);
|
|
7964
7899
|
react.useEffect(() => {
|
|
7965
7900
|
const loadAction = resolveDataLoadAction({
|
|
7966
7901
|
authenticated,
|
|
7967
|
-
step: state.step,
|
|
7968
7902
|
accountsCount: state.accounts.length,
|
|
7969
7903
|
hasActiveCredential: !!state.activeCredentialId,
|
|
7970
7904
|
loading: loadingDataRef.current
|
|
@@ -7997,24 +7931,16 @@ function usePaymentEffects(deps) {
|
|
|
7997
7931
|
const parsedAmt = depositAmount != null ? depositAmount : 0;
|
|
7998
7932
|
const defaults = resolveDepositSelection(accts, parsedAmt, state.selectedAccountId);
|
|
7999
7933
|
const persisted = loadMobileFlowState();
|
|
8000
|
-
const
|
|
8001
|
-
hasPasskey: !!state.activeCredentialId,
|
|
8002
|
-
accounts: accts,
|
|
8003
|
-
persistedMobileFlow: persisted,
|
|
8004
|
-
mobileSetupInProgress: mobileSetupFlowRef.current,
|
|
8005
|
-
connectingNewAccount: false
|
|
8006
|
-
});
|
|
8007
|
-
const correctableSteps = ["deposit", "wallet-picker", "open-wallet"];
|
|
7934
|
+
const clearMobile = persisted?.isSetup && accts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
|
|
8008
7935
|
dispatch({
|
|
8009
7936
|
type: "DATA_LOADED",
|
|
8010
7937
|
providers: prov,
|
|
8011
7938
|
accounts: accts,
|
|
8012
7939
|
chains: chn,
|
|
8013
7940
|
defaults,
|
|
8014
|
-
|
|
8015
|
-
clearMobileState: resolved.clearPersistedFlow
|
|
7941
|
+
clearMobileState: clearMobile
|
|
8016
7942
|
});
|
|
8017
|
-
if (
|
|
7943
|
+
if (clearMobile) clearMobileFlowState();
|
|
8018
7944
|
} catch (err) {
|
|
8019
7945
|
if (!cancelled) {
|
|
8020
7946
|
captureException(err);
|
|
@@ -8037,7 +7963,6 @@ function usePaymentEffects(deps) {
|
|
|
8037
7963
|
};
|
|
8038
7964
|
}, [
|
|
8039
7965
|
authenticated,
|
|
8040
|
-
state.step,
|
|
8041
7966
|
state.accounts.length,
|
|
8042
7967
|
apiBaseUrl,
|
|
8043
7968
|
state.activeCredentialId,
|
|
@@ -8046,7 +7971,7 @@ function usePaymentEffects(deps) {
|
|
|
8046
7971
|
]);
|
|
8047
7972
|
react.useEffect(() => {
|
|
8048
7973
|
if (authenticated || state.providers.length > 0) return;
|
|
8049
|
-
if (state.
|
|
7974
|
+
if (state.activeCredentialId) return;
|
|
8050
7975
|
let cancelled = false;
|
|
8051
7976
|
const loadProviders = async () => {
|
|
8052
7977
|
try {
|
|
@@ -8069,7 +7994,7 @@ function usePaymentEffects(deps) {
|
|
|
8069
7994
|
return () => {
|
|
8070
7995
|
cancelled = true;
|
|
8071
7996
|
};
|
|
8072
|
-
}, [authenticated, state.
|
|
7997
|
+
}, [authenticated, state.providers.length, state.activeCredentialId, apiBaseUrl]);
|
|
8073
7998
|
react.useEffect(() => {
|
|
8074
7999
|
if (!polling.transfer) return;
|
|
8075
8000
|
if (polling.transfer.status === "COMPLETED") {
|
|
@@ -8083,13 +8008,21 @@ function usePaymentEffects(deps) {
|
|
|
8083
8008
|
}
|
|
8084
8009
|
}, [polling.transfer, onComplete, dispatch, reloadAccounts]);
|
|
8085
8010
|
react.useEffect(() => {
|
|
8086
|
-
if (state.
|
|
8011
|
+
if (state.accounts.length > 0 && state.activeCredentialId && !state.loadingData && !state.transfer && authenticated && Date.now() - lastAccountFetchRef.current > 15e3) {
|
|
8087
8012
|
lastAccountFetchRef.current = Date.now();
|
|
8088
8013
|
reloadAccounts();
|
|
8089
8014
|
}
|
|
8090
|
-
}, [
|
|
8015
|
+
}, [
|
|
8016
|
+
state.accounts.length,
|
|
8017
|
+
state.activeCredentialId,
|
|
8018
|
+
state.loadingData,
|
|
8019
|
+
state.transfer,
|
|
8020
|
+
authenticated,
|
|
8021
|
+
reloadAccounts
|
|
8022
|
+
]);
|
|
8091
8023
|
react.useEffect(() => {
|
|
8092
|
-
|
|
8024
|
+
const isProcessing = state.creatingTransfer || state.transfer != null && ["CREATED", "SENDING", "SENT"].includes(state.transfer.status);
|
|
8025
|
+
if (!isProcessing) {
|
|
8093
8026
|
processingStartedAtRef.current = null;
|
|
8094
8027
|
return;
|
|
8095
8028
|
}
|
|
@@ -8113,7 +8046,15 @@ function usePaymentEffects(deps) {
|
|
|
8113
8046
|
}
|
|
8114
8047
|
const timeoutId = window.setTimeout(handleTimeout, remainingMs);
|
|
8115
8048
|
return () => window.clearTimeout(timeoutId);
|
|
8116
|
-
}, [
|
|
8049
|
+
}, [
|
|
8050
|
+
state.creatingTransfer,
|
|
8051
|
+
state.transfer,
|
|
8052
|
+
polling.transfer,
|
|
8053
|
+
polling.stopPolling,
|
|
8054
|
+
onError,
|
|
8055
|
+
dispatch,
|
|
8056
|
+
processingStartedAtRef
|
|
8057
|
+
]);
|
|
8117
8058
|
react.useEffect(() => {
|
|
8118
8059
|
if (!state.mobileFlow) {
|
|
8119
8060
|
handlingMobileReturnRef.current = false;
|
|
@@ -8126,7 +8067,6 @@ function usePaymentEffects(deps) {
|
|
|
8126
8067
|
}, [state.mobileFlow, polling.transfer, handleAuthorizedMobileReturn, handlingMobileReturnRef, mobileSetupFlowRef]);
|
|
8127
8068
|
react.useEffect(() => {
|
|
8128
8069
|
if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
|
|
8129
|
-
if (state.step !== "open-wallet") return;
|
|
8130
8070
|
if (!state.activeCredentialId || !setupAccountIdRef.current) return;
|
|
8131
8071
|
const accountId = setupAccountIdRef.current;
|
|
8132
8072
|
const credentialId = state.activeCredentialId;
|
|
@@ -8219,7 +8159,6 @@ function usePaymentEffects(deps) {
|
|
|
8219
8159
|
};
|
|
8220
8160
|
}, [
|
|
8221
8161
|
state.mobileFlow,
|
|
8222
|
-
state.step,
|
|
8223
8162
|
state.activeCredentialId,
|
|
8224
8163
|
apiBaseUrl,
|
|
8225
8164
|
reloadAccounts,
|
|
@@ -8289,46 +8228,22 @@ function usePaymentEffects(deps) {
|
|
|
8289
8228
|
setSelectSourceTokenSymbol,
|
|
8290
8229
|
initializedSelectSourceActionRef
|
|
8291
8230
|
]);
|
|
8231
|
+
const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
|
|
8292
8232
|
react.useEffect(() => {
|
|
8293
|
-
if (
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
8297
|
-
});
|
|
8298
|
-
if (isDesktop && (state.step === "setup-status" || state.step === "open-wallet")) {
|
|
8299
|
-
preSelectSourceStepRef.current = state.step;
|
|
8300
|
-
dispatch({ type: "NAVIGATE", step: "setup" });
|
|
8301
|
-
return;
|
|
8302
|
-
}
|
|
8303
|
-
preSelectSourceStepRef.current = state.step;
|
|
8304
|
-
dispatch({ type: "NAVIGATE", step: "select-source" });
|
|
8305
|
-
} else if (!pendingSelectSourceAction && state.step === "select-source") {
|
|
8306
|
-
dispatch({ type: "NAVIGATE", step: preSelectSourceStepRef.current ?? "processing" });
|
|
8307
|
-
preSelectSourceStepRef.current = null;
|
|
8233
|
+
if (pendingOneTapSetupAction && oneTapLimitSavedDuringSetupRef.current) {
|
|
8234
|
+
oneTapLimitSavedDuringSetupRef.current = false;
|
|
8235
|
+
authExecutor.resolveOneTapSetup();
|
|
8308
8236
|
}
|
|
8309
|
-
}, [
|
|
8310
|
-
const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
|
|
8311
|
-
const preOneTapSetupStepRef = react.useRef(null);
|
|
8237
|
+
}, [pendingOneTapSetupAction, authExecutor, oneTapLimitSavedDuringSetupRef]);
|
|
8312
8238
|
react.useEffect(() => {
|
|
8313
|
-
if (pendingOneTapSetupAction &&
|
|
8314
|
-
|
|
8315
|
-
oneTapLimitSavedDuringSetupRef.current = false;
|
|
8316
|
-
authExecutor.resolveOneTapSetup();
|
|
8317
|
-
} else {
|
|
8318
|
-
preOneTapSetupStepRef.current = state.step;
|
|
8319
|
-
reloadAccounts().then(() => {
|
|
8320
|
-
dispatch({ type: "NAVIGATE", step: "setup" });
|
|
8321
|
-
});
|
|
8322
|
-
}
|
|
8323
|
-
} else if (!pendingOneTapSetupAction && state.step === "setup" && preOneTapSetupStepRef.current) {
|
|
8324
|
-
dispatch({ type: "NAVIGATE", step: preOneTapSetupStepRef.current });
|
|
8325
|
-
preOneTapSetupStepRef.current = null;
|
|
8239
|
+
if (pendingOneTapSetupAction && !oneTapLimitSavedDuringSetupRef.current) {
|
|
8240
|
+
reloadAccounts();
|
|
8326
8241
|
}
|
|
8327
|
-
}, [pendingOneTapSetupAction,
|
|
8242
|
+
}, [pendingOneTapSetupAction, reloadAccounts, oneTapLimitSavedDuringSetupRef]);
|
|
8328
8243
|
react.useEffect(() => {
|
|
8329
|
-
if (state.step !== "success") return;
|
|
8330
8244
|
if (!state.guestSessionToken) return;
|
|
8331
8245
|
if (state.guestPreauthAccountId) return;
|
|
8246
|
+
if (!state.transfer || state.transfer.status !== "COMPLETED") return;
|
|
8332
8247
|
let cancelled = false;
|
|
8333
8248
|
const checkPreauth = async () => {
|
|
8334
8249
|
try {
|
|
@@ -8344,7 +8259,7 @@ function usePaymentEffects(deps) {
|
|
|
8344
8259
|
return () => {
|
|
8345
8260
|
cancelled = true;
|
|
8346
8261
|
};
|
|
8347
|
-
}, [state.
|
|
8262
|
+
}, [state.transfer, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
|
|
8348
8263
|
const settingOwnerRef = react.useRef(false);
|
|
8349
8264
|
react.useEffect(() => {
|
|
8350
8265
|
if (!state.guestPreauthAccountId) return;
|
|
@@ -8515,7 +8430,6 @@ function BlinkPaymentInner({
|
|
|
8515
8430
|
isGuestFlow: state.isGuestFlow,
|
|
8516
8431
|
guestTransferId: state.guestTransferId,
|
|
8517
8432
|
guestSessionToken: state.guestSessionToken,
|
|
8518
|
-
step: state.step,
|
|
8519
8433
|
onComplete,
|
|
8520
8434
|
onError
|
|
8521
8435
|
});
|
|
@@ -8523,14 +8437,13 @@ function BlinkPaymentInner({
|
|
|
8523
8437
|
clearMobileFlowState();
|
|
8524
8438
|
transfer.processingStartedAtRef.current = null;
|
|
8525
8439
|
transfer.pollingTransferIdRef.current = null;
|
|
8526
|
-
sourceSelection.preSelectSourceStepRef.current = null;
|
|
8527
8440
|
oneTapSetup.oneTapLimitSavedDuringSetupRef.current = false;
|
|
8528
8441
|
dispatch({
|
|
8529
8442
|
type: "NEW_PAYMENT",
|
|
8530
8443
|
depositAmount,
|
|
8531
8444
|
firstAccountId: state.accounts.length > 0 ? state.accounts[0].id : null
|
|
8532
8445
|
});
|
|
8533
|
-
}, [depositAmount, state.accounts, transfer,
|
|
8446
|
+
}, [depositAmount, state.accounts, transfer, oneTapSetup]);
|
|
8534
8447
|
const handleLogout = react.useCallback(async () => {
|
|
8535
8448
|
try {
|
|
8536
8449
|
await logout();
|
|
@@ -8541,13 +8454,12 @@ function BlinkPaymentInner({
|
|
|
8541
8454
|
window.localStorage.removeItem(ACTIVE_CREDENTIAL_STORAGE_KEY);
|
|
8542
8455
|
}
|
|
8543
8456
|
polling.stopPolling();
|
|
8544
|
-
sourceSelection.preSelectSourceStepRef.current = null;
|
|
8545
8457
|
passkey.checkingPasskeyRef.current = false;
|
|
8546
8458
|
oneTapSetup.oneTapLimitSavedDuringSetupRef.current = false;
|
|
8547
8459
|
auth.setAuthInput("");
|
|
8548
8460
|
auth.setOtpCode("");
|
|
8549
8461
|
dispatch({ type: "LOGOUT", depositAmount });
|
|
8550
|
-
}, [logout, polling, depositAmount, auth,
|
|
8462
|
+
}, [logout, polling, depositAmount, auth, passkey, oneTapSetup]);
|
|
8551
8463
|
usePaymentEffects({
|
|
8552
8464
|
state,
|
|
8553
8465
|
dispatch,
|
|
@@ -8555,7 +8467,6 @@ function BlinkPaymentInner({
|
|
|
8555
8467
|
authenticated,
|
|
8556
8468
|
apiBaseUrl,
|
|
8557
8469
|
depositAmount,
|
|
8558
|
-
useWalletConnectorProp,
|
|
8559
8470
|
onComplete,
|
|
8560
8471
|
onError,
|
|
8561
8472
|
polling,
|
|
@@ -8582,22 +8493,24 @@ function BlinkPaymentInner({
|
|
|
8582
8493
|
setSelectSourceChainName: sourceSelection.setSelectSourceChainName,
|
|
8583
8494
|
setSelectSourceTokenSymbol: sourceSelection.setSelectSourceTokenSymbol,
|
|
8584
8495
|
initializedSelectSourceActionRef: sourceSelection.initializedSelectSourceActionRef,
|
|
8585
|
-
preSelectSourceStepRef: sourceSelection.preSelectSourceStepRef,
|
|
8586
8496
|
oneTapLimitSavedDuringSetupRef: oneTapSetup.oneTapLimitSavedDuringSetupRef,
|
|
8587
8497
|
handleAuthorizedMobileReturn: mobileFlow.handleAuthorizedMobileReturn
|
|
8588
8498
|
});
|
|
8589
8499
|
const autoSelectingRef = react.useRef(false);
|
|
8590
8500
|
react.useEffect(() => {
|
|
8591
|
-
if (
|
|
8501
|
+
if (!state.isGuestFlow || !state.selectedProviderId || !state.activeCredentialId || !authenticated || autoSelectingRef.current || state.transfer != null) return;
|
|
8502
|
+
const hasActive = state.accounts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
|
|
8503
|
+
if (hasActive) return;
|
|
8592
8504
|
autoSelectingRef.current = true;
|
|
8593
8505
|
provider.handleSelectProvider(state.selectedProviderId).finally(() => {
|
|
8594
8506
|
autoSelectingRef.current = false;
|
|
8595
8507
|
});
|
|
8596
8508
|
}, [
|
|
8597
|
-
state.step,
|
|
8598
8509
|
state.isGuestFlow,
|
|
8599
8510
|
state.selectedProviderId,
|
|
8600
8511
|
state.activeCredentialId,
|
|
8512
|
+
state.transfer,
|
|
8513
|
+
state.accounts,
|
|
8601
8514
|
authenticated,
|
|
8602
8515
|
provider
|
|
8603
8516
|
]);
|
|
@@ -8620,9 +8533,10 @@ function BlinkPaymentInner({
|
|
|
8620
8533
|
onIncreaseLimit: provider.handleIncreaseLimit,
|
|
8621
8534
|
onConfirmSign: transfer.handleConfirmSign,
|
|
8622
8535
|
onRetryMobileStatus: mobileFlow.handleRetryMobileStatus,
|
|
8536
|
+
onBackFromOpenWallet: () => dispatch({ type: "CLEAR_MOBILE_STATE" }),
|
|
8623
8537
|
onLogout: handleLogout,
|
|
8624
8538
|
onNewPayment: handleNewPayment,
|
|
8625
|
-
|
|
8539
|
+
onSetUserIntent: (intent) => dispatch({ type: "SET_USER_INTENT", intent }),
|
|
8626
8540
|
onSetAuthInput: auth.setAuthInput,
|
|
8627
8541
|
onSetOtpCode: (code) => {
|
|
8628
8542
|
auth.setOtpCode(code);
|
|
@@ -8636,8 +8550,8 @@ function BlinkPaymentInner({
|
|
|
8636
8550
|
onSelectAuthorizedToken: provider.handleSelectAuthorizedToken,
|
|
8637
8551
|
onAuthorizeToken: provider.handleAuthorizeToken,
|
|
8638
8552
|
onSelectGuestToken: guestTransfer.handleSelectGuestToken,
|
|
8639
|
-
onLogin: () => dispatch({ type: "
|
|
8640
|
-
onPreauthorize: () => dispatch({ type: "
|
|
8553
|
+
onLogin: () => dispatch({ type: "REQUEST_LOGIN" }),
|
|
8554
|
+
onPreauthorize: () => dispatch({ type: "REQUEST_LOGIN" })
|
|
8641
8555
|
}), [
|
|
8642
8556
|
auth,
|
|
8643
8557
|
passkey,
|
|
@@ -8660,8 +8574,12 @@ function BlinkPaymentInner({
|
|
|
8660
8574
|
pollingTransfer: polling.transfer,
|
|
8661
8575
|
pollingError: polling.error,
|
|
8662
8576
|
authExecutorError: authExecutor.error,
|
|
8577
|
+
inlineAuthorizationExecuting: authExecutor.executing,
|
|
8663
8578
|
transferSigningSigning: transferSigning.signing,
|
|
8664
8579
|
transferSigningError: transferSigning.error,
|
|
8580
|
+
pendingSelectSource: authExecutor.pendingSelectSource,
|
|
8581
|
+
pendingOneTapSetup: authExecutor.pendingOneTapSetup,
|
|
8582
|
+
oneTapLimitAlreadySaved: oneTapSetup.oneTapLimitSavedDuringSetupRef.current,
|
|
8665
8583
|
pendingConnections: derived.pendingConnections,
|
|
8666
8584
|
depositEligibleAccounts: derived.depositEligibleAccounts,
|
|
8667
8585
|
sourceName: derived.sourceName,
|
|
@@ -8722,6 +8640,7 @@ exports.findDevicePasskeyViaPopup = findDevicePasskeyViaPopup;
|
|
|
8722
8640
|
exports.getTheme = getTheme;
|
|
8723
8641
|
exports.lightTheme = lightTheme;
|
|
8724
8642
|
exports.resolvePasskeyRpId = resolvePasskeyRpId;
|
|
8643
|
+
exports.resolveScreen = resolveScreen;
|
|
8725
8644
|
exports.useAuthorizationExecutor = useAuthorizationExecutor;
|
|
8726
8645
|
exports.useBlinkConfig = useBlinkConfig;
|
|
8727
8646
|
exports.useBlinkDepositAmount = useBlinkDepositAmount;
|