@daimo/pay 0.3.8 → 0.3.11

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.es.js CHANGED
@@ -1,13 +1,13 @@
1
- import { http, useConfig, useAccountEffect, useConnectors as useConnectors$1, useAccount, useWriteContract, useSendTransaction, useSwitchChain, useConnect as useConnect$1, createConfig, useEnsAddress, useEnsName, useEnsAvatar, useDisconnect, useBalance, useChainId, WagmiContext } from 'wagmi';
2
- import { mainnet, base as base$1, polygon, optimism, arbitrum, linea, sepolia, baseSepolia } from 'wagmi/chains';
1
+ import { http, useConfig, useAccountEffect, useConnectors as useConnectors$1, useAccount, useEnsName, useWriteContract, useSendTransaction, useSwitchChain, useConnect as useConnect$1, createConfig, useEnsAddress, useEnsAvatar, useDisconnect, useBalance, useChainId, WagmiContext } from 'wagmi';
2
+ import { mainnet, base as base$1, polygon, optimism, arbitrum, linea, bsc, sepolia, baseSepolia } from 'wagmi/chains';
3
3
  import { safe, injected, coinbaseWallet, walletConnect } from '@wagmi/connectors';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import { detect } from 'detect-browser';
6
6
  import React, { useEffect, useState, useCallback, useRef, useLayoutEffect, useMemo, createContext, createElement } from 'react';
7
7
  import { Buffer } from 'buffer';
8
- import { readDaimoPayOrderID, assert, assertNotNull, DaimoPayOrderMode, DaimoPayOrderStatusDest, ExternalPaymentOptions, getAddressContraction, capitalize, getDisplayPrice, debugJson, writeDaimoPayOrderID, DaimoPayIntentStatus, DaimoPayOrderStatusSource } from '@daimo/common';
8
+ import { ExternalPaymentOptions, readDaimoPayOrderID, assert, assertNotNull, DaimoPayOrderMode, DaimoPayOrderStatusDest, getAddressContraction, capitalize, getDisplayPrice, DaimoPayOrderStatusSource, DaimoPayIntentStatus, retryBackoff, debugJson, writeDaimoPayOrderID } from '@daimo/common';
9
9
  import styled$1, { css, keyframes, ThemeProvider } from 'styled-components';
10
- import { erc20Abi, getChainName, ethereum, arbitrum as arbitrum$1, base as base$2, optimism as optimism$1, polygon as polygon$1, ethereumSepolia, baseSepolia as baseSepolia$1, getChainExplorerTxUrl } from '@daimo/contract';
10
+ import { ethereum, erc20Abi, getChainName, arbitrum as arbitrum$1, base as base$2, optimism as optimism$1, polygon as polygon$1, ethereumSepolia, baseSepolia as baseSepolia$1, linea as linea$1, bsc as bsc$1, getChainExplorerTxUrl } from '@daimo/contract';
11
11
  import { zeroAddress, parseUnits } from 'viem';
12
12
  import { createTRPCClient, httpBatchLink } from '@trpc/client';
13
13
  import { motion, AnimatePresence, MotionConfig } from 'framer-motion';
@@ -70,6 +70,7 @@ const REQUIRED_CHAINS = [
70
70
  optimism,
71
71
  arbitrum,
72
72
  linea,
73
+ bsc,
73
74
  sepolia,
74
75
  baseSepolia,
75
76
  ];
@@ -900,25 +901,118 @@ const trpc = createTRPCClient({
900
901
  ],
901
902
  });
902
903
 
