@swype-org/react-sdk 0.2.372 → 0.2.375

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 CHANGED
@@ -523,6 +523,14 @@ function isVisibleUsdAmountAtTwoDecimals(amount) {
523
523
  function isSelectableDepositSourceAmountUsd(amount, minTransferAmountUsd = DEFAULT_MIN_SEND_AMOUNT_USD) {
524
524
  return Number.isFinite(amount) && amount >= minTransferAmountUsd;
525
525
  }
526
+ function buildNativeUnsupportedEntries(options) {
527
+ return options.map((option) => ({
528
+ tokenSymbol: option.tokenSymbol,
529
+ chainName: option.chainName,
530
+ amount: parseRawBalance(option.rawBalance, option.decimals),
531
+ logoURI: option.logoURI ?? null
532
+ })).filter((entry) => entry.amount > 0);
533
+ }
526
534
  function buildSelectSourceChoices(options, minTransferAmountUsd = DEFAULT_MIN_SEND_AMOUNT_USD) {
527
535
  const chainChoices = [];
528
536
  const chainIndexByName = /* @__PURE__ */ new Map();
@@ -1016,10 +1024,6 @@ var BLINK_PRIVY_APP_ID = "cmlil87uv004n0ck0blwumwek";
1016
1024
  var BLINK_WC_PROJECT_ID = "f6c60234412f94ef9108dc8f67f4362c";
1017
1025
  var BLINK_FINGERPRINT_API_KEY = "nr4FvTsZ6M5z2141FqrM";
1018
1026
  var BLINK_FINGERPRINT_REGION = "us";
1019
- function FingerprintVisitorPing() {
1020
- react$1.useVisitorData({ immediate: true });
1021
- return null;
1022
- }
1023
1027
  function buildStaticConnectors() {
1024
1028
  const userAgent = typeof navigator === "undefined" ? null : navigator.userAgent;
1025
1029
  return [
@@ -1128,30 +1132,30 @@ function BlinkProvider({
1128
1132
  );
1129
1133
  return (
1130
1134
  // Outermost wrapper: loads the Fingerprint browser agent once per
1131
- // provider mount, independent of wagmi/privy/query state. Visitor data
1132
- // collection starts here; no hook is exposed yet (see SDK barrel).
1133
- /* @__PURE__ */ jsxRuntime.jsxs(react$1.FingerprintProvider, { apiKey: BLINK_FINGERPRINT_API_KEY, region: BLINK_FINGERPRINT_REGION, children: [
1134
- /* @__PURE__ */ jsxRuntime.jsx(FingerprintVisitorPing, {}),
1135
- /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClientRef.current, children: /* @__PURE__ */ jsxRuntime.jsx(wagmi.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: /* @__PURE__ */ jsxRuntime.jsx(
1136
- reactAuth.PrivyProvider,
1137
- {
1138
- appId: privyAppId ?? BLINK_PRIVY_APP_ID,
1139
- config: {
1140
- appearance: {
1141
- theme: getThemeBase(theme),
1142
- accentColor: getTheme(theme).accent
1143
- },
1144
- intl: {
1145
- defaultCountry: "US"
1146
- },
1147
- embeddedWallets: {
1148
- showWalletUIs: false
1149
- }
1135
+ // provider mount, independent of wagmi/privy/query state. The agent loads
1136
+ // here (including during the hidden preload warm-up), but identification is
1137
+ // deferred to explicit flow events fired from `BlinkPayment` see
1138
+ // `useFingerprintFlowEvents` so a preload that never opens is never
1139
+ // identified.
1140
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.FingerprintProvider, { apiKey: BLINK_FINGERPRINT_API_KEY, region: BLINK_FINGERPRINT_REGION, children: /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClientRef.current, children: /* @__PURE__ */ jsxRuntime.jsx(wagmi.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: /* @__PURE__ */ jsxRuntime.jsx(
1141
+ reactAuth.PrivyProvider,
1142
+ {
1143
+ appId: privyAppId ?? BLINK_PRIVY_APP_ID,
1144
+ config: {
1145
+ appearance: {
1146
+ theme: getThemeBase(theme),
1147
+ accentColor: getTheme(theme).accent
1150
1148
  },
1151
- children: /* @__PURE__ */ jsxRuntime.jsx(BlinkContext.Provider, { value, children })
1152
- }
1153
- ) }) })
1154
- ] })
1149
+ intl: {
1150
+ defaultCountry: "US"
1151
+ },
1152
+ embeddedWallets: {
1153
+ showWalletUIs: false
1154
+ }
1155
+ },
1156
+ children: /* @__PURE__ */ jsxRuntime.jsx(BlinkContext.Provider, { value, children })
1157
+ }
1158
+ ) }) }) })
1155
1159
  );
1156
1160
  }
1157
1161
  function useBlinkConfig() {
@@ -9326,6 +9330,7 @@ var TETHER_LOGO = svgToDataUri(TETHER_SVG);
9326
9330
  var USDH_LOGO = svgToDataUri(USDH_SVG);
9327
9331
  var ETH_LOGO = "https://assets.relay.link/icons/currencies/eth.png";
9328
9332
  var SOL_LOGO = "https://assets.relay.link/icons/currencies/sol.png";
9333
+ var MON_LOGO = "https://assets.relay.link/icons/currencies/mon.png";
9329
9334
  var KNOWN_LOGOS = {
9330
9335
  metamask: METAMASK_LOGO,
9331
9336
  base: BASE_LOGO,
@@ -9343,7 +9348,8 @@ var TOKEN_LOGOS = {
9343
9348
  USDM: USDM_LOGO,
9344
9349
  USDH: USDH_LOGO,
9345
9350
  ETH: ETH_LOGO,
9346
- SOL: SOL_LOGO
9351
+ SOL: SOL_LOGO,
9352
+ MON: MON_LOGO
9347
9353
  };
9348
9354
  var CHAIN_LOGOS = {
9349
9355
  base: BASE_CHAIN_LOGO,
@@ -10368,6 +10374,7 @@ function TokenSourceRow({
10368
10374
  chainName,
10369
10375
  tokenLogoUri,
10370
10376
  balance,
10377
+ balanceLabel,
10371
10378
  selected,
10372
10379
  requiresAuth,
10373
10380
  notSupported,
@@ -10376,9 +10383,10 @@ function TokenSourceRow({
10376
10383
  const { tokens } = useBlinkConfig();
10377
10384
  const [hovered, setHovered] = react.useState(false);
10378
10385
  const tokenLogo = tokenLogoUri ?? TOKEN_LOGOS[symbol];
10386
+ const balanceText = balanceLabel ?? (balance != null ? `$${formatUsdTwoDecimals2(balance)}` : null);
10379
10387
  const ariaLabel = [
10380
10388
  `${symbol} on ${chainName}`,
10381
- balance != null ? `$${formatUsdTwoDecimals2(balance)} balance` : null,
10389
+ balanceText != null ? `${balanceText} balance` : null,
10382
10390
  requiresAuth ? "authorisation required" : null,
10383
10391
  notSupported ? NOT_SUPPORTED_LABEL.toLowerCase() : null
10384
10392
  ].filter(Boolean).join(", ");
@@ -10412,15 +10420,12 @@ function TokenSourceRow({
10412
10420
  selected && /* @__PURE__ */ jsxRuntime.jsx(SelectedBadge, { accent: tokens.accent, fill: tokens.textInverse })
10413
10421
  ] }),
10414
10422
  /* @__PURE__ */ jsxRuntime.jsxs("span", { style: textColStyle2, children: [
10415
- notSupported ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: symbolLineStyle, children: [
10416
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: symbolStyle(tokens.textMuted), children: symbol }),
10417
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: notSupportedTagStyle(tokens.bgInput, tokens.border, tokens.textMuted), children: NOT_SUPPORTED_BADGE_TEXT })
10418
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: symbolStyle(tokens.text), children: symbol }),
10423
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: symbolStyle(notSupported ? tokens.textMuted : tokens.text), children: symbol }),
10419
10424
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: chainStyle(tokens.textMuted), children: chainName })
10420
10425
  ] }),
