@mintmoney/react 0.2.0-alpha.2 → 0.2.0-alpha.3
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/css/styles.css +12 -1
- package/dist/esm/api/errors.js +89 -0
- package/dist/esm/api/errors.js.map +1 -0
- package/dist/esm/api/generated.js +825 -65
- package/dist/esm/api/generated.js.map +1 -1
- package/dist/esm/api/payments.js +26 -2
- package/dist/esm/api/payments.js.map +1 -1
- package/dist/esm/api/tokens.js +34 -0
- package/dist/esm/api/tokens.js.map +1 -0
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/checkout/claimable-funds.js +20 -10
- package/dist/esm/checkout/claimable-funds.js.map +1 -1
- package/dist/esm/checkout/creation-error-modal.js +2 -2
- package/dist/esm/checkout/creation-error-modal.js.map +1 -1
- package/dist/esm/checkout/index.js +48 -8
- package/dist/esm/checkout/index.js.map +1 -1
- package/dist/esm/checkout/modal.js +22 -14
- package/dist/esm/checkout/modal.js.map +1 -1
- package/dist/esm/checkout/payment-status.js +68 -28
- package/dist/esm/checkout/payment-status.js.map +1 -1
- package/dist/esm/checkout/provider-status.js +9 -0
- package/dist/esm/checkout/provider-status.js.map +1 -0
- package/dist/esm/checkout/providers/checkout-wallet.js +140 -44
- package/dist/esm/checkout/providers/checkout-wallet.js.map +1 -1
- package/dist/esm/checkout/providers/wagmi-config.js +6 -3
- package/dist/esm/checkout/providers/wagmi-config.js.map +1 -1
- package/dist/esm/checkout/refund-notice.js +16 -0
- package/dist/esm/checkout/refund-notice.js.map +1 -0
- package/dist/esm/checkout/resume-state.js +147 -0
- package/dist/esm/checkout/resume-state.js.map +1 -1
- package/dist/esm/checkout/surplus-refund.js +12 -0
- package/dist/esm/checkout/surplus-refund.js.map +1 -1
- package/dist/esm/checkout/views/amount-header.js +1 -1
- package/dist/esm/checkout/views/amount-header.js.map +1 -1
- package/dist/esm/checkout/views/claimable-funds.js +22 -13
- package/dist/esm/checkout/views/claimable-funds.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/direct-details.js +218 -890
- package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js +235 -0
- package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js +2 -26
- package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/manual-refresh.js +19 -0
- package/dist/esm/checkout/views/crypto-intent/manual-refresh.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js +151 -23
- package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js +295 -0
- package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-sources.js +155 -0
- package/dist/esm/checkout/views/crypto-intent/manual-sources.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js +84 -0
- package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/payment-route-error.js +10 -0
- package/dist/esm/checkout/views/crypto-intent/payment-route-error.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/processing.js +167 -24
- package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/success.js +74 -46
- package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js +14 -24
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js +61 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +105 -627
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js +506 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js +4 -11
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -1
- package/dist/esm/checkout/views/failed.js +62 -26
- package/dist/esm/checkout/views/failed.js.map +1 -1
- package/dist/esm/checkout/views/funding-timeline.js +255 -0
- package/dist/esm/checkout/views/funding-timeline.js.map +1 -0
- package/dist/esm/checkout/views/initial.js +25 -44
- package/dist/esm/checkout/views/initial.js.map +1 -1
- package/dist/esm/checkout/views/method-select.js +6 -4
- package/dist/esm/checkout/views/method-select.js.map +1 -1
- package/dist/esm/checkout/views/payment-follower.js +105 -0
- package/dist/esm/checkout/views/payment-follower.js.map +1 -0
- package/dist/esm/checkout/views/restart.js +8 -2
- package/dist/esm/checkout/views/restart.js.map +1 -1
- package/dist/esm/components/buttons/index.js +3 -2
- package/dist/esm/components/buttons/index.js.map +1 -1
- package/dist/esm/components/icons/search.js +5 -0
- package/dist/esm/components/icons/search.js.map +1 -0
- package/dist/esm/components/loading/index.js +2 -2
- package/dist/esm/components/loading/index.js.map +1 -1
- package/dist/esm/components/modals/modal-with-views.js +6 -12
- package/dist/esm/components/modals/modal-with-views.js.map +1 -1
- package/dist/esm/components/modals/modal.js +3 -3
- package/dist/esm/components/modals/modal.js.map +1 -1
- package/dist/esm/components/modals/transition-view.js +16 -0
- package/dist/esm/components/modals/transition-view.js.map +1 -0
- package/dist/esm/components/modals/use-modal-with-views.js +17 -19
- package/dist/esm/components/modals/use-modal-with-views.js.map +1 -1
- package/dist/esm/components/wallet-selector/wallets/wagmi/index.js +21 -2
- package/dist/esm/components/wallet-selector/wallets/wagmi/index.js.map +1 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/integrations/bitcoin-metamask.js +87 -0
- package/dist/esm/integrations/bitcoin-metamask.js.map +1 -0
- package/dist/esm/integrations/bitcoin-network.js +59 -0
- package/dist/esm/integrations/bitcoin-network.js.map +1 -0
- package/dist/esm/integrations/bitcoin-psbt.js +4 -0
- package/dist/esm/integrations/bitcoin-psbt.js.map +1 -0
- package/dist/esm/integrations/bitcoin-source.js +12 -0
- package/dist/esm/integrations/bitcoin-source.js.map +1 -0
- package/dist/esm/integrations/bitcoin-wallet.js +225 -0
- package/dist/esm/integrations/bitcoin-wallet.js.map +1 -0
- package/dist/esm/integrations/evm-chain.js +18 -0
- package/dist/esm/integrations/evm-chain.js.map +1 -1
- package/dist/esm/integrations/guarded-wallet-client.js +19 -0
- package/dist/esm/integrations/guarded-wallet-client.js.map +1 -0
- package/dist/esm/integrations/lifi.js +85 -38
- package/dist/esm/integrations/lifi.js.map +1 -1
- package/dist/esm/refund/index.js +216 -225
- package/dist/esm/refund/index.js.map +1 -1
- package/dist/esm/state/checkout/bitcoin-payment.js +253 -0
- package/dist/esm/state/checkout/bitcoin-payment.js.map +1 -0
- package/dist/esm/state/checkout/checkout-state.js +3 -9
- package/dist/esm/state/checkout/checkout-state.js.map +1 -1
- package/dist/esm/state/checkout/funding.js +5 -0
- package/dist/esm/state/checkout/funding.js.map +1 -0
- package/dist/esm/state/checkout/issuance-conflicts.js +29 -0
- package/dist/esm/state/checkout/issuance-conflicts.js.map +1 -0
- package/dist/esm/state/checkout/manual-route.js +10 -0
- package/dist/esm/state/checkout/manual-route.js.map +1 -0
- package/dist/esm/state/checkout/payment-attempt.js +44 -20
- package/dist/esm/state/checkout/payment-attempt.js.map +1 -1
- package/dist/esm/state/checkout/payment-lifecycle.js +9 -15
- package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -1
- package/dist/esm/state/checkout/payment-observer.js +147 -0
- package/dist/esm/state/checkout/payment-observer.js.map +1 -0
- package/dist/esm/state/checkout/payment-phase.js +131 -0
- package/dist/esm/state/checkout/payment-phase.js.map +1 -0
- package/dist/esm/state/checkout/quote-countdown.js +26 -0
- package/dist/esm/state/checkout/quote-countdown.js.map +1 -0
- package/dist/esm/state/checkout/quote-lifecycle.js +145 -144
- package/dist/esm/state/checkout/quote-lifecycle.js.map +1 -1
- package/dist/esm/state/checkout/route-estimate.js +77 -0
- package/dist/esm/state/checkout/route-estimate.js.map +1 -0
- package/dist/esm/state/checkout/store.js +222 -258
- package/dist/esm/state/checkout/store.js.map +1 -1
- package/dist/esm/state/checkout/wallet-payment.js +123 -32
- package/dist/esm/state/checkout/wallet-payment.js.map +1 -1
- package/dist/esm/utils/string.js +2 -0
- package/dist/esm/utils/string.js.map +1 -1
- package/dist/esm/utils/token-amount.js +88 -0
- package/dist/esm/utils/token-amount.js.map +1 -0
- package/dist/esm/utils/wallet-errors.js +21 -4
- package/dist/esm/utils/wallet-errors.js.map +1 -1
- package/dist/types/api/errors.d.ts +37 -0
- package/dist/types/api/errors.d.ts.map +1 -0
- package/dist/types/api/generated.d.ts +4562 -707
- package/dist/types/api/generated.d.ts.map +1 -1
- package/dist/types/api/payments.d.ts +28 -1
- package/dist/types/api/payments.d.ts.map +1 -1
- package/dist/types/api/tokens.d.ts +6 -0
- package/dist/types/api/tokens.d.ts.map +1 -0
- package/dist/types/api/types.d.ts +28 -2
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/checkout/claimable-funds.d.ts +15 -2
- package/dist/types/checkout/claimable-funds.d.ts.map +1 -1
- package/dist/types/checkout/creation-error-modal.d.ts +2 -1
- package/dist/types/checkout/creation-error-modal.d.ts.map +1 -1
- package/dist/types/checkout/index.d.ts +21 -1
- package/dist/types/checkout/index.d.ts.map +1 -1
- package/dist/types/checkout/modal.d.ts +4 -1
- package/dist/types/checkout/modal.d.ts.map +1 -1
- package/dist/types/checkout/payment-status.d.ts +10 -2
- package/dist/types/checkout/payment-status.d.ts.map +1 -1
- package/dist/types/checkout/provider-status.d.ts +11 -0
- package/dist/types/checkout/provider-status.d.ts.map +1 -0
- package/dist/types/checkout/providers/checkout-wallet.d.ts +2 -3
- package/dist/types/checkout/providers/checkout-wallet.d.ts.map +1 -1
- package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -1
- package/dist/types/checkout/refund-notice.d.ts +7 -0
- package/dist/types/checkout/refund-notice.d.ts.map +1 -0
- package/dist/types/checkout/resume-state.d.ts +41 -0
- package/dist/types/checkout/resume-state.d.ts.map +1 -1
- package/dist/types/checkout/surplus-refund.d.ts +8 -0
- package/dist/types/checkout/surplus-refund.d.ts.map +1 -1
- package/dist/types/checkout/views/amount-header.d.ts.map +1 -1
- package/dist/types/checkout/views/claimable-funds.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +3 -13
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts +10 -0
- package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts +4 -11
- package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts +4 -0
- package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts +14 -10
- package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts +18 -0
- package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts +33 -0
- package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts +18 -0
- package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts +2 -0
- package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/success.d.ts +2 -1
- package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts +8 -8
- package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts +17 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts +2 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts +61 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts +1 -2
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -1
- package/dist/types/checkout/views/failed.d.ts +6 -0
- package/dist/types/checkout/views/failed.d.ts.map +1 -1
- package/dist/types/checkout/views/funding-timeline.d.ts +49 -0
- package/dist/types/checkout/views/funding-timeline.d.ts.map +1 -0
- package/dist/types/checkout/views/initial.d.ts +2 -4
- package/dist/types/checkout/views/initial.d.ts.map +1 -1
- package/dist/types/checkout/views/method-select.d.ts +2 -1
- package/dist/types/checkout/views/method-select.d.ts.map +1 -1
- package/dist/types/checkout/views/payment-follower.d.ts +31 -0
- package/dist/types/checkout/views/payment-follower.d.ts.map +1 -0
- package/dist/types/checkout/views/restart.d.ts +1 -1
- package/dist/types/checkout/views/restart.d.ts.map +1 -1
- package/dist/types/components/buttons/index.d.ts.map +1 -1
- package/dist/types/components/icons/search.d.ts +2 -0
- package/dist/types/components/icons/search.d.ts.map +1 -0
- package/dist/types/components/loading/index.d.ts +6 -1
- package/dist/types/components/loading/index.d.ts.map +1 -1
- package/dist/types/components/modals/modal-with-views.d.ts +2 -0
- package/dist/types/components/modals/modal-with-views.d.ts.map +1 -1
- package/dist/types/components/modals/modal.d.ts +2 -1
- package/dist/types/components/modals/modal.d.ts.map +1 -1
- package/dist/types/components/modals/transition-view.d.ts +2 -0
- package/dist/types/components/modals/transition-view.d.ts.map +1 -0
- package/dist/types/components/modals/use-modal-with-views.d.ts +2 -1
- package/dist/types/components/modals/use-modal-with-views.d.ts.map +1 -1
- package/dist/types/components/wallet-selector/domain.d.ts +1 -1
- package/dist/types/components/wallet-selector/domain.d.ts.map +1 -1
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts +1 -1
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/integrations/bitcoin-metamask.d.ts +11 -0
- package/dist/types/integrations/bitcoin-metamask.d.ts.map +1 -0
- package/dist/types/integrations/bitcoin-network.d.ts +13 -0
- package/dist/types/integrations/bitcoin-network.d.ts.map +1 -0
- package/dist/types/integrations/bitcoin-psbt.d.ts +5 -0
- package/dist/types/integrations/bitcoin-psbt.d.ts.map +1 -0
- package/dist/types/integrations/bitcoin-source.d.ts +12 -0
- package/dist/types/integrations/bitcoin-source.d.ts.map +1 -0
- package/dist/types/integrations/bitcoin-wallet.d.ts +63 -0
- package/dist/types/integrations/bitcoin-wallet.d.ts.map +1 -0
- package/dist/types/integrations/evm-chain.d.ts +5 -0
- package/dist/types/integrations/evm-chain.d.ts.map +1 -1
- package/dist/types/integrations/guarded-wallet-client.d.ts +4 -0
- package/dist/types/integrations/guarded-wallet-client.d.ts.map +1 -0
- package/dist/types/integrations/lifi.d.ts +22 -0
- package/dist/types/integrations/lifi.d.ts.map +1 -1
- package/dist/types/refund/index.d.ts +1 -1
- package/dist/types/refund/index.d.ts.map +1 -1
- package/dist/types/state/checkout/bitcoin-payment.d.ts +28 -0
- package/dist/types/state/checkout/bitcoin-payment.d.ts.map +1 -0
- package/dist/types/state/checkout/checkout-state.d.ts +42 -10
- package/dist/types/state/checkout/checkout-state.d.ts.map +1 -1
- package/dist/types/state/checkout/funding.d.ts +6 -0
- package/dist/types/state/checkout/funding.d.ts.map +1 -0
- package/dist/types/state/checkout/issuance-conflicts.d.ts +22 -0
- package/dist/types/state/checkout/issuance-conflicts.d.ts.map +1 -0
- package/dist/types/state/checkout/manual-route.d.ts +13 -0
- package/dist/types/state/checkout/manual-route.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-attempt.d.ts +19 -1
- package/dist/types/state/checkout/payment-attempt.d.ts.map +1 -1
- package/dist/types/state/checkout/payment-lifecycle.d.ts +6 -8
- package/dist/types/state/checkout/payment-lifecycle.d.ts.map +1 -1
- package/dist/types/state/checkout/payment-observer.d.ts +41 -0
- package/dist/types/state/checkout/payment-observer.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-phase.d.ts +116 -0
- package/dist/types/state/checkout/payment-phase.d.ts.map +1 -0
- package/dist/types/state/checkout/quote-countdown.d.ts +15 -0
- package/dist/types/state/checkout/quote-countdown.d.ts.map +1 -0
- package/dist/types/state/checkout/quote-lifecycle.d.ts +17 -6
- package/dist/types/state/checkout/quote-lifecycle.d.ts.map +1 -1
- package/dist/types/state/checkout/route-estimate.d.ts +38 -0
- package/dist/types/state/checkout/route-estimate.d.ts.map +1 -0
- package/dist/types/state/checkout/store.d.ts +25 -10
- package/dist/types/state/checkout/store.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-payment.d.ts +13 -2
- package/dist/types/state/checkout/wallet-payment.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +2 -0
- package/dist/types/utils/string.d.ts.map +1 -1
- package/dist/types/utils/token-amount.d.ts +18 -0
- package/dist/types/utils/token-amount.d.ts.map +1 -0
- package/dist/types/utils/wallet-errors.d.ts.map +1 -1
- package/package.json +3 -1
- package/dist/esm/refund/confirmation.js +0 -30
- package/dist/esm/refund/confirmation.js.map +0 -1
- package/dist/types/refund/confirmation.d.ts +0 -14
- package/dist/types/refund/confirmation.d.ts.map +0 -1
|
@@ -1,348 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
|
|
4
|
-
import { QRCode } from "react-qr-code";
|
|
5
|
-
import { keyframes, styled } from "styled-components";
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { styled } from "styled-components";
|
|
6
4
|
import { useAccount } from "wagmi";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { describeRevealFailure } from "../../../api/errors.js";
|
|
6
|
+
import { confirmPayment } from "../../../api/payments.js";
|
|
7
|
+
import { AlertCircleIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
|
|
8
|
+
import { transitionView } from "../../../components/modals/transition-view.js";
|
|
9
9
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { BITCOIN, BITCOIN_CHAIN, } from "../../../integrations/bitcoin-source.js";
|
|
11
|
+
import { hasReceivedFunds } from "../../../state/checkout/funding.js";
|
|
12
|
+
import { hasClosedPaymentMovedOn } from "../../../state/checkout/issuance-conflicts.js";
|
|
13
|
+
import { getManualPaymentAttemptMode, } from "../../../state/checkout/manual-route.js";
|
|
14
|
+
import { acceptsFunds, derivePaymentPhase, pendingShortfall, } from "../../../state/checkout/payment-phase.js";
|
|
15
|
+
import { QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO, useQuoteCountdown, } from "../../../state/checkout/quote-countdown.js";
|
|
16
|
+
import { clearQuoteRefresh, captureCheckoutOpening, configureManualQuoteRefresh, createManualDirectPaymentAttempt, getFrozenRefundRecipient, isCheckoutIssued, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
|
|
17
|
+
import { formatChainLabel, formatTokenLabel, } from "../../../utils/token-amount.js";
|
|
12
18
|
import { ModalViewContainer } from "../../container.js";
|
|
19
|
+
import { manualTransferFor, writeCheckoutResumeState, } from "../../resume-state.js";
|
|
13
20
|
import { ModalBackButton } from "../back.js";
|
|
21
|
+
import { FundingProgress } from "../funding-timeline.js";
|
|
22
|
+
import { ManualInstructionCard } from "./manual-instruction-card.js";
|
|
14
23
|
import { ManualPaymentSummary } from "./manual-payment-summary.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
padding: 10px;
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
margin: 8px 0 0;
|
|
27
|
-
`;
|
|
28
|
-
const PaymentInstructionCard = styled.div `
|
|
29
|
-
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
30
|
-
border: 1px solid #e2e8f0;
|
|
31
|
-
border-radius: 16px;
|
|
32
|
-
padding: 16px;
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-direction: column;
|
|
35
|
-
gap: 14px;
|
|
36
|
-
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
|
|
37
|
-
`;
|
|
38
|
-
const PaymentInstructionHeader = styled.div `
|
|
39
|
-
display: flex;
|
|
40
|
-
align-items: center;
|
|
41
|
-
justify-content: space-between;
|
|
42
|
-
gap: 8px;
|
|
43
|
-
`;
|
|
44
|
-
const PaymentInstructionLabel = styled.div `
|
|
45
|
-
font-size: 13px;
|
|
46
|
-
line-height: 1.3;
|
|
47
|
-
font-weight: 600;
|
|
48
|
-
color: ${({ theme }) => theme.font.color.tertiary};
|
|
49
|
-
`;
|
|
50
|
-
const PaymentInstructionValue = styled.div `
|
|
51
|
-
font-size: 16px;
|
|
52
|
-
line-height: 1.45;
|
|
53
|
-
font-weight: 700;
|
|
54
|
-
color: ${({ theme }) => theme.font.color.primary};
|
|
55
|
-
min-width: 0;
|
|
56
|
-
overflow-wrap: anywhere;
|
|
57
|
-
`;
|
|
58
|
-
const PaymentInstructionDivider = styled.div `
|
|
59
|
-
height: 1px;
|
|
60
|
-
background: #eef2f6;
|
|
61
|
-
`;
|
|
62
|
-
const InfoRow = styled.div `
|
|
63
|
-
display: flex;
|
|
64
|
-
align-items: center;
|
|
65
|
-
background: transparent;
|
|
66
|
-
border-radius: 8px;
|
|
67
|
-
padding: 0;
|
|
68
|
-
margin: 0;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
transition: all 0.2s ease-in-out;
|
|
71
|
-
border: 0;
|
|
72
|
-
|
|
73
|
-
&:hover {
|
|
74
|
-
opacity: 0.78;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
${({ isCopied }) => isCopied &&
|
|
78
|
-
`
|
|
79
|
-
animation: copySuccess 0.6s ease-in-out;
|
|
80
|
-
`}
|
|
81
|
-
|
|
82
|
-
@keyframes copySuccess {
|
|
83
|
-
0% {
|
|
84
|
-
border-color: transparent;
|
|
85
|
-
}
|
|
86
|
-
50% {
|
|
87
|
-
border-color: #10b981;
|
|
88
|
-
}
|
|
89
|
-
100% {
|
|
90
|
-
border-color: #10b981;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
const AddressInfoRow = styled(InfoRow) `
|
|
95
|
-
align-items: flex-start;
|
|
96
|
-
width: 100%;
|
|
97
|
-
margin-top: 4px;
|
|
98
|
-
`;
|
|
99
|
-
const AddressText = styled.div `
|
|
100
|
-
font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
|
|
101
|
-
font-size: 14px;
|
|
102
|
-
line-height: 1.55;
|
|
103
|
-
font-weight: 600;
|
|
104
|
-
color: ${({ theme }) => theme.font.color.primary};
|
|
105
|
-
width: 100%;
|
|
106
|
-
flex: 1 1 auto;
|
|
107
|
-
min-width: 0;
|
|
108
|
-
overflow-wrap: anywhere;
|
|
109
|
-
`;
|
|
110
|
-
const AmountInfoRow = styled(InfoRow) `
|
|
111
|
-
align-items: center;
|
|
112
|
-
gap: 8px;
|
|
113
|
-
width: fit-content;
|
|
114
|
-
max-width: 100%;
|
|
115
|
-
margin-top: 4px;
|
|
116
|
-
`;
|
|
117
|
-
const CopyButton = styled.button `
|
|
118
|
-
display: flex;
|
|
119
|
-
align-items: center;
|
|
120
|
-
justify-content: center;
|
|
121
|
-
width: 28px;
|
|
122
|
-
height: 28px;
|
|
123
|
-
flex: 0 0 28px;
|
|
124
|
-
background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
|
|
125
|
-
color: ${({ isCopied }) => (isCopied ? "#047857" : "#374151")};
|
|
126
|
-
border: none;
|
|
127
|
-
cursor: pointer;
|
|
128
|
-
padding: 0;
|
|
129
|
-
border-radius: 999px;
|
|
130
|
-
transition:
|
|
131
|
-
background 0.15s ease,
|
|
132
|
-
color 0.15s ease,
|
|
133
|
-
transform 0.15s ease;
|
|
134
|
-
|
|
135
|
-
&:hover {
|
|
136
|
-
background: ${({ isCopied }) => (isCopied ? "#dcfce7" : "#e8edf7")};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
${({ isCopied }) => isCopied &&
|
|
140
|
-
`
|
|
141
|
-
animation: iconBounce 0.6s ease-in-out;
|
|
142
|
-
`}
|
|
143
|
-
|
|
144
|
-
@keyframes iconBounce {
|
|
145
|
-
0% {
|
|
146
|
-
transform: scale(1);
|
|
147
|
-
}
|
|
148
|
-
25% {
|
|
149
|
-
transform: scale(1.2);
|
|
150
|
-
}
|
|
151
|
-
50% {
|
|
152
|
-
transform: scale(0.9);
|
|
153
|
-
}
|
|
154
|
-
75% {
|
|
155
|
-
transform: scale(1.1);
|
|
156
|
-
}
|
|
157
|
-
100% {
|
|
158
|
-
transform: scale(1);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
`;
|
|
162
|
-
const IconButton = styled.button `
|
|
163
|
-
width: 28px;
|
|
164
|
-
height: 28px;
|
|
165
|
-
border: 0;
|
|
166
|
-
border-radius: 8px;
|
|
167
|
-
background: ${({ $active }) => ($active ? "#e0f2fe" : "transparent")};
|
|
168
|
-
color: ${({ $active }) => ($active ? "#0369a1" : "#374151")};
|
|
169
|
-
display: inline-flex;
|
|
170
|
-
align-items: center;
|
|
171
|
-
justify-content: center;
|
|
172
|
-
padding: 0;
|
|
173
|
-
cursor: pointer;
|
|
174
|
-
transition:
|
|
175
|
-
background 0.15s ease,
|
|
176
|
-
color 0.15s ease;
|
|
177
|
-
|
|
178
|
-
&:hover,
|
|
179
|
-
&:focus-visible {
|
|
180
|
-
background: #eef2f7;
|
|
181
|
-
outline: none;
|
|
182
|
-
}
|
|
183
|
-
`;
|
|
184
|
-
const CopyAddressCta = styled.button `
|
|
185
|
-
width: 100%;
|
|
186
|
-
min-height: 44px;
|
|
187
|
-
border: 0;
|
|
188
|
-
border-radius: 8px;
|
|
189
|
-
background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
|
|
190
|
-
color: ${({ isCopied }) => (isCopied ? "#047857" : "#111827")};
|
|
191
|
-
display: inline-flex;
|
|
192
|
-
align-items: center;
|
|
193
|
-
justify-content: center;
|
|
194
|
-
gap: 8px;
|
|
195
|
-
padding: 0 14px;
|
|
196
|
-
font-size: 15px;
|
|
197
|
-
line-height: 1.2;
|
|
198
|
-
font-weight: 700;
|
|
199
|
-
cursor: pointer;
|
|
200
|
-
transition:
|
|
201
|
-
background 0.15s ease,
|
|
202
|
-
color 0.15s ease,
|
|
203
|
-
transform 0.15s ease;
|
|
204
|
-
|
|
205
|
-
&:hover,
|
|
206
|
-
&:focus-visible {
|
|
207
|
-
background: ${({ isCopied }) => (isCopied ? "#dcfce7" : "#e8edf7")};
|
|
208
|
-
outline: none;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
&:active {
|
|
212
|
-
transform: translateY(1px);
|
|
213
|
-
}
|
|
214
|
-
`;
|
|
215
|
-
const OptionList = styled.div `
|
|
216
|
-
display: flex;
|
|
217
|
-
flex-direction: column;
|
|
218
|
-
gap: 8px;
|
|
219
|
-
min-height: 0;
|
|
220
|
-
max-height: min(34vh, 300px);
|
|
221
|
-
overflow-y: auto;
|
|
222
|
-
overscroll-behavior: contain;
|
|
223
|
-
scrollbar-width: none;
|
|
224
|
-
|
|
225
|
-
&::-webkit-scrollbar {
|
|
226
|
-
display: none;
|
|
227
|
-
}
|
|
228
|
-
`;
|
|
229
|
-
const SelectionSectionLabel = styled.div `
|
|
230
|
-
font-size: 12px;
|
|
231
|
-
font-weight: 600;
|
|
232
|
-
line-height: 1.3;
|
|
233
|
-
color: #94a3b8;
|
|
234
|
-
padding: 0 2px;
|
|
235
|
-
`;
|
|
236
|
-
const SelectionRow = styled.button `
|
|
237
|
-
width: 100%;
|
|
238
|
-
min-height: 72px;
|
|
239
|
-
border: 1px solid #eef2f6;
|
|
240
|
-
border-radius: 16px;
|
|
241
|
-
background: #ffffff;
|
|
242
|
-
display: flex;
|
|
243
|
-
align-items: center;
|
|
244
|
-
justify-content: space-between;
|
|
245
|
-
gap: 12px;
|
|
246
|
-
padding: 12px 14px;
|
|
247
|
-
cursor: pointer;
|
|
248
|
-
text-align: left;
|
|
249
|
-
color: inherit;
|
|
250
|
-
transition:
|
|
251
|
-
border-color 140ms ease,
|
|
252
|
-
box-shadow 140ms ease,
|
|
253
|
-
transform 140ms ease,
|
|
254
|
-
background-color 140ms ease;
|
|
255
|
-
|
|
256
|
-
&:hover,
|
|
257
|
-
&:focus-visible {
|
|
258
|
-
border-color: #cdd9e3;
|
|
259
|
-
box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
|
|
260
|
-
transform: translateY(-1px);
|
|
261
|
-
outline: none;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
&:disabled {
|
|
265
|
-
cursor: not-allowed;
|
|
266
|
-
opacity: 0.65;
|
|
267
|
-
}
|
|
268
|
-
`;
|
|
269
|
-
const SelectionRowLeft = styled.div `
|
|
270
|
-
display: flex;
|
|
271
|
-
align-items: center;
|
|
272
|
-
gap: 12px;
|
|
273
|
-
min-width: 0;
|
|
274
|
-
`;
|
|
275
|
-
const SelectionIcon = styled.div `
|
|
276
|
-
position: relative;
|
|
277
|
-
width: 40px;
|
|
278
|
-
height: 40px;
|
|
279
|
-
border-radius: 999px;
|
|
280
|
-
flex-shrink: 0;
|
|
281
|
-
display: inline-flex;
|
|
282
|
-
align-items: center;
|
|
283
|
-
justify-content: center;
|
|
284
|
-
font-size: 11px;
|
|
285
|
-
font-weight: 700;
|
|
286
|
-
color: #1f2937;
|
|
287
|
-
background: #eef2f7;
|
|
288
|
-
overflow: hidden;
|
|
289
|
-
`;
|
|
290
|
-
const SelectionIconFallback = styled.span `
|
|
291
|
-
position: relative;
|
|
292
|
-
z-index: 0;
|
|
293
|
-
`;
|
|
294
|
-
const SelectionIconImage = styled.img `
|
|
295
|
-
position: absolute;
|
|
296
|
-
inset: 6px;
|
|
297
|
-
z-index: 1;
|
|
298
|
-
width: calc(100% - 12px);
|
|
299
|
-
height: calc(100% - 12px);
|
|
300
|
-
object-fit: contain;
|
|
301
|
-
`;
|
|
302
|
-
const SelectionText = styled.div `
|
|
303
|
-
display: flex;
|
|
304
|
-
flex-direction: column;
|
|
305
|
-
gap: 2px;
|
|
306
|
-
min-width: 0;
|
|
307
|
-
`;
|
|
308
|
-
const SelectionTitle = styled.span `
|
|
309
|
-
font-size: 14px;
|
|
310
|
-
line-height: 1.3;
|
|
311
|
-
font-weight: 600;
|
|
312
|
-
color: #111827;
|
|
313
|
-
overflow: hidden;
|
|
314
|
-
text-overflow: ellipsis;
|
|
315
|
-
white-space: nowrap;
|
|
316
|
-
`;
|
|
317
|
-
const SelectionSubtitle = styled.span `
|
|
318
|
-
font-size: 12px;
|
|
319
|
-
line-height: 1.3;
|
|
320
|
-
color: #6b7280;
|
|
321
|
-
overflow: hidden;
|
|
322
|
-
text-overflow: ellipsis;
|
|
323
|
-
white-space: nowrap;
|
|
324
|
-
`;
|
|
325
|
-
const SelectionMeta = styled.span `
|
|
326
|
-
font-size: 12px;
|
|
327
|
-
line-height: 1.3;
|
|
328
|
-
color: #7c83a5;
|
|
329
|
-
white-space: nowrap;
|
|
330
|
-
flex-shrink: 0;
|
|
331
|
-
`;
|
|
332
|
-
const SelectionBadge = styled.span `
|
|
333
|
-
display: inline-flex;
|
|
334
|
-
align-items: center;
|
|
335
|
-
border-radius: 999px;
|
|
336
|
-
gap: 4px;
|
|
337
|
-
background: #ecfdf5;
|
|
338
|
-
color: #047857;
|
|
339
|
-
font-size: 11px;
|
|
340
|
-
font-weight: 600;
|
|
341
|
-
line-height: 1;
|
|
342
|
-
padding: 4px 8px;
|
|
343
|
-
white-space: nowrap;
|
|
344
|
-
flex-shrink: 0;
|
|
345
|
-
`;
|
|
24
|
+
import { ManualPaymentRefresh } from "./manual-refresh.js";
|
|
25
|
+
import { ManualRefundPreference } from "./manual-refund-preference.js";
|
|
26
|
+
import { ManualRoutePicker } from "./manual-route-picker.js";
|
|
27
|
+
import { getChainAbbreviation, getManualChainIconUrl, getManualInstructionSource, getMonogram, getSourceTokenSymbol, isEvmAddress, manualPaymentOptionToCurrency, uniqueSourceOptions, useManualPaymentOptions, } from "./manual-sources.js";
|
|
28
|
+
import { getManualTransferInstructions, manualInstructionsMatchFunding, } from "./manual-transfer-instructions.js";
|
|
29
|
+
import { PaymentRouteError } from "./payment-route-error.js";
|
|
346
30
|
const TokenIconWrap = styled.div `
|
|
347
31
|
position: relative;
|
|
348
32
|
width: 42px;
|
|
@@ -436,209 +120,25 @@ const ErrorCard = styled.div `
|
|
|
436
120
|
align-items: center;
|
|
437
121
|
gap: 8px;
|
|
438
122
|
`;
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
444
|
-
border: 1px solid #e8eef3;
|
|
445
|
-
border-radius: 14px;
|
|
446
|
-
padding: 18px;
|
|
447
|
-
margin: 8px 0;
|
|
448
|
-
display: flex;
|
|
449
|
-
align-items: center;
|
|
450
|
-
gap: 12px;
|
|
451
|
-
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
|
|
452
|
-
`;
|
|
453
|
-
const RefreshSpinner = styled.div `
|
|
454
|
-
width: 30px;
|
|
455
|
-
height: 30px;
|
|
456
|
-
border-radius: 999px;
|
|
457
|
-
border: 3px solid #d1fae5;
|
|
458
|
-
border-top-color: #10b981;
|
|
459
|
-
flex-shrink: 0;
|
|
460
|
-
animation: ${spin} 0.8s linear infinite;
|
|
461
|
-
`;
|
|
462
|
-
const RefreshTitle = styled.div `
|
|
463
|
-
display: flex;
|
|
464
|
-
flex-direction: column;
|
|
465
|
-
gap: 2px;
|
|
466
|
-
min-width: 0;
|
|
467
|
-
`;
|
|
468
|
-
const isEvmAddress = (value) => /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
469
|
-
const isValidRefundAddressForSource = (value, _source) => isEvmAddress(value);
|
|
470
|
-
const shouldResetManualRefundWalletForSource = (value, source) => {
|
|
471
|
-
const trimmedValue = value.trim();
|
|
472
|
-
return (trimmedValue.length > 0 &&
|
|
473
|
-
!isValidRefundAddressForSource(trimmedValue, source));
|
|
474
|
-
};
|
|
475
|
-
const getManualAttemptErrorMessage = (error) => {
|
|
476
|
-
const responseError = typeof error === "object" && error !== null && "error" in error
|
|
477
|
-
? error.error
|
|
478
|
-
: null;
|
|
479
|
-
const apiError = typeof responseError === "object" &&
|
|
480
|
-
responseError !== null &&
|
|
481
|
-
"error" in responseError
|
|
482
|
-
? responseError.error
|
|
483
|
-
: null;
|
|
484
|
-
const apiMessage = typeof apiError === "string" ? apiError : "";
|
|
485
|
-
const message = error instanceof Error
|
|
486
|
-
? error.message
|
|
487
|
-
: apiMessage || (typeof error === "string" ? error : "");
|
|
488
|
-
return message || "We couldn't generate payment details. Please try again.";
|
|
489
|
-
};
|
|
490
|
-
const QrCodeIcon = ({ size = 16 }) => (_jsxs("svg", { "aria-hidden": "true", width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M4 4h6v6H4V4ZM14 4h6v6h-6V4ZM4 14h6v6H4v-6Z", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round" }), _jsx("path", { d: "M15 14h2v2h-2v-2ZM19 14h1v3h-3v-1h2v-2ZM14 18h3v2h-3v-2ZM19 19h1v1h-1v-1Z", fill: "currentColor" })] }));
|
|
491
|
-
const getMonogram = (value) => {
|
|
492
|
-
const parts = value
|
|
493
|
-
.split(/\s+/)
|
|
494
|
-
.map((part) => part.trim())
|
|
495
|
-
.filter(Boolean);
|
|
496
|
-
if (parts.length === 0) {
|
|
497
|
-
return "?";
|
|
498
|
-
}
|
|
499
|
-
if (parts.length === 1) {
|
|
500
|
-
return parts[0].slice(0, 2).toUpperCase();
|
|
501
|
-
}
|
|
502
|
-
return `${parts[0][0]}${parts[1][0]}`.toUpperCase();
|
|
503
|
-
};
|
|
504
|
-
const getChainAbbreviation = (chainName) => {
|
|
505
|
-
const normalized = chainName.toLowerCase();
|
|
506
|
-
if (normalized === "base")
|
|
507
|
-
return "B";
|
|
508
|
-
if (normalized === "ethereum")
|
|
509
|
-
return "ETH";
|
|
510
|
-
return getMonogram(chainName);
|
|
511
|
-
};
|
|
512
|
-
const getManualChainIconUrl = (source) => {
|
|
513
|
-
const normalizedChain = source.chain.toLowerCase();
|
|
514
|
-
const normalizedChainName = source.chain_name.toLowerCase();
|
|
515
|
-
if (normalizedChain === "eip155:1" || normalizedChainName === "ethereum") {
|
|
516
|
-
return ETHEREUM_ICON_URL;
|
|
517
|
-
}
|
|
518
|
-
return source.chain_logo_url ?? null;
|
|
519
|
-
};
|
|
520
|
-
const SelectionIconView = ({ iconUrl, fallback, }) => {
|
|
521
|
-
const [failedIconUrl, setFailedIconUrl] = useState(null);
|
|
522
|
-
const resolvedIconUrl = iconUrl && iconUrl !== failedIconUrl ? iconUrl : null;
|
|
523
|
-
useEffect(() => {
|
|
524
|
-
setFailedIconUrl(null);
|
|
525
|
-
}, [iconUrl]);
|
|
526
|
-
return (_jsx(SelectionIcon, { children: resolvedIconUrl ? (_jsx(SelectionIconImage, { src: resolvedIconUrl, alt: "", "aria-hidden": "true", onError: () => setFailedIconUrl(resolvedIconUrl) })) : (_jsx(SelectionIconFallback, { children: fallback })) }));
|
|
527
|
-
};
|
|
528
|
-
const formatManualPaymentAmount = (amount, currency) => {
|
|
529
|
-
const amountText = String(amount);
|
|
530
|
-
return `${amountText} ${currency}`;
|
|
531
|
-
};
|
|
532
|
-
const shouldUseRawManualAmount = (chainName, currency) => {
|
|
533
|
-
const normalizedChain = chainName.toLowerCase();
|
|
534
|
-
const normalizedCurrency = currency.toLowerCase();
|
|
535
|
-
return (normalizedChain.includes("sepolia") ||
|
|
536
|
-
normalizedChain.includes("testnet") ||
|
|
537
|
-
normalizedCurrency.includes("mock"));
|
|
538
|
-
};
|
|
539
|
-
const isTestnetOrMockCurrency = (currency) => shouldUseRawManualAmount(currency.chain_name, currency.asset_name) ||
|
|
540
|
-
shouldUseRawManualAmount(currency.chain, currency.asset);
|
|
541
|
-
const shouldLoadManualPaymentOptions = (currency) => !isTestnetOrMockCurrency(currency);
|
|
542
|
-
const sourceKey = (source) => `${source.chain}__${source.asset}`;
|
|
543
|
-
const normalizeOptionalAddress = (address) => address?.trim().toLowerCase() || null;
|
|
544
|
-
const uniqueSourceOptions = (settlementCurrency, configuredSources) => {
|
|
545
|
-
const options = [settlementCurrency, ...(configuredSources ?? [])];
|
|
546
|
-
const seen = new Set();
|
|
547
|
-
return options.filter((option) => {
|
|
548
|
-
const key = sourceKey(option);
|
|
549
|
-
if (seen.has(key))
|
|
550
|
-
return false;
|
|
551
|
-
seen.add(key);
|
|
552
|
-
return true;
|
|
553
|
-
});
|
|
554
|
-
};
|
|
555
|
-
const getManualPaymentAttemptMode = (source, settlementCurrency) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
556
|
-
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase()
|
|
557
|
-
? undefined
|
|
558
|
-
: "relay_deposit";
|
|
559
|
-
const manualPaymentOptionToCurrency = (option) => ({
|
|
560
|
-
chain: option.from_chain.caip2,
|
|
561
|
-
asset: option.from_token.caip21,
|
|
562
|
-
chain_name: option.from_chain.name,
|
|
563
|
-
asset_name: option.from_token.name,
|
|
564
|
-
asset_id: option.id,
|
|
565
|
-
logo_url: option.from_token.logo_url,
|
|
566
|
-
chain_logo_url: option.from_chain.logo_url,
|
|
567
|
-
});
|
|
568
|
-
const manualPaymentOptionKey = (option) => `${option.from_chain.caip2}__${option.from_token.caip21}`;
|
|
569
|
-
const manualOptionLookupKey = (source) => `${source.chain}__${source.asset}`.toLowerCase();
|
|
570
|
-
const getSourceTokenSymbol = (source, manualOptions) => manualOptions.find((option) => manualPaymentOptionKey(option).toLowerCase() ===
|
|
571
|
-
manualOptionLookupKey(source))?.from_token.symbol ?? source.asset_name;
|
|
572
|
-
const getSourceTokenGroupKey = (source, manualOptions) => getSourceTokenSymbol(source, manualOptions).toLowerCase();
|
|
573
|
-
const uniqueSourceTokens = (options, manualOptions) => {
|
|
574
|
-
const seen = new Set();
|
|
575
|
-
return options.filter((option) => {
|
|
576
|
-
const key = getSourceTokenGroupKey(option, manualOptions);
|
|
577
|
-
if (seen.has(key))
|
|
578
|
-
return false;
|
|
579
|
-
seen.add(key);
|
|
580
|
-
return true;
|
|
581
|
-
});
|
|
582
|
-
};
|
|
583
|
-
const uniqueSourceChains = (options) => {
|
|
584
|
-
const seen = new Set();
|
|
585
|
-
return options.filter((option) => {
|
|
586
|
-
if (seen.has(option.chain))
|
|
587
|
-
return false;
|
|
588
|
-
seen.add(option.chain);
|
|
589
|
-
return true;
|
|
590
|
-
});
|
|
591
|
-
};
|
|
592
|
-
const getManualInstructionSource = (instructions) => {
|
|
593
|
-
if (!instructions)
|
|
594
|
-
return null;
|
|
595
|
-
if ("source_chain" in instructions &&
|
|
596
|
-
"source_token" in instructions &&
|
|
597
|
-
typeof instructions.source_chain === "string" &&
|
|
598
|
-
typeof instructions.source_token === "string") {
|
|
599
|
-
return {
|
|
600
|
-
chain: instructions.source_chain,
|
|
601
|
-
token: instructions.source_token,
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
const tokenTransferInstructions = instructions;
|
|
605
|
-
if (typeof tokenTransferInstructions.chain === "string" &&
|
|
606
|
-
typeof tokenTransferInstructions.token === "string") {
|
|
607
|
-
return {
|
|
608
|
-
chain: tokenTransferInstructions.chain,
|
|
609
|
-
token: tokenTransferInstructions.token,
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
return null;
|
|
613
|
-
};
|
|
614
|
-
const manualAttemptKey = (attempt) => {
|
|
615
|
-
const instructions = attempt?.payment_instructions;
|
|
616
|
-
if (!instructions)
|
|
617
|
-
return null;
|
|
618
|
-
const instructionSource = getManualInstructionSource(instructions);
|
|
619
|
-
const requestId = "request_id" in instructions ? instructions.request_id : null;
|
|
620
|
-
return [
|
|
621
|
-
requestId,
|
|
622
|
-
instructionSource?.chain,
|
|
623
|
-
instructionSource?.token,
|
|
624
|
-
instructions.payment_address ?? attempt.destination_address,
|
|
625
|
-
]
|
|
626
|
-
.filter(Boolean)
|
|
627
|
-
.join(":");
|
|
628
|
-
};
|
|
629
|
-
const CryptoIntentDirectDetailsViewContent = () => {
|
|
630
|
-
const modalRef = useRef(null);
|
|
631
|
-
const dismissedAttemptKeyRef = useRef(null);
|
|
632
|
-
const hasAutoPrefilledRefundWalletRef = useRef(false);
|
|
633
|
-
const { goToView } = useModalWithView();
|
|
123
|
+
const MANUAL_ATTEMPT_FAILED_MESSAGE = "We couldn't generate payment details. Please try again.";
|
|
124
|
+
const CryptoIntentDirectDetailsViewContent = ({ onPaymentSelectionChange, hostedRecovery, }) => {
|
|
125
|
+
const isIssuingRef = useRef(false);
|
|
126
|
+
const { goToView, viewProps } = useModalWithView();
|
|
634
127
|
const connectedAccount = useAccount();
|
|
635
|
-
const
|
|
128
|
+
const checkoutState = useCheckoutStore();
|
|
129
|
+
const { cryptoPaymentAttempt, cryptoCurrency, payment, quote } = checkoutState;
|
|
130
|
+
const phase = derivePaymentPhase(payment);
|
|
131
|
+
const shortfall = pendingShortfall(phase);
|
|
132
|
+
const instructions = cryptoPaymentAttempt?.payment_instructions;
|
|
133
|
+
// Once issued, the refund recipient is fixed and never sent again (QCT D1).
|
|
134
|
+
const isIssued = isCheckoutIssued(checkoutState);
|
|
135
|
+
const frozenRefundTo = getFrozenRefundRecipient(checkoutState);
|
|
636
136
|
const config = useMintMoneyConfig();
|
|
637
137
|
const fallbackSourceOptions = useMemo(() => cryptoCurrency
|
|
638
138
|
? uniqueSourceOptions(cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources)
|
|
639
139
|
: [], [cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources]);
|
|
640
|
-
const
|
|
641
|
-
const
|
|
140
|
+
const { manualPaymentOptions, manualPaymentOptionsStatus } = useManualPaymentOptions(payment?.id, cryptoCurrency);
|
|
141
|
+
const loadingSources = manualPaymentOptionsStatus === "loading";
|
|
642
142
|
const manualOptionSources = useMemo(() => manualPaymentOptions.map(manualPaymentOptionToCurrency), [manualPaymentOptions]);
|
|
643
143
|
const sourceOptions = useMemo(() => {
|
|
644
144
|
if (cryptoCurrency &&
|
|
@@ -653,173 +153,111 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
653
153
|
manualOptionSources,
|
|
654
154
|
manualPaymentOptionsStatus,
|
|
655
155
|
]);
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
const [
|
|
156
|
+
// The processing view returns a payer who confirmed sending too early to the
|
|
157
|
+
// instructions already issued, without choosing a route again.
|
|
158
|
+
const [showInstructions, setShowInstructions] = useState(() => viewProps.showIssuedInstructions === true &&
|
|
159
|
+
Boolean(cryptoPaymentAttempt?.payment_instructions));
|
|
659
160
|
const [paymentDetailsExpanded, setPaymentDetailsExpanded] = useState(false);
|
|
660
|
-
const [
|
|
661
|
-
const [refundWallet, setRefundWallet] = useState("");
|
|
662
|
-
const [selectedSourceKey, setSelectedSourceKey] = useState(sourceOptions[0] ? sourceKey(sourceOptions[0]) : "");
|
|
663
|
-
const [selectedTokenKey, setSelectedTokenKey] = useState("");
|
|
664
|
-
const [manualSetupStep, setManualSetupStep] = useState("token");
|
|
665
|
-
const [showQrCode, setShowQrCode] = useState(false);
|
|
161
|
+
const [refundWallet, setRefundWallet] = useState(null);
|
|
666
162
|
const [refundWalletError, setRefundWalletError] = useState(null);
|
|
667
|
-
const [
|
|
668
|
-
const [
|
|
669
|
-
const
|
|
670
|
-
const
|
|
671
|
-
const
|
|
672
|
-
const
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
163
|
+
const [issuingSource, setIssuingSource] = useState(null);
|
|
164
|
+
const [isConfirmingTransfer, setIsConfirmingTransfer] = useState(false);
|
|
165
|
+
const [revealError, setRevealError] = useState(null);
|
|
166
|
+
const countdown = useQuoteCountdown(quote, showInstructions ? cryptoPaymentAttempt : null);
|
|
167
|
+
const funding = payment?.funding;
|
|
168
|
+
const receivedFunds = hasReceivedFunds(funding);
|
|
169
|
+
const expiredWithoutTransfer = phase.cutoffPassed &&
|
|
170
|
+
!phase.broadcast &&
|
|
171
|
+
!receivedFunds &&
|
|
172
|
+
["awaiting_deposit", "relay_delivered_nothing", "failed"].includes(phase.kind);
|
|
173
|
+
const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
|
|
174
|
+
const [resumeSelection, setResumeSelection] = useState(() => {
|
|
175
|
+
const selection = viewProps.resumePaymentSelection;
|
|
176
|
+
return !isIssued && selection?.kind === "manual" ? selection : undefined;
|
|
177
|
+
});
|
|
178
|
+
const resumeSource = resumeSelection &&
|
|
179
|
+
settlementCurrency &&
|
|
180
|
+
getManualPaymentAttemptMode(resumeSelection, settlementCurrency) ===
|
|
181
|
+
undefined
|
|
182
|
+
? settlementCurrency
|
|
183
|
+
: null;
|
|
184
|
+
// Issued instructions are payable while the payment accepts funds and
|
|
185
|
+
// Relay's quote still matches what is due.
|
|
186
|
+
const instructionsOutdated = !acceptsFunds(phase) ||
|
|
187
|
+
!manualInstructionsMatchFunding(cryptoPaymentAttempt, shortfall);
|
|
692
188
|
useEffect(() => {
|
|
693
|
-
if (!
|
|
189
|
+
if (!showInstructions || isConfirmingTransfer || expiredWithoutTransfer)
|
|
694
190
|
return;
|
|
695
191
|
configureManualQuoteRefresh();
|
|
696
|
-
|
|
192
|
+
return () => clearQuoteRefresh();
|
|
193
|
+
}, [expiredWithoutTransfer, isConfirmingTransfer, showInstructions]);
|
|
697
194
|
useEffect(() => {
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const interval = window.setInterval(() => {
|
|
704
|
-
setManualQuoteTick((tick) => tick + 1);
|
|
705
|
-
}, 1000);
|
|
706
|
-
return () => {
|
|
707
|
-
window.clearInterval(interval);
|
|
708
|
-
};
|
|
709
|
-
}, [attemptQuoteTiming.expiresAt, hasAcknowledged, quote.remainingMs]);
|
|
710
|
-
useEffect(() => {
|
|
711
|
-
if (!payment?.id ||
|
|
712
|
-
!cryptoCurrency ||
|
|
713
|
-
!shouldLoadManualPaymentOptions(cryptoCurrency)) {
|
|
714
|
-
setManualPaymentOptions([]);
|
|
715
|
-
setManualPaymentOptionsStatus("idle");
|
|
716
|
-
return undefined;
|
|
717
|
-
}
|
|
718
|
-
let cancelled = false;
|
|
719
|
-
setManualPaymentOptionsStatus("loading");
|
|
720
|
-
getManualPaymentOptions(payment.id)
|
|
721
|
-
.then((options) => {
|
|
722
|
-
if (cancelled)
|
|
723
|
-
return;
|
|
724
|
-
setManualPaymentOptions(options);
|
|
725
|
-
setManualPaymentOptionsStatus("ready");
|
|
726
|
-
})
|
|
727
|
-
.catch((error) => {
|
|
728
|
-
if (cancelled)
|
|
729
|
-
return;
|
|
730
|
-
console.error("Failed to load manual payment options:", error);
|
|
731
|
-
setManualPaymentOptions([]);
|
|
732
|
-
setManualPaymentOptionsStatus("failed");
|
|
733
|
-
});
|
|
734
|
-
return () => {
|
|
735
|
-
cancelled = true;
|
|
736
|
-
};
|
|
737
|
-
}, [cryptoCurrency, payment?.id]);
|
|
738
|
-
useEffect(() => {
|
|
739
|
-
const selectedSourceIsAvailable = sourceOptions.some((option) => sourceKey(option) === selectedSourceKey);
|
|
740
|
-
if (!selectedSourceIsAvailable && sourceOptions[0]) {
|
|
741
|
-
setSelectedSourceKey(sourceKey(sourceOptions[0]));
|
|
742
|
-
}
|
|
743
|
-
}, [selectedSourceKey, sourceOptions]);
|
|
744
|
-
useEffect(() => {
|
|
745
|
-
const currentSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey);
|
|
746
|
-
const nextTokenKey = currentSource
|
|
747
|
-
? getSourceTokenGroupKey(currentSource, manualPaymentOptions)
|
|
748
|
-
: "";
|
|
749
|
-
const selectedTokenIsAvailable = sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
750
|
-
selectedTokenKey);
|
|
751
|
-
if (nextTokenKey && (!selectedTokenKey || !selectedTokenIsAvailable)) {
|
|
752
|
-
setSelectedTokenKey(nextTokenKey);
|
|
195
|
+
if (showInstructions &&
|
|
196
|
+
instructionsOutdated &&
|
|
197
|
+
!expiredWithoutTransfer &&
|
|
198
|
+
quote.status !== "refreshing") {
|
|
199
|
+
goToView("paymentStatus");
|
|
753
200
|
}
|
|
754
201
|
}, [
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
202
|
+
expiredWithoutTransfer,
|
|
203
|
+
goToView,
|
|
204
|
+
instructionsOutdated,
|
|
205
|
+
quote.status,
|
|
206
|
+
showInstructions,
|
|
759
207
|
]);
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
208
|
+
const paymentId = payment?.id;
|
|
209
|
+
const manualTransferPending = viewProps.showIssuedInstructions === true;
|
|
210
|
+
const directInstructions = instructions?.type === "token_transfer" ? instructions : null;
|
|
211
|
+
const manualAsset = directInstructions?.token;
|
|
212
|
+
const manualChain = directInstructions?.chain;
|
|
213
|
+
const continueManualPayment = showInstructions &&
|
|
214
|
+
!phase.broadcast &&
|
|
215
|
+
!receivedFunds &&
|
|
216
|
+
!isConfirmingTransfer &&
|
|
217
|
+
!manualTransferPending;
|
|
218
|
+
useLayoutEffect(() => {
|
|
219
|
+
if (!continueManualPayment || !paymentId || !manualAsset || !manualChain)
|
|
765
220
|
return;
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
option.chain.toLowerCase() === instructionSource.chain.toLowerCase());
|
|
774
|
-
if (attemptSource) {
|
|
775
|
-
setSelectedSourceKey(sourceKey(attemptSource));
|
|
776
|
-
}
|
|
777
|
-
setHasAcknowledged(true);
|
|
221
|
+
onPaymentSelectionChange?.(paymentId, {
|
|
222
|
+
kind: "manual",
|
|
223
|
+
asset: manualAsset,
|
|
224
|
+
chain: manualChain,
|
|
225
|
+
refundTo: frozenRefundTo,
|
|
226
|
+
});
|
|
227
|
+
return () => onPaymentSelectionChange?.(paymentId, null);
|
|
778
228
|
}, [
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
229
|
+
continueManualPayment,
|
|
230
|
+
frozenRefundTo,
|
|
231
|
+
manualAsset,
|
|
232
|
+
manualChain,
|
|
233
|
+
onPaymentSelectionChange,
|
|
234
|
+
paymentId,
|
|
783
235
|
]);
|
|
784
236
|
useEffect(() => {
|
|
785
|
-
if (
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
if (attemptRefundTo) {
|
|
789
|
-
setRefundWallet(attemptRefundTo);
|
|
237
|
+
if (!isIssued && !showInstructions && connectedAccount.address) {
|
|
238
|
+
const address = connectedAccount.address;
|
|
239
|
+
setRefundWallet((current) => current ?? address);
|
|
790
240
|
}
|
|
791
|
-
}, [
|
|
792
|
-
cryptoPaymentAttempt?.refund_to,
|
|
793
|
-
hasAcknowledged,
|
|
794
|
-
refundEditorExpanded,
|
|
795
|
-
refundWallet,
|
|
796
|
-
]);
|
|
797
|
-
useEffect(() => {
|
|
798
|
-
if (hasAcknowledged ||
|
|
799
|
-
refundEditorExpanded ||
|
|
800
|
-
refundWallet ||
|
|
801
|
-
hasAutoPrefilledRefundWalletRef.current ||
|
|
802
|
-
!connectedAccount.address)
|
|
803
|
-
return;
|
|
804
|
-
hasAutoPrefilledRefundWalletRef.current = true;
|
|
805
|
-
setRefundWallet(connectedAccount.address);
|
|
806
|
-
}, [
|
|
807
|
-
connectedAccount.address,
|
|
808
|
-
hasAcknowledged,
|
|
809
|
-
refundEditorExpanded,
|
|
810
|
-
refundWallet,
|
|
811
|
-
]);
|
|
241
|
+
}, [connectedAccount.address, isIssued, showInstructions]);
|
|
812
242
|
const handleConfirm = async () => {
|
|
243
|
+
if (isConfirmingTransfer)
|
|
244
|
+
return;
|
|
813
245
|
const isCurrent = captureCheckoutOpening();
|
|
814
|
-
if (!payment?.id) {
|
|
246
|
+
if (!payment?.id || !cryptoPaymentAttempt) {
|
|
815
247
|
goToView("failed", { reason: "confirm_payment" });
|
|
816
248
|
return;
|
|
817
249
|
}
|
|
250
|
+
setIsConfirmingTransfer(true);
|
|
251
|
+
const manualTransfer = manualTransferFor(cryptoPaymentAttempt, shortfall);
|
|
252
|
+
writeCheckoutResumeState(payment.id, {
|
|
253
|
+
view: "paymentStatus",
|
|
254
|
+
manualTransfer,
|
|
255
|
+
});
|
|
818
256
|
try {
|
|
819
257
|
await confirmPayment(payment.id);
|
|
820
258
|
if (!isCurrent())
|
|
821
259
|
return;
|
|
822
|
-
goToView("paymentStatus");
|
|
260
|
+
goToView("paymentStatus", { justSubmitted: true, manualTransfer });
|
|
823
261
|
}
|
|
824
262
|
catch (error) {
|
|
825
263
|
if (!isCurrent())
|
|
@@ -828,235 +266,125 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
828
266
|
goToView("failed", { reason: "confirm_payment" });
|
|
829
267
|
}
|
|
830
268
|
};
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
}
|
|
834
|
-
// Action needed: the quote refresh failed. No funds have been sent under a
|
|
835
|
-
// stale address, so the recovery is simply to fetch a fresh amount again.
|
|
836
|
-
if (quote.status === "failed") {
|
|
837
|
-
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsxs(ErrorCard, { children: [_jsx(AlertCircleIcon, { size: 28, color: "#ef4444" }), _jsx(Text, { size: "base", weight: "medium", color: config.theme.font.color.primary, children: "Something went wrong" }), _jsx(Text, { size: "sm", color: config.theme.font.color.secondary, children: quote.error ??
|
|
838
|
-
"We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
|
|
839
|
-
void refreshQuote();
|
|
840
|
-
}, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
|
|
841
|
-
}
|
|
842
|
-
// Quote refreshing: the address/route was stale or missing, so Mint is
|
|
843
|
-
// fetching a fresh payable amount — no expiry dead-end.
|
|
844
|
-
if (quote.status === "refreshing") {
|
|
845
|
-
return (_jsx(ModalViewContainer, { ref: modalRef, children: _jsxs(RefreshCard, { children: [_jsx(RefreshSpinner, { "aria-hidden": "true" }), _jsxs(RefreshTitle, { children: [_jsx(Text, { size: "base", weight: "semibold", color: config.theme.font.color.primary, children: "Updating quote" }), _jsx(Text, { size: "sm", color: config.theme.font.color.secondary, children: "Getting the latest amount..." })] })] }) }));
|
|
846
|
-
}
|
|
847
|
-
const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
|
|
848
|
-
const selectedSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey) ??
|
|
849
|
-
sourceOptions[0] ??
|
|
850
|
-
cryptoCurrency;
|
|
851
|
-
const tokenOptions = uniqueSourceTokens(sourceOptions, manualPaymentOptions);
|
|
852
|
-
const activeTokenKey = selectedTokenKey ||
|
|
853
|
-
getSourceTokenGroupKey(selectedSource, manualPaymentOptions);
|
|
854
|
-
const networkOptions = sourceOptions.filter((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
|
|
855
|
-
const uniqueNetworkOptions = uniqueSourceChains(networkOptions);
|
|
856
|
-
const selectedTokenOption = tokenOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
|
|
857
|
-
const instructions = cryptoPaymentAttempt?.payment_instructions ?? null;
|
|
858
|
-
const instructionSource = getManualInstructionSource(instructions);
|
|
859
|
-
const amount = cryptoPaymentAttempt?.amount_formatted;
|
|
860
|
-
const currency = settlementCurrency.asset_name;
|
|
861
|
-
const chain = settlementCurrency.chain_name;
|
|
862
|
-
const sourceCurrency = selectedSource?.asset_name ?? currency;
|
|
863
|
-
const sourceChain = selectedSource?.chain_name ?? chain;
|
|
864
|
-
const trimmedRefundWallet = refundWallet.trim();
|
|
865
|
-
const issuedPaymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
|
|
866
|
-
const manualRefundWallet = trimmedRefundWallet;
|
|
867
|
-
const refundPreferenceChanged = normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) !==
|
|
868
|
-
normalizeOptionalAddress(manualRefundWallet);
|
|
869
|
-
const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
870
|
-
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
|
|
871
|
-
const canReuseAttemptForSource = (source, sourceRefundWallet = manualRefundWallet) => Boolean(instructionSource &&
|
|
872
|
-
instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
|
|
873
|
-
instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
|
|
874
|
-
normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
|
|
875
|
-
normalizeOptionalAddress(sourceRefundWallet) &&
|
|
876
|
-
!attemptIsStale);
|
|
877
|
-
const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
878
|
-
getSourceTokenGroupKey(token, manualPaymentOptions) &&
|
|
879
|
-
(sourceMatchesSettlementCurrency(option) ||
|
|
880
|
-
manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
|
|
881
|
-
manualOptionLookupKey(option) && manualOption.kind === "direct")));
|
|
882
|
-
const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
|
|
883
|
-
const chainIconUrl = getManualChainIconUrl(selectedSource ?? settlementCurrency);
|
|
884
|
-
const rawAmount = cryptoPaymentAttempt?.amount === undefined
|
|
885
|
-
? null
|
|
886
|
-
: String(cryptoPaymentAttempt.amount);
|
|
887
|
-
const sourceAmountFormatted = instructions?.type === "relay_deposit_address"
|
|
888
|
-
? instructions.source_amount_formatted
|
|
889
|
-
: (instructions?.amount_formatted ?? amount);
|
|
890
|
-
const sourceAmountRaw = instructions?.type === "relay_deposit_address"
|
|
891
|
-
? instructions.source_amount
|
|
892
|
-
: (instructions?.amount ?? rawAmount);
|
|
893
|
-
const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
|
|
894
|
-
const formattedAmount = sourceAmountFormatted === undefined
|
|
895
|
-
? null
|
|
896
|
-
: formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
|
|
897
|
-
const useRawAmount = Boolean(sourceAmountRaw) &&
|
|
898
|
-
sourceAmountRaw !== String(sourceAmountFormatted) &&
|
|
899
|
-
shouldUseRawManualAmount(sourceChain, sourceCurrency);
|
|
900
|
-
const sendAmount = useRawAmount ? sourceAmountRaw : formattedAmount;
|
|
901
|
-
const copyAmount = useRawAmount
|
|
902
|
-
? sourceAmountRaw
|
|
903
|
-
: sourceAmountFormatted === undefined
|
|
904
|
-
? null
|
|
905
|
-
: String(sourceAmountFormatted);
|
|
906
|
-
const paymentAddress = issuedPaymentAddress;
|
|
907
|
-
const qrPayload = instructions?.type === "token_transfer"
|
|
908
|
-
? instructions.qr_payload
|
|
909
|
-
: paymentAddress;
|
|
910
|
-
const handleBackToSourceSetup = () => {
|
|
911
|
-
dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
|
|
912
|
-
setCopiedAddress(false);
|
|
913
|
-
setCopiedAmount(false);
|
|
914
|
-
setShowQrCode(false);
|
|
269
|
+
const manualRefundWallet = refundWallet?.trim() ?? "";
|
|
270
|
+
const clearPickerErrors = () => {
|
|
915
271
|
setRefundWalletError(null);
|
|
916
|
-
|
|
917
|
-
setPaymentDetailsExpanded(false);
|
|
918
|
-
if (selectedSource &&
|
|
919
|
-
shouldResetManualRefundWalletForSource(refundWallet, selectedSource)) {
|
|
920
|
-
setRefundWallet("");
|
|
921
|
-
}
|
|
922
|
-
setIsCreatingAttempt(false);
|
|
923
|
-
setHasAcknowledged(false);
|
|
924
|
-
setManualSetupStep("network");
|
|
272
|
+
setRevealError(null);
|
|
925
273
|
};
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
return;
|
|
274
|
+
const validateRefundWallet = () => {
|
|
275
|
+
if (!isIssued && manualRefundWallet && !isEvmAddress(manualRefundWallet)) {
|
|
276
|
+
setRefundWalletError("Enter a valid EVM wallet address, or clear the field to use the merchant address.");
|
|
277
|
+
return false;
|
|
931
278
|
}
|
|
932
|
-
return;
|
|
933
|
-
};
|
|
934
|
-
const selectToken = (token) => {
|
|
935
|
-
const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
|
|
936
|
-
const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
|
|
937
|
-
setSelectedTokenKey(nextTokenKey);
|
|
938
|
-
setSelectedSourceKey(sourceKey(firstNetworkForToken));
|
|
939
|
-
setManualSetupStep("network");
|
|
940
|
-
setRefundWalletError(null);
|
|
279
|
+
return true;
|
|
941
280
|
};
|
|
942
|
-
const
|
|
281
|
+
const revealManualPayment = async (source, resume) => {
|
|
282
|
+
if (isIssuingRef.current || !settlementCurrency)
|
|
283
|
+
return;
|
|
284
|
+
clearPickerErrors();
|
|
285
|
+
if (!resume && !validateRefundWallet())
|
|
286
|
+
return;
|
|
943
287
|
const isCurrent = captureCheckoutOpening();
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
dismissedAttemptKeyRef.current = null;
|
|
952
|
-
configureManualQuoteRefresh();
|
|
953
|
-
setAcknowledgedWithTransition(true);
|
|
954
|
-
return true;
|
|
955
|
-
}
|
|
956
|
-
setIsCreatingAttempt(true);
|
|
288
|
+
const settlementRefundWallet = isIssued
|
|
289
|
+
? null
|
|
290
|
+
: resume
|
|
291
|
+
? resume.refundTo
|
|
292
|
+
: manualRefundWallet || null;
|
|
293
|
+
isIssuingRef.current = true;
|
|
294
|
+
setIssuingSource(source);
|
|
957
295
|
try {
|
|
958
|
-
|
|
959
|
-
mode:
|
|
960
|
-
? undefined
|
|
961
|
-
: getManualPaymentAttemptMode(source, settlementCurrency),
|
|
296
|
+
await createManualDirectPaymentAttempt("", 1, settlementRefundWallet, {
|
|
297
|
+
mode: getManualPaymentAttemptMode(source, settlementCurrency),
|
|
962
298
|
source,
|
|
963
299
|
});
|
|
964
300
|
if (!isCurrent())
|
|
965
|
-
return
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
return true;
|
|
301
|
+
return;
|
|
302
|
+
await transitionView(() => {
|
|
303
|
+
if (isCurrent())
|
|
304
|
+
setShowInstructions(true);
|
|
305
|
+
});
|
|
971
306
|
}
|
|
972
307
|
catch (error) {
|
|
973
308
|
if (!isCurrent())
|
|
974
|
-
return
|
|
309
|
+
return;
|
|
310
|
+
// The closed payment was read again; it may have moved on with funds.
|
|
311
|
+
if (hasClosedPaymentMovedOn(error, useCheckoutStore.getState().payment)) {
|
|
312
|
+
goToView("paymentStatus");
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
975
315
|
console.error("Failed to create manual payment attempt:", error);
|
|
976
|
-
|
|
977
|
-
return false;
|
|
316
|
+
setRevealError(describeRevealFailure(error, MANUAL_ATTEMPT_FAILED_MESSAGE));
|
|
978
317
|
}
|
|
979
318
|
finally {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
const nextRefundWallet = shouldResetRefundWallet ? "" : manualRefundWallet;
|
|
987
|
-
setSelectedSourceKey(sourceKey(network));
|
|
988
|
-
setRefundWalletError(null);
|
|
989
|
-
setRefundEditorExpanded(false);
|
|
990
|
-
if (shouldResetRefundWallet) {
|
|
991
|
-
setRefundWallet("");
|
|
992
|
-
}
|
|
993
|
-
setCopiedAddress(false);
|
|
994
|
-
setCopiedAmount(false);
|
|
995
|
-
setShowQrCode(false);
|
|
996
|
-
void generateManualPaymentForSource(network, {
|
|
997
|
-
refundWallet: nextRefundWallet,
|
|
998
|
-
});
|
|
999
|
-
};
|
|
1000
|
-
const copyToClipboard = async (value, setCopied) => {
|
|
1001
|
-
try {
|
|
1002
|
-
await navigator.clipboard.writeText(value);
|
|
1003
|
-
setCopied(true);
|
|
1004
|
-
setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds
|
|
1005
|
-
}
|
|
1006
|
-
catch (error) {
|
|
1007
|
-
console.error("Failed to copy to clipboard:", error);
|
|
319
|
+
isIssuingRef.current = false;
|
|
320
|
+
if (isCurrent()) {
|
|
321
|
+
setIssuingSource(null);
|
|
322
|
+
if (resume)
|
|
323
|
+
setResumeSelection(undefined);
|
|
324
|
+
}
|
|
1008
325
|
}
|
|
1009
326
|
};
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
if (!refundPreferenceChanged) {
|
|
1017
|
-
setRefundEditorExpanded(false);
|
|
1018
|
-
setRefundWalletError(null);
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
void generateManualPaymentForSource(selectedSource);
|
|
1022
|
-
}, onRefundChange: (value) => {
|
|
1023
|
-
setRefundWallet(value);
|
|
1024
|
-
setRefundWalletError(null);
|
|
1025
|
-
} }), options.showPaymentDetails &&
|
|
1026
|
-
paymentAddress &&
|
|
1027
|
-
sendAmount &&
|
|
1028
|
-
copyAmount ? (_jsxs(PaymentInstructionCard, { children: [_jsxs("div", { children: [_jsxs(PaymentInstructionHeader, { children: [_jsx(PaymentInstructionLabel, { theme: config.theme, children: "Payment address" }), _jsx(IconButton, { type: "button", "$active": showQrCode, onClick: () => setShowQrCode((visible) => !visible), title: showQrCode ? "Hide QR code" : "Show QR code", "aria-label": showQrCode ? "Hide QR code" : "Show QR code", children: _jsx(QrCodeIcon, { size: 16 }) })] }), showQrCode ? (_jsx(QRCard, { children: _jsx(QRCode, { value: qrPayload ?? paymentAddress, size: 236 }) })) : (_jsx(AddressInfoRow, { isCopied: copiedAddress, onClick: () => copyToClipboard(paymentAddress, setCopiedAddress).catch((error) => {
|
|
1029
|
-
console.error("Failed to copy address:", error);
|
|
1030
|
-
}), title: "Click to copy address", children: _jsx(AddressText, { theme: config.theme, children: paymentAddress }) }))] }), _jsxs(CopyAddressCta, { type: "button", isCopied: copiedAddress, onClick: () => copyToClipboard(paymentAddress, setCopiedAddress).catch((error) => {
|
|
1031
|
-
console.error("Failed to copy address:", error);
|
|
1032
|
-
}), children: [copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })), copiedAddress ? "Copied address" : "Copy address"] }), _jsx(PaymentInstructionDivider, {}), _jsxs("div", { children: [_jsx(PaymentInstructionHeader, { children: _jsx(PaymentInstructionLabel, { theme: config.theme, children: "Amount to send" }) }), _jsxs(AmountInfoRow, { isCopied: copiedAmount, onClick: () => copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1033
|
-
console.error("Failed to copy amount:", error);
|
|
1034
|
-
}), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
|
|
1035
|
-
e.stopPropagation();
|
|
1036
|
-
copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1037
|
-
console.error("Failed to copy amount:", error);
|
|
1038
|
-
});
|
|
1039
|
-
}, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 15 })) : (_jsx(ClipboardAddIcon, { size: 15 })) })] })] })] })) : null] }));
|
|
1040
|
-
if (!hasAcknowledged) {
|
|
1041
|
-
if (manualSetupStep === "token") {
|
|
1042
|
-
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
|
|
1043
|
-
const hasFastRoute = tokenHasFastManualRoute(option);
|
|
1044
|
-
const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
|
|
1045
|
-
const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
|
|
1046
|
-
return (_jsxs(SelectionRow, { type: "button", onClick: () => selectToken(option), children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIconView, { iconUrl: option.logo_url, fallback: getMonogram(option.asset_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: tokenSymbol }), showTokenName ? (_jsx(SelectionSubtitle, { children: option.asset_name })) : null] })] }), hasFastRoute ? (_jsxs(SelectionBadge, { children: [_jsx("span", { children: "\u26A1" }), _jsx("span", { children: "Fast" })] })) : null] }, getSourceTokenGroupKey(option, manualPaymentOptions)));
|
|
1047
|
-
}) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
|
|
1048
|
-
}
|
|
1049
|
-
if (manualSetupStep === "network") {
|
|
1050
|
-
const selectedTokenLabel = selectedTokenOption?.asset_name ?? sourceCurrency;
|
|
1051
|
-
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select network" }), _jsx(OptionList, { children: uniqueNetworkOptions.map((option) => (_jsxs(SelectionRow, { type: "button", onClick: () => selectNetwork(option), disabled: isCreatingAttempt, children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIconView, { iconUrl: getManualChainIconUrl(option), fallback: getChainAbbreviation(option.chain_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: option.chain_name }), _jsx(SelectionSubtitle, { children: selectedTokenLabel })] })] }), isCreatingAttempt &&
|
|
1052
|
-
sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
|
|
1053
|
-
}
|
|
327
|
+
useEffect(() => {
|
|
328
|
+
if (!resumeSelection || !resumeSource || !paymentId || isIssued)
|
|
329
|
+
return;
|
|
330
|
+
void revealManualPayment(resumeSource, resumeSelection);
|
|
331
|
+
}, [isIssued, paymentId, resumeSelection, resumeSource, revealManualPayment]);
|
|
332
|
+
if (!cryptoCurrency || !settlementCurrency) {
|
|
1054
333
|
return null;
|
|
1055
334
|
}
|
|
1056
|
-
|
|
335
|
+
const expired = showInstructions && expiredWithoutTransfer;
|
|
336
|
+
const refreshing = (expired &&
|
|
337
|
+
continueManualPayment &&
|
|
338
|
+
directInstructions &&
|
|
339
|
+
(hostedRecovery === "checking" || hostedRecovery === "available")) ||
|
|
340
|
+
(showInstructions && !issuingSource && quote.status === "refreshing") ||
|
|
341
|
+
(resumeSource && !showInstructions && !revealError);
|
|
342
|
+
if (refreshing || expired) {
|
|
343
|
+
return _jsx(ManualPaymentRefresh, { expired: !refreshing });
|
|
344
|
+
}
|
|
345
|
+
// Action needed: the quote refresh failed. No funds have been sent under a
|
|
346
|
+
// stale address, so the recovery is simply to fetch a fresh amount again.
|
|
347
|
+
if (showInstructions && !issuingSource && quote.status === "failed") {
|
|
348
|
+
return (_jsxs(ModalViewContainer, { children: [_jsxs(ErrorCard, { children: [_jsx(AlertCircleIcon, { size: 28, color: "#ef4444" }), _jsx(Text, { size: "base", weight: "medium", color: config.theme.font.color.primary, children: "Something went wrong" }), _jsx(PaymentRouteError, { role: "alert", children: quote.error ??
|
|
349
|
+
"We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
|
|
350
|
+
void refreshQuote();
|
|
351
|
+
}, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
|
|
352
|
+
}
|
|
353
|
+
const relay = instructions?.type === "relay_deposit_address";
|
|
354
|
+
const bitcoin = relay && instructions.source_chain === BITCOIN_CHAIN;
|
|
355
|
+
if (!showInstructions) {
|
|
356
|
+
return (_jsx(ModalViewContainer, { children: _jsx(ManualRoutePicker, { sources: loadingSources ? [] : sourceOptions, loadingSources: loadingSources, manualPaymentOptions: manualPaymentOptions, settlementCurrency: settlementCurrency, issuingSource: issuingSource, error: revealError, onNavigate: clearPickerErrors, onSelectToken: validateRefundWallet, onReveal: (source) => void revealManualPayment(source), refundPreference: _jsx(ManualRefundPreference, { refundAddress: frozenRefundTo, editable: !isIssued, value: refundWallet ?? "", error: refundWalletError, disabled: Boolean(issuingSource), onChange: (value) => {
|
|
357
|
+
setRefundWallet(value);
|
|
358
|
+
setRefundWalletError(null);
|
|
359
|
+
} }) }) }));
|
|
360
|
+
}
|
|
361
|
+
if (instructionsOutdated)
|
|
1057
362
|
return null;
|
|
363
|
+
const instructionSource = getManualInstructionSource(instructions ?? null);
|
|
364
|
+
const source = relay
|
|
365
|
+
? sourceOptions.find((option) => option.asset.toLowerCase() ===
|
|
366
|
+
instructionSource?.token.toLowerCase() &&
|
|
367
|
+
option.chain.toLowerCase() === instructionSource?.chain.toLowerCase())
|
|
368
|
+
: settlementCurrency;
|
|
369
|
+
const sourceCurrency = source?.asset_name ?? formatTokenLabel(instructionSource?.token ?? "");
|
|
370
|
+
const sourceChain = source?.chain_name ?? formatChainLabel(instructionSource?.chain ?? "");
|
|
371
|
+
const tokenIconUrl = source?.logo_url;
|
|
372
|
+
const chainIconUrl = source ? getManualChainIconUrl(source) : null;
|
|
373
|
+
const sourceTokenSymbol = source
|
|
374
|
+
? getSourceTokenSymbol(source, manualPaymentOptions)
|
|
375
|
+
: sourceCurrency;
|
|
376
|
+
const transferInstructions = getManualTransferInstructions(cryptoPaymentAttempt, { chain: sourceChain, currency: bitcoin ? BITCOIN.symbol : sourceCurrency }, funding, shortfall);
|
|
377
|
+
if (transferInstructions.kind === "unavailable_top_up") {
|
|
378
|
+
return (_jsxs(ModalViewContainer, { children: [_jsx(PaymentRouteError, { role: "alert", children: "The remaining amount is unavailable." }), _jsx(StyledButton, { variant: "secondary", onClick: () => goToView("paymentStatus"), children: "Back to payment status" })] }));
|
|
1058
379
|
}
|
|
1059
|
-
|
|
380
|
+
if (transferInstructions.kind !== "ready")
|
|
381
|
+
return null;
|
|
382
|
+
return (_jsxs(ManualPaymentLayout, { children: [_jsx(ManualPaymentScrollArea, { children: _jsxs(PaymentDetailsStack, { children: [_jsx(QuoteExpiryCountdown, { remainingMs: countdown.remainingMs, totalDurationMs: countdown.totalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO }), _jsx(ManualPaymentSummary, { icon: _jsxs(TokenIconWrap, { children: [_jsx(TokenIcon, { "$iconUrl": tokenIconUrl, children: tokenIconUrl ? null : getMonogram(sourceCurrency) }), _jsx(ChainBadge, { "$iconUrl": chainIconUrl, children: chainIconUrl ? null : getChainAbbreviation(sourceChain) })] }), tokenLabel: `${sourceTokenSymbol} on ${sourceChain}`, expanded: paymentDetailsExpanded, refundAddress: frozenRefundTo, bitcoin: bitcoin, relay: relay, onToggle: () => setPaymentDetailsExpanded((expanded) => !expanded) }), _jsx(FundingProgress, { funding: payment?.funding, tokenSymbol: instructions?.type === "token_transfer"
|
|
383
|
+
? instructions.token_symbol
|
|
384
|
+
: settlementCurrency.asset_name }), _jsx(ManualInstructionCard, { ...transferInstructions }, transferInstructions.paymentAddress)] }) }), _jsxs(ManualPaymentActions, { children: [_jsx(StyledButton, { onClick: handleConfirm, variant: "primary", disabled: isConfirmingTransfer, children: isConfirmingTransfer ? "Confirming…" : "I've sent the funds" }), _jsx(StyledButton, { onClick: () => {
|
|
385
|
+
setPaymentDetailsExpanded(false);
|
|
386
|
+
void transitionView(() => setShowInstructions(false));
|
|
387
|
+
}, variant: "secondary", disabled: isConfirmingTransfer, children: "Back" })] })] }));
|
|
1060
388
|
};
|
|
1061
|
-
export { CryptoIntentDirectDetailsViewContent
|
|
389
|
+
export { CryptoIntentDirectDetailsViewContent };
|
|
1062
390
|
//# sourceMappingURL=direct-details.js.map
|