903
- function getPaymentInfo(setOpen, log) {
904
+ const DEFAULT_EXTERNAL_PAYMENT_OPTIONS = [
905
+ ExternalPaymentOptions.Coinbase,
906
+ ExternalPaymentOptions.Binance,
907
+ ExternalPaymentOptions.Daimo,
908
+ ExternalPaymentOptions.RampNetwork,
909
+ ];
910
+ function useExternalPaymentOptions({ filterIds, usdRequired, platform, }) {
911
+ const [options, setOptions] = useState([]);
912
+ const [loading, setLoading] = useState(false);
913
+ useEffect(() => {
914
+ const refreshExternalPaymentOptions = async (usd) => {
915
+ if (!platform)
916
+ return;
917
+ setLoading(true);
918
+ try {
919
+ const newOptions = await trpc.getExternalPaymentOptions.query({
920
+ usdRequired: usd,
921
+ platform,
922
+ });
923
+ // Filter out options not in options JSON
924
+ const enabledExtPaymentOptions = filterIds || DEFAULT_EXTERNAL_PAYMENT_OPTIONS;
925
+ const filteredOptions = newOptions.filter((option) => enabledExtPaymentOptions.includes(option.id));
926
+ setOptions(filteredOptions);
927
+ }
928
+ catch (error) {
929
+ console.error(error);
930
+ }
931
+ finally {
932
+ setLoading(false);
933
+ }
934
+ };
935
+ if (usdRequired != null) {
936
+ refreshExternalPaymentOptions(usdRequired);
937
+ }
938
+ }, [usdRequired, filterIds, platform]);
939
+ return {
940
+ options,
941
+ loading,
942
+ };
943
+ }
944
+
945
+ function useWalletPaymentOptions({ address, usdRequired, destChainId, }) {
946
+ const [options, setOptions] = useState(null);
947
+ const [isLoading, setIsLoading] = useState(false);
948
+ useEffect(() => {
949
+ const refreshWalletPaymentOptions = async () => {
950
+ setOptions(null);
951
+ setIsLoading(true);
952
+ try {
953
+ const newOptions = await trpc.getWalletPaymentOptions.query({
954
+ payerAddress: address,
955
+ usdRequired,
956
+ destChainId,
957
+ });
958
+ setOptions(newOptions);
959
+ }
960
+ catch (error) {
961
+ console.error(error);
962
+ }
963
+ finally {
964
+ setIsLoading(false);
965
+ }
966
+ };
967
+ if (!address || !usdRequired || !destChainId)
968
+ return;
969
+ if (address && usdRequired != null && destChainId) {
970
+ refreshWalletPaymentOptions();
971
+ }
972
+ }, [address, usdRequired, destChainId]);
973
+ return {
974
+ options,
975
+ isLoading,
976
+ };
977
+ }
978
+
979
+ function usePaymentInfo({ daimoPayOrder, setDaimoPayOrder, setOpen, log, }) {
980
+ // Browser state.
981
+ const [platform, setPlatform] = useState();
982
+ useEffect(() => {
983
+ setPlatform(detectPlatform(window.navigator.userAgent));
984
+ }, []);
904
985
  // Wallet state.
905
986
  const { address: senderAddr } = useAccount();
987
+ const { data: senderEnsName } = useEnsName({
988
+ chainId: ethereum.chainId,
989
+ address: senderAddr,
990
+ });
906
991
  const { writeContractAsync } = useWriteContract();
907
992
  const { sendTransactionAsync } = useSendTransaction();
908
993
  // Daimo Pay order state.
909
- const [daimoPayOrder, setDaimoPayOrder] = useState();
910
994
  const [paymentWaitingMessage, setPaymentWaitingMessage] = useState();
911
995
  // Payment UI config.
912
996
  const [modalOptions, setModalOptions] = useState({});
913
997
  // UI state. Selection for external payment (Binance, etc) vs wallet payment.
998
+ const externalPaymentOptions = useExternalPaymentOptions({
999
+ filterIds: daimoPayOrder?.metadata.payer?.paymentOptions,
1000
+ usdRequired: daimoPayOrder?.destFinalCallTokenAmount.usd,
1001
+ platform,
1002
+ });
1003
+ const walletPaymentOptions = useWalletPaymentOptions({
1004
+ address: senderAddr,
1005
+ usdRequired: daimoPayOrder?.destFinalCallTokenAmount.usd,
1006
+ destChainId: daimoPayOrder?.destFinalCallTokenAmount.token.chainId,
1007
+ });
914
1008
  const [selectedExternalOption, setSelectedExternalOption] = useState();
915
1009
  const [selectedTokenOption, setSelectedTokenOption] = useState();
916
1010
  const payWithToken = async (tokenAmount) => {
917
- assert(!!daimoPayOrder);
1011
+ assert(!!daimoPayOrder && !!platform);
918
1012
  const { hydratedOrder } = await trpc.hydrateOrder.query({
919
1013
  id: daimoPayOrder.id.toString(),
920
1014
  chosenFinalTokenAmount: daimoPayOrder.destFinalCallTokenAmount.amount,
921
- platform: detectPlatform(window.navigator.userAgent),
1015
+ platform,
922
1016
  refundAddress: senderAddr,
923
1017
  });
924
1018
  log(`[CHECKOUT] Hydrated order: ${JSON.stringify(hydratedOrder)}, checking out with ${tokenAmount.token.token}`);
@@ -926,7 +1020,7 @@ function getPaymentInfo(setOpen, log) {
926
1020
  try {
927
1021
  if (tokenAmount.token.token === zeroAddress) {
928
1022
  return await sendTransactionAsync({
929
- to: hydratedOrder.handoffAddr,
1023
+ to: hydratedOrder.intentAddr,
930
1024
  value: BigInt(tokenAmount.amount),
931
1025
  });
932
1026
  }
@@ -935,7 +1029,7 @@ function getPaymentInfo(setOpen, log) {
935
1029
  abi: erc20Abi,
936
1030
  address: tokenAmount.token.token,
937
1031
  functionName: "transfer",
938
- args: [hydratedOrder.handoffAddr, BigInt(tokenAmount.amount)],
1032
+ args: [hydratedOrder.intentAddr, BigInt(tokenAmount.amount)],
939
1033
  });
940
1034
  }
941
1035
  }
@@ -960,12 +1054,12 @@ function getPaymentInfo(setOpen, log) {
960
1054
  }
961
1055
  };
962
1056
  const payWithExternal = async (option) => {
963
- assert(!!daimoPayOrder);
1057
+ assert(!!daimoPayOrder && !!platform);
964
1058
  const { hydratedOrder, externalPaymentOptionData } = await trpc.hydrateOrder.query({
965
1059
  id: daimoPayOrder.id.toString(),
966
1060
  externalPaymentOption: option,
967
1061
  chosenFinalTokenAmount: daimoPayOrder.destFinalCallTokenAmount.amount,
968
- platform: detectPlatform(window.navigator.userAgent),
1062
+ platform,
969
1063
  });
970
1064
  assert(!!externalPaymentOptionData);
971
1065
  setPaymentWaitingMessage(externalPaymentOptionData.waitingMessage);
@@ -1026,6 +1120,8 @@ function getPaymentInfo(setOpen, log) {
1026
1120
  paymentWaitingMessage,
1027
1121
  selectedExternalOption,
1028
1122
  selectedTokenOption,
1123
+ externalPaymentOptions,
1124
+ walletPaymentOptions,
1029
1125
  setSelectedExternalOption,
1030
1126
  setSelectedTokenOption,
1031
1127
  setChosenUsd,
@@ -1033,6 +1129,7 @@ function getPaymentInfo(setOpen, log) {
1033
1129
  payWithExternal,
1034
1130
  refreshOrder,
1035
1131
  onSuccess,
1132
+ senderEnsName: senderEnsName ?? undefined,
1036
1133
  };
1037
1134
  }
1038
1135
 
@@ -2177,7 +2274,7 @@ const ResetContainer = styled(motion.div) `
2177
2274
  `;
2178
2275
 
2179
2276
  var name = "@daimo/pay";
2180
- var version = "0.3.8";
2277
+ var version = "0.3.11";
2181
2278
  var author = "Daimo";
2182
2279
  var homepage = "https://pay.daimo.com";
2183
2280
  var license = "BSD-2-Clause license";
@@ -2216,8 +2313,8 @@ var keywords = [
2216
2313
  "crypto"
2217
2314
  ];
2218
2315
  var dependencies = {
2219
- "@daimo/common": "0.3.6",
2220
- "@daimo/contract": "0.3.6",
2316
+ "@daimo/common": "0.3.11",
2317
+ "@daimo/contract": "0.3.11",
2221
2318
  "@trpc/client": "^11.0.0-next-beta.318",
2222
2319
  "@trpc/server": "^11.0.0-next-beta.318",
2223
2320
  buffer: "^6.0.3",
@@ -6910,6 +7007,7 @@ const Zora = ({ testnet, ...props }) => (jsxs("svg", { ...props, width: "44", he
6910
7007
  }, children: [jsx("mask", { id: "ck_zora_mask_a", style: {
6911
7008
  maskType: "alpha",
6912
7009
  }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "44", height: "44", children: jsx("path", { d: "M22 44C34.1503 44 44 34.1503 44 22C44 9.84974 34.1503 0 22 0C9.84974 0 0 9.84974 0 22C0 34.1503 9.84974 44 22 44Z", fill: "#D9D9D9" }) }), jsxs("g", { mask: "url(#ck_zora_mask_a)", children: [jsx("path", { d: "M51.4558 -9.56445H-6.78906V48.6804H51.4558V-9.56445Z", fill: "#A1723A" }), jsx("g", { filter: "url(#ck_zora_filter_a)", children: jsx("path", { d: "M23.6807 43.0752C36.6464 43.0752 47.157 32.5675 47.157 19.6058C47.157 6.64397 36.6464 -3.86365 23.6807 -3.86365C10.7152 -3.86365 0.20459 6.64397 0.20459 19.6058C0.20459 32.5675 10.7152 43.0752 23.6807 43.0752Z", fill: "#531002" }) }), jsx("g", { filter: "url(#ck_zora_filter_b)", children: jsx("path", { d: "M26.2112 35.6464C36.7271 35.6464 45.2521 27.1185 45.2521 16.5988C45.2521 6.07904 36.7271 -2.44885 26.2112 -2.44885C15.6953 -2.44885 7.17041 6.07904 7.17041 16.5988C7.17041 27.1185 15.6953 35.6464 26.2112 35.6464Z", fill: "#2B5DF0" }) }), jsx("g", { filter: "url(#ck_zora_filter_c)", children: jsx("path", { d: "M25.8644 36.7348C36.8276 36.7348 45.7149 27.8444 45.7149 16.8777C45.7149 5.91084 36.8276 -2.97949 25.8644 -2.97949C14.9015 -2.97949 6.01416 5.91084 6.01416 16.8777C6.01416 27.8444 14.9015 36.7348 25.8644 36.7348Z", fill: "url(#paint0_radial_3914_1946)" }) }), jsx("g", { filter: "url(#ck_zora_filter_d)", children: jsx("path", { d: "M29.1567 21.8779C34.6797 21.8779 39.1567 17.4008 39.1567 11.8779C39.1567 6.35509 34.6797 1.87793 29.1567 1.87793C23.6338 1.87793 19.1567 6.35509 19.1567 11.8779C19.1567 17.4008 23.6338 21.8779 29.1567 21.8779Z", fill: "#FCB8D4" }) }), jsx("g", { filter: "url(#ck_zora_filter_e)", children: jsx("path", { d: "M29.15 15.8642C31.3555 15.8642 33.1432 14.0765 33.1432 11.871C33.1432 9.66562 31.3555 7.87781 29.15 7.87781C26.9445 7.87781 25.1567 9.66562 25.1567 11.871C25.1567 14.0765 26.9445 15.8642 29.15 15.8642Z", fill: "white" }) }), jsx("g", { filter: "url(#ck_zora_filter_f)", children: jsx("path", { d: "M26.4967 51.7416C46.3151 51.7416 62.3811 35.6757 62.3811 15.8573C62.3811 -3.96109 46.3151 -20.0271 26.4967 -20.0271C6.67829 -20.0271 -9.3877 -3.96109 -9.3877 15.8573C-9.3877 35.6757 6.67829 51.7416 26.4967 51.7416Z", fill: "url(#paint1_radial_3914_1946)", fillOpacity: "0.9" }) })] }), jsxs("defs", { children: [jsxs("filter", { id: "ck_zora_filter_a", x: "-5.23758", y: "-9.30581", width: "57.837", height: "57.8232", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }), jsx("feGaussianBlur", { stdDeviation: "2.72108", result: "effect1_foregroundBlur_3914_1946" })] }), jsxs("filter", { id: "ck_zora_filter_b", x: "-3.71395", y: "-13.3332", width: "59.8503", height: "59.8639", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }), jsx("feGaussianBlur", { stdDeviation: "5.44218", result: "effect1_foregroundBlur_3914_1946" })] }), jsxs("filter", { id: "ck_zora_filter_c", x: "1.93251", y: "-7.06114", width: "47.864", height: "47.8775", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }), jsx("feGaussianBlur", { stdDeviation: "2.04082", result: "effect1_foregroundBlur_3914_1946" })] }), jsxs("filter", { id: "ck_zora_filter_d", x: "10.9935", y: "-6.28533", width: "36.3265", height: "36.3265", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }), jsx("feGaussianBlur", { stdDeviation: "4.08163", result: "effect1_foregroundBlur_3914_1946" })] }), jsxs("filter", { id: "ck_zora_filter_e", x: "19.7146", y: "2.43564", width: "18.8707", height: "18.8708", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }), jsx("feGaussianBlur", { stdDeviation: "2.72108", result: "effect1_foregroundBlur_3914_1946" })] }), jsxs("filter", { id: "ck_zora_filter_f", x: "-13.4693", y: "-24.1087", width: "79.9318", height: "79.9321", filterUnits: "userSpaceOnUse", colorInterpolationFilters: "sRGB", children: [jsx("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "BackgroundImageFix", result: "shape" }), jsx("feGaussianBlur", { stdDeviation: "2.04082", result: "effect1_foregroundBlur_3914_1946" })] }), jsxs("radialGradient", { id: "paint0_radial_3914_1946", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(29.2127 11.2756) rotate(128.228) scale(37.4897 37.4867)", children: [jsx("stop", { offset: "0.286458", stopColor: "#387AFA" }), jsx("stop", { offset: "0.647782", stopColor: "#387AFA", stopOpacity: "0" })] }), jsxs("radialGradient", { id: "paint1_radial_3914_1946", cx: "0", cy: "0", r: "1", gradientUnits: "userSpaceOnUse", gradientTransform: "translate(26.4967 15.8573) rotate(90) scale(35.8844 35.8844)", children: [jsx("stop", { offset: "0.598958", stopOpacity: "0" }), jsx("stop", { offset: "0.671875" }), jsx("stop", { offset: "0.734375", stopOpacity: "0" })] })] })] }));
