@stridge/kit 0.1.0-alpha.60 → 0.1.0-alpha.61

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.
Files changed (185) hide show
  1. package/dist/KitProvider.d.ts +0 -21
  2. package/dist/KitProvider.js +1 -1
  3. package/dist/_internal/deposit/driver/index.d.ts +3 -3
  4. package/dist/_internal/drivers/stridge-mock/index.d.ts +3 -2
  5. package/dist/_internal/drivers/stridge-mock/index.js +1 -1
  6. package/dist/activity/compound/index.js +1 -1
  7. package/dist/deposit/compound/index.d.ts +13 -10
  8. package/dist/deposit/compound/index.js +1 -1
  9. package/dist/deposit/widgets/index.d.ts +4 -3
  10. package/dist/deposit/widgets/index.js +1 -1
  11. package/dist/drivers/stridge/createStridgeDepositDriver.js +1 -1
  12. package/dist/drivers/stridge-mock/checkoutChannel.d.ts +31 -0
  13. package/dist/drivers/stridge-mock/checkoutChannel.js +1 -0
  14. package/dist/drivers/stridge-mock/createStridgeMockDriver.d.ts +28 -0
  15. package/dist/drivers/stridge-mock/createStridgeMockDriver.js +1 -1
  16. package/dist/drivers/stridge-mock/fixtures.d.ts +6 -2
  17. package/dist/drivers/stridge-mock/fixtures.js +1 -1
  18. package/dist/drivers/stridge-mock/triggers.d.ts +12 -0
  19. package/dist/events/emit/useDepositEmissions.js +1 -1
  20. package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
  21. package/dist/flows/deposit/driver/payloads.d.ts +77 -20
  22. package/dist/flows/deposit/driver/types.d.ts +64 -10
  23. package/dist/flows/deposit/orchestrator/controller.js +1 -1
  24. package/dist/flows/deposit/orchestrator/index.d.ts +1 -1
  25. package/dist/flows/deposit/orchestrator/reducer.js +1 -1
  26. package/dist/flows/deposit/orchestrator/types.d.ts +102 -59
  27. package/dist/flows/deposit/shared/checkoutPopup.js +1 -0
  28. package/dist/flows/deposit/shared/onramp.js +1 -0
  29. package/dist/flows/deposit/widgets/amount-entry/AmountEntry.js +1 -1
  30. package/dist/flows/deposit/widgets/deposit/Deposit.js +1 -1
  31. package/dist/flows/deposit/widgets/deposit/compound/Deposit.d.ts +5 -5
  32. package/dist/flows/deposit/widgets/deposit/compound/components/Guards.js +1 -1
  33. package/dist/flows/deposit/widgets/deposit/compound/components/Methods.d.ts +1 -2
  34. package/dist/flows/deposit/widgets/deposit/compound/components/RailPicker.js +1 -1
  35. package/dist/flows/deposit/widgets/deposit/compound/types.d.ts +9 -9
  36. package/dist/flows/deposit/widgets/error-state/ErrorState.js +1 -1
  37. package/dist/flows/deposit/widgets/onramp-amount-entry/OnrampAmountEntry.d.ts +64 -0
  38. package/dist/flows/deposit/widgets/onramp-amount-entry/OnrampAmountEntry.js +1 -0
  39. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.d.ts +62 -0
  40. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.js +1 -0
  41. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.slots.d.ts +14 -0
  42. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.slots.js +1 -0
  43. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.styles.js +1 -0
  44. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/HeroLabel.d.ts +13 -0
  45. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/HeroLabel.js +1 -0
  46. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/ReceiveChip.d.ts +14 -0
  47. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/ReceiveChip.js +1 -0
  48. package/dist/flows/deposit/widgets/{cash-amount-entry → onramp-amount-entry}/compound/context.js +1 -1
  49. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/index.d.ts +3 -0
  50. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/index.js +1 -0
  51. package/dist/flows/deposit/widgets/onramp-amount-entry/compound/types.d.ts +29 -0
  52. package/dist/flows/deposit/widgets/onramp-amount-entry/index.d.ts +1 -0
  53. package/dist/flows/deposit/widgets/onramp-amount-entry/index.js +1 -0
  54. package/dist/flows/deposit/widgets/onramp-confirm/OnrampConfirm.d.ts +50 -0
  55. package/dist/flows/deposit/widgets/onramp-confirm/OnrampConfirm.js +1 -0
  56. package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.d.ts +42 -0
  57. package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.js +1 -0
  58. package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.slots.d.ts +24 -0
  59. package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.slots.js +1 -0
  60. package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.styles.js +1 -0
  61. package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Body.d.ts +16 -0
  62. package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Body.js +1 -0
  63. package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Header.d.ts +15 -0
  64. package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Header.js +1 -0
  65. package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Summary.d.ts +15 -0
  66. package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Summary.js +1 -0
  67. package/dist/flows/deposit/widgets/onramp-confirm/compound/context.d.ts +25 -0
  68. package/dist/flows/deposit/widgets/{cash-confirm → onramp-confirm}/compound/context.js +1 -1
  69. package/dist/flows/deposit/widgets/onramp-confirm/compound/index.d.ts +4 -0
  70. package/dist/flows/deposit/widgets/onramp-confirm/compound/index.js +1 -0
  71. package/dist/flows/deposit/widgets/onramp-confirm/compound/types.d.ts +62 -0
  72. package/dist/flows/deposit/widgets/onramp-confirm/index.d.ts +1 -0
  73. package/dist/flows/deposit/widgets/onramp-confirm/index.js +1 -0
  74. package/dist/flows/deposit/widgets/onramp-payment-pending/OnrampPaymentPending.d.ts +48 -0
  75. package/dist/flows/deposit/widgets/onramp-payment-pending/OnrampPaymentPending.js +1 -0
  76. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.d.ts +63 -0
  77. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.js +1 -0
  78. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.slots.d.ts +14 -0
  79. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.slots.js +1 -0
  80. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/components/ReopenButton.d.ts +11 -0
  81. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/components/ReopenButton.js +1 -0
  82. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/context.js +1 -0
  83. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/index.d.ts +2 -0
  84. package/dist/flows/deposit/widgets/onramp-payment-pending/compound/index.js +1 -0
  85. package/dist/flows/deposit/widgets/onramp-payment-pending/index.d.ts +1 -0
  86. package/dist/flows/deposit/widgets/onramp-payment-pending/index.js +1 -0
  87. package/dist/flows/deposit/widgets/success-state/SuccessState.js +1 -1
  88. package/dist/flows/deposit/widgets/transfer-crypto/compound/components/QrCode.js +1 -1
  89. package/dist/i18n/locales/ar.js +1 -1
  90. package/dist/i18n/locales/es.js +1 -1
  91. package/dist/i18n/locales/source-keys.d.ts +1 -1
  92. package/dist/icons/index.d.ts +1 -8
  93. package/dist/icons/index.js +1 -1
  94. package/dist/index.d.ts +3 -4
  95. package/dist/index.js +1 -1
  96. package/dist/package.js +1 -1
  97. package/dist/shared/icons/BitcoinIcon.d.ts +5 -8
  98. package/dist/shared/icons/BitcoinIcon.js +1 -1
  99. package/dist/shared/icons/CardIcon.d.ts +3 -3
  100. package/dist/shared/orchestrator/index.js +1 -1
  101. package/dist/shared/orchestrator/useOnrampSessionWatcher.js +1 -0
  102. package/dist/shared/ui/Tabs/Tabs.d.ts +2 -2
  103. package/dist/shared/widgets/activity/compound/ActivityDetail.js +1 -1
  104. package/dist/shared/widgets/amount-entry/compound/AmountEntry.js +1 -1
  105. package/dist/shared/widgets/amount-entry/compound/components/Footer.js +1 -1
  106. package/dist/shared/widgets/amount-entry/compound/types.d.ts +6 -0
  107. package/dist/stridge/StridgeProvider.d.ts +0 -10
  108. package/dist/stridge/StridgeProvider.js +1 -1
  109. package/dist/stridge/stubs.js +1 -1
  110. package/dist/styles/index.css +4 -44
  111. package/dist/types.d.ts +3 -3
  112. package/dist/version.js +1 -1
  113. package/dist/withdraw/compound/index.js +1 -1
  114. package/package.json +1 -1
  115. package/dist/flows/deposit/bindings/DepositBindings.d.ts +0 -87
  116. package/dist/flows/deposit/bindings/DepositBindings.js +0 -1
  117. package/dist/flows/deposit/bindings/index.d.ts +0 -1
  118. package/dist/flows/deposit/bindings/index.js +0 -1
  119. package/dist/flows/deposit/shared/cash.d.ts +0 -20
  120. package/dist/flows/deposit/shared/cash.js +0 -1
  121. package/dist/flows/deposit/widgets/cash-amount-entry/CashAmountEntry.d.ts +0 -71
  122. package/dist/flows/deposit/widgets/cash-amount-entry/CashAmountEntry.js +0 -1
  123. package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.d.ts +0 -69
  124. package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.js +0 -1
  125. package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.slots.d.ts +0 -16
  126. package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.slots.js +0 -1
  127. package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.js +0 -1
  128. package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/HeroLabel.d.ts +0 -13
  129. package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/HeroLabel.js +0 -1
  130. package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/MethodChip.d.ts +0 -18
  131. package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/MethodChip.js +0 -1
  132. package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/ReceiveChip.d.ts +0 -14
  133. package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/ReceiveChip.js +0 -1
  134. package/dist/flows/deposit/widgets/cash-amount-entry/compound/index.d.ts +0 -3
  135. package/dist/flows/deposit/widgets/cash-amount-entry/compound/index.js +0 -1
  136. package/dist/flows/deposit/widgets/cash-amount-entry/compound/types.d.ts +0 -42
  137. package/dist/flows/deposit/widgets/cash-amount-entry/index.d.ts +0 -1
  138. package/dist/flows/deposit/widgets/cash-amount-entry/index.js +0 -1
  139. package/dist/flows/deposit/widgets/cash-confirm/CashConfirm.d.ts +0 -63
  140. package/dist/flows/deposit/widgets/cash-confirm/CashConfirm.js +0 -1
  141. package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.d.ts +0 -54
  142. package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.js +0 -1
  143. package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.slots.d.ts +0 -33
  144. package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.slots.js +0 -1
  145. package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.styles.js +0 -1
  146. package/dist/flows/deposit/widgets/cash-confirm/compound/cashConfirmDimensions.js +0 -1
  147. package/dist/flows/deposit/widgets/cash-confirm/compound/components/ApplePayBody.d.ts +0 -15
  148. package/dist/flows/deposit/widgets/cash-confirm/compound/components/ApplePayBody.js +0 -1
  149. package/dist/flows/deposit/widgets/cash-confirm/compound/components/Body.d.ts +0 -22
  150. package/dist/flows/deposit/widgets/cash-confirm/compound/components/Body.js +0 -1
  151. package/dist/flows/deposit/widgets/cash-confirm/compound/components/BodyLabel.js +0 -1
  152. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardBody.d.ts +0 -16
  153. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardBody.js +0 -1
  154. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.icons.js +0 -1
  155. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.js +0 -1
  156. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.keys.js +0 -1
  157. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.state.js +0 -1
  158. package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.styles.js +0 -1
  159. package/dist/flows/deposit/widgets/cash-confirm/compound/components/GooglePayBody.d.ts +0 -16
  160. package/dist/flows/deposit/widgets/cash-confirm/compound/components/GooglePayBody.js +0 -1
  161. package/dist/flows/deposit/widgets/cash-confirm/compound/components/Header.d.ts +0 -21
  162. package/dist/flows/deposit/widgets/cash-confirm/compound/components/Header.js +0 -1
  163. package/dist/flows/deposit/widgets/cash-confirm/compound/components/Summary.d.ts +0 -17
  164. package/dist/flows/deposit/widgets/cash-confirm/compound/components/Summary.js +0 -1
  165. package/dist/flows/deposit/widgets/cash-confirm/compound/components/cardFormat.js +0 -1
  166. package/dist/flows/deposit/widgets/cash-confirm/compound/index.d.ts +0 -3
  167. package/dist/flows/deposit/widgets/cash-confirm/compound/index.js +0 -1
  168. package/dist/flows/deposit/widgets/cash-confirm/compound/types.d.ts +0 -66
  169. package/dist/flows/deposit/widgets/cash-confirm/index.d.ts +0 -1
  170. package/dist/flows/deposit/widgets/cash-confirm/index.js +0 -1
  171. package/dist/flows/deposit/widgets/cash-confirm/mocks.js +0 -1
  172. package/dist/shared/icons/AmexIcon.d.ts +0 -14
  173. package/dist/shared/icons/AmexIcon.js +0 -1
  174. package/dist/shared/icons/ApplePayIcon.d.ts +0 -15
  175. package/dist/shared/icons/ApplePayIcon.js +0 -1
  176. package/dist/shared/icons/CashIcon.d.ts +0 -16
  177. package/dist/shared/icons/CashIcon.js +0 -1
  178. package/dist/shared/icons/DiscoverIcon.d.ts +0 -14
  179. package/dist/shared/icons/DiscoverIcon.js +0 -1
  180. package/dist/shared/icons/GooglePayIcon.d.ts +0 -15
  181. package/dist/shared/icons/GooglePayIcon.js +0 -1
  182. package/dist/shared/icons/MastercardIcon.d.ts +0 -16
  183. package/dist/shared/icons/MastercardIcon.js +0 -1
  184. package/dist/shared/icons/VisaIcon.d.ts +0 -15
  185. package/dist/shared/icons/VisaIcon.js +0 -1
