@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.cjs
CHANGED
|
@@ -238,7 +238,10 @@ async function createAccount(apiBaseUrl, token, params) {
|
|
|
238
238
|
if (!res.ok) await throwApiError(res);
|
|
239
239
|
return await res.json();
|
|
240
240
|
}
|
|
241
|
-
async function createAccountAuthorizationSession(apiBaseUrl, token, accountId, credentialId) {
|
|
241
|
+
async function createAccountAuthorizationSession(apiBaseUrl, token, accountId, credentialId, options) {
|
|
242
|
+
const body = { credentialId };
|
|
243
|
+
if (options?.tokenAddress) body.tokenAddress = options.tokenAddress;
|
|
244
|
+
if (options?.chainId != null) body.chainId = options.chainId;
|
|
242
245
|
const res = await fetch(
|
|
243
246
|
`${apiBaseUrl}/v1/accounts/${accountId}/authorization-sessions`,
|
|
244
247
|
{
|
|
@@ -247,7 +250,7 @@ async function createAccountAuthorizationSession(apiBaseUrl, token, accountId, c
|
|
|
247
250
|
"Content-Type": "application/json",
|
|
248
251
|
Authorization: `Bearer ${token}`
|
|
249
252
|
},
|
|
250
|
-
body: JSON.stringify(
|
|
253
|
+
body: JSON.stringify(body)
|
|
251
254
|
}
|
|
252
255
|
);
|
|
253
256
|
if (!res.ok) await throwApiError(res);
|
|
@@ -1929,6 +1932,7 @@ function createInitialState(config) {
|
|
|
1929
1932
|
selectedProviderId: null,
|
|
1930
1933
|
selectedAccountId: null,
|
|
1931
1934
|
selectedWalletId: null,
|
|
1935
|
+
selectedTokenSymbol: null,
|
|
1932
1936
|
amount: config.depositAmount != null ? config.depositAmount.toString() : "",
|
|
1933
1937
|
transfer: null,
|
|
1934
1938
|
creatingTransfer: false,
|
|
@@ -2023,7 +2027,8 @@ function paymentReducer(state, action) {
|
|
|
2023
2027
|
...state,
|
|
2024
2028
|
selectedProviderId: action.providerId,
|
|
2025
2029
|
selectedAccountId: null,
|
|
2026
|
-
selectedWalletId: null
|
|
2030
|
+
selectedWalletId: null,
|
|
2031
|
+
selectedTokenSymbol: null
|
|
2027
2032
|
};
|
|
2028
2033
|
case "SELECT_ACCOUNT":
|
|
2029
2034
|
return {
|
|
@@ -2032,6 +2037,13 @@ function paymentReducer(state, action) {
|
|
|
2032
2037
|
selectedWalletId: action.walletId,
|
|
2033
2038
|
step: "deposit"
|
|
2034
2039
|
};
|
|
2040
|
+
case "SELECT_TOKEN":
|
|
2041
|
+
return {
|
|
2042
|
+
...state,
|
|
2043
|
+
selectedWalletId: action.walletId,
|
|
2044
|
+
selectedTokenSymbol: action.tokenSymbol,
|
|
2045
|
+
step: "deposit"
|
|
2046
|
+
};
|
|
2035
2047
|
// ── Transfer lifecycle ───────────────────────────────────────
|
|
2036
2048
|
case "PAY_STARTED":
|
|
2037
2049
|
return {
|
|
@@ -3816,7 +3828,7 @@ var dividerTextStyle = (color) => ({
|
|
|
3816
3828
|
whiteSpace: "nowrap"
|
|
3817
3829
|
});
|
|
3818
3830
|
var DEFAULT_MAX = 500;
|
|
3819
|
-
var ABSOLUTE_MIN =
|
|
3831
|
+
var ABSOLUTE_MIN = 0.01;
|
|
3820
3832
|
function SetupScreen({
|
|
3821
3833
|
availableBalance,
|
|
3822
3834
|
tokenCount,
|
|
@@ -3830,7 +3842,7 @@ function SetupScreen({
|
|
|
3830
3842
|
error
|
|
3831
3843
|
}) {
|
|
3832
3844
|
const { tokens } = useSwypeConfig();
|
|
3833
|
-
const effectiveMax =
|
|
3845
|
+
const effectiveMax = DEFAULT_MAX;
|
|
3834
3846
|
const effectiveMin = Math.min(ABSOLUTE_MIN, effectiveMax);
|
|
3835
3847
|
const [limit, setLimit] = react.useState(() => effectiveMax);
|
|
3836
3848
|
const [editing, setEditing] = react.useState(false);
|
|
@@ -3924,11 +3936,15 @@ function SetupScreen({
|
|
|
3924
3936
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3925
3937
|
"div",
|
|
3926
3938
|
{
|
|
3927
|
-
style:
|
|
3939
|
+
style: editableLimitStyle(tokens.text),
|
|
3928
3940
|
onClick: startEditing,
|
|
3929
3941
|
children: [
|
|
3930
3942
|
"$",
|
|
3931
|
-
limit.toFixed(2)
|
|
3943
|
+
limit.toFixed(2),
|
|
3944
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", style: pencilIconStyle(tokens.textMuted), children: [
|
|
3945
|
+
/* @__PURE__ */ jsxRuntime.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" }),
|
|
3946
|
+
/* @__PURE__ */ jsxRuntime.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" })
|
|
3947
|
+
] })
|
|
3932
3948
|
]
|
|
3933
3949
|
}
|
|
3934
3950
|
)
|
|
@@ -4036,6 +4052,18 @@ var limitValueStyle = (color) => ({
|
|
|
4036
4052
|
color,
|
|
4037
4053
|
marginBottom: 12
|
|
4038
4054
|
});
|
|
4055
|
+
var editableLimitStyle = (color) => ({
|
|
4056
|
+
...limitValueStyle(color),
|
|
4057
|
+
cursor: "pointer",
|
|
4058
|
+
display: "inline-flex",
|
|
4059
|
+
alignItems: "center",
|
|
4060
|
+
gap: 6
|
|
4061
|
+
});
|
|
4062
|
+
var pencilIconStyle = (color) => ({
|
|
4063
|
+
color,
|
|
4064
|
+
opacity: 0.6,
|
|
4065
|
+
flexShrink: 0
|
|
4066
|
+
});
|
|
4039
4067
|
var limitInputStyle = (color) => ({
|
|
4040
4068
|
fontSize: "2.2rem",
|
|
4041
4069
|
fontWeight: 700,
|
|
@@ -4063,6 +4091,108 @@ var linkStyle = (color) => ({
|
|
|
4063
4091
|
padding: 0,
|
|
4064
4092
|
marginBottom: 16
|
|
4065
4093
|
});
|
|
4094
|
+
function SetupStatusScreen({
|
|
4095
|
+
complete,
|
|
4096
|
+
limit,
|
|
4097
|
+
tokensApproved,
|
|
4098
|
+
merchantName,
|
|
4099
|
+
onContinue,
|
|
4100
|
+
onLogout,
|
|
4101
|
+
error
|
|
4102
|
+
}) {
|
|
4103
|
+
const { tokens } = useSwypeConfig();
|
|
4104
|
+
const steps = complete ? [
|
|
4105
|
+
{
|
|
4106
|
+
label: "One-Tap ready",
|
|
4107
|
+
detail: `$${limit} limit \xB7 ${tokensApproved} token${tokensApproved !== 1 ? "s" : ""} approved`,
|
|
4108
|
+
status: "complete"
|
|
4109
|
+
},
|
|
4110
|
+
{ label: "Done", status: "complete" }
|
|
4111
|
+
] : [
|
|
4112
|
+
{
|
|
4113
|
+
label: "Setting up Wallet",
|
|
4114
|
+
status: "active"
|
|
4115
|
+
},
|
|
4116
|
+
{ label: "Done", status: "pending" }
|
|
4117
|
+
];
|
|
4118
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4119
|
+
ScreenLayout,
|
|
4120
|
+
{
|
|
4121
|
+
footer: complete ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4122
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick: onContinue, children: merchantName ? `Return to ${merchantName}` : "Continue" }),
|
|
4123
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: swipeHintStyle(tokens.textMuted), children: "Swipe to deposit \u2014 no approvals needed." })
|
|
4124
|
+
] }) : void 0,
|
|
4125
|
+
children: [
|
|
4126
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
4127
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle5, children: [
|
|
4128
|
+
complete ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4129
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconCircle, { variant: "success", size: 64, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z", fill: tokens.success }) }) }),
|
|
4130
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle6(tokens.text), children: "You're all set!" })
|
|
4131
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4132
|
+
/* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
4133
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle6(tokens.text), children: "Setting up One-Tap..." })
|
|
4134
|
+
] }),
|
|
4135
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle4(tokens), children: error }),
|
|
4136
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: stepsWrapStyle, children: /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps }) }),
|
|
4137
|
+
!complete && /* @__PURE__ */ jsxRuntime.jsx("p", { style: waitHintStyle(tokens.textMuted), children: "Usually takes a few seconds" }),
|
|
4138
|
+
complete && /* @__PURE__ */ jsxRuntime.jsx("p", { style: readyHintStyle(tokens.textSecondary), children: "You can now deposit instantly from any partner app." })
|
|
4139
|
+
] })
|
|
4140
|
+
]
|
|
4141
|
+
}
|
|
4142
|
+
);
|
|
4143
|
+
}
|
|
4144
|
+
var contentStyle5 = {
|
|
4145
|
+
flex: 1,
|
|
4146
|
+
display: "flex",
|
|
4147
|
+
flexDirection: "column",
|
|
4148
|
+
alignItems: "center",
|
|
4149
|
+
justifyContent: "center",
|
|
4150
|
+
textAlign: "center",
|
|
4151
|
+
padding: "0 24px 32px"
|
|
4152
|
+
};
|
|
4153
|
+
var headingStyle6 = (color) => ({
|
|
4154
|
+
fontSize: "1.45rem",
|
|
4155
|
+
fontWeight: 700,
|
|
4156
|
+
letterSpacing: "-0.02em",
|
|
4157
|
+
color,
|
|
4158
|
+
margin: "20px 0 16px"
|
|
4159
|
+
});
|
|
4160
|
+
var errorBannerStyle4 = (tokens) => ({
|
|
4161
|
+
background: tokens.errorBg,
|
|
4162
|
+
border: `1px solid ${tokens.error}66`,
|
|
4163
|
+
borderRadius: 16,
|
|
4164
|
+
padding: "11px 14px",
|
|
4165
|
+
color: tokens.error,
|
|
4166
|
+
fontSize: "0.84rem",
|
|
4167
|
+
marginBottom: 14,
|
|
4168
|
+
lineHeight: 1.5,
|
|
4169
|
+
width: "100%",
|
|
4170
|
+
textAlign: "left"
|
|
4171
|
+
});
|
|
4172
|
+
var stepsWrapStyle = {
|
|
4173
|
+
width: "100%",
|
|
4174
|
+
maxWidth: 280,
|
|
4175
|
+
textAlign: "left",
|
|
4176
|
+
marginBottom: 16
|
|
4177
|
+
};
|
|
4178
|
+
var waitHintStyle = (color) => ({
|
|
4179
|
+
fontSize: "0.82rem",
|
|
4180
|
+
color,
|
|
4181
|
+
margin: 0
|
|
4182
|
+
});
|
|
4183
|
+
var readyHintStyle = (color) => ({
|
|
4184
|
+
fontSize: "0.88rem",
|
|
4185
|
+
color,
|
|
4186
|
+
margin: "8px 0 0",
|
|
4187
|
+
lineHeight: 1.5,
|
|
4188
|
+
maxWidth: 280
|
|
4189
|
+
});
|
|
4190
|
+
var swipeHintStyle = (color) => ({
|
|
4191
|
+
textAlign: "center",
|
|
4192
|
+
fontSize: "0.8rem",
|
|
4193
|
+
color,
|
|
4194
|
+
margin: "12px 0 0"
|
|
4195
|
+
});
|
|
4066
4196
|
var MIN_DEPOSIT = 0.25;
|
|
4067
4197
|
function DepositScreen({
|
|
4068
4198
|
merchantName,
|
|
@@ -4087,7 +4217,8 @@ function DepositScreen({
|
|
|
4087
4217
|
selectedAccountId,
|
|
4088
4218
|
onSelectAccount,
|
|
4089
4219
|
onAuthorizeAccount,
|
|
4090
|
-
onAddProvider
|
|
4220
|
+
onAddProvider,
|
|
4221
|
+
onSelectToken
|
|
4091
4222
|
}) {
|
|
4092
4223
|
const { tokens } = useSwypeConfig();
|
|
4093
4224
|
const amount = initialAmount;
|
|
@@ -4217,12 +4348,20 @@ function DepositScreen({
|
|
|
4217
4348
|
] })
|
|
4218
4349
|
] })
|
|
4219
4350
|
] }),
|
|
4220
|
-
tokenCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4351
|
+
tokenCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4352
|
+
"button",
|
|
4353
|
+
{
|
|
4354
|
+
type: "button",
|
|
4355
|
+
onClick: onSelectToken,
|
|
4356
|
+
style: tokenBadgeButtonStyle2(tokens, !!onSelectToken),
|
|
4357
|
+
children: [
|
|
4358
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: tokenDotStyle2(tokens.accent) }),
|
|
4359
|
+
tokenCount,
|
|
4360
|
+
" ",
|
|
4361
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: chevronInlineStyle, children: ">" })
|
|
4362
|
+
]
|
|
4363
|
+
}
|
|
4364
|
+
)
|
|
4226
4365
|
] }),
|
|
4227
4366
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: detailsStyle, children: [
|
|
4228
4367
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: detailRowStyle(tokens.textMuted), children: [
|
|
@@ -4240,7 +4379,7 @@ function DepositScreen({
|
|
|
4240
4379
|
"%)"
|
|
4241
4380
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: detailRowStyle(tokens.textMuted), children: "Fees calculated at time of transfer" })
|
|
4242
4381
|
] }),
|
|
4243
|
-
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
4382
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle5(tokens), children: error })
|
|
4244
4383
|
]
|
|
4245
4384
|
}
|
|
4246
4385
|
);
|
|
@@ -4280,7 +4419,7 @@ var balanceAmountStyle = {
|
|
|
4280
4419
|
fontSize: "1rem",
|
|
4281
4420
|
fontWeight: 700
|
|
4282
4421
|
};
|
|
4283
|
-
var
|
|
4422
|
+
var tokenBadgeButtonStyle2 = (tokens, clickable) => ({
|
|
4284
4423
|
display: "flex",
|
|
4285
4424
|
alignItems: "center",
|
|
4286
4425
|
gap: 4,
|
|
@@ -4288,7 +4427,10 @@ var tokenBadgeStyle = (tokens) => ({
|
|
|
4288
4427
|
color: tokens.textMuted,
|
|
4289
4428
|
border: `1px solid ${tokens.border}`,
|
|
4290
4429
|
borderRadius: 999,
|
|
4291
|
-
padding: "4px 10px"
|
|
4430
|
+
padding: "4px 10px",
|
|
4431
|
+
background: "transparent",
|
|
4432
|
+
fontFamily: "inherit",
|
|
4433
|
+
cursor: clickable ? "pointer" : "default"
|
|
4292
4434
|
});
|
|
4293
4435
|
var tokenDotStyle2 = (color) => ({
|
|
4294
4436
|
width: 8,
|
|
@@ -4297,7 +4439,7 @@ var tokenDotStyle2 = (color) => ({
|
|
|
4297
4439
|
background: color,
|
|
4298
4440
|
display: "inline-block"
|
|
4299
4441
|
});
|
|
4300
|
-
var
|
|
4442
|
+
var chevronInlineStyle = { fontSize: "0.68rem", marginLeft: 2 };
|
|
4301
4443
|
var detailsStyle = {
|
|
4302
4444
|
textAlign: "center",
|
|
4303
4445
|
marginTop: 12,
|
|
@@ -4308,7 +4450,7 @@ var detailRowStyle = (color) => ({
|
|
|
4308
4450
|
color,
|
|
4309
4451
|
marginBottom: 4
|
|
4310
4452
|
});
|
|
4311
|
-
var
|
|
4453
|
+
var errorBannerStyle5 = (tokens) => ({
|
|
4312
4454
|
background: tokens.errorBg,
|
|
4313
4455
|
border: `1px solid ${tokens.error}66`,
|
|
4314
4456
|
borderRadius: 16,
|
|
@@ -4407,10 +4549,10 @@ function SuccessScreen({
|
|
|
4407
4549
|
right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout })
|
|
4408
4550
|
}
|
|
4409
4551
|
),
|
|
4410
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
4552
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle6, children: [
|
|
4411
4553
|
succeeded ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4412
4554
|
/* @__PURE__ */ jsxRuntime.jsx(IconCircle, { variant: "success", size: 64, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z", fill: tokens.success }) }) }),
|
|
4413
|
-
/* @__PURE__ */ jsxRuntime.jsxs("h2", { style:
|
|
4555
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h2", { style: headingStyle7(tokens.text), children: [
|
|
4414
4556
|
"$",
|
|
4415
4557
|
amount.toFixed(2),
|
|
4416
4558
|
" deposited"
|
|
@@ -4421,7 +4563,7 @@ function SuccessScreen({
|
|
|
4421
4563
|
] })
|
|
4422
4564
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4423
4565
|
/* @__PURE__ */ jsxRuntime.jsx(IconCircle, { variant: "error", size: 64, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.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 }) }) }),
|
|
4424
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
4566
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle7(tokens.text), children: "Transfer failed" }),
|
|
4425
4567
|
error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle6(tokens.error), children: error })
|
|
4426
4568
|
] }),
|
|
4427
4569
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: summaryCardStyle(tokens), children: [
|
|
@@ -4454,14 +4596,14 @@ function SuccessScreen({
|
|
|
4454
4596
|
}
|
|
4455
4597
|
);
|
|
4456
4598
|
}
|
|
4457
|
-
var
|
|
4599
|
+
var contentStyle6 = {
|
|
4458
4600
|
flex: 1,
|
|
4459
4601
|
display: "flex",
|
|
4460
4602
|
flexDirection: "column",
|
|
4461
4603
|
alignItems: "center",
|
|
4462
4604
|
paddingTop: 16
|
|
4463
4605
|
};
|
|
4464
|
-
var
|
|
4606
|
+
var headingStyle7 = (color) => ({
|
|
4465
4607
|
fontSize: "1.5rem",
|
|
4466
4608
|
fontWeight: 700,
|
|
4467
4609
|
letterSpacing: "-0.02em",
|
|
@@ -4746,7 +4888,7 @@ function AdvancedSourceScreen({
|
|
|
4746
4888
|
right: /* @__PURE__ */ jsxRuntime.jsx("span", { style: advancedBadgeStyle(tokens.accent), children: "Advanced" })
|
|
4747
4889
|
}
|
|
4748
4890
|
),
|
|
4749
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
4891
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle8(tokens.text), children: "Set up One-Tap deposits" }),
|
|
4750
4892
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle8(tokens.textSecondary), children: "Select a token source for your One-Tap deposits." }),
|
|
4751
4893
|
/* @__PURE__ */ jsxRuntime.jsx("label", { style: labelStyle3(tokens.textSecondary), children: "Select tokens to approve" }),
|
|
4752
4894
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: chainListStyle, children: choices.map((chain) => {
|
|
@@ -4810,7 +4952,7 @@ var advancedBadgeStyle = (color) => ({
|
|
|
4810
4952
|
padding: "3px 10px",
|
|
4811
4953
|
letterSpacing: "0.02em"
|
|
4812
4954
|
});
|
|
4813
|
-
var
|
|
4955
|
+
var headingStyle8 = (color) => ({
|
|
4814
4956
|
fontSize: "1.3rem",
|
|
4815
4957
|
fontWeight: 700,
|
|
4816
4958
|
letterSpacing: "-0.02em",
|
|
@@ -4945,16 +5087,16 @@ function TransferStatusScreen({
|
|
|
4945
5087
|
const steps = buildSteps(phase);
|
|
4946
5088
|
return /* @__PURE__ */ jsxRuntime.jsxs(ScreenLayout, { children: [
|
|
4947
5089
|
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
4948
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
5090
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle7, children: [
|
|
4949
5091
|
/* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
4950
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
4951
|
-
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
4952
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style:
|
|
4953
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style:
|
|
5092
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle9(tokens.text), children: "Processing Transfer..." }),
|
|
5093
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle6(tokens), children: error }),
|
|
5094
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: stepsWrapStyle2, children: /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps }) }),
|
|
5095
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: waitHintStyle2(tokens.textMuted), children: "Usually takes a few seconds" })
|
|
4954
5096
|
] })
|
|
4955
5097
|
] });
|
|
4956
5098
|
}
|
|
4957
|
-
var
|
|
5099
|
+
var contentStyle7 = {
|
|
4958
5100
|
flex: 1,
|
|
4959
5101
|
display: "flex",
|
|
4960
5102
|
flexDirection: "column",
|
|
@@ -4963,14 +5105,14 @@ var contentStyle6 = {
|
|
|
4963
5105
|
textAlign: "center",
|
|
4964
5106
|
padding: "0 24px"
|
|
4965
5107
|
};
|
|
4966
|
-
var
|
|
5108
|
+
var headingStyle9 = (color) => ({
|
|
4967
5109
|
fontSize: "1.45rem",
|
|
4968
5110
|
fontWeight: 700,
|
|
4969
5111
|
letterSpacing: "-0.02em",
|
|
4970
5112
|
color,
|
|
4971
5113
|
margin: "20px 0 16px"
|
|
4972
5114
|
});
|
|
4973
|
-
var
|
|
5115
|
+
var errorBannerStyle6 = (tokens) => ({
|
|
4974
5116
|
background: tokens.errorBg,
|
|
4975
5117
|
border: `1px solid ${tokens.error}66`,
|
|
4976
5118
|
borderRadius: 16,
|
|
@@ -4982,13 +5124,13 @@ var errorBannerStyle5 = (tokens) => ({
|
|
|
4982
5124
|
width: "100%",
|
|
4983
5125
|
textAlign: "left"
|
|
4984
5126
|
});
|
|
4985
|
-
var
|
|
5127
|
+
var stepsWrapStyle2 = {
|
|
4986
5128
|
width: "100%",
|
|
4987
5129
|
maxWidth: 280,
|
|
4988
5130
|
textAlign: "left",
|
|
4989
5131
|
marginBottom: 16
|
|
4990
5132
|
};
|
|
4991
|
-
var
|
|
5133
|
+
var waitHintStyle2 = (color) => ({
|
|
4992
5134
|
fontSize: "0.82rem",
|
|
4993
5135
|
color,
|
|
4994
5136
|
margin: 0
|
|
@@ -5030,9 +5172,9 @@ function OpenWalletScreen({
|
|
|
5030
5172
|
] }),
|
|
5031
5173
|
children: [
|
|
5032
5174
|
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
5033
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
5175
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle8, children: [
|
|
5034
5176
|
logoSrc ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoSrc, alt: displayName, style: logoStyle }) : /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
5035
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
5177
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle10(tokens.text), children: loading ? "Connecting..." : `Open ${displayName}` }),
|
|
5036
5178
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle9(tokens.textSecondary), children: loading ? "Creating transfer and preparing your wallet link..." : `Continue in ${displayName} to authorize this connection.` }),
|
|
5037
5179
|
!loading && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: waitingBadgeStyle(tokens), children: [
|
|
5038
5180
|
/* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 14 }),
|
|
@@ -5043,7 +5185,7 @@ function OpenWalletScreen({
|
|
|
5043
5185
|
}
|
|
5044
5186
|
);
|
|
5045
5187
|
}
|
|
5046
|
-
var
|
|
5188
|
+
var contentStyle8 = {
|
|
5047
5189
|
flex: 1,
|
|
5048
5190
|
display: "flex",
|
|
5049
5191
|
flexDirection: "column",
|
|
@@ -5063,7 +5205,7 @@ var logoStyle = {
|
|
|
5063
5205
|
borderRadius: 14,
|
|
5064
5206
|
objectFit: "contain"
|
|
5065
5207
|
};
|
|
5066
|
-
var
|
|
5208
|
+
var headingStyle10 = (color) => ({
|
|
5067
5209
|
fontSize: "1.45rem",
|
|
5068
5210
|
fontWeight: 700,
|
|
5069
5211
|
letterSpacing: "-0.02em",
|
|
@@ -5114,9 +5256,9 @@ function ConfirmSignScreen({
|
|
|
5114
5256
|
] }),
|
|
5115
5257
|
children: [
|
|
5116
5258
|
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
5117
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
5259
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle9, children: [
|
|
5118
5260
|
logoSrc ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoSrc, alt: displayName, style: logoStyle2 }) : /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
5119
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
5261
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle11(tokens.text), children: "Wallet authorized" }),
|
|
5120
5262
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: subtitleStyle10(tokens.textSecondary), children: [
|
|
5121
5263
|
displayName,
|
|
5122
5264
|
" approved the connection. Tap below to confirm your payment."
|
|
@@ -5130,7 +5272,7 @@ function ConfirmSignScreen({
|
|
|
5130
5272
|
}
|
|
5131
5273
|
);
|
|
5132
5274
|
}
|
|
5133
|
-
var
|
|
5275
|
+
var contentStyle9 = {
|
|
5134
5276
|
flex: 1,
|
|
5135
5277
|
display: "flex",
|
|
5136
5278
|
flexDirection: "column",
|
|
@@ -5145,7 +5287,7 @@ var logoStyle2 = {
|
|
|
5145
5287
|
borderRadius: 14,
|
|
5146
5288
|
objectFit: "contain"
|
|
5147
5289
|
};
|
|
5148
|
-
var
|
|
5290
|
+
var headingStyle11 = (color) => ({
|
|
5149
5291
|
fontSize: "1.45rem",
|
|
5150
5292
|
fontWeight: 700,
|
|
5151
5293
|
letterSpacing: "-0.02em",
|
|
@@ -5186,6 +5328,236 @@ var errorStyle2 = (color) => ({
|
|
|
5186
5328
|
color: "#ef4444",
|
|
5187
5329
|
margin: "8px 0 0"
|
|
5188
5330
|
});
|
|
5331
|
+
function TokenPickerScreen({
|
|
5332
|
+
account,
|
|
5333
|
+
chains,
|
|
5334
|
+
onSelectAuthorized,
|
|
5335
|
+
onAuthorizeToken,
|
|
5336
|
+
onBack
|
|
5337
|
+
}) {
|
|
5338
|
+
const { tokens: themeTokens } = useSwypeConfig();
|
|
5339
|
+
const [selectedIndex, setSelectedIndex] = react.useState(null);
|
|
5340
|
+
const entries = [];
|
|
5341
|
+
for (const wallet of account.wallets) {
|
|
5342
|
+
for (const source of wallet.sources) {
|
|
5343
|
+
entries.push({
|
|
5344
|
+
walletId: wallet.id,
|
|
5345
|
+
chainName: wallet.chain.name,
|
|
5346
|
+
tokenSymbol: source.token.symbol,
|
|
5347
|
+
tokenAddress: source.address,
|
|
5348
|
+
balance: source.balance.total.amount,
|
|
5349
|
+
status: source.token.status
|
|
5350
|
+
});
|
|
5351
|
+
}
|
|
5352
|
+
}
|
|
5353
|
+
const selected = selectedIndex != null ? entries[selectedIndex] : null;
|
|
5354
|
+
const isAuthorized = selected?.status === "AUTHORIZED";
|
|
5355
|
+
const handleConfirm = () => {
|
|
5356
|
+
if (!selected) return;
|
|
5357
|
+
if (isAuthorized) {
|
|
5358
|
+
onSelectAuthorized(selected.walletId, selected.tokenSymbol);
|
|
5359
|
+
} else {
|
|
5360
|
+
const chain = chains.find((c) => c.name === selected.chainName);
|
|
5361
|
+
const evmChainId = chain?.commonId;
|
|
5362
|
+
if (evmChainId == null) return;
|
|
5363
|
+
onAuthorizeToken(selected.walletId, selected.tokenAddress, evmChainId, selected.tokenSymbol);
|
|
5364
|
+
}
|
|
5365
|
+
};
|
|
5366
|
+
const chainGroups = /* @__PURE__ */ new Map();
|
|
5367
|
+
for (const entry of entries) {
|
|
5368
|
+
const group = chainGroups.get(entry.chainName);
|
|
5369
|
+
if (group) {
|
|
5370
|
+
group.push(entry);
|
|
5371
|
+
} else {
|
|
5372
|
+
chainGroups.set(entry.chainName, [entry]);
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
const [expandedChain, setExpandedChain] = react.useState(
|
|
5376
|
+
entries.length > 0 ? entries[0].chainName : null
|
|
5377
|
+
);
|
|
5378
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5379
|
+
ScreenLayout,
|
|
5380
|
+
{
|
|
5381
|
+
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5382
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5383
|
+
PrimaryButton,
|
|
5384
|
+
{
|
|
5385
|
+
onClick: handleConfirm,
|
|
5386
|
+
disabled: selected == null,
|
|
5387
|
+
children: selected == null ? "Select a token" : isAuthorized ? "Select Source" : "Authorize Token"
|
|
5388
|
+
}
|
|
5389
|
+
),
|
|
5390
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoweredByFooter, {})
|
|
5391
|
+
] }),
|
|
5392
|
+
children: [
|
|
5393
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { title: "Select Token", onBack }),
|
|
5394
|
+
/* @__PURE__ */ jsxRuntime.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." }),
|
|
5395
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: chainListStyle2, children: [...chainGroups.entries()].map(([chainName, chainEntries]) => {
|
|
5396
|
+
const isExpanded = expandedChain === chainName;
|
|
5397
|
+
const chainTotal = chainEntries.reduce((sum, e) => sum + e.balance, 0);
|
|
5398
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: chainCardStyle2(themeTokens), children: [
|
|
5399
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5400
|
+
"button",
|
|
5401
|
+
{
|
|
5402
|
+
type: "button",
|
|
5403
|
+
onClick: () => setExpandedChain((prev) => prev === chainName ? null : chainName),
|
|
5404
|
+
style: chainHeaderStyle2(themeTokens),
|
|
5405
|
+
children: [
|
|
5406
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: chainHeaderLeftStyle2, children: [
|
|
5407
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: chainNameStyle2(themeTokens.text), children: chainName }),
|
|
5408
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: chainBalanceStyle2(themeTokens.textMuted), children: [
|
|
5409
|
+
"$",
|
|
5410
|
+
chainTotal.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
5411
|
+
] })
|
|
5412
|
+
] }),
|
|
5413
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: chevronStyle2(themeTokens.textMuted), children: isExpanded ? "\u25BE" : "\u25B8" })
|
|
5414
|
+
]
|
|
5415
|
+
}
|
|
5416
|
+
),
|
|
5417
|
+
isExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { style: tokenListStyle2, children: chainEntries.map((entry) => {
|
|
5418
|
+
const globalIdx = entries.indexOf(entry);
|
|
5419
|
+
const isSelected = selectedIndex === globalIdx;
|
|
5420
|
+
const authorized = entry.status === "AUTHORIZED";
|
|
5421
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5422
|
+
"button",
|
|
5423
|
+
{
|
|
5424
|
+
type: "button",
|
|
5425
|
+
onClick: () => setSelectedIndex(globalIdx),
|
|
5426
|
+
style: tokenRowStyle2(themeTokens, isSelected),
|
|
5427
|
+
children: [
|
|
5428
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: tokenInfoStyle2, children: [
|
|
5429
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: tokenHeaderRowStyle, children: [
|
|
5430
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: tokenSymbolStyle2(themeTokens.text), children: entry.tokenSymbol }),
|
|
5431
|
+
authorized ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: statusBadgeStyle(themeTokens.success), children: "Authorized" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: statusBadgeStyle(themeTokens.textMuted), children: "Not authorized" })
|
|
5432
|
+
] }),
|
|
5433
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: tokenBalStyle2(themeTokens.textMuted), children: [
|
|
5434
|
+
"$",
|
|
5435
|
+
entry.balance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
5436
|
+
] })
|
|
5437
|
+
] }),
|
|
5438
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: radioStyle3(themeTokens, isSelected), children: isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { style: radioDotStyle3(themeTokens.accent) }) })
|
|
5439
|
+
]
|
|
5440
|
+
},
|
|
5441
|
+
`${entry.walletId}-${entry.tokenSymbol}`
|
|
5442
|
+
);
|
|
5443
|
+
}) })
|
|
5444
|
+
] }, chainName);
|
|
5445
|
+
}) })
|
|
5446
|
+
]
|
|
5447
|
+
}
|
|
5448
|
+
);
|
|
5449
|
+
}
|
|
5450
|
+
var subtitleStyle11 = (color) => ({
|
|
5451
|
+
fontSize: "0.86rem",
|
|
5452
|
+
color,
|
|
5453
|
+
margin: "0 0 20px",
|
|
5454
|
+
lineHeight: 1.5
|
|
5455
|
+
});
|
|
5456
|
+
var chainListStyle2 = {
|
|
5457
|
+
display: "flex",
|
|
5458
|
+
flexDirection: "column",
|
|
5459
|
+
gap: 10
|
|
5460
|
+
};
|
|
5461
|
+
var chainCardStyle2 = (tokens) => ({
|
|
5462
|
+
border: `1px solid ${tokens.border}`,
|
|
5463
|
+
borderRadius: 14,
|
|
5464
|
+
overflow: "hidden",
|
|
5465
|
+
background: tokens.bgInput
|
|
5466
|
+
});
|
|
5467
|
+
var chainHeaderStyle2 = (tokens) => ({
|
|
5468
|
+
display: "flex",
|
|
5469
|
+
alignItems: "center",
|
|
5470
|
+
justifyContent: "space-between",
|
|
5471
|
+
width: "100%",
|
|
5472
|
+
padding: "14px 16px",
|
|
5473
|
+
background: tokens.bgInput,
|
|
5474
|
+
border: "none",
|
|
5475
|
+
cursor: "pointer",
|
|
5476
|
+
fontFamily: "inherit",
|
|
5477
|
+
textAlign: "left"
|
|
5478
|
+
});
|
|
5479
|
+
var chainHeaderLeftStyle2 = {
|
|
5480
|
+
display: "flex",
|
|
5481
|
+
flexDirection: "column",
|
|
5482
|
+
gap: 2
|
|
5483
|
+
};
|
|
5484
|
+
var chainNameStyle2 = (color) => ({
|
|
5485
|
+
fontSize: "0.92rem",
|
|
5486
|
+
fontWeight: 600,
|
|
5487
|
+
color
|
|
5488
|
+
});
|
|
5489
|
+
var chainBalanceStyle2 = (color) => ({
|
|
5490
|
+
fontSize: "0.76rem",
|
|
5491
|
+
color
|
|
5492
|
+
});
|
|
5493
|
+
var chevronStyle2 = (color) => ({
|
|
5494
|
+
fontSize: "0.9rem",
|
|
5495
|
+
color
|
|
5496
|
+
});
|
|
5497
|
+
var tokenListStyle2 = {
|
|
5498
|
+
padding: "0 12px 12px",
|
|
5499
|
+
display: "flex",
|
|
5500
|
+
flexDirection: "column",
|
|
5501
|
+
gap: 6
|
|
5502
|
+
};
|
|
5503
|
+
var tokenRowStyle2 = (tokens, selected) => ({
|
|
5504
|
+
display: "flex",
|
|
5505
|
+
alignItems: "center",
|
|
5506
|
+
justifyContent: "space-between",
|
|
5507
|
+
padding: "12px 14px",
|
|
5508
|
+
background: tokens.bgCard,
|
|
5509
|
+
border: `1.5px solid ${selected ? tokens.accent : tokens.border}`,
|
|
5510
|
+
borderRadius: 10,
|
|
5511
|
+
cursor: "pointer",
|
|
5512
|
+
fontFamily: "inherit",
|
|
5513
|
+
textAlign: "left",
|
|
5514
|
+
transition: "border-color 0.15s ease"
|
|
5515
|
+
});
|
|
5516
|
+
var tokenInfoStyle2 = {
|
|
5517
|
+
display: "flex",
|
|
5518
|
+
flexDirection: "column",
|
|
5519
|
+
gap: 4,
|
|
5520
|
+
flex: 1
|
|
5521
|
+
};
|
|
5522
|
+
var tokenHeaderRowStyle = {
|
|
5523
|
+
display: "flex",
|
|
5524
|
+
alignItems: "center",
|
|
5525
|
+
gap: 8
|
|
5526
|
+
};
|
|
5527
|
+
var tokenSymbolStyle2 = (color) => ({
|
|
5528
|
+
fontSize: "0.88rem",
|
|
5529
|
+
fontWeight: 600,
|
|
5530
|
+
color
|
|
5531
|
+
});
|
|
5532
|
+
var statusBadgeStyle = (color) => ({
|
|
5533
|
+
fontSize: "0.65rem",
|
|
5534
|
+
fontWeight: 600,
|
|
5535
|
+
color,
|
|
5536
|
+
border: `1px solid ${color}44`,
|
|
5537
|
+
borderRadius: 999,
|
|
5538
|
+
padding: "1px 7px",
|
|
5539
|
+
letterSpacing: "0.02em"
|
|
5540
|
+
});
|
|
5541
|
+
var tokenBalStyle2 = (color) => ({
|
|
5542
|
+
fontSize: "0.74rem",
|
|
5543
|
+
color
|
|
5544
|
+
});
|
|
5545
|
+
var radioStyle3 = (tokens, selected) => ({
|
|
5546
|
+
width: 20,
|
|
5547
|
+
height: 20,
|
|
5548
|
+
borderRadius: "50%",
|
|
5549
|
+
border: `2px solid ${selected ? tokens.accent : tokens.border}`,
|
|
5550
|
+
display: "flex",
|
|
5551
|
+
alignItems: "center",
|
|
5552
|
+
justifyContent: "center",
|
|
5553
|
+
flexShrink: 0
|
|
5554
|
+
});
|
|
5555
|
+
var radioDotStyle3 = (color) => ({
|
|
5556
|
+
width: 10,
|
|
5557
|
+
height: 10,
|
|
5558
|
+
borderRadius: "50%",
|
|
5559
|
+
background: color
|
|
5560
|
+
});
|
|
5189
5561
|
function StepRenderer({
|
|
5190
5562
|
state,
|
|
5191
5563
|
ready,
|
|
@@ -5295,6 +5667,35 @@ function StepRenderer({
|
|
|
5295
5667
|
}
|
|
5296
5668
|
);
|
|
5297
5669
|
}
|
|
5670
|
+
if (step === "setup-status") {
|
|
5671
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5672
|
+
SetupStatusScreen,
|
|
5673
|
+
{
|
|
5674
|
+
complete: false,
|
|
5675
|
+
limit: state.oneTapLimit,
|
|
5676
|
+
tokensApproved: 0,
|
|
5677
|
+
merchantName,
|
|
5678
|
+
onContinue: () => handlers.onNavigate("setup"),
|
|
5679
|
+
onLogout: handlers.onLogout,
|
|
5680
|
+
error: state.error || authExecutorError
|
|
5681
|
+
}
|
|
5682
|
+
);
|
|
5683
|
+
}
|
|
5684
|
+
if (step === "setup") {
|
|
5685
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5686
|
+
SetupScreen,
|
|
5687
|
+
{
|
|
5688
|
+
availableBalance: selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
|
|
5689
|
+
tokenCount,
|
|
5690
|
+
sourceName,
|
|
5691
|
+
onSetupOneTap: handlers.onSetupOneTap,
|
|
5692
|
+
onBack: () => handlers.onNavigate("deposit"),
|
|
5693
|
+
onLogout: handlers.onLogout,
|
|
5694
|
+
loading: state.creatingTransfer,
|
|
5695
|
+
error: state.error
|
|
5696
|
+
}
|
|
5697
|
+
);
|
|
5698
|
+
}
|
|
5298
5699
|
if (step === "confirm-sign") {
|
|
5299
5700
|
const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
|
|
5300
5701
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5336,7 +5737,23 @@ function StepRenderer({
|
|
|
5336
5737
|
selectedAccountId: state.selectedAccountId,
|
|
5337
5738
|
onSelectAccount: handlers.onSelectAccount,
|
|
5338
5739
|
onAuthorizeAccount: handlers.onContinueConnection,
|
|
5339
|
-
onAddProvider: () => handlers.onNavigate("wallet-picker")
|
|
5740
|
+
onAddProvider: () => handlers.onNavigate("wallet-picker"),
|
|
5741
|
+
onSelectToken: handlers.onSelectToken
|
|
5742
|
+
}
|
|
5743
|
+
);
|
|
5744
|
+
}
|
|
5745
|
+
if (step === "token-picker") {
|
|
5746
|
+
if (!selectedAccount) {
|
|
5747
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SwypeLoadingScreen, {});
|
|
5748
|
+
}
|
|
5749
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5750
|
+
TokenPickerScreen,
|
|
5751
|
+
{
|
|
5752
|
+
account: selectedAccount,
|
|
5753
|
+
chains: state.chains,
|
|
5754
|
+
onSelectAuthorized: handlers.onSelectAuthorizedToken,
|
|
5755
|
+
onAuthorizeToken: handlers.onAuthorizeToken,
|
|
5756
|
+
onBack: () => handlers.onNavigate("deposit")
|
|
5340
5757
|
}
|
|
5341
5758
|
);
|
|
5342
5759
|
}
|
|
@@ -5443,7 +5860,7 @@ var PaymentErrorBoundary = class extends react.Component {
|
|
|
5443
5860
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
5444
5861
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
|
|
5445
5862
|
] }) }),
|
|
5446
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style:
|
|
5863
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle12, children: "Something went wrong" }),
|
|
5447
5864
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
|
|
5448
5865
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
|
|
5449
5866
|
] });
|
|
@@ -5463,7 +5880,7 @@ var containerStyle8 = {
|
|
|
5463
5880
|
var iconStyle4 = {
|
|
5464
5881
|
marginBottom: 20
|
|
5465
5882
|
};
|
|
5466
|
-
var
|
|
5883
|
+
var headingStyle12 = {
|
|
5467
5884
|
fontSize: "1.25rem",
|
|
5468
5885
|
fontWeight: 700,
|
|
5469
5886
|
color: "#1a1a1a",
|
|
@@ -5535,6 +5952,7 @@ function SwypePaymentInner({
|
|
|
5535
5952
|
const processingStartedAtRef = react.useRef(null);
|
|
5536
5953
|
const initializedSelectSourceActionRef = react.useRef(null);
|
|
5537
5954
|
const preSelectSourceStepRef = react.useRef(null);
|
|
5955
|
+
const pendingTokenAuthRef = react.useRef(null);
|
|
5538
5956
|
const checkingPasskeyRef = react.useRef(false);
|
|
5539
5957
|
const onCompleteRef = react.useRef(onComplete);
|
|
5540
5958
|
onCompleteRef.current = onComplete;
|
|
@@ -5962,6 +6380,84 @@ function SwypePaymentInner({
|
|
|
5962
6380
|
reloadAccounts,
|
|
5963
6381
|
onError
|
|
5964
6382
|
]);
|
|
6383
|
+
const handleNavigateToTokenPicker = react.useCallback(() => {
|
|
6384
|
+
dispatch({ type: "NAVIGATE", step: "token-picker" });
|
|
6385
|
+
}, []);
|
|
6386
|
+
const handleSelectAuthorizedToken = react.useCallback((walletId, tokenSymbol) => {
|
|
6387
|
+
dispatch({ type: "SELECT_TOKEN", walletId, tokenSymbol });
|
|
6388
|
+
}, []);
|
|
6389
|
+
const handleAuthorizeToken = react.useCallback(async (_walletId, tokenAddress, chainId, tokenSymbol) => {
|
|
6390
|
+
if (!state.selectedAccountId) {
|
|
6391
|
+
dispatch({ type: "SET_ERROR", error: "No account selected." });
|
|
6392
|
+
return;
|
|
6393
|
+
}
|
|
6394
|
+
if (!state.activeCredentialId) {
|
|
6395
|
+
dispatch({ type: "SET_ERROR", error: "Create a passkey on this device before continuing." });
|
|
6396
|
+
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6397
|
+
return;
|
|
6398
|
+
}
|
|
6399
|
+
const acct = state.accounts.find((a) => a.id === state.selectedAccountId);
|
|
6400
|
+
const matchedProvider = acct ? state.providers.find((p) => p.name === acct.name) : void 0;
|
|
6401
|
+
if (matchedProvider) {
|
|
6402
|
+
dispatch({ type: "SELECT_PROVIDER", providerId: matchedProvider.id });
|
|
6403
|
+
}
|
|
6404
|
+
dispatch({ type: "SET_ERROR", error: null });
|
|
6405
|
+
dispatch({ type: "SET_INCREASING_LIMIT", value: true });
|
|
6406
|
+
pendingTokenAuthRef.current = { tokenAddress, chainId, tokenSymbol, walletId: _walletId };
|
|
6407
|
+
try {
|
|
6408
|
+
const token = await getAccessToken();
|
|
6409
|
+
if (!token) throw new Error("Not authenticated");
|
|
6410
|
+
const session = await createAccountAuthorizationSession(
|
|
6411
|
+
apiBaseUrl,
|
|
6412
|
+
token,
|
|
6413
|
+
state.selectedAccountId,
|
|
6414
|
+
state.activeCredentialId,
|
|
6415
|
+
{ tokenAddress, chainId }
|
|
6416
|
+
);
|
|
6417
|
+
const isMobile = !shouldUseWalletConnector({
|
|
6418
|
+
useWalletConnector: useWalletConnectorProp,
|
|
6419
|
+
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
6420
|
+
});
|
|
6421
|
+
if (isMobile) {
|
|
6422
|
+
handlingMobileReturnRef.current = false;
|
|
6423
|
+
mobileSetupFlowRef.current = true;
|
|
6424
|
+
setupAccountIdRef.current = state.selectedAccountId;
|
|
6425
|
+
persistMobileFlowState({
|
|
6426
|
+
accountId: state.selectedAccountId,
|
|
6427
|
+
sessionId: session.id,
|
|
6428
|
+
deeplinkUri: session.uri,
|
|
6429
|
+
providerId: matchedProvider?.id ?? null,
|
|
6430
|
+
isSetup: true
|
|
6431
|
+
});
|
|
6432
|
+
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6433
|
+
triggerDeeplink(session.uri);
|
|
6434
|
+
} else {
|
|
6435
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6436
|
+
await authExecutor.executeSessionById(session.id);
|
|
6437
|
+
await reloadAccounts();
|
|
6438
|
+
dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
|
|
6439
|
+
}
|
|
6440
|
+
} catch (err) {
|
|
6441
|
+
captureException(err);
|
|
6442
|
+
const msg = err instanceof Error ? err.message : "Failed to authorize token";
|
|
6443
|
+
dispatch({ type: "SET_ERROR", error: msg });
|
|
6444
|
+
onError?.(msg);
|
|
6445
|
+
} finally {
|
|
6446
|
+
pendingTokenAuthRef.current = null;
|
|
6447
|
+
dispatch({ type: "SET_INCREASING_LIMIT", value: false });
|
|
6448
|
+
}
|
|
6449
|
+
}, [
|
|
6450
|
+
state.selectedAccountId,
|
|
6451
|
+
state.activeCredentialId,
|
|
6452
|
+
state.accounts,
|
|
6453
|
+
state.providers,
|
|
6454
|
+
apiBaseUrl,
|
|
6455
|
+
getAccessToken,
|
|
6456
|
+
authExecutor,
|
|
6457
|
+
useWalletConnectorProp,
|
|
6458
|
+
reloadAccounts,
|
|
6459
|
+
onError
|
|
6460
|
+
]);
|
|
5965
6461
|
const handleConfirmSign = react.useCallback(async () => {
|
|
5966
6462
|
const t = state.transfer ?? polling.transfer;
|
|
5967
6463
|
if (!t) return;
|
|
@@ -5999,7 +6495,16 @@ function SwypePaymentInner({
|
|
|
5999
6495
|
}
|
|
6000
6496
|
const provider = state.providers.find((p) => p.id === providerId);
|
|
6001
6497
|
const providerName = provider?.name ?? "Wallet";
|
|
6002
|
-
|
|
6498
|
+
const isMobile = !shouldUseWalletConnector({
|
|
6499
|
+
useWalletConnector: useWalletConnectorProp,
|
|
6500
|
+
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
6501
|
+
});
|
|
6502
|
+
if (isMobile) {
|
|
6503
|
+
dispatch({ type: "PAY_STARTED", isSetupRedirect: true });
|
|
6504
|
+
} else {
|
|
6505
|
+
dispatch({ type: "PAY_STARTED", isSetupRedirect: false });
|
|
6506
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6507
|
+
}
|
|
6003
6508
|
try {
|
|
6004
6509
|
const token = await getAccessToken();
|
|
6005
6510
|
if (!token) throw new Error("Not authenticated");
|
|
@@ -6012,10 +6517,6 @@ function SwypePaymentInner({
|
|
|
6012
6517
|
});
|
|
6013
6518
|
const session = account.authorizationSessions?.[0];
|
|
6014
6519
|
if (!session) throw new Error("No authorization session returned.");
|
|
6015
|
-
const isMobile = !shouldUseWalletConnector({
|
|
6016
|
-
useWalletConnector: useWalletConnectorProp,
|
|
6017
|
-
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
6018
|
-
});
|
|
6019
6520
|
if (isMobile) {
|
|
6020
6521
|
handlingMobileReturnRef.current = false;
|
|
6021
6522
|
mobileSetupFlowRef.current = true;
|
|
@@ -6032,7 +6533,7 @@ function SwypePaymentInner({
|
|
|
6032
6533
|
} else {
|
|
6033
6534
|
await authExecutor.executeSessionById(session.id);
|
|
6034
6535
|
await reloadAccounts();
|
|
6035
|
-
dispatch({ type: "NAVIGATE", step: "
|
|
6536
|
+
dispatch({ type: "NAVIGATE", step: "setup" });
|
|
6036
6537
|
}
|
|
6037
6538
|
} catch (err) {
|
|
6038
6539
|
captureException(err);
|
|
@@ -6076,6 +6577,20 @@ function SwypePaymentInner({
|
|
|
6076
6577
|
},
|
|
6077
6578
|
[state.accounts, depositAmount]
|
|
6078
6579
|
);
|
|
6580
|
+
const handleSetupOneTap = react.useCallback(async (limit) => {
|
|
6581
|
+
try {
|
|
6582
|
+
const token = await getAccessToken();
|
|
6583
|
+
if (!token) throw new Error("Not authenticated");
|
|
6584
|
+
await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
|
|
6585
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
6586
|
+
} catch (err) {
|
|
6587
|
+
captureException(err);
|
|
6588
|
+
dispatch({
|
|
6589
|
+
type: "SET_ERROR",
|
|
6590
|
+
error: err instanceof Error ? err.message : "Failed to save One-Tap limit"
|
|
6591
|
+
});
|
|
6592
|
+
}
|
|
6593
|
+
}, [getAccessToken, apiBaseUrl]);
|
|
6079
6594
|
const handleNewPayment = react.useCallback(() => {
|
|
6080
6595
|
clearMobileFlowState();
|
|
6081
6596
|
processingStartedAtRef.current = null;
|
|
@@ -6312,6 +6827,7 @@ function SwypePaymentInner({
|
|
|
6312
6827
|
checkPasskey();
|
|
6313
6828
|
return () => {
|
|
6314
6829
|
cancelled = true;
|
|
6830
|
+
checkingPasskeyRef.current = false;
|
|
6315
6831
|
};
|
|
6316
6832
|
}, [ready, authenticated, state.step, apiBaseUrl, state.activeCredentialId]);
|
|
6317
6833
|
react.useEffect(() => {
|
|
@@ -6523,7 +7039,7 @@ function SwypePaymentInner({
|
|
|
6523
7039
|
initializedSelectSourceActionRef.current = pendingSelectSourceAction.id;
|
|
6524
7040
|
}, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
|
|
6525
7041
|
react.useEffect(() => {
|
|
6526
|
-
if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet")) {
|
|
7042
|
+
if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet" || state.step === "setup-status")) {
|
|
6527
7043
|
preSelectSourceStepRef.current = state.step;
|
|
6528
7044
|
dispatch({ type: "NAVIGATE", step: "select-source" });
|
|
6529
7045
|
} else if (!pendingSelectSourceAction && state.step === "select-source") {
|
|
@@ -6531,6 +7047,21 @@ function SwypePaymentInner({
|
|
|
6531
7047
|
preSelectSourceStepRef.current = null;
|
|
6532
7048
|
}
|
|
6533
7049
|
}, [pendingSelectSourceAction, state.step]);
|
|
7050
|
+
react.useEffect(() => {
|
|
7051
|
+
if (!pendingSelectSourceAction || !pendingTokenAuthRef.current) return;
|
|
7052
|
+
const { tokenAddress, chainId } = pendingTokenAuthRef.current;
|
|
7053
|
+
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
7054
|
+
const options = pendingSelectSourceAction.metadata?.options ?? [];
|
|
7055
|
+
const match = options.find(
|
|
7056
|
+
(opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
|
|
7057
|
+
);
|
|
7058
|
+
if (match) {
|
|
7059
|
+
authExecutor.resolveSelectSource({
|
|
7060
|
+
chainName: match.chainName,
|
|
7061
|
+
tokenSymbol: match.tokenSymbol
|
|
7062
|
+
});
|
|
7063
|
+
}
|
|
7064
|
+
}, [pendingSelectSourceAction, authExecutor]);
|
|
6534
7065
|
const handlers = react.useMemo(() => ({
|
|
6535
7066
|
onSendLoginCode: handleSendLoginCode,
|
|
6536
7067
|
onVerifyLoginCode: handleVerifyLoginCode,
|
|
@@ -6559,7 +7090,11 @@ function SwypePaymentInner({
|
|
|
6559
7090
|
},
|
|
6560
7091
|
onSelectSourceChainChange: handleSelectSourceChainChange,
|
|
6561
7092
|
onSetSelectSourceTokenSymbol: setSelectSourceTokenSymbol,
|
|
6562
|
-
onConfirmSelectSource: handleConfirmSelectSource
|
|
7093
|
+
onConfirmSelectSource: handleConfirmSelectSource,
|
|
7094
|
+
onSetupOneTap: handleSetupOneTap,
|
|
7095
|
+
onSelectToken: handleNavigateToTokenPicker,
|
|
7096
|
+
onSelectAuthorizedToken: handleSelectAuthorizedToken,
|
|
7097
|
+
onAuthorizeToken: handleAuthorizeToken
|
|
6563
7098
|
}), [
|
|
6564
7099
|
handleSendLoginCode,
|
|
6565
7100
|
handleVerifyLoginCode,
|
|
@@ -6577,7 +7112,11 @@ function SwypePaymentInner({
|
|
|
6577
7112
|
handleLogout,
|
|
6578
7113
|
handleNewPayment,
|
|
6579
7114
|
handleSelectSourceChainChange,
|
|
6580
|
-
handleConfirmSelectSource
|
|
7115
|
+
handleConfirmSelectSource,
|
|
7116
|
+
handleSetupOneTap,
|
|
7117
|
+
handleNavigateToTokenPicker,
|
|
7118
|
+
handleSelectAuthorizedToken,
|
|
7119
|
+
handleAuthorizeToken
|
|
6581
7120
|
]);
|
|
6582
7121
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6583
7122
|
StepRenderer,
|
|
@@ -6633,6 +7172,7 @@ exports.StepList = StepList;
|
|
|
6633
7172
|
exports.SwypeLoadingScreen = SwypeLoadingScreen;
|
|
6634
7173
|
exports.SwypePayment = SwypePayment;
|
|
6635
7174
|
exports.SwypeProvider = SwypeProvider;
|
|
7175
|
+
exports.TokenPickerScreen = TokenPickerScreen;
|
|
6636
7176
|
exports.buildPasskeyPopupOptions = buildPasskeyPopupOptions;
|
|
6637
7177
|
exports.createPasskeyCredential = createPasskeyCredential;
|
|
6638
7178
|
exports.createPasskeyViaPopup = createPasskeyViaPopup;
|