7010
+ const Linea = ({ testnet, ...props }) => (jsxs("svg", { ...props, width: "44", height: "44", viewBox: "0 0 200 200", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { d: "M200 0H0V200H200V0Z", fill: "#121212" }), jsx("mask", { id: "mask0_267_10", style: { maskType: "luminance" }, maskUnits: "userSpaceOnUse", x: "50", y: "48", width: "100", height: "104", children: jsx("path", { d: "M149.541 48H50V151.977H149.541V48Z", fill: "white" }) }), jsxs("g", { mask: "url(#mask0_267_10)", children: [jsx("path", { d: "M132.669 151.977H50V64.8721H68.9147V135.096H132.669V151.968V151.977Z", fill: "white" }), jsx("path", { d: "M132.669 81.7441C141.987 81.7441 149.541 74.1902 149.541 64.8721C149.541 55.5539 141.987 48 132.669 48C123.35 48 115.797 55.5539 115.797 64.8721C115.797 74.1902 123.35 81.7441 132.669 81.7441Z", fill: "white" })] })] }));
6913
7011
  const chainToLogo = {
6914
7012
  [ethereum.chainId]: jsx(Ethereum, {}),
6915
7013
  [arbitrum$1.chainId]: jsx(Arbitrum, {}),
@@ -6918,6 +7016,8 @@ const chainToLogo = {
6918
7016
  [polygon$1.chainId]: jsx(Polygon, {}),
6919
7017
  [ethereumSepolia.chainId]: jsx(Ethereum, {}),
6920
7018
  [baseSepolia$1.chainId]: jsx(Base, {}),
7019
+ [linea$1.chainId]: jsx(Linea, {}),
7020
+ [bsc$1.chainId]: jsx(BinanceSmartChain, {}),
6921
7021
  };
6922
7022
  var ChainIcons = {
6923
7023
  UnknownChain,
@@ -10049,13 +10149,7 @@ const TextButton = styled(motion.button) `
10049
10149
 
10050
10150
  const Confirmation = () => {
10051
10151
  const { paymentInfo } = useContext();
10052
- const { daimoPayOrder, refreshOrder } = paymentInfo;
10053
- useEffect(() => {
10054
- const interval = setInterval(() => {
10055
- refreshOrder();
10056
- }, 300);
10057
- return () => clearInterval(interval);
10058
- }, [refreshOrder]);
10152
+ const { daimoPayOrder } = paymentInfo;
10059
10153
  const { done, txURL } = (() => {
10060
10154
  if (daimoPayOrder && daimoPayOrder.mode === DaimoPayOrderMode.HYDRATED) {
10061
10155
  // Frontends are optimistic, assume submits will be successful
@@ -10551,12 +10645,6 @@ const IconStackItem = styled(motion.div) `
10551
10645
  border-radius: 22.5%;
10552
10646
  `;
10553
10647
 
10554
- const DEFAULT_EXTERNAL_PAYMENT_OPTIONS = [
10555
- ExternalPaymentOptions.Coinbase,
10556
- ExternalPaymentOptions.Binance,
10557
- ExternalPaymentOptions.Daimo,
10558
- ExternalPaymentOptions.RampNetwork,
10559
- ];
10560
10648
  // Get 3 icons, skipping the one that is already connected
10561
10649
  function getBestUnconnectedWalletIcons(connector) {
10562
10650
  const icons = [];
@@ -10580,13 +10668,9 @@ const SelectMethod = () => {
10580
10668
  const isMobile = useIsMobile();
10581
10669
  const { address, isConnected, connector } = useAccount();
10582
10670
  const { disconnectAsync } = useDisconnect();
10583
- const { data: ensName } = useEnsName({
10584
- chainId: ethereum.chainId,
10585
- address: address,
10586
- });
10587
- const displayName = ensName ?? (address ? getAddressContraction(address) : "wallet");
10588
- const { setRoute, paymentInfo } = useContext();
10589
- const { daimoPayOrder, setSelectedExternalOption } = paymentInfo;
10671
+ const { setRoute, paymentInfo, log } = useContext();
10672
+ const { setSelectedExternalOption, externalPaymentOptions, senderEnsName } = paymentInfo;
10673
+ const displayName = senderEnsName ?? (address ? getAddressContraction(address) : "wallet");
10590
10674
  const connectedWalletOption = isConnected
10591
10675
  ? {
10592
10676
  id: "connectedWallet",
@@ -10609,30 +10693,10 @@ const SelectMethod = () => {
10609
10693
  const walletOptions = connectedWalletOption
10610
10694
  ? [connectedWalletOption, unconnectedWalletOption]
10611
10695
  : [unconnectedWalletOption];
10612
- const [externalPaymentOptions, setExternalPaymentOptions] = useState([]);
10613
- const [loadingExternalPaymentOptions, setLoadingExternalPaymentOptions] = useState(true);
10614
- useEffect(() => {
10615
- const refreshExternalPaymentOptions = async (usd) => {
10616
- setLoadingExternalPaymentOptions(true);
10617
- const options = await trpc.getExternalPaymentOptions.query({
10618
- usdRequired: usd,
10619
- platform: detectPlatform(window.navigator.userAgent),
10620
- });
10621
- // Filter out options not in options JSON
10622
- const enabledExtPaymentOptions = daimoPayOrder?.metadata.payer?.paymentOptions ||
10623
- DEFAULT_EXTERNAL_PAYMENT_OPTIONS;
10624
- const filteredOptions = options.filter((option) => enabledExtPaymentOptions.includes(option.id));
10625
- setExternalPaymentOptions(filteredOptions);
10626
- setLoadingExternalPaymentOptions(false);
10627
- };
10628
- const usd = daimoPayOrder?.destFinalCallTokenAmount.usd;
10629
- if (usd != null) {
10630
- refreshExternalPaymentOptions(usd);
10631
- }
10632
- }, [daimoPayOrder?.destFinalCallTokenAmount.usd]);
10633
- return (jsxs(PageContent, { children: [jsx(OrderHeader, {}), jsx(OptionsList, { requiredSkeletons: isMobile ? 4 : 3, isLoading: loadingExternalPaymentOptions, options: [
10696
+ log(`[SELECT_METHOD] loading: ${externalPaymentOptions.loading}, options: ${JSON.stringify(externalPaymentOptions.options)}`);
10697
+ return (jsxs(PageContent, { children: [jsx(OrderHeader, {}), jsx(OptionsList, { requiredSkeletons: isMobile ? 4 : 3, isLoading: externalPaymentOptions.loading, options: [
10634
10698
  ...walletOptions,
10635
- ...(externalPaymentOptions ?? []).map((option) => ({
10699
+ ...(externalPaymentOptions.options ?? []).map((option) => ({
10636
10700
  id: option.id,
10637
10701
  title: option.cta,
10638
10702
  icons: [option.logoURI],
@@ -10665,32 +10729,15 @@ const ChainContainer = styled(motion.div) `
10665
10729
  `;
10666
10730
  const SelectToken = () => {
10667
10731
  const { setRoute, paymentInfo } = useContext();
10668
- const { daimoPayOrder, setSelectedTokenOption } = paymentInfo;
10669
- const { address: payerAddress } = useAccount();
10670
- const [paymentOptions, setPaymentOptions] = useState(null);
10671
- const [isLoadingOptions, setIsLoadingOptions] = useState(true);
10672
- useEffect(() => {
10673
- if (!payerAddress || !daimoPayOrder)
10674
- return;
10675
- setPaymentOptions(null);
10676
- setIsLoadingOptions(true);
10677
- const destChainId = daimoPayOrder.destFinalCallTokenAmount.token.chainId;
10678
- trpc.getWalletPaymentOptions
10679
- .query({
10680
- payerAddress,
10681
- usdRequired: daimoPayOrder.destFinalCallTokenAmount.usd,
10682
- destChainId,
10683
- })
10684
- .then(setPaymentOptions)
10685
- .finally(() => setIsLoadingOptions(false));
10686
- }, [payerAddress, daimoPayOrder]);
10687
- return (jsxs(PageContent, { children: [jsx(OrderHeader, { minified: true }), !isLoadingOptions && paymentOptions?.length === 0 && (jsxs(ModalContent, { style: {
10732
+ const { setSelectedTokenOption, walletPaymentOptions } = paymentInfo;
10733
+ return (jsxs(PageContent, { children: [jsx(OrderHeader, { minified: true }), walletPaymentOptions.isLoading &&
10734
+ walletPaymentOptions.options?.length === 0 && (jsxs(ModalContent, { style: {
10688
10735
  display: "flex",
10689
10736
  alignItems: "center",
10690
10737
  justifyContent: "center",
10691
10738
  paddingTop: 16,
10692
10739
  paddingBottom: 16,
10693
- }, children: [jsx(ModalH1, { children: "Insufficient balance. Please select an alternative payment method." }), jsx(Button, { onClick: () => setRoute(ROUTES.SELECT_METHOD), children: "Select Another Method" })] })), jsx(OptionsList, { requiredSkeletons: 4, isLoading: isLoadingOptions, options: paymentOptions?.map((option) => {
10740
+ }, children: [jsx(ModalH1, { children: "Insufficient balance. Please select an alternative payment method." }), jsx(Button, { onClick: () => setRoute(ROUTES.SELECT_METHOD), children: "Select Another Method" })] })), jsx(OptionsList, { requiredSkeletons: 4, isLoading: walletPaymentOptions.isLoading, options: walletPaymentOptions.options?.map((option) => {
10694
10741
  const capitalizedChainName = capitalize(getChainName(option.required.token.chainId));
10695
10742
  const title = `${getDisplayPrice(option.required)} ${option.required.token.symbol} on ${capitalizedChainName}`;
10696
10743
  const subtitle = `Balance: ${getDisplayPrice(option.balance)} ${option.balance.token.symbol}`;
@@ -10992,7 +11039,37 @@ const DaimoPayProvider = ({ children, theme = "auto", mode = "auto", customTheme
10992
11039
  }
10993
11040
  }, [injectedConnector]);
10994
11041
  const log = debugMode ? console.log : () => { };
10995
- const paymentInfo = getPaymentInfo(setOpen, log);
11042
+ // PaymentInfo is a second, inner context object containing a DaimoPayOrder
11043
+ // plus all associated status and callbacks. In order for useContext() and
11044
+ // downstream hooks like useDaimoPayStatus() to work correctly, we must set
11045
+ // set refresh context when payment status changes; done via setDaimoPayOrder.
11046
+ const [daimoPayOrder, setDaimoPayOrder] = useState();
11047
+ const paymentInfo = usePaymentInfo({
11048
+ daimoPayOrder,
11049
+ setDaimoPayOrder,
11050
+ setOpen,
11051
+ log,
11052
+ });
11053
+ // When a payment is in progress, poll for status updates. Do this regardless
11054
+ // of whether the modal is still being displayed for useDaimoPayStatus().
11055
+ useEffect(() => {
11056
+ // Order just updated...
11057
+ if (daimoPayOrder?.mode !== DaimoPayOrderMode.HYDRATED)
11058
+ return;
11059
+ const { sourceStatus, intentStatus } = daimoPayOrder;
11060
+ let intervalMs = 0;
11061
+ if (sourceStatus === DaimoPayOrderStatusSource.WAITING_PAYMENT) {
11062
+ intervalMs = 2500; // additional, faster polling in WaitingOther
11063
+ }
11064
+ else if (intentStatus === DaimoPayIntentStatus.PENDING) {
11065
+ intervalMs = 300; // poll fast from (payment initiated) to (finished)
11066
+ }
11067
+ else {
11068
+ return;
11069
+ }
11070
+ log(`[PAY] polling in ${intervalMs}ms`);
11071
+ setTimeout(() => retryBackoff("refreshOrder", () => paymentInfo.refreshOrder()), intervalMs);
11072
+ }, [daimoPayOrder]);
10996
11073
  const loadAndShowPayment = async (payId, modalOptions) => {
10997
11074
  log(`[PAY] showing order ${payId}, options ${debugJson(modalOptions)}`);
10998
11075
  await paymentInfo.setPayId(payId);
@@ -11021,7 +11098,6 @@ const DaimoPayProvider = ({ children, theme = "auto", mode = "auto", customTheme
11021
11098
  setOpen,
11022
11099
  route,
11023
11100
  setRoute,
11024
- loadAndShowPayment,
11025
11101
  connector,
11026
11102
  setConnector,
11027
11103
  onConnect,
@@ -11040,6 +11116,9 @@ const DaimoPayProvider = ({ children, theme = "auto", mode = "auto", customTheme
11040
11116
  },
11041
11117
  resize,
11042
11118
  triggerResize: () => onResize((prev) => prev + 1),
11119
+ // Above: generic ConnectKit context
11120
+ // Below: Daimo Pay context
11121
+ loadAndShowPayment,
11043
11122
  paymentInfo,
11044
11123
  };
11045
11124
  return createElement(Context.Provider, { value }, jsx(Web3ContextProvider, { enabled: open, children: jsxs(ThemeProvider, { theme: defaultTheme$1, children: [children, jsx(DaimoPayModal, { lang: ckLang, theme: ckTheme, mode: mode, customTheme: ckCustomTheme })] }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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useConnectCallbackProps } from "../hooks/useConnectCallback";
4
- import { PaymentInfo } from "../utils/getPaymentInfo";
4
+ import { PaymentInfo } from "../hooks/usePaymentInfo";
5
5
  export declare enum ROUTES {
6
6
  SELECT_METHOD = "daimoPaySelectMethod",
7
7
  SELECT_TOKEN = "daimoPaySelectToken",
@@ -0,0 +1,9 @@
1
+ import { ExternalPaymentOptionMetadata, PlatformType } from "@daimo/common";
2
+ export declare function useExternalPaymentOptions({ filterIds, usdRequired, platform, }: {
3
+ filterIds: string[] | undefined;
4
+ usdRequired: number | undefined;
5
+ platform: PlatformType | undefined;
6
+ }): {
7
+ options: ExternalPaymentOptionMetadata[];
8
+ loading: boolean;
9
+ };
@@ -0,0 +1,36 @@
1
+ import { DaimoPayOrder, DaimoPayTokenAmount, ExternalPaymentOptionMetadata, ExternalPaymentOptions } from "@daimo/common";
2
+ import { DaimoPayModalOptions } from "../types";
3
+ import { trpc } from "../utils/trpc";
4
+ import { useExternalPaymentOptions } from "./useExternalPaymentOptions";
5
+ import { useWalletPaymentOptions, WalletPaymentOption } from "./useWalletPaymentOptions";
6
+ /** Wallet payment details, sent to processSourcePayment after submitting tx. */
7
+ export type SourcePayment = Parameters<typeof trpc.processSourcePayment.mutate>[0];
8
+ /** Loads a DaimoPayOrder + manages the corresponding modal. */
9
+ export interface PaymentInfo {
10
+ setPayId: (id: string | null) => Promise<void>;
11
+ daimoPayOrder: DaimoPayOrder | undefined;
12
+ modalOptions: DaimoPayModalOptions;
13
+ setModalOptions: (modalOptions: DaimoPayModalOptions) => void;
14
+ paymentWaitingMessage: string | undefined;
15
+ externalPaymentOptions: ReturnType<typeof useExternalPaymentOptions>;
16
+ walletPaymentOptions: ReturnType<typeof useWalletPaymentOptions>;
17
+ selectedExternalOption: ExternalPaymentOptionMetadata | undefined;
18
+ selectedTokenOption: WalletPaymentOption | undefined;
19
+ setSelectedExternalOption: (option: ExternalPaymentOptionMetadata | undefined) => void;
20
+ setSelectedTokenOption: (option: WalletPaymentOption | undefined) => void;
21
+ setChosenUsd: (amount: number) => void;
22
+ payWithToken: (tokenAmount: DaimoPayTokenAmount) => Promise<void>;
23
+ payWithExternal: (option: ExternalPaymentOptions) => Promise<string>;
24
+ refreshOrder: () => Promise<void>;
25
+ onSuccess: (args: {
26
+ txHash: string;
27
+ txURL?: string;
28
+ }) => void;
29
+ senderEnsName: string | undefined;
30
+ }
31
+ export declare function usePaymentInfo({ daimoPayOrder, setDaimoPayOrder, setOpen, log, }: {
32
+ daimoPayOrder: DaimoPayOrder | undefined;
33
+ setDaimoPayOrder: (o: DaimoPayOrder) => void;
34
+ setOpen: (showModal: boolean) => void;
35
+ log: (...args: any[]) => void;
36
+ }): PaymentInfo;
@@ -0,0 +1,11 @@
1
+ import { trpc } from "../utils/trpc";
2
+ /** Wallet payment options. User picks one. */
3
+ export type WalletPaymentOption = Awaited<ReturnType<typeof trpc.getWalletPaymentOptions.query>>[0];
4
+ export declare function useWalletPaymentOptions({ address, usdRequired, destChainId, }: {
5
+ address: string | undefined;
6
+ usdRequired: number | undefined;
7
+ destChainId: number | undefined;
8
+ }): {
9
+ options: any[] | null;
10
+ isLoading: boolean;
11
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daimo/pay",
3
3
  "private": false,
4
- "version": "0.3.8",
4
+ "version": "0.3.11",
5
5
  "author": "Daimo",
6
6
  "homepage": "https://pay.daimo.com",
7
7
  "license": "BSD-2-Clause license",
@@ -40,8 +40,8 @@
40
40
  "crypto"
41
41
  ],
42
42
  "dependencies": {
43
- "@daimo/common": "0.3.6",
44
- "@daimo/contract": "0.3.6",
43
+ "@daimo/common": "0.3.11",
44
+ "@daimo/contract": "0.3.11",
45
45
  "@trpc/client": "^11.0.0-next-beta.318",
46
46
  "@trpc/server": "^11.0.0-next-beta.318",
47
47
  "buffer": "^6.0.3",
@@ -1,2 +0,0 @@
1
- declare const ConnectUsing: () => import("react/jsx-runtime").JSX.Element;
2
- export default ConnectUsing;
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- export declare const states: {
3
- CONNECTED: string;
4
- CONNECTING: string;
5
- EXPIRING: string;
6
- FAILED: string;
7
- REJECTED: string;
8
- NOTCONNECTED: string;
9
- UNAVAILABLE: string;
10
- };
11
- declare const ConnectWithInjector: React.FC<{
12
- switchConnectMethod: (id?: string) => void;
13
- forceState?: typeof states;
14
- }>;
15
- export default ConnectWithInjector;
@@ -1,6 +0,0 @@
1
- export declare const Content: any;
2
- export declare const Container: any;
3
- export declare const ConnectingContainer: any;
4
- export declare const ConnectingAnimation: any;
5
- export declare const RetryButton: any;
6
- export declare const RetryIconContainer: any;
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- declare const ConnectWithQRCode: React.FC<{
3
- switchConnectMethod: (id?: string) => void;
4
- }>;
5
- export default ConnectWithQRCode;
@@ -1,8 +0,0 @@
1
- import { CustomTheme, Languages, Mode, Theme } from "../../types";
2
- declare const ConnectModal: React.FC<{
3
- mode?: Mode;
4
- theme?: Theme;
5
- customTheme?: CustomTheme;
6
- lang?: Languages;
7
- }>;
8
- export default ConnectModal;
@@ -1,46 +0,0 @@
1
- import { DaimoPayOrder, DaimoPayTokenAmount, ExternalPaymentOptionMetadata, ExternalPaymentOptions } from "@daimo/common";
2
- import { DaimoPayModalOptions } from "../types";
3
- import { trpc } from "./trpc";
4
- /** Wallet payment options. User picks one. */
5
- export type PaymentOption = Awaited<ReturnType<typeof trpc.getWalletPaymentOptions.query>>[0];
6
- /** Wallet payment details, sent to processSourcePayment after submitting tx. */
7
- export type SourcePayment = Parameters<typeof trpc.processSourcePayment.mutate>[0];
8
- /** Loads a DaimoPayOrder + manages the corresponding modal. */
9
- export interface PaymentInfo {
10
- setPayId: (id: string | null) => Promise<void>;
11
- daimoPayOrder: DaimoPayOrder | undefined;
12
- modalOptions: DaimoPayModalOptions;
13
- setModalOptions: (modalOptions: DaimoPayModalOptions) => void;
14
- paymentWaitingMessage: string | undefined;
15
- selectedExternalOption: ExternalPaymentOptionMetadata | undefined;
16
- selectedTokenOption: PaymentOption | undefined;
17
- setSelectedExternalOption: (option: ExternalPaymentOptionMetadata | undefined) => void;
18
- setSelectedTokenOption: (option: PaymentOption | undefined) => void;
19
- setChosenUsd: (amount: number) => void;
20
- payWithToken: (tokenAmount: DaimoPayTokenAmount) => Promise<void>;
21
- payWithExternal: (option: ExternalPaymentOptions) => Promise<string>;
22
- refreshOrder: () => Promise<void>;
23
- onSuccess: (args: {
24
- txHash: string;
25
- txURL?: string;
26
- }) => void;
27
- }
28
- export declare function getPaymentInfo(setOpen: (showModal: boolean) => void, log: (...args: any[]) => void): {
29
- setPayId: (payId: string | null) => Promise<void>;
30
- daimoPayOrder: DaimoPayOrder | undefined;
31
- modalOptions: DaimoPayModalOptions;
32
- setModalOptions: import("react").Dispatch<import("react").SetStateAction<DaimoPayModalOptions>>;
33
- paymentWaitingMessage: string | undefined;
34
- selectedExternalOption: ExternalPaymentOptionMetadata | undefined;
35
- selectedTokenOption: any;
36
- setSelectedExternalOption: import("react").Dispatch<import("react").SetStateAction<ExternalPaymentOptionMetadata | undefined>>;
37
- setSelectedTokenOption: import("react").Dispatch<any>;
38
- setChosenUsd: (usdAmount: number) => void;
39
- payWithToken: (tokenAmount: DaimoPayTokenAmount) => Promise<void>;
40
- payWithExternal: (option: ExternalPaymentOptions) => Promise<any>;
41
- refreshOrder: () => Promise<void>;
42
- onSuccess: ({ txHash, txURL }: {
43
- txHash: string;
44
- txURL?: string;
45
- }) => void;
46
- };