@@ -1 +1 @@
1
- "use client";import{StridgeEventsContext as e}from"../context.js";import{useDialogLifecycle as t}from"../../shared/orchestrator/useDialogLifecycle.js";import"../../shared/orchestrator/index.js";import{mapFailureInfoToPayload as n}from"./mapFailure.js";import{closeFlowSession as r,openFlowSession as i,publishEvent as a}from"../publish.js";import{use as o,useRef as s}from"react";function c(n){let r=o(e),i=s(n.metadata);i.current=n.metadata,t({state:n.state,settlement:n.settlement,quote:n.quote,fireFsm:(e,t)=>{r&&d(r,e,t,i.current)},fireSettlement:(e,t)=>{r&&p(r,e,t,n.state)},fireQuote:(e,t)=>{r&&t.status===`ready`&&e!==`ready`&&a(r,{type:`deposit.quote.resolved`,flow:`deposit`,tier:`flow`,payload:{quote:t.payload}})}})}function l(e){if(e.name!==`deposit`){if(e.name===`transferCrypto`)return{method:`transfer`};if(e.name===`assetPicker`)return{method:`wallet`};if(e.name===`amountEntry`)return{method:`wallet`,asset:e.ctx.asset};if(e.name!==`cashAmountEntry`&&e.name!==`cashConfirm`){if(e.name===`confirmDeposit`)return{method:`wallet`,asset:e.ctx.asset};if(e.name===`processing`||e.name===`success`)return e.ctx.method===`transfer`?{method:`transfer`}:{method:`wallet`}}}}function u(e){return e.name===`confirmDeposit`?e.ctx.phase.kind===`submitting`?`submitting`:`confirming`:e.name===`processing`?`processing`:e.name===`deposit`||e.name===`assetPicker`||e.name===`amountEntry`||e.name===`cashAmountEntry`||e.name===`cashConfirm`||e.name===`transferCrypto`?`quoting`:`unknown`}function d(e,t,o,s){if(o.name===`confirmDeposit`&&t.name===`confirmDeposit`){f(e,t.ctx.phase,o.ctx.phase,o);return}if(t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`deposit`,s,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:l(o)}}),a(e,{type:`deposit.step.changed`,flow:`deposit`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`deposit`&&o.name===`assetPicker`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`wallet`}}),t.name===`deposit`&&o.name===`transferCrypto`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`transfer`}}),t.name===`assetPicker`&&o.name===`amountEntry`&&a(e,{type:`deposit.asset.clicked`,flow:`deposit`,tier:`ui`,payload:{asset:o.ctx.asset}}),t.name===`amountEntry`&&o.name===`confirmDeposit`&&a(e,{type:`deposit.amount.submitted`,flow:`deposit`,tier:`ui`,payload:{amount:o.ctx.amount}}),o.name===`confirmDeposit`&&f(e,t.name===`confirmDeposit`?t.ctx.phase:void 0,o.ctx.phase,o),t.name===`confirmDeposit`&&o.name===`processing`&&a(e,{type:`deposit.submission.broadcast`,flow:`deposit`,tier:`flow`,payload:{tx:o.ctx.tx}}),t.name!==`error`&&o.name===`error`&&o.ctx.failure){let r=t.name===`confirmDeposit`?t.ctx.phase:void 0,i=n(o.ctx.failure,o.ctx.failure.cause);r?.kind===`submitting`&&a(e,{type:`deposit.submission.failed`,flow:`deposit`,tier:`flow`,payload:i}),a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...i,kind:`unknown`}})}o.name!==`closed`&&t.name!==`closed`&&`backTarget`in t.ctx&&o.name===t.ctx.backTarget&&a(e,{type:`deposit.back.clicked`,flow:`deposit`,tier:`ui`,payload:{fromStep:t.name}}),t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`deposit.cancelled`,flow:`deposit`,tier:`flow`,payload:{phase:u(t)}}),r(e,`deposit`,{type:`deposit.closed`,flow:`deposit`,tier:`ui`,payload:{atStep:t.name}}))}}function f(e,t,r,i){t?.kind!==r.kind&&((r.kind===`loading`||r.kind===`regenerating`)&&(a(e,{type:`deposit.quote.requested`,flow:`deposit`,tier:`flow`,payload:{input:{asset:i.ctx.asset,amount:i.ctx.amount}}}),r.kind===`regenerating`&&(t?.kind===`submitting`?a(e,{type:`deposit.submission.declined`,flow:`deposit`,tier:`flow`,payload:{}}):t?.kind===`ready`&&a(e,{type:`deposit.quote.expired`,flow:`deposit`,tier:`flow`,payload:{}}))),r.kind===`failed`&&a(e,{type:`deposit.quote.failed`,flow:`deposit`,tier:`flow`,payload:n(r.failure,r.failure.cause)}),r.kind===`submitting`&&a(e,{type:`deposit.submission.confirmed`,flow:`deposit`,tier:`ui`,payload:{}}))}function p(e,t,r,o){if(r.status!==`ready`&&r.status!==`stale`)return;let s=r.payload;if(s.kind===`pending`){t===null?(o.name===`closed`&&i(e,`deposit`,void 0,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:void 0}}),a(e,{type:`deposit.settlement.resumed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}})):a(e,{type:`deposit.settlement.progressed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}if(s.kind===`succeeded`){a(e,{type:`deposit.settlement.succeeded`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}s.kind===`failed`&&a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...n({reason:m(s.failureKind)}),kind:s.failureKind,...s.txHash?.value?{txHash:s.txHash.value}:{}}})}function m(e){return e===`slippage`?`Quote slipped before settlement landed.`:e===`insufficient-gas`?`Bridge gas budget exhausted before settlement.`:e===`execution-reverted`?`Destination transaction reverted on-chain.`:`Settlement failed.`}export{c as useDepositEmissions};
1
+ "use client";import{StridgeEventsContext as e}from"../context.js";import{useDialogLifecycle as t}from"../../shared/orchestrator/useDialogLifecycle.js";import"../../shared/orchestrator/index.js";import{mapFailureInfoToPayload as n}from"./mapFailure.js";import{closeFlowSession as r,openFlowSession as i,publishEvent as a}from"../publish.js";import{use as o,useRef as s}from"react";function c(n){let r=o(e),i=s(n.metadata);i.current=n.metadata,t({state:n.state,settlement:n.settlement,quote:n.quote,fireFsm:(e,t)=>{r&&d(r,e,t,i.current)},fireSettlement:(e,t)=>{r&&p(r,e,t,n.state)},fireQuote:(e,t)=>{r&&t.status===`ready`&&e!==`ready`&&a(r,{type:`deposit.quote.resolved`,flow:`deposit`,tier:`flow`,payload:{quote:t.payload}})}})}function l(e){if(e.name!==`deposit`){if(e.name===`transferCrypto`)return{method:`transfer`};if(e.name===`assetPicker`)return{method:`wallet`};if(e.name===`amountEntry`)return{method:`wallet`,asset:e.ctx.asset};if(e.name!==`onrampAmountEntry`&&e.name!==`onrampConfirm`&&e.name!==`onrampPaymentPending`){if(e.name===`confirmDeposit`)return{method:`wallet`,asset:e.ctx.asset};if(e.name===`processing`||e.name===`success`)return e.ctx.method===`transfer`?{method:`transfer`}:{method:`wallet`}}}}function u(e){return e.name===`confirmDeposit`?e.ctx.phase.kind===`submitting`?`submitting`:`confirming`:e.name===`processing`?`processing`:e.name===`deposit`||e.name===`assetPicker`||e.name===`amountEntry`||e.name===`onrampAmountEntry`||e.name===`onrampConfirm`||e.name===`onrampPaymentPending`||e.name===`transferCrypto`?`quoting`:`unknown`}function d(e,t,o,s){if(o.name===`confirmDeposit`&&t.name===`confirmDeposit`){f(e,t.ctx.phase,o.ctx.phase,o);return}if(t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`deposit`,s,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:l(o)}}),a(e,{type:`deposit.step.changed`,flow:`deposit`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`deposit`&&o.name===`assetPicker`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`wallet`}}),t.name===`deposit`&&o.name===`transferCrypto`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`transfer`}}),t.name===`assetPicker`&&o.name===`amountEntry`&&a(e,{type:`deposit.asset.clicked`,flow:`deposit`,tier:`ui`,payload:{asset:o.ctx.asset}}),t.name===`amountEntry`&&o.name===`confirmDeposit`&&a(e,{type:`deposit.amount.submitted`,flow:`deposit`,tier:`ui`,payload:{amount:o.ctx.amount}}),o.name===`confirmDeposit`&&f(e,t.name===`confirmDeposit`?t.ctx.phase:void 0,o.ctx.phase,o),t.name===`confirmDeposit`&&o.name===`processing`&&a(e,{type:`deposit.submission.broadcast`,flow:`deposit`,tier:`flow`,payload:{tx:o.ctx.tx}}),t.name!==`error`&&o.name===`error`&&o.ctx.failure){let r=t.name===`confirmDeposit`?t.ctx.phase:void 0,i=n(o.ctx.failure,o.ctx.failure.cause);r?.kind===`submitting`&&a(e,{type:`deposit.submission.failed`,flow:`deposit`,tier:`flow`,payload:i}),a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...i,kind:`unknown`}})}o.name!==`closed`&&t.name!==`closed`&&`backTarget`in t.ctx&&o.name===t.ctx.backTarget&&a(e,{type:`deposit.back.clicked`,flow:`deposit`,tier:`ui`,payload:{fromStep:t.name}}),t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`deposit.cancelled`,flow:`deposit`,tier:`flow`,payload:{phase:u(t)}}),r(e,`deposit`,{type:`deposit.closed`,flow:`deposit`,tier:`ui`,payload:{atStep:t.name}}))}}function f(e,t,r,i){t?.kind!==r.kind&&((r.kind===`loading`||r.kind===`regenerating`)&&(a(e,{type:`deposit.quote.requested`,flow:`deposit`,tier:`flow`,payload:{input:{asset:i.ctx.asset,amount:i.ctx.amount}}}),r.kind===`regenerating`&&(t?.kind===`submitting`?a(e,{type:`deposit.submission.declined`,flow:`deposit`,tier:`flow`,payload:{}}):t?.kind===`ready`&&a(e,{type:`deposit.quote.expired`,flow:`deposit`,tier:`flow`,payload:{}}))),r.kind===`failed`&&a(e,{type:`deposit.quote.failed`,flow:`deposit`,tier:`flow`,payload:n(r.failure,r.failure.cause)}),r.kind===`submitting`&&a(e,{type:`deposit.submission.confirmed`,flow:`deposit`,tier:`ui`,payload:{}}))}function p(e,t,r,o){if(r.status!==`ready`&&r.status!==`stale`)return;let s=r.payload;if(s.kind===`pending`){t===null?(o.name===`closed`&&i(e,`deposit`,void 0,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:void 0}}),a(e,{type:`deposit.settlement.resumed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}})):a(e,{type:`deposit.settlement.progressed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}if(s.kind===`succeeded`){a(e,{type:`deposit.settlement.succeeded`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}s.kind===`failed`&&a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...n({reason:m(s.failureKind)}),kind:s.failureKind,...s.txHash?.value?{txHash:s.txHash.value}:{}}})}function m(e){return e===`slippage`?`Quote slipped before settlement landed.`:e===`insufficient-gas`?`Bridge gas budget exhausted before settlement.`:e===`execution-reverted`?`Destination transaction reverted on-chain.`:`Settlement failed.`}export{c as useDepositEmissions};
@@ -1 +1 @@
1
- "use client";import{useDepositSnapshot as e}from"../driver/context.js";import{useControllerContext as t}from"../orchestrator/controller.js";import{useDepositEmissions as n}from"../../../events/emit/useDepositEmissions.js";import"../../../events/emit/index.js";import{useIntercomShutdownOnUnmount as r}from"../../../shared/support/useIntercomShutdownOnUnmount.js";import"../../../shared/support/index.js";import{AdaptiveSurface as i}from"../../../shared/ui/AdaptiveSurface/AdaptiveSurface.js";import"../../../shared/ui/AdaptiveSurface/index.js";import{Deposit as a}from"../widgets/deposit/compound/Deposit.js";import"../widgets/deposit/compound/index.js";import{DepositActivityDetail as o}from"../widgets/activity/DepositActivityDetail.js";import{DepositActivityList as s}from"../widgets/activity/DepositActivityList.js";import"../widgets/activity/index.js";import{AmountEntry as c}from"../widgets/amount-entry/AmountEntry.js";import"../widgets/amount-entry/index.js";import{AssetPicker as l}from"../widgets/asset-picker/AssetPicker.js";import"../widgets/asset-picker/index.js";import{CashAmountEntry as u}from"../widgets/cash-amount-entry/CashAmountEntry.js";import"../widgets/cash-amount-entry/index.js";import{CashConfirm as d}from"../widgets/cash-confirm/CashConfirm.js";import"../widgets/cash-confirm/index.js";import{ConfirmDeposit as f}from"../widgets/confirm-deposit/ConfirmDeposit.js";import"../widgets/confirm-deposit/index.js";import{Deposit as p}from"../widgets/deposit/Deposit.js";import"../widgets/deposit/index.js";import{DepositStatusBanner as m}from"../widgets/deposit-status-banner/DepositStatusBanner.js";import"../widgets/deposit-status-banner/index.js";import{ErrorState as h}from"../widgets/error-state/ErrorState.js";import"../widgets/error-state/index.js";import{ProcessingState as g}from"../widgets/processing-state/ProcessingState.js";import"../widgets/processing-state/index.js";import{SuccessState as _}from"../widgets/success-state/SuccessState.js";import"../widgets/success-state/index.js";import{TransferCrypto as v}from"../widgets/transfer-crypto/TransferCrypto.js";import"../widgets/transfer-crypto/index.js";import{jsx as y,jsxs as b}from"react/jsx-runtime";function x({container:x,metadata:S,onError:C,presentation:w}={}){let{state:T,controller:E}=t(),D=e(),O=T.name!==`closed`;return n({state:T,settlement:D.settlement,quote:D.quote,metadata:S}),r(),y(i,{open:O,onOpenChange:e=>{e||E.close()},container:x,...w?{presentation:w}:{},children:b(a.Boundary,{...C?{onError:C}:{},children:[y(a.Guards,{children:b(a.Steps,{children:[y(a.Step,{name:`deposit`,children:y(p,{})}),y(a.Step,{name:`assetPicker`,children:y(l,{})}),y(a.Step,{name:`amountEntry`,children:y(c,{})}),y(a.Step,{name:`cashAmountEntry`,children:y(u,{})}),y(a.Step,{name:`cashConfirm`,children:y(d,{})}),y(a.Step,{name:`confirmDeposit`,children:y(f,{})}),y(a.Step,{name:`transferCrypto`,children:y(v,{})}),y(a.Step,{name:`processing`,children:y(g,{})}),y(a.Step,{name:`success`,children:y(_,{})}),y(a.Step,{name:`error`,children:y(h,{})}),y(a.Step,{name:`activityList`,children:y(s,{})}),y(a.Step,{name:`activityDetail`,children:y(o,{})})]})}),y(m,{})]})})}export{x as DepositDialog};
1
+ "use client";import{useDepositSnapshot as e}from"../driver/context.js";import{useControllerContext as t}from"../orchestrator/controller.js";import{useDepositEmissions as n}from"../../../events/emit/useDepositEmissions.js";import"../../../events/emit/index.js";import{useIntercomShutdownOnUnmount as r}from"../../../shared/support/useIntercomShutdownOnUnmount.js";import"../../../shared/support/index.js";import{AdaptiveSurface as i}from"../../../shared/ui/AdaptiveSurface/AdaptiveSurface.js";import"../../../shared/ui/AdaptiveSurface/index.js";import{Deposit as a}from"../widgets/deposit/compound/Deposit.js";import"../widgets/deposit/compound/index.js";import{DepositActivityDetail as o}from"../widgets/activity/DepositActivityDetail.js";import{DepositActivityList as s}from"../widgets/activity/DepositActivityList.js";import"../widgets/activity/index.js";import{AmountEntry as c}from"../widgets/amount-entry/AmountEntry.js";import"../widgets/amount-entry/index.js";import{AssetPicker as l}from"../widgets/asset-picker/AssetPicker.js";import"../widgets/asset-picker/index.js";import{ConfirmDeposit as u}from"../widgets/confirm-deposit/ConfirmDeposit.js";import"../widgets/confirm-deposit/index.js";import{Deposit as d}from"../widgets/deposit/Deposit.js";import"../widgets/deposit/index.js";import{DepositStatusBanner as f}from"../widgets/deposit-status-banner/DepositStatusBanner.js";import"../widgets/deposit-status-banner/index.js";import{ErrorState as p}from"../widgets/error-state/ErrorState.js";import"../widgets/error-state/index.js";import{OnrampAmountEntry as m}from"../widgets/onramp-amount-entry/OnrampAmountEntry.js";import"../widgets/onramp-amount-entry/index.js";import{OnrampConfirm as h}from"../widgets/onramp-confirm/OnrampConfirm.js";import"../widgets/onramp-confirm/index.js";import{OnrampPaymentPending as g}from"../widgets/onramp-payment-pending/OnrampPaymentPending.js";import"../widgets/onramp-payment-pending/index.js";import{ProcessingState as _}from"../widgets/processing-state/ProcessingState.js";import"../widgets/processing-state/index.js";import{SuccessState as v}from"../widgets/success-state/SuccessState.js";import"../widgets/success-state/index.js";import{TransferCrypto as y}from"../widgets/transfer-crypto/TransferCrypto.js";import"../widgets/transfer-crypto/index.js";import{jsx as b,jsxs as x}from"react/jsx-runtime";function S({container:S,metadata:C,onError:w,presentation:T}={}){let{state:E,controller:D}=t(),O=e(),k=E.name!==`closed`;return n({state:E,settlement:O.settlement,quote:O.quote,metadata:C}),r(),b(i,{open:k,onOpenChange:e=>{e||D.close()},container:S,...T?{presentation:T}:{},children:x(a.Boundary,{...w?{onError:w}:{},children:[b(a.Guards,{children:x(a.Steps,{children:[b(a.Step,{name:`deposit`,children:b(d,{})}),b(a.Step,{name:`assetPicker`,children:b(l,{})}),b(a.Step,{name:`amountEntry`,children:b(c,{})}),b(a.Step,{name:`onrampAmountEntry`,children:b(m,{})}),b(a.Step,{name:`onrampConfirm`,children:b(h,{})}),b(a.Step,{name:`onrampPaymentPending`,children:b(g,{})}),b(a.Step,{name:`confirmDeposit`,children:b(u,{})}),b(a.Step,{name:`transferCrypto`,children:b(y,{})}),b(a.Step,{name:`processing`,children:b(_,{})}),b(a.Step,{name:`success`,children:b(v,{})}),b(a.Step,{name:`error`,children:b(p,{})}),b(a.Step,{name:`activityList`,children:b(s,{})}),b(a.Step,{name:`activityDetail`,children:b(o,{})})]})}),b(f,{})]})})}export{S as DepositDialog};
@@ -41,16 +41,17 @@ interface WalletPayload {
41
41
  balanceTotalUsd?: FormattedField<number>;
42
42
  }
43
43
  /**
44
- * Capability descriptor for a single cash-rail payment method (Card / Apple Pay / Google Pay).
45
- * Drivers populate the per-method limit + processing-time the deposit-method picker surfaces on
46
- * the cash rows' meta line (`"$116,000.00 limit · Instant"`). Both fields are optional so the
47
- * meta line drops segments gracefully when the driver doesn't surface them yet.
44
+ * Capability descriptor for the onramp ("Cash") rail. The rail is single-method the
45
+ * provider's hosted checkout collects the payment instrument so drivers populate one capability
46
+ * bag with the limit + processing-time the deposit-method picker surfaces on the row's meta line
47
+ * (`"$116,000.00 limit · Instant"`). Both fields are optional so the meta line drops segments
48
+ * gracefully when the driver doesn't surface them yet.
48
49
  */
49
- interface CashMethodCapability {
50
+ interface OnrampMethodCapability {
50
51
  /**
51
- * Per-method maximum deposit, in USD. `value` is the raw ceiling for sorting / range checks;
52
- * `formatted` is the localized currency string (`"$116,000.00"`). The widget composes the
53
- * meta segment from the formatted string plus a localized `" limit"` suffix.
52
+ * Maximum deposit, in USD. `value` is the raw ceiling for sorting / range checks; `formatted`
53
+ * is the localized currency string (`"$116,000.00"`). The widget composes the meta segment
54
+ * from the formatted string plus a localized `" limit"` suffix.
54
55
  */
55
56
  limit?: FormattedField<number>;
56
57
  /**
@@ -61,18 +62,74 @@ interface CashMethodCapability {
61
62
  processingTime?: FormattedField<number>;
62
63
  }
63
64
  /**
64
- * Per-cash-method capability bag surfaced on `DepositSnapshot.cashMethods`. Each key matches a
65
- * method id rendered inside `Deposit.MethodSection`; the orchestrated `Deposit` widget reads each
66
- * row's `limit` + `processingTime` and maps them into the row's meta line. Future cash methods
67
- * (`bankTransfer`, `cashPickup`, …) extend this shape additively.
65
+ * Onramp-rail capability bag surfaced on `DepositSnapshot.onrampMethods`. The rail is single-method
66
+ * (the hosted-checkout provider collects the payment instrument), so this carries one capability
67
+ * directly rather than a per-method map. The orchestrated `Deposit` widget reads the `limit` +
68
+ * `processingTime` and maps them into the "Cash" row's meta line; the onramp amount-entry
69
+ * reads `limit` for its over-limit / unavailable notices.
68
70
  */
69
- interface CashMethodsPayload {
70
- /** Capabilities for the Card method (`Deposit.Method` row in the cash rail). */
71
- card?: CashMethodCapability;
72
- /** Capabilities for the Apple Pay method. */
73
- applePay?: CashMethodCapability;
74
- /** Capabilities for the Google Pay method. */
75
- googlePay?: CashMethodCapability;
71
+ type OnrampMethodsPayload = OnrampMethodCapability;
72
+ /**
73
+ * Receive-asset descriptor for the onramp rail — the crypto the user ends up with after the fiat
74
+ * purchase settles. Mirrors {@link AssetPayload} plus the `chainId` the kit's `TokenLogo` resolver
75
+ * needs, so the onramp amount-entry / confirm screens render the destination token without reaching
76
+ * into another entity.
77
+ */
78
+ interface OnrampReceiveAssetPayload extends AssetPayload {
79
+ /** EIP-155 chain id of the receive asset (drives the token-logo resolver). */
80
+ chainId: number;
81
+ }
82
+ /**
83
+ * Formatted onramp-quote result surfaced on `DepositSnapshot.onrampQuote` — the fiat→crypto pricing
84
+ * the onramp amount-entry hero, receive chip, and fee-breakdown rows read. Backed by the SDK's
85
+ * `OnrampQuoteResponse`. Raw numeric `value`s are kept on the {@link FormattedField}s so widgets can
86
+ * re-derive (e.g. net-of-fees) locally.
87
+ */
88
+ interface OnrampQuotePayload {
89
+ /** Fiat amount the user pays (USD). */
90
+ amountUsd: FormattedField<number>;
91
+ /** Crypto amount the user receives after fees. Drives the Receive chip + hero sub-line. */
92
+ receiveAmount: FormattedField<number>;
93
+ /** The crypto asset the user receives. */
94
+ receiveAsset: OnrampReceiveAssetPayload;
95
+ /** Crypto-per-fiat rate (e.g. USDC per USD). Drives the price row. */
96
+ rate: FormattedField<number>;
97
+ /** Provider processing fee (USD). Omitted when the provider doesn't surface it. */
98
+ processingFeeUsd?: FormattedField<number>;
99
+ /** Network/settlement fee (USD). Omitted when zero / unknown. */
100
+ networkFeeUsd?: FormattedField<number>;
101
+ /** Total fee charged on top of the received crypto (USD). */
102
+ totalFeeUsd: FormattedField<number>;
103
+ /** Resolved hosted-checkout provider name. */
104
+ provider?: string;
105
+ }
106
+ /**
107
+ * Lifecycle state of an onramp checkout session, mirrored 1:1 from the SDK's
108
+ * `OnrampSessionState`. The kit's reducer maps the three terminal values onto its shared
109
+ * `processing` / `success` / `error` screens.
110
+ */
111
+ type OnrampSessionStateName = "SESSION_PENDING" | "SESSION_COMPLETED" | "SESSION_EXPIRED" | "SESSION_FAILED";
112
+ /**
113
+ * Onramp checkout-session payload surfaced on `DepositSnapshot.onrampSession`. Created by
114
+ * {@link import("./types").DepositDriver.createOnrampSession} and advanced by
115
+ * {@link import("./types").DepositDriver.watchOnrampSession}. The `checkoutUrl` is the provider-hosted
116
+ * page the kit redirects (or pops out) to; `state` drives the redirect → poll → terminal UI.
117
+ */
118
+ interface OnrampSessionPayload {
119
+ /** Provider session id (UUID). */
120
+ sessionId: string;
121
+ /** Current session state. */
122
+ state: OnrampSessionStateName;
123
+ /** Provider-hosted checkout URL the user completes payment on. Present once the session is created. */
124
+ checkoutUrl?: string;
125
+ /** Provider order id, once allocated. */
126
+ providerOrderId?: string;
127
+ /** Crypto amount the user receives, captured at create time (display units). */
128
+ receiveAmount?: FormattedField<number>;
129
+ /** Failure code when `state === "SESSION_FAILED"` (e.g. `"payment_declined"`). */
130
+ failureCode?: string;
131
+ /** Session/checkout expiry timestamp (Unix-ms). */
132
+ expiresAt?: number;
76
133
  }
77
134
  /**
78
135
  * Brand context surfaced across the kit's chrome — `<DialogShell>` title, `<ConfirmDeposit>`
@@ -386,4 +443,4 @@ interface SettlementFailurePayload {
386
443
  */
387
444
  type SettlementPayload = SettlementPendingPayload | SettlementSuccessPayload | SettlementFailurePayload;
388
445
  //#endregion
389
- export { AcceptedAssetPayload, AddressItemPayload, AssetPayload, BalanceItemPayload, BrandPayload, CashMethodCapability, CashMethodsPayload, ChainPayload, QuoteBreakdownPayload, QuotePayload, QuoteRoutePayload, SettlementFailurePayload, SettlementPayload, SettlementPendingPayload, SettlementSuccessPayload, SourceWalletPayload, TargetPayload, WalletInfo, WalletPayload };
446
+ export { AcceptedAssetPayload, AddressItemPayload, AssetPayload, BalanceItemPayload, BrandPayload, ChainPayload, OnrampMethodCapability, OnrampMethodsPayload, OnrampQuotePayload, OnrampReceiveAssetPayload, OnrampSessionPayload, OnrampSessionStateName, QuoteBreakdownPayload, QuotePayload, QuoteRoutePayload, SettlementFailurePayload, SettlementPayload, SettlementPendingPayload, SettlementSuccessPayload, SourceWalletPayload, TargetPayload, WalletInfo, WalletPayload };
@@ -1,6 +1,6 @@
1
1
  import { Entity, SettlementFailureKind, TxRef } from "../../../shared/driver/types.js";
2
- import { AcceptedAssetPayload, AddressItemPayload, AssetPayload, BalanceItemPayload, BrandPayload, CashMethodCapability, CashMethodsPayload, ChainPayload, QuoteBreakdownPayload, QuotePayload, QuoteRoutePayload, SettlementFailurePayload, SettlementPayload, SettlementPendingPayload, SettlementSuccessPayload, SourceWalletPayload, TargetPayload, WalletInfo, WalletPayload } from "./payloads.js";
3
- import { DepositAddressDto, GatewaySettlementDto, GatewayStartResponse, GatewayUdaDto, OnchainBalanceResponse, QuoteResponse, SupportedAssetDto, SupportedAssetsResponse } from "@stridge/sdk";
2
+ import { AcceptedAssetPayload, AddressItemPayload, AssetPayload, BalanceItemPayload, BrandPayload, ChainPayload, OnrampMethodCapability, OnrampMethodsPayload, OnrampQuotePayload, OnrampReceiveAssetPayload, OnrampSessionPayload, OnrampSessionStateName, QuoteBreakdownPayload, QuotePayload, QuoteRoutePayload, SettlementFailurePayload, SettlementPayload, SettlementPendingPayload, SettlementSuccessPayload, SourceWalletPayload, TargetPayload, WalletInfo, WalletPayload } from "./payloads.js";
3
+ import { DepositAddressDto, GatewaySettlementDto, GatewayStartResponse, GatewayUdaDto, OnchainBalanceResponse, OnrampQuoteResponse, OnrampSessionResponse, QuoteResponse, SupportedAssetDto, SupportedAssetsResponse } from "@stridge/sdk";
4
4
 
5
5
  //#region src/flows/deposit/driver/types.d.ts
6
6
  /**
@@ -48,14 +48,26 @@ interface DepositSnapshot {
48
48
  */
49
49
  wallet: Entity<WalletPayload, WalletInfo, WalletInfo>;
50
50
  /**
51
- * Per-cash-method capability bag — limits + processing times surfaced on the cash-rail
52
- * method rows' meta line. Optional so BYO drivers shipped before the cash rail existed
53
- * keep type-checking against the contract; readers null-coalesce a missing entity to
54
- * `idle`, which already means "no cash backend wired up yet" in the kit's reducer. The
55
- * live stridge driver wires this through `getCashMethods()` once the cash API ships; the
56
- * mock driver seeds fixtures today.
51
+ * Onramp-rail capability bag — the limit + processing time surfaced on the "Cash"
52
+ * method row's meta line and read by the onramp amount-entry for its over-limit / unavailable
53
+ * notices. Optional so BYO drivers shipped before the onramp rail existed keep type-checking
54
+ * against the contract; readers null-coalesce a missing entity to `idle`, which means "no
55
+ * onramp backend wired up yet". The live stridge driver leaves this `idle` until the rail is
56
+ * exercised; the mock driver seeds a fixture today.
57
57
  */
58
- cashMethods?: Entity<CashMethodsPayload, CashMethodsPayload, CashMethodsPayload>;
58
+ onrampMethods?: Entity<OnrampMethodsPayload, OnrampMethodsPayload, OnrampMethodsPayload>;
59
+ /**
60
+ * Formatted fiat→crypto onramp quote backing the onramp amount-entry hero / receive chip / fee
61
+ * rows. Optional (same back-compat rationale as {@link onrampMethods}); `idle` until
62
+ * {@link DepositDriver.requestOnrampQuote} runs. Backed by the SDK's `OnrampQuoteResponse`.
63
+ */
64
+ onrampQuote?: Entity<OnrampQuotePayload, OnrampQuoteResponse, OnrampQuoteResponse>;
65
+ /**
66
+ * The active onramp checkout session — carries the provider-hosted `checkoutUrl` and the
67
+ * session state the kit polls to a terminal verdict. Optional; `idle` until
68
+ * {@link DepositDriver.createOnrampSession} runs. Backed by the SDK's `OnrampSessionResponse`.
69
+ */
70
+ onrampSession?: Entity<OnrampSessionPayload, OnrampSessionResponse, OnrampSessionResponse>;
59
71
  }
60
72
  /**
61
73
  * Input to {@link DepositDriver.requestQuote}.
@@ -89,6 +101,29 @@ interface SubmitDepositInput {
89
101
  /** Send amount in display units. */
90
102
  amount: number;
91
103
  }
104
+ /**
105
+ * Input to {@link DepositDriver.requestOnrampQuote}. The fiat side is all the backend needs — the
106
+ * receive crypto is derived from the tenant's deposit preferences. The onramp rail is single-method
107
+ * (the provider's hosted checkout collects the payment instrument), so there is no method selector.
108
+ */
109
+ interface RequestOnrampQuoteInput {
110
+ /** Fiat amount the user wants to spend (display units, e.g. dollars). */
111
+ amount: number;
112
+ }
113
+ /**
114
+ * Input to {@link DepositDriver.createOnrampSession}. Binds the priced amount to a provider checkout.
115
+ */
116
+ interface CreateOnrampSessionInput {
117
+ /** Fiat amount to charge (display units). */
118
+ amount: number;
119
+ }
120
+ /**
121
+ * Input to {@link DepositDriver.watchOnrampSession}. Scopes the poll to a single created session.
122
+ */
123
+ interface WatchOnrampSessionInput {
124
+ /** The session id returned by {@link DepositDriver.createOnrampSession}. */
125
+ sessionId: string;
126
+ }
92
127
  /**
93
128
  * Input to {@link DepositDriver.watchSourceTx}. Path B — kit waits for an inbound transfer to the
94
129
  * deposit address.
@@ -205,6 +240,25 @@ interface DepositDriver {
205
240
  * method picker.
206
241
  */
207
242
  fetchActiveSettlement?(input: FetchActiveSettlementInput, signal: AbortSignal): Promise<SettlementSnapshot | null>;
243
+ /**
244
+ * Onramp rail — fetches a fiat→crypto quote and updates the `onrampQuote` entity through its
245
+ * lifecycle (`idle | loading → ready | error`). Optional: drivers without an onramp backend
246
+ * omit it, and the onramp amount-entry falls back to its empty-quote surface. Mirrors
247
+ * {@link requestQuote} for the fiat side.
248
+ */
249
+ requestOnrampQuote?(input: RequestOnrampQuoteInput, signal: AbortSignal): Promise<void>;
250
+ /**
251
+ * Onramp rail — binds the priced amount to a provider checkout session, populates the
252
+ * `onrampSession` entity, and resolves with the created session (carrying `checkoutUrl`). The kit
253
+ * opens `checkoutUrl` in a new tab, then calls {@link watchOnrampSession} to poll. Optional.
254
+ */
255
+ createOnrampSession?(input: CreateOnrampSessionInput, signal: AbortSignal): Promise<OnrampSessionPayload>;
256
+ /**
257
+ * Onramp rail — polls a created session until it reaches a terminal state, firing the listener on
258
+ * every transition (the kit maps `SESSION_COMPLETED` / `SESSION_EXPIRED` / `SESSION_FAILED` onto
259
+ * its shared success / error screens). Mirrors {@link watchSettlement}. Optional.
260
+ */
261
+ watchOnrampSession?(input: WatchOnrampSessionInput, listener: (entity: DepositSnapshot["onrampSession"]) => void, signal: AbortSignal): void;
208
262
  }
