@swype-org/react-sdk 0.1.112 → 0.1.114
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 +387 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +387 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -26,6 +26,8 @@ interface WalletToken {
|
|
|
26
26
|
/** A token source within a wallet (e.g. USDC on a specific chain) */
|
|
27
27
|
interface WalletSource {
|
|
28
28
|
id: string;
|
|
29
|
+
/** On-chain ERC-20 contract address (e.g. 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) */
|
|
30
|
+
address: string;
|
|
29
31
|
token: WalletToken;
|
|
30
32
|
balance: TokenBalance;
|
|
31
33
|
}
|
|
@@ -78,6 +80,8 @@ interface AuthorizationSessionDetail {
|
|
|
78
80
|
id: string;
|
|
79
81
|
status: string;
|
|
80
82
|
uri: string;
|
|
83
|
+
selectedTokenAddress?: string;
|
|
84
|
+
selectedChainId?: number;
|
|
81
85
|
actions: AuthorizationAction[];
|
|
82
86
|
}
|
|
83
87
|
/** Monetary amount */
|
|
@@ -202,7 +206,7 @@ interface UserConfig {
|
|
|
202
206
|
/** Theme mode */
|
|
203
207
|
type ThemeMode = 'light' | 'dark';
|
|
204
208
|
/** Steps in the payment flow */
|
|
205
|
-
type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'wallet-picker' | 'open-wallet' | 'setup-status' | 'setup' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
|
|
209
|
+
type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'wallet-picker' | 'open-wallet' | 'setup-status' | 'setup' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'token-picker' | 'success';
|
|
206
210
|
/** User-selected advanced settings for chain/asset override */
|
|
207
211
|
interface AdvancedSettings {
|
|
208
212
|
/** Override asset (e.g. 'USDC', 'USDT'). Null = let backend decide. */
|
|
@@ -310,7 +314,10 @@ interface CreateAccountParams {
|
|
|
310
314
|
nickname?: string;
|
|
311
315
|
}
|
|
312
316
|
declare function createAccount(apiBaseUrl: string, token: string, params: CreateAccountParams): Promise<Account>;
|
|
313
|
-
declare function createAccountAuthorizationSession(apiBaseUrl: string, token: string, accountId: string, credentialId: string
|
|
317
|
+
declare function createAccountAuthorizationSession(apiBaseUrl: string, token: string, accountId: string, credentialId: string, options?: {
|
|
318
|
+
tokenAddress?: string;
|
|
319
|
+
chainId?: number;
|
|
320
|
+
}): Promise<{
|
|
314
321
|
id: string;
|
|
315
322
|
status: string;
|
|
316
323
|
uri: string;
|
|
@@ -775,4 +782,17 @@ interface AdvancedSourceScreenProps {
|
|
|
775
782
|
}
|
|
776
783
|
declare function AdvancedSourceScreen({ choices, selectedChainName, selectedTokenSymbol, onSelectSource, onBack, }: AdvancedSourceScreenProps): react_jsx_runtime.JSX.Element;
|
|
777
784
|
|
|
778
|
-
|
|
785
|
+
interface TokenPickerScreenProps {
|
|
786
|
+
account: Account;
|
|
787
|
+
chains: Array<{
|
|
788
|
+
id: string;
|
|
789
|
+
name: string;
|
|
790
|
+
commonId: number | null;
|
|
791
|
+
}>;
|
|
792
|
+
onSelectAuthorized: (walletId: string, tokenSymbol: string) => void;
|
|
793
|
+
onAuthorizeToken: (walletId: string, tokenAddress: string, chainId: number, tokenSymbol: string) => void;
|
|
794
|
+
onBack: () => void;
|
|
795
|
+
}
|
|
796
|
+
declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
|
|
797
|
+
|
|
798
|
+
export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypeLoadingScreen, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, TokenPickerScreen, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ interface WalletToken {
|
|
|
26
26
|
/** A token source within a wallet (e.g. USDC on a specific chain) */
|
|
27
27
|
interface WalletSource {
|
|
28
28
|
id: string;
|
|
29
|
+
/** On-chain ERC-20 contract address (e.g. 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) */
|
|
30
|
+
address: string;
|
|
29
31
|
token: WalletToken;
|
|
30
32
|
balance: TokenBalance;
|
|
31
33
|
}
|
|
@@ -78,6 +80,8 @@ interface AuthorizationSessionDetail {
|
|
|
78
80
|
id: string;
|
|
79
81
|
status: string;
|
|
80
82
|
uri: string;
|
|
83
|
+
selectedTokenAddress?: string;
|
|
84
|
+
selectedChainId?: number;
|
|
81
85
|
actions: AuthorizationAction[];
|
|
82
86
|
}
|
|
83
87
|
/** Monetary amount */
|
|
@@ -202,7 +206,7 @@ interface UserConfig {
|
|
|
202
206
|
/** Theme mode */
|
|
203
207
|
type ThemeMode = 'light' | 'dark';
|
|
204
208
|
/** Steps in the payment flow */
|
|
205
|
-
type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'wallet-picker' | 'open-wallet' | 'setup-status' | 'setup' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
|
|
209
|
+
type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'wallet-picker' | 'open-wallet' | 'setup-status' | 'setup' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'token-picker' | 'success';
|
|
206
210
|
/** User-selected advanced settings for chain/asset override */
|
|
207
211
|
interface AdvancedSettings {
|
|
208
212
|
/** Override asset (e.g. 'USDC', 'USDT'). Null = let backend decide. */
|
|
@@ -310,7 +314,10 @@ interface CreateAccountParams {
|
|
|
310
314
|
nickname?: string;
|
|
311
315
|
}
|
|
312
316
|
declare function createAccount(apiBaseUrl: string, token: string, params: CreateAccountParams): Promise<Account>;
|
|
313
|
-
declare function createAccountAuthorizationSession(apiBaseUrl: string, token: string, accountId: string, credentialId: string
|
|
317
|
+
declare function createAccountAuthorizationSession(apiBaseUrl: string, token: string, accountId: string, credentialId: string, options?: {
|
|
318
|
+
tokenAddress?: string;
|
|
319
|
+
chainId?: number;
|
|
320
|
+
}): Promise<{
|
|
314
321
|
id: string;
|
|
315
322
|
status: string;
|
|
316
323
|
uri: string;
|
|
@@ -775,4 +782,17 @@ interface AdvancedSourceScreenProps {
|
|
|
775
782
|
}
|
|
776
783
|
declare function AdvancedSourceScreen({ choices, selectedChainName, selectedTokenSymbol, onSelectSource, onBack, }: AdvancedSourceScreenProps): react_jsx_runtime.JSX.Element;
|
|
777
784
|
|
|
778
|
-
|
|
785
|
+
interface TokenPickerScreenProps {
|
|
786
|
+
account: Account;
|
|
787
|
+
chains: Array<{
|
|
788
|
+
id: string;
|
|
789
|
+
name: string;
|
|
790
|
+
commonId: number | null;
|
|
791
|
+
}>;
|
|
792
|
+
onSelectAuthorized: (walletId: string, tokenSymbol: string) => void;
|
|
793
|
+
onAuthorizeToken: (walletId: string, tokenAddress: string, chainId: number, tokenSymbol: string) => void;
|
|
794
|
+
onBack: () => void;
|
|
795
|
+
}
|
|
796
|
+
declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
|
|
797
|
+
|
|
798
|
+
export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypeLoadingScreen, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, TokenPickerScreen, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
package/dist/index.js
CHANGED
|
@@ -235,7 +235,10 @@ async function createAccount(apiBaseUrl, token, params) {
|
|
|
235
235
|
if (!res.ok) await throwApiError(res);
|
|
236
236
|
return await res.json();
|
|
237
237
|
}
|
|
238
|
-
async function createAccountAuthorizationSession(apiBaseUrl, token, accountId, credentialId) {
|
|
238
|
+
async function createAccountAuthorizationSession(apiBaseUrl, token, accountId, credentialId, options) {
|
|
239
|
+
const body = { credentialId };
|
|
240
|
+
if (options?.tokenAddress) body.tokenAddress = options.tokenAddress;
|
|
241
|
+
if (options?.chainId != null) body.chainId = options.chainId;
|
|
239
242
|
const res = await fetch(
|
|
240
243
|
`${apiBaseUrl}/v1/accounts/${accountId}/authorization-sessions`,
|
|
241
244
|
{
|
|
@@ -244,7 +247,7 @@ async function createAccountAuthorizationSession(apiBaseUrl, token, accountId, c
|
|
|
244
247
|
"Content-Type": "application/json",
|
|
245
248
|
Authorization: `Bearer ${token}`
|
|
246
249
|
},
|
|
247
|
-
body: JSON.stringify(
|
|
250
|
+
body: JSON.stringify(body)
|
|
248
251
|
}
|
|
249
252
|
);
|
|
250
253
|
if (!res.ok) await throwApiError(res);
|
|
@@ -1926,6 +1929,7 @@ function createInitialState(config) {
|
|
|
1926
1929
|
selectedProviderId: null,
|
|
1927
1930
|
selectedAccountId: null,
|
|
1928
1931
|
selectedWalletId: null,
|
|
1932
|
+
selectedTokenSymbol: null,
|
|
1929
1933
|
amount: config.depositAmount != null ? config.depositAmount.toString() : "",
|
|
1930
1934
|
transfer: null,
|
|
1931
1935
|
creatingTransfer: false,
|
|
@@ -2020,7 +2024,8 @@ function paymentReducer(state, action) {
|
|
|
2020
2024
|
...state,
|
|
2021
2025
|
selectedProviderId: action.providerId,
|
|
2022
2026
|
selectedAccountId: null,
|
|
2023
|
-
selectedWalletId: null
|
|
2027
|
+
selectedWalletId: null,
|
|
2028
|
+
selectedTokenSymbol: null
|
|
2024
2029
|
};
|
|
2025
2030
|
case "SELECT_ACCOUNT":
|
|
2026
2031
|
return {
|
|
@@ -2029,6 +2034,13 @@ function paymentReducer(state, action) {
|
|
|
2029
2034
|
selectedWalletId: action.walletId,
|
|
2030
2035
|
step: "deposit"
|
|
2031
2036
|
};
|
|
2037
|
+
case "SELECT_TOKEN":
|
|
2038
|
+
return {
|
|
2039
|
+
...state,
|
|
2040
|
+
selectedWalletId: action.walletId,
|
|
2041
|
+
selectedTokenSymbol: action.tokenSymbol,
|
|
2042
|
+
step: "deposit"
|
|
2043
|
+
};
|
|
2032
2044
|
// ── Transfer lifecycle ───────────────────────────────────────
|
|
2033
2045
|
case "PAY_STARTED":
|
|
2034
2046
|
return {
|
|
@@ -4202,7 +4214,8 @@ function DepositScreen({
|
|
|
4202
4214
|
selectedAccountId,
|
|
4203
4215
|
onSelectAccount,
|
|
4204
4216
|
onAuthorizeAccount,
|
|
4205
|
-
onAddProvider
|
|
4217
|
+
onAddProvider,
|
|
4218
|
+
onSelectToken
|
|
4206
4219
|
}) {
|
|
4207
4220
|
const { tokens } = useSwypeConfig();
|
|
4208
4221
|
const amount = initialAmount;
|
|
@@ -4332,12 +4345,20 @@ function DepositScreen({
|
|
|
4332
4345
|
] })
|
|
4333
4346
|
] })
|
|
4334
4347
|
] }),
|
|
4335
|
-
tokenCount > 0 && /* @__PURE__ */ jsxs(
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4348
|
+
tokenCount > 0 && /* @__PURE__ */ jsxs(
|
|
4349
|
+
"button",
|
|
4350
|
+
{
|
|
4351
|
+
type: "button",
|
|
4352
|
+
onClick: onSelectToken,
|
|
4353
|
+
style: tokenBadgeButtonStyle2(tokens, !!onSelectToken),
|
|
4354
|
+
children: [
|
|
4355
|
+
/* @__PURE__ */ jsx("span", { style: tokenDotStyle2(tokens.accent) }),
|
|
4356
|
+
tokenCount,
|
|
4357
|
+
" ",
|
|
4358
|
+
/* @__PURE__ */ jsx("span", { style: chevronInlineStyle, children: ">" })
|
|
4359
|
+
]
|
|
4360
|
+
}
|
|
4361
|
+
)
|
|
4341
4362
|
] }),
|
|
4342
4363
|
/* @__PURE__ */ jsxs("div", { style: detailsStyle, children: [
|
|
4343
4364
|
/* @__PURE__ */ jsxs("div", { style: detailRowStyle(tokens.textMuted), children: [
|
|
@@ -4395,7 +4416,7 @@ var balanceAmountStyle = {
|
|
|
4395
4416
|
fontSize: "1rem",
|
|
4396
4417
|
fontWeight: 700
|
|
4397
4418
|
};
|
|
4398
|
-
var
|
|
4419
|
+
var tokenBadgeButtonStyle2 = (tokens, clickable) => ({
|
|
4399
4420
|
display: "flex",
|
|
4400
4421
|
alignItems: "center",
|
|
4401
4422
|
gap: 4,
|
|
@@ -4403,7 +4424,10 @@ var tokenBadgeStyle = (tokens) => ({
|
|
|
4403
4424
|
color: tokens.textMuted,
|
|
4404
4425
|
border: `1px solid ${tokens.border}`,
|
|
4405
4426
|
borderRadius: 999,
|
|
4406
|
-
padding: "4px 10px"
|
|
4427
|
+
padding: "4px 10px",
|
|
4428
|
+
background: "transparent",
|
|
4429
|
+
fontFamily: "inherit",
|
|
4430
|
+
cursor: clickable ? "pointer" : "default"
|
|
4407
4431
|
});
|
|
4408
4432
|
var tokenDotStyle2 = (color) => ({
|
|
4409
4433
|
width: 8,
|
|
@@ -4412,7 +4436,7 @@ var tokenDotStyle2 = (color) => ({
|
|
|
4412
4436
|
background: color,
|
|
4413
4437
|
display: "inline-block"
|
|
4414
4438
|
});
|
|
4415
|
-
var
|
|
4439
|
+
var chevronInlineStyle = { fontSize: "0.68rem", marginLeft: 2 };
|
|
4416
4440
|
var detailsStyle = {
|
|
4417
4441
|
textAlign: "center",
|
|
4418
4442
|
marginTop: 12,
|
|
@@ -5301,6 +5325,236 @@ var errorStyle2 = (color) => ({
|
|
|
5301
5325
|
color: "#ef4444",
|
|
5302
5326
|
margin: "8px 0 0"
|
|
5303
5327
|
});
|
|
5328
|
+
function TokenPickerScreen({
|
|
5329
|
+
account,
|
|
5330
|
+
chains,
|
|
5331
|
+
onSelectAuthorized,
|
|
5332
|
+
onAuthorizeToken,
|
|
5333
|
+
onBack
|
|
5334
|
+
}) {
|
|
5335
|
+
const { tokens: themeTokens } = useSwypeConfig();
|
|
5336
|
+
const [selectedIndex, setSelectedIndex] = useState(null);
|
|
5337
|
+
const entries = [];
|
|
5338
|
+
for (const wallet of account.wallets) {
|
|
5339
|
+
for (const source of wallet.sources) {
|
|
5340
|
+
entries.push({
|
|
5341
|
+
walletId: wallet.id,
|
|
5342
|
+
chainName: wallet.chain.name,
|
|
5343
|
+
tokenSymbol: source.token.symbol,
|
|
5344
|
+
tokenAddress: source.address,
|
|
5345
|
+
balance: source.balance.total.amount,
|
|
5346
|
+
status: source.token.status
|
|
5347
|
+
});
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
const selected = selectedIndex != null ? entries[selectedIndex] : null;
|
|
5351
|
+
const isAuthorized = selected?.status === "AUTHORIZED";
|
|
5352
|
+
const handleConfirm = () => {
|
|
5353
|
+
if (!selected) return;
|
|
5354
|
+
if (isAuthorized) {
|
|
5355
|
+
onSelectAuthorized(selected.walletId, selected.tokenSymbol);
|
|
5356
|
+
} else {
|
|
5357
|
+
const chain = chains.find((c) => c.name === selected.chainName);
|
|
5358
|
+
const evmChainId = chain?.commonId;
|
|
5359
|
+
if (evmChainId == null) return;
|
|
5360
|
+
onAuthorizeToken(selected.walletId, selected.tokenAddress, evmChainId, selected.tokenSymbol);
|
|
5361
|
+
}
|
|
5362
|
+
};
|
|
5363
|
+
const chainGroups = /* @__PURE__ */ new Map();
|
|
5364
|
+
for (const entry of entries) {
|
|
5365
|
+
const group = chainGroups.get(entry.chainName);
|
|
5366
|
+
if (group) {
|
|
5367
|
+
group.push(entry);
|
|
5368
|
+
} else {
|
|
5369
|
+
chainGroups.set(entry.chainName, [entry]);
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
const [expandedChain, setExpandedChain] = useState(
|
|
5373
|
+
entries.length > 0 ? entries[0].chainName : null
|
|
5374
|
+
);
|
|
5375
|
+
return /* @__PURE__ */ jsxs(
|
|
5376
|
+
ScreenLayout,
|
|
5377
|
+
{
|
|
5378
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5379
|
+
/* @__PURE__ */ jsx(
|
|
5380
|
+
PrimaryButton,
|
|
5381
|
+
{
|
|
5382
|
+
onClick: handleConfirm,
|
|
5383
|
+
disabled: selected == null,
|
|
5384
|
+
children: selected == null ? "Select a token" : isAuthorized ? "Select Source" : "Authorize Token"
|
|
5385
|
+
}
|
|
5386
|
+
),
|
|
5387
|
+
/* @__PURE__ */ jsx(PoweredByFooter, {})
|
|
5388
|
+
] }),
|
|
5389
|
+
children: [
|
|
5390
|
+
/* @__PURE__ */ jsx(ScreenHeader, { title: "Select Token", onBack }),
|
|
5391
|
+
/* @__PURE__ */ jsx("p", { style: subtitleStyle11(themeTokens.textSecondary), children: "Choose a token to deposit with. Tokens that haven't been authorized yet will require a one-time wallet approval." }),
|
|
5392
|
+
/* @__PURE__ */ jsx("div", { style: chainListStyle2, children: [...chainGroups.entries()].map(([chainName, chainEntries]) => {
|
|
5393
|
+
const isExpanded = expandedChain === chainName;
|
|
5394
|
+
const chainTotal = chainEntries.reduce((sum, e) => sum + e.balance, 0);
|
|
5395
|
+
return /* @__PURE__ */ jsxs("div", { style: chainCardStyle2(themeTokens), children: [
|
|
5396
|
+
/* @__PURE__ */ jsxs(
|
|
5397
|
+
"button",
|
|
5398
|
+
{
|
|
5399
|
+
type: "button",
|
|
5400
|
+
onClick: () => setExpandedChain((prev) => prev === chainName ? null : chainName),
|
|
5401
|
+
style: chainHeaderStyle2(themeTokens),
|
|
5402
|
+
children: [
|
|
5403
|
+
/* @__PURE__ */ jsxs("div", { style: chainHeaderLeftStyle2, children: [
|
|
5404
|
+
/* @__PURE__ */ jsx("span", { style: chainNameStyle2(themeTokens.text), children: chainName }),
|
|
5405
|
+
/* @__PURE__ */ jsxs("span", { style: chainBalanceStyle2(themeTokens.textMuted), children: [
|
|
5406
|
+
"$",
|
|
5407
|
+
chainTotal.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
5408
|
+
] })
|
|
5409
|
+
] }),
|
|
5410
|
+
/* @__PURE__ */ jsx("span", { style: chevronStyle2(themeTokens.textMuted), children: isExpanded ? "\u25BE" : "\u25B8" })
|
|
5411
|
+
]
|
|
5412
|
+
}
|
|
5413
|
+
),
|
|
5414
|
+
isExpanded && /* @__PURE__ */ jsx("div", { style: tokenListStyle2, children: chainEntries.map((entry) => {
|
|
5415
|
+
const globalIdx = entries.indexOf(entry);
|
|
5416
|
+
const isSelected = selectedIndex === globalIdx;
|
|
5417
|
+
const authorized = entry.status === "AUTHORIZED";
|
|
5418
|
+
return /* @__PURE__ */ jsxs(
|
|
5419
|
+
"button",
|
|
5420
|
+
{
|
|
5421
|
+
type: "button",
|
|
5422
|
+
onClick: () => setSelectedIndex(globalIdx),
|
|
5423
|
+
style: tokenRowStyle2(themeTokens, isSelected),
|
|
5424
|
+
children: [
|
|
5425
|
+
/* @__PURE__ */ jsxs("div", { style: tokenInfoStyle2, children: [
|
|
5426
|
+
/* @__PURE__ */ jsxs("div", { style: tokenHeaderRowStyle, children: [
|
|
5427
|
+
/* @__PURE__ */ jsx("span", { style: tokenSymbolStyle2(themeTokens.text), children: entry.tokenSymbol }),
|
|
5428
|
+
authorized ? /* @__PURE__ */ jsx("span", { style: statusBadgeStyle(themeTokens.success), children: "Authorized" }) : /* @__PURE__ */ jsx("span", { style: statusBadgeStyle(themeTokens.textMuted), children: "Not authorized" })
|
|
5429
|
+
] }),
|
|
5430
|
+
/* @__PURE__ */ jsxs("span", { style: tokenBalStyle2(themeTokens.textMuted), children: [
|
|
5431
|
+
"$",
|
|
5432
|
+
entry.balance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
5433
|
+
] })
|
|
5434
|
+
] }),
|
|
5435
|
+
/* @__PURE__ */ jsx("div", { style: radioStyle3(themeTokens, isSelected), children: isSelected && /* @__PURE__ */ jsx("div", { style: radioDotStyle3(themeTokens.accent) }) })
|
|
5436
|
+
]
|
|
5437
|
+
},
|
|
5438
|
+
`${entry.walletId}-${entry.tokenSymbol}`
|
|
5439
|
+
);
|
|
5440
|
+
}) })
|
|
5441
|
+
] }, chainName);
|
|
5442
|
+
}) })
|
|
5443
|
+
]
|
|
5444
|
+
}
|
|
5445
|
+
);
|
|
5446
|
+
}
|
|
5447
|
+
var subtitleStyle11 = (color) => ({
|
|
5448
|
+
fontSize: "0.86rem",
|
|
5449
|
+
color,
|
|
5450
|
+
margin: "0 0 20px",
|
|
5451
|
+
lineHeight: 1.5
|
|
5452
|
+
});
|
|
5453
|
+
var chainListStyle2 = {
|
|
5454
|
+
display: "flex",
|
|
5455
|
+
flexDirection: "column",
|
|
5456
|
+
gap: 10
|
|
5457
|
+
};
|
|
5458
|
+
var chainCardStyle2 = (tokens) => ({
|
|
5459
|
+
border: `1px solid ${tokens.border}`,
|
|
5460
|
+
borderRadius: 14,
|
|
5461
|
+
overflow: "hidden",
|
|
5462
|
+
background: tokens.bgInput
|
|
5463
|
+
});
|
|
5464
|
+
var chainHeaderStyle2 = (tokens) => ({
|
|
5465
|
+
display: "flex",
|
|
5466
|
+
alignItems: "center",
|
|
5467
|
+
justifyContent: "space-between",
|
|
5468
|
+
width: "100%",
|
|
5469
|
+
padding: "14px 16px",
|
|
5470
|
+
background: tokens.bgInput,
|
|
5471
|
+
border: "none",
|
|
5472
|
+
cursor: "pointer",
|
|
5473
|
+
fontFamily: "inherit",
|
|
5474
|
+
textAlign: "left"
|
|
5475
|
+
});
|
|
5476
|
+
var chainHeaderLeftStyle2 = {
|
|
5477
|
+
display: "flex",
|
|
5478
|
+
flexDirection: "column",
|
|
5479
|
+
gap: 2
|
|
5480
|
+
};
|
|
5481
|
+
var chainNameStyle2 = (color) => ({
|
|
5482
|
+
fontSize: "0.92rem",
|
|
5483
|
+
fontWeight: 600,
|
|
5484
|
+
color
|
|
5485
|
+
});
|
|
5486
|
+
var chainBalanceStyle2 = (color) => ({
|
|
5487
|
+
fontSize: "0.76rem",
|
|
5488
|
+
color
|
|
5489
|
+
});
|
|
5490
|
+
var chevronStyle2 = (color) => ({
|
|
5491
|
+
fontSize: "0.9rem",
|
|
5492
|
+
color
|
|
5493
|
+
});
|
|
5494
|
+
var tokenListStyle2 = {
|
|
5495
|
+
padding: "0 12px 12px",
|
|
5496
|
+
display: "flex",
|
|
5497
|
+
flexDirection: "column",
|
|
5498
|
+
gap: 6
|
|
5499
|
+
};
|
|
5500
|
+
var tokenRowStyle2 = (tokens, selected) => ({
|
|
5501
|
+
display: "flex",
|
|
5502
|
+
alignItems: "center",
|
|
5503
|
+
justifyContent: "space-between",
|
|
5504
|
+
padding: "12px 14px",
|
|
5505
|
+
background: tokens.bgCard,
|
|
5506
|
+
border: `1.5px solid ${selected ? tokens.accent : tokens.border}`,
|
|
5507
|
+
borderRadius: 10,
|
|
5508
|
+
cursor: "pointer",
|
|
5509
|
+
fontFamily: "inherit",
|
|
5510
|
+
textAlign: "left",
|
|
5511
|
+
transition: "border-color 0.15s ease"
|
|
5512
|
+
});
|
|
5513
|
+
var tokenInfoStyle2 = {
|
|
5514
|
+
display: "flex",
|
|
5515
|
+
flexDirection: "column",
|
|
5516
|
+
gap: 4,
|
|
5517
|
+
flex: 1
|
|
5518
|
+
};
|
|
5519
|
+
var tokenHeaderRowStyle = {
|
|
5520
|
+
display: "flex",
|
|
5521
|
+
alignItems: "center",
|
|
5522
|
+
gap: 8
|
|
5523
|
+
};
|
|
5524
|
+
var tokenSymbolStyle2 = (color) => ({
|
|
5525
|
+
fontSize: "0.88rem",
|
|
5526
|
+
fontWeight: 600,
|
|
5527
|
+
color
|
|
5528
|
+
});
|
|
5529
|
+
var statusBadgeStyle = (color) => ({
|
|
5530
|
+
fontSize: "0.65rem",
|
|
5531
|
+
fontWeight: 600,
|
|
5532
|
+
color,
|
|
5533
|
+
border: `1px solid ${color}44`,
|
|
5534
|
+
borderRadius: 999,
|
|
5535
|
+
padding: "1px 7px",
|
|
5536
|
+
letterSpacing: "0.02em"
|
|
5537
|
+
});
|
|
5538
|
+
var tokenBalStyle2 = (color) => ({
|
|
5539
|
+
fontSize: "0.74rem",
|
|
5540
|
+
color
|
|
5541
|
+
});
|
|
5542
|
+
var radioStyle3 = (tokens, selected) => ({
|
|
5543
|
+
width: 20,
|
|
5544
|
+
height: 20,
|
|
5545
|
+
borderRadius: "50%",
|
|
5546
|
+
border: `2px solid ${selected ? tokens.accent : tokens.border}`,
|
|
5547
|
+
display: "flex",
|
|
5548
|
+
alignItems: "center",
|
|
5549
|
+
justifyContent: "center",
|
|
5550
|
+
flexShrink: 0
|
|
5551
|
+
});
|
|
5552
|
+
var radioDotStyle3 = (color) => ({
|
|
5553
|
+
width: 10,
|
|
5554
|
+
height: 10,
|
|
5555
|
+
borderRadius: "50%",
|
|
5556
|
+
background: color
|
|
5557
|
+
});
|
|
5304
5558
|
function StepRenderer({
|
|
5305
5559
|
state,
|
|
5306
5560
|
ready,
|
|
@@ -5480,7 +5734,23 @@ function StepRenderer({
|
|
|
5480
5734
|
selectedAccountId: state.selectedAccountId,
|
|
5481
5735
|
onSelectAccount: handlers.onSelectAccount,
|
|
5482
5736
|
onAuthorizeAccount: handlers.onContinueConnection,
|
|
5483
|
-
onAddProvider: () => handlers.onNavigate("wallet-picker")
|
|
5737
|
+
onAddProvider: () => handlers.onNavigate("wallet-picker"),
|
|
5738
|
+
onSelectToken: handlers.onSelectToken
|
|
5739
|
+
}
|
|
5740
|
+
);
|
|
5741
|
+
}
|
|
5742
|
+
if (step === "token-picker") {
|
|
5743
|
+
if (!selectedAccount) {
|
|
5744
|
+
return /* @__PURE__ */ jsx(SwypeLoadingScreen, {});
|
|
5745
|
+
}
|
|
5746
|
+
return /* @__PURE__ */ jsx(
|
|
5747
|
+
TokenPickerScreen,
|
|
5748
|
+
{
|
|
5749
|
+
account: selectedAccount,
|
|
5750
|
+
chains: state.chains,
|
|
5751
|
+
onSelectAuthorized: handlers.onSelectAuthorizedToken,
|
|
5752
|
+
onAuthorizeToken: handlers.onAuthorizeToken,
|
|
5753
|
+
onBack: () => handlers.onNavigate("deposit")
|
|
5484
5754
|
}
|
|
5485
5755
|
);
|
|
5486
5756
|
}
|
|
@@ -5679,6 +5949,7 @@ function SwypePaymentInner({
|
|
|
5679
5949
|
const processingStartedAtRef = useRef(null);
|
|
5680
5950
|
const initializedSelectSourceActionRef = useRef(null);
|
|
5681
5951
|
const preSelectSourceStepRef = useRef(null);
|
|
5952
|
+
const pendingTokenAuthRef = useRef(null);
|
|
5682
5953
|
const checkingPasskeyRef = useRef(false);
|
|
5683
5954
|
const onCompleteRef = useRef(onComplete);
|
|
5684
5955
|
onCompleteRef.current = onComplete;
|
|
@@ -6106,6 +6377,84 @@ function SwypePaymentInner({
|
|
|
6106
6377
|
reloadAccounts,
|
|
6107
6378
|
onError
|
|
6108
6379
|
]);
|
|
6380
|
+
const handleNavigateToTokenPicker = useCallback(() => {
|
|
6381
|
+
dispatch({ type: "NAVIGATE", step: "token-picker" });
|
|
6382
|
+
}, []);
|
|
6383
|
+
const handleSelectAuthorizedToken = useCallback((walletId, tokenSymbol) => {
|
|
6384
|
+
dispatch({ type: "SELECT_TOKEN", walletId, tokenSymbol });
|
|
6385
|
+
}, []);
|
|
6386
|
+
const handleAuthorizeToken = useCallback(async (_walletId, tokenAddress, chainId, tokenSymbol) => {
|
|
6387
|
+
if (!state.selectedAccountId) {
|
|
6388
|
+
dispatch({ type: "SET_ERROR", error: "No account selected." });
|
|
6389
|
+
return;
|
|
6390
|
+
}
|
|
6391
|
+
if (!state.activeCredentialId) {
|
|
6392
|
+
dispatch({ type: "SET_ERROR", error: "Create a passkey on this device before continuing." });
|
|
6393
|
+
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6394
|
+
return;
|
|
6395
|
+
}
|
|
6396
|
+
const acct = state.accounts.find((a) => a.id === state.selectedAccountId);
|
|
6397
|
+
const matchedProvider = acct ? state.providers.find((p) => p.name === acct.name) : void 0;
|
|
6398
|
+
if (matchedProvider) {
|
|
6399
|
+
dispatch({ type: "SELECT_PROVIDER", providerId: matchedProvider.id });
|
|
6400
|
+
}
|
|
6401
|
+
dispatch({ type: "SET_ERROR", error: null });
|
|
6402
|
+
dispatch({ type: "SET_INCREASING_LIMIT", value: true });
|
|
6403
|
+
pendingTokenAuthRef.current = { tokenAddress, chainId, tokenSymbol, walletId: _walletId };
|
|
6404
|
+
try {
|
|
6405
|
+
const token = await getAccessToken();
|
|
6406
|
+
if (!token) throw new Error("Not authenticated");
|
|
6407
|
+
const session = await createAccountAuthorizationSession(
|
|
6408
|
+
apiBaseUrl,
|
|
6409
|
+
token,
|
|
6410
|
+
state.selectedAccountId,
|
|
6411
|
+
state.activeCredentialId,
|
|
6412
|
+
{ tokenAddress, chainId }
|
|
6413
|
+
);
|
|
6414
|
+
const isMobile = !shouldUseWalletConnector({
|
|
6415
|
+
useWalletConnector: useWalletConnectorProp,
|
|
6416
|
+
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
6417
|
+
});
|
|
6418
|
+
if (isMobile) {
|
|
6419
|
+
handlingMobileReturnRef.current = false;
|
|
6420
|
+
mobileSetupFlowRef.current = true;
|
|
6421
|
+
setupAccountIdRef.current = state.selectedAccountId;
|
|
6422
|
+
persistMobileFlowState({
|
|
6423
|
+
accountId: state.selectedAccountId,
|
|
6424
|
+
sessionId: session.id,
|
|
6425
|
+
deeplinkUri: session.uri,
|
|
6426
|
+
providerId: matchedProvider?.id ?? null,
|
|
6427
|
+
isSetup: true
|
|
6428
|
+
});
|
|
6429
|
+
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6430
|
+
triggerDeeplink(session.uri);
|
|
6431
|
+
} else {
|
|
6432
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6433
|
+
await authExecutor.executeSessionById(session.id);
|
|
6434
|
+
await reloadAccounts();
|
|
6435
|
+
dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
|
|
6436
|
+
}
|
|
6437
|
+
} catch (err) {
|
|
6438
|
+
captureException(err);
|
|
6439
|
+
const msg = err instanceof Error ? err.message : "Failed to authorize token";
|
|
6440
|
+
dispatch({ type: "SET_ERROR", error: msg });
|
|
6441
|
+
onError?.(msg);
|
|
6442
|
+
} finally {
|
|
6443
|
+
pendingTokenAuthRef.current = null;
|
|
6444
|
+
dispatch({ type: "SET_INCREASING_LIMIT", value: false });
|
|
6445
|
+
}
|
|
6446
|
+
}, [
|
|
6447
|
+
state.selectedAccountId,
|
|
6448
|
+
state.activeCredentialId,
|
|
6449
|
+
state.accounts,
|
|
6450
|
+
state.providers,
|
|
6451
|
+
apiBaseUrl,
|
|
6452
|
+
getAccessToken,
|
|
6453
|
+
authExecutor,
|
|
6454
|
+
useWalletConnectorProp,
|
|
6455
|
+
reloadAccounts,
|
|
6456
|
+
onError
|
|
6457
|
+
]);
|
|
6109
6458
|
const handleConfirmSign = useCallback(async () => {
|
|
6110
6459
|
const t = state.transfer ?? polling.transfer;
|
|
6111
6460
|
if (!t) return;
|
|
@@ -6695,6 +7044,21 @@ function SwypePaymentInner({
|
|
|
6695
7044
|
preSelectSourceStepRef.current = null;
|
|
6696
7045
|
}
|
|
6697
7046
|
}, [pendingSelectSourceAction, state.step]);
|
|
7047
|
+
useEffect(() => {
|
|
7048
|
+
if (!pendingSelectSourceAction || !pendingTokenAuthRef.current) return;
|
|
7049
|
+
const { tokenAddress, chainId } = pendingTokenAuthRef.current;
|
|
7050
|
+
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
7051
|
+
const options = pendingSelectSourceAction.metadata?.options ?? [];
|
|
7052
|
+
const match = options.find(
|
|
7053
|
+
(opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
|
|
7054
|
+
);
|
|
7055
|
+
if (match) {
|
|
7056
|
+
authExecutor.resolveSelectSource({
|
|
7057
|
+
chainName: match.chainName,
|
|
7058
|
+
tokenSymbol: match.tokenSymbol
|
|
7059
|
+
});
|
|
7060
|
+
}
|
|
7061
|
+
}, [pendingSelectSourceAction, authExecutor]);
|
|
6698
7062
|
const handlers = useMemo(() => ({
|
|
6699
7063
|
onSendLoginCode: handleSendLoginCode,
|
|
6700
7064
|
onVerifyLoginCode: handleVerifyLoginCode,
|
|
@@ -6724,7 +7088,10 @@ function SwypePaymentInner({
|
|
|
6724
7088
|
onSelectSourceChainChange: handleSelectSourceChainChange,
|
|
6725
7089
|
onSetSelectSourceTokenSymbol: setSelectSourceTokenSymbol,
|
|
6726
7090
|
onConfirmSelectSource: handleConfirmSelectSource,
|
|
6727
|
-
onSetupOneTap: handleSetupOneTap
|
|
7091
|
+
onSetupOneTap: handleSetupOneTap,
|
|
7092
|
+
onSelectToken: handleNavigateToTokenPicker,
|
|
7093
|
+
onSelectAuthorizedToken: handleSelectAuthorizedToken,
|
|
7094
|
+
onAuthorizeToken: handleAuthorizeToken
|
|
6728
7095
|
}), [
|
|
6729
7096
|
handleSendLoginCode,
|
|
6730
7097
|
handleVerifyLoginCode,
|
|
@@ -6743,7 +7110,10 @@ function SwypePaymentInner({
|
|
|
6743
7110
|
handleNewPayment,
|
|
6744
7111
|
handleSelectSourceChainChange,
|
|
6745
7112
|
handleConfirmSelectSource,
|
|
6746
|
-
handleSetupOneTap
|
|
7113
|
+
handleSetupOneTap,
|
|
7114
|
+
handleNavigateToTokenPicker,
|
|
7115
|
+
handleSelectAuthorizedToken,
|
|
7116
|
+
handleAuthorizeToken
|
|
6747
7117
|
]);
|
|
6748
7118
|
return /* @__PURE__ */ jsx(
|
|
6749
7119
|
StepRenderer,
|
|
@@ -6781,6 +7151,6 @@ function SwypePaymentInner({
|
|
|
6781
7151
|
);
|
|
6782
7152
|
}
|
|
6783
7153
|
|
|
6784
|
-
export { AdvancedSourceScreen, CreatePasskeyScreen, IconCircle, InfoBanner, OutlineButton, PasskeyIframeBlockedError, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, SwypeLoadingScreen, SwypePayment, SwypeProvider, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
|
7154
|
+
export { AdvancedSourceScreen, CreatePasskeyScreen, IconCircle, InfoBanner, OutlineButton, PasskeyIframeBlockedError, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, SwypeLoadingScreen, SwypePayment, SwypeProvider, TokenPickerScreen, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
|
6785
7155
|
//# sourceMappingURL=index.js.map
|
|
6786
7156
|
//# sourceMappingURL=index.js.map
|