@mintmoney/react 0.1.0-alpha.9 → 0.2.0-alpha.1
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/README.md +13 -88
- package/dist/css/styles.css +178 -7
- package/dist/docs/customisation.md +67 -0
- package/dist/docs/overview.md +19 -0
- package/dist/docs/quickstart.md +171 -0
- package/dist/esm/api/checkouts.js +13 -12
- package/dist/esm/api/checkouts.js.map +1 -1
- package/dist/esm/api/generated.js +961 -51
- package/dist/esm/api/generated.js.map +1 -1
- package/dist/esm/api/index.js +2 -1
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/payments.js +74 -11
- package/dist/esm/api/payments.js.map +1 -1
- package/dist/esm/api/types.js +10 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/checkout/claimable-funds.js +26 -0
- package/dist/esm/checkout/claimable-funds.js.map +1 -0
- package/dist/esm/checkout/container.js +1 -1
- package/dist/esm/checkout/creation-error-modal.js +6 -0
- package/dist/esm/checkout/creation-error-modal.js.map +1 -0
- package/dist/esm/checkout/index.js +100 -8
- package/dist/esm/checkout/index.js.map +1 -1
- package/dist/esm/checkout/launcher.js +6 -0
- package/dist/esm/checkout/launcher.js.map +1 -0
- package/dist/esm/checkout/modal.js +75 -35
- package/dist/esm/checkout/modal.js.map +1 -1
- package/dist/esm/checkout/payment-status.js +55 -0
- package/dist/esm/checkout/payment-status.js.map +1 -0
- package/dist/esm/checkout/providers/wagmi-config.js +108 -0
- package/dist/esm/checkout/providers/wagmi-config.js.map +1 -0
- package/dist/esm/checkout/providers/wallet-connect-resume.js +129 -0
- package/dist/esm/checkout/providers/wallet-connect-resume.js.map +1 -0
- package/dist/esm/checkout/refund-availability.js +16 -0
- package/dist/esm/checkout/refund-availability.js.map +1 -0
- package/dist/esm/checkout/resume-state.js +82 -0
- package/dist/esm/checkout/resume-state.js.map +1 -0
- package/dist/esm/checkout/surplus-refund.js +38 -0
- package/dist/esm/checkout/surplus-refund.js.map +1 -0
- package/dist/esm/checkout/views/amount-header.js +82 -0
- package/dist/esm/checkout/views/amount-header.js.map +1 -0
- package/dist/esm/checkout/views/back.js +2 -2
- package/dist/esm/checkout/views/back.js.map +1 -1
- package/dist/esm/checkout/views/claimable-funds.js +29 -0
- package/dist/esm/checkout/views/claimable-funds.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/direct-details.js +1037 -12
- package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js +112 -0
- package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js +69 -0
- package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/methods.js +166 -18
- package/dist/esm/checkout/views/crypto-intent/methods.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/processing.js +89 -31
- package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/success.js +70 -9
- package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/test-payment.js +35 -0
- package/dist/esm/checkout/views/crypto-intent/test-payment.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js +30 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +1207 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js +166 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -0
- package/dist/esm/checkout/views/failed.js +91 -0
- package/dist/esm/checkout/views/failed.js.map +1 -0
- package/dist/esm/checkout/views/initial.js +63 -12
- package/dist/esm/checkout/views/initial.js.map +1 -1
- package/dist/esm/checkout/views/method-select.js +28 -5
- package/dist/esm/checkout/views/method-select.js.map +1 -1
- package/dist/esm/checkout/views/restart.js +12 -0
- package/dist/esm/checkout/views/restart.js.map +1 -0
- package/dist/esm/components/buttons/async-button.js +16 -0
- package/dist/esm/components/buttons/async-button.js.map +1 -0
- package/dist/esm/components/buttons/index.js +102 -16
- package/dist/esm/components/buttons/index.js.map +1 -1
- package/dist/esm/components/buttons/use-async-button.js +44 -0
- package/dist/esm/components/buttons/use-async-button.js.map +1 -0
- package/dist/esm/components/crypto/currency-selector.js +26 -0
- package/dist/esm/components/crypto/currency-selector.js.map +1 -0
- package/dist/esm/components/icons/alert.js +20 -0
- package/dist/esm/components/icons/alert.js.map +1 -0
- package/dist/esm/components/icons/checkMark.js.map +1 -1
- package/dist/esm/components/icons/clipboard-add.js +20 -0
- package/dist/esm/components/icons/clipboard-add.js.map +1 -0
- package/dist/esm/components/icons/clipboard-check.js +20 -0
- package/dist/esm/components/icons/clipboard-check.js.map +1 -0
- package/dist/esm/components/icons/clock.js +4 -0
- package/dist/esm/components/icons/clock.js.map +1 -0
- package/dist/esm/components/icons/close.js.map +1 -1
- package/dist/esm/components/icons/edit.js +6 -0
- package/dist/esm/components/icons/edit.js.map +1 -0
- package/dist/esm/components/icons/index.js +9 -0
- package/dist/esm/components/icons/index.js.map +1 -1
- package/dist/esm/components/icons/link.js +20 -0
- package/dist/esm/components/icons/link.js.map +1 -0
- package/dist/esm/components/icons/loading.js +26 -0
- package/dist/esm/components/icons/loading.js.map +1 -0
- package/dist/esm/components/icons/log-out.js +6 -0
- package/dist/esm/components/icons/log-out.js.map +1 -0
- package/dist/esm/components/icons/send.js +6 -0
- package/dist/esm/components/icons/send.js.map +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/inputs/index.js +47 -0
- package/dist/esm/components/inputs/index.js.map +1 -0
- package/dist/esm/components/lists/index.js.map +1 -1
- package/dist/esm/components/loading/index.js.map +1 -1
- package/dist/esm/components/modals/modal-with-views.js +7 -4
- 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/use-modal-with-views.js +11 -3
- package/dist/esm/components/modals/use-modal-with-views.js.map +1 -1
- package/dist/esm/components/quote-expiry/index.js +2 -0
- package/dist/esm/components/quote-expiry/index.js.map +1 -0
- package/dist/esm/components/quote-expiry/quote-expiry-countdown.js +35 -0
- package/dist/esm/components/quote-expiry/quote-expiry-countdown.js.map +1 -0
- package/dist/esm/components/quote-expiry/styles.js +109 -0
- package/dist/esm/components/quote-expiry/styles.js.map +1 -0
- package/dist/esm/components/quote-expiry/tiers.js +31 -0
- package/dist/esm/components/quote-expiry/tiers.js.map +1 -0
- package/dist/esm/components/text/index.js +2 -0
- package/dist/esm/components/text/index.js.map +1 -1
- package/dist/esm/components/wallet-selector/component.js +59 -0
- package/dist/esm/components/wallet-selector/component.js.map +1 -0
- package/dist/esm/components/wallet-selector/domain.js +2 -0
- package/dist/esm/components/wallet-selector/domain.js.map +1 -0
- package/dist/esm/components/wallet-selector/helper.js +12 -0
- package/dist/esm/components/wallet-selector/helper.js.map +1 -0
- package/dist/esm/components/wallet-selector/index.js +5 -0
- package/dist/esm/components/wallet-selector/index.js.map +1 -0
- package/dist/esm/components/wallet-selector/provider.js +15 -0
- package/dist/esm/components/wallet-selector/provider.js.map +1 -0
- package/dist/esm/components/wallet-selector/schemas.js +6 -0
- package/dist/esm/components/wallet-selector/schemas.js.map +1 -0
- package/dist/esm/components/wallet-selector/store.js +134 -0
- package/dist/esm/components/wallet-selector/store.js.map +1 -0
- package/dist/esm/components/wallet-selector/util/exceptions.js +16 -0
- package/dist/esm/components/wallet-selector/util/exceptions.js.map +1 -0
- package/dist/esm/components/wallet-selector/wallets/index.js +3 -0
- package/dist/esm/components/wallet-selector/wallets/index.js.map +1 -0
- package/dist/esm/components/wallet-selector/wallets/wagmi/index.js +218 -0
- package/dist/esm/components/wallet-selector/wallets/wagmi/index.js.map +1 -0
- package/dist/esm/components/wallet-selector/wallets/wagmi/usdt-abi.json +671 -0
- package/dist/esm/config.js +10 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/context.js +2 -1
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations/evm-chain.js +22 -0
- package/dist/esm/integrations/evm-chain.js.map +1 -0
- package/dist/esm/integrations/index.js +3 -0
- package/dist/esm/integrations/index.js.map +1 -0
- package/dist/esm/integrations/lifi.js +218 -0
- package/dist/esm/integrations/lifi.js.map +1 -0
- package/dist/esm/integrations/types.js +2 -0
- package/dist/esm/integrations/types.js.map +1 -0
- package/dist/esm/refund/confirmation.js +30 -0
- package/dist/esm/refund/confirmation.js.map +1 -0
- package/dist/esm/refund/index.js +599 -0
- package/dist/esm/refund/index.js.map +1 -0
- package/dist/esm/refund/prepare-guard.js +13 -0
- package/dist/esm/refund/prepare-guard.js.map +1 -0
- package/dist/esm/state/checkout/payment-attempt.js +46 -0
- package/dist/esm/state/checkout/payment-attempt.js.map +1 -0
- package/dist/esm/state/checkout/payment-lifecycle.js +78 -0
- package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -0
- package/dist/esm/state/checkout/store.js +841 -55
- package/dist/esm/state/checkout/store.js.map +1 -1
- package/dist/esm/state/checkout/wallet-payment-options.js +44 -0
- package/dist/esm/state/checkout/wallet-payment-options.js.map +1 -0
- package/dist/esm/themes/default.js +48 -0
- package/dist/esm/themes/default.js.map +1 -1
- package/dist/esm/themes/types.js +1 -1
- package/dist/esm/themes/types.js.map +1 -1
- package/dist/esm/utils/string.js +35 -0
- package/dist/esm/utils/string.js.map +1 -0
- package/dist/esm/utils/wallet-errors.js +15 -0
- package/dist/esm/utils/wallet-errors.js.map +1 -0
- package/dist/types/api/checkouts.d.ts +2 -8
- package/dist/types/api/checkouts.d.ts.map +1 -1
- package/dist/types/api/generated.d.ts +4653 -269
- package/dist/types/api/generated.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/payments.d.ts +53 -5
- package/dist/types/api/payments.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +27 -7
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/checkout/claimable-funds.d.ts +9 -0
- package/dist/types/checkout/claimable-funds.d.ts.map +1 -0
- package/dist/types/checkout/creation-error-modal.d.ts +9 -0
- package/dist/types/checkout/creation-error-modal.d.ts.map +1 -0
- package/dist/types/checkout/index.d.ts +10 -2
- package/dist/types/checkout/index.d.ts.map +1 -1
- package/dist/types/checkout/launcher.d.ts +6 -0
- package/dist/types/checkout/launcher.d.ts.map +1 -0
- package/dist/types/checkout/modal.d.ts +4 -2
- package/dist/types/checkout/modal.d.ts.map +1 -1
- package/dist/types/checkout/payment-status.d.ts +23 -0
- package/dist/types/checkout/payment-status.d.ts.map +1 -0
- package/dist/types/checkout/providers/wagmi-config.d.ts +18 -0
- package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -0
- package/dist/types/checkout/providers/wallet-connect-resume.d.ts +9 -0
- package/dist/types/checkout/providers/wallet-connect-resume.d.ts.map +1 -0
- package/dist/types/checkout/refund-availability.d.ts +2 -0
- package/dist/types/checkout/refund-availability.d.ts.map +1 -0
- package/dist/types/checkout/resume-state.d.ts +13 -0
- package/dist/types/checkout/resume-state.d.ts.map +1 -0
- package/dist/types/checkout/surplus-refund.d.ts +10 -0
- package/dist/types/checkout/surplus-refund.d.ts.map +1 -0
- package/dist/types/checkout/views/amount-header.d.ts +10 -0
- package/dist/types/checkout/views/amount-header.d.ts.map +1 -0
- package/dist/types/checkout/views/back.d.ts +3 -1
- package/dist/types/checkout/views/back.d.ts.map +1 -1
- package/dist/types/checkout/views/claimable-funds.d.ts +2 -0
- package/dist/types/checkout/views/claimable-funds.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +12 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts +20 -0
- package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts +16 -0
- package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/methods.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/processing.d.ts +3 -2
- package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/test-payment.d.ts +3 -0
- package/dist/types/checkout/views/crypto-intent/test-payment.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts +13 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts +3 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts +3 -0
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -0
- package/dist/types/checkout/views/failed.d.ts +2 -0
- package/dist/types/checkout/views/failed.d.ts.map +1 -0
- package/dist/types/checkout/views/initial.d.ts +6 -2
- package/dist/types/checkout/views/initial.d.ts.map +1 -1
- package/dist/types/checkout/views/method-select.d.ts +3 -0
- package/dist/types/checkout/views/method-select.d.ts.map +1 -1
- package/dist/types/checkout/views/restart.d.ts +4 -0
- package/dist/types/checkout/views/restart.d.ts.map +1 -0
- package/dist/types/components/buttons/async-button.d.ts +14 -0
- package/dist/types/components/buttons/async-button.d.ts.map +1 -0
- package/dist/types/components/buttons/index.d.ts +21 -3
- package/dist/types/components/buttons/index.d.ts.map +1 -1
- package/dist/types/components/buttons/use-async-button.d.ts +16 -0
- package/dist/types/components/buttons/use-async-button.d.ts.map +1 -0
- package/dist/types/components/crypto/currency-selector.d.ts +11 -0
- package/dist/types/components/crypto/currency-selector.d.ts.map +1 -0
- package/dist/types/components/icons/alert.d.ts +7 -0
- package/dist/types/components/icons/alert.d.ts.map +1 -0
- package/dist/types/components/icons/checkMark.d.ts.map +1 -1
- package/dist/types/components/icons/clipboard-add.d.ts +6 -0
- package/dist/types/components/icons/clipboard-add.d.ts.map +1 -0
- package/dist/types/components/icons/clipboard-check.d.ts +6 -0
- package/dist/types/components/icons/clipboard-check.d.ts.map +1 -0
- package/dist/types/components/icons/clock.d.ts +6 -0
- package/dist/types/components/icons/clock.d.ts.map +1 -0
- package/dist/types/components/icons/close.d.ts.map +1 -1
- package/dist/types/components/icons/edit.d.ts +6 -0
- package/dist/types/components/icons/edit.d.ts.map +1 -0
- package/dist/types/components/icons/index.d.ts +9 -0
- package/dist/types/components/icons/index.d.ts.map +1 -1
- package/dist/types/components/icons/link.d.ts +6 -0
- package/dist/types/components/icons/link.d.ts.map +1 -0
- package/dist/types/components/icons/loading.d.ts +6 -0
- package/dist/types/components/icons/loading.d.ts.map +1 -0
- package/dist/types/components/icons/log-out.d.ts +6 -0
- package/dist/types/components/icons/log-out.d.ts.map +1 -0
- package/dist/types/components/icons/send.d.ts +6 -0
- package/dist/types/components/icons/send.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/inputs/index.d.ts +7 -0
- package/dist/types/components/inputs/index.d.ts.map +1 -0
- package/dist/types/components/lists/index.d.ts.map +1 -1
- package/dist/types/components/loading/index.d.ts.map +1 -1
- package/dist/types/components/modals/modal-with-views.d.ts +1 -0
- package/dist/types/components/modals/modal-with-views.d.ts.map +1 -1
- package/dist/types/components/modals/modal.d.ts.map +1 -1
- package/dist/types/components/modals/use-modal-with-views.d.ts.map +1 -1
- package/dist/types/components/quote-expiry/index.d.ts +2 -0
- package/dist/types/components/quote-expiry/index.d.ts.map +1 -0
- package/dist/types/components/quote-expiry/quote-expiry-countdown.d.ts +15 -0
- package/dist/types/components/quote-expiry/quote-expiry-countdown.d.ts.map +1 -0
- package/dist/types/components/quote-expiry/styles.d.ts +22 -0
- package/dist/types/components/quote-expiry/styles.d.ts.map +1 -0
- package/dist/types/components/quote-expiry/tiers.d.ts +10 -0
- package/dist/types/components/quote-expiry/tiers.d.ts.map +1 -0
- package/dist/types/components/text/index.d.ts.map +1 -1
- package/dist/types/components/wallet-selector/component.d.ts +12 -0
- package/dist/types/components/wallet-selector/component.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/domain.d.ts +96 -0
- package/dist/types/components/wallet-selector/domain.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/helper.d.ts +4 -0
- package/dist/types/components/wallet-selector/helper.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/index.d.ts +7 -0
- package/dist/types/components/wallet-selector/index.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/provider.d.ts +10 -0
- package/dist/types/components/wallet-selector/provider.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/schemas.d.ts +4 -0
- package/dist/types/components/wallet-selector/schemas.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/store.d.ts +33 -0
- package/dist/types/components/wallet-selector/store.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/util/exceptions.d.ts +7 -0
- package/dist/types/components/wallet-selector/util/exceptions.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/wallets/index.d.ts +3 -0
- package/dist/types/components/wallet-selector/wallets/index.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts +519 -0
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -0
- package/dist/types/config.d.ts +74 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/integrations/evm-chain.d.ts +3 -0
- package/dist/types/integrations/evm-chain.d.ts.map +1 -0
- package/dist/types/integrations/index.d.ts +3 -0
- package/dist/types/integrations/index.d.ts.map +1 -0
- package/dist/types/integrations/lifi.d.ts +14 -0
- package/dist/types/integrations/lifi.d.ts.map +1 -0
- package/dist/types/integrations/types.d.ts +5 -0
- package/dist/types/integrations/types.d.ts.map +1 -0
- package/dist/types/refund/confirmation.d.ts +14 -0
- package/dist/types/refund/confirmation.d.ts.map +1 -0
- package/dist/types/refund/index.d.ts +26 -0
- package/dist/types/refund/index.d.ts.map +1 -0
- package/dist/types/refund/prepare-guard.d.ts +11 -0
- package/dist/types/refund/prepare-guard.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-attempt.d.ts +9 -0
- package/dist/types/state/checkout/payment-attempt.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-lifecycle.d.ts +39 -0
- package/dist/types/state/checkout/payment-lifecycle.d.ts.map +1 -0
- package/dist/types/state/checkout/store.d.ts +88 -40
- package/dist/types/state/checkout/store.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-payment-options.d.ts +24 -0
- package/dist/types/state/checkout/wallet-payment-options.d.ts.map +1 -0
- package/dist/types/themes/default.d.ts +2 -2
- package/dist/types/themes/default.d.ts.map +1 -1
- package/dist/types/themes/types.d.ts +20 -0
- package/dist/types/themes/types.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +24 -0
- package/dist/types/utils/string.d.ts.map +1 -0
- package/dist/types/utils/wallet-errors.d.ts +2 -0
- package/dist/types/utils/wallet-errors.d.ts.map +1 -0
- package/package.json +50 -7
- package/LICENSE +0 -21
- package/dist/esm/checkout/views/card-intent/details.js +0 -12
- package/dist/esm/checkout/views/card-intent/details.js.map +0 -1
- package/dist/esm/checkout/views/crypto-intent/curreny.js +0 -28
- package/dist/esm/checkout/views/crypto-intent/curreny.js.map +0 -1
- package/dist/types/checkout/views/card-intent/details.d.ts +0 -3
- package/dist/types/checkout/views/card-intent/details.d.ts.map +0 -1
- package/dist/types/checkout/views/crypto-intent/curreny.d.ts +0 -3
- package/dist/types/checkout/views/crypto-intent/curreny.d.ts.map +0 -1
|
@@ -1,26 +1,1051 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
//@ts-
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
//@ts-expect-error import error
|
|
4
4
|
import { QRCode } from "react-qr-code";
|
|
5
|
-
import {
|
|
5
|
+
import { keyframes, styled } from "styled-components";
|
|
6
|
+
import { useAccount } from "wagmi";
|
|
7
|
+
import { confirmPayment, getManualPaymentOptions, } from "../../../api/payments.js";
|
|
8
|
+
import { AlertCircleIcon, ClipboardAddIcon, ClipboardCheckIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
|
|
6
9
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
7
|
-
import {
|
|
10
|
+
import { getAttemptQuoteTiming, isAttemptStale, } from "../../../state/checkout/payment-lifecycle.js";
|
|
11
|
+
import { clearQuoteRefresh, configureManualQuoteRefresh, createManualDirectPaymentAttempt, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
|
|
8
12
|
import { ModalViewContainer } from "../../container.js";
|
|
13
|
+
import { ModalBackButton } from "../back.js";
|
|
14
|
+
import { ManualPaymentSummary } from "./manual-payment-summary.js";
|
|
15
|
+
const QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO = 0.25;
|
|
16
|
+
const ETHEREUM_ICON_URL = "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628";
|
|
17
|
+
const QRCard = styled.div `
|
|
18
|
+
background: #ffffff;
|
|
19
|
+
border: 1px solid #111827;
|
|
20
|
+
border-radius: 10px;
|
|
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
|
+
`;
|
|
346
|
+
const TokenIconWrap = styled.div `
|
|
347
|
+
position: relative;
|
|
348
|
+
width: 42px;
|
|
349
|
+
height: 42px;
|
|
350
|
+
flex-shrink: 0;
|
|
351
|
+
`;
|
|
352
|
+
const TokenIcon = styled.div `
|
|
353
|
+
width: 100%;
|
|
354
|
+
height: 100%;
|
|
355
|
+
border-radius: 999px;
|
|
356
|
+
display: inline-flex;
|
|
357
|
+
align-items: center;
|
|
358
|
+
justify-content: center;
|
|
359
|
+
font-size: 11px;
|
|
360
|
+
font-weight: 700;
|
|
361
|
+
color: #1d4ed8;
|
|
362
|
+
background: linear-gradient(135deg, #dbeafe, #bfdbfe);
|
|
363
|
+
background-image: ${({ $iconUrl }) => $iconUrl ? `url(${$iconUrl})` : "none"};
|
|
364
|
+
background-size: 85%;
|
|
365
|
+
background-position: center;
|
|
366
|
+
background-repeat: no-repeat;
|
|
367
|
+
`;
|
|
368
|
+
const ChainBadge = styled.div `
|
|
369
|
+
position: absolute;
|
|
370
|
+
right: -1px;
|
|
371
|
+
bottom: -1px;
|
|
372
|
+
width: 20px;
|
|
373
|
+
height: 20px;
|
|
374
|
+
border-radius: 999px;
|
|
375
|
+
border: 2px solid #ffffff;
|
|
376
|
+
background: #ffffff;
|
|
377
|
+
background-image: ${({ $iconUrl }) => $iconUrl ? `url(${$iconUrl})` : "none"};
|
|
378
|
+
background-size: 72%;
|
|
379
|
+
background-position: center;
|
|
380
|
+
background-repeat: no-repeat;
|
|
381
|
+
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
|
|
382
|
+
display: flex;
|
|
383
|
+
align-items: center;
|
|
384
|
+
justify-content: center;
|
|
385
|
+
font-size: 8px;
|
|
386
|
+
font-weight: 700;
|
|
387
|
+
color: #065f46;
|
|
388
|
+
`;
|
|
389
|
+
const SetupActions = styled.div `
|
|
390
|
+
display: flex;
|
|
391
|
+
flex-direction: column;
|
|
392
|
+
gap: 10px;
|
|
393
|
+
margin-top: 8px;
|
|
394
|
+
`;
|
|
395
|
+
const PaymentDetailsStack = styled.div `
|
|
396
|
+
display: flex;
|
|
397
|
+
flex-direction: column;
|
|
398
|
+
gap: 12px;
|
|
399
|
+
margin: 8px 0;
|
|
400
|
+
text-align: left;
|
|
401
|
+
`;
|
|
402
|
+
const ManualPaymentLayout = styled(ModalViewContainer) `
|
|
403
|
+
min-height: 0;
|
|
404
|
+
gap: 0;
|
|
405
|
+
`;
|
|
406
|
+
const ManualPaymentScrollArea = styled.div `
|
|
407
|
+
min-height: 0;
|
|
408
|
+
flex: 1 1 auto;
|
|
409
|
+
overflow-y: auto;
|
|
410
|
+
overflow-x: hidden;
|
|
411
|
+
padding-bottom: 16px;
|
|
412
|
+
scrollbar-width: none;
|
|
413
|
+
|
|
414
|
+
&::-webkit-scrollbar {
|
|
415
|
+
width: 0;
|
|
416
|
+
height: 0;
|
|
417
|
+
}
|
|
418
|
+
`;
|
|
419
|
+
const ManualPaymentActions = styled.div `
|
|
420
|
+
flex: 0 0 auto;
|
|
421
|
+
display: flex;
|
|
422
|
+
flex-direction: column;
|
|
423
|
+
gap: 10px;
|
|
424
|
+
padding-top: 14px;
|
|
425
|
+
background: #ffffff;
|
|
426
|
+
`;
|
|
427
|
+
const ErrorCard = styled.div `
|
|
428
|
+
background: #fef2f2;
|
|
429
|
+
border: 1px solid #fecaca;
|
|
430
|
+
border-radius: 12px;
|
|
431
|
+
padding: 16px;
|
|
432
|
+
margin: 8px 0;
|
|
433
|
+
text-align: center;
|
|
434
|
+
display: flex;
|
|
435
|
+
flex-direction: column;
|
|
436
|
+
align-items: center;
|
|
437
|
+
gap: 8px;
|
|
438
|
+
`;
|
|
439
|
+
const spin = keyframes `
|
|
440
|
+
to { transform: rotate(360deg); }
|
|
441
|
+
`;
|
|
442
|
+
const RefreshCard = styled.div `
|
|
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
|
+
};
|
|
9
629
|
const CryptoIntentDirectDetailsViewContent = () => {
|
|
10
630
|
const modalRef = useRef(null);
|
|
631
|
+
const dismissedAttemptKeyRef = useRef(null);
|
|
632
|
+
const hasAutoPrefilledRefundWalletRef = useRef(false);
|
|
11
633
|
const { goToView } = useModalWithView();
|
|
12
|
-
const
|
|
634
|
+
const connectedAccount = useAccount();
|
|
635
|
+
const { cryptoPaymentAttempt, cryptoCurrency, payment, quote } = useCheckoutStore();
|
|
13
636
|
const config = useMintMoneyConfig();
|
|
14
|
-
const
|
|
15
|
-
|
|
637
|
+
const fallbackSourceOptions = useMemo(() => cryptoCurrency
|
|
638
|
+
? uniqueSourceOptions(cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources)
|
|
639
|
+
: [], [cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources]);
|
|
640
|
+
const [manualPaymentOptions, setManualPaymentOptions] = useState([]);
|
|
641
|
+
const [manualPaymentOptionsStatus, setManualPaymentOptionsStatus] = useState("idle");
|
|
642
|
+
const manualOptionSources = useMemo(() => manualPaymentOptions.map(manualPaymentOptionToCurrency), [manualPaymentOptions]);
|
|
643
|
+
const sourceOptions = useMemo(() => {
|
|
644
|
+
if (cryptoCurrency &&
|
|
645
|
+
manualPaymentOptionsStatus === "ready" &&
|
|
646
|
+
manualOptionSources.length > 0) {
|
|
647
|
+
return uniqueSourceOptions(cryptoCurrency, manualOptionSources);
|
|
648
|
+
}
|
|
649
|
+
return fallbackSourceOptions;
|
|
650
|
+
}, [
|
|
651
|
+
cryptoCurrency,
|
|
652
|
+
fallbackSourceOptions,
|
|
653
|
+
manualOptionSources,
|
|
654
|
+
manualPaymentOptionsStatus,
|
|
655
|
+
]);
|
|
656
|
+
const [copiedAddress, setCopiedAddress] = useState(false);
|
|
657
|
+
const [copiedAmount, setCopiedAmount] = useState(false);
|
|
658
|
+
const [hasAcknowledged, setHasAcknowledged] = useState(false);
|
|
659
|
+
const [paymentDetailsExpanded, setPaymentDetailsExpanded] = useState(false);
|
|
660
|
+
const [refundEditorExpanded, setRefundEditorExpanded] = useState(false);
|
|
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);
|
|
666
|
+
const [refundWalletError, setRefundWalletError] = useState(null);
|
|
667
|
+
const [isCreatingAttempt, setIsCreatingAttempt] = useState(false);
|
|
668
|
+
const [manualQuoteTick, setManualQuoteTick] = useState(0);
|
|
669
|
+
const attemptIsStale = isAttemptStale(cryptoPaymentAttempt);
|
|
670
|
+
const attemptQuoteTiming = useMemo(() => getAttemptQuoteTiming(cryptoPaymentAttempt), [cryptoPaymentAttempt, manualQuoteTick]);
|
|
671
|
+
const countdownRemainingMs = quote.remainingMs ?? attemptQuoteTiming.remainingMs;
|
|
672
|
+
const countdownTotalDurationMs = quote.totalDurationMs ?? attemptQuoteTiming.totalDurationMs;
|
|
673
|
+
const setAcknowledgedWithTransition = (value) => {
|
|
674
|
+
if (document.startViewTransition) {
|
|
675
|
+
document.startViewTransition(() => {
|
|
676
|
+
setHasAcknowledged(value);
|
|
677
|
+
});
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
setHasAcknowledged(value);
|
|
16
681
|
};
|
|
17
|
-
|
|
682
|
+
useEffect(() => {
|
|
683
|
+
if (!hasAcknowledged) {
|
|
684
|
+
clearQuoteRefresh();
|
|
685
|
+
return undefined;
|
|
686
|
+
}
|
|
687
|
+
configureManualQuoteRefresh();
|
|
688
|
+
return () => {
|
|
689
|
+
clearQuoteRefresh();
|
|
690
|
+
};
|
|
691
|
+
}, [hasAcknowledged]);
|
|
692
|
+
useEffect(() => {
|
|
693
|
+
if (!hasAcknowledged || !cryptoPaymentAttempt)
|
|
694
|
+
return;
|
|
695
|
+
configureManualQuoteRefresh();
|
|
696
|
+
}, [cryptoPaymentAttempt, hasAcknowledged]);
|
|
697
|
+
useEffect(() => {
|
|
698
|
+
if (!hasAcknowledged ||
|
|
699
|
+
quote.remainingMs !== null ||
|
|
700
|
+
attemptQuoteTiming.expiresAt === null) {
|
|
701
|
+
return undefined;
|
|
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);
|
|
753
|
+
}
|
|
754
|
+
}, [
|
|
755
|
+
manualPaymentOptions,
|
|
756
|
+
selectedSourceKey,
|
|
757
|
+
selectedTokenKey,
|
|
758
|
+
sourceOptions,
|
|
759
|
+
]);
|
|
760
|
+
useEffect(() => {
|
|
761
|
+
if (!hasAcknowledged)
|
|
762
|
+
return;
|
|
763
|
+
const instructions = cryptoPaymentAttempt?.payment_instructions;
|
|
764
|
+
if (!instructions)
|
|
765
|
+
return;
|
|
766
|
+
const attemptKey = manualAttemptKey(cryptoPaymentAttempt);
|
|
767
|
+
if (!attemptKey || dismissedAttemptKeyRef.current === attemptKey)
|
|
768
|
+
return;
|
|
769
|
+
const instructionSource = getManualInstructionSource(instructions);
|
|
770
|
+
if (!instructionSource)
|
|
771
|
+
return;
|
|
772
|
+
const attemptSource = sourceOptions.find((option) => option.asset.toLowerCase() === instructionSource.token.toLowerCase() &&
|
|
773
|
+
option.chain.toLowerCase() === instructionSource.chain.toLowerCase());
|
|
774
|
+
if (attemptSource) {
|
|
775
|
+
setSelectedSourceKey(sourceKey(attemptSource));
|
|
776
|
+
}
|
|
777
|
+
setHasAcknowledged(true);
|
|
778
|
+
}, [
|
|
779
|
+
cryptoPaymentAttempt,
|
|
780
|
+
cryptoPaymentAttempt?.payment_instructions,
|
|
781
|
+
hasAcknowledged,
|
|
782
|
+
sourceOptions,
|
|
783
|
+
]);
|
|
784
|
+
useEffect(() => {
|
|
785
|
+
if (hasAcknowledged || refundEditorExpanded || refundWallet)
|
|
786
|
+
return;
|
|
787
|
+
const attemptRefundTo = cryptoPaymentAttempt?.refund_to?.trim();
|
|
788
|
+
if (attemptRefundTo) {
|
|
789
|
+
setRefundWallet(attemptRefundTo);
|
|
790
|
+
}
|
|
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
|
+
]);
|
|
812
|
+
const handleConfirm = async () => {
|
|
813
|
+
if (!payment?.id) {
|
|
814
|
+
goToView("failed", { reason: "confirm_payment" });
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
try {
|
|
818
|
+
await confirmPayment(payment.id);
|
|
819
|
+
goToView("paymentStatus");
|
|
820
|
+
}
|
|
821
|
+
catch (error) {
|
|
822
|
+
console.error("Failed to confirm payment:", error);
|
|
823
|
+
goToView("failed", { reason: "confirm_payment" });
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
if (!cryptoCurrency) {
|
|
18
827
|
return null;
|
|
19
828
|
}
|
|
20
|
-
|
|
21
|
-
|
|
829
|
+
// Action needed: the quote refresh failed. No funds have been sent under a
|
|
830
|
+
// stale address, so the recovery is simply to fetch a fresh amount again.
|
|
831
|
+
if (quote.status === "failed") {
|
|
832
|
+
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 ??
|
|
833
|
+
"We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
|
|
834
|
+
void refreshQuote();
|
|
835
|
+
}, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
|
|
836
|
+
}
|
|
837
|
+
// Quote refreshing: the address/route was stale or missing, so Mint is
|
|
838
|
+
// fetching a fresh payable amount — no expiry dead-end.
|
|
839
|
+
if (quote.status === "refreshing") {
|
|
840
|
+
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..." })] })] }) }));
|
|
841
|
+
}
|
|
842
|
+
const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
|
|
843
|
+
const selectedSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey) ??
|
|
844
|
+
sourceOptions[0] ??
|
|
845
|
+
cryptoCurrency;
|
|
846
|
+
const tokenOptions = uniqueSourceTokens(sourceOptions, manualPaymentOptions);
|
|
847
|
+
const activeTokenKey = selectedTokenKey ||
|
|
848
|
+
getSourceTokenGroupKey(selectedSource, manualPaymentOptions);
|
|
849
|
+
const networkOptions = sourceOptions.filter((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
|
|
850
|
+
const uniqueNetworkOptions = uniqueSourceChains(networkOptions);
|
|
851
|
+
const selectedTokenOption = tokenOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
|
|
852
|
+
const instructions = cryptoPaymentAttempt?.payment_instructions ?? null;
|
|
853
|
+
const instructionSource = getManualInstructionSource(instructions);
|
|
854
|
+
const amount = cryptoPaymentAttempt?.amount_formatted;
|
|
855
|
+
const currency = settlementCurrency.asset_name;
|
|
856
|
+
const chain = settlementCurrency.chain_name;
|
|
857
|
+
const sourceCurrency = selectedSource?.asset_name ?? currency;
|
|
858
|
+
const sourceChain = selectedSource?.chain_name ?? chain;
|
|
859
|
+
const trimmedRefundWallet = refundWallet.trim();
|
|
860
|
+
const issuedPaymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
|
|
861
|
+
const manualRefundWallet = trimmedRefundWallet;
|
|
862
|
+
const refundPreferenceChanged = normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) !==
|
|
863
|
+
normalizeOptionalAddress(manualRefundWallet);
|
|
864
|
+
const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
865
|
+
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
|
|
866
|
+
const canReuseAttemptForSource = (source, sourceRefundWallet = manualRefundWallet) => Boolean(instructionSource &&
|
|
867
|
+
instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
|
|
868
|
+
instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
|
|
869
|
+
normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
|
|
870
|
+
normalizeOptionalAddress(sourceRefundWallet) &&
|
|
871
|
+
!attemptIsStale);
|
|
872
|
+
const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
873
|
+
getSourceTokenGroupKey(token, manualPaymentOptions) &&
|
|
874
|
+
(sourceMatchesSettlementCurrency(option) ||
|
|
875
|
+
manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
|
|
876
|
+
manualOptionLookupKey(option) && manualOption.kind === "direct")));
|
|
877
|
+
const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
|
|
878
|
+
const chainIconUrl = getManualChainIconUrl(selectedSource ?? settlementCurrency);
|
|
879
|
+
const rawAmount = cryptoPaymentAttempt?.amount === undefined
|
|
880
|
+
? null
|
|
881
|
+
: String(cryptoPaymentAttempt.amount);
|
|
882
|
+
const sourceAmountFormatted = instructions?.type === "relay_deposit_address"
|
|
883
|
+
? instructions.source_amount_formatted
|
|
884
|
+
: (instructions?.amount_formatted ?? amount);
|
|
885
|
+
const sourceAmountRaw = instructions?.type === "relay_deposit_address"
|
|
886
|
+
? instructions.source_amount
|
|
887
|
+
: (instructions?.amount ?? rawAmount);
|
|
888
|
+
const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
|
|
889
|
+
const formattedAmount = sourceAmountFormatted === undefined
|
|
890
|
+
? null
|
|
891
|
+
: formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
|
|
892
|
+
const useRawAmount = Boolean(sourceAmountRaw) &&
|
|
893
|
+
sourceAmountRaw !== String(sourceAmountFormatted) &&
|
|
894
|
+
shouldUseRawManualAmount(sourceChain, sourceCurrency);
|
|
895
|
+
const sendAmount = useRawAmount ? sourceAmountRaw : formattedAmount;
|
|
896
|
+
const copyAmount = useRawAmount
|
|
897
|
+
? sourceAmountRaw
|
|
898
|
+
: sourceAmountFormatted === undefined
|
|
899
|
+
? null
|
|
900
|
+
: String(sourceAmountFormatted);
|
|
901
|
+
const paymentAddress = issuedPaymentAddress;
|
|
902
|
+
const qrPayload = instructions?.type === "token_transfer"
|
|
903
|
+
? instructions.qr_payload
|
|
904
|
+
: paymentAddress;
|
|
905
|
+
const handleBackToSourceSetup = () => {
|
|
906
|
+
dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
|
|
907
|
+
setCopiedAddress(false);
|
|
908
|
+
setCopiedAmount(false);
|
|
909
|
+
setShowQrCode(false);
|
|
910
|
+
setRefundWalletError(null);
|
|
911
|
+
setRefundEditorExpanded(false);
|
|
912
|
+
setPaymentDetailsExpanded(false);
|
|
913
|
+
if (selectedSource &&
|
|
914
|
+
shouldResetManualRefundWalletForSource(refundWallet, selectedSource)) {
|
|
915
|
+
setRefundWallet("");
|
|
916
|
+
}
|
|
917
|
+
setIsCreatingAttempt(false);
|
|
918
|
+
setHasAcknowledged(false);
|
|
919
|
+
setManualSetupStep("network");
|
|
920
|
+
};
|
|
921
|
+
const goBackInSetup = () => {
|
|
922
|
+
setRefundWalletError(null);
|
|
923
|
+
if (manualSetupStep === "network") {
|
|
924
|
+
setManualSetupStep("token");
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
return;
|
|
928
|
+
};
|
|
929
|
+
const selectToken = (token) => {
|
|
930
|
+
const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
|
|
931
|
+
const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
|
|
932
|
+
setSelectedTokenKey(nextTokenKey);
|
|
933
|
+
setSelectedSourceKey(sourceKey(firstNetworkForToken));
|
|
934
|
+
setManualSetupStep("network");
|
|
935
|
+
setRefundWalletError(null);
|
|
936
|
+
};
|
|
937
|
+
const generateManualPaymentForSource = async (source, options = {}) => {
|
|
938
|
+
const sourceRefundWallet = options.refundWallet ?? manualRefundWallet;
|
|
939
|
+
if (sourceRefundWallet &&
|
|
940
|
+
!isValidRefundAddressForSource(sourceRefundWallet, source)) {
|
|
941
|
+
setRefundWalletError("Enter a valid EVM wallet address.");
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
if (canReuseAttemptForSource(source, sourceRefundWallet)) {
|
|
945
|
+
dismissedAttemptKeyRef.current = null;
|
|
946
|
+
configureManualQuoteRefresh();
|
|
947
|
+
setAcknowledgedWithTransition(true);
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
setIsCreatingAttempt(true);
|
|
951
|
+
try {
|
|
952
|
+
const attempt = await createManualDirectPaymentAttempt("", 1, sourceRefundWallet || null, {
|
|
953
|
+
mode: sourceMatchesSettlementCurrency(source)
|
|
954
|
+
? undefined
|
|
955
|
+
: getManualPaymentAttemptMode(source, settlementCurrency),
|
|
956
|
+
source,
|
|
957
|
+
});
|
|
958
|
+
setRefundWallet(attempt.refund_to ?? "");
|
|
959
|
+
configureManualQuoteRefresh();
|
|
960
|
+
setRefundEditorExpanded(false);
|
|
961
|
+
setAcknowledgedWithTransition(true);
|
|
962
|
+
return true;
|
|
963
|
+
}
|
|
964
|
+
catch (error) {
|
|
965
|
+
console.error("Failed to create manual payment attempt:", error);
|
|
966
|
+
goToView("failed", { reason: getManualAttemptErrorMessage(error) });
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
finally {
|
|
970
|
+
setIsCreatingAttempt(false);
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
const selectNetwork = (network) => {
|
|
974
|
+
const shouldResetRefundWallet = shouldResetManualRefundWalletForSource(refundWallet, network);
|
|
975
|
+
const nextRefundWallet = shouldResetRefundWallet ? "" : manualRefundWallet;
|
|
976
|
+
setSelectedSourceKey(sourceKey(network));
|
|
977
|
+
setRefundWalletError(null);
|
|
978
|
+
setRefundEditorExpanded(false);
|
|
979
|
+
if (shouldResetRefundWallet) {
|
|
980
|
+
setRefundWallet("");
|
|
981
|
+
}
|
|
982
|
+
setCopiedAddress(false);
|
|
983
|
+
setCopiedAmount(false);
|
|
984
|
+
setShowQrCode(false);
|
|
985
|
+
void generateManualPaymentForSource(network, {
|
|
986
|
+
refundWallet: nextRefundWallet,
|
|
987
|
+
});
|
|
22
988
|
};
|
|
23
|
-
|
|
989
|
+
const copyToClipboard = async (value, setCopied) => {
|
|
990
|
+
try {
|
|
991
|
+
await navigator.clipboard.writeText(value);
|
|
992
|
+
setCopied(true);
|
|
993
|
+
setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds
|
|
994
|
+
}
|
|
995
|
+
catch (error) {
|
|
996
|
+
console.error("Failed to copy to clipboard:", error);
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
const renderManualPaymentPanel = (options) => (_jsxs(PaymentDetailsStack, { children: [options.showPaymentDetails ? (_jsx(QuoteExpiryCountdown, { remainingMs: countdownRemainingMs, totalDurationMs: countdownTotalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO })) : null, _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, refundEditing: refundEditorExpanded, isSaving: isCreatingAttempt, refundAddress: cryptoPaymentAttempt?.refund_to, paymentTerms: cryptoPaymentAttempt?.payment_terms_snapshot, refundValue: refundWallet, refundError: refundWalletError, onToggle: () => setPaymentDetailsExpanded((expanded) => !expanded), onBeginRefundEdit: () => {
|
|
1000
|
+
setPaymentDetailsExpanded(true);
|
|
1001
|
+
setRefundWallet(cryptoPaymentAttempt?.refund_to ?? "");
|
|
1002
|
+
setRefundWalletError(null);
|
|
1003
|
+
setRefundEditorExpanded(true);
|
|
1004
|
+
}, onSaveRefund: () => {
|
|
1005
|
+
if (!refundPreferenceChanged) {
|
|
1006
|
+
setRefundEditorExpanded(false);
|
|
1007
|
+
setRefundWalletError(null);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
void generateManualPaymentForSource(selectedSource);
|
|
1011
|
+
}, onRefundChange: (value) => {
|
|
1012
|
+
setRefundWallet(value);
|
|
1013
|
+
setRefundWalletError(null);
|
|
1014
|
+
} }), options.showPaymentDetails &&
|
|
1015
|
+
paymentAddress &&
|
|
1016
|
+
sendAmount &&
|
|
1017
|
+
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) => {
|
|
1018
|
+
console.error("Failed to copy address:", error);
|
|
1019
|
+
}), 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) => {
|
|
1020
|
+
console.error("Failed to copy address:", error);
|
|
1021
|
+
}), 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) => {
|
|
1022
|
+
console.error("Failed to copy amount:", error);
|
|
1023
|
+
}), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
|
|
1024
|
+
e.stopPropagation();
|
|
1025
|
+
copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1026
|
+
console.error("Failed to copy amount:", error);
|
|
1027
|
+
});
|
|
1028
|
+
}, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 15 })) : (_jsx(ClipboardAddIcon, { size: 15 })) })] })] })] })) : null] }));
|
|
1029
|
+
if (!hasAcknowledged) {
|
|
1030
|
+
if (manualSetupStep === "token") {
|
|
1031
|
+
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
|
|
1032
|
+
const hasFastRoute = tokenHasFastManualRoute(option);
|
|
1033
|
+
const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
|
|
1034
|
+
const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
|
|
1035
|
+
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)));
|
|
1036
|
+
}) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
|
|
1037
|
+
}
|
|
1038
|
+
if (manualSetupStep === "network") {
|
|
1039
|
+
const selectedTokenLabel = selectedTokenOption?.asset_name ?? sourceCurrency;
|
|
1040
|
+
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 &&
|
|
1041
|
+
sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
|
|
1042
|
+
}
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
if (!cryptoPaymentAttempt || !sendAmount || !copyAmount || !paymentAddress) {
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
return (_jsxs(ManualPaymentLayout, { ref: modalRef, children: [_jsx(ManualPaymentScrollArea, { children: renderManualPaymentPanel({ showPaymentDetails: true }) }), _jsxs(ManualPaymentActions, { children: [_jsx(StyledButton, { onClick: handleConfirm, variant: "primary", children: "I've sent the funds" }), _jsx(StyledButton, { onClick: handleBackToSourceSetup, variant: "secondary", children: "Back" })] })] }));
|
|
24
1049
|
};
|
|
25
|
-
export { CryptoIntentDirectDetailsViewContent };
|
|
1050
|
+
export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualChainIconUrl, getManualInstructionSource, shouldResetManualRefundWalletForSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
|
|
26
1051
|
//# sourceMappingURL=direct-details.js.map
|