@stridge/kit 0.1.0-alpha.57 → 0.1.0-alpha.58
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/events/bus/createBus.d.ts +20 -1
- package/dist/events/bus/createBus.js +1 -1
- package/dist/events/emit/useDepositEmissions.js +1 -1
- package/dist/events/emit/useWithdrawEmissions.js +1 -1
- package/dist/events/hooks/useStridgeEvent.d.ts +2 -1
- package/dist/events/hooks/useStridgeEvent.js +1 -1
- package/dist/events/hooks/useStridgeEventBus.d.ts +5 -4
- package/dist/events/hooks/useStridgeEvents.d.ts +2 -1
- package/dist/events/hooks/useStridgeEvents.js +1 -1
- package/dist/events/index.d.ts +4 -2
- package/dist/events/index.js +1 -1
- package/dist/events/publish.js +1 -1
- package/dist/events/redact.d.ts +34 -0
- package/dist/events/redact.js +1 -0
- package/dist/flows/deposit/orchestrator/controller.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/package.js +1 -1
- package/dist/shared/orchestrator/toFailure.js +1 -1
- package/dist/shared/orchestrator/types.d.ts +8 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +1 -0
- package/package.json +1 -1
|
@@ -3,5 +3,24 @@ import { StridgeEvent } from "../types/index.js";
|
|
|
3
3
|
//#region src/events/bus/createBus.d.ts
|
|
4
4
|
/** Handler shape — accepts a typed event, returns nothing (return values are ignored). */
|
|
5
5
|
type EventHandler<TEvent extends StridgeEvent = StridgeEvent> = (event: TEvent) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Per-subscription options shared by every subscribe method.
|
|
8
|
+
*/
|
|
9
|
+
interface SubscribeOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Immediately replay the active `<flow>.opened` event(s) to this handler at subscribe time,
|
|
12
|
+
* for any flow whose session is currently open. Lets a late subscriber recover the session
|
|
13
|
+
* start (and the `flowId` + frozen `metadata` it carries) instead of silently missing it.
|
|
14
|
+
*
|
|
15
|
+
* Only the `<flow>.opened` event is replayed — never `quote`, `settlement`, or other
|
|
16
|
+
* mid-flow events. The replayed envelope is identical to the one live subscribers received
|
|
17
|
+
* (same `timestamp`, `flowId`, `metadata`); it is not flagged as a replay. Because `opened`
|
|
18
|
+
* events are `tier: "ui"`, replay reaches `subscribeToAll` / `useStridgeEvents` and
|
|
19
|
+
* `subscribeToEvent("<flow>.opened", …)` — the flow-only surfaces never carry it.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue `false`
|
|
22
|
+
*/
|
|
23
|
+
replayOpenSession?: boolean;
|
|
24
|
+
}
|
|
6
25
|
//#endregion
|
|
7
|
-
export { EventHandler };
|
|
26
|
+
export { EventHandler, SubscribeOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(){let e=new Set,t=new Set,n=new Map,r=!1;function
|
|
1
|
+
function e(){let e=new Set,t=new Set,n=new Map,r=new Map,i=!1;function a(e,t){try{e(t)}catch(e){console.error(`[stridge/kit] handler for "${t.type}" threw:`,e)}}function o(r){if(i)return;if(r.tier===`flow`)for(let t of e)a(t,r);for(let e of t)a(e,r);let o=n.get(r.type);if(o)for(let e of o)a(e,r)}function s(e,t){return e.add(t),()=>{e.delete(t)}}function c(e,t){let r=n.get(e);return r||(r=new Set,n.set(e,r)),r.add(t),()=>{let r=n.get(e);r&&(r.delete(t),r.size===0&&n.delete(e))}}function l(e,t,n){if(!(i||!t?.replayOpenSession))for(let t of r.values())n(t)&&a(e,t)}return{emit:o,subscribeToFlow:(t,n)=>{let r=s(e,t);return l(t,n,e=>e.tier===`flow`),r},subscribeToFlowEvent:(e,t,n)=>{let r=c(e,t);return l(t,n,t=>t.type===e),r},subscribeToAll:(e,n)=>{let r=s(t,e);return l(e,n,()=>!0),r},subscribeToEvent:(e,t,n)=>{let r=c(e,t);return l(t,n,t=>t.type===e),r},retainOpenSession:e=>{i||r.set(e.flow,e)},releaseOpenSession:e=>{r.delete(e)},dispose:()=>{i=!0,e.clear(),t.clear(),n.clear(),r.clear()}}}export{e as createBus};
|
|
@@ -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);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.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!==`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 +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(r){let i=o(e),c=s(r.metadata);c.current=r.metadata,t({state:r.state,settlement:r.settlement,quote:r.quote,fireFsm:(e,t)=>{i&&u(i,e,t,c.current)},fireSettlement:(e,t)=>{i&&d(i,t)},fireQuote:(e,t)=>{i&&t.status!==e&&(t.status===`ready`&&a(i,{type:`withdraw.quote.resolved`,flow:`withdraw`,tier:`flow`,payload:{quote:t.payload}}),t.status===`error`&&a(i,{type:`withdraw.quote.failed`,flow:`withdraw`,tier:`flow`,payload:n({reason:t.error.message||`Quote failed.`,...t.error.name?{code:t.error.name}:{}},t.error)}))}})}function l(e){return e.name===`form`?`quoting`:e.name===`submitting`?`confirming`:e.name===`inProgress`?`processing`:`unknown`}function u(e,t,o,s){let c=t.name===`form`&&!!t.ctx?.notice;if(o.name===`form`&&o.ctx?.notice&&!c&&a(e,{type:`withdraw.submission.declined`,flow:`withdraw`,tier:`flow`,payload:{}}),t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`withdraw`,s,{type:`withdraw.opened`,flow:`withdraw`,tier:`ui`,payload:{}}),a(e,{type:`withdraw.step.changed`,flow:`withdraw`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`form`&&o.name===`submitting`&&a(e,{type:`withdraw.submission.confirmed`,flow:`withdraw`,tier:`ui`,payload:{}}),t.name===`submitting`&&o.name===`inProgress`&&o.ctx.tx&&a(e,{type:`withdraw.submission.broadcast`,flow:`withdraw`,tier:`flow`,payload:{input:o.ctx.input,tx:o.ctx.tx}}),o.name===`error`){let t=o.ctx.failure;if(t!==void 0&&o.ctx.tx===void 0&&t){let r=n(t);a(e,{type:`withdraw.submission.failed`,flow:`withdraw`,tier:`flow`,payload:r}),a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...r,kind:`unknown`}})}}t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`withdraw.cancelled`,flow:`withdraw`,tier:`flow`,payload:{phase:l(t)}}),r(e,`withdraw`,{type:`withdraw.closed`,flow:`withdraw`,tier:`ui`,payload:{atStep:t.name}}))}}function d(e,t){if(t.status!==`ready`&&t.status!==`stale`)return;let r=t.payload;if(r.kind===`pending`){a(e,{type:`withdraw.settlement.progressed`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}if(r.kind===`succeeded`){a(e,{type:`withdraw.settlement.succeeded`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}r.kind===`failed`&&a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...n({reason:f(r.failureKind)}),kind:r.failureKind,...r.txHash?.value?{txHash:r.txHash.value}:{}}})}function f(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 useWithdrawEmissions};
|
|
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(r){let i=o(e),c=s(r.metadata);c.current=r.metadata,t({state:r.state,settlement:r.settlement,quote:r.quote,fireFsm:(e,t)=>{i&&u(i,e,t,c.current)},fireSettlement:(e,t)=>{i&&d(i,t)},fireQuote:(e,t)=>{i&&t.status!==e&&(t.status===`ready`&&a(i,{type:`withdraw.quote.resolved`,flow:`withdraw`,tier:`flow`,payload:{quote:t.payload}}),t.status===`error`&&a(i,{type:`withdraw.quote.failed`,flow:`withdraw`,tier:`flow`,payload:n({reason:t.error.message||`Quote failed.`,...t.error.name?{code:t.error.name}:{}},t.error)}))}})}function l(e){return e.name===`form`?`quoting`:e.name===`submitting`?`confirming`:e.name===`inProgress`?`processing`:`unknown`}function u(e,t,o,s){let c=t.name===`form`&&!!t.ctx?.notice;if(o.name===`form`&&o.ctx?.notice&&!c&&a(e,{type:`withdraw.submission.declined`,flow:`withdraw`,tier:`flow`,payload:{}}),t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`withdraw`,s,{type:`withdraw.opened`,flow:`withdraw`,tier:`ui`,payload:{}}),a(e,{type:`withdraw.step.changed`,flow:`withdraw`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`form`&&o.name===`submitting`&&a(e,{type:`withdraw.submission.confirmed`,flow:`withdraw`,tier:`ui`,payload:{}}),t.name===`submitting`&&o.name===`inProgress`&&o.ctx.tx&&a(e,{type:`withdraw.submission.broadcast`,flow:`withdraw`,tier:`flow`,payload:{input:o.ctx.input,tx:o.ctx.tx}}),o.name===`error`){let t=o.ctx.failure;if(t!==void 0&&o.ctx.tx===void 0&&t){let r=n(t,t.cause);a(e,{type:`withdraw.submission.failed`,flow:`withdraw`,tier:`flow`,payload:r}),a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...r,kind:`unknown`}})}}t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`withdraw.cancelled`,flow:`withdraw`,tier:`flow`,payload:{phase:l(t)}}),r(e,`withdraw`,{type:`withdraw.closed`,flow:`withdraw`,tier:`ui`,payload:{atStep:t.name}}))}}function d(e,t){if(t.status!==`ready`&&t.status!==`stale`)return;let r=t.payload;if(r.kind===`pending`){a(e,{type:`withdraw.settlement.progressed`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}if(r.kind===`succeeded`){a(e,{type:`withdraw.settlement.succeeded`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}r.kind===`failed`&&a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...n({reason:f(r.failureKind)}),kind:r.failureKind,...r.txHash?.value?{txHash:r.txHash.value}:{}}})}function f(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 useWithdrawEmissions};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { StridgeEvent } from "../types/index.js";
|
|
2
|
+
import { SubscribeOptions } from "../bus/createBus.js";
|
|
2
3
|
|
|
3
4
|
//#region src/events/hooks/useStridgeEvent.d.ts
|
|
4
5
|
declare function useStridgeEvent<TType extends StridgeEvent["type"]>(type: TType, handler: (event: Extract<StridgeEvent, {
|
|
5
6
|
type: TType;
|
|
6
|
-
}>) => void): void;
|
|
7
|
+
}>) => void, options?: SubscribeOptions): void;
|
|
7
8
|
//#endregion
|
|
8
9
|
export { useStridgeEvent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i,a){let
|
|
1
|
+
"use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i,a,o){let s=n(e),c=t(a),l=o?.replayOpenSession??!1;r(()=>{if(s)return s.bus.subscribeToEvent(i,e=>c.current(e),{replayOpenSession:l})},[s,c,i,l])}export{i as useStridgeEvent};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FlowEvent, StridgeEvent } from "../types/index.js";
|
|
2
|
-
import { EventHandler } from "../bus/createBus.js";
|
|
2
|
+
import { EventHandler, SubscribeOptions } from "../bus/createBus.js";
|
|
3
3
|
|
|
4
4
|
//#region src/events/hooks/useStridgeEventBus.d.ts
|
|
5
5
|
/**
|
|
@@ -8,17 +8,18 @@ import { EventHandler } from "../bus/createBus.js";
|
|
|
8
8
|
*
|
|
9
9
|
* `subscribeToFlow` / `subscribeToFlowEvent` narrow the handler to `flow:*` events only
|
|
10
10
|
* (headless-safe). `subscribeToAll` / `subscribeToEvent` are the firehose — they see every
|
|
11
|
-
* event the kit emits regardless of tier.
|
|
11
|
+
* event the kit emits regardless of tier, and accept {@link SubscribeOptions} (e.g.
|
|
12
|
+
* `replayOpenSession`) since the `<flow>.opened` event they can replay is `tier: "ui"`.
|
|
12
13
|
*/
|
|
13
14
|
interface PublicStridgeEventBus {
|
|
14
15
|
subscribeToFlow: (handler: EventHandler<FlowEvent>) => () => void;
|
|
15
16
|
subscribeToFlowEvent: <TType extends FlowEvent["type"]>(type: TType, handler: EventHandler<Extract<FlowEvent, {
|
|
16
17
|
type: TType;
|
|
17
18
|
}>>) => () => void;
|
|
18
|
-
subscribeToAll: (handler: EventHandler<StridgeEvent
|
|
19
|
+
subscribeToAll: (handler: EventHandler<StridgeEvent>, options?: SubscribeOptions) => () => void;
|
|
19
20
|
subscribeToEvent: <TType extends StridgeEvent["type"]>(type: TType, handler: EventHandler<Extract<StridgeEvent, {
|
|
20
21
|
type: TType;
|
|
21
|
-
}
|
|
22
|
+
}>>, options?: SubscribeOptions) => () => void;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Returns the provider-scoped bus accessor, or `null` when no `<StridgeProvider>` is
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StridgeEvent } from "../types/index.js";
|
|
2
|
+
import { SubscribeOptions } from "../bus/createBus.js";
|
|
2
3
|
|
|
3
4
|
//#region src/events/hooks/useStridgeEvents.d.ts
|
|
4
|
-
declare function useStridgeEvents(handler: (event: StridgeEvent) => void): void;
|
|
5
|
+
declare function useStridgeEvents(handler: (event: StridgeEvent) => void, options?: SubscribeOptions): void;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { useStridgeEvents };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i){let
|
|
1
|
+
"use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i,a){let o=n(e),s=t(i),c=a?.replayOpenSession??!1;r(()=>{if(o)return o.bus.subscribeToAll(e=>s.current(e),{replayOpenSession:c})},[o,s,c])}export{i as useStridgeEvents};
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KIT_VERSION } from "../version.js";
|
|
1
2
|
import { FlowIdKey } from "./bus/flowIdRegistry.js";
|
|
2
3
|
import { useCurrentFlowId } from "./hooks/useCurrentFlowId.js";
|
|
3
4
|
import { FailureCode, FailurePayloadBase, StridgeEventBase, StridgeEventFlow, StridgeEventTier } from "./types/envelope.js";
|
|
@@ -6,10 +7,11 @@ import { DepositAmountChangedEvent, DepositAmountSubmittedEvent, DepositAssetCli
|
|
|
6
7
|
import { KitEvent, KitSupportClickedEvent, KitTermsClickedEvent } from "./types/kit.js";
|
|
7
8
|
import { WithdrawAmountChangedEvent, WithdrawBreakdownClickedEvent, WithdrawCancelPhase, WithdrawCancelledEvent, WithdrawClosedEvent, WithdrawEvent, WithdrawFlowEvent, WithdrawMaxClickedEvent, WithdrawOpenedEvent, WithdrawQuoteExpiredEvent, WithdrawQuoteFailedEvent, WithdrawQuoteRequestedEvent, WithdrawQuoteResolvedEvent, WithdrawReceiveChainChangedEvent, WithdrawReceiveTokenChangedEvent, WithdrawRecipientChangedEvent, WithdrawSettlementFailedEvent, WithdrawSettlementFailurePayload, WithdrawSettlementProgressedEvent, WithdrawSettlementSucceededEvent, WithdrawStepChangedEvent, WithdrawSubmissionBroadcastEvent, WithdrawSubmissionConfirmedEvent, WithdrawSubmissionDeclinedEvent, WithdrawSubmissionFailedEvent, WithdrawSubmitClickedEvent, WithdrawUiEvent } from "./types/withdraw.js";
|
|
8
9
|
import { FlowEvent, FlowEventType, StridgeEvent, StridgeEventType, UiEvent, UiEventType } from "./types/index.js";
|
|
10
|
+
import { EventHandler, SubscribeOptions } from "./bus/createBus.js";
|
|
9
11
|
import { useStridgeEvent } from "./hooks/useStridgeEvent.js";
|
|
10
|
-
import { EventHandler } from "./bus/createBus.js";
|
|
11
12
|
import { PublicStridgeEventBus, useStridgeEventBus } from "./hooks/useStridgeEventBus.js";
|
|
12
13
|
import { useStridgeEvents } from "./hooks/useStridgeEvents.js";
|
|
13
14
|
import { useStridgeFlowEvent } from "./hooks/useStridgeFlowEvent.js";
|
|
14
15
|
import { useStridgeFlowEvents } from "./hooks/useStridgeFlowEvents.js";
|
|
15
|
-
|
|
16
|
+
import { RedactEventOptions, redactEvent } from "./redact.js";
|
|
17
|
+
export { type ActivityClosedEvent, type ActivityEvent, type ActivityOpenedEvent, type ActivitySelectionVia, type ActivitySettlementSelectedEvent, type ActivityStepChangedEvent, type ActivityUiEvent, type DepositAmountChangedEvent, type DepositAmountSubmittedEvent, type DepositAssetClickedEvent, type DepositBackClickedEvent, type DepositCancelPhase, type DepositCancelledEvent, type DepositClosedEvent, type DepositConfirmClickedEvent, type DepositEvent, type DepositFlowEvent, type DepositMaxClickedEvent, type DepositMethodClickedEvent, type DepositOpenedEvent, type DepositQuoteExpiredEvent, type DepositQuoteFailedEvent, type DepositQuoteRequestInput, type DepositQuoteRequestedEvent, type DepositQuoteResolvedEvent, type DepositSettlementFailedEvent, type DepositSettlementFailurePayload, type DepositSettlementProgressedEvent, type DepositSettlementResumedEvent, type DepositSettlementSucceededEvent, type DepositStepChangedEvent, type DepositSubmissionBroadcastEvent, type DepositSubmissionConfirmedEvent, type DepositSubmissionDeclinedEvent, type DepositSubmissionFailedEvent, type DepositTransferAddressCopiedEvent, type DepositTransferChainChangedEvent, type DepositTransferTokenChangedEvent, type DepositUiEvent, type EventHandler, type FailureCode, type FailurePayloadBase, type FlowEvent, type FlowEventType, type FlowIdKey, KIT_VERSION, type KitEvent, type KitSupportClickedEvent, type KitTermsClickedEvent, type PublicStridgeEventBus, type RedactEventOptions, type StridgeEvent, type StridgeEventBase, type StridgeEventFlow, type StridgeEventTier, type StridgeEventType, type SubscribeOptions, type UiEvent, type UiEventType, type WithdrawAmountChangedEvent, type WithdrawBreakdownClickedEvent, type WithdrawCancelPhase, type WithdrawCancelledEvent, type WithdrawClosedEvent, type WithdrawEvent, type WithdrawFlowEvent, type WithdrawMaxClickedEvent, type WithdrawOpenedEvent, type WithdrawQuoteExpiredEvent, type WithdrawQuoteFailedEvent, type WithdrawQuoteRequestedEvent, type WithdrawQuoteResolvedEvent, type WithdrawReceiveChainChangedEvent, type WithdrawReceiveTokenChangedEvent, type WithdrawRecipientChangedEvent, type WithdrawSettlementFailedEvent, type WithdrawSettlementFailurePayload, type WithdrawSettlementProgressedEvent, type WithdrawSettlementSucceededEvent, type WithdrawStepChangedEvent, type WithdrawSubmissionBroadcastEvent, type WithdrawSubmissionConfirmedEvent, type WithdrawSubmissionDeclinedEvent, type WithdrawSubmissionFailedEvent, type WithdrawSubmitClickedEvent, type WithdrawUiEvent, redactEvent, useCurrentFlowId, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents };
|
package/dist/events/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{KIT_VERSION as e}from"../version.js";import{useCurrentFlowId as t}from"./hooks/useCurrentFlowId.js";import{useStridgeEvent as n}from"./hooks/useStridgeEvent.js";import{useStridgeEventBus as r}from"./hooks/useStridgeEventBus.js";import{useStridgeEvents as i}from"./hooks/useStridgeEvents.js";import{useStridgeFlowEvent as a}from"./hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as o}from"./hooks/useStridgeFlowEvents.js";import"./hooks/index.js";import{redactEvent as s}from"./redact.js";export{e as KIT_VERSION,s as redactEvent,t as useCurrentFlowId,n as useStridgeEvent,r as useStridgeEventBus,i as useStridgeEvents,a as useStridgeFlowEvent,o as useStridgeFlowEvents};
|
package/dist/events/publish.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e({bus:e,flowIds:t,metadata:n},r){let i=null;if(r.flow!==`kit`&&(i=t.current(r.flow),i===null))
|
|
1
|
+
function e({bus:e,flowIds:t,metadata:n},r){let i=null;if(r.flow!==`kit`&&(i=t.current(r.flow),i===null))return process.env.NODE_ENV!==`production`&&console.warn(`[stridge/kit] tried to emit "${r.type}" but no active "${r.flow}" flow — the event was dropped. This usually means an emit fired before "opened" or after the terminal event.`),null;let a=r.flow===`kit`?{}:n.read(r.flow),o={type:r.type,flow:r.flow,tier:r.tier,timestamp:Date.now(),flowId:i,payload:r.payload,metadata:a};return e.emit(o),o}function t(t,n,i,a){r(n,a.flow,`openFlowSession`),t.flowIds.open(n),t.metadata.snapshot(n,i);let o=e(t,{...a,flow:n});o&&t.bus.retainOpenSession(o)}function n(t,n,i){r(n,i.flow,`closeFlowSession`),e(t,{...i,flow:n}),t.bus.releaseOpenSession(n),t.flowIds.close(n),t.metadata.clear(n)}function r(e,t,n){process.env.NODE_ENV!==`production`&&e!==t&&console.error(`[stridge/kit] ${n}() called with flow="${e}" but partial.flow="${t}". Override applied (envelope will carry "${e}") but this is a sign of a copy-paste bug in the emit site.`)}export{n as closeFlowSession,t as openFlowSession,e as publishEvent};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StridgeEvent } from "./types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/events/redact.d.ts
|
|
4
|
+
/** Options for {@link redactEvent}. Both default to `true`. */
|
|
5
|
+
interface RedactEventOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Mask EVM-address-like substrings (`0x` + 40 hex) anywhere in the payload to
|
|
8
|
+
* `0x1234…cdef`. Only EVM addresses are matched — the pattern is precise enough to avoid
|
|
9
|
+
* mangling unrelated hex (tx hashes are 64 hex and are left intact). Defaults to `true`.
|
|
10
|
+
*/
|
|
11
|
+
maskAddresses?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Drop `payload.cause` (the debug-only raw error). Defaults to `true`. Set `false` only if
|
|
14
|
+
* the destination is an error tracker that should keep the stack and you accept the
|
|
15
|
+
* forwarded contents.
|
|
16
|
+
*/
|
|
17
|
+
dropCause?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Return a privacy-redacted deep copy of `event`, safe to forward to a third-party analytics
|
|
21
|
+
* backend. Drops `payload.cause` and masks EVM addresses by default; preserves `type`, `flow`,
|
|
22
|
+
* `tier`, `timestamp`, `flowId`, and consumer-supplied `metadata`. The input is never mutated.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* useStridgeEvents((e) => {
|
|
27
|
+
* const safe = redactEvent(e);
|
|
28
|
+
* mixpanel.track(safe.type, { flowId: safe.flowId, ...safe.payload });
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function redactEvent<E extends StridgeEvent>(event: E, options?: RedactEventOptions): E;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { RedactEventOptions, redactEvent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=/0x[0-9a-fA-F]{40}(?![0-9a-fA-F])/g;function t(t){return t.replace(e,e=>`${e.slice(0,6)}…${e.slice(-4)}`)}function n(e,r,i,a){if(typeof e==`string`)return r.maskAddresses?t(e):e;if(typeof e!=`object`||!e||a>=8)return e;let o=i.get(e);if(o!==void 0)return o;if(Array.isArray(e)){let t=[];i.set(e,t);for(let o of e)t.push(n(o,r,i,a+1));return t}let s={};i.set(e,s);for(let[t,o]of Object.entries(e)){if(t===`cause`){if(r.dropCause)continue;s[t]=o;continue}s[t]=n(o,r,i,a+1)}return s}function r(e,t){let r={maskAddresses:t?.maskAddresses??!0,dropCause:t?.dropCause??!0},i=n(e.payload,r,new WeakMap,0);return{...e,payload:i}}export{r as redactEvent};
|
|
@@ -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}}))},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{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};
|
package/dist/index.d.ts
CHANGED
|
@@ -21,16 +21,19 @@ import { createKitStorage } from "./storage/createKitStorage.js";
|
|
|
21
21
|
import { DEFAULT_KIT_STORAGE_NAMESPACE, KitStorageProvider, useKitStorage, useKitStorageValue, useOptionalKitStorage } from "./storage/context.js";
|
|
22
22
|
import { useActivitySnapshot } from "./flows/activity/driver/context.js";
|
|
23
23
|
import { StridgeEnvironment } from "./drivers/stridge/types.js";
|
|
24
|
+
import { KIT_VERSION } from "./version.js";
|
|
24
25
|
import { FlowIdKey } from "./events/bus/flowIdRegistry.js";
|
|
25
26
|
import { useCurrentFlowId } from "./events/hooks/useCurrentFlowId.js";
|
|
26
27
|
import { ActivityActions, ActivityController, ActivityState, ActivityStateName } from "./flows/activity/orchestrator/types.js";
|
|
27
28
|
import { WithdrawActions, WithdrawController, WithdrawState, WithdrawStateName, WithdrawSubmitActions, WithdrawSubmitCallback, WithdrawSubmitInput, WithdrawalFormSnapshot } from "./flows/withdraw/orchestrator/types.js";
|
|
28
29
|
import { FlowEvent, StridgeEvent, UiEvent } from "./events/types/index.js";
|
|
30
|
+
import { SubscribeOptions } from "./events/bus/createBus.js";
|
|
29
31
|
import { useStridgeEvent } from "./events/hooks/useStridgeEvent.js";
|
|
30
32
|
import { PublicStridgeEventBus, useStridgeEventBus } from "./events/hooks/useStridgeEventBus.js";
|
|
31
33
|
import { useStridgeEvents } from "./events/hooks/useStridgeEvents.js";
|
|
32
34
|
import { useStridgeFlowEvent } from "./events/hooks/useStridgeFlowEvent.js";
|
|
33
35
|
import { useStridgeFlowEvents } from "./events/hooks/useStridgeFlowEvents.js";
|
|
36
|
+
import { RedactEventOptions, redactEvent } from "./events/redact.js";
|
|
34
37
|
import { useActivityState } from "./flows/activity/orchestrator/controller.js";
|
|
35
38
|
import { useActivity, useOptionalActivity, useOptionalPrefetchActivity, usePrefetchActivity } from "./flows/activity/orchestrator/useActivity.js";
|
|
36
39
|
import { useDepositState } from "./flows/deposit/orchestrator/controller.js";
|
|
@@ -45,4 +48,4 @@ import { useWithdrawState } from "./flows/withdraw/orchestrator/controller.js";
|
|
|
45
48
|
import { useOptionalWithdraw, usePrefetchWithdraw, useWithdraw } from "./flows/withdraw/orchestrator/useWithdraw.js";
|
|
46
49
|
import { ConnectWalletConfig } from "./shared/wallet/ConnectWalletContext.js";
|
|
47
50
|
import { StridgeAppearance, StridgeAsset, StridgeDepositDestination, StridgeDepositFlowConfig, StridgeDepositMethodConfig, StridgeDepositMethodsConfig, StridgeFlowOwner, StridgePrefetchConfig, StridgeProvider, StridgeStorageConfig, StridgeWithdrawFlowConfig } from "./stridge/StridgeProvider.js";
|
|
48
|
-
export { type ActivityActions, type ActivityAmount, type ActivityController, type ActivityDirection, type ActivityDriver, type ActivityOpenInput, type ActivityPayload, type ActivityRowPayload, type ActivitySnapshot, type ActivityState, type ActivityStateName, type ActivityStatus, type ActivityStatusType, type BannerAckBucket, type CardBrand, type CardData, type CashMethodCapability, type CashMethodId, type CashMethodsPayload, type ChainLogoInput, type ChainLogoMeta, type ChainType, type ConnectWalletConfig, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositBindings, type DepositController, type DepositMethod, type DepositMethodConfig, type DepositMethodsConfig, type OpenInput as DepositOpenInput, type DepositRailConfig, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type FlowEvent, type FlowIdKey, type IntercomMerchantContext, KitPortalScope, KitStorageProvider, type LogosNamespace, type Presentation, type PresentationConfig, type PresentationMode, type PublicStridgeEventBus, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeDepositMethodConfig, type StridgeDepositMethodsConfig, type StridgeEnvironment, type StridgeEvent, type StridgeFlowOwner, type StridgePrefetchConfig, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SupportConfig, type SupportOpenContext, type TermsConfig, type TermsSelectContext, type TokenLogoInput, type TokenizationResult, type TxRef, type UiEvent, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, isValidAddressForChainType, isValidEvmAddress, isValidTronAddress, logos, resolveStorageAdapter, toChainType, useActivity, useActivitySnapshot, useActivityState, useBannerAck, useBannerAckForSettlement, useCurrentFlowId, useDeposit, useDepositBindings, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalActivity, useOptionalDeposit, useOptionalKitStorage, useOptionalPrefetchActivity, useOptionalWithdraw, usePrefetchActivity, usePrefetchDeposit, usePrefetchWithdraw, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
|
|
51
|
+
export { type ActivityActions, type ActivityAmount, type ActivityController, type ActivityDirection, type ActivityDriver, type ActivityOpenInput, type ActivityPayload, type ActivityRowPayload, type ActivitySnapshot, type ActivityState, type ActivityStateName, type ActivityStatus, type ActivityStatusType, type BannerAckBucket, type CardBrand, type CardData, type CashMethodCapability, type CashMethodId, type CashMethodsPayload, type ChainLogoInput, type ChainLogoMeta, type ChainType, type ConnectWalletConfig, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositBindings, type DepositController, type DepositMethod, type DepositMethodConfig, type DepositMethodsConfig, type OpenInput as DepositOpenInput, type DepositRailConfig, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type FlowEvent, type FlowIdKey, type IntercomMerchantContext, KIT_VERSION, KitPortalScope, KitStorageProvider, type LogosNamespace, type Presentation, type PresentationConfig, type PresentationMode, type PublicStridgeEventBus, type RedactEventOptions, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeDepositMethodConfig, type StridgeDepositMethodsConfig, type StridgeEnvironment, type StridgeEvent, type StridgeFlowOwner, type StridgePrefetchConfig, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SubscribeOptions, type SupportConfig, type SupportOpenContext, type TermsConfig, type TermsSelectContext, type TokenLogoInput, type TokenizationResult, type TxRef, type UiEvent, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, isValidAddressForChainType, isValidEvmAddress, isValidTronAddress, logos, redactEvent, resolveStorageAdapter, toChainType, useActivity, useActivitySnapshot, useActivityState, useBannerAck, useBannerAckForSettlement, useCurrentFlowId, useDeposit, useDepositBindings, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalActivity, useOptionalDeposit, useOptionalKitStorage, useOptionalPrefetchActivity, useOptionalWithdraw, usePrefetchActivity, usePrefetchDeposit, usePrefetchWithdraw, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidAddressForChainType as e,isValidEvmAddress as t,isValidTronAddress as n,toChainType as r}from"./shared/chains/index.js";import{logos as i}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as a,createMemoryStorageAdapter as o,createSessionStorageAdapter as s,resolveStorageAdapter as c}from"./storage/adapters.js";import{createKitStorage as l}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as u,KitStorageProvider as d,useKitStorage as f,useKitStorageValue as p,useOptionalKitStorage as m}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as h,bucketFromSettlement as g,useBannerAck as _,useBannerAckForSettlement as v}from"./banners/useBannerAck.js";import"./banners/index.js";import{
|
|
1
|
+
import{isValidAddressForChainType as e,isValidEvmAddress as t,isValidTronAddress as n,toChainType as r}from"./shared/chains/index.js";import{logos as i}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as a,createMemoryStorageAdapter as o,createSessionStorageAdapter as s,resolveStorageAdapter as c}from"./storage/adapters.js";import{createKitStorage as l}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as u,KitStorageProvider as d,useKitStorage as f,useKitStorageValue as p,useOptionalKitStorage as m}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as h,bucketFromSettlement as g,useBannerAck as _,useBannerAckForSettlement as v}from"./banners/useBannerAck.js";import"./banners/index.js";import{KIT_VERSION as y}from"./version.js";import{useCurrentFlowId as b}from"./events/hooks/useCurrentFlowId.js";import{useStridgeEvent as x}from"./events/hooks/useStridgeEvent.js";import{useStridgeEventBus as S}from"./events/hooks/useStridgeEventBus.js";import{useStridgeEvents as C}from"./events/hooks/useStridgeEvents.js";import{useStridgeFlowEvent as w}from"./events/hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as T}from"./events/hooks/useStridgeFlowEvents.js";import{redactEvent as E}from"./events/redact.js";import"./events/index.js";import{useActivitySnapshot as D}from"./flows/activity/driver/context.js";import{useActivityState as O}from"./flows/activity/orchestrator/controller.js";import{useActivity as k,useOptionalActivity as A,useOptionalPrefetchActivity as j,usePrefetchActivity as M}from"./flows/activity/orchestrator/useActivity.js";import"./flows/activity/orchestrator/index.js";import{useDepositBindings as N}from"./flows/deposit/bindings/DepositBindings.js";import"./flows/deposit/bindings/index.js";import{useDepositSnapshot as P}from"./flows/deposit/driver/context.js";import{useDepositState as F}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as I,useOptionalDeposit as L,usePrefetchDeposit as R}from"./flows/deposit/orchestrator/useDeposit.js";import{useWithdrawBindings as z}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{useWithdrawSnapshot as B}from"./flows/withdraw/driver/context.js";import{useWithdrawState as V}from"./flows/withdraw/orchestrator/controller.js";import{useOptionalWithdraw as H,usePrefetchWithdraw as U,useWithdraw as W}from"./flows/withdraw/orchestrator/useWithdraw.js";import"./flows/withdraw/orchestrator/index.js";import{useKitConfig as G}from"./scope/context.js";import{KitPortalScope as K}from"./scope/KitPortalScope.js";import{StridgeProvider as q}from"./stridge/StridgeProvider.js";export{u as DEFAULT_KIT_STORAGE_NAMESPACE,y as KIT_VERSION,K as KitPortalScope,d as KitStorageProvider,q as StridgeProvider,h as bannerAckStorageKey,g as bucketFromSettlement,l as createKitStorage,a as createLocalStorageAdapter,o as createMemoryStorageAdapter,s as createSessionStorageAdapter,e as isValidAddressForChainType,t as isValidEvmAddress,n as isValidTronAddress,i as logos,E as redactEvent,c as resolveStorageAdapter,r as toChainType,k as useActivity,D as useActivitySnapshot,O as useActivityState,_ as useBannerAck,v as useBannerAckForSettlement,b as useCurrentFlowId,I as useDeposit,N as useDepositBindings,P as useDepositSnapshot,F as useDepositState,G as useKitConfig,f as useKitStorage,p as useKitStorageValue,A as useOptionalActivity,L as useOptionalDeposit,m as useOptionalKitStorage,j as useOptionalPrefetchActivity,H as useOptionalWithdraw,M as usePrefetchActivity,R as usePrefetchDeposit,U as usePrefetchWithdraw,x as useStridgeEvent,S as useStridgeEventBus,C as useStridgeEvents,w as useStridgeFlowEvent,T as useStridgeFlowEvents,W as useWithdraw,z as useWithdrawBindings,B as useWithdrawSnapshot,V as useWithdrawState};
|
package/dist/package.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`0.1.0-alpha.
|
|
1
|
+
var e=`0.1.0-alpha.58`;export{e as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){if(e instanceof Error){let n=e.cause;if(n&&typeof n==`object`){let r=n;if(r.success===!1&&typeof r.error==`string`&&r.error.trim())return{reason:e.message||t,code:r.error}}return{reason:e.message||t,code:e.name}}return{reason:t}}export{e as toFailure};
|
|
1
|
+
function e(e,t){if(e instanceof Error){let n=e.cause;if(n&&typeof n==`object`){let r=n;if(r.success===!1&&typeof r.error==`string`&&r.error.trim())return{reason:e.message||t,code:r.error,cause:e}}return{reason:e.message||t,code:e.name,cause:e}}return{reason:t,cause:e}}export{e as toFailure};
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
interface FailureInfo {
|
|
16
16
|
reason: string;
|
|
17
17
|
code?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The original thrown value (typically an `Error` with a stack), retained for debugging and
|
|
20
|
+
* error reporting. Rides through to the event bus as {@link FailurePayloadBase.cause} so
|
|
21
|
+
* consumers can `Sentry.captureException(e.payload.cause)` with a real stack instead of a
|
|
22
|
+
* bare reason string. `undefined` for failures with no JS error origin (e.g. settlement
|
|
23
|
+
* failures decoded from a driver `failureKind` enum). Never rendered to users.
|
|
24
|
+
*/
|
|
25
|
+
cause?: unknown;
|
|
18
26
|
}
|
|
19
27
|
//#endregion
|
|
20
28
|
export { FailureInfo };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/version.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolved at build time by tsdown's `define` (the `__STRIDGE_KIT_VERSION__` token is replaced
|
|
4
|
+
* with the `package.json` version string). The `typeof` guard keeps the reference safe in test
|
|
5
|
+
* runners and any environment where the token was not substituted — there it falls back to the
|
|
6
|
+
* sentinel `"0.0.0-dev"` instead of throwing on an undeclared identifier.
|
|
7
|
+
*/
|
|
8
|
+
declare const KIT_VERSION: string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { KIT_VERSION };
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`0.1.0-alpha.58`;export{e as KIT_VERSION};
|