@stridge/kit 0.1.0-alpha.13 → 0.1.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/KitProvider.js +1 -1
  2. package/dist/_internal/withdraw/driver/index.d.ts +2 -2
  3. package/dist/drivers/stridge/createStridgeDepositDriver.js +1 -1
  4. package/dist/drivers/stridge/createStridgeWithdrawDriver.d.ts +10 -12
  5. package/dist/drivers/stridge/createStridgeWithdrawDriver.js +1 -1
  6. package/dist/drivers/stridge/types.d.ts +7 -4
  7. package/dist/drivers/stridge-mock/createStridgeMockWithdrawDriver.d.ts +2 -2
  8. package/dist/drivers/stridge-mock/createStridgeMockWithdrawDriver.js +1 -1
  9. package/dist/flows/deposit/orchestrator/controller.js +1 -1
  10. package/dist/flows/deposit/widgets/deposit/Deposit.js +1 -1
  11. package/dist/flows/shared/transformers/pickRelevantSettlement.js +1 -1
  12. package/dist/flows/withdraw/dialog/WithdrawDialog.d.ts +57 -11
  13. package/dist/flows/withdraw/dialog/WithdrawDialog.js +1 -1
  14. package/dist/flows/withdraw/dialog/WithdrawDialogBindingsContext.d.ts +44 -0
  15. package/dist/flows/withdraw/dialog/WithdrawDialogBindingsContext.js +1 -0
  16. package/dist/flows/withdraw/driver/types.d.ts +53 -11
  17. package/dist/flows/withdraw/orchestrator/controller.js +1 -1
  18. package/dist/flows/withdraw/orchestrator/reducer.js +1 -1
  19. package/dist/flows/withdraw/orchestrator/types.d.ts +106 -31
  20. package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.js +1 -1
  21. package/dist/flows/withdraw/widgets/withdraw-form/compound/WithdrawForm.js +1 -1
  22. package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.d.ts +7 -5
  23. package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.js +1 -1
  24. package/dist/flows/withdraw/widgets/withdraw-form/compound/types.d.ts +8 -5
  25. package/dist/i18n/locales/ar.js +1 -1
  26. package/dist/i18n/locales/es.js +1 -1
  27. package/dist/i18n/locales/source-keys.d.ts +1 -1
  28. package/dist/index.d.ts +2 -2
  29. package/dist/package.js +1 -1
  30. package/dist/shared/driver/types.d.ts +4 -3
  31. package/dist/shared/orchestrator/useSettlementWatcher.js +1 -1
  32. package/dist/stridge/StridgeProvider.d.ts +44 -3
  33. package/dist/stridge/StridgeProvider.js +1 -1
  34. package/dist/stridge/optionalWagmi.js +1 -0
  35. package/dist/stridge/stubs.js +1 -1
  36. package/dist/withdraw/dialog/index.d.ts +3 -1
  37. package/package.json +1 -1
@@ -22,9 +22,44 @@ interface StridgeAsset {
22
22
  symbol: string;
23
23
  }
24
24
  /**
25
- * Per-flow deposit tuning. Pass `deposit: {}` to enable the deposit flow with defaults.
25
+ * Settlement destination for the deposit flow. The kit does not infer a destination from any
26
+ * connected wagmi wallet — businesses pass the treasury / settlement address where deposited
27
+ * funds should land.
28
+ *
29
+ * @remarks
30
+ * If the gateway-kit admin config has "Same-owner only" enabled (default), `address` must
31
+ * equal {@link StridgeDepositFlowConfig.owner | the deposit owner}. Turn the toggle off — and
32
+ * optionally pair it with a destination whitelist — to route funds to an address that differs
33
+ * from the owner.
34
+ */
35
+ interface StridgeDepositDestination {
36
+ address: Address;
37
+ }
38
+ /**
39
+ * Stridge `gateway/start.owner` identifier for a single flow. Scopes UDA provisioning and the
40
+ * proactive `gateway/{owner}` settlement poll. The kit treats the address as opaque — businesses
41
+ * pick whatever per-customer (real EOA, derived per-user EOA) or shared (treasury) granularity
42
+ * fits their model.
43
+ */
44
+ interface StridgeFlowOwner {
45
+ address: Address;
46
+ }
47
+ /**
48
+ * Per-flow deposit tuning.
26
49
  */
