@mintmoney/react 0.2.0-alpha.2 → 0.2.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/styles.css +12 -1
- package/dist/docs/customisation.md +4 -0
- package/dist/docs/quickstart.md +2 -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 +36 -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 +19 -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 +54 -13
- package/dist/esm/checkout/index.js.map +1 -1
- package/dist/esm/checkout/modal.js +52 -23
- package/dist/esm/checkout/modal.js.map +1 -1
- package/dist/esm/checkout/payment-status.js +68 -28
- package/dist/esm/checkout/payment-status.js.map +1 -1
- package/dist/esm/checkout/provider-status.js +9 -0
- package/dist/esm/checkout/provider-status.js.map +1 -0
- package/dist/esm/checkout/providers/checkout-wallet.js +140 -44
- package/dist/esm/checkout/providers/checkout-wallet.js.map +1 -1
- package/dist/esm/checkout/providers/wagmi-config.js +6 -3
- package/dist/esm/checkout/providers/wagmi-config.js.map +1 -1
- package/dist/esm/checkout/refund-notice.js +16 -0
- package/dist/esm/checkout/refund-notice.js.map +1 -0
- package/dist/esm/checkout/resume-state.js +207 -1
- 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 +11 -2
- package/dist/esm/checkout/views/amount-header.js.map +1 -1
- package/dist/esm/checkout/views/claimable-funds.js +21 -13
- package/dist/esm/checkout/views/claimable-funds.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/direct-details.js +288 -888
- package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js +239 -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 +309 -0
- package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-sources.js +155 -0
- package/dist/esm/checkout/views/crypto-intent/manual-sources.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js +84 -0
- package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/payment-route-error.js +10 -0
- package/dist/esm/checkout/views/crypto-intent/payment-route-error.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/processing.js +183 -32
- package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/success.js +74 -46
- package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js +14 -24
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js +61 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +105 -627
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js +506 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js.map +1 -0
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js +4 -11
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -1
- package/dist/esm/checkout/views/failed.js +44 -55
- package/dist/esm/checkout/views/failed.js.map +1 -1
- package/dist/esm/checkout/views/funding-timeline.js +182 -0
- package/dist/esm/checkout/views/funding-timeline.js.map +1 -0
- package/dist/esm/checkout/views/initial.js +35 -46
- 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 +128 -0
- package/dist/esm/checkout/views/payment-follower.js.map +1 -0
- package/dist/esm/checkout/views/restart.js +17 -2
- package/dist/esm/checkout/views/restart.js.map +1 -1
- package/dist/esm/checkout/views/use-checkout-refund-status.js +75 -0
- package/dist/esm/checkout/views/use-checkout-refund-status.js.map +1 -0
- 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 +8 -14
- 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 +36 -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 +134 -45
- package/dist/esm/integrations/lifi.js.map +1 -1
- package/dist/esm/refund/index.js +237 -227
- package/dist/esm/refund/index.js.map +1 -1
- package/dist/esm/state/checkout/bitcoin-payment.js +254 -0
- package/dist/esm/state/checkout/bitcoin-payment.js.map +1 -0
- package/dist/esm/state/checkout/checkout-state.js +5 -11
- package/dist/esm/state/checkout/checkout-state.js.map +1 -1
- package/dist/esm/state/checkout/funding.js +5 -0
- package/dist/esm/state/checkout/funding.js.map +1 -0
- package/dist/esm/state/checkout/issuance-conflicts.js +29 -0
- package/dist/esm/state/checkout/issuance-conflicts.js.map +1 -0
- package/dist/esm/state/checkout/manual-route.js +10 -0
- package/dist/esm/state/checkout/manual-route.js.map +1 -0
- package/dist/esm/state/checkout/payment-attempt.js +44 -20
- package/dist/esm/state/checkout/payment-attempt.js.map +1 -1
- package/dist/esm/state/checkout/payment-lifecycle.js +9 -15
- package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -1
- package/dist/esm/state/checkout/payment-observer.js +148 -0
- package/dist/esm/state/checkout/payment-observer.js.map +1 -0
- package/dist/esm/state/checkout/payment-phase.js +142 -0
- package/dist/esm/state/checkout/payment-phase.js.map +1 -0
- package/dist/esm/state/checkout/quote-countdown.js +26 -0
- package/dist/esm/state/checkout/quote-countdown.js.map +1 -0
- package/dist/esm/state/checkout/quote-lifecycle.js +145 -144
- package/dist/esm/state/checkout/quote-lifecycle.js.map +1 -1
- package/dist/esm/state/checkout/route-estimate.js +77 -0
- package/dist/esm/state/checkout/route-estimate.js.map +1 -0
- package/dist/esm/state/checkout/store.js +348 -313
- package/dist/esm/state/checkout/store.js.map +1 -1
- package/dist/esm/state/checkout/wallet-payment.js +334 -37
- package/dist/esm/state/checkout/wallet-payment.js.map +1 -1
- package/dist/esm/state/checkout/wallet-transfer-receipt.js +68 -0
- package/dist/esm/state/checkout/wallet-transfer-receipt.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 -707
- package/dist/types/api/generated.d.ts.map +1 -1
- package/dist/types/api/payments.d.ts +22 -2
- 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 +30 -2
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/checkout/claimable-funds.d.ts +12 -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 +23 -2
- package/dist/types/checkout/index.d.ts.map +1 -1
- package/dist/types/checkout/modal.d.ts +5 -2
- package/dist/types/checkout/modal.d.ts.map +1 -1
- package/dist/types/checkout/payment-status.d.ts +10 -2
- package/dist/types/checkout/payment-status.d.ts.map +1 -1
- package/dist/types/checkout/provider-status.d.ts +11 -0
- package/dist/types/checkout/provider-status.d.ts.map +1 -0
- package/dist/types/checkout/providers/checkout-wallet.d.ts +2 -3
- package/dist/types/checkout/providers/checkout-wallet.d.ts.map +1 -1
- package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -1
- package/dist/types/checkout/refund-notice.d.ts +7 -0
- package/dist/types/checkout/refund-notice.d.ts.map +1 -0
- package/dist/types/checkout/resume-state.d.ts +63 -1
- 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 +1 -0
- 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 +11 -0
- package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts +4 -11
- package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts +4 -0
- package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts +14 -10
- package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts +18 -0
- package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts +33 -0
- package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts +18 -0
- package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts +2 -0
- package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/processing.d.ts +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 +2 -1
- package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts +8 -8
- package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts +17 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts +2 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts +61 -0
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts.map +1 -0
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts +1 -2
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -1
- package/dist/types/checkout/views/failed.d.ts +6 -0
- package/dist/types/checkout/views/failed.d.ts.map +1 -1
- package/dist/types/checkout/views/funding-timeline.d.ts +21 -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 +12 -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/checkout/views/use-checkout-refund-status.d.ts +74 -0
- package/dist/types/checkout/views/use-checkout-refund-status.d.ts.map +1 -0
- 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 +3 -1
- 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 -1
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -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 +42 -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 +46 -13
- package/dist/types/state/checkout/checkout-state.d.ts.map +1 -1
- package/dist/types/state/checkout/funding.d.ts +6 -0
- package/dist/types/state/checkout/funding.d.ts.map +1 -0
- package/dist/types/state/checkout/issuance-conflicts.d.ts +22 -0
- package/dist/types/state/checkout/issuance-conflicts.d.ts.map +1 -0
- package/dist/types/state/checkout/manual-route.d.ts +13 -0
- package/dist/types/state/checkout/manual-route.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-attempt.d.ts +19 -1
- package/dist/types/state/checkout/payment-attempt.d.ts.map +1 -1
- package/dist/types/state/checkout/payment-lifecycle.d.ts +6 -8
- package/dist/types/state/checkout/payment-lifecycle.d.ts.map +1 -1
- package/dist/types/state/checkout/payment-observer.d.ts +42 -0
- package/dist/types/state/checkout/payment-observer.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-phase.d.ts +118 -0
- package/dist/types/state/checkout/payment-phase.d.ts.map +1 -0
- package/dist/types/state/checkout/quote-countdown.d.ts +15 -0
- package/dist/types/state/checkout/quote-countdown.d.ts.map +1 -0
- package/dist/types/state/checkout/quote-lifecycle.d.ts +17 -6
- package/dist/types/state/checkout/quote-lifecycle.d.ts.map +1 -1
- package/dist/types/state/checkout/route-estimate.d.ts +38 -0
- package/dist/types/state/checkout/route-estimate.d.ts.map +1 -0
- package/dist/types/state/checkout/store.d.ts +35 -15
- package/dist/types/state/checkout/store.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-payment.d.ts +15 -2
- package/dist/types/state/checkout/wallet-payment.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-transfer-receipt.d.ts +18 -0
- package/dist/types/state/checkout/wallet-transfer-receipt.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/refund/confirmation.js +0 -30
- package/dist/esm/refund/confirmation.js.map +0 -1
- package/dist/types/refund/confirmation.d.ts +0 -14
- package/dist/types/refund/confirmation.d.ts.map +0 -1
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { waitForTransactionReceipt } from "@wagmi/core";
|
|
2
1
|
import { create } from "zustand";
|
|
3
2
|
import { immer } from "zustand/middleware/immer";
|
|
4
3
|
import { getCheckoutCryptoCurrencies } from "../../api/checkouts.js";
|
|
5
|
-
import {
|
|
4
|
+
import { CheckoutRequestError, describeRequestFailure, getCryptoPayConflictCode, withConflictCopy, } from "../../api/errors.js";
|
|
5
|
+
import { createPaymentAttempt, createTestPaymentAttempt, estimateCryptoPay, findDepositInTimelinePages, getPaymentById, getRequiredSettlementConfig, hasConfirmedDeposit, } from "../../api/payments.js";
|
|
6
6
|
import { PaymentStatus, } from "../../api/types.js";
|
|
7
|
-
import {
|
|
7
|
+
import { readCheckoutResumeState, writeCheckoutResumeState, } from "../../checkout/resume-state.js";
|
|
8
|
+
import { BITCOIN_CHAIN } from "../../integrations/bitcoin-source.js";
|
|
8
9
|
import { resolveEvmChainId, switchEvmWalletChain, } from "../../integrations/evm-chain.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
10
|
+
import { assertNoUncertainBitcoinSend, getUncertainBitcoinSend, isReturnedBitcoinRoute, observeBitcoinRecovery, retryBitcoinBroadcast, } from "./bitcoin-payment.js";
|
|
11
|
+
import { ACTIONS, createInitialCheckoutState, initialWalletPaymentState, } from "./checkout-state.js";
|
|
12
|
+
import { createIssuanceConflictRecovery } from "./issuance-conflicts.js";
|
|
13
|
+
import { buildManualRoutePayload, buildWalletEstimatePayload, buildWalletPaymentAttemptPayload, } from "./payment-attempt.js";
|
|
14
|
+
import { canCreateFreshAttempt, isAttemptStale, PAYMENT_NO_LONGER_PAYABLE_MESSAGE, } from "./payment-lifecycle.js";
|
|
15
|
+
import { createPaymentObserver } from "./payment-observer.js";
|
|
16
|
+
import { derivePaymentPhase } from "./payment-phase.js";
|
|
17
|
+
import { createQuoteLifecycle, } from "./quote-lifecycle.js";
|
|
18
|
+
import { buildDirectWalletQuote, buildWalletQuoteTarget, priceBitcoinWalletEstimate, priceEstimate, } from "./route-estimate.js";
|
|
14
19
|
export { ACTIONS } from "./checkout-state.js";
|
|
15
20
|
export const useCheckoutStore = create()(immer(() => createInitialCheckoutState()));
|
|
16
21
|
const set = (fn) => {
|
|
@@ -40,59 +45,108 @@ const quoteLifecycle = createQuoteLifecycle({
|
|
|
40
45
|
get,
|
|
41
46
|
set,
|
|
42
47
|
captureOpening: captureCheckoutOpening,
|
|
43
|
-
|
|
48
|
+
priceWalletRoute: (...args) => priceWalletRoute(...args),
|
|
44
49
|
createManualAttempt: (...args) => createManualDirectPaymentAttempt(...args),
|
|
45
50
|
});
|
|
46
|
-
export const { refreshQuote, syncQuote,
|
|
51
|
+
export const { refreshQuote, syncQuote, configureManualQuoteRefresh, prepareWalletQuoteReplacement, clearQuoteRefresh, loadWalletPaymentQuote, setWalletPaymentOptions, resetWalletPaymentState, beginBitcoinWalletPreparation, setWalletPaymentQuote, } = quoteLifecycle;
|
|
47
52
|
const getCurrentCheckoutAttempt = (state = get()) => {
|
|
48
53
|
return state.cryptoPaymentAttempt ?? state.payment?.payment_attempt ?? null;
|
|
49
54
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return null;
|
|
64
|
-
return normalizeWalletAddress(attempt.refund_to) ===
|
|
65
|
-
normalizeWalletAddress(source.sendingAddress)
|
|
66
|
-
? attempt
|
|
67
|
-
: null;
|
|
68
|
-
};
|
|
69
|
-
const reuseCurrentAttempt = (attempt) => {
|
|
70
|
-
set((state) => {
|
|
71
|
-
state.cryptoPaymentAttempt = attempt;
|
|
72
|
-
state.error[ACTIONS.CREATE_PAYMENT_ATTEMPT] = null;
|
|
73
|
-
state.loading[ACTIONS.CREATE_PAYMENT_ATTEMPT] = false;
|
|
74
|
-
});
|
|
75
|
-
syncQuote(get().payment, attempt);
|
|
76
|
-
return attempt;
|
|
77
|
-
};
|
|
55
|
+
export const getCurrentWalletTopUp = (state = get()) => state.walletTopUp?.attemptId === getCurrentCheckoutAttempt(state)?.attempt_id
|
|
56
|
+
? state.walletTopUp
|
|
57
|
+
: null;
|
|
58
|
+
/**
|
|
59
|
+
* A payment is issued once its only attempt exists (QCT D1). From then on its
|
|
60
|
+
* terms, including the refund recipient, are fixed.
|
|
61
|
+
*/
|
|
62
|
+
export const isCheckoutIssued = (state = get()) => Boolean(getCurrentCheckoutAttempt(state));
|
|
63
|
+
/** The refund recipient frozen at issuance, or null before issuance. */
|
|
64
|
+
export const getFrozenRefundRecipient = (state = get()) => getCurrentCheckoutAttempt(state)?.refund_to ?? null;
|
|
65
|
+
/** Routes are priced against an issued payment's frozen asset, else the checkout's. */
|
|
66
|
+
const getRouteSettlement = (payment, state = get()) => getCurrentCheckoutAttempt(state)?.settlement_config ??
|
|
67
|
+
getRequiredSettlementConfig(payment);
|
|
78
68
|
const withFreshAttempt = (payment, attempt) => {
|
|
79
69
|
if (!payment) {
|
|
80
70
|
return payment;
|
|
81
71
|
}
|
|
82
72
|
return {
|
|
83
73
|
...payment,
|
|
74
|
+
// Public-key calls receive the public attempt shape the payment read uses.
|
|
84
75
|
payment_attempt: attempt,
|
|
85
76
|
};
|
|
86
77
|
};
|
|
87
|
-
|
|
78
|
+
// A read that has already observed newer instructions takes precedence over
|
|
79
|
+
// the issuing response. Matching timestamps cannot order two different quotes.
|
|
80
|
+
const reconcileIssuedAttempt = (issued, observed) => {
|
|
81
|
+
if (!observed)
|
|
82
|
+
return issued;
|
|
83
|
+
const issuedAt = Date.parse(issued.updated_at);
|
|
84
|
+
const observedAt = Date.parse(observed.updated_at);
|
|
85
|
+
const differentQuote = observed.attempt_id !== issued.attempt_id ||
|
|
86
|
+
(Boolean(observed.quote_request_id) &&
|
|
87
|
+
observed.quote_request_id !== issued.quote_request_id);
|
|
88
|
+
return observedAt > issuedAt || (differentQuote && !(observedAt < issuedAt))
|
|
89
|
+
? observed
|
|
90
|
+
: issued;
|
|
91
|
+
};
|
|
92
|
+
const changedQuoteError = (message = "The payment quote changed. Try again for a fresh quote.") => new CheckoutRequestError(message, "PAYMENT_QUOTE_CHANGED");
|
|
93
|
+
export const assertWalletAttemptCurrent = (attempt) => {
|
|
94
|
+
const { payment } = get();
|
|
95
|
+
if (!payment ||
|
|
96
|
+
!canCreateFreshAttempt(payment) ||
|
|
97
|
+
derivePaymentPhase(payment).cutoffPassed) {
|
|
98
|
+
throw new Error(PAYMENT_NO_LONGER_PAYABLE_MESSAGE);
|
|
99
|
+
}
|
|
100
|
+
assertNoUncertainBitcoinSend(payment.id);
|
|
101
|
+
if (isAttemptStale(attempt) ||
|
|
102
|
+
reconcileIssuedAttempt(attempt, getCurrentCheckoutAttempt()) !== attempt) {
|
|
103
|
+
quoteLifecycle.clearWalletQuoteRequestId(attempt.quote_request_id ?? "");
|
|
104
|
+
throw changedQuoteError();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const getPaymentSnapshotAfterAttempt = async (paymentId, fallbackPayment) => {
|
|
108
|
+
const beforeRead = get().payment;
|
|
88
109
|
try {
|
|
89
|
-
|
|
110
|
+
const read = await getPaymentById(paymentId);
|
|
111
|
+
const current = get().payment;
|
|
112
|
+
if (current?.id !== paymentId || current === beforeRead)
|
|
113
|
+
return read;
|
|
114
|
+
const snapshot = current.status === "pending" && read.status !== "pending"
|
|
115
|
+
? read
|
|
116
|
+
: current;
|
|
117
|
+
const attempt = current.payment_attempt
|
|
118
|
+
? reconcileIssuedAttempt(current.payment_attempt, read.payment_attempt)
|
|
119
|
+
: read.payment_attempt;
|
|
120
|
+
return attempt
|
|
121
|
+
? { ...snapshot, payment_attempt: attempt }
|
|
122
|
+
: snapshot;
|
|
90
123
|
}
|
|
91
124
|
catch {
|
|
92
|
-
|
|
125
|
+
const current = get().payment;
|
|
126
|
+
return current?.id === paymentId ? current : fallbackPayment;
|
|
93
127
|
}
|
|
94
128
|
};
|
|
95
|
-
const updatePaymentSnapshot = (payment, attempt, extra) => {
|
|
129
|
+
const updatePaymentSnapshot = (payment, attempt, extra, syncQuoteWithSnapshot = true, verifiedRefund) => {
|
|
130
|
+
if (payment) {
|
|
131
|
+
const { walletPayment, cryptoPaymentAttempt } = get();
|
|
132
|
+
const submission = walletPayment.submission;
|
|
133
|
+
const returnedQuote = payment.payment_attempt?.quote_request_id;
|
|
134
|
+
const retireWallet = isReturnedBitcoinRoute(payment) &&
|
|
135
|
+
Boolean(returnedQuote) &&
|
|
136
|
+
returnedQuote === cryptoPaymentAttempt?.quote_request_id &&
|
|
137
|
+
walletPayment.status === "submitted" &&
|
|
138
|
+
(!submission || submission.kind === "bitcoin");
|
|
139
|
+
const resolvedQuote = observeBitcoinRecovery(payment, retireWallet && submission?.kind === "bitcoin"
|
|
140
|
+
? submission.quoteId
|
|
141
|
+
: undefined, verifiedRefund);
|
|
142
|
+
if (walletPayment.status === "submitted" &&
|
|
143
|
+
(resolvedQuote
|
|
144
|
+
? !submission ||
|
|
145
|
+
(submission.kind === "bitcoin" &&
|
|
146
|
+
submission.quoteId === resolvedQuote)
|
|
147
|
+
: retireWallet && !getUncertainBitcoinSend(payment)))
|
|
148
|
+
resetWalletPaymentState();
|
|
149
|
+
}
|
|
96
150
|
set((state) => {
|
|
97
151
|
state.payment = payment;
|
|
98
152
|
state.cryptoPaymentAttempt =
|
|
@@ -103,8 +157,17 @@ const updatePaymentSnapshot = (payment, attempt, extra) => {
|
|
|
103
157
|
});
|
|
104
158
|
// Hydrate the current attempt from the payment snapshot so retry can resume
|
|
105
159
|
// the existing quote context and refresh it instead of restarting selection.
|
|
106
|
-
|
|
160
|
+
if (syncQuoteWithSnapshot)
|
|
161
|
+
syncQuote(payment, get().cryptoPaymentAttempt);
|
|
107
162
|
};
|
|
163
|
+
export const { followPayment } = createPaymentObserver({
|
|
164
|
+
get,
|
|
165
|
+
captureOpening: captureCheckoutOpening,
|
|
166
|
+
updatePaymentSnapshot: (payment, attempt, syncQuote, verifiedRefund) => updatePaymentSnapshot(payment, attempt, undefined, syncQuote, verifiedRefund),
|
|
167
|
+
hydrateCheckout: (payment) => hydrateCheckoutFromPayment(payment),
|
|
168
|
+
reconcileWalletTopUp,
|
|
169
|
+
});
|
|
170
|
+
const recoverFromIssuanceConflict = createIssuanceConflictRecovery((payment) => updatePaymentSnapshot(payment));
|
|
108
171
|
export const clearErrors = () => {
|
|
109
172
|
set((state) => {
|
|
110
173
|
Object.values(ACTIONS).forEach((action) => {
|
|
@@ -121,6 +184,12 @@ export const initialiseStore = async (payment) => {
|
|
|
121
184
|
return;
|
|
122
185
|
updatePaymentSnapshot(refreshedPayment);
|
|
123
186
|
hydrateCheckoutFromPayment(refreshedPayment);
|
|
187
|
+
reconcileWalletTopUp(refreshedPayment);
|
|
188
|
+
// Pending payments use their submission to resume the status view, which
|
|
189
|
+
// retries while polling. A settled payment might never start polling.
|
|
190
|
+
if (refreshedPayment.status !== PaymentStatus.PENDING) {
|
|
191
|
+
void retryBitcoinBroadcast(payment.id);
|
|
192
|
+
}
|
|
124
193
|
}
|
|
125
194
|
catch (err) {
|
|
126
195
|
if (!canUpdate())
|
|
@@ -130,33 +199,36 @@ export const initialiseStore = async (payment) => {
|
|
|
130
199
|
});
|
|
131
200
|
}
|
|
132
201
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
202
|
+
/**
|
|
203
|
+
* The checks every issuing call shares: the opening (and the caller's own
|
|
204
|
+
* lifetime) still owns the request, and the payment still takes instructions.
|
|
205
|
+
*/
|
|
206
|
+
const beginIssuance = (owns) => {
|
|
207
|
+
const canUpdate = captureCheckoutOpening(owns);
|
|
138
208
|
if (!canUpdate())
|
|
139
209
|
throw new Error("Checkout is no longer active");
|
|
140
|
-
const payment =
|
|
141
|
-
|
|
142
|
-
if (!paymentId) {
|
|
210
|
+
const payment = get().payment;
|
|
211
|
+
if (!payment?.id) {
|
|
143
212
|
throw Error("Cannot create payment attempt without payment object.");
|
|
144
213
|
}
|
|
145
214
|
if (!canCreateFreshAttempt(payment)) {
|
|
146
215
|
throw Error(PAYMENT_NO_LONGER_PAYABLE_MESSAGE);
|
|
147
216
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const reusableAttempt = getReusableCurrentAttemptForSource({
|
|
151
|
-
token: option.fromToken,
|
|
152
|
-
chain: option.fromChain,
|
|
153
|
-
sendingAddress,
|
|
154
|
-
quoteRequestId,
|
|
155
|
-
});
|
|
156
|
-
if (reusableAttempt) {
|
|
157
|
-
return reuseCurrentAttempt(reusableAttempt);
|
|
158
|
-
}
|
|
217
|
+
if (readWalletTopUp(payment.id)) {
|
|
218
|
+
throw new Error("Wait for your wallet transfer before sending again.");
|
|
159
219
|
}
|
|
220
|
+
assertNoUncertainBitcoinSend(payment.id);
|
|
221
|
+
return { canUpdate, payment, paymentId: payment.id };
|
|
222
|
+
};
|
|
223
|
+
export const createWalletOptionPaymentAttempt = async (
|
|
224
|
+
// "direct" is a routing classification: the payer sends the settlement
|
|
225
|
+
// asset on the settlement chain. It is not tied to manual vs wallet UX.
|
|
226
|
+
option, sendingAddress, quote, ownsWallet) => {
|
|
227
|
+
const { canUpdate, payment, paymentId } = beginIssuance(ownsWallet);
|
|
228
|
+
const quoteRequestId = quoteLifecycle.getWalletQuoteRequestId();
|
|
229
|
+
// The refund recipient is frozen at issuance: the first wallet Pay names the
|
|
230
|
+
// connected wallet, and later calls never send it (QCT D1, D7).
|
|
231
|
+
const refundTo = isCheckoutIssued() ? null : sendingAddress;
|
|
160
232
|
try {
|
|
161
233
|
set((state) => {
|
|
162
234
|
state.error[ACTIONS.CREATE_PAYMENT_ATTEMPT] = null;
|
|
@@ -168,132 +240,140 @@ option, sendingAddress, quote, ownsWallet) => {
|
|
|
168
240
|
quote,
|
|
169
241
|
requiredConfirmations: 1,
|
|
170
242
|
quoteRequestId,
|
|
243
|
+
refundTo,
|
|
171
244
|
});
|
|
172
245
|
const attempt = await createPaymentAttempt(paymentId, attemptPayload, 1);
|
|
173
246
|
if (!canUpdate())
|
|
174
247
|
return attempt;
|
|
175
248
|
if (attempt.quote_request_id !== quoteRequestId) {
|
|
176
|
-
throw
|
|
249
|
+
throw changedQuoteError("Could not get a fresh payment quote. Please try again.");
|
|
177
250
|
}
|
|
178
|
-
const refreshedPayment = await getPaymentSnapshotAfterAttempt(paymentId,
|
|
251
|
+
const refreshedPayment = await getPaymentSnapshotAfterAttempt(paymentId, payment);
|
|
179
252
|
if (!canUpdate())
|
|
180
253
|
return attempt;
|
|
181
|
-
|
|
254
|
+
const currentAttempt = reconcileIssuedAttempt(attempt, refreshedPayment.payment_attempt);
|
|
255
|
+
updatePaymentSnapshot(withFreshAttempt(refreshedPayment, currentAttempt), currentAttempt, (state) => {
|
|
182
256
|
state.retrySession = false;
|
|
183
257
|
state.error[ACTIONS.CREATE_PAYMENT_ATTEMPT] = null;
|
|
184
258
|
state.loading[ACTIONS.CREATE_PAYMENT_ATTEMPT] = false;
|
|
185
259
|
});
|
|
260
|
+
if (currentAttempt !== attempt)
|
|
261
|
+
throw changedQuoteError();
|
|
186
262
|
return attempt;
|
|
187
263
|
}
|
|
188
264
|
catch (err) {
|
|
189
265
|
if (!canUpdate())
|
|
190
266
|
throw err;
|
|
191
|
-
|
|
267
|
+
if (getCryptoPayConflictCode(err) === "PAYMENT_QUOTE_CHANGED") {
|
|
268
|
+
quoteLifecycle.clearWalletQuoteRequestId(quoteRequestId);
|
|
269
|
+
}
|
|
270
|
+
const error = await recoverFromIssuanceConflict(err, paymentId, canUpdate, [
|
|
271
|
+
"REFUND_RECIPIENT_FIXED",
|
|
272
|
+
]);
|
|
273
|
+
if (!canUpdate())
|
|
274
|
+
throw error;
|
|
192
275
|
set((state) => {
|
|
193
|
-
state.error[ACTIONS.CREATE_PAYMENT_ATTEMPT] = error
|
|
276
|
+
state.error[ACTIONS.CREATE_PAYMENT_ATTEMPT] = describeRequestFailure(error, "Failed to create payment attempt");
|
|
194
277
|
state.loading[ACTIONS.CREATE_PAYMENT_ATTEMPT] = false;
|
|
195
278
|
});
|
|
196
279
|
throw error;
|
|
197
280
|
}
|
|
198
281
|
};
|
|
199
282
|
export const createManualDirectPaymentAttempt = async (sendingAddress = "", confirmations = 1, refundTo, options = {}, ownsQuote) => {
|
|
200
|
-
const canUpdate =
|
|
201
|
-
|
|
202
|
-
throw new Error("Checkout is no longer active");
|
|
203
|
-
const payment = useCheckoutStore.getState().payment;
|
|
204
|
-
const paymentId = payment?.id;
|
|
205
|
-
if (!paymentId) {
|
|
206
|
-
throw Error("Cannot create payment attempt without payment object.");
|
|
207
|
-
}
|
|
208
|
-
if (!canCreateFreshAttempt(payment)) {
|
|
209
|
-
throw Error(PAYMENT_NO_LONGER_PAYABLE_MESSAGE);
|
|
210
|
-
}
|
|
211
|
-
const settlementConfig = getRequiredSettlementConfig(payment);
|
|
283
|
+
const { canUpdate, payment, paymentId } = beginIssuance(ownsQuote);
|
|
284
|
+
const settlementConfig = getRouteSettlement(payment);
|
|
212
285
|
const source = options.source ?? {
|
|
213
286
|
asset: settlementConfig.asset,
|
|
214
287
|
chain: settlementConfig.chain,
|
|
215
288
|
};
|
|
216
289
|
const normalizedSendingAddress = sendingAddress.trim();
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
290
|
+
// The refund recipient is frozen at issuance: only the first issuing call
|
|
291
|
+
// names it (the manual refund field, else the checkout fallback). Later
|
|
292
|
+
// reveals and refreshes never send it (QCT D1, D7).
|
|
293
|
+
const refundRecipient = isCheckoutIssued()
|
|
294
|
+
? {}
|
|
295
|
+
: { refund_to: refundTo?.trim() || normalizedSendingAddress || null };
|
|
223
296
|
const attemptPayload = {
|
|
224
|
-
|
|
297
|
+
...buildManualRoutePayload(source, settlementConfig, options.mode),
|
|
225
298
|
...(normalizedSendingAddress
|
|
226
299
|
? { sendingAddress: normalizedSendingAddress }
|
|
227
300
|
: {}),
|
|
228
|
-
|
|
301
|
+
...refundRecipient,
|
|
229
302
|
required_confirmations: confirmations,
|
|
230
|
-
source: options.mode === "relay_deposit"
|
|
231
|
-
? {
|
|
232
|
-
token: source.asset,
|
|
233
|
-
chain: source.chain,
|
|
234
|
-
}
|
|
235
|
-
: undefined,
|
|
236
|
-
routing: {
|
|
237
|
-
type: routingType,
|
|
238
|
-
source: {
|
|
239
|
-
token: source.asset,
|
|
240
|
-
chain: source.chain,
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
303
|
};
|
|
244
|
-
|
|
304
|
+
let attempt;
|
|
305
|
+
try {
|
|
306
|
+
attempt = await createPaymentAttempt(paymentId, attemptPayload);
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
if (!canUpdate())
|
|
310
|
+
throw err;
|
|
311
|
+
// Revealed instructions refresh through this call, so a closed payment is
|
|
312
|
+
// read again: it may hold the payer's funds rather than need a new link.
|
|
313
|
+
throw await recoverFromIssuanceConflict(err, paymentId, canUpdate, [
|
|
314
|
+
"REFUND_RECIPIENT_FIXED",
|
|
315
|
+
"PAYMENT_REQUIRES_NEW_LINK",
|
|
316
|
+
]);
|
|
317
|
+
}
|
|
245
318
|
if (!canUpdate())
|
|
246
319
|
return attempt;
|
|
247
|
-
const refreshedPayment = await getPaymentSnapshotAfterAttempt(paymentId,
|
|
320
|
+
const refreshedPayment = await getPaymentSnapshotAfterAttempt(paymentId, payment);
|
|
248
321
|
if (!canUpdate())
|
|
249
322
|
return attempt;
|
|
250
|
-
|
|
323
|
+
const currentAttempt = reconcileIssuedAttempt(attempt, refreshedPayment.payment_attempt);
|
|
324
|
+
updatePaymentSnapshot(withFreshAttempt(refreshedPayment, currentAttempt), currentAttempt, (state) => {
|
|
251
325
|
state.retrySession = false;
|
|
252
326
|
});
|
|
253
327
|
return attempt;
|
|
254
328
|
};
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
if (!
|
|
259
|
-
throw Error("
|
|
329
|
+
/** Prices a selected wallet route without issuing payment instructions. */
|
|
330
|
+
export const priceWalletRoute = async (option, walletAddress, ownsQuote) => {
|
|
331
|
+
const canUpdate = captureCheckoutOpening(ownsQuote);
|
|
332
|
+
if (!canUpdate())
|
|
333
|
+
throw new Error("Checkout is no longer active");
|
|
334
|
+
const payment = get().payment;
|
|
335
|
+
if (!payment) {
|
|
336
|
+
throw new Error("Cannot price a route without payment object.");
|
|
260
337
|
}
|
|
338
|
+
let estimate;
|
|
261
339
|
try {
|
|
262
|
-
|
|
263
|
-
state.error[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = null;
|
|
264
|
-
state.loading[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = true;
|
|
265
|
-
});
|
|
266
|
-
const currentPayment = useCheckoutStore.getState().payment;
|
|
267
|
-
if (!currentPayment) {
|
|
268
|
-
throw Error("Cannot create test payment attempt without payment object.");
|
|
269
|
-
}
|
|
270
|
-
const attempt = await createTestPaymentAttempt(paymentId, "0xsuccess", currentPayment);
|
|
271
|
-
if (!canUpdate())
|
|
272
|
-
return;
|
|
273
|
-
const payment = await getPaymentById(paymentId);
|
|
274
|
-
if (!canUpdate())
|
|
275
|
-
return;
|
|
276
|
-
updatePaymentSnapshot(payment, attempt, (state) => {
|
|
277
|
-
state.retrySession = false;
|
|
278
|
-
state.error[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = null;
|
|
279
|
-
state.loading[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = false;
|
|
280
|
-
});
|
|
340
|
+
estimate = await estimateCryptoPay(payment.id, buildWalletEstimatePayload({ option, sendingAddress: walletAddress }));
|
|
281
341
|
}
|
|
282
342
|
catch (err) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
343
|
+
throw withConflictCopy(err);
|
|
344
|
+
}
|
|
345
|
+
assertNoUncertainBitcoinSend(payment.id);
|
|
346
|
+
if (option.fromChain === BITCOIN_CHAIN) {
|
|
347
|
+
return priceBitcoinWalletEstimate(estimate);
|
|
348
|
+
}
|
|
349
|
+
const attempt = getCurrentCheckoutAttempt();
|
|
350
|
+
const priced = await priceEstimate(estimate, getRouteSettlement(payment), attempt);
|
|
351
|
+
if (option.kind === "direct") {
|
|
352
|
+
return {
|
|
353
|
+
quote: { kind: "quoted", quote: buildDirectWalletQuote(option, priced) },
|
|
354
|
+
expiresAt: priced.expiresAt,
|
|
355
|
+
};
|
|
291
356
|
}
|
|
357
|
+
// Keep routed-quote loading behind a dynamic import so the checkout store
|
|
358
|
+
// does not eagerly pull the LI.FI integration path into manual-only flows.
|
|
359
|
+
const { fetchWalletRouteQuote } = await import("../../integrations/index.js");
|
|
360
|
+
const quote = await fetchWalletRouteQuote({
|
|
361
|
+
option,
|
|
362
|
+
walletAddress,
|
|
363
|
+
target: buildWalletQuoteTarget({
|
|
364
|
+
priced,
|
|
365
|
+
attempt: getCurrentCheckoutAttempt(),
|
|
366
|
+
settlement: getRouteSettlement(payment),
|
|
367
|
+
walletAddress,
|
|
368
|
+
}),
|
|
369
|
+
});
|
|
370
|
+
return { quote: { kind: "quoted", quote }, expiresAt: priced.expiresAt };
|
|
292
371
|
};
|
|
293
|
-
|
|
372
|
+
// A test payment settles or fails through the transaction hash it reports.
|
|
373
|
+
const createSimulatedTestPaymentAttempt = async (txHash) => {
|
|
294
374
|
const canUpdate = captureCheckoutOpening();
|
|
295
|
-
const
|
|
296
|
-
if (!
|
|
375
|
+
const payment = get().payment;
|
|
376
|
+
if (!payment?.id) {
|
|
297
377
|
throw Error("Cannot create test payment attempt without payment object.");
|
|
298
378
|
}
|
|
299
379
|
try {
|
|
@@ -301,17 +381,13 @@ export const createFailedTestPaymentAttempt = async () => {
|
|
|
301
381
|
state.error[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = null;
|
|
302
382
|
state.loading[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = true;
|
|
303
383
|
});
|
|
304
|
-
const
|
|
305
|
-
if (!currentPayment) {
|
|
306
|
-
throw Error("Cannot create test payment attempt without payment object.");
|
|
307
|
-
}
|
|
308
|
-
const attempt = await createTestPaymentAttempt(paymentId, "0xfail", currentPayment);
|
|
384
|
+
const attempt = await createTestPaymentAttempt(payment.id, txHash, payment);
|
|
309
385
|
if (!canUpdate())
|
|
310
386
|
return;
|
|
311
|
-
const
|
|
387
|
+
const refreshedPayment = await getPaymentById(payment.id);
|
|
312
388
|
if (!canUpdate())
|
|
313
389
|
return;
|
|
314
|
-
updatePaymentSnapshot(
|
|
390
|
+
updatePaymentSnapshot(refreshedPayment, attempt, (state) => {
|
|
315
391
|
state.retrySession = false;
|
|
316
392
|
state.error[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = null;
|
|
317
393
|
state.loading[ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT] = false;
|
|
@@ -328,6 +404,8 @@ export const createFailedTestPaymentAttempt = async () => {
|
|
|
328
404
|
throw error;
|
|
329
405
|
}
|
|
330
406
|
};
|
|
407
|
+
export const createSuccessfulTestPaymentAttempt = () => createSimulatedTestPaymentAttempt("0xsuccess");
|
|
408
|
+
export const createFailedTestPaymentAttempt = () => createSimulatedTestPaymentAttempt("0xfail");
|
|
331
409
|
export function getAvailableCheckoutMethods(checkout) {
|
|
332
410
|
const methods = [];
|
|
333
411
|
if (checkout.checkout_config.crypto?.enabled) {
|
|
@@ -368,53 +446,7 @@ export const hydrateCheckoutFromPayment = (payment) => {
|
|
|
368
446
|
});
|
|
369
447
|
}
|
|
370
448
|
};
|
|
371
|
-
export const
|
|
372
|
-
const canUpdate = captureCheckoutOpening();
|
|
373
|
-
const ACTION = ACTIONS.GET_PAYMENT;
|
|
374
|
-
set((state) => {
|
|
375
|
-
state.loading[ACTION] = true;
|
|
376
|
-
state.error[ACTION] = null;
|
|
377
|
-
});
|
|
378
|
-
const payment = get().payment;
|
|
379
|
-
if (!payment) {
|
|
380
|
-
set((state) => {
|
|
381
|
-
state.loading[ACTION] = false;
|
|
382
|
-
state.error[ACTION] = "No payment found";
|
|
383
|
-
});
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
try {
|
|
387
|
-
const resp = await getPaymentById(payment.id);
|
|
388
|
-
if (!canUpdate())
|
|
389
|
-
return null;
|
|
390
|
-
if (resp) {
|
|
391
|
-
updatePaymentSnapshot(resp);
|
|
392
|
-
set((state) => {
|
|
393
|
-
state.loading[ACTION] = false;
|
|
394
|
-
state.error[ACTION] = null;
|
|
395
|
-
});
|
|
396
|
-
hydrateCheckoutFromPayment(resp);
|
|
397
|
-
return resp;
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
set((state) => {
|
|
401
|
-
state.loading[ACTION] = false;
|
|
402
|
-
state.error[ACTION] = "Failed to load payment";
|
|
403
|
-
});
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
catch (error) {
|
|
408
|
-
if (!canUpdate())
|
|
409
|
-
return null;
|
|
410
|
-
set((state) => {
|
|
411
|
-
state.loading[ACTION] = false;
|
|
412
|
-
state.error[ACTION] = "Failed to load payment";
|
|
413
|
-
});
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
export const executeTransfer = async (wallet, ownsWallet) => {
|
|
449
|
+
export const executeTransfer = async (wallet, ownsWallet, beforeSign, onIdentity) => {
|
|
418
450
|
const canExecute = captureCheckoutOpening(ownsWallet);
|
|
419
451
|
if (!canExecute())
|
|
420
452
|
throw new Error("Checkout is no longer active");
|
|
@@ -429,9 +461,9 @@ export const executeTransfer = async (wallet, ownsWallet) => {
|
|
|
429
461
|
state.transfer.status = "pending";
|
|
430
462
|
state.transfer.error = null;
|
|
431
463
|
state.transfer.transactionHash = null;
|
|
432
|
-
state.transfer.chainStatus = "pending";
|
|
433
464
|
});
|
|
434
465
|
try {
|
|
466
|
+
beforeSign?.();
|
|
435
467
|
const settlementChainHex = state.cryptoPaymentAttempt.settlement_config.chain_hex;
|
|
436
468
|
const targetChainId = resolveEvmChainId(settlementChainHex);
|
|
437
469
|
if (targetChainId && wallet.switchChain) {
|
|
@@ -447,7 +479,8 @@ export const executeTransfer = async (wallet, ownsWallet) => {
|
|
|
447
479
|
const transfer = {
|
|
448
480
|
sendingAddress: address,
|
|
449
481
|
destinationAddress: state.cryptoPaymentAttempt.destination_address,
|
|
450
|
-
amount: state.cryptoPaymentAttempt.
|
|
482
|
+
amount: state.cryptoPaymentAttempt.amount_to_pay ??
|
|
483
|
+
state.cryptoPaymentAttempt.amount,
|
|
451
484
|
evm: {
|
|
452
485
|
implementationAddress: state.cryptoPaymentAttempt.settlement_token_address,
|
|
453
486
|
assetName: state.cryptoPaymentAttempt.settlement_config.asset_name,
|
|
@@ -456,7 +489,10 @@ export const executeTransfer = async (wallet, ownsWallet) => {
|
|
|
456
489
|
if (!canExecute()) {
|
|
457
490
|
throw new Error("Wallet connection changed. Connect again before paying.");
|
|
458
491
|
}
|
|
459
|
-
|
|
492
|
+
beforeSign?.();
|
|
493
|
+
const txHash = await (onIdentity
|
|
494
|
+
? wallet.executeTransfer(transfer, beforeSign, onIdentity)
|
|
495
|
+
: wallet.executeTransfer(transfer, beforeSign));
|
|
460
496
|
if (!canExecute())
|
|
461
497
|
return txHash;
|
|
462
498
|
if (!txHash) {
|
|
@@ -483,143 +519,145 @@ export const executeTransfer = async (wallet, ownsWallet) => {
|
|
|
483
519
|
throw error instanceof Error ? error : new Error(errorMessage);
|
|
484
520
|
}
|
|
485
521
|
};
|
|
486
|
-
export const checkChainStatus = async (wallet, submitted) => {
|
|
487
|
-
const ACTION = ACTIONS.CHECK_CHAIN_STATUS;
|
|
488
|
-
const state = get();
|
|
489
|
-
const hash = submitted?.hash ?? state.transfer.transactionHash;
|
|
490
|
-
const canUpdate = captureCheckoutOpening(submitted?.canUpdate);
|
|
491
|
-
if (!hash || (!submitted && state.transfer.status !== "success")) {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
// Check if the wallet is a WagmiWalletInterface
|
|
495
|
-
if (!(wallet instanceof WagmiWalletInterface)) {
|
|
496
|
-
const error = new Error("Wallet does not support chain status checks");
|
|
497
|
-
console.error(error.message);
|
|
498
|
-
if (canUpdate())
|
|
499
|
-
set((state) => {
|
|
500
|
-
state.transfer.status = "failed";
|
|
501
|
-
state.transfer.error = error.message;
|
|
502
|
-
state.transfer.chainStatus = "failed";
|
|
503
|
-
state.error[ACTION] = error.message;
|
|
504
|
-
});
|
|
505
|
-
throw error;
|
|
506
|
-
}
|
|
507
|
-
if (canUpdate())
|
|
508
|
-
set((state) => {
|
|
509
|
-
state.loading[ACTION] = true;
|
|
510
|
-
state.error[ACTION] = null;
|
|
511
|
-
});
|
|
512
|
-
try {
|
|
513
|
-
const receipt = await waitForTransactionReceipt(wallet.wagmiConfig, {
|
|
514
|
-
hash: hash,
|
|
515
|
-
chainId: submitted?.chainId,
|
|
516
|
-
confirmations: 1,
|
|
517
|
-
});
|
|
518
|
-
if (receipt.status === "reverted") {
|
|
519
|
-
throw new Error("Transaction reverted before confirmation");
|
|
520
|
-
}
|
|
521
|
-
if (canUpdate())
|
|
522
|
-
set((state) => {
|
|
523
|
-
state.transfer.chainStatus = "confirmed";
|
|
524
|
-
state.loading[ACTION] = false;
|
|
525
|
-
state.error[ACTION] = null;
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
catch (error) {
|
|
529
|
-
console.error("Error checking transaction status:", error);
|
|
530
|
-
const errorMessage = error instanceof Error ? error.message : "Failed to check chain status";
|
|
531
|
-
if (canUpdate())
|
|
532
|
-
set((state) => {
|
|
533
|
-
state.transfer.status = "failed";
|
|
534
|
-
state.transfer.error = errorMessage;
|
|
535
|
-
state.transfer.chainStatus = "failed";
|
|
536
|
-
state.loading[ACTION] = false;
|
|
537
|
-
state.error[ACTION] = errorMessage;
|
|
538
|
-
});
|
|
539
|
-
throw error instanceof Error ? error : new Error(errorMessage);
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
522
|
export const resetTransfer = () => {
|
|
543
523
|
set((state) => {
|
|
544
524
|
state.transfer = {
|
|
545
525
|
status: "idle",
|
|
546
526
|
error: null,
|
|
547
527
|
transactionHash: null,
|
|
548
|
-
chainStatus: "pending",
|
|
549
528
|
};
|
|
550
529
|
});
|
|
551
530
|
};
|
|
552
|
-
export const
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
531
|
+
export const recordManualTransfer = (manualTransfer) => {
|
|
532
|
+
const paymentId = get().payment?.id;
|
|
533
|
+
if (!paymentId)
|
|
534
|
+
return;
|
|
535
|
+
set((state) => {
|
|
536
|
+
state.manualTransfer = manualTransfer;
|
|
537
|
+
});
|
|
538
|
+
writeCheckoutResumeState(paymentId, {
|
|
539
|
+
...(manualTransfer ? { view: "paymentStatus" } : {}),
|
|
540
|
+
manualTransfer,
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
// Session storage keeps the reservation available on a reload. The in-memory
|
|
544
|
+
// record holds newer evidence if a later storage write fails.
|
|
545
|
+
const walletTopUps = new Map();
|
|
546
|
+
export const readWalletTopUp = (paymentId) => {
|
|
547
|
+
const current = walletTopUps.get(paymentId);
|
|
548
|
+
if (current !== undefined)
|
|
549
|
+
return current;
|
|
550
|
+
const saved = readCheckoutResumeState(paymentId).walletTopUp;
|
|
551
|
+
if (saved)
|
|
552
|
+
walletTopUps.set(paymentId, saved);
|
|
553
|
+
return saved ?? null;
|
|
554
|
+
};
|
|
555
|
+
function saveWalletTopUp(paymentId, attemptId, next, { beforeSend = false, indexedHash, } = {}) {
|
|
556
|
+
const submitted = Boolean(next?.txHash || next?.source);
|
|
557
|
+
const saved = writeCheckoutResumeState(paymentId, {
|
|
558
|
+
...(submitted ? { view: "paymentStatus", manualTransfer: null } : {}),
|
|
559
|
+
walletTopUp: next,
|
|
560
|
+
});
|
|
561
|
+
if (!saved && beforeSend) {
|
|
562
|
+
throw new Error("Allow browser storage to pay the remaining amount with a wallet.");
|
|
563
|
+
}
|
|
564
|
+
if (saved && !next)
|
|
565
|
+
walletTopUps.delete(paymentId);
|
|
566
|
+
else
|
|
567
|
+
walletTopUps.set(paymentId, next);
|
|
568
|
+
if (get().payment?.id === paymentId &&
|
|
569
|
+
getCurrentCheckoutAttempt()?.attempt_id === attemptId) {
|
|
566
570
|
set((state) => {
|
|
567
|
-
state.
|
|
568
|
-
|
|
571
|
+
state.walletTopUp = next;
|
|
572
|
+
if (submitted)
|
|
573
|
+
state.manualTransfer = null;
|
|
574
|
+
if (indexedHash && state.walletPayment.submission?.txHash === indexedHash)
|
|
575
|
+
state.walletPayment = initialWalletPaymentState();
|
|
569
576
|
});
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
state.polling.isPolling = true;
|
|
596
|
-
state.polling.pollCount = 0;
|
|
597
|
-
state.polling.lastPollTime = null;
|
|
598
|
-
state.loading[ACTION] = true;
|
|
599
|
-
state.error[ACTION] = null;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
export const reserveWalletTopUp = (paymentId, attemptId) => {
|
|
580
|
+
if (get().payment?.id !== paymentId ||
|
|
581
|
+
getCurrentCheckoutAttempt()?.attempt_id !== attemptId)
|
|
582
|
+
throw new Error("This attempt is no longer active.");
|
|
583
|
+
if (readWalletTopUp(paymentId)?.attemptId === attemptId) {
|
|
584
|
+
throw new Error("Wait for your wallet transfer before sending again.");
|
|
585
|
+
}
|
|
586
|
+
const pending = { attemptId, pending: true };
|
|
587
|
+
saveWalletTopUp(paymentId, attemptId, pending, { beforeSend: true });
|
|
588
|
+
return pending;
|
|
589
|
+
};
|
|
590
|
+
export const advanceWalletTopUp = (paymentId, current, next, { beforeSend = false, indexed = false } = {}) => {
|
|
591
|
+
if (readWalletTopUp(paymentId) !== current) {
|
|
592
|
+
if (beforeSend)
|
|
593
|
+
throw new Error("This attempt is no longer active.");
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
const lookup = current.txHash && checkedWalletTopUps.get(current);
|
|
597
|
+
if (lookup && next?.txHash && next.txHash === current.txHash)
|
|
598
|
+
checkedWalletTopUps.set(next, lookup);
|
|
599
|
+
saveWalletTopUp(paymentId, current.attemptId, next, {
|
|
600
|
+
beforeSend,
|
|
601
|
+
indexedHash: indexed ? current.txHash : undefined,
|
|
600
602
|
});
|
|
601
|
-
|
|
602
|
-
pollInterval = setInterval(pollPaymentStatus, POLL_INTERVAL);
|
|
603
|
-
void pollPaymentStatus();
|
|
604
|
-
return {
|
|
605
|
-
stop: stopPolling,
|
|
606
|
-
};
|
|
603
|
+
return true;
|
|
607
604
|
};
|
|
608
|
-
export const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
605
|
+
export const updateWalletTopUp = (paymentId, attemptId, txHash, change) => {
|
|
606
|
+
const current = readWalletTopUp(paymentId);
|
|
607
|
+
if (!current || current.attemptId !== attemptId || current.txHash !== txHash)
|
|
608
|
+
return;
|
|
609
|
+
const next = change && change !== "indexed" ? { ...current, ...change } : null;
|
|
610
|
+
advanceWalletTopUp(paymentId, current, next, {
|
|
611
|
+
indexed: change === "indexed",
|
|
614
612
|
});
|
|
615
613
|
};
|
|
614
|
+
// A continuation cursor pins the history snapshot. Cache misses until it changes.
|
|
615
|
+
const checkedWalletTopUps = new WeakMap();
|
|
616
|
+
function reconcileWalletTopUp(payment) {
|
|
617
|
+
const { walletTopUp } = get();
|
|
618
|
+
if (!walletTopUp?.txHash ||
|
|
619
|
+
walletTopUp.attemptId !== payment.payment_attempt?.attempt_id ||
|
|
620
|
+
!payment.timeline)
|
|
621
|
+
return;
|
|
622
|
+
const { timeline } = payment;
|
|
623
|
+
const txHash = walletTopUp.txHash;
|
|
624
|
+
if (hasConfirmedDeposit(timeline.items, txHash)) {
|
|
625
|
+
updateWalletTopUp(payment.id, walletTopUp.attemptId, txHash, "indexed");
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const cursor = timeline.next_cursor;
|
|
629
|
+
const checked = checkedWalletTopUps.get(walletTopUp);
|
|
630
|
+
if (!cursor || checked?.reading || checked?.cursor === cursor)
|
|
631
|
+
return;
|
|
632
|
+
const lookup = {
|
|
633
|
+
cursor,
|
|
634
|
+
reading: true,
|
|
635
|
+
};
|
|
636
|
+
checkedWalletTopUps.set(walletTopUp, lookup);
|
|
637
|
+
void findDepositInTimelinePages(payment.id, cursor, txHash)
|
|
638
|
+
.then((found) => {
|
|
639
|
+
if (found)
|
|
640
|
+
updateWalletTopUp(payment.id, walletTopUp.attemptId, txHash, "indexed");
|
|
641
|
+
})
|
|
642
|
+
.catch(() => {
|
|
643
|
+
// The next payment read can retry an unavailable timeline page.
|
|
644
|
+
lookup.cursor = null;
|
|
645
|
+
})
|
|
646
|
+
.finally(() => {
|
|
647
|
+
lookup.reading = false;
|
|
648
|
+
});
|
|
649
|
+
}
|
|
616
650
|
export const resetCheckoutStore = (payment = null) => {
|
|
617
651
|
checkoutOpening += 1;
|
|
618
652
|
quoteLifecycle.dispose();
|
|
653
|
+
const { manualTransfer } = readCheckoutResumeState(payment?.id);
|
|
654
|
+
const walletTopUp = payment ? readWalletTopUp(payment.id) : null;
|
|
619
655
|
set((state) => {
|
|
620
656
|
Object.assign(state, createInitialCheckoutState(), {
|
|
621
657
|
payment,
|
|
622
658
|
cryptoPaymentAttempt: payment?.payment_attempt ?? null,
|
|
659
|
+
manualTransfer: manualTransfer ?? null,
|
|
660
|
+
walletTopUp,
|
|
623
661
|
});
|
|
624
662
|
});
|
|
625
663
|
};
|
|
@@ -635,7 +673,6 @@ export const resetCheckoutSessionForRetry = () => {
|
|
|
635
673
|
cryptoPaymentAttempt: initial.cryptoPaymentAttempt,
|
|
636
674
|
processing: initial.processing,
|
|
637
675
|
transfer: initial.transfer,
|
|
638
|
-
polling: initial.polling,
|
|
639
676
|
walletPayment: initial.walletPayment,
|
|
640
677
|
quote: initial.quote,
|
|
641
678
|
});
|
|
@@ -643,8 +680,6 @@ export const resetCheckoutSessionForRetry = () => {
|
|
|
643
680
|
ACTIONS.CREATE_PAYMENT_ATTEMPT,
|
|
644
681
|
ACTIONS.CREATE_TEST_PAYMENT_ATTEMPT,
|
|
645
682
|
ACTIONS.EXECUTE_TRANSFER,
|
|
646
|
-
ACTIONS.POLL_PAYMENT,
|
|
647
|
-
ACTIONS.CHECK_CHAIN_STATUS,
|
|
648
683
|
]) {
|
|
649
684
|
state.error[action] = initial.error[action];
|
|
650
685
|
state.loading[action] = initial.loading[action];
|