@daimo/pay 1.10.0 → 1.10.2

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/build/index.js CHANGED
@@ -2,7 +2,7 @@ import { http, useConnectors as useConnectors$1, useAccount, useSwitchChain, use
2
2
  import { mainnet, base as base$1, polygon, optimism, arbitrum, linea, bsc, sepolia, baseSepolia, worldchain, mantle } from 'wagmi/chains';
3
3
  import { safe, injected, coinbaseWallet, walletConnect } from '@wagmi/connectors';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import { DaimoPayIntentStatus, assert, DaimoPayOrderMode, isHydrated, readDaimoPayOrderID, getOrderDestChainId, assertNotNull, getChainName, arbitrum as arbitrum$1, base as base$2, bsc as bsc$1, ethereum, linea as linea$1, mantle as mantle$1, optimism as optimism$1, polygon as polygon$1, worldchain as worldchain$1, solana, getAddressContraction, supportedChains, getChainExplorerTxUrl, ExternalPaymentOptions, DepositAddressPaymentOptions, ethereumUSDC, polygonUSDC, baseUSDC, arbitrumUSDC, optimismUSDC, isCCTPV1Chain, debugJson, writeDaimoPayOrderID, DaimoPayOrderStatusSource, getOrderSourceChainId, DaimoPayEventType, getDaimoPayOrderView, worldchainWLD, worldchainUSDCe } from '@daimo/pay-common';
5
+ import { DaimoPayIntentStatus, assert, DaimoPayOrderMode, isHydrated, readDaimoPayOrderID, getOrderDestChainId, assertNotNull, getChainName, arbitrum as arbitrum$1, base as base$2, bsc as bsc$1, ethereum, linea as linea$1, mantle as mantle$1, optimism as optimism$1, polygon as polygon$1, worldchain as worldchain$1, solana, getAddressContraction, supportedChains, getChainExplorerTxUrl, ExternalPaymentOptions, DepositAddressPaymentOptions, ethereumUSDC, polygonUSDC, baseUSDC, arbitrumUSDC, optimismUSDC, isCCTPV1Chain, debugJson, writeDaimoPayOrderID, DaimoPayOrderStatusSource, getOrderSourceChainId, DaimoPayEventType, getDaimoPayOrderView, worldchainWLD, worldchainUSDC } from '@daimo/pay-common';
6
6
  import { Buffer } from 'buffer';
7
7
  import React, { createContext, useRef, useState, useEffect, useLayoutEffect, useMemo, useContext, useSyncExternalStore, useCallback, createElement } from 'react';
8
8
  import styled$1, { css, keyframes, ThemeProvider } from 'styled-components';
@@ -22,7 +22,7 @@ import { VersionedTransaction } from '@solana/web3.js';
22
22
  import { normalize } from 'viem/ens';
23
23
 
24
24
  var name = "@daimo/pay";
25
- var version = "1.10.0";
25
+ var version = "1.10.2";
26
26
  var author = "Daimo";
27
27
  var homepage = "https://pay.daimo.com";
28
28
  var license = "BSD-2-Clause license";
@@ -61,7 +61,7 @@ var keywords = [
61
61
  "crypto"
62
62
  ];
63
63
  var dependencies = {
64
- "@daimo/pay-common": "1.10.0",
64
+ "@daimo/pay-common": "1.10.2",
65
65
  "@rollup/plugin-typescript": "^12.1.2",
66
66
  "@solana/wallet-adapter-base": "^0.9.23",
67
67
  "@solana/wallet-adapter-react": "^0.15.35",
@@ -7281,11 +7281,15 @@ const ConnectorItem = ({ wallet, isRecent, }) => {
7281
7281
  if (redirectToMoreWallets) {
7282
7282
  context.setRoute(ROUTES.MOBILECONNECTORS);
7283
7283
  }
7284
- else if (context.paymentState.isDepositFlow && isMobile) {
7284
+ else if (context.paymentState.isDepositFlow &&
7285
+ isMobile &&
7286
+ !wallet.connector) {
7285
7287
  context.paymentState.setSelectedWallet(wallet);
7286
7288
  context.setRoute(ROUTES.SELECT_WALLET_AMOUNT);
7287
7289
  }
7288
- else if (isMobile && wallet.getDaimoPayDeeplink != null) {
7290
+ else if (isMobile &&
7291
+ wallet.getDaimoPayDeeplink != null &&
7292
+ !wallet.connector) {
7289
7293
  context.paymentState.openInWalletBrowser(wallet);
7290
7294
  }
7291
7295
  else {
@@ -7296,11 +7300,7 @@ const ConnectorItem = ({ wallet, isRecent, }) => {
7296
7300
  context.setRoute(ROUTES.CONNECT);
7297
7301
  }
7298
7302
  };
7299
- return (jsxs(ConnectorButton, { type: "button",
7300
- // Is this <a> tag necessary?
7301
- // as={deeplink ? "a" : undefined}
7302
- // href={deeplink ? deeplink : undefined}
7303
- onClick: onClick, children: [jsx(ConnectorIcon, { "data-small": wallet.iconShouldShrink, "data-shape": wallet.iconShape, children: wallet.iconConnector ?? wallet.icon }), jsxs(ConnectorLabel, { children: [isMobile ? (wallet.shortName ?? wallet.name) : wallet.name, !context.options?.hideRecentBadge && isRecent && (jsx(RecentlyUsedTag, { children: jsx("span", { children: "Recent" }) }))] })] }));
7303
+ return (jsxs(ConnectorButton, { type: "button", onClick: onClick, children: [jsx(ConnectorIcon, { "data-small": wallet.iconShouldShrink, "data-shape": wallet.iconShape, children: wallet.iconConnector ?? wallet.icon }), jsxs(ConnectorLabel, { children: [isMobile ? (wallet.shortName ?? wallet.name) : wallet.name, !context.options?.hideRecentBadge && isRecent && (jsx(RecentlyUsedTag, { children: jsx("span", { children: "Recent" }) }))] })] }));
7304
7304
  };
7305
7305
  const SkeletonConnectorItem = () => {
7306
7306
  const { isMobile } = useIsMobile();
@@ -7669,6 +7669,8 @@ const QRPlaceholder = styled(motion.div) `
7669
7669
  display: flex;
7670
7670
  align-items: center;
7671
7671
  justify-content: center;
7672
+ border-radius: var(--ck-qr-border-radius, 24px);
7673
+ overflow: hidden;
7672
7674
  > div {
7673
7675
  z-index: 4;
7674
7676
  position: relative;
@@ -11518,7 +11520,8 @@ const CountdownWrap = styled.div `
11518
11520
  height: 16px;
11519
11521
  `;
11520
11522
  function useCountdown(expirationS) {
11521
- const [initMs] = useState(Date.now());
11523
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11524
+ const initMs = useMemo(() => Date.now(), [expirationS]);
11522
11525
  const [ms, setMs] = useState(initMs);
11523
11526
  useEffect(() => {
11524
11527
  const interval = setInterval(() => setMs(Date.now()), 1000);
@@ -11560,6 +11563,7 @@ const CopyRow = styled.button `
11560
11563
 
11561
11564
  cursor: pointer;
11562
11565
  background-color: var(--ck-body-background);
11566
+ background-color: var(--ck-body-background);
11563
11567
 
11564
11568
  display: flex;
11565
11569
  align-items: center;
@@ -12081,7 +12085,9 @@ function useExternalPaymentOptions({ trpc, filterIds, platform, usdRequired, mod
12081
12085
  });
12082
12086
  // Filter out options not in options JSON
12083
12087
  const enabledExtPaymentOptions = filterIds || DEFAULT_EXTERNAL_PAYMENT_OPTIONS;
12084
- const filteredOptions = newOptions.filter((option) => enabledExtPaymentOptions.includes(option.id));
12088
+ const hasAllPaymentApps = enabledExtPaymentOptions.includes(ExternalPaymentOptions.AllPaymentApps);
12089
+ const filteredOptions = newOptions.filter((option) => enabledExtPaymentOptions.includes(option.id) ||
12090
+ (hasAllPaymentApps && option.optionType === "zkp2p"));
12085
12091
  const optionsByType = new Map();
12086
12092
  filteredOptions.forEach((option) => {
12087
12093
  const { optionType } = option;
@@ -12410,42 +12416,12 @@ function usePaymentState({ trpc, lockPayParams, setRoute, log, redirectReturnUrl
12410
12416
  return externalPaymentOptionData.url;
12411
12417
  };
12412
12418
  const payWithDepositAddress = async (option) => {
12413
- const { order: hydratedOrder } = await pay.hydrateOrder();
12414
- log(`[PAY DEPOSIT ADDRESS] hydrated order: ${debugJson(hydratedOrder)}, checking out with deposit address: ${option}`);
12415
- // Special-case: USDT on Tron uses the Untron service rather than ChangeNow
12416
- const payParams = currPayParams;
12417
- if (option === DepositAddressPaymentOptions.TRON_USDT) {
12418
- // Ensure we have an appId for auth to backend
12419
- assert(payParams?.appId != null, "[PAY DEPOSIT ADDRESS] missing appId required for Tron USDT payments");
12420
- // Round up to the nearest integer number of USDT to avoid fractional tokens.
12421
- const usd = hydratedOrder.usdValue.toFixed(2);
12422
- const amountTronUSDT = parseUnits(usd, 6);
12423
- const untronResp = await trpc.untronTryCreateOrder.mutate({
12424
- appId: payParams.appId,
12425
- intentAddr: assertNotNull(hydratedOrder.intentAddr, `[PAY DEPOSIT ADDRESS] missing intentAddr on order ${hydratedOrder.id}`),
12426
- amountTronUSDT: Number(amountTronUSDT),
12427
- });
12428
- if ("error" in untronResp) {
12429
- log(`[PAY DEPOSIT ADDRESS] failed to create Untron order: ${untronResp.error}`);
12430
- return null;
12431
- }
12432
- const untronOrder = untronResp.untronOrder;
12433
- // Map Untron response to the generic deposit-address shape expected by the UI
12434
- return {
12435
- address: untronOrder.receiver,
12436
- amount: usd,
12437
- suffix: "USDT on Tron",
12438
- uri: `tron:${untronOrder.receiver}`,
12439
- expirationS: untronOrder.expiresAtS - 60,
12440
- };
12441
- }
12442
- // Default behaviour for all other tokens via ChangeNow
12443
- const depositAddressOption = await trpc.getDepositAddressOptionData.query({
12444
- input: option,
12445
- usdRequired: hydratedOrder.destFinalCallTokenAmount.usd,
12446
- toAddress: hydratedOrder.intentAddr,
12419
+ const { order } = await pay.hydrateOrder();
12420
+ log(`[PAY DEPOSIT ADDRESS] hydrated order ${order.id} for ${order.usdValue} USD, checking out with deposit address: ${option}`);
12421
+ return await trpc.getDepositAddressForOrder.query({
12422
+ orderId: order.id.toString(),
12423
+ option,
12447
12424
  });
12448
- return depositAddressOption;
12449
12425
  };
12450
12426
  const { isIOS } = useIsMobile();
12451
12427
  const openInWalletBrowser = (wallet, amountUsd) => {
@@ -13598,7 +13574,8 @@ async function promptWorldcoinPayment(order, trpc) {
13598
13574
  // Dynamically import @worldcoin/minikit-js to avoid bundling it for
13599
13575
  // developers who don't use World Mini App features, as it's an optional
13600
13576
  // peer dependency.
13601
- const { MiniKit, Tokens } = await import('@worldcoin/minikit-js');
13577
+ const { MiniKit, Tokens } = await import(
13578
+ /* webpackIgnore: true */ '@worldcoin/minikit-js');
13602
13579
  if (!MiniKit.isInstalled()) {
13603
13580
  console.error("[WORLD] MiniKit is not installed. Please install @worldcoin/minikit-js to use this feature.");
13604
13581
  return null;
@@ -13611,13 +13588,13 @@ async function promptWorldcoinPayment(order, trpc) {
13611
13588
  token: worldchainWLD.token,
13612
13589
  },
13613
13590
  {
13614
- chainId: worldchainUSDCe.chainId,
13615
- token: worldchainUSDCe.token,
13591
+ chainId: worldchainUSDC.chainId,
13592
+ token: worldchainUSDC.token,
13616
13593
  },
13617
13594
  ],
13618
13595
  }));
13619
13596
  const wld = paymentOptions.find((opt) => getAddress(opt.token.token) === getAddress(worldchainWLD.token));
13620
- const usdc = paymentOptions.find((opt) => getAddress(opt.token.token) === getAddress(worldchainUSDCe.token));
13597
+ const usdc = paymentOptions.find((opt) => getAddress(opt.token.token) === getAddress(worldchainUSDC.token));
13621
13598
  assert(wld != null, "WLD DP token not found");
13622
13599
  assert(usdc != null, "USDCe DP token not found");
13623
13600
  const paymentId = crypto.randomUUID().replace(/-/g, "");
@@ -13658,7 +13635,7 @@ function WorldPayButtonCustom(props) {
13658
13635
  // Dynamically import @worldcoin/minikit-js to avoid bundling it for
13659
13636
  // developers who don't use World Mini App features, as it's an optional
13660
13637
  // peer dependency.
13661
- import('@worldcoin/minikit-js')
13638
+ import(/* webpackIgnore: true */ '@worldcoin/minikit-js')
13662
13639
  .then(({ MiniKit }) => {
13663
13640
  if (MiniKit.isInstalled()) {
13664
13641
  setIsMiniKitReady(true);