27
50
  interface StridgeDepositFlowConfig {
51
+ /**
52
+ * Settlement destination address — where settled brand-currency funds land at completion.
53
+ * Required when the deposit flow is enabled.
54
+ */
55
+ destination: StridgeDepositDestination;
56
+ /**
57
+ * Owner used as `gateway/start.owner` for deposit UDAs. Optional — falls back to the
58
+ * connected wagmi wallet address, then to `dev.userAddressOverride`. Set explicitly when
59
+ * the customer is identified by something other than their wagmi address (e.g. a derived
60
+ * per-user identifier, or a shared business owner that is not the wagmi-connected EOA).
61
+ */
62
+ owner?: StridgeFlowOwner;
28
63
  /**
29
64
  * Low-balance / amount-entry USD floor. Defaults to the kit's internal default
30
65
  * (`STRIDGE_DEFAULT_MIN_DEPOSIT_USD`) when omitted.
@@ -37,9 +72,15 @@ interface StridgeDepositFlowConfig {
37
72
  metadata?: Record<string, unknown>;
38
73
  }
39
74
  /**
40
- * Per-flow withdraw tuning. Pass `withdraw: {}` to enable the withdraw flow with defaults.
75
+ * Per-flow withdraw tuning.
41
76
  */
42
77
  interface StridgeWithdrawFlowConfig {
78
+ /**
79
+ * Owner used as `gateway/start.owner` for every withdraw UDA the flow provisions. Required —
80
+ * the withdraw flow has no wagmi fallback because the business (not the end-user) is the
81
+ * party broadcasting the source-chain tx to the UDA.
82
+ */
83
+ owner: StridgeFlowOwner;
43
84
  /**
44
85
  * Metadata persisted on every UDA the withdraw flow provisions. Merged under the kit-set
45
86
  * `kit_flow` / `kit_version` / `source` keys (kit keys win).
@@ -183,4 +224,4 @@ declare function StridgeProvider({
183
224
  children
184
225
  }: StridgeProvider.Props): _$react_jsx_runtime0.JSX.Element;
185
226
  //#endregion
186
- export { StridgeAppearance, StridgeAsset, StridgeDepositFlowConfig, StridgeProvider, StridgeStorageConfig, StridgeWithdrawFlowConfig };
227
+ export { StridgeAppearance, StridgeAsset, StridgeDepositDestination, StridgeDepositFlowConfig, StridgeFlowOwner, StridgeProvider, StridgeStorageConfig, StridgeWithdrawFlowConfig };
@@ -1 +1 @@
1
- "use client";import{normalizeChainToNetworkId as e}from"../shared/chains/index.js";import{createKitI18n as t}from"../shared/i18n/createKitI18n.js";import"../i18n/index.js";import{StridgeContext as n}from"./StridgeContext.js";import{createStridgeDepositDriver as r}from"../drivers/stridge/createStridgeDepositDriver.js";import{createStridgeWithdrawDriver as i}from"../drivers/stridge/createStridgeWithdrawDriver.js";import"../_internal/drivers/stridge/index.js";import{KitProvider as a}from"../KitProvider.js";import{useIntercomMerchantContext as o}from"../shared/support/useIntercomMerchantContext.js";import"../shared/support/index.js";import{createStubDepositDriver as s,createStubWithdrawDriver as c}from"./stubs.js";import{useMemo as l,useRef as u,useSyncExternalStore as d}from"react";import{jsx as f}from"react/jsx-runtime";import{useAccount as p,useConfig as m}from"wagmi";function h({gatewayKey:h,environment:g,asset:_,flows:v,appearance:y,i18n:b,storage:x,dev:S,className:C,children:w}){if(!v.deposit&&!v.withdraw)throw Error("<StridgeProvider /> requires at least one of `flows.deposit` or `flows.withdraw`.");if(!_)throw Error("<StridgeProvider /> requires `asset: { chain, symbol }`.");let T=m(),{address:E}=p(),D=E??S?.userAddressOverride,O=l(()=>t(b??{}),[b?.locale,b?.messages]),k=u(O);k.current=O;let A=l(()=>e(_.chain),[_.chain]),j=_.symbol,M=v.deposit,N=v.withdraw,P=l(()=>{if(!(!M||!D))return r({userAddress:D,projectKey:h,destination:{network_id:A,asset_symbol:j},wagmiConfig:T,getI18n:()=>k.current,...g?{environment:g}:{},...M.minDepositUsd===void 0?{}:{minDepositUsd:M.minDepositUsd},...M.metadata?{metadata:M.metadata}:{}})},[M,D,h,g,A,j,T]),F=l(()=>s(),[]),I=M?P??F:void 0,L=l(()=>{if(!(!N||!D))return i({userAddress:D,projectKey:h,currency:{networkId:A,assetSymbol:j},wagmiConfig:T,getI18n:()=>k.current,...g?{environment:g}:{},...N.metadata?{metadata:N.metadata}:{}})},[N,D,h,g,A,j,T]),R=l(()=>c(),[]),z=N?L??R:void 0,B=P??L,V=d(e=>B?.subscribe(e)??(()=>{}),()=>{if(P){let e=P.getSnapshot();return e.brand.status===`ready`&&e.target.status===`ready`}return L?L.getSnapshot().receiveOptions.status===`ready`:!1},()=>!1),H=d(e=>P?.subscribe(e)??(()=>{}),()=>{let e=P;if(!e)return;let t=e.getSnapshot();if(t.brand.status===`ready`||t.brand.status===`stale`)return t.brand.payload.name},()=>void 0),U=d(e=>P?.subscribe(e)??(()=>{}),()=>{let e=P;if(!e)return;let t=e.getSnapshot();if(t.brand.status===`ready`||t.brand.status===`stale`)return t.brand.payload.checkoutItemTitle},()=>void 0);return o({gatewayKey:h,environment:g??`production`,assetChain:A,assetSymbol:j,...D?{userAddress:D}:{},...H?{brandName:H}:{},...U?{checkoutItemTitle:U}:{}}),f(n,{value:l(()=>({isReady:V,driver:P}),[V,P]),children:f(a,{theme:y?.theme,accent:y?.accent,radius:y?.radius,direction:y?.direction,i18n:b,storage:x?.driver,storageNamespace:x?.namespace,className:C,...I?{deposit:I}:{},...z?{withdraw:z}:{},children:w})})}export{h as StridgeProvider};
1
+ "use client";import{normalizeChainToNetworkId as e}from"../shared/chains/index.js";import{createKitI18n as t}from"../shared/i18n/createKitI18n.js";import"../i18n/index.js";import{StridgeContext as n}from"./StridgeContext.js";import{createStridgeDepositDriver as r}from"../drivers/stridge/createStridgeDepositDriver.js";import{createStridgeWithdrawDriver as i}from"../drivers/stridge/createStridgeWithdrawDriver.js";import"../_internal/drivers/stridge/index.js";import{KitProvider as a}from"../KitProvider.js";import{useIntercomMerchantContext as o}from"../shared/support/useIntercomMerchantContext.js";import"../shared/support/index.js";import{useOptionalWagmi as s}from"./optionalWagmi.js";import{createStubDepositDriver as c,createStubWithdrawDriver as l}from"./stubs.js";import{useMemo as u,useRef as d,useSyncExternalStore as f}from"react";import{jsx as p}from"react/jsx-runtime";function m({gatewayKey:m,environment:h,asset:g,flows:_,appearance:v,i18n:y,storage:b,dev:x,className:S,children:C}){if(!_.deposit&&!_.withdraw)throw Error("<StridgeProvider /> requires at least one of `flows.deposit` or `flows.withdraw`.");if(!g)throw Error("<StridgeProvider /> requires `asset: { chain, symbol }`.");let{config:w,address:T}=s(),E=u(()=>t(y??{}),[y?.locale,y?.messages]),D=d(E);D.current=E;let O=u(()=>e(g.chain),[g.chain]),k=g.symbol,A=_.deposit,j=_.withdraw,M=A?.owner?.address??T??x?.userAddressOverride,N=j?.owner.address,P=u(()=>{if(!(!A||!M))return r({userAddress:M,projectKey:m,destination:{network_id:O,asset_symbol:k,to_address:A.destination.address},wagmiConfig:w,getI18n:()=>D.current,...h?{environment:h}:{},...A.minDepositUsd===void 0?{}:{minDepositUsd:A.minDepositUsd},...A.metadata?{metadata:A.metadata}:{}})},[A,M,m,h,O,k,w]),F=u(()=>c(),[]),I=A?P??F:void 0,L=u(()=>{if(!(!j||!N))return i({userAddress:N,projectKey:m,currency:{networkId:O,assetSymbol:k},wagmiConfig:w,getI18n:()=>D.current,...h?{environment:h}:{},...j.metadata?{metadata:j.metadata}:{}})},[j,N,m,h,O,k,w]),R=u(()=>l(),[]),z=j?L??R:void 0,B=P??L,V=f(e=>B?.subscribe(e)??(()=>{}),()=>{if(P){let e=P.getSnapshot();return e.brand.status===`ready`&&e.target.status===`ready`}return L?L.getSnapshot().receiveOptions.status===`ready`:!1},()=>!1),H=f(e=>P?.subscribe(e)??(()=>{}),()=>{let e=P;if(!e)return;let t=e.getSnapshot();if(t.brand.status===`ready`||t.brand.status===`stale`)return t.brand.payload.name},()=>void 0),U=f(e=>P?.subscribe(e)??(()=>{}),()=>{let e=P;if(!e)return;let t=e.getSnapshot();if(t.brand.status===`ready`||t.brand.status===`stale`)return t.brand.payload.checkoutItemTitle},()=>void 0),W=M??N;return o({gatewayKey:m,environment:h??`production`,assetChain:O,assetSymbol:k,...W?{userAddress:W}:{},...H?{brandName:H}:{},...U?{checkoutItemTitle:U}:{}}),p(n,{value:u(()=>({isReady:V,driver:P}),[V,P]),children:p(a,{theme:v?.theme,accent:v?.accent,radius:v?.radius,direction:v?.direction,i18n:y,storage:b?.driver,storageNamespace:b?.namespace,className:S,...I?{deposit:I}:{},...z?{withdraw:z}:{},children:C})})}export{m as StridgeProvider};
@@ -0,0 +1 @@
1
+ "use client";import{use as e,useCallback as t,useSyncExternalStore as n}from"react";import{getAccount as r,watchAccount as i}from"wagmi/actions";import{WagmiContext as a}from"wagmi";function o(){let o=e(a);return{config:o,address:n(t(e=>o?i(o,{onChange:()=>e()}):()=>{},[o]),t(()=>{if(o)return r(o).address},[o]),()=>void 0)}}export{o as useOptionalWagmi};
@@ -1 +1 @@
1
- const e=Object.freeze({status:`idle`}),t=Object.freeze({brand:e,target:e,addresses:e,balances:e,quote:e,settlement:e,wallet:e}),n=Object.freeze({withdrawableBalances:e,receiveOptions:e,quote:e,settlement:e}),r=()=>{};function i(){if(typeof DOMException==`function`)return new DOMException(`Aborted`,`AbortError`);let e=Error(`Aborted`);return e.name=`AbortError`,e}function a(e){return new Promise((t,n)=>{if(e.aborted){n(i());return}e.addEventListener(`abort`,()=>n(i()),{once:!0})})}function o(){return{getSnapshot:()=>t,subscribe:()=>r,requestQuote:(e,t)=>a(t),submitDeposit:(e,t)=>a(t),watchSettlement:()=>{},fetchActiveSettlement:async()=>null}}function s(){return{getSnapshot:()=>n,subscribe:()=>r,requestQuote:(e,t)=>a(t),submitWithdrawal:(e,t)=>a(t),watchSettlement:()=>{}}}export{o as createStubDepositDriver,s as createStubWithdrawDriver};
1
+ const e=Object.freeze({status:`idle`}),t=Object.freeze({brand:e,target:e,addresses:e,balances:e,quote:e,settlement:e,wallet:e}),n=Object.freeze({withdrawableBalances:e,receiveOptions:e,quote:e,settlement:e}),r=()=>{};function i(){if(typeof DOMException==`function`)return new DOMException(`Aborted`,`AbortError`);let e=Error(`Aborted`);return e.name=`AbortError`,e}function a(e){return new Promise((t,n)=>{if(e.aborted){n(i());return}e.addEventListener(`abort`,()=>n(i()),{once:!0})})}function o(){return{getSnapshot:()=>t,subscribe:()=>r,requestQuote:(e,t)=>a(t),submitDeposit:(e,t)=>a(t),watchSettlement:()=>{},fetchActiveSettlement:async()=>null}}function s(){return{getSnapshot:()=>n,subscribe:()=>r,requestQuote:(e,t)=>a(t),prepareWithdrawal:(e,t)=>a(t),watchSettlement:()=>{}}}export{o as createStubDepositDriver,s as createStubWithdrawDriver};
@@ -1,2 +1,4 @@
1
+ import { WithdrawSubmitActions, WithdrawSubmitCallback, WithdrawSubmitInput } from "../../flows/withdraw/orchestrator/types.js";
2
+ import { WithdrawBalanceInput, WithdrawSuggestedRecipient } from "../../flows/withdraw/dialog/WithdrawDialogBindingsContext.js";
1
3
  import { WithdrawDialog } from "../../flows/withdraw/dialog/WithdrawDialog.js";
2
- export { WithdrawDialog };
4
+ export { type WithdrawBalanceInput, WithdrawDialog, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stridge/kit",
3
- "version": "0.1.0-alpha.13",
3
+ "version": "0.1.0-alpha.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [