@swype-org/react-sdk 0.2.232 → 0.2.237
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 +76 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +77 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1605,6 +1605,7 @@ __export(api_exports, {
|
|
|
1605
1605
|
fetchUserConfig: () => fetchUserConfig,
|
|
1606
1606
|
postTransferQuote: () => postTransferQuote,
|
|
1607
1607
|
probeActionCompletion: () => probeActionCompletion,
|
|
1608
|
+
refreshManualTransferQuote: () => refreshManualTransferQuote,
|
|
1608
1609
|
registerPasskey: () => registerPasskey,
|
|
1609
1610
|
reportActionCompletion: () => reportActionCompletion,
|
|
1610
1611
|
reportPasskeyActivity: () => reportPasskeyActivity,
|
|
@@ -2031,6 +2032,14 @@ async function fetchManualTransferSession(apiBaseUrl, sessionId) {
|
|
|
2031
2032
|
if (!res.ok) await throwApiError(res);
|
|
2032
2033
|
return await res.json();
|
|
2033
2034
|
}
|
|
2035
|
+
async function refreshManualTransferQuote(apiBaseUrl, sessionId) {
|
|
2036
|
+
const res = await fetch(
|
|
2037
|
+
`${apiBaseUrl}/v1/manual-transfers/${sessionId}/refresh-quote`,
|
|
2038
|
+
{ method: "POST" }
|
|
2039
|
+
);
|
|
2040
|
+
if (!res.ok) await throwApiError(res);
|
|
2041
|
+
return await res.json();
|
|
2042
|
+
}
|
|
2034
2043
|
async function reportActionCompletion(apiBaseUrl, actionId, result) {
|
|
2035
2044
|
const res = await fetchWithRetry(
|
|
2036
2045
|
`${apiBaseUrl}/v1/authorization-actions/${actionId}`,
|
|
@@ -8264,7 +8273,6 @@ function toTransfer(session) {
|
|
|
8264
8273
|
};
|
|
8265
8274
|
}
|
|
8266
8275
|
var SOLANA_CHAIN_ID = 792703809;
|
|
8267
|
-
var TRON_CHAIN_ID = 728126428;
|
|
8268
8276
|
var SOLANA_NATIVE_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
8269
8277
|
function formatDepositUri(address, chainId, depToken) {
|
|
8270
8278
|
if (chainId === SOLANA_CHAIN_ID) {
|
|
@@ -8273,10 +8281,7 @@ function formatDepositUri(address, chainId, depToken) {
|
|
|
8273
8281
|
}
|
|
8274
8282
|
return `solana:${address}?spl-token=${depToken}`;
|
|
8275
8283
|
}
|
|
8276
|
-
|
|
8277
|
-
return address;
|
|
8278
|
-
}
|
|
8279
|
-
return `ethereum:${address}@${chainId}`;
|
|
8284
|
+
return address;
|
|
8280
8285
|
}
|
|
8281
8286
|
|
|
8282
8287
|
// src/hooks/useManualTransferSession.ts
|
|
@@ -8309,11 +8314,11 @@ function useManualTransferSession({
|
|
|
8309
8314
|
setSourceOptions(sources);
|
|
8310
8315
|
setLoadingSources(false);
|
|
8311
8316
|
const defaultOption = sources.find(
|
|
8312
|
-
(opt) => opt.tokenSymbol === "USDC" && opt.chainId ===
|
|
8317
|
+
(opt) => opt.tokenSymbol === "USDC" && opt.chainId === 792703809
|
|
8313
8318
|
);
|
|
8314
8319
|
if (defaultOption) {
|
|
8315
8320
|
setSelectedToken("USDC");
|
|
8316
|
-
setSelectedChainId("
|
|
8321
|
+
setSelectedChainId("792703809");
|
|
8317
8322
|
}
|
|
8318
8323
|
}
|
|
8319
8324
|
}).catch((err) => {
|
|
@@ -8335,7 +8340,9 @@ function useManualTransferSession({
|
|
|
8335
8340
|
const timer = window.setTimeout(() => setQrReady(true), 1200);
|
|
8336
8341
|
return () => window.clearTimeout(timer);
|
|
8337
8342
|
}, [depositAddress]);
|
|
8338
|
-
const
|
|
8343
|
+
const lastFeeCopyRef = react.useRef(null);
|
|
8344
|
+
const nextFeeCopy = session ? feeCopy(session) : null;
|
|
8345
|
+
const sessionFeeCopy = nextFeeCopy === lastFeeCopyRef.current ? lastFeeCopyRef.current : lastFeeCopyRef.current = nextFeeCopy;
|
|
8339
8346
|
const advanceMockStatus = react.useCallback((status) => {
|
|
8340
8347
|
setSession((prev) => prev ? { ...prev, status } : prev);
|
|
8341
8348
|
}, []);
|
|
@@ -8347,6 +8354,21 @@ function useManualTransferSession({
|
|
|
8347
8354
|
}, 2e3);
|
|
8348
8355
|
return () => window.clearInterval(timer);
|
|
8349
8356
|
}, [apiBaseUrl, mock, session?.sessionId, session?.status]);
|
|
8357
|
+
react.useEffect(() => {
|
|
8358
|
+
if (mock) return;
|
|
8359
|
+
if (!session?.sessionId || session.status !== "awaiting_deposit") return;
|
|
8360
|
+
const sessionId = session.sessionId;
|
|
8361
|
+
const timer = window.setInterval(() => {
|
|
8362
|
+
refreshManualTransferQuote(apiBaseUrl, sessionId).then(({ quoteValidUntil, minAmountUsd, slippage }) => {
|
|
8363
|
+
setSession(
|
|
8364
|
+
(prev) => prev && prev.sessionId === sessionId ? { ...prev, quoteValidUntil, minAmountUsd, slippage } : prev
|
|
8365
|
+
);
|
|
8366
|
+
}).catch((err) => {
|
|
8367
|
+
console.warn("[manual-transfer] refresh quote failed", err);
|
|
8368
|
+
});
|
|
8369
|
+
}, 1e4);
|
|
8370
|
+
return () => window.clearInterval(timer);
|
|
8371
|
+
}, [apiBaseUrl, mock, session?.sessionId, session?.status]);
|
|
8350
8372
|
react.useEffect(() => {
|
|
8351
8373
|
if (session?.status !== "completed") return;
|
|
8352
8374
|
if (completedRef.current === session.sessionId) return;
|
|
@@ -8369,6 +8391,15 @@ function useManualTransferSession({
|
|
|
8369
8391
|
return true;
|
|
8370
8392
|
});
|
|
8371
8393
|
}, [sourceOptions]);
|
|
8394
|
+
const tokenLogoUriBySymbol = react.useMemo(() => {
|
|
8395
|
+
const out = {};
|
|
8396
|
+
for (const opt of sourceOptions ?? []) {
|
|
8397
|
+
if (out[opt.tokenSymbol] == null) {
|
|
8398
|
+
out[opt.tokenSymbol] = opt.tokenLogoUri;
|
|
8399
|
+
}
|
|
8400
|
+
}
|
|
8401
|
+
return out;
|
|
8402
|
+
}, [sourceOptions]);
|
|
8372
8403
|
const selectedOption = react.useMemo(
|
|
8373
8404
|
() => (sourceOptions ?? []).find(
|
|
8374
8405
|
(opt) => opt.tokenSymbol === selectedToken && String(opt.chainId) === selectedChainId
|
|
@@ -8521,6 +8552,7 @@ function useManualTransferSession({
|
|
|
8521
8552
|
copiedAddress,
|
|
8522
8553
|
tokenChoices,
|
|
8523
8554
|
chainChoices,
|
|
8555
|
+
tokenLogoUriBySymbol,
|
|
8524
8556
|
selectedOption,
|
|
8525
8557
|
tokensForSelectedChain,
|
|
8526
8558
|
chainsForSelectedToken,
|
|
@@ -9853,12 +9885,14 @@ var trailingStyle = {
|
|
|
9853
9885
|
function TokenChainIcons({
|
|
9854
9886
|
tokenSymbol,
|
|
9855
9887
|
chainName,
|
|
9888
|
+
tokenLogoUri,
|
|
9889
|
+
chainLogoUri,
|
|
9856
9890
|
size = 28,
|
|
9857
9891
|
overlap = 12
|
|
9858
9892
|
}) {
|
|
9859
|
-
const tokenLogo = tokenSymbol ? TOKEN_LOGOS[tokenSymbol] : void 0;
|
|
9893
|
+
const tokenLogo = tokenLogoUri ?? (tokenSymbol ? TOKEN_LOGOS[tokenSymbol] : void 0);
|
|
9860
9894
|
const chainKey = chainName ? chainName.toLowerCase() : void 0;
|
|
9861
|
-
const chainLogo = chainKey ? CHAIN_LOGOS[chainKey] : void 0;
|
|
9895
|
+
const chainLogo = chainLogoUri ?? (chainKey ? CHAIN_LOGOS[chainKey] : void 0);
|
|
9862
9896
|
const chainInitial = chainName ? chainName.charAt(0).toUpperCase() : "?";
|
|
9863
9897
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { style: wrapStyle2(overlap), children: [
|
|
9864
9898
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: tokenCircleStyle(size, overlap, 2), children: tokenLogo ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -10070,6 +10104,7 @@ function formatUsdTwoDecimals2(value) {
|
|
|
10070
10104
|
function TokenSourceRow({
|
|
10071
10105
|
symbol,
|
|
10072
10106
|
chainName,
|
|
10107
|
+
tokenLogoUri,
|
|
10073
10108
|
balance,
|
|
10074
10109
|
selected,
|
|
10075
10110
|
requiresAuth,
|
|
@@ -10077,7 +10112,7 @@ function TokenSourceRow({
|
|
|
10077
10112
|
}) {
|
|
10078
10113
|
const { tokens } = useBlinkConfig();
|
|
10079
10114
|
const [hovered, setHovered] = react.useState(false);
|
|
10080
|
-
const tokenLogo = TOKEN_LOGOS[symbol];
|
|
10115
|
+
const tokenLogo = tokenLogoUri ?? TOKEN_LOGOS[symbol];
|
|
10081
10116
|
const ariaLabel = [
|
|
10082
10117
|
`${symbol} on ${chainName}`,
|
|
10083
10118
|
balance != null ? `$${formatUsdTwoDecimals2(balance)} balance` : null,
|
|
@@ -10341,7 +10376,7 @@ var errorBoxStyle = (size, bg, color) => ({
|
|
|
10341
10376
|
textAlign: "center"
|
|
10342
10377
|
});
|
|
10343
10378
|
var QR_BOX_SIZE = 251;
|
|
10344
|
-
function
|
|
10379
|
+
function DepositQrCodeImpl({
|
|
10345
10380
|
address,
|
|
10346
10381
|
chainId,
|
|
10347
10382
|
depToken
|
|
@@ -10370,6 +10405,7 @@ function DepositQrCode({
|
|
|
10370
10405
|
/* @__PURE__ */ jsxRuntime.jsx("img", { src: BLINK_QR_LOGO, alt: "", style: qrLogoStyle })
|
|
10371
10406
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: tokens.textMuted, fontSize: 13 }, children: "QR unavailable" }) });
|
|
10372
10407
|
}
|
|
10408
|
+
var DepositQrCode = react.memo(DepositQrCodeImpl);
|
|
10373
10409
|
var qrFrameStyle = (bgCardTranslucent) => ({
|
|
10374
10410
|
alignItems: "center",
|
|
10375
10411
|
alignSelf: "center",
|
|
@@ -10507,7 +10543,8 @@ function CompactTokenSelect({
|
|
|
10507
10543
|
value,
|
|
10508
10544
|
onValueChange,
|
|
10509
10545
|
options,
|
|
10510
|
-
availableTokens
|
|
10546
|
+
availableTokens,
|
|
10547
|
+
tokenLogoUriBySymbol
|
|
10511
10548
|
}) {
|
|
10512
10549
|
const { tokens } = useBlinkConfig();
|
|
10513
10550
|
const [hovered, setHovered] = react.useState(false);
|
|
@@ -10532,7 +10569,7 @@ function CompactTokenSelect({
|
|
|
10532
10569
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10533
10570
|
LogoCircle,
|
|
10534
10571
|
{
|
|
10535
|
-
src: TOKEN_LOGOS[value],
|
|
10572
|
+
src: tokenLogoUriBySymbol?.[value] ?? TOKEN_LOGOS[value],
|
|
10536
10573
|
fallback: (value || "?").charAt(0),
|
|
10537
10574
|
size: 28
|
|
10538
10575
|
}
|
|
@@ -10579,7 +10616,7 @@ function CompactTokenSelect({
|
|
|
10579
10616
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10580
10617
|
LogoCircle,
|
|
10581
10618
|
{
|
|
10582
|
-
src: TOKEN_LOGOS[token],
|
|
10619
|
+
src: tokenLogoUriBySymbol?.[token] ?? TOKEN_LOGOS[token],
|
|
10583
10620
|
fallback: token.charAt(0),
|
|
10584
10621
|
size: 28
|
|
10585
10622
|
}
|
|
@@ -10629,7 +10666,7 @@ function CompactChainSelect({
|
|
|
10629
10666
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10630
10667
|
LogoCircle,
|
|
10631
10668
|
{
|
|
10632
|
-
src: CHAIN_LOGOS[selected?.chainName.toLowerCase() ?? ""],
|
|
10669
|
+
src: selected?.chainLogoUri ?? CHAIN_LOGOS[selected?.chainName.toLowerCase() ?? ""],
|
|
10633
10670
|
fallback: (selected?.chainName ?? "?").charAt(0),
|
|
10634
10671
|
size: 28,
|
|
10635
10672
|
preserveShape: true
|
|
@@ -10677,7 +10714,7 @@ function CompactChainSelect({
|
|
|
10677
10714
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10678
10715
|
LogoCircle,
|
|
10679
10716
|
{
|
|
10680
|
-
src: CHAIN_LOGOS[opt.chainName.toLowerCase()],
|
|
10717
|
+
src: opt.chainLogoUri ?? CHAIN_LOGOS[opt.chainName.toLowerCase()],
|
|
10681
10718
|
fallback: opt.chainName.charAt(0),
|
|
10682
10719
|
size: 28,
|
|
10683
10720
|
preserveShape: true
|
|
@@ -13210,6 +13247,8 @@ function SetupDepositScreen({
|
|
|
13210
13247
|
tokenSelectionLoading = false,
|
|
13211
13248
|
selectedTokenSymbol,
|
|
13212
13249
|
selectedChainName,
|
|
13250
|
+
selectedTokenLogoUri,
|
|
13251
|
+
selectedChainLogoUri,
|
|
13213
13252
|
tokenOptions,
|
|
13214
13253
|
onSelectToken,
|
|
13215
13254
|
quoteFee,
|
|
@@ -13337,7 +13376,9 @@ function SetupDepositScreen({
|
|
|
13337
13376
|
TokenChainIcons,
|
|
13338
13377
|
{
|
|
13339
13378
|
tokenSymbol: selectedTokenSymbol,
|
|
13340
|
-
chainName: selectedChainName
|
|
13379
|
+
chainName: selectedChainName,
|
|
13380
|
+
tokenLogoUri: selectedTokenLogoUri,
|
|
13381
|
+
chainLogoUri: selectedChainLogoUri
|
|
13341
13382
|
}
|
|
13342
13383
|
),
|
|
13343
13384
|
name: selectedTokenSymbol,
|
|
@@ -13849,6 +13890,8 @@ function DepositScreen({
|
|
|
13849
13890
|
onCommitTokenAuthorization,
|
|
13850
13891
|
selectedTokenSymbol,
|
|
13851
13892
|
selectedChainName,
|
|
13893
|
+
selectedTokenLogoUri,
|
|
13894
|
+
selectedChainLogoUri,
|
|
13852
13895
|
selectedWalletId,
|
|
13853
13896
|
selectedTokenStatus,
|
|
13854
13897
|
onAuthorizeSelectedToken,
|
|
@@ -13952,7 +13995,9 @@ function DepositScreen({
|
|
|
13952
13995
|
TokenChainIcons,
|
|
13953
13996
|
{
|
|
13954
13997
|
tokenSymbol: selectedTokenSymbol,
|
|
13955
|
-
chainName: selectedChainName
|
|
13998
|
+
chainName: selectedChainName,
|
|
13999
|
+
tokenLogoUri: selectedTokenLogoUri,
|
|
14000
|
+
chainLogoUri: selectedChainLogoUri
|
|
13956
14001
|
}
|
|
13957
14002
|
),
|
|
13958
14003
|
name: selectedProviderName,
|
|
@@ -14855,6 +14900,7 @@ function DepositAddressScreen({
|
|
|
14855
14900
|
selectedChainId,
|
|
14856
14901
|
tokenChoices,
|
|
14857
14902
|
chainChoices,
|
|
14903
|
+
tokenLogoUriBySymbol,
|
|
14858
14904
|
selectedOption,
|
|
14859
14905
|
tokensForSelectedChain,
|
|
14860
14906
|
chainsForSelectedToken,
|
|
@@ -14949,7 +14995,8 @@ function DepositAddressScreen({
|
|
|
14949
14995
|
value: selectedToken,
|
|
14950
14996
|
onValueChange: selectToken,
|
|
14951
14997
|
options: tokenChoices,
|
|
14952
|
-
availableTokens: tokensForSelectedChain
|
|
14998
|
+
availableTokens: tokensForSelectedChain,
|
|
14999
|
+
tokenLogoUriBySymbol
|
|
14953
15000
|
}
|
|
14954
15001
|
),
|
|
14955
15002
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -14987,12 +15034,18 @@ function DepositAddressScreen({
|
|
|
14987
15034
|
}
|
|
14988
15035
|
),
|
|
14989
15036
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: bodyStyle3(tokens.textMuted), children: selectedOption ? session ? `Send ${selectedOption.tokenSymbol} on ${selectedOption.chainName}. Minimum $${session.minAmountUsd}.` : `Send ${selectedOption.tokenSymbol} on ${selectedOption.chainName}.` : "\xA0" }),
|
|
14990
|
-
sessionFeeCopy && /* @__PURE__ */ jsxRuntime.jsx(
|
|
15037
|
+
sessionFeeCopy && /* @__PURE__ */ jsxRuntime.jsx(FeeRow, { feeCopy: sessionFeeCopy, color: tokens.textMuted })
|
|
14991
15038
|
] }),
|
|
14992
15039
|
error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: errorStyle2(tokens.error), children: error })
|
|
14993
15040
|
] })
|
|
14994
15041
|
] });
|
|
14995
15042
|
}
|
|
15043
|
+
var FeeRow = react.memo(function FeeRow2({
|
|
15044
|
+
feeCopy: feeCopy2,
|
|
15045
|
+
color
|
|
15046
|
+
}) {
|
|
15047
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { style: bodyStyle3(color), children: feeCopy2 });
|
|
15048
|
+
});
|
|
14996
15049
|
var contentStyle17 = {
|
|
14997
15050
|
alignItems: "center",
|
|
14998
15051
|
display: "flex",
|
|
@@ -15949,6 +16002,7 @@ function ManualTransferFlow({
|
|
|
15949
16002
|
copiedAddress,
|
|
15950
16003
|
tokenChoices,
|
|
15951
16004
|
chainChoices,
|
|
16005
|
+
tokenLogoUriBySymbol,
|
|
15952
16006
|
selectedOption,
|
|
15953
16007
|
tokensForSelectedChain,
|
|
15954
16008
|
chainsForSelectedToken,
|
|
@@ -16002,6 +16056,7 @@ function ManualTransferFlow({
|
|
|
16002
16056
|
selectedChainId,
|
|
16003
16057
|
tokenChoices,
|
|
16004
16058
|
chainChoices,
|
|
16059
|
+
tokenLogoUriBySymbol,
|
|
16005
16060
|
selectedOption,
|
|
16006
16061
|
tokensForSelectedChain,
|
|
16007
16062
|
chainsForSelectedToken,
|