10421
- balance != null && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: balanceStyle2(tokens.textMuted), children: [
10422
- "$",
10423
- formatUsdTwoDecimals2(balance)
10426
+ (balanceText != null || notSupported) && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: balanceColStyle, children: [
10427
+ balanceText != null && /* @__PURE__ */ jsxRuntime.jsx("span", { style: balanceStyle2(tokens.textMuted), children: balanceText }),
10428
+ notSupported && /* @__PURE__ */ jsxRuntime.jsx("span", { style: notSupportedTagStyle(tokens.bgInput, tokens.border, tokens.textMuted), children: NOT_SUPPORTED_BADGE_TEXT })
10424
10429
  ] })
10425
10430
  ]
10426
10431
  }
@@ -10529,11 +10534,12 @@ var balanceStyle2 = (color) => ({
10529
10534
  whiteSpace: "nowrap",
10530
10535
  flexShrink: 0
10531
10536
  });
10532
- var symbolLineStyle = {
10537
+ var balanceColStyle = {
10533
10538
  display: "flex",
10534
- alignItems: "center",
10535
- gap: 6,
10536
- minWidth: 0
10539
+ flexDirection: "column",
10540
+ alignItems: "flex-end",
10541
+ gap: 4,
10542
+ flexShrink: 0
10537
10543
  };
10538
10544
  var notSupportedTagStyle = (bg, borderColor, color) => ({
10539
10545
  fontSize: 11,
@@ -13375,7 +13381,7 @@ function LinkTokensScreen({
13375
13381
  }
13376
13382
  ),
13377
13383
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle10, children: [
13378
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle7(t.text), children: "Pick your asset for passkey deposits" }),
13384
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle7(t.text), children: "Pick your stablecoin for passkey deposits" }),
13379
13385
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "blink-link-tokens-list", style: listCardStyle(t.bgRecessed), children: [
13380
13386
  showShimmer ? Array.from({ length: SHIMMER_ROWS }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs(
13381
13387
  "div",
@@ -13398,7 +13404,9 @@ function LinkTokensScreen({
13398
13404
  {
13399
13405
  symbol: entry.tokenSymbol,
13400
13406
  chainName: entry.chainName,
13401
- balance: entry.balanceUsd,
13407
+ tokenLogoUri: entry.tokenLogoUri,
13408
+ balance: entry.balanceLabel == null ? entry.balanceUsd : void 0,
13409
+ balanceLabel: entry.balanceLabel,
13402
13410
  selected: i === selectedIndex,
13403
13411
  notSupported: entry.notSupported,
13404
13412
  onClick: () => onSelect(i)
@@ -17010,6 +17018,14 @@ var genericStackStyle = {
17010
17018
  gap: 14
17011
17019
  };
17012
17020
 
17021
+ // src/feeFormat.ts
17022
+ function formatNativeAmount(value, maxDecimals = 4) {
17023
+ if (!Number.isFinite(value) || value <= 0) return "0";
17024
+ const rounded = Number(value.toFixed(maxDecimals));
17025
+ if (rounded === 0) return `< ${(10 ** -maxDecimals).toFixed(maxDecimals)}`;
17026
+ return rounded.toLocaleString("en-US", { maximumFractionDigits: maxDecimals }).replace(/,/g, "");
17027
+ }
17028
+
17013
17029
  // src/screenViewModels.ts
17014
17030
  function findSelectedWallet(selectedAccount, selectedWalletId) {
17015
17031
  return selectedAccount?.wallets.find((w) => w.id === selectedWalletId);
@@ -17176,7 +17192,11 @@ function buildLinkTokensScreenProps({
17176
17192
  walletId: rawOption?.walletId,
17177
17193
  tokenAddress: rawOption?.tokenAddress,
17178
17194
  chainId: rawOption?.chainId != null ? Number(rawOption.chainId) : void 0,
17179
- notSupported: false
17195
+ notSupported: false,
17196
+ // Server-provided token logo (token_addresses.logo_uri). The component
17197
+ // falls back to the bundled TOKEN_LOGOS map by symbol, so tokens without
17198
+ // a bundled asset (e.g. CASH) rely on this DB-driven URI.
17199
+ tokenLogoUri: t.logoURI ?? void 0
17180
17200
  };
17181
17201
  })
17182
17202
  );
@@ -17186,19 +17206,32 @@ function buildLinkTokensScreenProps({
17186
17206
  symbol: t.tokenSymbol,
17187
17207
  chainName: chain.chainName,
17188
17208
  balanceUsd: t.balance ?? 0,
17189
- walletId: void 0,
17190
- tokenAddress: void 0,
17191
- chainId: void 0,
17192
- notSupported: true
17209
+ notSupported: true,
17210
+ tokenLogoUri: t.logoURI ?? void 0
17193
17211
  }))
17194
17212
  )
17195
17213
  );
17196
- const entries2 = rowContexts.map(({ symbol, chainName, balanceUsd, notSupported }) => ({
17197
- tokenSymbol: symbol,
17198
- chainName,
17199
- balanceUsd,
17200
- notSupported
17201
- }));
17214
+ rowContexts.push(
17215
+ ...derived.selectSourceNativeChoices.map((native) => ({
17216
+ symbol: native.tokenSymbol,
17217
+ chainName: native.chainName,
17218
+ balanceUsd: 0,
17219
+ notSupported: true,
17220
+ tokenLogoUri: native.logoURI ?? void 0,
17221
+ balanceLabel: `${formatNativeAmount(native.amount)} ${native.tokenSymbol}`
17222
+ }))
17223
+ );
17224
+ const entries2 = rowContexts.map(
17225
+ ({ symbol, chainName, balanceUsd, notSupported, tokenLogoUri, balanceLabel }) => ({
17226
+ tokenSymbol: symbol,
17227
+ chainName,
17228
+ balanceUsd,
17229
+ notSupported,
17230
+ // Only present on native rows — keeps stablecoin / WC entries unchanged.
17231
+ ...tokenLogoUri != null ? { tokenLogoUri } : {},
17232
+ ...balanceLabel != null ? { balanceLabel } : {}
17233
+ })
17234
+ );
17202
17235
  const firstSupportedIndex = rowContexts.findIndex((row) => !row.notSupported);
17203
17236
  const selectedTokenSymbol = flow.state.setupDepositToken?.symbol ?? derived.selectSourceRecommended?.tokenSymbol;
17204
17237
  const selectedChainName = flow.state.setupDepositToken?.chainName ?? derived.selectSourceRecommended?.chainName;
@@ -18201,6 +18234,11 @@ function useSourceSelectionHandlers(_dispatch, orchestrator, options) {
18201
18234
  const unsupportedOptions = pendingSelectSourceAction.metadata?.unsupportedOptions ?? [];
18202
18235
  return buildSelectSourceChoices(unsupportedOptions, minTransferAmountUsd);
18203
18236
  }, [pendingSelectSourceAction, minTransferAmountUsd]);
18237
+ const selectSourceNativeChoices = react.useMemo(() => {
18238
+ if (!pendingSelectSourceAction) return [];
18239
+ const nativeOptions = pendingSelectSourceAction.metadata?.nativeUnsupportedOptions ?? [];
18240
+ return buildNativeUnsupportedEntries(nativeOptions);
18241
+ }, [pendingSelectSourceAction]);
18204
18242
  const selectSourceRecommended = react.useMemo(() => {
18205
18243
  if (!pendingSelectSourceAction) return null;
18206
18244
  return pendingSelectSourceAction.metadata?.recommended ?? null;
@@ -18252,6 +18290,7 @@ function useSourceSelectionHandlers(_dispatch, orchestrator, options) {
18252
18290
  setSelectSourceTokenSymbol,
18253
18291
  selectSourceChoices,
18254
18292
  selectSourceUnsupportedChoices,
18293
+ selectSourceNativeChoices,
18255
18294
  selectSourceRecommended,
18256
18295
  selectSourceAvailableBalance,
18257
18296
  handleSelectSourceChainChange,
@@ -20783,6 +20822,33 @@ function usePersistAmountToActiveSession({
20783
20822
  });
20784
20823
  }, [apiBaseUrl, sessionId, effectiveDepositAmount]);
20785
20824
  }
20825
+ function useFingerprintFlowEvents(deps) {
20826
+ const { ready, authenticated, merchantId } = deps;
20827
+ const { getData } = react$1.useVisitorData({ immediate: false });
20828
+ const openedSentRef = react.useRef(false);
20829
+ const authenticatedSentRef = react.useRef(false);
20830
+ react.useEffect(() => {
20831
+ if (openedSentRef.current) return;
20832
+ openedSentRef.current = true;
20833
+ void getData({
20834
+ tag: { event: "blink_opened", ...merchantId ? { merchantId } : {} },
20835
+ ...merchantId ? { linkedId: merchantId } : {}
20836
+ }).catch((error) => {
20837
+ console.error("Fingerprint blink_opened event failed", error);
20838
+ });
20839
+ }, [getData, merchantId]);
20840
+ react.useEffect(() => {
20841
+ if (authenticatedSentRef.current) return;
20842
+ if (!ready || !authenticated) return;
20843
+ authenticatedSentRef.current = true;
20844
+ void getData({
20845
+ tag: { event: "blink_authenticated", ...merchantId ? { merchantId } : {} },
20846
+ ...merchantId ? { linkedId: merchantId } : {}
20847
+ }).catch((error) => {
20848
+ console.error("Fingerprint blink_authenticated event failed", error);
20849
+ });
20850
+ }, [getData, ready, authenticated, merchantId]);
20851
+ }
20786
20852
  var NoMatchingExtensionError = class extends Error {
20787
20853
  constructor() {
20788
20854
  super("No installed EIP-6963 extension matches the selected wallet");
@@ -20821,6 +20887,11 @@ function BlinkPaymentInner({
20821
20887
  return true;
20822
20888
  })();
20823
20889
  const effectiveAuthenticated = authenticated || popupAuthValid;
20890
+ useFingerprintFlowEvents({
20891
+ ready,
20892
+ authenticated: effectiveAuthenticated,
20893
+ merchantId: merchantAuthorization?.merchantId
20894
+ });
20824
20895
  const effectiveGetAccessToken = react.useCallback(async () => {
20825
20896
  if (popupAuthRef.current) {
20826
20897
  if (isPopupAuthExpired(popupAuthRef.current.accessToken)) {
@@ -21429,6 +21500,7 @@ function BlinkPaymentInner({
21429
21500
  selectedSource: derived.selectedSource,
21430
21501
  selectSourceChoices: sourceSelection.selectSourceChoices,
21431
21502
  selectSourceUnsupportedChoices: sourceSelection.selectSourceUnsupportedChoices,
21503
+ selectSourceNativeChoices: sourceSelection.selectSourceNativeChoices,
21432
21504
  selectSourceRecommended: sourceSelection.selectSourceRecommended,
21433
21505
  selectSourceAvailableBalance: sourceSelection.selectSourceAvailableBalance,
21434
21506
  walletConnectChainIdsByAccount
@@ -21499,6 +21571,7 @@ exports.WalletPickerScreen = WalletPickerScreen;
21499
21571
  exports.WelcomeBackScreen = WelcomeBackScreen;
21500
21572
  exports.appendDebug = appendDebug;
21501
21573
  exports.blinkApi = api_exports;
21574
+ exports.buildNativeUnsupportedEntries = buildNativeUnsupportedEntries;
21502
21575
  exports.clearDebugEntries = clearDebugEntries;
21503
21576
  exports.createInitialState = createInitialState;
21504
21577
  exports.credentialIdBase64ToBytes = credentialIdBase64ToBytes;
@@ -21510,6 +21583,7 @@ exports.deviceHasPasskey = deviceHasPasskey;
21510
21583
  exports.encodePermit2ApproveCalldata = encodePermit2ApproveCalldata;
21511
21584
  exports.findDevicePasskey = findDevicePasskey;
21512
21585
  exports.findDevicePasskeyViaPopup = findDevicePasskeyViaPopup;
21586
+ exports.formatNativeAmount = formatNativeAmount;
21513
21587
  exports.getAtomicBatchSupportDebugInfo = getAtomicBatchSupportDebugInfo;
21514
21588
  exports.getDebugEntries = getDebugEntries;
21515
21589
  exports.getDeviceBiometricUnlockText = getDeviceBiometricUnlockText;