@mintmoney/react 0.2.0-alpha.1 → 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/docs/customisation.md +8 -0
- 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 +78 -78
- 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 +315 -0
- package/dist/esm/checkout/providers/checkout-wallet.js.map +1 -0
- package/dist/esm/checkout/providers/wagmi-config.js +55 -49
- 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 +151 -13
- 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 +226 -887
- 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/methods.js +22 -123
- package/dist/esm/checkout/views/crypto-intent/methods.js.map +1 -1
- 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 -25
- 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/test-payment.js +11 -1
- package/dist/esm/checkout/views/crypto-intent/test-payment.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 +136 -1169
- 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 +7 -164
- 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 -41
- 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 +11 -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 +217 -226
- 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 +54 -0
- package/dist/esm/state/checkout/checkout-state.js.map +1 -0
- 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 +50 -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 +378 -0
- package/dist/esm/state/checkout/quote-lifecycle.js.map +1 -0
- 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 +350 -708
- package/dist/esm/state/checkout/store.js.map +1 -1
- package/dist/esm/state/checkout/wallet-payment-options.js +0 -32
- package/dist/esm/state/checkout/wallet-payment-options.js.map +1 -1
- package/dist/esm/state/checkout/wallet-payment.js +249 -0
- package/dist/esm/state/checkout/wallet-payment.js.map +1 -0
- 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 +4570 -695
- 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 +23 -0
- package/dist/types/checkout/providers/checkout-wallet.d.ts.map +1 -0
- package/dist/types/checkout/providers/wagmi-config.d.ts +8 -2
- 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 -4
- 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/methods.d.ts.map +1 -1
- 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/test-payment.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 +2 -2
- 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 +102 -0
- package/dist/types/state/checkout/checkout-state.d.ts.map +1 -0
- 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 +20 -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 +39 -0
- package/dist/types/state/checkout/quote-lifecycle.d.ts.map +1 -0
- 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 +38 -90
- package/dist/types/state/checkout/store.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-payment-options.d.ts +0 -16
- package/dist/types/state/checkout/wallet-payment-options.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-payment.d.ts +24 -0
- package/dist/types/state/checkout/wallet-payment.d.ts.map +1 -0
- 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/checkout/providers/wallet-connect-resume.js +0 -129
- package/dist/esm/checkout/providers/wallet-connect-resume.js.map +0 -1
- package/dist/esm/refund/confirmation.js +0 -30
- package/dist/esm/refund/confirmation.js.map +0 -1
- package/dist/types/checkout/providers/wallet-connect-resume.d.ts +0 -9
- package/dist/types/checkout/providers/wallet-connect-resume.d.ts.map +0 -1
- package/dist/types/refund/confirmation.d.ts +0 -14
- package/dist/types/refund/confirmation.d.ts.map +0 -1
package/dist/esm/refund/index.js
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useAppKit } from "@reown/appkit/react";
|
|
4
4
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
-
import { disconnect, sendTransaction, switchChain, } from "@wagmi/core";
|
|
5
|
+
import { disconnect, getTransaction, getTransactionCount, sendTransaction, switchChain, } from "@wagmi/core";
|
|
6
6
|
import { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { styled, ThemeProvider } from "styled-components";
|
|
8
8
|
import { useAccount, useConfig, WagmiProvider } from "wagmi";
|
|
9
|
+
import { getApiErrorCode } from "../api/errors.js";
|
|
9
10
|
import { confirmPaymentRefund, getPaymentRefundStatus, preparePaymentRefund, } from "../api/payments.js";
|
|
10
11
|
import { getAppKitWagmiConfig, } from "../checkout/providers/wagmi-config.js";
|
|
12
|
+
import { PaymentFundingTimeline } from "../checkout/views/funding-timeline.js";
|
|
11
13
|
import { StyledButton } from "../components/index.js";
|
|
12
14
|
import { WalletProvider } from "../components/wallet-selector/provider.js";
|
|
13
15
|
import { defaultTheme } from "../themes/default.js";
|
|
14
|
-
import {
|
|
16
|
+
import { formatShortAddress } from "../utils/string.js";
|
|
17
|
+
import { formatChainLabel, formatRefundAmount, transactionUrl, } from "../utils/token-amount.js";
|
|
15
18
|
import { buildRefundPrepareAttemptKey, claimRefundPrepareAttempt, normalizeComparableAddress, } from "./prepare-guard.js";
|
|
16
|
-
const shortAddress = (address) => `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
17
19
|
const REFUND_SELECTOR = "0x590e1ae3";
|
|
20
|
+
// Late deposits and claims reach the refund status through the chain scanner.
|
|
21
|
+
const REFUND_STATUS_REFRESH_MS = 15_000;
|
|
18
22
|
const Shell = styled.div `
|
|
19
23
|
width: 100%;
|
|
20
24
|
display: flex;
|
|
@@ -22,19 +26,6 @@ const Shell = styled.div `
|
|
|
22
26
|
gap: 18px;
|
|
23
27
|
text-align: center;
|
|
24
28
|
`;
|
|
25
|
-
const StatusPill = styled.span `
|
|
26
|
-
display: inline-flex;
|
|
27
|
-
align-items: center;
|
|
28
|
-
align-self: center;
|
|
29
|
-
padding: 7px 14px;
|
|
30
|
-
border-radius: 999px;
|
|
31
|
-
background: rgba(24, 178, 138, 0.16);
|
|
32
|
-
color: #68e1c0;
|
|
33
|
-
font-size: 11px;
|
|
34
|
-
font-weight: 700;
|
|
35
|
-
letter-spacing: 0.08em;
|
|
36
|
-
text-transform: uppercase;
|
|
37
|
-
`;
|
|
38
29
|
const BalancePanel = styled.div `
|
|
39
30
|
padding: 18px;
|
|
40
31
|
border-radius: 16px;
|
|
@@ -56,35 +47,6 @@ const BalanceValue = styled.div `
|
|
|
56
47
|
font-weight: 800;
|
|
57
48
|
overflow-wrap: anywhere;
|
|
58
49
|
`;
|
|
59
|
-
const Details = styled.div `
|
|
60
|
-
display: flex;
|
|
61
|
-
flex-direction: column;
|
|
62
|
-
border: 1px solid rgba(148, 163, 184, 0.18);
|
|
63
|
-
border-radius: 14px;
|
|
64
|
-
overflow: hidden;
|
|
65
|
-
`;
|
|
66
|
-
const DetailRow = styled.div `
|
|
67
|
-
display: flex;
|
|
68
|
-
justify-content: space-between;
|
|
69
|
-
gap: 16px;
|
|
70
|
-
padding: 14px 16px;
|
|
71
|
-
border-bottom: 1px solid rgba(148, 163, 184, 0.18);
|
|
72
|
-
color: #9aa3b5;
|
|
73
|
-
font-size: 14px;
|
|
74
|
-
text-align: left;
|
|
75
|
-
background: rgba(17, 24, 39, 0.62);
|
|
76
|
-
|
|
77
|
-
strong {
|
|
78
|
-
color: #edf1f7;
|
|
79
|
-
font-weight: 600;
|
|
80
|
-
text-align: right;
|
|
81
|
-
word-break: break-word;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&:last-child {
|
|
85
|
-
border-bottom: none;
|
|
86
|
-
}
|
|
87
|
-
`;
|
|
88
50
|
const ErrorText = styled.p `
|
|
89
51
|
margin: 0;
|
|
90
52
|
color: #d94b4b;
|
|
@@ -137,12 +99,14 @@ const Actions = styled.div `
|
|
|
137
99
|
gap: 10px;
|
|
138
100
|
`;
|
|
139
101
|
const Page = styled.div `
|
|
140
|
-
|
|
141
|
-
|
|
102
|
+
height: 100vh;
|
|
103
|
+
height: 100dvh;
|
|
104
|
+
overflow-y: auto;
|
|
105
|
+
overscroll-behavior: contain;
|
|
106
|
+
padding: 72px 20px 32px;
|
|
142
107
|
display: flex;
|
|
143
108
|
flex-direction: column;
|
|
144
109
|
align-items: center;
|
|
145
|
-
justify-content: center;
|
|
146
110
|
gap: 24px;
|
|
147
111
|
position: relative;
|
|
148
112
|
background: #0b0e16;
|
|
@@ -165,7 +129,8 @@ const PageMain = styled.main `
|
|
|
165
129
|
display: flex;
|
|
166
130
|
align-items: center;
|
|
167
131
|
justify-content: center;
|
|
168
|
-
|
|
132
|
+
flex: 0 0 auto;
|
|
133
|
+
margin-block: auto;
|
|
169
134
|
width: 100%;
|
|
170
135
|
`;
|
|
171
136
|
const PageCard = styled.div `
|
|
@@ -195,81 +160,13 @@ function caip2ToChainId(caip2) {
|
|
|
195
160
|
function isSubmittedRefundTxHash(value) {
|
|
196
161
|
return /^(?:0x)?[0-9a-fA-F]{64}$/.test(value);
|
|
197
162
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return "Base";
|
|
206
|
-
if (chain === "eip155:84532")
|
|
207
|
-
return "Base Sepolia";
|
|
208
|
-
return chain;
|
|
209
|
-
}
|
|
210
|
-
function formatTokenLabel(token) {
|
|
211
|
-
if (/\/(native|slip44:60)$/.test(token))
|
|
212
|
-
return "ETH";
|
|
213
|
-
const erc20Match = /\/erc20:(0x[a-fA-F0-9]{40})$/.exec(token);
|
|
214
|
-
if (!erc20Match)
|
|
215
|
-
return token;
|
|
216
|
-
const address = erc20Match[1];
|
|
217
|
-
if (address.toLowerCase() === "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913") {
|
|
218
|
-
return "USDC";
|
|
219
|
-
}
|
|
220
|
-
return `ERC-20 ${shortAddress(address)}`;
|
|
221
|
-
}
|
|
222
|
-
function transactionUrl(chain, transactionHash) {
|
|
223
|
-
if (chain === "eip155:8453")
|
|
224
|
-
return `https://basescan.org/tx/${transactionHash}`;
|
|
225
|
-
if (chain === "eip155:84532")
|
|
226
|
-
return `https://sepolia.basescan.org/tx/${transactionHash}`;
|
|
227
|
-
if (chain === "eip155:1")
|
|
228
|
-
return `https://etherscan.io/tx/${transactionHash}`;
|
|
229
|
-
if (chain === "eip155:11155111")
|
|
230
|
-
return `https://sepolia.etherscan.io/tx/${transactionHash}`;
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
function tokenDecimals(refundStatus) {
|
|
234
|
-
if (refundStatus.token_decimals !== null)
|
|
235
|
-
return refundStatus.token_decimals;
|
|
236
|
-
const token = refundStatus.token;
|
|
237
|
-
if (/\/(native|slip44:60)$/.test(token))
|
|
238
|
-
return 18;
|
|
239
|
-
const erc20Match = /\/erc20:(0x[a-fA-F0-9]{40})$/.exec(token);
|
|
240
|
-
if (!erc20Match)
|
|
241
|
-
return 18;
|
|
242
|
-
const address = erc20Match[1];
|
|
243
|
-
if (address.toLowerCase() === "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913") {
|
|
244
|
-
return 6;
|
|
245
|
-
}
|
|
246
|
-
return 18;
|
|
247
|
-
}
|
|
248
|
-
function formatTokenAmount(rawAmount, decimals) {
|
|
249
|
-
let amount;
|
|
250
|
-
try {
|
|
251
|
-
amount = BigInt(rawAmount);
|
|
252
|
-
}
|
|
253
|
-
catch {
|
|
254
|
-
return rawAmount;
|
|
255
|
-
}
|
|
256
|
-
const negative = amount < 0n;
|
|
257
|
-
const value = negative ? -amount : amount;
|
|
258
|
-
const divisor = 10n ** BigInt(decimals);
|
|
259
|
-
const whole = value / divisor;
|
|
260
|
-
const fraction = value % divisor;
|
|
261
|
-
if (decimals === 0)
|
|
262
|
-
return `${negative ? "-" : ""}${whole.toString()}`;
|
|
263
|
-
const fractionText = fraction
|
|
264
|
-
.toString()
|
|
265
|
-
.padStart(decimals, "0")
|
|
266
|
-
.slice(0, 6)
|
|
267
|
-
.replace(/0+$/, "");
|
|
268
|
-
const displayFraction = fractionText.padEnd(2, "0");
|
|
269
|
-
return `${negative ? "-" : ""}${whole.toString()}.${displayFraction}`;
|
|
270
|
-
}
|
|
271
|
-
function formatRefundAmount(refundStatus) {
|
|
272
|
-
return `${formatTokenAmount(refundStatus.current_refundable_balance, tokenDecimals(refundStatus))} ${formatTokenLabel(refundStatus.token)}`;
|
|
163
|
+
function isRecordedRefund(status, hash) {
|
|
164
|
+
const normalized = hash.toLowerCase().replace(/^0x/, "");
|
|
165
|
+
return (status.refund_transaction_hash?.toLowerCase().replace(/^0x/, "") ===
|
|
166
|
+
normalized ||
|
|
167
|
+
(status.timeline?.items.some((item) => item.kind === "claim" &&
|
|
168
|
+
item.transaction_hash.toLowerCase().replace(/^0x/, "") === normalized) ??
|
|
169
|
+
false));
|
|
273
170
|
}
|
|
274
171
|
function refundUnlockDate(refundStatus) {
|
|
275
172
|
if (!refundStatus || refundStatus.payment_status === "paid")
|
|
@@ -296,7 +193,17 @@ function readSubmittedRefundTx(paymentId, attemptId) {
|
|
|
296
193
|
if (typeof parsed.hash === "string" &&
|
|
297
194
|
isSubmittedRefundTxHash(parsed.hash) &&
|
|
298
195
|
typeof parsed.submittedAt === "number") {
|
|
299
|
-
|
|
196
|
+
const { hash, submittedAt, identity } = parsed;
|
|
197
|
+
return {
|
|
198
|
+
hash,
|
|
199
|
+
submittedAt,
|
|
200
|
+
...(typeof identity?.from === "string" &&
|
|
201
|
+
/^0x[0-9a-f]{40}$/i.test(identity.from) &&
|
|
202
|
+
Number.isSafeInteger(identity.nonce) &&
|
|
203
|
+
identity.nonce >= 0
|
|
204
|
+
? { identity }
|
|
205
|
+
: {}),
|
|
206
|
+
};
|
|
300
207
|
}
|
|
301
208
|
}
|
|
302
209
|
catch {
|
|
@@ -304,17 +211,43 @@ function readSubmittedRefundTx(paymentId, attemptId) {
|
|
|
304
211
|
}
|
|
305
212
|
return null;
|
|
306
213
|
}
|
|
307
|
-
function writeSubmittedRefundTx(paymentId, attemptId,
|
|
214
|
+
function writeSubmittedRefundTx(paymentId, attemptId, submission) {
|
|
308
215
|
if (typeof window === "undefined")
|
|
309
216
|
return;
|
|
310
|
-
window.sessionStorage.setItem(refundSubmittedTxStorageKey(paymentId, attemptId), JSON.stringify(
|
|
217
|
+
window.sessionStorage.setItem(refundSubmittedTxStorageKey(paymentId, attemptId), JSON.stringify(submission));
|
|
311
218
|
}
|
|
312
219
|
function clearSubmittedRefundTx(paymentId, attemptId) {
|
|
313
220
|
if (typeof window === "undefined")
|
|
314
221
|
return;
|
|
315
222
|
window.sessionStorage.removeItem(refundSubmittedTxStorageKey(paymentId, attemptId));
|
|
316
223
|
}
|
|
317
|
-
|
|
224
|
+
async function reconcileRefundReplacement(config, status, submission) {
|
|
225
|
+
const chainId = caip2ToChainId(status.settlement_chain);
|
|
226
|
+
if (!chainId)
|
|
227
|
+
return { submission, replaced: false };
|
|
228
|
+
const lookup = (hash) => getTransaction(config, {
|
|
229
|
+
chainId,
|
|
230
|
+
hash: `0x${hash.replace(/^0x/i, "")}`,
|
|
231
|
+
}).catch(() => null);
|
|
232
|
+
// Keep the original sender and nonce even if the RPC forgets its hash after
|
|
233
|
+
// a speed-up. A different claim only resolves this submission if it used
|
|
234
|
+
// that same nonce, which makes it impossible for the original to mine too.
|
|
235
|
+
const original = submission.identity ?? (await lookup(submission.hash));
|
|
236
|
+
if (!original)
|
|
237
|
+
return { submission, replaced: false };
|
|
238
|
+
const identity = { from: original.from, nonce: original.nonce };
|
|
239
|
+
const confirmedHash = status.refund_transaction_hash;
|
|
240
|
+
const replacement = confirmedHash && isSubmittedRefundTxHash(confirmedHash)
|
|
241
|
+
? await lookup(confirmedHash)
|
|
242
|
+
: null;
|
|
243
|
+
return {
|
|
244
|
+
submission: { ...submission, identity },
|
|
245
|
+
replaced: Boolean(replacement?.blockNumber != null) &&
|
|
246
|
+
replacement?.from.toLowerCase() === identity.from.toLowerCase() &&
|
|
247
|
+
replacement?.nonce === identity.nonce,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
async function submitRefund(refundStatus, { address, wagmiConfig, }) {
|
|
318
251
|
if (!address) {
|
|
319
252
|
throw new Error("No wallet account connected.");
|
|
320
253
|
}
|
|
@@ -323,7 +256,7 @@ export async function claimPaymentRefund(refundStatus, { address, wagmiConfig, }
|
|
|
323
256
|
if (refundStatus.refund_to &&
|
|
324
257
|
normalizeComparableAddress(refundStatus.settlement_chain, address) !==
|
|
325
258
|
normalizeComparableAddress(refundStatus.settlement_chain, refundStatus.refund_to)) {
|
|
326
|
-
throw new Error(`Connected wallet ${
|
|
259
|
+
throw new Error(`Connected wallet ${formatShortAddress(address)} is not the refund recipient. Connect ${formatShortAddress(refundStatus.refund_to)} and try again.`);
|
|
327
260
|
}
|
|
328
261
|
const chainId = caip2ToChainId(refundStatus.settlement_chain);
|
|
329
262
|
if (!chainId) {
|
|
@@ -335,11 +268,25 @@ export async function claimPaymentRefund(refundStatus, { address, wagmiConfig, }
|
|
|
335
268
|
catch {
|
|
336
269
|
throw new Error(`Refunds are claimed on the merchant settlement chain (${refundStatus.settlement_chain}). Switch your wallet to that network and try again.`);
|
|
337
270
|
}
|
|
271
|
+
const from = address;
|
|
272
|
+
// The original hash may already be gone when the wallet returns control.
|
|
273
|
+
// Set the nonce on the send itself so a speed-up can still be identified.
|
|
274
|
+
const nonce = await getTransactionCount(wagmiConfig, {
|
|
275
|
+
address: from,
|
|
276
|
+
chainId,
|
|
277
|
+
blockTag: "pending",
|
|
278
|
+
});
|
|
338
279
|
const transactionHash = await sendTransaction(wagmiConfig, {
|
|
339
|
-
account:
|
|
280
|
+
account: from,
|
|
281
|
+
chainId,
|
|
282
|
+
nonce,
|
|
340
283
|
to: refundStatus.splitter_address,
|
|
341
284
|
data: REFUND_SELECTOR,
|
|
342
285
|
});
|
|
286
|
+
return { transactionHash, identity: { from, nonce } };
|
|
287
|
+
}
|
|
288
|
+
export async function claimPaymentRefund(refundStatus, wallet) {
|
|
289
|
+
const { transactionHash } = await submitRefund(refundStatus, wallet);
|
|
343
290
|
return { transactionHash };
|
|
344
291
|
}
|
|
345
292
|
export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
|
|
@@ -351,64 +298,101 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
|
|
|
351
298
|
const [busy, setBusy] = useState(false);
|
|
352
299
|
const [preparing, setPreparing] = useState(false);
|
|
353
300
|
const [error, setError] = useState(null);
|
|
354
|
-
const [
|
|
301
|
+
const [submittedClaim, setSubmittedClaim] = useState(null);
|
|
355
302
|
const [claimedAmountLabel, setClaimedAmountLabel] = useState(null);
|
|
356
303
|
const attemptedPrepareKeys = useRef(new Set());
|
|
357
304
|
const connectedAddress = account.address ?? null;
|
|
358
|
-
|
|
305
|
+
useEffect(() => {
|
|
359
306
|
setLoading(true);
|
|
360
307
|
setError(null);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (Date.now() - submittedTx.submittedAt > 120_000) {
|
|
308
|
+
}, [apiUrl, paymentId, attemptId, connectedAddress]);
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
if (busy || preparing)
|
|
311
|
+
return;
|
|
312
|
+
const request = new AbortController();
|
|
313
|
+
let timer;
|
|
314
|
+
const options = {
|
|
315
|
+
attemptId,
|
|
316
|
+
apiUrl,
|
|
317
|
+
connectedAddress: connectedAddress ?? undefined,
|
|
318
|
+
signal: request.signal,
|
|
319
|
+
};
|
|
320
|
+
const poll = async () => {
|
|
321
|
+
try {
|
|
322
|
+
let status = await getPaymentRefundStatus(paymentId, options);
|
|
323
|
+
if (request.signal.aborted)
|
|
324
|
+
return;
|
|
325
|
+
const submitted = readSubmittedRefundTx(paymentId, status.attempt_id);
|
|
326
|
+
let hash = submitted?.hash ?? null;
|
|
327
|
+
if (hash && !isRecordedRefund(status, hash)) {
|
|
382
328
|
try {
|
|
383
|
-
|
|
384
|
-
|
|
329
|
+
status = await confirmPaymentRefund(paymentId, {
|
|
330
|
+
...options,
|
|
385
331
|
attemptId: status.attempt_id,
|
|
386
|
-
|
|
387
|
-
apiUrl,
|
|
332
|
+
transactionHash: hash,
|
|
388
333
|
});
|
|
389
|
-
|
|
390
|
-
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
if (request.signal.aborted)
|
|
337
|
+
return;
|
|
338
|
+
if (getApiErrorCode(error) === "REFUND_TRANSACTION_REVERTED") {
|
|
391
339
|
clearSubmittedRefundTx(paymentId, status.attempt_id);
|
|
340
|
+
hash = null;
|
|
341
|
+
setError("The refund transaction reverted. You can try again.");
|
|
392
342
|
}
|
|
393
343
|
}
|
|
394
|
-
|
|
344
|
+
}
|
|
345
|
+
if (request.signal.aborted)
|
|
346
|
+
return;
|
|
347
|
+
if (hash && submitted) {
|
|
348
|
+
const recorded = isRecordedRefund(status, hash);
|
|
349
|
+
const reconciled = recorded
|
|
350
|
+
? null
|
|
351
|
+
: await reconcileRefundReplacement(wagmiConfig, status, submitted);
|
|
352
|
+
if (request.signal.aborted)
|
|
353
|
+
return;
|
|
354
|
+
if (recorded || reconciled?.replaced) {
|
|
395
355
|
clearSubmittedRefundTx(paymentId, status.attempt_id);
|
|
396
|
-
|
|
397
|
-
|
|
356
|
+
hash = null;
|
|
357
|
+
}
|
|
358
|
+
else if (!submitted.identity && reconciled?.submission.identity) {
|
|
359
|
+
writeSubmittedRefundTx(paymentId, status.attempt_id, reconciled.submission);
|
|
398
360
|
}
|
|
399
361
|
}
|
|
362
|
+
setRefundStatus(status);
|
|
363
|
+
setSubmittedClaim(hash ? { attemptId: status.attempt_id, hash } : null);
|
|
364
|
+
setClaimedAmountLabel(window.sessionStorage.getItem(refundClaimedAmountStorageKey(paymentId, status.attempt_id)));
|
|
400
365
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
366
|
+
catch (err) {
|
|
367
|
+
if (request.signal.aborted)
|
|
368
|
+
return;
|
|
369
|
+
setError(err instanceof Error ? err.message : "Unable to load refund status.");
|
|
370
|
+
}
|
|
371
|
+
finally {
|
|
372
|
+
if (!request.signal.aborted) {
|
|
373
|
+
setLoading(false);
|
|
374
|
+
timer = setTimeout(poll, REFUND_STATUS_REFRESH_MS);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
void poll();
|
|
379
|
+
return () => {
|
|
380
|
+
request.abort();
|
|
381
|
+
clearTimeout(timer);
|
|
382
|
+
};
|
|
383
|
+
}, [
|
|
384
|
+
apiUrl,
|
|
385
|
+
attemptId,
|
|
386
|
+
busy,
|
|
387
|
+
connectedAddress,
|
|
388
|
+
paymentId,
|
|
389
|
+
preparing,
|
|
390
|
+
wagmiConfig,
|
|
391
|
+
]);
|
|
392
|
+
const submittedHash = refundStatus?.payment_id === paymentId &&
|
|
393
|
+
refundStatus.attempt_id === submittedClaim?.attemptId
|
|
394
|
+
? submittedClaim.hash
|
|
395
|
+
: null;
|
|
412
396
|
const connectWallet = async () => {
|
|
413
397
|
setError(null);
|
|
414
398
|
await open({ view: "Connect" });
|
|
@@ -416,7 +400,6 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
|
|
|
416
400
|
const useAnotherWallet = async () => {
|
|
417
401
|
setBusy(true);
|
|
418
402
|
setError(null);
|
|
419
|
-
setTxHash(null);
|
|
420
403
|
try {
|
|
421
404
|
await disconnect(wagmiConfig);
|
|
422
405
|
}
|
|
@@ -486,20 +469,19 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
|
|
|
486
469
|
await connectWallet();
|
|
487
470
|
return;
|
|
488
471
|
}
|
|
489
|
-
const result = await
|
|
472
|
+
const result = await submitRefund(refundStatus, {
|
|
490
473
|
address: connectedAddress,
|
|
491
474
|
wagmiConfig,
|
|
492
475
|
});
|
|
493
|
-
|
|
494
|
-
writeSubmittedRefundTx(paymentId, refundStatus.attempt_id, result.transactionHash);
|
|
495
|
-
const recorded = await waitForRefundConfirmation(paymentId, {
|
|
496
|
-
transactionHash: result.transactionHash,
|
|
476
|
+
setSubmittedClaim({
|
|
497
477
|
attemptId: refundStatus.attempt_id,
|
|
498
|
-
|
|
499
|
-
|
|
478
|
+
hash: result.transactionHash,
|
|
479
|
+
});
|
|
480
|
+
writeSubmittedRefundTx(paymentId, refundStatus.attempt_id, {
|
|
481
|
+
hash: result.transactionHash,
|
|
482
|
+
submittedAt: Date.now(),
|
|
483
|
+
identity: result.identity,
|
|
500
484
|
});
|
|
501
|
-
setRefundStatus(recorded);
|
|
502
|
-
clearSubmittedRefundTx(paymentId, refundStatus.attempt_id);
|
|
503
485
|
}
|
|
504
486
|
catch (err) {
|
|
505
487
|
setError(err instanceof Error ? err.message : "Refund transaction failed.");
|
|
@@ -531,62 +513,71 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
|
|
|
531
513
|
Boolean(refundStatus &&
|
|
532
514
|
["refund_available", "surplus_available"].includes(refundStatus.attempt_status));
|
|
533
515
|
const isRefundUnavailable = Boolean(refundStatus) && !isClaimed && !hasRefundableBalance;
|
|
516
|
+
const refundPending = hasRefundableBalance &&
|
|
517
|
+
!["refund_available", "surplus_available"].includes(refundStatus?.attempt_status ?? "");
|
|
518
|
+
const isSurplus = refundStatus?.attempt_status === "surplus_available";
|
|
519
|
+
const isSubmitted = Boolean(submittedHash) && !isClaimed;
|
|
534
520
|
const balanceLabel = isClaimed
|
|
535
|
-
? "
|
|
536
|
-
:
|
|
537
|
-
? "
|
|
538
|
-
: "
|
|
539
|
-
const balanceValue =
|
|
540
|
-
?
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
521
|
+
? "Amount returned"
|
|
522
|
+
: refundPending
|
|
523
|
+
? "Amount received"
|
|
524
|
+
: "Amount available";
|
|
525
|
+
const balanceValue = isClaimed
|
|
526
|
+
? claimedAmountLabel
|
|
527
|
+
: refundStatus && hasRefundableBalance
|
|
528
|
+
? formatRefundAmount(refundStatus)
|
|
529
|
+
: null;
|
|
530
|
+
const transactionHash = isClaimed
|
|
531
|
+
? refundStatus.refund_transaction_hash
|
|
532
|
+
: isSubmitted
|
|
533
|
+
? submittedHash
|
|
534
|
+
: null;
|
|
535
|
+
const explorerUrl = refundStatus && transactionHash
|
|
536
|
+
? transactionUrl(refundStatus.settlement_chain, transactionHash)
|
|
547
537
|
: null;
|
|
548
|
-
const isSubmitted = Boolean(txHash) && !isClaimed;
|
|
549
538
|
const claimedAtLabel = refundStatus?.refund_claimed_at
|
|
550
539
|
? new Date(refundStatus.refund_claimed_at).toLocaleString()
|
|
551
540
|
: null;
|
|
552
|
-
return (_jsxs(Shell, { className: className, children: [_jsx(
|
|
553
|
-
? "Refund
|
|
554
|
-
:
|
|
555
|
-
? "Refund
|
|
556
|
-
:
|
|
557
|
-
? "Refund
|
|
558
|
-
:
|
|
559
|
-
?
|
|
560
|
-
:
|
|
561
|
-
|
|
562
|
-
|
|
541
|
+
return (_jsxs(Shell, { className: className, children: [_jsx(TitleText, { children: !refundStatus
|
|
542
|
+
? "Refund"
|
|
543
|
+
: isClaimed
|
|
544
|
+
? "Refund claimed"
|
|
545
|
+
: isSubmitted
|
|
546
|
+
? "Refund submitted"
|
|
547
|
+
: isRefundUnavailable
|
|
548
|
+
? "Refund unavailable"
|
|
549
|
+
: refundPending || waitingForRefundWindow
|
|
550
|
+
? "Refund pending"
|
|
551
|
+
: isSurplus
|
|
552
|
+
? "Surplus available"
|
|
553
|
+
: "Refund available" }), loading ? _jsx(SubtleText, { children: "Loading refund details\u2026" }) : null, refundStatus ? (_jsxs(_Fragment, { children: [balanceValue ? (_jsxs(BalancePanel, { children: [_jsx(BalanceLabel, { children: balanceLabel }), _jsx(BalanceValue, { children: balanceValue })] })) : null, _jsx(SubtleText, { children: formatChainLabel(refundStatus.settlement_chain) }), isClaimed ? (_jsxs(HelperText, { children: ["Returned to", " ", refundStatus.refund_to
|
|
554
|
+
? formatShortAddress(refundStatus.refund_to)
|
|
555
|
+
: "the refund wallet", claimedAtLabel ? ` on ${claimedAtLabel}` : "", "."] })) : isSubmitted ? (_jsx(HelperText, { children: "This page will update once the network confirms your transaction." })) : refundPending ? (_jsx(HelperText, { children: refundStatus.funding?.settlement_cutoff_at &&
|
|
556
|
+
Date.parse(refundStatus.funding.settlement_cutoff_at) > Date.now()
|
|
557
|
+
? "You can send the rest from your original payment link."
|
|
558
|
+
: "This page will update when the refund is available." })) : !hasRefundableBalance ? (_jsx(HelperText, { children: "There\u2019s no refundable balance for this payment." })) : !refundRecipient ? (_jsx(HelperText, { children: "This attempt needs merchant recovery before a refund can be claimed." })) : connectedAddress && !connectedMatchesRefundRecipient ? (_jsxs(HelperText, { children: ["Connected wallet ", formatShortAddress(connectedAddress), " is not the refund recipient. Connect ", formatShortAddress(refundRecipient), " to claim."] })) : connectedMatchesRefundRecipient ? (_jsx(HelperText, { children: waitingForRefundWindow
|
|
563
559
|
? `Refunds can be claimed after ${refundAvailableAt?.toLocaleString()} if this payment does not settle.`
|
|
564
560
|
: needsRefundSetup
|
|
565
|
-
?
|
|
566
|
-
|
|
567
|
-
: "Prepare the refund contract before claiming."
|
|
568
|
-
: `Connected refund wallet ${shortAddress(refundRecipient)} can claim this refund.` })) : (_jsxs(HelperText, { children: ["Connect refund wallet ", shortAddress(refundRecipient), " to claim."] }))] })) : null, error ? _jsx(ErrorText, { children: error }) : null, isClaimed && recordedTxHash ? (_jsxs(SuccessText, { children: ["Refund transaction:", " ", recordedTxUrl ? (_jsx(TransactionLink, { href: recordedTxUrl, target: "_blank", rel: "noreferrer", children: recordedTxHash })) : (recordedTxHash)] })) : txHash ? (_jsxs(SuccessText, { children: ["Refund transaction submitted:", " ", refundStatus &&
|
|
569
|
-
transactionUrl(refundStatus.settlement_chain, txHash) ? (_jsx(TransactionLink, { href: transactionUrl(refundStatus.settlement_chain, txHash) ??
|
|
570
|
-
undefined, target: "_blank", rel: "noreferrer", children: txHash })) : (txHash)] })) : null, isClaimed ||
|
|
561
|
+
? "Set up this wallet on the settlement network to continue."
|
|
562
|
+
: `Connected as ${formatShortAddress(refundRecipient)}.` })) : (_jsxs(HelperText, { children: ["Connect refund wallet ", formatShortAddress(refundRecipient), " to claim."] }))] })) : null, error ? _jsx(ErrorText, { children: error }) : null, transactionHash ? (_jsx(SuccessText, { children: explorerUrl ? (_jsx(TransactionLink, { href: explorerUrl, target: "_blank", rel: "noreferrer", title: transactionHash, children: "View transaction" })) : (transactionHash) })) : null, isClaimed ||
|
|
571
563
|
isRefundUnavailable ||
|
|
564
|
+
refundPending ||
|
|
565
|
+
waitingForRefundWindow ||
|
|
572
566
|
isSubmitted ? null : !connectedAddress ? (_jsx(Actions, { children: _jsx(StyledButton, { onClick: () => void connectWallet(), disabled: busy, children: "Connect wallet" }) })) : (_jsxs(Actions, { children: [_jsx(StyledButton, { onClick: () => {
|
|
573
567
|
if (needsRefundSetup) {
|
|
574
568
|
retryRefundSetup();
|
|
575
569
|
return;
|
|
576
570
|
}
|
|
577
571
|
void claimRefund();
|
|
578
|
-
}, disabled: busy ||
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
: busy
|
|
588
|
-
? "Submitting..."
|
|
589
|
-
: "Claim refund" }), !canClaim && !needsRefundSetup && !waitingForRefundWindow ? (_jsx(StyledButton, { variant: "secondary", onClick: () => void useAnotherWallet(), disabled: busy, children: "Use another wallet" })) : null] }))] }));
|
|
572
|
+
}, disabled: busy || preparing || (!canClaim && !needsRefundSetup), children: preparing
|
|
573
|
+
? "Preparing refund…"
|
|
574
|
+
: needsRefundSetup
|
|
575
|
+
? "Prepare refund"
|
|
576
|
+
: busy
|
|
577
|
+
? "Submitting…"
|
|
578
|
+
: isSurplus
|
|
579
|
+
? "Claim surplus"
|
|
580
|
+
: "Claim refund" }), !canClaim && !needsRefundSetup ? (_jsx(StyledButton, { variant: "secondary", onClick: () => void useAnotherWallet(), disabled: busy, children: "Use another wallet" })) : null] })), refundStatus ? (_jsx(PaymentFundingTimeline, { paymentId: paymentId, funding: refundStatus.funding, timeline: refundStatus.timeline, tokenSymbol: refundStatus.token_symbol, readKey: refundStatus, apiUrl: apiUrl }, refundStatus.attempt_id)) : null] }));
|
|
590
581
|
}
|
|
591
582
|
export function RefundClaimPage({ logoSrc = "/logo.svg", wagmiConfig, walletConnectProjectId, ...props }) {
|
|
592
583
|
const wagmi = useRef();
|
|
@@ -594,6 +585,6 @@ export function RefundClaimPage({ logoSrc = "/logo.svg", wagmiConfig, walletConn
|
|
|
594
585
|
if (!wagmi.current) {
|
|
595
586
|
wagmi.current = getAppKitWagmiConfig(walletConnectProjectId ?? "", defaultTheme, wagmiConfig);
|
|
596
587
|
}
|
|
597
|
-
return (_jsx(ThemeProvider, { theme: defaultTheme, children: _jsx(WalletProvider, { children: _jsx(QueryClientProvider, { client: queryClient.current, children: _jsx(WagmiProvider, { config: wagmi.current, reconnectOnMount:
|
|
588
|
+
return (_jsx(ThemeProvider, { theme: defaultTheme, children: _jsx(WalletProvider, { children: _jsx(QueryClientProvider, { client: queryClient.current, children: _jsx(WagmiProvider, { config: wagmi.current, reconnectOnMount: false, children: _jsxs(Page, { children: [_jsx(PageHeader, { children: _jsx(BrandMark, { src: logoSrc, alt: "Mint" }) }), _jsx(PageMain, { children: _jsx(PageCard, { children: _jsx(RefundClaim, { ...props }) }) })] }) }) }) }) }));
|
|
598
589
|
}
|
|
599
590
|
//# sourceMappingURL=index.js.map
|