209
263
  //#endregion
210
- export { DepositDriver, DepositSnapshot, FetchActiveSettlementInput, RequestQuoteInput, SettlementSnapshot, SubmitDepositInput, WatchSettlementInput, WatchSourceTxInput };
264
+ export { CreateOnrampSessionInput, DepositDriver, DepositSnapshot, FetchActiveSettlementInput, RequestOnrampQuoteInput, RequestQuoteInput, SettlementSnapshot, SubmitDepositInput, WatchOnrampSessionInput, WatchSettlementInput, WatchSourceTxInput };
@@ -1 +1 @@
1
- "use client";import{useOptionalActivityDriverInstance as e}from"../../activity/driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useDepositDriverInstance as s}from"../driver/context.js";import{initialState as c,reducer as l}from"./reducer.js";import{resolveAssetById as u}from"./resolveAssetById.js";import{createContext as d,use as f,useCallback as p,useEffect as m,useMemo as h,useReducer as g,useRef as _}from"react";import{jsx as v}from"react/jsx-runtime";const y={id:`ELhVSL`,message:`Failed to submit deposit.`},b={id:`Ej5HL9`,message:`Signature declined. Please try again.`},x=d(null);x.displayName=`GatewayControllerStateContext`;const S=d(null);S.displayName=`GatewayControllerStableContext`;function C(){let e=f(x),t=f(S);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function w(){let e=f(S);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function T(){return f(S)}const E=d(void 0);E.displayName=`DepositMethodsConfigContext`;function D(){return f(E)}const O=d(!1);O.displayName=`CashRailUnlockedContext`;function k(){return f(O)}function A(e){let t=D();return h(()=>t?e.filter(e=>e.value===`cash`?t.cashRail?.disabled!==!0:!0):e,[e,t])}function j(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function M(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function N(){return w().actions}function P({methodsConfig:t,cashRailUnlocked:n=!1,children:r}){let a=s(),o=e(),[u,d]=g(l,c),f=I(u,d,a,o);L(u,d,a),R(u,d,a,o);let p=i(u),m=F(u,d,a,f,t);return v(E,{value:t,children:v(O,{value:n,children:v(S,{value:h(()=>({dispatch:d,controller:m,actions:f}),[d,m,f]),children:v(x,{value:h(()=>({state:u,effectiveState:p}),[u,p]),children:r})})})})}function F(e,t,n,r,i){let a=_(n);a.current=n;let o=_(i);o.current=i;let s=p(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=u(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=p(()=>{t({type:`CLOSE`})},[t]);return h(()=>({open:s,close:c,actions:r}),[s,c,r])}function I(e,r,i,o){let s=_(e);s.current=e;let c=_(i);c.current=i;let l=_(o);l.current=o;let u=_(r);u.current=r;let{i18n:d}=t(),f=_(d);f.current=d;let m=p((e,t)=>{let r=c.current,i=new AbortController,o=B(e,t);r.submitDeposit(o,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(y));if(a(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(b)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),g=p(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),v=p(e=>{u.current({type:`CASH_METHOD_SELECTED`,cashMethod:e})},[]),x=p(e=>{u.current({type:`CASH_AMOUNT_CONFIRMED`,amount:e})},[]),S=p(()=>{u.current({type:`CASH_METHOD_READY`})},[]),C=p(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),w=p(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),T=p(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),m(n,r)},[m]),E=p(()=>{u.current({type:`BACK`})},[]),D=p(()=>{u.current({type:`CLOSE`})},[]),O=p(()=>{u.current({type:`SUCCESS_DONE`})},[]),k=p(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),A=p((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),j=p((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),M=p(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),N=p(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),P=p(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return h(()=>({selectMethod:g,selectCashMethod:v,confirmCashAmount:x,cashMethodReady:S,confirmAsset:C,confirmAmount:w,confirmDeposit:T,back:E,close:D,successDone:O,tryAgain:k,resumeToProcessing:A,resumeToSuccess:j,resumeToError:M,openActivity:N,selectSettlement:P}),[g,v,x,S,C,w,T,E,D,O,k,A,j,M,N,P])}function L(e,t,r){m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=z(e.ctx.asset,e.ctx.amount);return r.requestQuote(a,i.signal).catch(e=>{i.signal.aborted||t({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>i.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,r,t]),m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let n=e.ctx.phase.quoteExpiresAt,r=Math.max(0,n-Date.now()),i=setTimeout(()=>{t({type:`QUOTE_EXPIRED`})},r);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,t])}function R(e,t,n,i){let a=_(i);a.current=i;let s=e.name===`processing`?e.ctx.tx:void 0;o(n,s?{tx:s}:void 0,s?.hash),m(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{a.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let c=e.name===`activityList`||e.name===`activityDetail`;m(()=>{if(!c||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[c,i]),m(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||c||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,c,n]);let l=_(e);l.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}l.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let u=_(null);m(()=>{let e=()=>{let e=n.getSnapshot(),r=l.current,i=e.quote;i.status!==u.current&&(u.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}}))},r=n.subscribe(e);return e(),r},[n,t])}function z(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function B(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{P as GatewayController,k as useCashRailUnlocked,C as useControllerContext,N as useDepositActions,M as useDepositEffectiveState,D as useDepositMethodsConfig,j as useDepositState,A as useEnabledRails,T as useOptionalStableControllerContext,w as useStableControllerContext};
1
+ "use client";import{useOptionalActivityDriverInstance as e}from"../../activity/driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{useOnrampSessionWatcher as a}from"../../../shared/orchestrator/useOnrampSessionWatcher.js";import{isUserRejectionFailure as o}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as s}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useDepositDriverInstance as c}from"../driver/context.js";import{openCheckoutPopup as l}from"../shared/checkoutPopup.js";import{initialState as u,reducer as d}from"./reducer.js";import{resolveAssetById as f}from"./resolveAssetById.js";import{createContext as p,use as m,useCallback as h,useEffect as g,useMemo as _,useReducer as v,useRef as y}from"react";import{jsx as b}from"react/jsx-runtime";const x={id:`ELhVSL`,message:`Failed to submit deposit.`},S={id:`Ej5HL9`,message:`Signature declined. Please try again.`},C={id:`Z0UMar`,message:`Failed to fetch quote.`},w={id:`9d3cBd`,message:`Failed to open the payment window. Please try again.`},T=p(null);T.displayName=`GatewayControllerStateContext`;const E=p(null);E.displayName=`GatewayControllerStableContext`;function D(){let e=m(T),t=m(E);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function O(){let e=m(E);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function k(){return m(E)}const A=p(void 0);A.displayName=`DepositMethodsConfigContext`;function j(){return m(A)}function M(e){let t=j();return _(()=>t?e.filter(e=>e.value===`onramp`?t.onrampRail?.disabled!==!0:!0):e,[e,t])}function N(){let e=m(T);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function P(){let e=m(T);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function F(){return O().actions}function I({methodsConfig:t,children:n}){let r=c(),a=e(),[o,s]=v(d,u),l=R(o,s,r,a);z(o,s,r),B(o,s,r,a);let f=i(o),p=L(o,s,r,l,t);return b(A,{value:t,children:b(E,{value:_(()=>({dispatch:s,controller:p,actions:l}),[s,p,l]),children:b(T,{value:_(()=>({state:o,effectiveState:f}),[o,f]),children:n})})})}function L(e,t,n,r,i){let a=y(n);a.current=n;let o=y(i);o.current=i;let s=h(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=f(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=h(()=>{t({type:`CLOSE`})},[t]);return _(()=>({open:s,close:c,actions:r}),[s,c,r])}function R(e,r,i,a){let s=y(e);s.current=e;let c=y(i);c.current=i;let l=y(a);l.current=a;let u=y(r);u.current=r;let{i18n:d}=t(),f=y(d);f.current=d;let p=h((e,t)=>{let r=c.current,i=new AbortController,a=H(e,t);r.submitDeposit(a,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(x));if(o(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(S)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),m=h(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),g=h(()=>{u.current({type:`ONRAMP_SELECTED`})},[]),v=h(e=>{s.current.name===`onrampAmountEntry`&&u.current({type:`ONRAMP_AMOUNT_CHANGED`,amount:e})},[]),b=h(e=>{u.current({type:`ONRAMP_AMOUNT_CONFIRMED`,amount:e})},[]),C=h(()=>{let e=s.current;if(e.name!==`onrampConfirm`)return;let t=e.ctx.phase;t.kind!==`ready`&&t.kind!==`failed`||u.current({type:`ONRAMP_CONFIRMED`})},[]),w=h(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),T=h(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),E=h(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),p(n,r)},[p]),D=h(()=>{u.current({type:`BACK`})},[]),O=h(()=>{u.current({type:`CLOSE`})},[]),k=h(()=>{u.current({type:`SUCCESS_DONE`})},[]),A=h(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),j=h((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),M=h((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),N=h(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),P=h(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),F=h(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return _(()=>({selectMethod:m,selectOnramp:g,setOnrampAmount:v,confirmOnrampAmount:b,confirmOnramp:C,confirmAsset:w,confirmAmount:T,confirmDeposit:E,back:D,close:O,successDone:k,tryAgain:A,resumeToProcessing:j,resumeToSuccess:M,resumeToError:N,openActivity:P,selectSettlement:F}),[m,g,v,b,C,w,T,E,D,O,k,A,j,M,N,P,F])}function z(e,r,i){let{i18n:a}=t(),o=y(a);o.current=a;let s=e.name===`onrampAmountEntry`?e.ctx.amount:void 0;g(()=>{if(e.name!==`onrampAmountEntry`||!i.requestOnrampQuote)return;let t=s;if(t==null||!Number.isFinite(t)||t<=0)return;let n=new AbortController,r=setTimeout(()=>{i.requestOnrampQuote?.({amount:t},n.signal).catch(()=>{})},400);return()=>{clearTimeout(r),n.abort()}},[e.name,s,i]);let c=e.name===`onrampConfirm`&&e.ctx.phase.kind===`loading`,u=e.name===`onrampConfirm`?e.ctx.amount:void 0;g(()=>{if(!c||!i.requestOnrampQuote||u==null)return;let e=new AbortController;return i.requestOnrampQuote({amount:u},e.signal).catch(t=>{e.signal.aborted||r({type:`ONRAMP_QUOTE_FAILED`,failure:n(t,o.current._(C))})}),()=>e.abort()},[c,u,i,r]);let d=e.name===`onrampConfirm`&&e.ctx.phase.kind===`creating`,f=e.name===`onrampConfirm`?e.ctx.amount:void 0;g(()=>{if(!d||f==null)return;if(!i.createOnrampSession){r({type:`ONRAMP_SESSION_FAILED`,failure:{reason:o.current._(w)}});return}let e=new AbortController;return i.createOnrampSession({amount:f},e.signal).then(t=>{if(!e.signal.aborted){if(!t.checkoutUrl){r({type:`ONRAMP_SESSION_FAILED`,failure:{reason:o.current._(w)}});return}l(t.checkoutUrl),r({type:`ONRAMP_SESSION_CREATED`,sessionId:t.sessionId,checkoutUrl:t.checkoutUrl})}}).catch(t=>{e.signal.aborted||r({type:`ONRAMP_SESSION_FAILED`,failure:n(t,o.current._(w))})}),()=>e.abort()},[d,f,i,r]),g(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let t=new AbortController,a=V(e.ctx.asset,e.ctx.amount);return i.requestQuote(a,t.signal).catch(e=>{t.signal.aborted||r({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>t.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,i,r]),g(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let t=e.ctx.phase.quoteExpiresAt,n=Math.max(0,t-Date.now()),i=setTimeout(()=>{r({type:`QUOTE_EXPIRED`})},n);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,r])}function B(e,t,n,i){let o=y(i);o.current=i;let c=e.name===`processing`?e.ctx.tx:void 0;s(n,c?{tx:c}:void 0,c?.hash);let l=e.name===`onrampPaymentPending`?e.ctx.sessionId:void 0;a(n,l?{sessionId:l}:void 0,l),g(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{o.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let u=e.name===`activityList`||e.name===`activityDetail`;g(()=>{if(!u||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[u,i]),g(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||u||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,u,n]);let d=y(e);d.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}d.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let f=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.quote;i.status!==f.current&&(f.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}}))},r=n.subscribe(e);return e(),r},[n,t]);let p=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.onrampQuote,a=i?.status??`idle`;a!==p.current&&(p.current=a,!(r.name!==`onrampConfirm`||r.ctx.phase.kind!==`loading`)&&(a===`ready`||a===`stale`?t({type:`ONRAMP_QUOTE_RESOLVED`}):a===`error`&&i?.status===`error`&&t({type:`ONRAMP_QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}})))},r=n.subscribe(e);return e(),r},[n,t]);let m=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.onrampSession,a=i?.status===`ready`||i?.status===`stale`?i.payload.state:i?.status??`idle`;if(a!==m.current&&(m.current=a,r.name===`onrampPaymentPending`)){if(a===`SESSION_COMPLETED`)t({type:`ONRAMP_SESSION_COMPLETED`});else if(a===`SESSION_EXPIRED`)t({type:`ONRAMP_SESSION_EXPIRED`});else if(a===`SESSION_FAILED`){let e=i?.status===`ready`||i?.status===`stale`?i.payload.failureCode:void 0;t({type:`ONRAMP_SESSION_FAILED`,failure:{reason:e??`Payment failed.`,...e?{code:e}:{}}})}}},r=n.subscribe(e);return e(),r},[n,t])}function V(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function H(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{I as GatewayController,D as useControllerContext,F as useDepositActions,P as useDepositEffectiveState,j as useDepositMethodsConfig,N as useDepositState,M as useEnabledRails,k as useOptionalStableControllerContext,O as useStableControllerContext};
@@ -1,5 +1,5 @@
1
1
  import { FailureInfo } from "../../../shared/orchestrator/types.js";
