@daimo/pay 1.7.3 → 1.7.4
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.d.ts +21 -13
- package/build/index.js +141 -83
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { ExternalPaymentOptions, assert, assertNotNull, debugJson, supportedChains, ethereum, readDaimoPayOrderID, getChainName, arbitrum as arbitrum$1, base as base$2, blast as blast$1, bsc as bsc$1, linea as linea$1, mantle as mantle$1, optimism as optimism$1, polygon as polygon$1, worldchain as worldchain$1, getAddressContraction, writeDaimoPayOrderID, DaimoPayOrderMode, DaimoPayOrderStatusDest, getChainExplorerTxUrl, DaimoPayIntentStatus, retryBackoff, DaimoPayOrderStatusSource, getDaimoPayOrderView } from '@daimo/pay-common';
|
|
2
|
+
import { ExternalPaymentOptions, assert, assertNotNull, debugJson, supportedChains, ethereum, isCCTPV1Chain, getOrderDestChainId, readDaimoPayOrderID, getChainName, arbitrum as arbitrum$1, base as base$2, blast as blast$1, bsc as bsc$1, linea as linea$1, mantle as mantle$1, optimism as optimism$1, polygon as polygon$1, worldchain as worldchain$1, getAddressContraction, writeDaimoPayOrderID, DaimoPayOrderMode, DaimoPayOrderStatusDest, getChainExplorerTxUrl, DaimoPayIntentStatus, retryBackoff, DaimoPayOrderStatusSource, getDaimoPayOrderView } from '@daimo/pay-common';
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
4
|
import React, { useState, useEffect, createContext, useCallback, useRef, useLayoutEffect, useMemo, createElement } from 'react';
|
|
5
5
|
import styled$1, { css, keyframes, ThemeProvider } from 'styled-components';
|
|
@@ -22,7 +22,7 @@ import { WalletSignTransactionError, WalletSendTransactionError } from '@solana/
|
|
|
22
22
|
import { normalize } from 'viem/ens';
|
|
23
23
|
|
|
24
24
|
var name = "@daimo/pay";
|
|
25
|
-
var version = "1.7.
|
|
25
|
+
var version = "1.7.4";
|
|
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.7.
|
|
64
|
+
"@daimo/pay-common": "1.7.4",
|
|
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",
|
|
@@ -377,7 +377,7 @@ const OtherWallets = ({ ...props }) => {
|
|
|
377
377
|
overflow: "hidden",
|
|
378
378
|
borderRadius: "27.5%",
|
|
379
379
|
};
|
|
380
|
-
return (jsxs("div", { style: column, ...props, children: [jsxs("div", { style: row, children: [jsx("div", { style: cell, children: jsx(
|
|
380
|
+
return (jsxs("div", { style: column, ...props, children: [jsxs("div", { style: row, children: [jsx("div", { style: cell, children: jsx(Zerion, {}) }), jsx("div", { style: cell, children: jsx(WalletConnect, { background: true }) })] }), jsxs("div", { style: row, children: [jsx("div", { style: cell, children: jsx(Family, {}) }), jsx("div", { style: cell, children: jsx(Ledger, {}) })] })] }));
|
|
381
381
|
};
|
|
382
382
|
const Fordefi = ({ ...props }) => (jsxs("svg", { ...props, width: "88", height: "88", viewBox: "0 0 96 96", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxs("g", { clipPath: "url(#clip0_14298_75627)", children: [jsx("path", { d: "M43.5075 62.5508H6V73.5954C6 79.2046 10.5379 83.7515 16.1357 83.7515H32.9997L43.5075 62.5508Z", fill: "#7994FF" }), jsx("path", { d: "M6.00098 39.1016H76.2075L68.0567 55.4841H6.00098V39.1016Z", fill: "#486DFF" }), jsx("path", { d: "M30.6398 12H6.09766V32.0282H89.8447V12H65.3025V26.9577H60.2423V12H35.7001V26.9577H30.6398V12Z", fill: "#5CD1FA" })] }), jsx("defs", { children: jsx("clipPath", { id: "clip0_14298_75627", children: jsx("rect", { width: "84", height: "72", fill: "white", transform: "translate(6 12)" }) }) })] }));
|
|
383
383
|
const SquircleIcon = ({ icon, alt, }) => {
|
|
@@ -580,11 +580,12 @@ const walletConfigs = {
|
|
|
580
580
|
edge: "https://rainbow.me/extension?utm_source=daimopay",
|
|
581
581
|
brave: "https://rainbow.me/extension?utm_source=daimopay",
|
|
582
582
|
},
|
|
583
|
-
showInMobileConnectors:
|
|
583
|
+
showInMobileConnectors: false,
|
|
584
584
|
isWcMobileConnector: false,
|
|
585
585
|
getWalletConnectDeeplink: (uri) => {
|
|
586
|
-
return `
|
|
586
|
+
return `rainbow://wc?uri=${encodeURIComponent(uri)}&connector=daimopay`;
|
|
587
587
|
},
|
|
588
|
+
walletDeepLink: "rainbow://",
|
|
588
589
|
},
|
|
589
590
|
"io.rabby": {
|
|
590
591
|
name: "Rabby Wallet",
|
|
@@ -732,7 +733,7 @@ const walletConfigs = {
|
|
|
732
733
|
getWalletConnectDeeplink: (uri) => {
|
|
733
734
|
return `https://app.zerion.io/wc?uri=${encodeURIComponent(uri)}`;
|
|
734
735
|
},
|
|
735
|
-
showInMobileConnectors:
|
|
736
|
+
showInMobileConnectors: true,
|
|
736
737
|
},
|
|
737
738
|
slope: {
|
|
738
739
|
name: "Slope",
|
|
@@ -838,7 +839,7 @@ function extractWcWalletFromProvider(p, log) {
|
|
|
838
839
|
isWcMobileConnector: true,
|
|
839
840
|
};
|
|
840
841
|
}
|
|
841
|
-
log(`[WCWALLET] name: ${name} wcWallet: ${wallet?.name} isWcMobileConnector: ${wallet?.isWcMobileConnector} provider:
|
|
842
|
+
log(`[WCWALLET] name: ${name} wcWallet: ${wallet?.name} isWcMobileConnector: ${wallet?.isWcMobileConnector} provider: `, p);
|
|
842
843
|
return wallet;
|
|
843
844
|
}
|
|
844
845
|
|
|
@@ -1189,6 +1190,14 @@ function usePaymentState({ trpc, daimoPayOrder, setDaimoPayOrder, setOpen, log,
|
|
|
1189
1190
|
// Solana wallet state.
|
|
1190
1191
|
const solanaWallet = useWallet$1();
|
|
1191
1192
|
const solanaPubKey = solanaWallet.publicKey?.toBase58();
|
|
1193
|
+
// TODO: backend should determine whether to show solana payment method
|
|
1194
|
+
const paymentOptions = daimoPayOrder?.metadata.payer?.paymentOptions;
|
|
1195
|
+
// Include by default if paymentOptions not provided. Solana bridging is only
|
|
1196
|
+
// supported on CCTP v1 chains.
|
|
1197
|
+
const showSolanaPaymentMethod = (paymentOptions == null ||
|
|
1198
|
+
paymentOptions.includes(ExternalPaymentOptions.Solana)) &&
|
|
1199
|
+
daimoPayOrder != null &&
|
|
1200
|
+
isCCTPV1Chain(getOrderDestChainId(daimoPayOrder));
|
|
1192
1201
|
// Daimo Pay order state.
|
|
1193
1202
|
const [payParams, setPayParamsState] = useState();
|
|
1194
1203
|
const [paymentWaitingMessage, setPaymentWaitingMessage] = useState();
|
|
@@ -1337,11 +1346,11 @@ function usePaymentState({ trpc, daimoPayOrder, setDaimoPayOrder, setOpen, log,
|
|
|
1337
1346
|
const setChosenUsd = (usd) => {
|
|
1338
1347
|
assert(!!daimoPayOrder, "[SET CHOSEN USD] daimoPayOrder cannot be null");
|
|
1339
1348
|
const token = daimoPayOrder.destFinalCallTokenAmount.token;
|
|
1340
|
-
const tokenUnits = (usd / token.
|
|
1349
|
+
const tokenUnits = (usd / token.priceFromUsd).toString();
|
|
1341
1350
|
const tokenAmount = parseUnits(tokenUnits, token.decimals);
|
|
1342
1351
|
// TODO: remove amount from destFinalCall, it is redundant with
|
|
1343
1352
|
// destFinalCallTokenAmount. Here, we only modify one and not the other.
|
|
1344
|
-
log(`[CHECKOUT]
|
|
1353
|
+
log(`[CHECKOUT] chose USD amount $${usd} = ${tokenUnits} ${token.symbol}`);
|
|
1345
1354
|
setDaimoPayOrder({
|
|
1346
1355
|
...daimoPayOrder,
|
|
1347
1356
|
destFinalCallTokenAmount: {
|
|
@@ -1409,6 +1418,9 @@ function usePaymentState({ trpc, daimoPayOrder, setDaimoPayOrder, setOpen, log,
|
|
|
1409
1418
|
setTimeout(() => setOpen(false, { event: "wait-success" }), 1000);
|
|
1410
1419
|
}
|
|
1411
1420
|
};
|
|
1421
|
+
const resetOrder = () => {
|
|
1422
|
+
setDaimoPayOrder(undefined);
|
|
1423
|
+
};
|
|
1412
1424
|
return {
|
|
1413
1425
|
setPayId,
|
|
1414
1426
|
payParams,
|
|
@@ -1423,11 +1435,13 @@ function usePaymentState({ trpc, daimoPayOrder, setDaimoPayOrder, setOpen, log,
|
|
|
1423
1435
|
selectedTokenOption,
|
|
1424
1436
|
selectedSolanaTokenOption,
|
|
1425
1437
|
externalPaymentOptions,
|
|
1438
|
+
showSolanaPaymentMethod,
|
|
1426
1439
|
walletPaymentOptions,
|
|
1427
1440
|
solanaPaymentOptions,
|
|
1428
1441
|
depositAddressOptions,
|
|
1429
1442
|
selectedDepositAddressOption,
|
|
1430
1443
|
getOrderUsdLimit,
|
|
1444
|
+
resetOrder,
|
|
1431
1445
|
setPaymentWaitingMessage,
|
|
1432
1446
|
setSelectedExternalOption,
|
|
1433
1447
|
setSelectedTokenOption,
|
|
@@ -4887,9 +4901,39 @@ const useWallet = (id) => {
|
|
|
4887
4901
|
return null;
|
|
4888
4902
|
return wallet;
|
|
4889
4903
|
};
|
|
4890
|
-
const useWallets = () => {
|
|
4904
|
+
const useWallets = (isMobile) => {
|
|
4891
4905
|
const connectors = useConnectors();
|
|
4892
4906
|
const context = usePayContext();
|
|
4907
|
+
if (isMobile) {
|
|
4908
|
+
const mobileWallets = [];
|
|
4909
|
+
// Add Rainbow first
|
|
4910
|
+
mobileWallets.push({
|
|
4911
|
+
id: "me.rainbow",
|
|
4912
|
+
...walletConfigs["me.rainbow"],
|
|
4913
|
+
});
|
|
4914
|
+
// Add MetaMask second
|
|
4915
|
+
const metaMaskConnector = connectors.find((c) => c.id === "metaMask");
|
|
4916
|
+
if (metaMaskConnector) {
|
|
4917
|
+
mobileWallets.push({
|
|
4918
|
+
id: metaMaskConnector.id,
|
|
4919
|
+
connector: metaMaskConnector,
|
|
4920
|
+
...walletConfigs["metaMask, metaMask-io, io.metamask, io.metamask.mobile, metaMaskSDK"],
|
|
4921
|
+
});
|
|
4922
|
+
}
|
|
4923
|
+
// Add WalletConnect and other wallets
|
|
4924
|
+
connectors.forEach((connector) => {
|
|
4925
|
+
if (connector.id === "metaMask")
|
|
4926
|
+
return;
|
|
4927
|
+
if (isCoinbaseWalletConnector(connector.id))
|
|
4928
|
+
return;
|
|
4929
|
+
mobileWallets.push({
|
|
4930
|
+
id: connector.id,
|
|
4931
|
+
connector,
|
|
4932
|
+
...walletConfigs[connector.id],
|
|
4933
|
+
});
|
|
4934
|
+
});
|
|
4935
|
+
return mobileWallets;
|
|
4936
|
+
}
|
|
4893
4937
|
const wallets = connectors.map((connector) => {
|
|
4894
4938
|
// use overrides
|
|
4895
4939
|
const walletId = Object.keys(walletConfigs).find(
|
|
@@ -4944,8 +4988,8 @@ const useWallets = () => {
|
|
|
4944
4988
|
self.find((w) => w.id === "farcaster")))
|
|
4945
4989
|
// order by isInstalled injected connectors first
|
|
4946
4990
|
.sort((a, b) => {
|
|
4947
|
-
const AisInstalled = a.isInstalled && isInjectedConnector(a.connector
|
|
4948
|
-
const BisInstalled = b.isInstalled && isInjectedConnector(b.connector
|
|
4991
|
+
const AisInstalled = a.isInstalled && isInjectedConnector(a.connector?.type);
|
|
4992
|
+
const BisInstalled = b.isInstalled && isInjectedConnector(b.connector?.type);
|
|
4949
4993
|
if (AisInstalled && !BisInstalled)
|
|
4950
4994
|
return -1;
|
|
4951
4995
|
if (!AisInstalled && BisInstalled)
|
|
@@ -7246,15 +7290,15 @@ const ConnectorsContainer = styled.div `
|
|
|
7246
7290
|
const ConnectorList = () => {
|
|
7247
7291
|
const context = usePayContext();
|
|
7248
7292
|
const { isMobile } = useIsMobile();
|
|
7249
|
-
const wallets = useWallets();
|
|
7293
|
+
const wallets = useWallets(isMobile);
|
|
7250
7294
|
const { lastConnectorId } = useLastConnector();
|
|
7251
7295
|
const walletsToDisplay = context.options?.hideRecentBadge || lastConnectorId === "walletConnect" // do not hoist walletconnect to top of list
|
|
7252
7296
|
? wallets
|
|
7253
7297
|
: [
|
|
7254
7298
|
// move last used wallet to top of list
|
|
7255
7299
|
// using .filter and spread to avoid mutating original array order with .sort
|
|
7256
|
-
...wallets.filter((wallet) => lastConnectorId === wallet.connector
|
|
7257
|
-
...wallets.filter((wallet) => lastConnectorId !== wallet.connector
|
|
7300
|
+
...wallets.filter((wallet) => lastConnectorId === wallet.connector?.id),
|
|
7301
|
+
...wallets.filter((wallet) => lastConnectorId !== wallet.connector?.id),
|
|
7258
7302
|
];
|
|
7259
7303
|
return (jsxs(ScrollArea, { mobileDirection: "horizontal", children: [walletsToDisplay.length === 0 && (jsx(Alert, { error: true, children: "No connectors found in ConnectKit config." })), walletsToDisplay.length > 0 && (jsx(ConnectorsContainer, { "$mobile": isMobile, "$totalResults": walletsToDisplay.length, children: walletsToDisplay.map((wallet) => (jsx(ConnectorItem, { wallet: wallet, isRecent: wallet.id === lastConnectorId }, wallet.id))) }))] }));
|
|
7260
7304
|
};
|
|
@@ -7271,7 +7315,7 @@ const ConnectorItem = ({ wallet, isRecent, }) => {
|
|
|
7271
7315
|
const redirectToMoreWallets = isMobile && isWalletConnectConnector(wallet.id);
|
|
7272
7316
|
// Safari requires opening popup on user gesture, so we connect immediately here
|
|
7273
7317
|
const shouldConnectImmediately = (detectBrowser() === "safari" || detectBrowser() === "ios") &&
|
|
7274
|
-
isCoinbaseWalletConnector(wallet.connector
|
|
7318
|
+
isCoinbaseWalletConnector(wallet.connector?.id);
|
|
7275
7319
|
if (redirectToMoreWallets || shouldConnectImmediately)
|
|
7276
7320
|
deeplink = undefined; // mobile redirects to more wallets page
|
|
7277
7321
|
return (jsxs(ConnectorButton, { type: "button", as: deeplink ? "a" : undefined, href: deeplink ? deeplink : undefined, disabled: context.route !== ROUTES.CONNECTORS, onClick: deeplink
|
|
@@ -8225,7 +8269,7 @@ const MobileConnectors = () => {
|
|
|
8225
8269
|
// filter out installed wallets
|
|
8226
8270
|
const walletsIdsToDisplay = Object.keys(walletConfigs).filter((walletId) => {
|
|
8227
8271
|
const wallet = walletConfigs[walletId];
|
|
8228
|
-
if (wallets.find((w) => w.connector
|
|
8272
|
+
if (wallets.find((w) => w.connector?.id === walletId))
|
|
8229
8273
|
return false;
|
|
8230
8274
|
if (!wallet.getWalletConnectDeeplink)
|
|
8231
8275
|
return false;
|
|
@@ -9357,7 +9401,7 @@ const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
|
|
|
9357
9401
|
return (jsx(PageContent, { children: jsxs(Container$4, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "No connectors match the id given. This state should never happen." }) })] }) }));
|
|
9358
9402
|
}
|
|
9359
9403
|
// TODO: Make this more generic
|
|
9360
|
-
if (isWalletConnectConnector(wallet?.connector
|
|
9404
|
+
if (isWalletConnectConnector(wallet?.connector?.id)) {
|
|
9361
9405
|
return (jsx(PageContent, { children: jsxs(Container$4, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "WalletConnect does not have an injection flow. This state should never happen." }) })] }) }));
|
|
9362
9406
|
}
|
|
9363
9407
|
return (jsx(PageContent, { children: jsxs(Container$4, { children: [jsx(ConnectingContainer, { children: jsxs(ConnectingAnimation, { "$shake": status === states$1.FAILED || status === states$1.REJECTED, "$circle": walletInfo.iconShape === "circle", children: [jsx(AnimatePresence, { children: (status === states$1.FAILED || status === states$1.REJECTED) && (jsx(RetryButton, { "aria-label": "Retry", initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, whileTap: { scale: 0.9 }, transition: { duration: 0.1 }, onClick: runConnect, children: jsx(RetryIconContainer, { children: jsx(Tooltip, { open: showTryAgainTooltip &&
|
|
@@ -9369,9 +9413,9 @@ const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
|
|
|
9369
9413
|
transform: "scale(1.14)",
|
|
9370
9414
|
position: "relative",
|
|
9371
9415
|
width: "100%",
|
|
9372
|
-
}, children: walletInfo.icon })) : (jsx(Fragment, { children: walletInfo.icon })), loading: status === states$1.CONNECTING }))] }) }), jsx(ModalContentContainer, { children: jsxs(AnimatePresence, { initial: false, children: [status === states$1.FAILED && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { children: [jsxs(ModalH1, { "$error": true, children: [jsx(AlertIcon, {}), locales.injectionScreen_failed_h1] }), jsx(ModalBody, { children: locales.injectionScreen_failed_p })] }) }, states$1.FAILED)), status === states$1.REJECTED && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { style: { paddingBottom: 28 }, children: [jsx(ModalH1, { children: locales.injectionScreen_rejected_h1 }), jsx(ModalBody, { children: locales.injectionScreen_rejected_p })] }) }, states$1.REJECTED)), (status === states$1.CONNECTING || status === states$1.EXPIRING) && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { style: { paddingBottom: 28 }, children: [jsx(ModalH1, { children: wallet.connector
|
|
9416
|
+
}, children: walletInfo.icon })) : (jsx(Fragment, { children: walletInfo.icon })), loading: status === states$1.CONNECTING }))] }) }), jsx(ModalContentContainer, { children: jsxs(AnimatePresence, { initial: false, children: [status === states$1.FAILED && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { children: [jsxs(ModalH1, { "$error": true, children: [jsx(AlertIcon, {}), locales.injectionScreen_failed_h1] }), jsx(ModalBody, { children: locales.injectionScreen_failed_p })] }) }, states$1.FAILED)), status === states$1.REJECTED && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { style: { paddingBottom: 28 }, children: [jsx(ModalH1, { children: locales.injectionScreen_rejected_h1 }), jsx(ModalBody, { children: locales.injectionScreen_rejected_p })] }) }, states$1.REJECTED)), (status === states$1.CONNECTING || status === states$1.EXPIRING) && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { style: { paddingBottom: 28 }, children: [jsx(ModalH1, { children: wallet.connector?.id === "injected"
|
|
9373
9417
|
? locales.injectionScreen_connecting_injected_h1
|
|
9374
|
-
: locales.injectionScreen_connecting_h1 }), jsx(ModalBody, { children: wallet.connector
|
|
9418
|
+
: locales.injectionScreen_connecting_h1 }), jsx(ModalBody, { children: wallet.connector?.id === "injected"
|
|
9375
9419
|
? locales.injectionScreen_connecting_injected_p
|
|
9376
9420
|
: locales.injectionScreen_connecting_p }), jsxs(Button, { icon: jsx(ExternalLinkIcon, {}), onClick: runConnect, children: ["Connect ", walletInfo.name] })] }) }, states$1.CONNECTING)), status === states$1.CONNECTED && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { children: [jsxs(ModalH1, { "$valid": true, children: [jsx(TickIcon, {}), " ", locales.injectionScreen_connected_h1] }), jsx(ModalBody, { children: locales.injectionScreen_connected_p })] }) }, states$1.CONNECTED)), status === states$1.NOTCONNECTED && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: jsxs(ModalContent, { children: [jsx(ModalH1, { children: locales.injectionScreen_notconnected_h1 }), jsx(ModalBody, { children: locales.injectionScreen_notconnected_p })] }) }, states$1.NOTCONNECTED)), status === states$1.UNAVAILABLE && (jsx(Content, { initial: "initial", animate: "animate", exit: "exit", variants: contentVariants$1, children: !extensionUrl ? (jsxs(Fragment, { children: [jsxs(ModalContent, { style: { paddingBottom: 12 }, children: [jsx(ModalH1, { children: locales.injectionScreen_unavailable_h1 }), jsx(ModalBody, { children: locales.injectionScreen_unavailable_p })] }), !wallet.isInstalled && suggestedExtension && (jsxs(Button, { href: suggestedExtension?.url, icon: jsx(BrowserIcon, { browser: suggestedExtension?.name }), children: ["Install on ", suggestedExtension?.label] }))] })) : (jsxs(Fragment, { children: [jsxs(ModalContent, { style: { paddingBottom: 18 }, children: [jsx(ModalH1, { children: locales.injectionScreen_install_h1 }), jsx(ModalBody, { children: locales.injectionScreen_install_p })] }), !wallet.isInstalled && extensionUrl && (jsx(Button, { href: extensionUrl, icon: jsx(BrowserIcon, {}), children: locales.installTheExtension }))] })) }, states$1.UNAVAILABLE))] }) })] }) }));
|
|
9377
9421
|
};
|
|
@@ -9459,7 +9503,7 @@ const ConnectUsing = () => {
|
|
|
9459
9503
|
useEffect(() => {
|
|
9460
9504
|
// if no provider, change to qrcode
|
|
9461
9505
|
const checkProvider = async () => {
|
|
9462
|
-
const res = await wallet?.connector
|
|
9506
|
+
const res = await wallet?.connector?.getProvider();
|
|
9463
9507
|
if (!res) {
|
|
9464
9508
|
setStatus(states.QRCODE);
|
|
9465
9509
|
setTimeout(context.triggerResize, 10); // delay required here for modal to resize
|
|
@@ -9761,8 +9805,8 @@ const ChainLogoContainer = styled(motion.div) `
|
|
|
9761
9805
|
}
|
|
9762
9806
|
`;
|
|
9763
9807
|
|
|
9764
|
-
const TokenLogoSpinner = ({ token
|
|
9765
|
-
return (jsx(LoadingContainer$2, { children: jsx(AnimationContainer$1, { "$circle": true, children: jsxs(AnimatePresence, { children: [chainToLogo[token.chainId] && (jsx(ChainLogoContainer, { children: chainToLogo[token.chainId] }, "ChainLogoContainer")), jsx(CircleSpinner, { logo: jsx("img", { src: token.logoURI, alt: token.symbol }), loading:
|
|
9808
|
+
const TokenLogoSpinner = ({ token }) => {
|
|
9809
|
+
return (jsx(LoadingContainer$2, { children: jsx(AnimationContainer$1, { "$circle": true, children: jsxs(AnimatePresence, { children: [chainToLogo[token.chainId] && (jsx(ChainLogoContainer, { children: chainToLogo[token.chainId] }, "ChainLogoContainer")), jsx(CircleSpinner, { logo: jsx("img", { src: token.logoURI, alt: token.symbol }), loading: false, unavailable: false }, "CircleSpinner")] }) }) }));
|
|
9766
9810
|
};
|
|
9767
9811
|
|
|
9768
9812
|
var PayState$1;
|
|
@@ -9869,12 +9913,12 @@ const PayWithToken = () => {
|
|
|
9869
9913
|
if (selectedTokenOption == null) {
|
|
9870
9914
|
return jsx(PageContent, {});
|
|
9871
9915
|
}
|
|
9872
|
-
return (jsxs(PageContent, { children: [jsx(TokenLogoSpinner, { token: selectedTokenOption.required.token }), jsxs(ModalContent, { style: { paddingBottom: 0 }, "$preserveDisplay": true, children: [jsx(ModalH1, { children: payState }), jsx(PaymentBreakdown, { paymentOption: selectedTokenOption }), payState === PayState$1.RequestingPayment && wcWallet && isMobile && (
|
|
9916
|
+
return (jsxs(PageContent, { children: [jsx(TokenLogoSpinner, { token: selectedTokenOption.required.token }), jsxs(ModalContent, { style: { paddingBottom: 0 }, "$preserveDisplay": true, children: [jsx(ModalH1, { children: payState }), jsx(PaymentBreakdown, { paymentOption: selectedTokenOption }), payState === PayState$1.RequestingPayment && wcWallet && isMobile && (jsx(Button, { icon: jsx(ExternalLinkIcon, {}), onClick: wcWallet.isWcMobileConnector
|
|
9873
9917
|
? () => handleTransfer(selectedTokenOption)
|
|
9874
9918
|
: undefined, href: wcWallet.isWcMobileConnector
|
|
9875
9919
|
? undefined
|
|
9876
9920
|
: wcWallet.walletDeepLink ||
|
|
9877
|
-
wcWallet.getWalletConnectDeeplink?.(""), children:
|
|
9921
|
+
wcWallet.getWalletConnectDeeplink?.(""), children: "Tap Here to Pay" })), payState === PayState$1.RequestCancelled && (jsx(Button, { onClick: () => handleTransfer(selectedTokenOption), children: "Retry Payment" }))] })] }));
|
|
9878
9922
|
};
|
|
9879
9923
|
|
|
9880
9924
|
/**
|
|
@@ -10087,7 +10131,7 @@ const MultiCurrencySelectAmount = ({ selectedTokenOption, setSelectedTokenOption
|
|
|
10087
10131
|
tokenSymbol: balanceToken.symbol,
|
|
10088
10132
|
});
|
|
10089
10133
|
};
|
|
10090
|
-
return (jsxs(PageContent, { children: [jsx(TokenLogoSpinner, { token: balanceToken
|
|
10134
|
+
return (jsxs(PageContent, { children: [jsx(TokenLogoSpinner, { token: balanceToken }), jsxs(ModalContent, { "$preserveDisplay": true, children: [jsxs(AmountInputContainer$2, { children: [jsx(MaxButton, { style: { visibility: "hidden" }, children: "Max" }), jsx(AmountInputField, { value: isEditingUsd ? usdValue : tokenValue, onChange: handleAmountChange, currency: isEditingUsd ? "$" : balanceToken.symbol, onKeyDown: handleKeyDown }), jsx(MaxButton, { onClick: handleMax, children: "Max" })] }), balanceToken.fiatISO !== "USD" && (jsx(SwitchContainer, { children: jsx(SwitchButton, { onClick: handleSwitchCurrency, children: jsx(SecondaryAmount, { children: isEditingUsd
|
|
10091
10135
|
? `${tokenValue} ${balanceToken.symbol}`
|
|
10092
10136
|
: `$${usdValue}` }) }) })), message && jsx(ModalBody, { children: message }), jsx(Button, { onClick: handleContinue, disabled: continueDisabled, children: "Continue" })] })] }));
|
|
10093
10137
|
};
|
|
@@ -10135,13 +10179,13 @@ const SelectAmount = () => {
|
|
|
10135
10179
|
return (jsx(MultiCurrencySelectAmount, { selectedTokenOption: selectedTokenOption, setSelectedTokenOption: setSelectedTokenOption, nextPage: ROUTES.PAY_WITH_TOKEN }));
|
|
10136
10180
|
};
|
|
10137
10181
|
|
|
10138
|
-
const ExternalPaymentSpinner = ({ logoURI, logoShape,
|
|
10182
|
+
const ExternalPaymentSpinner = ({ logoURI, logoShape, }) => {
|
|
10139
10183
|
const optionSpinner = (() => {
|
|
10140
10184
|
if (logoShape === "circle") {
|
|
10141
|
-
return (jsx(CircleSpinner, { logo: jsx("img", { src: logoURI }), loading:
|
|
10185
|
+
return (jsx(CircleSpinner, { logo: jsx("img", { src: logoURI }), loading: false, unavailable: false }));
|
|
10142
10186
|
}
|
|
10143
10187
|
else {
|
|
10144
|
-
return
|
|
10188
|
+
return jsx(SquircleSpinner, { logo: jsx("img", { src: logoURI }), loading: false });
|
|
10145
10189
|
}
|
|
10146
10190
|
})();
|
|
10147
10191
|
return (jsx(LoadingContainer$2, { children: jsx(AnimationContainer$1, { "$circle": logoShape === "circle", children: jsx(AnimatePresence, { children: optionSpinner }) }) }));
|
|
@@ -10187,7 +10231,7 @@ const SelectDepositAddressAmount = () => {
|
|
|
10187
10231
|
paymentState.setChosenUsd(amountUsd);
|
|
10188
10232
|
setRoute(ROUTES.WAITING_DEPOSIT_ADDRESS, { amountUsd });
|
|
10189
10233
|
};
|
|
10190
|
-
return (jsxs(PageContent, { children: [jsx(ExternalPaymentSpinner, { logoURI: selectedDepositAddressOption.logoURI, logoShape: "circle"
|
|
10234
|
+
return (jsxs(PageContent, { children: [jsx(ExternalPaymentSpinner, { logoURI: selectedDepositAddressOption.logoURI, logoShape: "circle" }), jsxs(ModalContent, { "$preserveDisplay": true, children: [jsx(AmountInputContainer$1, { children: jsx(AmountInputField, { value: usdInput, onChange: handleAmountChange, onKeyDown: handleKeyDown }) }), message && jsx(ModalBody, { children: message }), jsx(Button, { onClick: handleContinue, disabled: continueDisabled, children: "Continue" })] })] }));
|
|
10191
10235
|
};
|
|
10192
10236
|
const AmountInputContainer$1 = styled.div `
|
|
10193
10237
|
display: flex;
|
|
@@ -10449,7 +10493,7 @@ const IconStackItem = styled(motion.div) `
|
|
|
10449
10493
|
border-radius: 22.5%;
|
|
10450
10494
|
`;
|
|
10451
10495
|
|
|
10452
|
-
const OptionsContainer = styled
|
|
10496
|
+
const OptionsContainer = styled.div `
|
|
10453
10497
|
width: 100%;
|
|
10454
10498
|
margin-top: 1rem;
|
|
10455
10499
|
`;
|
|
@@ -10598,7 +10642,7 @@ const SelectExternalAmount = () => {
|
|
|
10598
10642
|
paymentState.setChosenUsd(amountUsd);
|
|
10599
10643
|
setRoute(ROUTES.WAITING_EXTERNAL, { amountUsd });
|
|
10600
10644
|
};
|
|
10601
|
-
return (jsxs(PageContent, { children: [jsx(ExternalPaymentSpinner, { logoURI: selectedExternalOption.logoURI, logoShape: selectedExternalOption.logoShape
|
|
10645
|
+
return (jsxs(PageContent, { children: [jsx(ExternalPaymentSpinner, { logoURI: selectedExternalOption.logoURI, logoShape: selectedExternalOption.logoShape }), jsxs(ModalContent, { "$preserveDisplay": true, children: [jsx(AmountInputContainer, { children: jsx(AmountInputField, { value: usdInput, onChange: handleAmountChange, onKeyDown: handleKeyDown }) }), message && jsx(ModalBody, { children: message }), jsx(Button, { onClick: handleContinue, disabled: continueDisabled, children: "Continue" })] })] }));
|
|
10602
10646
|
};
|
|
10603
10647
|
const AmountInputContainer = styled.div `
|
|
10604
10648
|
display: flex;
|
|
@@ -10630,7 +10674,7 @@ function SelectMethod() {
|
|
|
10630
10674
|
const { connected: isSolanaConnected, wallet: solanaWallet, publicKey, } = useWallet$1();
|
|
10631
10675
|
const { setRoute, paymentState, wcWallet, log } = usePayContext();
|
|
10632
10676
|
const { disconnectAsync } = useDisconnect();
|
|
10633
|
-
const { daimoPayOrder, setSelectedExternalOption, externalPaymentOptions, depositAddressOptions, senderEnsName, } = paymentState;
|
|
10677
|
+
const { daimoPayOrder, setSelectedExternalOption, externalPaymentOptions, showSolanaPaymentMethod, depositAddressOptions, senderEnsName, } = paymentState;
|
|
10634
10678
|
const paymentOptions = daimoPayOrder?.metadata.payer?.paymentOptions;
|
|
10635
10679
|
const getConnectedWalletOptions = () => {
|
|
10636
10680
|
const showChainLogo = isEthConnected && isSolanaConnected;
|
|
@@ -10665,7 +10709,7 @@ function SelectMethod() {
|
|
|
10665
10709
|
};
|
|
10666
10710
|
connectedOptions.push(connectedEthWalletOption);
|
|
10667
10711
|
}
|
|
10668
|
-
if (isSolanaConnected &&
|
|
10712
|
+
if (isSolanaConnected && showSolanaPaymentMethod) {
|
|
10669
10713
|
const solWalletDisplayName = getAddressContraction(publicKey?.toBase58() ?? "");
|
|
10670
10714
|
const connectedSolWalletOption = {
|
|
10671
10715
|
id: "connectedSolanaWallet",
|
|
@@ -10690,13 +10734,9 @@ function SelectMethod() {
|
|
|
10690
10734
|
}
|
|
10691
10735
|
return connectedOptions;
|
|
10692
10736
|
};
|
|
10693
|
-
// Solana payment option
|
|
10694
|
-
// Include by default if paymentOptions not provided
|
|
10695
|
-
const includeSolana = paymentOptions == null ||
|
|
10696
|
-
paymentOptions.includes(ExternalPaymentOptions.Solana);
|
|
10697
10737
|
// Deposit address options, e.g. Bitcoin, Tron, Zcash, etc.
|
|
10698
10738
|
// Include by default if paymentOptions not provided
|
|
10699
|
-
const
|
|
10739
|
+
const showDepositAddressMethod = paymentOptions == null ||
|
|
10700
10740
|
paymentOptions.includes(ExternalPaymentOptions.ExternalChains);
|
|
10701
10741
|
const connectedWalletOptions = getConnectedWalletOptions();
|
|
10702
10742
|
const unconnectedWalletOption = {
|
|
@@ -10714,7 +10754,7 @@ function SelectMethod() {
|
|
|
10714
10754
|
options.push(...connectedWalletOptions);
|
|
10715
10755
|
options.push(unconnectedWalletOption);
|
|
10716
10756
|
log(`[SELECT_METHOD] loading: ${externalPaymentOptions.loading}, options: ${JSON.stringify(externalPaymentOptions.options)}`);
|
|
10717
|
-
if (
|
|
10757
|
+
if (showSolanaPaymentMethod) {
|
|
10718
10758
|
const solanaOption = getSolanaOption(isIOS);
|
|
10719
10759
|
if (solanaOption) {
|
|
10720
10760
|
options.push(solanaOption);
|
|
@@ -10738,7 +10778,7 @@ function SelectMethod() {
|
|
|
10738
10778
|
disabled: option.disabled,
|
|
10739
10779
|
subtitle: option.message,
|
|
10740
10780
|
})));
|
|
10741
|
-
if (
|
|
10781
|
+
if (showDepositAddressMethod) {
|
|
10742
10782
|
const depositAddressOption = getDepositAddressOption(depositAddressOptions);
|
|
10743
10783
|
options.push(depositAddressOption);
|
|
10744
10784
|
}
|
|
@@ -10998,7 +11038,7 @@ var PayState;
|
|
|
10998
11038
|
})(PayState || (PayState = {}));
|
|
10999
11039
|
const PayWithSolanaToken = () => {
|
|
11000
11040
|
const { triggerResize, paymentState, setRoute } = usePayContext();
|
|
11001
|
-
const {
|
|
11041
|
+
const { selectedSolanaTokenOption, payWithSolanaToken } = paymentState;
|
|
11002
11042
|
const [payState, setPayState] = useState(PayState.RequestingPayment);
|
|
11003
11043
|
const handleTransfer = async () => {
|
|
11004
11044
|
try {
|
|
@@ -11135,6 +11175,7 @@ const WaitingExternal = () => {
|
|
|
11135
11175
|
const context = usePayContext();
|
|
11136
11176
|
const { triggerResize, paymentState, setRoute } = context;
|
|
11137
11177
|
const trpc = context.trpc;
|
|
11178
|
+
const { isMobile } = useIsMobile();
|
|
11138
11179
|
const { selectedExternalOption, payWithExternal, paymentWaitingMessage, daimoPayOrder, } = paymentState;
|
|
11139
11180
|
const [externalURL, setExternalURL] = useState(null);
|
|
11140
11181
|
useEffect(() => {
|
|
@@ -11160,17 +11201,19 @@ const WaitingExternal = () => {
|
|
|
11160
11201
|
});
|
|
11161
11202
|
}, [selectedExternalOption]);
|
|
11162
11203
|
const openExternalWindow = (url) => {
|
|
11163
|
-
if (
|
|
11164
|
-
//
|
|
11204
|
+
if (isMobile) {
|
|
11205
|
+
// on mobile: open in a new tab
|
|
11206
|
+
window.open(url, "_blank");
|
|
11207
|
+
}
|
|
11208
|
+
else {
|
|
11209
|
+
// on desktop: open in a popup window in
|
|
11210
|
+
// portrait mode in the center of the screen
|
|
11165
11211
|
const width = 500;
|
|
11166
11212
|
const height = 700;
|
|
11167
11213
|
const left = Math.max(0, Math.floor((window.innerWidth - width) / 2) + window.screenX);
|
|
11168
11214
|
const top = Math.max(0, Math.floor((window.innerHeight - height) / 2) + window.screenY);
|
|
11169
11215
|
window.open(url, "popupWindow", `width=${width},height=${height},left=${left},top=${top},scrollbars=yes`);
|
|
11170
11216
|
}
|
|
11171
|
-
else {
|
|
11172
|
-
window.open(url, "_blank");
|
|
11173
|
-
}
|
|
11174
11217
|
};
|
|
11175
11218
|
const waitingMessageLength = paymentWaitingMessage?.length;
|
|
11176
11219
|
useEffect(() => {
|
|
@@ -11190,14 +11233,14 @@ const customThemeDefault = {};
|
|
|
11190
11233
|
const DaimoPayModal = ({ mode = "auto", theme = "auto", customTheme = customThemeDefault, lang = "en-US", }) => {
|
|
11191
11234
|
const context = usePayContext();
|
|
11192
11235
|
const paymentState = context.paymentState;
|
|
11193
|
-
const { payParams, generatePreviewOrder, isDepositFlow, setPaymentWaitingMessage, setSelectedExternalOption, setSelectedTokenOption, setSelectedSolanaTokenOption, setSelectedDepositAddressOption, } = paymentState;
|
|
11236
|
+
const { payParams, generatePreviewOrder, isDepositFlow, showSolanaPaymentMethod, setPaymentWaitingMessage, setSelectedExternalOption, setSelectedTokenOption, setSelectedSolanaTokenOption, setSelectedDepositAddressOption, } = paymentState;
|
|
11194
11237
|
const { isConnected: isEthConnected, connector, chain, address, } = useAccount();
|
|
11195
11238
|
const { connected: isSolanaConnected } = useWallet$1();
|
|
11196
11239
|
const { daimoPayOrder } = paymentState;
|
|
11197
11240
|
const paymentOptions = daimoPayOrder?.metadata.payer?.paymentOptions;
|
|
11198
11241
|
// Solana payment option
|
|
11199
11242
|
// Include by default if paymentOptions not provided
|
|
11200
|
-
|
|
11243
|
+
paymentOptions == null ||
|
|
11201
11244
|
paymentOptions.includes(ExternalPaymentOptions.Solana);
|
|
11202
11245
|
const chainIsSupported = useChainIsSupported(chain?.id);
|
|
11203
11246
|
//if chain is unsupported we enforce a "switch chain" prompt
|
|
@@ -11317,34 +11360,42 @@ const DaimoPayModal = ({ mode = "auto", theme = "auto", customTheme = customThem
|
|
|
11317
11360
|
}
|
|
11318
11361
|
context.setOpen(false, { event: "click-close" });
|
|
11319
11362
|
}
|
|
11320
|
-
//
|
|
11363
|
+
// If the user has a wallet already connected upon opening the modal, go
|
|
11364
|
+
// straight to the select token screen
|
|
11321
11365
|
useEffect(() => {
|
|
11322
|
-
if (context.open
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11366
|
+
if (!context.open)
|
|
11367
|
+
return;
|
|
11368
|
+
if (context.route !== ROUTES.SELECT_METHOD)
|
|
11369
|
+
return;
|
|
11370
|
+
const ethMethodAvailable = context.wcWallet != null || isEthConnected;
|
|
11371
|
+
const solanaMethodAvailable = isSolanaConnected && showSolanaPaymentMethod;
|
|
11372
|
+
// Skip to token selection if exactly one wallet is connected. If both
|
|
11373
|
+
// wallets are connected, stay on the SELECT_METHOD screen to allow the
|
|
11374
|
+
// user to select which wallet to use
|
|
11375
|
+
if (ethMethodAvailable && !solanaMethodAvailable) {
|
|
11376
|
+
context.setRoute(ROUTES.SELECT_TOKEN, {
|
|
11377
|
+
event: "eth_connected_on_open",
|
|
11378
|
+
walletId: connector?.id,
|
|
11379
|
+
chainId: chain?.id,
|
|
11380
|
+
address,
|
|
11381
|
+
});
|
|
11334
11382
|
}
|
|
11335
|
-
else if (
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
includeSolana) {
|
|
11340
|
-
if (context.route === ROUTES.SELECT_METHOD) {
|
|
11341
|
-
context.setRoute(ROUTES.SOLANA_SELECT_TOKEN, {
|
|
11342
|
-
event: "solana_connected_on_open",
|
|
11343
|
-
});
|
|
11344
|
-
}
|
|
11383
|
+
else if (solanaMethodAvailable && !ethMethodAvailable) {
|
|
11384
|
+
context.setRoute(ROUTES.SOLANA_SELECT_TOKEN, {
|
|
11385
|
+
event: "solana_connected_on_open",
|
|
11386
|
+
});
|
|
11345
11387
|
}
|
|
11346
|
-
//
|
|
11347
|
-
|
|
11388
|
+
// Don't include context.route in the dependency array otherwise the user
|
|
11389
|
+
// can't go back from the select token screen to the select method screen
|
|
11390
|
+
}, [
|
|
11391
|
+
context.open,
|
|
11392
|
+
context.wcWallet,
|
|
11393
|
+
isEthConnected,
|
|
11394
|
+
isSolanaConnected,
|
|
11395
|
+
showSolanaPaymentMethod,
|
|
11396
|
+
]);
|
|
11397
|
+
// If we're on the connect page and the user successfully connects their
|
|
11398
|
+
// wallet, go to the select token page
|
|
11348
11399
|
useEffect(() => {
|
|
11349
11400
|
if (context.route === ROUTES.CONNECT ||
|
|
11350
11401
|
context.route === ROUTES.CONNECTORS ||
|
|
@@ -11358,7 +11409,7 @@ const DaimoPayModal = ({ mode = "auto", theme = "auto", customTheme = customThem
|
|
|
11358
11409
|
});
|
|
11359
11410
|
}
|
|
11360
11411
|
}
|
|
11361
|
-
}, [isEthConnected, context.route]);
|
|
11412
|
+
}, [isEthConnected, context.route, connector?.id, chain?.id, address]);
|
|
11362
11413
|
useEffect(() => context.setMode(mode), [mode]);
|
|
11363
11414
|
useEffect(() => context.setTheme(theme), [theme]);
|
|
11364
11415
|
useEffect(() => context.setCustomTheme(customTheme), [customTheme]);
|
|
@@ -11530,6 +11581,10 @@ const DaimoPayProviderWithoutSolana = ({ children, theme = "auto", mode = "auto"
|
|
|
11530
11581
|
// set refresh context when payment status changes; done via setDaimoPayOrder.
|
|
11531
11582
|
const setDaimoPayOrder = useCallback((order) => {
|
|
11532
11583
|
setDaimoPayOrderInner(order);
|
|
11584
|
+
if (order == null) {
|
|
11585
|
+
log(`[PAY] setDaimoPayOrder: reset`);
|
|
11586
|
+
return;
|
|
11587
|
+
}
|
|
11533
11588
|
let extra = `> $${order.destFinalCallTokenAmount.usd.toFixed(2)} to ${order.destFinalCallTokenAmount.token.chainId} ${order.destFinalCall.to}`;
|
|
11534
11589
|
if (order.mode === DaimoPayOrderMode.HYDRATED) {
|
|
11535
11590
|
extra += ` via ${order.intentAddr} ${order.sourceStatus} ${order.intentStatus}`;
|
|
@@ -11931,21 +11986,23 @@ function DaimoPayButtonCustom(props) {
|
|
|
11931
11986
|
};
|
|
11932
11987
|
const hide = () => context.setOpen(false);
|
|
11933
11988
|
// Emit event handlers when payment status changes
|
|
11989
|
+
const sentStart = useRef(false);
|
|
11934
11990
|
useEffect(() => {
|
|
11935
11991
|
if (hydOrder == null)
|
|
11936
11992
|
return;
|
|
11937
11993
|
if (intentStatus === DaimoPayIntentStatus.UNPAID)
|
|
11938
11994
|
return;
|
|
11939
|
-
if (
|
|
11995
|
+
if (!sentStart.current && hydOrder.sourceTokenAmount) {
|
|
11996
|
+
sentStart.current = true;
|
|
11940
11997
|
onPaymentStarted?.({
|
|
11941
11998
|
type: DaimoPayIntentStatus.STARTED,
|
|
11942
11999
|
paymentId: writeDaimoPayOrderID(hydOrder.id),
|
|
11943
|
-
chainId: hydOrder.
|
|
11944
|
-
txHash:
|
|
12000
|
+
chainId: hydOrder.sourceTokenAmount?.token.chainId,
|
|
12001
|
+
txHash: hydOrder.sourceInitiateTxHash ?? null,
|
|
11945
12002
|
payment: getDaimoPayOrderView(hydOrder),
|
|
11946
12003
|
});
|
|
11947
12004
|
}
|
|
11948
|
-
|
|
12005
|
+
if (intentStatus === DaimoPayIntentStatus.COMPLETED ||
|
|
11949
12006
|
intentStatus === DaimoPayIntentStatus.BOUNCED) {
|
|
11950
12007
|
const event = {
|
|
11951
12008
|
type: intentStatus,
|
|
@@ -11961,7 +12018,7 @@ function DaimoPayButtonCustom(props) {
|
|
|
11961
12018
|
onPaymentBounced?.(event);
|
|
11962
12019
|
}
|
|
11963
12020
|
}
|
|
11964
|
-
}, [hydOrder?.id, intentStatus]);
|
|
12021
|
+
}, [hydOrder?.id, intentStatus, hydOrder?.sourceTokenAmount?.token.chainId]);
|
|
11965
12022
|
// Open the modal by default if the defaultOpen prop is true
|
|
11966
12023
|
useEffect(() => {
|
|
11967
12024
|
if (props.defaultOpen && order != null) {
|
|
@@ -12022,11 +12079,12 @@ function DaimoPayButtonInner({ disabled }) {
|
|
|
12022
12079
|
*/
|
|
12023
12080
|
function useDaimoPayStatus() {
|
|
12024
12081
|
const { paymentState } = usePayContext();
|
|
12082
|
+
const reset = paymentState.resetOrder;
|
|
12025
12083
|
if (!paymentState || !paymentState.daimoPayOrder)
|
|
12026
|
-
return
|
|
12084
|
+
return { reset };
|
|
12027
12085
|
const order = paymentState.daimoPayOrder;
|
|
12028
12086
|
const paymentId = writeDaimoPayOrderID(order.id);
|
|
12029
|
-
return { paymentId, status: order.intentStatus };
|
|
12087
|
+
return { paymentId, status: order.intentStatus, reset };
|
|
12030
12088
|
}
|
|
12031
12089
|
|
|
12032
12090
|
function addressToNumber(address) {
|