@stridge/kit 0.1.0-alpha.31 → 0.1.0-alpha.33
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/deposit/compound/index.d.ts +1 -1
- package/dist/drivers/stridge/createStridgeWithdrawDriver.js +1 -1
- package/dist/events/bus/createBus.d.ts +7 -0
- package/dist/events/bus/createBus.js +1 -0
- package/dist/events/bus/flowIdRegistry.d.ts +17 -0
- package/dist/events/bus/flowIdRegistry.js +1 -0
- package/dist/events/bus/index.js +1 -0
- package/dist/events/bus/metadata.js +1 -0
- package/dist/events/context.js +1 -0
- package/dist/events/emit/index.js +1 -0
- package/dist/events/emit/mapFailure.js +1 -0
- package/dist/events/emit/useDepositEmissions.js +1 -0
- package/dist/events/emit/useKitEmitter.js +1 -0
- package/dist/events/emit/useWithdrawEmissions.js +1 -0
- package/dist/events/hooks/index.d.ts +6 -0
- package/dist/events/hooks/index.js +1 -0
- package/dist/events/hooks/useCurrentFlowId.d.ts +6 -0
- package/dist/events/hooks/useCurrentFlowId.js +1 -0
- package/dist/events/hooks/useStableHandler.js +1 -0
- package/dist/events/hooks/useStridgeEvent.d.ts +8 -0
- package/dist/events/hooks/useStridgeEvent.js +1 -0
- package/dist/events/hooks/useStridgeEventBus.d.ts +33 -0
- package/dist/events/hooks/useStridgeEventBus.js +1 -0
- package/dist/events/hooks/useStridgeEvents.d.ts +6 -0
- package/dist/events/hooks/useStridgeEvents.js +1 -0
- package/dist/events/hooks/useStridgeFlowEvent.d.ts +8 -0
- package/dist/events/hooks/useStridgeFlowEvent.js +1 -0
- package/dist/events/hooks/useStridgeFlowEvents.d.ts +6 -0
- package/dist/events/hooks/useStridgeFlowEvents.js +1 -0
- package/dist/events/index.d.ts +14 -0
- package/dist/events/index.js +1 -0
- package/dist/events/publish.js +1 -0
- package/dist/events/types/deposit.d.ts +235 -0
- package/dist/events/types/envelope.d.ts +145 -0
- package/dist/events/types/index.d.ts +31 -0
- package/dist/events/types/kit.d.ts +23 -0
- package/dist/events/types/withdraw.d.ts +150 -0
- package/dist/flows/deposit/dialog/DepositDialog.d.ts +14 -81
- package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.js +1 -1
- package/dist/flows/deposit/widgets/confirm-deposit/ConfirmDeposit.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/TransferCrypto.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/TransferCrypto.d.ts +1 -1
- package/dist/flows/withdraw/dialog/WithdrawDialog.d.ts +27 -109
- package/dist/flows/withdraw/dialog/WithdrawDialog.js +1 -1
- package/dist/flows/withdraw/driver/transformers/settlementToWithdrawalPayload.js +1 -1
- package/dist/flows/withdraw/orchestrator/controller.js +1 -1
- package/dist/flows/withdraw/orchestrator/types.d.ts +18 -1
- package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.d.ts +5 -13
- package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-in-progress/WithdrawInProgress.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-success/WithdrawSuccess.js +1 -1
- package/dist/i18n/locales/ar.js +1 -1
- package/dist/i18n/locales/es.js +1 -1
- package/dist/i18n/locales/source-keys.d.ts +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -1
- package/dist/package.js +1 -1
- package/dist/shared/support/SupportLink.js +1 -1
- package/dist/shared/terms/TermsLink.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Hero.d.ts +4 -1
- package/dist/shared/widgets/processing-state/compound/components/Hero.js +1 -1
- package/dist/stridge/StridgeProvider.js +1 -1
- package/package.json +7 -3
- package/dist/flows/withdraw/dialog/WithdrawDialogEventsContext.d.ts +0 -36
- package/dist/flows/withdraw/dialog/WithdrawDialogEventsContext.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ConfirmTransferAmountsProps, ConfirmTransferBodyProps, ConfirmTransferBreakdown, ConfirmTransferBreakdownPercentRow, ConfirmTransferBreakdownProps, ConfirmTransferBreakdownTextRow, ConfirmTransferBreakdownUsdRow, ConfirmTransferDialogProps, ConfirmTransferDisclaimerProps, ConfirmTransferFooterProps, ConfirmTransferHeaderProps, ConfirmTransferHeroProps, ConfirmTransferMetaProps, ConfirmTransferProps, ConfirmTransferToken, ConfirmTransferTransfer } from "../../shared/widgets/confirm-transfer/compound/types.js";
|
|
2
2
|
import { ConfirmTransfer } from "../../shared/widgets/confirm-transfer/compound/ConfirmTransfer.js";
|
|
3
3
|
import { CONFIRM_TRANSFER_SLOTS, ConfirmTransferSlot } from "../../shared/widgets/confirm-transfer/compound/ConfirmTransfer.slots.js";
|
|
4
|
+
import { TransferCryptoAsset, TransferCryptoBodyProps, TransferCryptoChain, TransferCryptoDialogProps, TransferCryptoDisclosureProps, TransferCryptoHeaderProps, TransferCryptoProps, TransferCryptoToken } from "../../flows/deposit/widgets/transfer-crypto/compound/types.js";
|
|
4
5
|
import { DepositBodyProps, DepositDialogProps, DepositHeaderProps, DepositMethodInput, DepositMethodOption, DepositMethodProps, DepositMethodsProps, DepositProps } from "../../flows/deposit/widgets/deposit/compound/types.js";
|
|
5
6
|
import { Deposit } from "../../flows/deposit/widgets/deposit/compound/Deposit.js";
|
|
6
7
|
import { DEPOSIT_SLOTS, DepositSlot } from "../../flows/deposit/widgets/deposit/compound/Deposit.slots.js";
|
|
7
8
|
import { DepositStatusBannerAsset, DepositStatusBannerBodyProps, DepositStatusBannerCloseProps, DepositStatusBannerDetailProps, DepositStatusBannerDetailsProps, DepositStatusBannerFooterProps, DepositStatusBannerHeroProps, DepositStatusBannerKind, DepositStatusBannerPrimaryActionProps, DepositStatusBannerProps, DepositStatusBannerRowProps, DepositStatusBannerToggleProps, DepositStatusBannerTxRef } from "../../flows/deposit/widgets/deposit-status-banner/compound/types.js";
|
|
8
9
|
import { DepositStatusBanner } from "../../flows/deposit/widgets/deposit-status-banner/compound/DepositStatusBanner.js";
|
|
9
10
|
import { DEPOSIT_STATUS_BANNER_SLOTS, DepositStatusBannerSlot } from "../../flows/deposit/widgets/deposit-status-banner/compound/DepositStatusBanner.slots.js";
|
|
10
|
-
import { TransferCryptoAsset, TransferCryptoBodyProps, TransferCryptoChain, TransferCryptoDialogProps, TransferCryptoDisclosureProps, TransferCryptoHeaderProps, TransferCryptoProps, TransferCryptoToken } from "../../flows/deposit/widgets/transfer-crypto/compound/types.js";
|
|
11
11
|
import { TransferCrypto } from "../../flows/deposit/widgets/transfer-crypto/compound/TransferCrypto.js";
|
|
12
12
|
import { TRANSFER_CRYPTO_SLOTS, TransferCryptoSlot } from "../../flows/deposit/widgets/transfer-crypto/compound/TransferCrypto.slots.js";
|
|
13
13
|
import { AmountEntryBodyProps, AmountEntryDialogProps, AmountEntryFlowProps, AmountEntryFooterProps, AmountEntryHeaderProps, AmountEntryHeroProps, AmountEntryPercentPreset, AmountEntryPillsProps, AmountEntryProps, AmountEntryToken } from "../../shared/widgets/amount-entry/compound/types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{defaultI18n as e}from"../../shared/i18n/defaultI18n.js";import{pickRelevantSettlement as t}from"../../flows/shared/transformers/pickRelevantSettlement.js";import{formatUsd as n}from"../../shared/format/formatUsd.js";import{defaultBlockExplorers as r}from"../../shared/utils/explorers.js";import{createEntityStore as i}from"../stridge-mock/store.js";import{NATIVE_QUOTE_ADDRESS as a,isStablecoinSymbol as o,toBaseUnits as s}from"./internal/encoding.js";import{resolveSdkEnv as c}from"./internal/env.js";import{buildKitMetadata as l}from"./internal/metadata.js";import{pollOnce as u}from"./internal/pollOnce.js";import{startPoll as d}from"./poll.js";import{balanceToWithdrawableBalancesPayload as f}from"../../flows/withdraw/driver/transformers/balanceToWithdrawableBalancesPayload.js";import{quoteToWithdrawalPayload as p}from"../../flows/withdraw/driver/transformers/quoteToWithdrawalPayload.js";import{settlementToWithdrawalPayload as m}from"../../flows/withdraw/driver/transformers/settlementToWithdrawalPayload.js";import{supportedAssetsToReceiveOptionsPayload as h}from"../../flows/withdraw/driver/transformers/supportedAssetsToReceiveOptionsPayload.js";import{createApiClient as g}from"@stridge/sdk";function _(_){let v=g({projectKey:_.projectKey,env:c(_.environment)}),y=_.pollIntervals??{},b=y.processingMs??2e3,x=y.terminalMs??1e4,S=y.balancesMs??6e4,C=_.getI18n??(()=>e),w={...r(),..._.explorers??{}},T=C(),E=i({withdrawableBalances:{status:`loading`},receiveOptions:{status:`loading`},quote:{status:`idle`},settlement:{status:`idle`},..._.minAmountUsd===void 0?{}:{minAmountUsd:{value:_.minAmountUsd,formatted:n(_.minAmountUsd,T)}},..._.maxAmountUsd===void 0?{}:{maxAmountUsd:{value:_.maxAmountUsd,formatted:n(_.maxAmountUsd,T)}}}),D,O,k;function A(e){let t=e.assets.find(e=>e.network_id===_.currency.networkId);if(!t)return;let n=_.currency.assetSymbol.toUpperCase(),r=t.native_currency?.symbol?.toUpperCase()===n?t.native_currency:void 0,i=t.assets.find(e=>e.symbol?.toUpperCase()===n),a={networkId:t.network_id,eip155Id:t.eip155_id,networkName:t.network_name,...t.native_currency?.logo?{chainLogoUrl:t.native_currency.logo}:{},decimals:i?.decimals??r?.decimals??18,address:i?.address??``,isNative:!i&&!!r,...i?.logo?{assetLogoUrl:i.logo}:r?.logo?{assetLogoUrl:r.logo}:{}};return i||r?a:void 0}function j(e){let t=C(),n=O,r=f(e,{i18n:t,networkId:_.currency.networkId,assetSymbol:_.currency.assetSymbol,...n?{fallbackMeta:{decimals:n.decimals,address:n.address,isNative:n.isNative,eip155Id:String(n.eip155Id),networkName:n.networkName,...n.chainLogoUrl?{chainLogoUrl:n.chainLogoUrl}:{},...n.assetLogoUrl?{assetLogoUrl:n.assetLogoUrl}:{}}}:{}});E.update({withdrawableBalances:{status:`ready`,payload:r,raw:e,response:e}})}let M=(async()=>{try{let[e,t]=await Promise.all([v.uda.supportedAssets(),v.balance.onchain(_.userAddress,{includeSpam:!1,includeZero:!1}).catch(()=>null)]);D=e,O=A(e);let n=h(e);E.update({receiveOptions:{status:`ready`,payload:n,raw:e.assets,response:e}}),t?j(t):O&&j({wallet_address:_.userAddress,fetched_at:new Date().toISOString(),total_usd:`0`,chains:[]})}catch(e){let t=e instanceof Error?e:Error(String(e));E.update({receiveOptions:{status:`error`,error:t}})}})();function N(){return l({flow:`withdraw`,..._.metadata?{hostMetadata:_.metadata}:{},extras:{source:{networkId:_.currency.networkId,assetSymbol:_.currency.assetSymbol}}})}function P(e,t){if(!D)return;let n=D.assets.find(t=>t.eip155_id===e);if(!n)return;let r=t.toUpperCase(),i=n.native_currency?.symbol?.toUpperCase()===r?n.native_currency:void 0,a=n.assets.find(e=>e.symbol?.toUpperCase()===r);if(!(!i&&!a))return{chainId:n.eip155_id,symbol:a?.symbol??i?.symbol??t,decimals:a?.decimals??i?.decimals??18,address:a?.address??``,isNative:!a&&!!i,...a?.logo?{assetLogoUrl:a.logo}:i?.logo?{assetLogoUrl:i.logo}:{},networkId:n.network_id,networkName:n.network_name,...i?.logo?{chainLogoUrl:i.logo}:{}}}function F(e){let t=E.getSnapshot().receiveOptions;if(!(t.status!==`ready`&&t.status!==`stale`))return t.payload.find(t=>t.eip155Id===e)}return{getSnapshot(){return E.getSnapshot()},subscribe(e){return E.subscribe(e)},async requestQuote(e,t){E.update({quote:{status:`loading`}});try{if(await M,t.aborted)return;let n=O;if(!n)throw Error(`Stridge withdraw driver: source currency ${_.currency.assetSymbol} not found on network ${_.currency.networkId} in supportedAssets.`);let r=P(e.receiveChainId,e.receiveTokenSymbol);if(!r)throw Error(`Stridge withdraw driver: receive asset ${e.receiveTokenSymbol} not found on chain ${e.receiveChainId} in supportedAssets.`);let i=s(e.amount,n.decimals),c=await v.uda.quote({fromNetworkId:n.eip155Id,fromAsset:n.isNative?a:n.address,toNetworkId:r.chainId,toAsset:r.isNative?a:r.address,amount:i,fromAddress:_.userAddress,toAddress:e.recipientAddress},{signal:t});if(t.aborted)return;let l=o(_.currency.assetSymbol)?1:void 0,u=o(r.symbol)?1:void 0,d=p(c,{i18n:C(),receiveSide:r,sourceAmount:e.amount,sendDecimals:n.decimals,sendSymbol:_.currency.assetSymbol,now:Date.now(),...l===void 0?{}:{sendPriceUsd:l},...u===void 0?{}:{receivePriceUsd:u}});E.update({quote:{status:`ready`,payload:d,raw:c,response:c}})}catch(e){if(t.aborted)return;let n=e instanceof Error?e:Error(String(e));E.update({quote:{status:`error`,error:n}})}},async prepareWithdrawal(e,t){if(await M,t.aborted)throw new DOMException(`Aborted`,`AbortError`);let n=O;if(!n)throw Error(`Stridge withdraw driver: source currency ${_.currency.assetSymbol} not found on network ${_.currency.networkId} in supportedAssets.`);let r=P(e.receiveChainId,e.receiveTokenSymbol);if(!r)throw Error(`Stridge withdraw driver: receive asset ${e.receiveTokenSymbol} not found on chain ${e.receiveChainId} in supportedAssets.`);let i=await v.gateway.start({owner:_.userAddress,destination:{network_id:r.networkId??String(e.receiveChainId),asset_symbol:r.symbol,to_address:e.recipientAddress},metadata:N()},{signal:t});if(t.aborted)throw new DOMException(`Aborted`,`AbortError`);let a=i.deposit_addresses.find(e=>Number(e.eip155_id)===n.eip155Id);if(!a)throw Error(`Stridge withdraw driver: no UDA deposit address provisioned on chain ${n.eip155Id} for the brand currency. Check that supportedAssets advertises this chain.`);return k={network_id:r.networkId??String(e.receiveChainId),asset_symbol:r.symbol,to_address:e.recipientAddress},{depositTarget:{address:a.address,chainId:n.eip155Id,tokenSymbol:_.currency.assetSymbol,tokenAddress:n.isNative?``:n.address,tokenDecimals:n.decimals,isNative:n.isNative,amount:e.amount},correlation:{owner:_.userAddress}}},watchSettlement(e,n,r){let i=e=>u(v,_.userAddress,k,e),a=!1;d({signal:r,fetch:i,listener:r=>{if(!r)return;let i=O?s(e.form.amount,O.decimals).toString():void 0,o=e.tx?.hash?t(r,{txHash:e.tx.hash}):t(r,{bestMatch:{destination:{chainId:e.form.receiveChainId,tokenSymbol:e.form.receiveTokenSymbol,recipientAddress:e.form.recipientAddress},submittedAt:e.submittedAt,...i?{sourceAmountBaseUnits:i}:{}}});if(!o)return;let c=C(),l=F(Number(r.destination.eip155_id)),u=l?.tokens.find(e=>e.symbol===r.destination.asset_symbol),d={...l?.chainLogoUrl?{chainLogoUrl:l.chainLogoUrl}:{},...u?.assetLogoUrl?{assetLogoUrl:u.assetLogoUrl}:{},...l?.networkName?{networkName:l.networkName}:{}},f=m(o,r,{i18n:c,explorers:w,...Object.keys(d).length>0?{receiveAssetEnrichment:d}:{},...
|
|
1
|
+
"use client";import{defaultI18n as e}from"../../shared/i18n/defaultI18n.js";import{pickRelevantSettlement as t}from"../../flows/shared/transformers/pickRelevantSettlement.js";import{formatUsd as n}from"../../shared/format/formatUsd.js";import{defaultBlockExplorers as r}from"../../shared/utils/explorers.js";import{createEntityStore as i}from"../stridge-mock/store.js";import{NATIVE_QUOTE_ADDRESS as a,isStablecoinSymbol as o,toBaseUnits as s}from"./internal/encoding.js";import{resolveSdkEnv as c}from"./internal/env.js";import{buildKitMetadata as l}from"./internal/metadata.js";import{pollOnce as u}from"./internal/pollOnce.js";import{startPoll as d}from"./poll.js";import{balanceToWithdrawableBalancesPayload as f}from"../../flows/withdraw/driver/transformers/balanceToWithdrawableBalancesPayload.js";import{quoteToWithdrawalPayload as p}from"../../flows/withdraw/driver/transformers/quoteToWithdrawalPayload.js";import{settlementToWithdrawalPayload as m}from"../../flows/withdraw/driver/transformers/settlementToWithdrawalPayload.js";import{supportedAssetsToReceiveOptionsPayload as h}from"../../flows/withdraw/driver/transformers/supportedAssetsToReceiveOptionsPayload.js";import{createApiClient as g}from"@stridge/sdk";function _(_){let v=g({projectKey:_.projectKey,env:c(_.environment)}),y=_.pollIntervals??{},b=y.processingMs??2e3,x=y.terminalMs??1e4,S=y.balancesMs??6e4,C=_.getI18n??(()=>e),w={...r(),..._.explorers??{}},T=C(),E=i({withdrawableBalances:{status:`loading`},receiveOptions:{status:`loading`},quote:{status:`idle`},settlement:{status:`idle`},..._.minAmountUsd===void 0?{}:{minAmountUsd:{value:_.minAmountUsd,formatted:n(_.minAmountUsd,T)}},..._.maxAmountUsd===void 0?{}:{maxAmountUsd:{value:_.maxAmountUsd,formatted:n(_.maxAmountUsd,T)}}}),D,O,k;function A(e){let t=e.assets.find(e=>e.network_id===_.currency.networkId);if(!t)return;let n=_.currency.assetSymbol.toUpperCase(),r=t.native_currency?.symbol?.toUpperCase()===n?t.native_currency:void 0,i=t.assets.find(e=>e.symbol?.toUpperCase()===n),a={networkId:t.network_id,eip155Id:t.eip155_id,networkName:t.network_name,...t.native_currency?.logo?{chainLogoUrl:t.native_currency.logo}:{},decimals:i?.decimals??r?.decimals??18,address:i?.address??``,isNative:!i&&!!r,...i?.logo?{assetLogoUrl:i.logo}:r?.logo?{assetLogoUrl:r.logo}:{}};return i||r?a:void 0}function j(e){let t=C(),n=O,r=f(e,{i18n:t,networkId:_.currency.networkId,assetSymbol:_.currency.assetSymbol,...n?{fallbackMeta:{decimals:n.decimals,address:n.address,isNative:n.isNative,eip155Id:String(n.eip155Id),networkName:n.networkName,...n.chainLogoUrl?{chainLogoUrl:n.chainLogoUrl}:{},...n.assetLogoUrl?{assetLogoUrl:n.assetLogoUrl}:{}}}:{}});E.update({withdrawableBalances:{status:`ready`,payload:r,raw:e,response:e}})}let M=(async()=>{try{let[e,t]=await Promise.all([v.uda.supportedAssets(),v.balance.onchain(_.userAddress,{includeSpam:!1,includeZero:!1}).catch(()=>null)]);D=e,O=A(e);let n=h(e);E.update({receiveOptions:{status:`ready`,payload:n,raw:e.assets,response:e}}),t?j(t):O&&j({wallet_address:_.userAddress,fetched_at:new Date().toISOString(),total_usd:`0`,chains:[]})}catch(e){let t=e instanceof Error?e:Error(String(e));E.update({receiveOptions:{status:`error`,error:t}})}})();function N(){return l({flow:`withdraw`,..._.metadata?{hostMetadata:_.metadata}:{},extras:{source:{networkId:_.currency.networkId,assetSymbol:_.currency.assetSymbol}}})}function P(e,t){if(!D)return;let n=D.assets.find(t=>t.eip155_id===e);if(!n)return;let r=t.toUpperCase(),i=n.native_currency?.symbol?.toUpperCase()===r?n.native_currency:void 0,a=n.assets.find(e=>e.symbol?.toUpperCase()===r);if(!(!i&&!a))return{chainId:n.eip155_id,symbol:a?.symbol??i?.symbol??t,decimals:a?.decimals??i?.decimals??18,address:a?.address??``,isNative:!a&&!!i,...a?.logo?{assetLogoUrl:a.logo}:i?.logo?{assetLogoUrl:i.logo}:{},networkId:n.network_id,networkName:n.network_name,...i?.logo?{chainLogoUrl:i.logo}:{}}}function F(e){let t=E.getSnapshot().receiveOptions;if(!(t.status!==`ready`&&t.status!==`stale`))return t.payload.find(t=>t.eip155Id===e)}return{getSnapshot(){return E.getSnapshot()},subscribe(e){return E.subscribe(e)},async requestQuote(e,t){E.update({quote:{status:`loading`}});try{if(await M,t.aborted)return;let n=O;if(!n)throw Error(`Stridge withdraw driver: source currency ${_.currency.assetSymbol} not found on network ${_.currency.networkId} in supportedAssets.`);let r=P(e.receiveChainId,e.receiveTokenSymbol);if(!r)throw Error(`Stridge withdraw driver: receive asset ${e.receiveTokenSymbol} not found on chain ${e.receiveChainId} in supportedAssets.`);let i=s(e.amount,n.decimals),c=await v.uda.quote({fromNetworkId:n.eip155Id,fromAsset:n.isNative?a:n.address,toNetworkId:r.chainId,toAsset:r.isNative?a:r.address,amount:i,fromAddress:_.userAddress,toAddress:e.recipientAddress},{signal:t});if(t.aborted)return;let l=o(_.currency.assetSymbol)?1:void 0,u=o(r.symbol)?1:void 0,d=p(c,{i18n:C(),receiveSide:r,sourceAmount:e.amount,sendDecimals:n.decimals,sendSymbol:_.currency.assetSymbol,now:Date.now(),...l===void 0?{}:{sendPriceUsd:l},...u===void 0?{}:{receivePriceUsd:u}});E.update({quote:{status:`ready`,payload:d,raw:c,response:c}})}catch(e){if(t.aborted)return;let n=e instanceof Error?e:Error(String(e));E.update({quote:{status:`error`,error:n}})}},async prepareWithdrawal(e,t){if(await M,t.aborted)throw new DOMException(`Aborted`,`AbortError`);let n=O;if(!n)throw Error(`Stridge withdraw driver: source currency ${_.currency.assetSymbol} not found on network ${_.currency.networkId} in supportedAssets.`);let r=P(e.receiveChainId,e.receiveTokenSymbol);if(!r)throw Error(`Stridge withdraw driver: receive asset ${e.receiveTokenSymbol} not found on chain ${e.receiveChainId} in supportedAssets.`);let i=await v.gateway.start({owner:_.userAddress,destination:{network_id:r.networkId??String(e.receiveChainId),asset_symbol:r.symbol,to_address:e.recipientAddress},metadata:N()},{signal:t});if(t.aborted)throw new DOMException(`Aborted`,`AbortError`);let a=i.deposit_addresses.find(e=>Number(e.eip155_id)===n.eip155Id);if(!a)throw Error(`Stridge withdraw driver: no UDA deposit address provisioned on chain ${n.eip155Id} for the brand currency. Check that supportedAssets advertises this chain.`);return k={network_id:r.networkId??String(e.receiveChainId),asset_symbol:r.symbol,to_address:e.recipientAddress},{depositTarget:{address:a.address,chainId:n.eip155Id,tokenSymbol:_.currency.assetSymbol,tokenAddress:n.isNative?``:n.address,tokenDecimals:n.decimals,isNative:n.isNative,amount:e.amount},correlation:{owner:_.userAddress}}},watchSettlement(e,n,r){let i=e=>u(v,_.userAddress,k,e),a=!1;d({signal:r,fetch:i,listener:r=>{if(!r)return;let i=O?s(e.form.amount,O.decimals).toString():void 0,o=e.tx?.hash?t(r,{txHash:e.tx.hash}):t(r,{bestMatch:{destination:{chainId:e.form.receiveChainId,tokenSymbol:e.form.receiveTokenSymbol,recipientAddress:e.form.recipientAddress},submittedAt:e.submittedAt,...i?{sourceAmountBaseUnits:i}:{}}});if(!o)return;let c=C(),l=F(Number(r.destination.eip155_id)),u=l?.tokens.find(e=>e.symbol===r.destination.asset_symbol),d={...l?.chainLogoUrl?{chainLogoUrl:l.chainLogoUrl}:{},...u?.assetLogoUrl?{assetLogoUrl:u.assetLogoUrl}:{},...l?.networkName?{networkName:l.networkName}:{}},f=m(o,r,{i18n:c,explorers:w,...Object.keys(d).length>0?{receiveAssetEnrichment:d}:{},...u?.decimals===void 0?{}:{receiveAssetDecimals:u.decimals}});f.kind!==`pending`&&(a=!0);let p={status:`ready`,payload:f,raw:o,response:r};E.update({settlement:p}),n(p)},nextIntervalMs:()=>a?x:b})},watchWithdrawableBalances(e,t,n){d({signal:n,fetch:async e=>{try{return await M,e.aborted?null:await v.balance.onchain(_.userAddress,{signal:e,includeSpam:!1,includeZero:!1})}catch{return null}},listener:e=>{e&&j(e),t(E.getSnapshot().withdrawableBalances)},nextIntervalMs:()=>S})}}}export{_ as createStridgeWithdrawDriver};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StridgeEvent } from "../types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/events/bus/createBus.d.ts
|
|
4
|
+
/** Handler shape — accepts a typed event, returns nothing (return values are ignored). */
|
|
5
|
+
type EventHandler<TEvent extends StridgeEvent = StridgeEvent> = (event: TEvent) => void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { EventHandler };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){let e=new Set,t=new Set,n=new Map,r=!1;function i(e,t){try{e(t)}catch(e){console.error(`[stridge/kit] handler for "${t.type}" threw:`,e)}}function a(a){if(r)return;if(a.tier===`flow`)for(let t of e)i(t,a);for(let e of t)i(e,a);let o=n.get(a.type);if(o)for(let e of o)i(e,a)}function o(e,t){return e.add(t),()=>{e.delete(t)}}function s(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))}}return{emit:a,subscribeToFlow:t=>o(e,t),subscribeToFlowEvent:(e,t)=>s(e,t),subscribeToAll:e=>o(t,e),subscribeToEvent:(e,t)=>s(e,t),dispose:()=>{r=!0,e.clear(),t.clear(),n.clear()}}}export{e as createBus};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/events/bus/flowIdRegistry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Per-flow session id (`flowId`) lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* One `flowId` is minted at `<flow>.opened` (synchronously, before the event is emitted, so
|
|
6
|
+
* the opened event carries the id). The same id rides every subsequent event in that
|
|
7
|
+
* session. Retired after the terminal event (`*.settlement.succeeded` /
|
|
8
|
+
* `*.settlement.failed` / `*.cancelled`). Reopening the same flow type mints a fresh id —
|
|
9
|
+
* sessions are not merged across opens.
|
|
10
|
+
*
|
|
11
|
+
* The registry also serves `useCurrentFlowId(flow)` — consumers can read the active id
|
|
12
|
+
* without subscribing to the bus.
|
|
13
|
+
*/
|
|
14
|
+
/** Flow types eligible for a `flowId`. `kit` is excluded — `kit:*` events carry `flowId: null`. */
|
|
15
|
+
type FlowIdKey = "deposit" | "withdraw";
|
|
16
|
+
//#endregion
|
|
17
|
+
export { FlowIdKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;function t(){let t=``,n=typeof globalThis<`u`?globalThis.crypto:void 0;if(n?.getRandomValues){let r=new Uint8Array(10);n.getRandomValues(r);for(let n=0;n<10;n+=1)t+=e[(r[n]??0)%62];return t}for(let n=0;n<10;n+=1)t+=e[Math.floor(Math.random()*62)];return t}function n(){let e={deposit:null,withdraw:null},n={deposit:new Set,withdraw:new Set};function r(e){for(let t of n[e])try{t()}catch(t){console.error(`[stridge/kit] flowId listener for "${e}" threw:`,t)}}return{open(n){e[n]!==null&&process.env.NODE_ENV!==`production`&&console.warn(`[stridge/kit] minted a new "${n}" flowId while a previous session was still active — the previous flowId is being discarded. This usually means the kit emitted opened twice without an intervening terminal/cancelled event.`);let i=t();return e[n]=i,r(n),i},close(t){e[t]!==null&&(e[t]=null,r(t))},current(t){return e[t]},subscribe(e,t){return n[e].add(t),()=>{n[e].delete(t)}}}}export{n as createFlowIdRegistry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./createBus.js";import"./flowIdRegistry.js";import"./metadata.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({});function t(){let t={deposit:e,withdraw:e};return{snapshot(n,r){if(!r||Object.keys(r).length===0){t[n]=e;return}t[n]=Object.freeze({...r})},read(e){return t[e]},clear(n){t[n]=e}}}export{t as createMetadataStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as e}from"react";const t=e(null);export{t as StridgeEventsContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./mapFailure.js";import"./useDepositEmissions.js";import"./useKitEmitter.js";import"./useWithdrawEmissions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Set([`UserRejectedRequestError`,`ACTION_REJECTED`]);function t(t){return!t||e.has(t)?`internal`:t===`TimeoutError`||t===`ETIMEDOUT`?`timeout`:t===`NetworkError`||t===`ERR_NETWORK`||t===`ECONNREFUSED`||t===`FETCH_FAILED`?`network`:t===`RATE_LIMITED`||t===`TooManyRequestsError`?`rate_limited`:t===`UNAUTHORIZED`||t===`InvalidProjectKeyError`?`unauthorized`:t===`INSUFFICIENT_FUNDS`||t===`InsufficientBalanceError`?`insufficient_funds`:t===`INVALID_INPUT`||t===`ValidationError`?`invalid_input`:t===`QUOTE_EXPIRED`||t===`QuoteExpiredError`?`quote_expired`:t===`TX_REVERTED`||t===`TransactionRevertedError`||t===`TransactionExecutionError`?`tx_reverted`:t===`TX_DROPPED`||t===`TransactionReplacedError`?`tx_dropped`:t===`SETTLEMENT_LOST`||t===`SettlementNotFoundError`?`settlement_lost`:`internal`}function n(e){return e===`network`||e===`timeout`||e===`rate_limited`}function r(e,r){let i=t(e.code);return{code:i,reason:e.reason,retryable:n(i),...r===void 0?{}:{cause:r}}}export{r as mapFailureInfoToPayload};
|
|
@@ -0,0 +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`||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===`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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{StridgeEventsContext as e}from"../context.js";import{publishEvent as t}from"../publish.js";import{use as n,useCallback as r}from"react";function i(){let i=n(e);return r(e=>{i&&t(i,e)},[i])}export{i as useKitEmitter};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useCurrentFlowId } from "./useCurrentFlowId.js";
|
|
2
|
+
import { useStridgeEvent } from "./useStridgeEvent.js";
|
|
3
|
+
import { PublicStridgeEventBus, useStridgeEventBus } from "./useStridgeEventBus.js";
|
|
4
|
+
import { useStridgeEvents } from "./useStridgeEvents.js";
|
|
5
|
+
import { useStridgeFlowEvent } from "./useStridgeFlowEvent.js";
|
|
6
|
+
import { useStridgeFlowEvents } from "./useStridgeFlowEvents.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./useCurrentFlowId.js";import"./useStridgeEvent.js";import"./useStridgeEventBus.js";import"./useStridgeEvents.js";import"./useStridgeFlowEvent.js";import"./useStridgeFlowEvents.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{StridgeEventsContext as e}from"../context.js";import{use as t,useCallback as n,useSyncExternalStore as r}from"react";function i(i){let a=t(e);return r(n(e=>a?a.flowIds.subscribe(i,e):()=>void 0,[a,i]),n(()=>a?a.flowIds.current(i):null,[a,i]),()=>null)}export{i as useCurrentFlowId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useEffect as e,useRef as t}from"react";function n(n){let r=t(n);return e(()=>{r.current=n},[n]),r}export{n as useStableHandler};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StridgeEvent } from "../types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/events/hooks/useStridgeEvent.d.ts
|
|
4
|
+
declare function useStridgeEvent<TType extends StridgeEvent["type"]>(type: TType, handler: (event: Extract<StridgeEvent, {
|
|
5
|
+
type: TType;
|
|
6
|
+
}>) => void): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { useStridgeEvent };
|
|
@@ -0,0 +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 o=n(e),s=t(a);r(()=>{if(o)return o.bus.subscribeToEvent(i,e=>s.current(e))},[o,s,i])}export{i as useStridgeEvent};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FlowEvent, StridgeEvent } from "../types/index.js";
|
|
2
|
+
import { EventHandler } from "../bus/createBus.js";
|
|
3
|
+
|
|
4
|
+
//#region src/events/hooks/useStridgeEventBus.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Subset of {@link StridgeEventBus} exposed publicly. `emit` and `dispose` are
|
|
7
|
+
* kit-internal — consumers only ever subscribe.
|
|
8
|
+
*
|
|
9
|
+
* `subscribeToFlow` / `subscribeToFlowEvent` narrow the handler to `flow:*` events only
|
|
10
|
+
* (headless-safe). `subscribeToAll` / `subscribeToEvent` are the firehose — they see every
|
|
11
|
+
* event the kit emits regardless of tier.
|
|
12
|
+
*/
|
|
13
|
+
interface PublicStridgeEventBus {
|
|
14
|
+
subscribeToFlow: (handler: EventHandler<FlowEvent>) => () => void;
|
|
15
|
+
subscribeToFlowEvent: <TType extends FlowEvent["type"]>(type: TType, handler: EventHandler<Extract<FlowEvent, {
|
|
16
|
+
type: TType;
|
|
17
|
+
}>>) => () => void;
|
|
18
|
+
subscribeToAll: (handler: EventHandler<StridgeEvent>) => () => void;
|
|
19
|
+
subscribeToEvent: <TType extends StridgeEvent["type"]>(type: TType, handler: EventHandler<Extract<StridgeEvent, {
|
|
20
|
+
type: TType;
|
|
21
|
+
}>>) => () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the provider-scoped bus accessor, or `null` when no `<StridgeProvider>` is
|
|
25
|
+
* mounted above. Always guard with `if (!bus) return;` in your subscription setup.
|
|
26
|
+
*
|
|
27
|
+
* The returned object identity is stable across renders as long as the provider's bus
|
|
28
|
+
* doesn't change, so consumers can safely list it in `useEffect` dep arrays without
|
|
29
|
+
* re-subscribing every render.
|
|
30
|
+
*/
|
|
31
|
+
declare function useStridgeEventBus(): PublicStridgeEventBus | null;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { PublicStridgeEventBus, useStridgeEventBus };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{StridgeEventsContext as e}from"../context.js";import{use as t,useMemo as n}from"react";function r(){let r=t(e);return n(()=>r?{subscribeToFlow:r.bus.subscribeToFlow,subscribeToFlowEvent:r.bus.subscribeToFlowEvent,subscribeToAll:r.bus.subscribeToAll,subscribeToEvent:r.bus.subscribeToEvent}:null,[r])}export{r as useStridgeEventBus};
|
|
@@ -0,0 +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 a=n(e),o=t(i);r(()=>{if(a)return a.bus.subscribeToAll(e=>o.current(e))},[a,o])}export{i as useStridgeEvents};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowEvent } from "../types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/events/hooks/useStridgeFlowEvent.d.ts
|
|
4
|
+
declare function useStridgeFlowEvent<TType extends FlowEvent["type"]>(type: TType, handler: (event: Extract<FlowEvent, {
|
|
5
|
+
type: TType;
|
|
6
|
+
}>) => void): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { useStridgeFlowEvent };
|
|
@@ -0,0 +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 o=n(e),s=t(a);r(()=>{if(o)return o.bus.subscribeToFlowEvent(i,e=>s.current(e))},[o,s,i])}export{i as useStridgeFlowEvent};
|
|
@@ -0,0 +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 a=n(e),o=t(i);r(()=>{if(a)return a.bus.subscribeToFlow(e=>o.current(e))},[a,o])}export{i as useStridgeFlowEvents};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlowIdKey } from "./bus/flowIdRegistry.js";
|
|
2
|
+
import { useCurrentFlowId } from "./hooks/useCurrentFlowId.js";
|
|
3
|
+
import { FailureCode, FailurePayloadBase, StridgeEventBase, StridgeEventFlow, StridgeEventTier } from "./types/envelope.js";
|
|
4
|
+
import { DepositAmountChangedEvent, DepositAmountSubmittedEvent, DepositAssetClickedEvent, DepositBackClickedEvent, DepositCancelPhase, DepositCancelledEvent, DepositClosedEvent, DepositConfirmClickedEvent, DepositEvent, DepositFlowEvent, DepositMaxClickedEvent, DepositMethodClickedEvent, DepositOpenedEvent, DepositQuoteExpiredEvent, DepositQuoteFailedEvent, DepositQuoteRequestInput, DepositQuoteRequestedEvent, DepositQuoteResolvedEvent, DepositSettlementFailedEvent, DepositSettlementFailurePayload, DepositSettlementProgressedEvent, DepositSettlementResumedEvent, DepositSettlementSucceededEvent, DepositStepChangedEvent, DepositSubmissionBroadcastEvent, DepositSubmissionConfirmedEvent, DepositSubmissionDeclinedEvent, DepositSubmissionFailedEvent, DepositTransferAddressCopiedEvent, DepositTransferChainChangedEvent, DepositTransferTokenChangedEvent, DepositUiEvent } from "./types/deposit.js";
|
|
5
|
+
import { KitEvent, KitSupportClickedEvent, KitTermsClickedEvent } from "./types/kit.js";
|
|
6
|
+
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";
|
|
7
|
+
import { FlowEvent, FlowEventType, StridgeEvent, StridgeEventType, UiEvent, UiEventType } from "./types/index.js";
|
|
8
|
+
import { useStridgeEvent } from "./hooks/useStridgeEvent.js";
|
|
9
|
+
import { EventHandler } from "./bus/createBus.js";
|
|
10
|
+
import { PublicStridgeEventBus, useStridgeEventBus } from "./hooks/useStridgeEventBus.js";
|
|
11
|
+
import { useStridgeEvents } from "./hooks/useStridgeEvents.js";
|
|
12
|
+
import { useStridgeFlowEvent } from "./hooks/useStridgeFlowEvent.js";
|
|
13
|
+
import { useStridgeFlowEvents } from "./hooks/useStridgeFlowEvents.js";
|
|
14
|
+
export { 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, type KitEvent, type KitSupportClickedEvent, type KitTermsClickedEvent, type PublicStridgeEventBus, type StridgeEvent, type StridgeEventBase, type StridgeEventFlow, type StridgeEventTier, type StridgeEventType, 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, useCurrentFlowId, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCurrentFlowId as e}from"./hooks/useCurrentFlowId.js";import{useStridgeEvent as t}from"./hooks/useStridgeEvent.js";import{useStridgeEventBus as n}from"./hooks/useStridgeEventBus.js";import{useStridgeEvents as r}from"./hooks/useStridgeEvents.js";import{useStridgeFlowEvent as i}from"./hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as a}from"./hooks/useStridgeFlowEvents.js";import"./hooks/index.js";export{e as useCurrentFlowId,t as useStridgeEvent,n as useStridgeEventBus,r as useStridgeEvents,i as useStridgeFlowEvent,a as useStridgeFlowEvents};
|
|
@@ -0,0 +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)){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.`);return}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};e.emit(o)}function t(t,n,i,a){r(n,a.flow,`openFlowSession`),t.flowIds.open(n),t.metadata.snapshot(n,i),e(t,{...a,flow:n})}function n(t,n,i){r(n,i.flow,`closeFlowSession`),e(t,{...i,flow: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,235 @@
|
|
|
1
|
+
import { SettlementFailureKind, TxRef } from "../../shared/driver/types.js";
|
|
2
|
+
import { BalanceItemPayload, QuotePayload, SettlementPendingPayload, SettlementSuccessPayload } from "../../flows/deposit/driver/payloads.js";
|
|
3
|
+
import { DepositMethod, DepositStateName, ResolvedOpenInput } from "../../flows/deposit/orchestrator/types.js";
|
|
4
|
+
import { TransferCryptoChain, TransferCryptoToken } from "../../flows/deposit/widgets/transfer-crypto/compound/types.js";
|
|
5
|
+
import { FailurePayloadBase, StridgeEventBase } from "./envelope.js";
|
|
6
|
+
|
|
7
|
+
//#region src/events/types/deposit.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Orchestrator-level input the kit assembled to ask the driver for a deposit quote. Mirrors
|
|
10
|
+
* the shape of {@link import("#/flows/withdraw/driver").RequestWithdrawalQuoteInput} for the
|
|
11
|
+
* deposit side — wrapping the request fields in a single `input` field keeps the `payload`
|
|
12
|
+
* shape symmetric across flows so generic analytics handlers can write
|
|
13
|
+
* `track("quote_requested", e.payload.input)` for both flows.
|
|
14
|
+
*/
|
|
15
|
+
interface DepositQuoteRequestInput {
|
|
16
|
+
/** Source-side asset the user picked on the AssetPicker step. */
|
|
17
|
+
asset: BalanceItemPayload;
|
|
18
|
+
/** Send amount in display units. */
|
|
19
|
+
amount: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Phase the deposit flow was in when it was cancelled. Lets consumers distinguish "user
|
|
23
|
+
* abandoned at amount entry" from "user abandoned during processing wait" without parsing
|
|
24
|
+
* step names.
|
|
25
|
+
*/
|
|
26
|
+
type DepositCancelPhase = "quoting" | "confirming" | "submitting" | "processing" | "unknown";
|
|
27
|
+
/**
|
|
28
|
+
* Settlement failure variant — extends the base with settlement-specific structure
|
|
29
|
+
* (typed `kind`, optional `txHash`) when the failure originates from the gateway's
|
|
30
|
+
* settlement entity rather than from a generic orchestrator path.
|
|
31
|
+
*/
|
|
32
|
+
interface DepositSettlementFailurePayload extends FailurePayloadBase {
|
|
33
|
+
/**
|
|
34
|
+
* Driver-classified failure kind for downstream branching. Bounded enum so consumers can
|
|
35
|
+
* `switch (e.payload.kind)` exhaustively. The kit also escalates FSM-level failures with
|
|
36
|
+
* `kind: "unknown"` when no settlement-specific classification applies.
|
|
37
|
+
*/
|
|
38
|
+
kind: SettlementFailureKind;
|
|
39
|
+
/** On-chain transaction hash, when one was successfully broadcast before settlement failed. */
|
|
40
|
+
txHash?: TxRef;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Orchestrator asked the driver for a quote — either the first request for this asset/amount
|
|
44
|
+
* pair or a regeneration after expiry or signature decline. The payload carries the inputs
|
|
45
|
+
* the orchestrator used so consumers can correlate request → response.
|
|
46
|
+
*/
|
|
47
|
+
type DepositQuoteRequestedEvent = StridgeEventBase<"deposit.quote.requested", "deposit", "flow", {
|
|
48
|
+
input: DepositQuoteRequestInput;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Driver returned a successful quote and the orchestrator transitioned to `ready`. Payload is
|
|
52
|
+
* the full quote entity; reflect-then-render is safe (the orchestrator will not regenerate
|
|
53
|
+
* silently between this event and the next user action unless the quote expires).
|
|
54
|
+
*/
|
|
55
|
+
type DepositQuoteResolvedEvent = StridgeEventBase<"deposit.quote.resolved", "deposit", "flow", {
|
|
56
|
+
quote: QuotePayload;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Quote fetch failed. Payload is the standard {@link FailurePayloadBase} — same shape as every
|
|
60
|
+
* other `*.failed` event so generic error handlers work without per-event branching.
|
|
61
|
+
*/
|
|
62
|
+
type DepositQuoteFailedEvent = StridgeEventBase<"deposit.quote.failed", "deposit", "flow", FailurePayloadBase>;
|
|
63
|
+
/**
|
|
64
|
+
* Active quote went stale (TTL elapsed) before the user could submit, and the orchestrator
|
|
65
|
+
* silently started regenerating it. Payload is empty — the next `deposit.quote.resolved`
|
|
66
|
+
* carries the replacement quote.
|
|
67
|
+
*/
|
|
68
|
+
type DepositQuoteExpiredEvent = StridgeEventBase<"deposit.quote.expired", "deposit", "flow", Record<string, never>>;
|
|
69
|
+
/**
|
|
70
|
+
* Wallet broadcast the deposit transaction and the orchestrator transitioned into
|
|
71
|
+
* `processing`. The on-chain tx hash is now stable; settlement polling has started.
|
|
72
|
+
*/
|
|
73
|
+
type DepositSubmissionBroadcastEvent = StridgeEventBase<"deposit.submission.broadcast", "deposit", "flow", {
|
|
74
|
+
tx: TxRef;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* User refused the wallet signature prompt. Distinct from {@link DepositSubmissionFailedEvent} —
|
|
78
|
+
* declining is a user choice, not an error. The orchestrator regenerates the quote and lands
|
|
79
|
+
* the user back on the confirm step.
|
|
80
|
+
*/
|
|
81
|
+
type DepositSubmissionDeclinedEvent = StridgeEventBase<"deposit.submission.declined", "deposit", "flow", Record<string, never>>;
|
|
82
|
+
/**
|
|
83
|
+
* Submission attempted but couldn't complete — network failure, backend rejection, broken
|
|
84
|
+
* wallet provider, anything that isn't user-rejection. Carries the standard
|
|
85
|
+
* {@link FailurePayloadBase}.
|
|
86
|
+
*/
|
|
87
|
+
type DepositSubmissionFailedEvent = StridgeEventBase<"deposit.submission.failed", "deposit", "flow", FailurePayloadBase>;
|
|
88
|
+
/**
|
|
89
|
+
* Background `fetchActiveSettlement` probe surfaced a pre-existing pending deposit on flow
|
|
90
|
+
* start — the user hadn't started this flow in this session but a prior unfinished deposit
|
|
91
|
+
* was detected and resumed. Payload is the settlement entity's pending snapshot.
|
|
92
|
+
*
|
|
93
|
+
* Withdraw has no symmetric event: the withdraw driver does not currently probe for
|
|
94
|
+
* pre-existing pending withdrawals (host-driven submission means the host already knows
|
|
95
|
+
* when a withdrawal was started). If withdraw later grows an equivalent probe, the
|
|
96
|
+
* symmetric `withdraw.settlement.resumed` will land at that time.
|
|
97
|
+
*/
|
|
98
|
+
type DepositSettlementResumedEvent = StridgeEventBase<"deposit.settlement.resumed", "deposit", "flow", {
|
|
99
|
+
settlement: SettlementPendingPayload;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Settlement entity emitted a progressive pending update — confirmations advancing, partial
|
|
103
|
+
* fill credited, etc. Fires once per update; payload always reflects the current snapshot.
|
|
104
|
+
*/
|
|
105
|
+
type DepositSettlementProgressedEvent = StridgeEventBase<"deposit.settlement.progressed", "deposit", "flow", {
|
|
106
|
+
settlement: SettlementPendingPayload;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Terminal success — settlement entity reached `ready{kind: "succeeded"}`. The flow is over;
|
|
110
|
+
* this event closes the session and the `flowId` is retired after it fires.
|
|
111
|
+
*/
|
|
112
|
+
type DepositSettlementSucceededEvent = StridgeEventBase<"deposit.settlement.succeeded", "deposit", "flow", {
|
|
113
|
+
settlement: SettlementSuccessPayload;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Terminal failure — settlement entity reached `ready{kind: "failed"}` (driver-emitted
|
|
117
|
+
* classification) or the orchestrator escalated an FSM-level failure to the global error arm.
|
|
118
|
+
* Payload extends the standard {@link FailurePayloadBase} with settlement-specific fields.
|
|
119
|
+
*/
|
|
120
|
+
type DepositSettlementFailedEvent = StridgeEventBase<"deposit.settlement.failed", "deposit", "flow", DepositSettlementFailurePayload>;
|
|
121
|
+
/**
|
|
122
|
+
* Flow ended before reaching a terminal state — typically the user closed the dialog
|
|
123
|
+
* mid-flow, or an AbortSignal fired. `payload.phase` indicates where in the lifecycle the
|
|
124
|
+
* cancellation happened so consumers can build drop-off funnels without parsing step names.
|
|
125
|
+
*/
|
|
126
|
+
type DepositCancelledEvent = StridgeEventBase<"deposit.cancelled", "deposit", "flow", {
|
|
127
|
+
phase: DepositCancelPhase;
|
|
128
|
+
}>;
|
|
129
|
+
/** Union of every `deposit.*` `flow:*` event. */
|
|
130
|
+
type DepositFlowEvent = DepositQuoteRequestedEvent | DepositQuoteResolvedEvent | DepositQuoteFailedEvent | DepositQuoteExpiredEvent | DepositSubmissionBroadcastEvent | DepositSubmissionDeclinedEvent | DepositSubmissionFailedEvent | DepositSettlementResumedEvent | DepositSettlementProgressedEvent | DepositSettlementSucceededEvent | DepositSettlementFailedEvent | DepositCancelledEvent;
|
|
131
|
+
/**
|
|
132
|
+
* Dialog transitioned from `closed` to any open step. Mints the `flowId` (every subsequent
|
|
133
|
+
* event in this session carries the same `flowId`) and snapshots the `metadata` prop.
|
|
134
|
+
*/
|
|
135
|
+
type DepositOpenedEvent = StridgeEventBase<"deposit.opened", "deposit", "ui", {
|
|
136
|
+
input: ResolvedOpenInput;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Dialog returned to `closed`. `payload.atStep` is the step name the dialog was on at close
|
|
140
|
+
* time. Fires after any terminal event (`*.succeeded` / `*.failed`) or `deposit.cancelled`
|
|
141
|
+
* in the same session.
|
|
142
|
+
*/
|
|
143
|
+
type DepositClosedEvent = StridgeEventBase<"deposit.closed", "deposit", "ui", {
|
|
144
|
+
atStep: DepositStateName;
|
|
145
|
+
}>;
|
|
146
|
+
/**
|
|
147
|
+
* Dialog step transitioned. Fires on every logical step change including back-presses.
|
|
148
|
+
* `from === to` is not emitted; same-step `ctx` changes (e.g. `confirmDeposit` phase shifts)
|
|
149
|
+
* surface through their respective `flow:*` events instead.
|
|
150
|
+
*/
|
|
151
|
+
type DepositStepChangedEvent = StridgeEventBase<"deposit.step.changed", "deposit", "ui", {
|
|
152
|
+
from: DepositStateName;
|
|
153
|
+
to: DepositStateName;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* User clicked a deposit method tile (`wallet` / `transfer`) on the entry step. Fires on
|
|
157
|
+
* commit — picking is the action that advances the FSM.
|
|
158
|
+
*/
|
|
159
|
+
type DepositMethodClickedEvent = StridgeEventBase<"deposit.method.clicked", "deposit", "ui", {
|
|
160
|
+
method: DepositMethod;
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* User clicked an asset row on the AssetPicker step. The asset is the driver-shaped balance row;
|
|
164
|
+
* use {@link BalanceItemPayload}'s `symbol` and `chainId` to identify it.
|
|
165
|
+
*/
|
|
166
|
+
type DepositAssetClickedEvent = StridgeEventBase<"deposit.asset.clicked", "deposit", "ui", {
|
|
167
|
+
asset: BalanceItemPayload;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* User typed in the amount field on the AmountEntry step. Fires per keystroke (no debounce);
|
|
171
|
+
* `payload.raw` is the literal input string, `payload.numeric` is the parsed value (or `null`
|
|
172
|
+
* when empty / unparseable). Use this for live UI; use {@link DepositAmountSubmittedEvent} for
|
|
173
|
+
* commitment.
|
|
174
|
+
*/
|
|
175
|
+
type DepositAmountChangedEvent = StridgeEventBase<"deposit.amount.changed", "deposit", "ui", {
|
|
176
|
+
raw: string;
|
|
177
|
+
numeric: number | null;
|
|
178
|
+
}>;
|
|
179
|
+
/**
|
|
180
|
+
* User clicked the Max preset in the AmountEntry step (fills the amount with the full
|
|
181
|
+
* available balance). Mirrors {@link import("./withdraw").WithdrawMaxClickedEvent}.
|
|
182
|
+
*/
|
|
183
|
+
type DepositMaxClickedEvent = StridgeEventBase<"deposit.max.clicked", "deposit", "ui", Record<string, never>>;
|
|
184
|
+
/**
|
|
185
|
+
* User submitted the AmountEntry step. `payload.amount` is the parsed numeric value (the FSM
|
|
186
|
+
* would not have advanced otherwise). The next event is typically `deposit.quote.requested`.
|
|
187
|
+
*/
|
|
188
|
+
type DepositAmountSubmittedEvent = StridgeEventBase<"deposit.amount.submitted", "deposit", "ui", {
|
|
189
|
+
amount: number;
|
|
190
|
+
}>;
|
|
191
|
+
/**
|
|
192
|
+
* User clicked the Confirm button on the ConfirmDeposit step. Fires unconditionally on click —
|
|
193
|
+
* even when the button is disabled / mid-submit — so analytics can observe intent regardless
|
|
194
|
+
* of whether the click triggers FSM advance. Mirrors
|
|
195
|
+
* {@link import("./withdraw").WithdrawSubmitClickedEvent}. Use
|
|
196
|
+
* {@link DepositSubmissionConfirmedEvent} for the FSM-level "submission accepted" signal.
|
|
197
|
+
*/
|
|
198
|
+
type DepositConfirmClickedEvent = StridgeEventBase<"deposit.confirm.clicked", "deposit", "ui", Record<string, never>>;
|
|
199
|
+
/**
|
|
200
|
+
* Confirm-step FSM transition to the submitting phase — the wallet prompt is about to fire.
|
|
201
|
+
* Fires only when the FSM accepts the submission (the click was valid); for the raw click
|
|
202
|
+
* signal (regardless of validity), subscribe to {@link DepositConfirmClickedEvent}. The
|
|
203
|
+
* next event is typically `deposit.submission.broadcast`, `deposit.submission.declined`, or
|
|
204
|
+
* `deposit.submission.failed`.
|
|
205
|
+
*/
|
|
206
|
+
type DepositSubmissionConfirmedEvent = StridgeEventBase<"deposit.submission.confirmed", "deposit", "ui", Record<string, never>>;
|
|
207
|
+
/**
|
|
208
|
+
* User clicked the Back chevron in the dialog header on a non-root step. `payload.fromStep` is
|
|
209
|
+
* the step they were leaving. Withdraw has no symmetric event — the withdraw dialog is
|
|
210
|
+
* single-form with no Back affordance (the dialog X closes the flow instead).
|
|
211
|
+
*/
|
|
212
|
+
type DepositBackClickedEvent = StridgeEventBase<"deposit.back.clicked", "deposit", "ui", {
|
|
213
|
+
fromStep: DepositStateName;
|
|
214
|
+
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Inside the TransferCrypto compound, user picked a different source token. The selection
|
|
217
|
+
* affects which deposit address is shown but does not advance the FSM.
|
|
218
|
+
*/
|
|
219
|
+
type DepositTransferTokenChangedEvent = StridgeEventBase<"deposit.transfer.token.changed", "deposit", "ui", {
|
|
220
|
+
token: TransferCryptoToken;
|
|
221
|
+
}>;
|
|
222
|
+
/** Inside the TransferCrypto compound, user picked a different source chain. */
|
|
223
|
+
type DepositTransferChainChangedEvent = StridgeEventBase<"deposit.transfer.chain.changed", "deposit", "ui", {
|
|
224
|
+
chain: TransferCryptoChain;
|
|
225
|
+
}>;
|
|
226
|
+
/** User clicked the copy-address button in the TransferCrypto compound. */
|
|
227
|
+
type DepositTransferAddressCopiedEvent = StridgeEventBase<"deposit.transfer.address.copied", "deposit", "ui", {
|
|
228
|
+
address: string;
|
|
229
|
+
}>;
|
|
230
|
+
/** Union of every `deposit.*` `ui:*` event. */
|
|
231
|
+
type DepositUiEvent = DepositOpenedEvent | DepositClosedEvent | DepositStepChangedEvent | DepositMethodClickedEvent | DepositAssetClickedEvent | DepositAmountChangedEvent | DepositMaxClickedEvent | DepositAmountSubmittedEvent | DepositConfirmClickedEvent | DepositSubmissionConfirmedEvent | DepositBackClickedEvent | DepositTransferTokenChangedEvent | DepositTransferChainChangedEvent | DepositTransferAddressCopiedEvent;
|
|
232
|
+
/** Union of every `deposit.*` event regardless of tier. */
|
|
233
|
+
type DepositEvent = DepositFlowEvent | DepositUiEvent;
|
|
234
|
+
//#endregion
|
|
235
|
+
export { DepositAmountChangedEvent, DepositAmountSubmittedEvent, DepositAssetClickedEvent, DepositBackClickedEvent, DepositCancelPhase, DepositCancelledEvent, DepositClosedEvent, DepositConfirmClickedEvent, DepositEvent, DepositFlowEvent, DepositMaxClickedEvent, DepositMethodClickedEvent, DepositOpenedEvent, DepositQuoteExpiredEvent, DepositQuoteFailedEvent, DepositQuoteRequestInput, DepositQuoteRequestedEvent, DepositQuoteResolvedEvent, DepositSettlementFailedEvent, DepositSettlementFailurePayload, DepositSettlementProgressedEvent, DepositSettlementResumedEvent, DepositSettlementSucceededEvent, DepositStepChangedEvent, DepositSubmissionBroadcastEvent, DepositSubmissionConfirmedEvent, DepositSubmissionDeclinedEvent, DepositSubmissionFailedEvent, DepositTransferAddressCopiedEvent, DepositTransferChainChangedEvent, DepositTransferTokenChangedEvent, DepositUiEvent };
|