2
- import { CashConfirmPhase, CashMethodId, ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositMethodConfig, DepositMethodsConfig, DepositRailConfig, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec } from "./types.js";
2
+ import { ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositMethodConfig, DepositMethodsConfig, DepositRailConfig, DepositState, DepositStateName, GatewayEvent, OnrampConfirmPhase, OpenInput, ResolvedOpenInput, RetryTargetSpec } from "./types.js";
3
3
  import { useDepositState } from "./controller.js";
4
4
  import { STEPS_WITH_OWN_SETTLEMENT_VIEW, stepRendersSettlement } from "./steps.js";
5
5
  import { useDeposit } from "./useDeposit.js";
@@ -1 +1 @@
1
- import{createActivityReducers as e}from"../../../shared/orchestrator/createActivityReducers.js";import"../../../shared/orchestrator/index.js";import{assertNever as t}from"../../../shared/utils/assertNever.js";const n={name:`closed`},{reduceFromActivityList:r,reduceFromActivityDetail:i}=e({activityList:e=>({name:`activityList`,ctx:{backTarget:e}}),activityDetail:(e,t,n)=>({name:`activityDetail`,ctx:{settlementId:e,backTarget:t,viaList:n}}),closed:()=>({name:`closed`}),restoreFromBackTarget:e=>_(e)});function a(e,n){if(n.type===`RESUME_TO_PROCESSING`)return e.name===`closed`?e:{name:`processing`,ctx:{method:n.method,tx:n.tx,retryTargetForFailure:{kind:`fresh`}}};if(n.type===`RESUME_TO_SUCCESS`)return e.name===`closed`?e:{name:`success`,ctx:{method:n.method,tx:n.tx}};if(n.type===`RESUME_TO_ERROR`)return e.name===`closed`?e:{name:`error`,ctx:{retryTarget:{kind:`fresh`},...n.tx?{tx:n.tx}:{}}};switch(e.name){case`closed`:return o(n);case`deposit`:return s(e,n);case`assetPicker`:return c(e,n);case`amountEntry`:return l(e,n);case`cashAmountEntry`:return u(e,n);case`cashConfirm`:return d(e,n);case`confirmDeposit`:return f(e,n);case`transferCrypto`:return p(e,n);case`processing`:return m(e,n);case`success`:return h(e,n);case`error`:return g(e,n);case`activityList`:return r(e,n);case`activityDetail`:return i(e,n);default:return t(e)}}function o(e){if(e.type!==`OPEN`)return{name:`closed`};let t=e.input;return t?t.method===`transfer`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`closed`}}:t.asset?{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`closed`}}:{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`closed`}}:{name:`deposit`,ctx:{backTarget:`closed`}}}function s(e,t){switch(t.type){case`DEPOSIT_METHOD_SELECTED`:return t.method===`wallet`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`deposit`}};case`CASH_METHOD_SELECTED`:return{name:`cashAmountEntry`,ctx:{method:`cash`,cashMethod:t.cashMethod,backTarget:`deposit`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`deposit`,backTarget:`closed`}}};case`BACK`:case`CLOSE`:return{name:`closed`};default:return e}}function c(e,t){switch(t.type){case`ASSET_CONFIRMED`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`assetPicker`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`assetPicker`,method:`wallet`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function l(e,t){switch(t.type){case`AMOUNT_CONFIRMED`:return{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.ctx.asset,amount:t.amount,phase:{kind:`loading`},backTarget:`amountEntry`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`amountEntry`,method:`wallet`,asset:e.ctx.asset,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function u(e,t){switch(t.type){case`CASH_AMOUNT_CONFIRMED`:return{name:`cashConfirm`,ctx:{method:`cash`,cashMethod:e.ctx.cashMethod,amount:t.amount,phase:{kind:`loading`},backTarget:`cashAmountEntry`}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function d(e,t){let n=e.ctx.phase;switch(t.type){case`CASH_METHOD_READY`:return n.kind===`loading`?{...e,ctx:{...e.ctx,phase:{kind:`ready`}}}:e;case`BACK`:return{name:`cashAmountEntry`,ctx:{method:`cash`,cashMethod:e.ctx.cashMethod,backTarget:`deposit`,amount:e.ctx.amount}};case`CLOSE`:return{name:`closed`};default:return e}}function f(e,t){let n=e.ctx.phase;switch(t.type){case`QUOTE_RESOLVED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`ready`,quoteExpiresAt:t.expiresAt}}}:e;case`QUOTE_FAILED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`quote`}}}:e;case`QUOTE_RETRY`:return n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`loading`}}}:e;case`QUOTE_EXPIRED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`}}}:e;case`DEPOSIT_CONFIRMED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`submitting`}}}:e;case`DEPOSIT_SUBMITTED`:if(n.kind===`submitting`){let n={kind:`confirmDepositReady`,method:`wallet`,asset:e.ctx.asset,amount:e.ctx.amount};return{name:`processing`,ctx:{method:`wallet`,tx:t.tx,retryTargetForFailure:n}}}return e;case`DEPOSIT_SUBMISSION_FAILED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`submission`}}}:e;case`DEPOSIT_SIGNATURE_DECLINED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`,...t.notice?{notice:t.notice}:{}}}}:e;case`BACK`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:e.ctx.asset,backTarget:`assetPicker`}};case`CLOSE`:return{name:`closed`};default:return e}}function p(e,t){switch(t.type){case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`transferCrypto`,method:`transfer`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function m(e,t){switch(t.type){case`PROCESSING_SUCCEEDED`:return{name:`success`,ctx:{method:e.ctx.method,tx:e.ctx.tx}};case`PROCESSING_FAILED`:return{name:`error`,ctx:{retryTarget:e.ctx.retryTargetForFailure,tx:e.ctx.tx}};case`CLOSE`:return{name:`closed`};default:return e}}function h(e,t){return t.type===`SUCCESS_DONE`||t.type===`CLOSE`?{name:`closed`}:e}function g(e,t){return t.type===`ERROR_TRY_AGAIN`?v(e.ctx.retryTarget):t.type===`CLOSE`?{name:`closed`}:e}function _(e){return e.kind===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:e.backTarget}}:e.kind===`amountEntry`?{name:`amountEntry`,ctx:{method:`wallet`,asset:e.asset,backTarget:e.backTarget}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}}function v(e){return e.kind===`fresh`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`transferCrypto`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}:{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.asset,amount:e.amount,phase:{kind:`loading`},backTarget:`amountEntry`}}}export{n as initialState,a as reducer};
1
+ import{createActivityReducers as e}from"../../../shared/orchestrator/createActivityReducers.js";import"../../../shared/orchestrator/index.js";import{assertNever as t}from"../../../shared/utils/assertNever.js";const n={name:`closed`},{reduceFromActivityList:r,reduceFromActivityDetail:i}=e({activityList:e=>({name:`activityList`,ctx:{backTarget:e}}),activityDetail:(e,t,n)=>({name:`activityDetail`,ctx:{settlementId:e,backTarget:t,viaList:n}}),closed:()=>({name:`closed`}),restoreFromBackTarget:e=>v(e)});function a(e,n){if(n.type===`RESUME_TO_PROCESSING`)return e.name===`closed`?e:{name:`processing`,ctx:{method:n.method,tx:n.tx,retryTargetForFailure:{kind:`fresh`}}};if(n.type===`RESUME_TO_SUCCESS`)return e.name===`closed`?e:{name:`success`,ctx:{method:n.method,tx:n.tx}};if(n.type===`RESUME_TO_ERROR`)return e.name===`closed`?e:{name:`error`,ctx:{retryTarget:{kind:`fresh`},...n.tx?{tx:n.tx}:{}}};switch(e.name){case`closed`:return o(n);case`deposit`:return s(e,n);case`assetPicker`:return c(e,n);case`amountEntry`:return l(e,n);case`onrampAmountEntry`:return u(e,n);case`onrampConfirm`:return d(e,n);case`onrampPaymentPending`:return f(e,n);case`confirmDeposit`:return p(e,n);case`transferCrypto`:return m(e,n);case`processing`:return h(e,n);case`success`:return g(e,n);case`error`:return _(e,n);case`activityList`:return r(e,n);case`activityDetail`:return i(e,n);default:return t(e)}}function o(e){if(e.type!==`OPEN`)return{name:`closed`};let t=e.input;return t?t.method===`transfer`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`closed`}}:t.asset?{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`closed`}}:{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`closed`}}:{name:`deposit`,ctx:{backTarget:`closed`}}}function s(e,t){switch(t.type){case`DEPOSIT_METHOD_SELECTED`:return t.method===`wallet`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`deposit`}};case`ONRAMP_SELECTED`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`deposit`,backTarget:`closed`}}};case`BACK`:case`CLOSE`:return{name:`closed`};default:return e}}function c(e,t){switch(t.type){case`ASSET_CONFIRMED`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`assetPicker`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`assetPicker`,method:`wallet`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function l(e,t){switch(t.type){case`AMOUNT_CONFIRMED`:return{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.ctx.asset,amount:t.amount,phase:{kind:`loading`},backTarget:`amountEntry`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`amountEntry`,method:`wallet`,asset:e.ctx.asset,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function u(e,t){switch(t.type){case`ONRAMP_AMOUNT_CHANGED`:return t.amount===null?{...e,ctx:{...e.ctx,amount:void 0}}:{...e,ctx:{...e.ctx,amount:t.amount}};case`ONRAMP_AMOUNT_CONFIRMED`:return{name:`onrampConfirm`,ctx:{method:`onramp`,amount:t.amount,phase:{kind:`loading`},backTarget:`onrampAmountEntry`}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function d(e,t){let n=e.ctx.phase;switch(t.type){case`ONRAMP_QUOTE_RESOLVED`:return n.kind===`loading`?{...e,ctx:{...e.ctx,phase:{kind:`ready`}}}:e;case`ONRAMP_QUOTE_FAILED`:return n.kind===`loading`||n.kind===`creating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure}}}:e;case`ONRAMP_CONFIRMED`:return n.kind===`ready`||n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`creating`}}}:e;case`ONRAMP_SESSION_CREATED`:return n.kind===`creating`?{name:`onrampPaymentPending`,ctx:{method:`onramp`,amount:e.ctx.amount,sessionId:t.sessionId,checkoutUrl:t.checkoutUrl,backTarget:`onrampConfirm`}}:e;case`ONRAMP_SESSION_FAILED`:return n.kind===`creating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure}}}:e;case`BACK`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`,amount:e.ctx.amount}};case`CLOSE`:return{name:`closed`};default:return e}}function f(e,t){switch(t.type){case`ONRAMP_SESSION_COMPLETED`:return{name:`success`,ctx:{method:`onramp`,sessionId:e.ctx.sessionId}};case`ONRAMP_SESSION_EXPIRED`:return{name:`error`,ctx:{retryTarget:{kind:`onrampAmountEntry`},sessionId:e.ctx.sessionId,...t.failure?{failure:t.failure}:{}}};case`ONRAMP_SESSION_FAILED`:return{name:`error`,ctx:{retryTarget:{kind:`onrampAmountEntry`},sessionId:e.ctx.sessionId,failure:t.failure}};case`BACK`:return{name:`onrampConfirm`,ctx:{method:`onramp`,amount:e.ctx.amount,phase:{kind:`ready`},backTarget:`onrampAmountEntry`}};case`CLOSE`:return{name:`closed`};default:return e}}function p(e,t){let n=e.ctx.phase;switch(t.type){case`QUOTE_RESOLVED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`ready`,quoteExpiresAt:t.expiresAt}}}:e;case`QUOTE_FAILED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`quote`}}}:e;case`QUOTE_RETRY`:return n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`loading`}}}:e;case`QUOTE_EXPIRED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`}}}:e;case`DEPOSIT_CONFIRMED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`submitting`}}}:e;case`DEPOSIT_SUBMITTED`:if(n.kind===`submitting`){let n={kind:`confirmDepositReady`,method:`wallet`,asset:e.ctx.asset,amount:e.ctx.amount};return{name:`processing`,ctx:{method:`wallet`,tx:t.tx,retryTargetForFailure:n}}}return e;case`DEPOSIT_SUBMISSION_FAILED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`submission`}}}:e;case`DEPOSIT_SIGNATURE_DECLINED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`,...t.notice?{notice:t.notice}:{}}}}:e;case`BACK`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:e.ctx.asset,backTarget:`assetPicker`}};case`CLOSE`:return{name:`closed`};default:return e}}function m(e,t){switch(t.type){case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`transferCrypto`,method:`transfer`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function h(e,t){switch(t.type){case`PROCESSING_SUCCEEDED`:return{name:`success`,ctx:{method:e.ctx.method,tx:e.ctx.tx}};case`PROCESSING_FAILED`:return{name:`error`,ctx:{retryTarget:e.ctx.retryTargetForFailure,tx:e.ctx.tx}};case`CLOSE`:return{name:`closed`};default:return e}}function g(e,t){return t.type===`SUCCESS_DONE`||t.type===`CLOSE`?{name:`closed`}:e}function _(e,t){return t.type===`ERROR_TRY_AGAIN`?y(e.ctx.retryTarget):t.type===`CLOSE`?{name:`closed`}:e}function v(e){return e.kind===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:e.backTarget}}:e.kind===`amountEntry`?{name:`amountEntry`,ctx:{method:`wallet`,asset:e.asset,backTarget:e.backTarget}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}}function y(e){return e.kind===`fresh`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`onrampAmountEntry`?{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`}}:e.kind===`transferCrypto`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}:{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.asset,amount:e.amount,phase:{kind:`loading`},backTarget:`amountEntry`}}}export{n as initialState,a as reducer};