@swype-org/react-sdk 0.1.110 → 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 +596 -56
- 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 +596 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 {
|
|
@@ -3813,7 +3825,7 @@ var dividerTextStyle = (color) => ({
|
|
|
3813
3825
|
whiteSpace: "nowrap"
|
|
3814
3826
|
});
|
|
3815
3827
|
var DEFAULT_MAX = 500;
|
|
3816
|
-
var ABSOLUTE_MIN =
|
|
3828
|
+
var ABSOLUTE_MIN = 0.01;
|
|
3817
3829
|
function SetupScreen({
|
|
3818
3830
|
availableBalance,
|
|
3819
3831
|
tokenCount,
|
|
@@ -3827,7 +3839,7 @@ function SetupScreen({
|
|
|
3827
3839
|
error
|
|
3828
3840
|
}) {
|
|
3829
3841
|
const { tokens } = useSwypeConfig();
|
|
3830
|
-
const effectiveMax =
|
|
3842
|
+
const effectiveMax = DEFAULT_MAX;
|
|
3831
3843
|
const effectiveMin = Math.min(ABSOLUTE_MIN, effectiveMax);
|
|
3832
3844
|
const [limit, setLimit] = useState(() => effectiveMax);
|
|
3833
3845
|
const [editing, setEditing] = useState(false);
|
|
@@ -3921,11 +3933,15 @@ function SetupScreen({
|
|
|
3921
3933
|
] }) : /* @__PURE__ */ jsxs(
|
|
3922
3934
|
"div",
|
|
3923
3935
|
{
|
|
3924
|
-
style:
|
|
3936
|
+
style: editableLimitStyle(tokens.text),
|
|
3925
3937
|
onClick: startEditing,
|
|
3926
3938
|
children: [
|
|
3927
3939
|
"$",
|
|
3928
|
-
limit.toFixed(2)
|
|
3940
|
+
limit.toFixed(2),
|
|
3941
|
+
/* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", style: pencilIconStyle(tokens.textMuted), children: [
|
|
3942
|
+
/* @__PURE__ */ jsx("path", { d: "M16.474 5.408l2.118 2.117m-.756-3.982L12.109 9.27a2.118 2.118 0 00-.58 1.082L11 13l2.648-.53c.41-.082.786-.283 1.082-.579l5.727-5.727a1.853 1.853 0 10-2.621-2.621z", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
3943
|
+
/* @__PURE__ */ jsx("path", { d: "M19 15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V6a2 2 0 012-2h3", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
3944
|
+
] })
|
|
3929
3945
|
]
|
|
3930
3946
|
}
|
|
3931
3947
|
)
|
|
@@ -4033,6 +4049,18 @@ var limitValueStyle = (color) => ({
|
|
|
4033
4049
|
color,
|
|
4034
4050
|
marginBottom: 12
|
|
4035
4051
|
});
|
|
4052
|
+
var editableLimitStyle = (color) => ({
|
|
4053
|
+
...limitValueStyle(color),
|
|
4054
|
+
cursor: "pointer",
|
|
4055
|
+
display: "inline-flex",
|
|
4056
|
+
alignItems: "center",
|
|
4057
|
+
gap: 6
|
|
4058
|
+
});
|
|
4059
|
+
var pencilIconStyle = (color) => ({
|
|
4060
|
+
color,
|
|
4061
|
+
opacity: 0.6,
|
|
4062
|
+
flexShrink: 0
|
|
4063
|
+
});
|
|
4036
4064
|
var limitInputStyle = (color) => ({
|
|
4037
4065
|
fontSize: "2.2rem",
|
|
4038
4066
|
fontWeight: 700,
|
|
@@ -4060,6 +4088,108 @@ var linkStyle = (color) => ({
|
|
|
4060
4088
|
padding: 0,
|
|
4061
4089
|
marginBottom: 16
|
|
4062
4090
|
});
|
|
4091
|
+
function SetupStatusScreen({
|
|
4092
|
+
complete,
|
|
4093
|
+
limit,
|
|
4094
|
+
tokensApproved,
|
|
4095
|
+
merchantName,
|
|
4096
|
+
onContinue,
|
|
4097
|
+
onLogout,
|
|
4098
|
+
error
|
|
4099
|
+
}) {
|
|
4100
|
+
const { tokens } = useSwypeConfig();
|
|
4101
|
+
const steps = complete ? [
|
|
4102
|
+
{
|
|
4103
|
+
label: "One-Tap ready",
|
|
4104
|
+
detail: `$${limit} limit \xB7 ${tokensApproved} token${tokensApproved !== 1 ? "s" : ""} approved`,
|
|
4105
|
+
status: "complete"
|
|
4106
|
+
},
|
|
4107
|
+
{ label: "Done", status: "complete" }
|
|
4108
|
+
] : [
|
|
4109
|
+
{
|
|
4110
|
+
label: "Setting up Wallet",
|
|
4111
|
+
status: "active"
|
|
4112
|
+
},
|
|
4113
|
+
{ label: "Done", status: "pending" }
|
|
4114
|
+
];
|
|
4115
|
+
return /* @__PURE__ */ jsxs(
|
|
4116
|
+
ScreenLayout,
|
|
4117
|
+
{
|
|
4118
|
+
footer: complete ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4119
|
+
/* @__PURE__ */ jsx(PrimaryButton, { onClick: onContinue, children: merchantName ? `Return to ${merchantName}` : "Continue" }),
|
|
4120
|
+
/* @__PURE__ */ jsx("p", { style: swipeHintStyle(tokens.textMuted), children: "Swipe to deposit \u2014 no approvals needed." })
|
|
4121
|
+
] }) : void 0,
|
|
4122
|
+
children: [
|
|
4123
|
+
/* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
|
|
4124
|
+
/* @__PURE__ */ jsxs("div", { style: contentStyle5, children: [
|
|
4125
|
+
complete ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4126
|
+
/* @__PURE__ */ jsx(IconCircle, { variant: "success", size: 64, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z", fill: tokens.success }) }) }),
|
|
4127
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle6(tokens.text), children: "You're all set!" })
|
|
4128
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4129
|
+
/* @__PURE__ */ jsx(Spinner, { size: 48 }),
|
|
4130
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle6(tokens.text), children: "Setting up One-Tap..." })
|
|
4131
|
+
] }),
|
|
4132
|
+
error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle4(tokens), children: error }),
|
|
4133
|
+
/* @__PURE__ */ jsx("div", { style: stepsWrapStyle, children: /* @__PURE__ */ jsx(StepList, { steps }) }),
|
|
4134
|
+
!complete && /* @__PURE__ */ jsx("p", { style: waitHintStyle(tokens.textMuted), children: "Usually takes a few seconds" }),
|
|
4135
|
+
complete && /* @__PURE__ */ jsx("p", { style: readyHintStyle(tokens.textSecondary), children: "You can now deposit instantly from any partner app." })
|
|
4136
|
+
] })
|
|
4137
|
+
]
|
|
4138
|
+
}
|
|
4139
|
+
);
|
|
4140
|
+
}
|
|
4141
|
+
var contentStyle5 = {
|
|
4142
|
+
flex: 1,
|
|
4143
|
+
display: "flex",
|
|
4144
|
+
flexDirection: "column",
|
|
4145
|
+
alignItems: "center",
|
|
4146
|
+
justifyContent: "center",
|
|
4147
|
+
textAlign: "center",
|
|
4148
|
+
padding: "0 24px 32px"
|
|
4149
|
+
};
|
|
4150
|
+
var headingStyle6 = (color) => ({
|
|
4151
|
+
fontSize: "1.45rem",
|
|
4152
|
+
fontWeight: 700,
|
|
4153
|
+
letterSpacing: "-0.02em",
|
|
4154
|
+
color,
|
|
4155
|
+
margin: "20px 0 16px"
|
|
4156
|
+
});
|
|
4157
|
+
var errorBannerStyle4 = (tokens) => ({
|
|
4158
|
+
background: tokens.errorBg,
|
|
4159
|
+
border: `1px solid ${tokens.error}66`,
|
|
4160
|
+
borderRadius: 16,
|
|
4161
|
+
padding: "11px 14px",
|
|
4162
|
+
color: tokens.error,
|
|
4163
|
+
fontSize: "0.84rem",
|
|
4164
|
+
marginBottom: 14,
|
|
4165
|
+
lineHeight: 1.5,
|
|
4166
|
+
width: "100%",
|
|
4167
|
+
textAlign: "left"
|
|
4168
|
+
});
|
|
4169
|
+
var stepsWrapStyle = {
|
|
4170
|
+
width: "100%",
|
|
4171
|
+
maxWidth: 280,
|
|
4172
|
+
textAlign: "left",
|
|
4173
|
+
marginBottom: 16
|
|
4174
|
+
};
|
|
4175
|
+
var waitHintStyle = (color) => ({
|
|
4176
|
+
fontSize: "0.82rem",
|
|
4177
|
+
color,
|
|
4178
|
+
margin: 0
|
|
4179
|
+
});
|
|
4180
|
+
var readyHintStyle = (color) => ({
|
|
4181
|
+
fontSize: "0.88rem",
|
|
4182
|
+
color,
|
|
4183
|
+
margin: "8px 0 0",
|
|
4184
|
+
lineHeight: 1.5,
|
|
4185
|
+
maxWidth: 280
|
|
4186
|
+
});
|
|
4187
|
+
var swipeHintStyle = (color) => ({
|
|
4188
|
+
textAlign: "center",
|
|
4189
|
+
fontSize: "0.8rem",
|
|
4190
|
+
color,
|
|
4191
|
+
margin: "12px 0 0"
|
|
4192
|
+
});
|
|
4063
4193
|
var MIN_DEPOSIT = 0.25;
|
|
4064
4194
|
function DepositScreen({
|
|
4065
4195
|
merchantName,
|
|
@@ -4084,7 +4214,8 @@ function DepositScreen({
|
|
|
4084
4214
|
selectedAccountId,
|
|
4085
4215
|
onSelectAccount,
|
|
4086
4216
|
onAuthorizeAccount,
|
|
4087
|
-
onAddProvider
|
|
4217
|
+
onAddProvider,
|
|
4218
|
+
onSelectToken
|
|
4088
4219
|
}) {
|
|
4089
4220
|
const { tokens } = useSwypeConfig();
|
|
4090
4221
|
const amount = initialAmount;
|
|
@@ -4214,12 +4345,20 @@ function DepositScreen({
|
|
|
4214
4345
|
] })
|
|
4215
4346
|
] })
|
|
4216
4347
|
] }),
|
|
4217
|
-
tokenCount > 0 && /* @__PURE__ */ jsxs(
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
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
|
+
)
|
|
4223
4362
|
] }),
|
|
4224
4363
|
/* @__PURE__ */ jsxs("div", { style: detailsStyle, children: [
|
|
4225
4364
|
/* @__PURE__ */ jsxs("div", { style: detailRowStyle(tokens.textMuted), children: [
|
|
@@ -4237,7 +4376,7 @@ function DepositScreen({
|
|
|
4237
4376
|
"%)"
|
|
4238
4377
|
] }) : /* @__PURE__ */ jsx("div", { style: detailRowStyle(tokens.textMuted), children: "Fees calculated at time of transfer" })
|
|
4239
4378
|
] }),
|
|
4240
|
-
error && /* @__PURE__ */ jsx("div", { style:
|
|
4379
|
+
error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle5(tokens), children: error })
|
|
4241
4380
|
]
|
|
4242
4381
|
}
|
|
4243
4382
|
);
|
|
@@ -4277,7 +4416,7 @@ var balanceAmountStyle = {
|
|
|
4277
4416
|
fontSize: "1rem",
|
|
4278
4417
|
fontWeight: 700
|
|
4279
4418
|
};
|
|
4280
|
-
var
|
|
4419
|
+
var tokenBadgeButtonStyle2 = (tokens, clickable) => ({
|
|
4281
4420
|
display: "flex",
|
|
4282
4421
|
alignItems: "center",
|
|
4283
4422
|
gap: 4,
|
|
@@ -4285,7 +4424,10 @@ var tokenBadgeStyle = (tokens) => ({
|
|
|
4285
4424
|
color: tokens.textMuted,
|
|
4286
4425
|
border: `1px solid ${tokens.border}`,
|
|
4287
4426
|
borderRadius: 999,
|
|
4288
|
-
padding: "4px 10px"
|
|
4427
|
+
padding: "4px 10px",
|
|
4428
|
+
background: "transparent",
|
|
4429
|
+
fontFamily: "inherit",
|
|
4430
|
+
cursor: clickable ? "pointer" : "default"
|
|
4289
4431
|
});
|
|
4290
4432
|
var tokenDotStyle2 = (color) => ({
|
|
4291
4433
|
width: 8,
|
|
@@ -4294,7 +4436,7 @@ var tokenDotStyle2 = (color) => ({
|
|
|
4294
4436
|
background: color,
|
|
4295
4437
|
display: "inline-block"
|
|
4296
4438
|
});
|
|
4297
|
-
var
|
|
4439
|
+
var chevronInlineStyle = { fontSize: "0.68rem", marginLeft: 2 };
|
|
4298
4440
|
var detailsStyle = {
|
|
4299
4441
|
textAlign: "center",
|
|
4300
4442
|
marginTop: 12,
|
|
@@ -4305,7 +4447,7 @@ var detailRowStyle = (color) => ({
|
|
|
4305
4447
|
color,
|
|
4306
4448
|
marginBottom: 4
|
|
4307
4449
|
});
|
|
4308
|
-
var
|
|
4450
|
+
var errorBannerStyle5 = (tokens) => ({
|
|
4309
4451
|
background: tokens.errorBg,
|
|
4310
4452
|
border: `1px solid ${tokens.error}66`,
|
|
4311
4453
|
borderRadius: 16,
|
|
@@ -4404,10 +4546,10 @@ function SuccessScreen({
|
|
|
4404
4546
|
right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout })
|
|
4405
4547
|
}
|
|
4406
4548
|
),
|
|
4407
|
-
/* @__PURE__ */ jsxs("div", { style:
|
|
4549
|
+
/* @__PURE__ */ jsxs("div", { style: contentStyle6, children: [
|
|
4408
4550
|
succeeded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4409
4551
|
/* @__PURE__ */ jsx(IconCircle, { variant: "success", size: 64, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z", fill: tokens.success }) }) }),
|
|
4410
|
-
/* @__PURE__ */ jsxs("h2", { style:
|
|
4552
|
+
/* @__PURE__ */ jsxs("h2", { style: headingStyle7(tokens.text), children: [
|
|
4411
4553
|
"$",
|
|
4412
4554
|
amount.toFixed(2),
|
|
4413
4555
|
" deposited"
|
|
@@ -4418,7 +4560,7 @@ function SuccessScreen({
|
|
|
4418
4560
|
] })
|
|
4419
4561
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4420
4562
|
/* @__PURE__ */ jsx(IconCircle, { variant: "error", size: 64, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z", fill: tokens.error }) }) }),
|
|
4421
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
4563
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle7(tokens.text), children: "Transfer failed" }),
|
|
4422
4564
|
error && /* @__PURE__ */ jsx("p", { style: subtitleStyle6(tokens.error), children: error })
|
|
4423
4565
|
] }),
|
|
4424
4566
|
/* @__PURE__ */ jsxs("div", { style: summaryCardStyle(tokens), children: [
|
|
@@ -4451,14 +4593,14 @@ function SuccessScreen({
|
|
|
4451
4593
|
}
|
|
4452
4594
|
);
|
|
4453
4595
|
}
|
|
4454
|
-
var
|
|
4596
|
+
var contentStyle6 = {
|
|
4455
4597
|
flex: 1,
|
|
4456
4598
|
display: "flex",
|
|
4457
4599
|
flexDirection: "column",
|
|
4458
4600
|
alignItems: "center",
|
|
4459
4601
|
paddingTop: 16
|
|
4460
4602
|
};
|
|
4461
|
-
var
|
|
4603
|
+
var headingStyle7 = (color) => ({
|
|
4462
4604
|
fontSize: "1.5rem",
|
|
4463
4605
|
fontWeight: 700,
|
|
4464
4606
|
letterSpacing: "-0.02em",
|
|
@@ -4743,7 +4885,7 @@ function AdvancedSourceScreen({
|
|
|
4743
4885
|
right: /* @__PURE__ */ jsx("span", { style: advancedBadgeStyle(tokens.accent), children: "Advanced" })
|
|
4744
4886
|
}
|
|
4745
4887
|
),
|
|
4746
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
4888
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle8(tokens.text), children: "Set up One-Tap deposits" }),
|
|
4747
4889
|
/* @__PURE__ */ jsx("p", { style: subtitleStyle8(tokens.textSecondary), children: "Select a token source for your One-Tap deposits." }),
|
|
4748
4890
|
/* @__PURE__ */ jsx("label", { style: labelStyle3(tokens.textSecondary), children: "Select tokens to approve" }),
|
|
4749
4891
|
/* @__PURE__ */ jsx("div", { style: chainListStyle, children: choices.map((chain) => {
|
|
@@ -4807,7 +4949,7 @@ var advancedBadgeStyle = (color) => ({
|
|
|
4807
4949
|
padding: "3px 10px",
|
|
4808
4950
|
letterSpacing: "0.02em"
|
|
4809
4951
|
});
|
|
4810
|
-
var
|
|
4952
|
+
var headingStyle8 = (color) => ({
|
|
4811
4953
|
fontSize: "1.3rem",
|
|
4812
4954
|
fontWeight: 700,
|
|
4813
4955
|
letterSpacing: "-0.02em",
|
|
@@ -4942,16 +5084,16 @@ function TransferStatusScreen({
|
|
|
4942
5084
|
const steps = buildSteps(phase);
|
|
4943
5085
|
return /* @__PURE__ */ jsxs(ScreenLayout, { children: [
|
|
4944
5086
|
/* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
|
|
4945
|
-
/* @__PURE__ */ jsxs("div", { style:
|
|
5087
|
+
/* @__PURE__ */ jsxs("div", { style: contentStyle7, children: [
|
|
4946
5088
|
/* @__PURE__ */ jsx(Spinner, { size: 48 }),
|
|
4947
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
4948
|
-
error && /* @__PURE__ */ jsx("div", { style:
|
|
4949
|
-
/* @__PURE__ */ jsx("div", { style:
|
|
4950
|
-
/* @__PURE__ */ jsx("p", { style:
|
|
5089
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle9(tokens.text), children: "Processing Transfer..." }),
|
|
5090
|
+
error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle6(tokens), children: error }),
|
|
5091
|
+
/* @__PURE__ */ jsx("div", { style: stepsWrapStyle2, children: /* @__PURE__ */ jsx(StepList, { steps }) }),
|
|
5092
|
+
/* @__PURE__ */ jsx("p", { style: waitHintStyle2(tokens.textMuted), children: "Usually takes a few seconds" })
|
|
4951
5093
|
] })
|
|
4952
5094
|
] });
|
|
4953
5095
|
}
|
|
4954
|
-
var
|
|
5096
|
+
var contentStyle7 = {
|
|
4955
5097
|
flex: 1,
|
|
4956
5098
|
display: "flex",
|
|
4957
5099
|
flexDirection: "column",
|
|
@@ -4960,14 +5102,14 @@ var contentStyle6 = {
|
|
|
4960
5102
|
textAlign: "center",
|
|
4961
5103
|
padding: "0 24px"
|
|
4962
5104
|
};
|
|
4963
|
-
var
|
|
5105
|
+
var headingStyle9 = (color) => ({
|
|
4964
5106
|
fontSize: "1.45rem",
|
|
4965
5107
|
fontWeight: 700,
|
|
4966
5108
|
letterSpacing: "-0.02em",
|
|
4967
5109
|
color,
|
|
4968
5110
|
margin: "20px 0 16px"
|
|
4969
5111
|
});
|
|
4970
|
-
var
|
|
5112
|
+
var errorBannerStyle6 = (tokens) => ({
|
|
4971
5113
|
background: tokens.errorBg,
|
|
4972
5114
|
border: `1px solid ${tokens.error}66`,
|
|
4973
5115
|
borderRadius: 16,
|
|
@@ -4979,13 +5121,13 @@ var errorBannerStyle5 = (tokens) => ({
|
|
|
4979
5121
|
width: "100%",
|
|
4980
5122
|
textAlign: "left"
|
|
4981
5123
|
});
|
|
4982
|
-
var
|
|
5124
|
+
var stepsWrapStyle2 = {
|
|
4983
5125
|
width: "100%",
|
|
4984
5126
|
maxWidth: 280,
|
|
4985
5127
|
textAlign: "left",
|
|
4986
5128
|
marginBottom: 16
|
|
4987
5129
|
};
|
|
4988
|
-
var
|
|
5130
|
+
var waitHintStyle2 = (color) => ({
|
|
4989
5131
|
fontSize: "0.82rem",
|
|
4990
5132
|
color,
|
|
4991
5133
|
margin: 0
|
|
@@ -5027,9 +5169,9 @@ function OpenWalletScreen({
|
|
|
5027
5169
|
] }),
|
|
5028
5170
|
children: [
|
|
5029
5171
|
/* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
|
|
5030
|
-
/* @__PURE__ */ jsxs("div", { style:
|
|
5172
|
+
/* @__PURE__ */ jsxs("div", { style: contentStyle8, children: [
|
|
5031
5173
|
logoSrc ? /* @__PURE__ */ jsx("img", { src: logoSrc, alt: displayName, style: logoStyle }) : /* @__PURE__ */ jsx(Spinner, { size: 48 }),
|
|
5032
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
5174
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle10(tokens.text), children: loading ? "Connecting..." : `Open ${displayName}` }),
|
|
5033
5175
|
/* @__PURE__ */ jsx("p", { style: subtitleStyle9(tokens.textSecondary), children: loading ? "Creating transfer and preparing your wallet link..." : `Continue in ${displayName} to authorize this connection.` }),
|
|
5034
5176
|
!loading && /* @__PURE__ */ jsxs("div", { style: waitingBadgeStyle(tokens), children: [
|
|
5035
5177
|
/* @__PURE__ */ jsx(Spinner, { size: 14 }),
|
|
@@ -5040,7 +5182,7 @@ function OpenWalletScreen({
|
|
|
5040
5182
|
}
|
|
5041
5183
|
);
|
|
5042
5184
|
}
|
|
5043
|
-
var
|
|
5185
|
+
var contentStyle8 = {
|
|
5044
5186
|
flex: 1,
|
|
5045
5187
|
display: "flex",
|
|
5046
5188
|
flexDirection: "column",
|
|
@@ -5060,7 +5202,7 @@ var logoStyle = {
|
|
|
5060
5202
|
borderRadius: 14,
|
|
5061
5203
|
objectFit: "contain"
|
|
5062
5204
|
};
|
|
5063
|
-
var
|
|
5205
|
+
var headingStyle10 = (color) => ({
|
|
5064
5206
|
fontSize: "1.45rem",
|
|
5065
5207
|
fontWeight: 700,
|
|
5066
5208
|
letterSpacing: "-0.02em",
|
|
@@ -5111,9 +5253,9 @@ function ConfirmSignScreen({
|
|
|
5111
5253
|
] }),
|
|
5112
5254
|
children: [
|
|
5113
5255
|
/* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
|
|
5114
|
-
/* @__PURE__ */ jsxs("div", { style:
|
|
5256
|
+
/* @__PURE__ */ jsxs("div", { style: contentStyle9, children: [
|
|
5115
5257
|
logoSrc ? /* @__PURE__ */ jsx("img", { src: logoSrc, alt: displayName, style: logoStyle2 }) : /* @__PURE__ */ jsx(Spinner, { size: 48 }),
|
|
5116
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
5258
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle11(tokens.text), children: "Wallet authorized" }),
|
|
5117
5259
|
/* @__PURE__ */ jsxs("p", { style: subtitleStyle10(tokens.textSecondary), children: [
|
|
5118
5260
|
displayName,
|
|
5119
5261
|
" approved the connection. Tap below to confirm your payment."
|
|
@@ -5127,7 +5269,7 @@ function ConfirmSignScreen({
|
|
|
5127
5269
|
}
|
|
5128
5270
|
);
|
|
5129
5271
|
}
|
|
5130
|
-
var
|
|
5272
|
+
var contentStyle9 = {
|
|
5131
5273
|
flex: 1,
|
|
5132
5274
|
display: "flex",
|
|
5133
5275
|
flexDirection: "column",
|
|
@@ -5142,7 +5284,7 @@ var logoStyle2 = {
|
|
|
5142
5284
|
borderRadius: 14,
|
|
5143
5285
|
objectFit: "contain"
|
|
5144
5286
|
};
|
|
5145
|
-
var
|
|
5287
|
+
var headingStyle11 = (color) => ({
|
|
5146
5288
|
fontSize: "1.45rem",
|
|
5147
5289
|
fontWeight: 700,
|
|
5148
5290
|
letterSpacing: "-0.02em",
|
|
@@ -5183,6 +5325,236 @@ var errorStyle2 = (color) => ({
|
|
|
5183
5325
|
color: "#ef4444",
|
|
5184
5326
|
margin: "8px 0 0"
|
|
5185
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
|
+
});
|
|
5186
5558
|
function StepRenderer({
|
|
5187
5559
|
state,
|
|
5188
5560
|
ready,
|
|
@@ -5292,6 +5664,35 @@ function StepRenderer({
|
|
|
5292
5664
|
}
|
|
5293
5665
|
);
|
|
5294
5666
|
}
|
|
5667
|
+
if (step === "setup-status") {
|
|
5668
|
+
return /* @__PURE__ */ jsx(
|
|
5669
|
+
SetupStatusScreen,
|
|
5670
|
+
{
|
|
5671
|
+
complete: false,
|
|
5672
|
+
limit: state.oneTapLimit,
|
|
5673
|
+
tokensApproved: 0,
|
|
5674
|
+
merchantName,
|
|
5675
|
+
onContinue: () => handlers.onNavigate("setup"),
|
|
5676
|
+
onLogout: handlers.onLogout,
|
|
5677
|
+
error: state.error || authExecutorError
|
|
5678
|
+
}
|
|
5679
|
+
);
|
|
5680
|
+
}
|
|
5681
|
+
if (step === "setup") {
|
|
5682
|
+
return /* @__PURE__ */ jsx(
|
|
5683
|
+
SetupScreen,
|
|
5684
|
+
{
|
|
5685
|
+
availableBalance: selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
|
|
5686
|
+
tokenCount,
|
|
5687
|
+
sourceName,
|
|
5688
|
+
onSetupOneTap: handlers.onSetupOneTap,
|
|
5689
|
+
onBack: () => handlers.onNavigate("deposit"),
|
|
5690
|
+
onLogout: handlers.onLogout,
|
|
5691
|
+
loading: state.creatingTransfer,
|
|
5692
|
+
error: state.error
|
|
5693
|
+
}
|
|
5694
|
+
);
|
|
5695
|
+
}
|
|
5295
5696
|
if (step === "confirm-sign") {
|
|
5296
5697
|
const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
|
|
5297
5698
|
return /* @__PURE__ */ jsx(
|
|
@@ -5333,7 +5734,23 @@ function StepRenderer({
|
|
|
5333
5734
|
selectedAccountId: state.selectedAccountId,
|
|
5334
5735
|
onSelectAccount: handlers.onSelectAccount,
|
|
5335
5736
|
onAuthorizeAccount: handlers.onContinueConnection,
|
|
5336
|
-
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")
|
|
5337
5754
|
}
|
|
5338
5755
|
);
|
|
5339
5756
|
}
|
|
@@ -5440,7 +5857,7 @@ var PaymentErrorBoundary = class extends Component {
|
|
|
5440
5857
|
/* @__PURE__ */ jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
5441
5858
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
|
|
5442
5859
|
] }) }),
|
|
5443
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
5860
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle12, children: "Something went wrong" }),
|
|
5444
5861
|
/* @__PURE__ */ jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
|
|
5445
5862
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
|
|
5446
5863
|
] });
|
|
@@ -5460,7 +5877,7 @@ var containerStyle8 = {
|
|
|
5460
5877
|
var iconStyle4 = {
|
|
5461
5878
|
marginBottom: 20
|
|
5462
5879
|
};
|
|
5463
|
-
var
|
|
5880
|
+
var headingStyle12 = {
|
|
5464
5881
|
fontSize: "1.25rem",
|
|
5465
5882
|
fontWeight: 700,
|
|
5466
5883
|
color: "#1a1a1a",
|
|
@@ -5532,6 +5949,7 @@ function SwypePaymentInner({
|
|
|
5532
5949
|
const processingStartedAtRef = useRef(null);
|
|
5533
5950
|
const initializedSelectSourceActionRef = useRef(null);
|
|
5534
5951
|
const preSelectSourceStepRef = useRef(null);
|
|
5952
|
+
const pendingTokenAuthRef = useRef(null);
|
|
5535
5953
|
const checkingPasskeyRef = useRef(false);
|
|
5536
5954
|
const onCompleteRef = useRef(onComplete);
|
|
5537
5955
|
onCompleteRef.current = onComplete;
|
|
@@ -5959,6 +6377,84 @@ function SwypePaymentInner({
|
|
|
5959
6377
|
reloadAccounts,
|
|
5960
6378
|
onError
|
|
5961
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
|
+
]);
|
|
5962
6458
|
const handleConfirmSign = useCallback(async () => {
|
|
5963
6459
|
const t = state.transfer ?? polling.transfer;
|
|
5964
6460
|
if (!t) return;
|
|
@@ -5996,7 +6492,16 @@ function SwypePaymentInner({
|
|
|
5996
6492
|
}
|
|
5997
6493
|
const provider = state.providers.find((p) => p.id === providerId);
|
|
5998
6494
|
const providerName = provider?.name ?? "Wallet";
|
|
5999
|
-
|
|
6495
|
+
const isMobile = !shouldUseWalletConnector({
|
|
6496
|
+
useWalletConnector: useWalletConnectorProp,
|
|
6497
|
+
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
6498
|
+
});
|
|
6499
|
+
if (isMobile) {
|
|
6500
|
+
dispatch({ type: "PAY_STARTED", isSetupRedirect: true });
|
|
6501
|
+
} else {
|
|
6502
|
+
dispatch({ type: "PAY_STARTED", isSetupRedirect: false });
|
|
6503
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6504
|
+
}
|
|
6000
6505
|
try {
|
|
6001
6506
|
const token = await getAccessToken();
|
|
6002
6507
|
if (!token) throw new Error("Not authenticated");
|
|
@@ -6009,10 +6514,6 @@ function SwypePaymentInner({
|
|
|
6009
6514
|
});
|
|
6010
6515
|
const session = account.authorizationSessions?.[0];
|
|
6011
6516
|
if (!session) throw new Error("No authorization session returned.");
|
|
6012
|
-
const isMobile = !shouldUseWalletConnector({
|
|
6013
|
-
useWalletConnector: useWalletConnectorProp,
|
|
6014
|
-
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
6015
|
-
});
|
|
6016
6517
|
if (isMobile) {
|
|
6017
6518
|
handlingMobileReturnRef.current = false;
|
|
6018
6519
|
mobileSetupFlowRef.current = true;
|
|
@@ -6029,7 +6530,7 @@ function SwypePaymentInner({
|
|
|
6029
6530
|
} else {
|
|
6030
6531
|
await authExecutor.executeSessionById(session.id);
|
|
6031
6532
|
await reloadAccounts();
|
|
6032
|
-
dispatch({ type: "NAVIGATE", step: "
|
|
6533
|
+
dispatch({ type: "NAVIGATE", step: "setup" });
|
|
6033
6534
|
}
|
|
6034
6535
|
} catch (err) {
|
|
6035
6536
|
captureException(err);
|
|
@@ -6073,6 +6574,20 @@ function SwypePaymentInner({
|
|
|
6073
6574
|
},
|
|
6074
6575
|
[state.accounts, depositAmount]
|
|
6075
6576
|
);
|
|
6577
|
+
const handleSetupOneTap = useCallback(async (limit) => {
|
|
6578
|
+
try {
|
|
6579
|
+
const token = await getAccessToken();
|
|
6580
|
+
if (!token) throw new Error("Not authenticated");
|
|
6581
|
+
await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
|
|
6582
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
6583
|
+
} catch (err) {
|
|
6584
|
+
captureException(err);
|
|
6585
|
+
dispatch({
|
|
6586
|
+
type: "SET_ERROR",
|
|
6587
|
+
error: err instanceof Error ? err.message : "Failed to save One-Tap limit"
|
|
6588
|
+
});
|
|
6589
|
+
}
|
|
6590
|
+
}, [getAccessToken, apiBaseUrl]);
|
|
6076
6591
|
const handleNewPayment = useCallback(() => {
|
|
6077
6592
|
clearMobileFlowState();
|
|
6078
6593
|
processingStartedAtRef.current = null;
|
|
@@ -6309,6 +6824,7 @@ function SwypePaymentInner({
|
|
|
6309
6824
|
checkPasskey();
|
|
6310
6825
|
return () => {
|
|
6311
6826
|
cancelled = true;
|
|
6827
|
+
checkingPasskeyRef.current = false;
|
|
6312
6828
|
};
|
|
6313
6829
|
}, [ready, authenticated, state.step, apiBaseUrl, state.activeCredentialId]);
|
|
6314
6830
|
useEffect(() => {
|
|
@@ -6520,7 +7036,7 @@ function SwypePaymentInner({
|
|
|
6520
7036
|
initializedSelectSourceActionRef.current = pendingSelectSourceAction.id;
|
|
6521
7037
|
}, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
|
|
6522
7038
|
useEffect(() => {
|
|
6523
|
-
if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet")) {
|
|
7039
|
+
if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet" || state.step === "setup-status")) {
|
|
6524
7040
|
preSelectSourceStepRef.current = state.step;
|
|
6525
7041
|
dispatch({ type: "NAVIGATE", step: "select-source" });
|
|
6526
7042
|
} else if (!pendingSelectSourceAction && state.step === "select-source") {
|
|
@@ -6528,6 +7044,21 @@ function SwypePaymentInner({
|
|
|
6528
7044
|
preSelectSourceStepRef.current = null;
|
|
6529
7045
|
}
|
|
6530
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]);
|
|
6531
7062
|
const handlers = useMemo(() => ({
|
|
6532
7063
|
onSendLoginCode: handleSendLoginCode,
|
|
6533
7064
|
onVerifyLoginCode: handleVerifyLoginCode,
|
|
@@ -6556,7 +7087,11 @@ function SwypePaymentInner({
|
|
|
6556
7087
|
},
|
|
6557
7088
|
onSelectSourceChainChange: handleSelectSourceChainChange,
|
|
6558
7089
|
onSetSelectSourceTokenSymbol: setSelectSourceTokenSymbol,
|
|
6559
|
-
onConfirmSelectSource: handleConfirmSelectSource
|
|
7090
|
+
onConfirmSelectSource: handleConfirmSelectSource,
|
|
7091
|
+
onSetupOneTap: handleSetupOneTap,
|
|
7092
|
+
onSelectToken: handleNavigateToTokenPicker,
|
|
7093
|
+
onSelectAuthorizedToken: handleSelectAuthorizedToken,
|
|
7094
|
+
onAuthorizeToken: handleAuthorizeToken
|
|
6560
7095
|
}), [
|
|
6561
7096
|
handleSendLoginCode,
|
|
6562
7097
|
handleVerifyLoginCode,
|
|
@@ -6574,7 +7109,11 @@ function SwypePaymentInner({
|
|
|
6574
7109
|
handleLogout,
|
|
6575
7110
|
handleNewPayment,
|
|
6576
7111
|
handleSelectSourceChainChange,
|
|
6577
|
-
handleConfirmSelectSource
|
|
7112
|
+
handleConfirmSelectSource,
|
|
7113
|
+
handleSetupOneTap,
|
|
7114
|
+
handleNavigateToTokenPicker,
|
|
7115
|
+
handleSelectAuthorizedToken,
|
|
7116
|
+
handleAuthorizeToken
|
|
6578
7117
|
]);
|
|
6579
7118
|
return /* @__PURE__ */ jsx(
|
|
6580
7119
|
StepRenderer,
|
|
@@ -6612,6 +7151,6 @@ function SwypePaymentInner({
|
|
|
6612
7151
|
);
|
|
6613
7152
|
}
|
|
6614
7153
|
|
|
6615
|
-
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 };
|
|
6616
7155
|
//# sourceMappingURL=index.js.map
|
|
6617
7156
|
//# sourceMappingURL=index.js.map
|