@spicenet-io/spiceflow-ui 4.14.4-rc.4 → 4.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,8 +78,11 @@ host-configured RPC. Keep private credentials out of browser bundles.
78
78
  - In this unreleased source, eligible External-mode actions with a matching wallet token
79
79
  and destination chain execute directly from the external signer, without embedded funding.
80
80
  Other assets/chains still use embedded funding and the shared routed executor.
81
- `onPayExecute` and `onLockExecute` remain blocked; the deprecated external-caller hint
82
- supports only the direct case. Verify contract caller/beneficiary and NFT receiver behavior.
81
+ A controlled ERC20 action can opt into `actionExecution: { wallet: "external", recoveryKey: "my-action" }`
82
+ when its contract requires the external caller. The SDK routes funds to that wallet,
83
+ verifies delivery, then submits the captured host calls. This also permits a matching
84
+ external source to execute directly while the app remains in Embedded mode.
85
+ `onPayExecute` and `onLockExecute` remain blocked. Verify contract caller/beneficiary and NFT receiver behavior.
83
86
  Published `.16` does not contain this restoration.
84
87
  - Supply `input` adds fees to principal; `input-inclusive` uses a total budget; Pay
85
88
  `output` fixes the destination amount. Use controller readiness/Max/status instead of
@@ -87,7 +90,7 @@ host-configured RPC. Keep private credentials out of browser bundles.
87
90
  - Use controller recovery for uncertain funding and `retryFinalization()` for failed
88
91
  application updates after settlement. Preserve original host terms across reload.
89
92
  - Deposit and rollup Withdraw retain distinct execution semantics while sharing
90
- inventory/policy. Account wallet withdrawal uses the inclusive Supply controller and its fee hierarchy.
93
+ inventory/policy. Account wallet withdrawal uses the fee-only Supply path.
91
94
 
92
95
  Inventory isolation does not establish support for simultaneous differently configured
93
96
  providers: underlying quote/execution transports still have global state.
@@ -283,12 +286,30 @@ mode to its own wallet, pass `includeExternalWalletAssets={false}` (Embedded mod
283
286
  token in both wallets sees one row per wallet; a host that preselects a source should
284
287
  match on `assetPositionId`, not on symbol or address alone.
285
288
 
289
+ ### Routed external callers
290
+
291
+ The controlled hook supports positive ERC20 input, input-inclusive and fixed-output
292
+ actions with an explicit external caller. Configure `rpcOverrides` for the destination
293
+ and any wallet-source chain. Quotes bind the source spend cap, destination delivery,
294
+ external caller and host calls before funding. The SDK checks the destination receipt,
295
+ ERC20 transfer amount and caller balance before requesting the host transactions.
296
+ Only the final external transaction hash reaches awaited application finalization.
297
+
298
+ Below one destination transaction's native gas cost, the accepted route buys gas for
299
+ the pending external calls plus three later transactions. At or above that threshold
300
+ it adds no reserve; direct execution still pays its own native gas. Native destinations,
301
+ zero-principal, proceeds-funded and explicit source-escrow caller actions remain
302
+ unsupported capability gaps. This does not add a stock-component prop or a durable
303
+ execution journal: after signing fails, delivered tokens remain ordinary wallet assets
304
+ and retrying the original route can fund again. Use `retryFinalization()` to retry only
305
+ a failed application callback after the external action has confirmed.
306
+
286
307
  ### Action Fee Readiness
287
308
 
288
309
  - Routed Supply, Pay and Lock actions must surface fee estimation before enabling submission.
289
310
  - Eligible direct external actions still require an accepted plan but charge no Spicenet fee. Network gas remains payable in the external wallet; native Max reserves gas.
290
311
  - Deposit gas and rollup withdrawal semantics remain distinct from action intent fees. Preserve their existing quote/readiness requirements.
291
- - Account wallet withdrawal uses the shared input-inclusive Supply controller and its fee-only planner for local fees. Do not bypass its fee/readiness gates based on the label "withdraw".
312
+ - Account wallet withdrawal is a fee-only Supply action. Do not bypass its fee/readiness gates based on the label "withdraw".
292
313
  - Custom actions use the shared controller's `canExecute`; an available balance or old quote alone is insufficient.
293
314
  - `onSubmit` on `SpiceSupply`, `SpiceLock`, `SpiceDeposit` and the shared controller fires once when the user submits and the SDK accepts it, before any wallet prompt. Use it for "transaction in progress" feedback instead of listening for clicks on SDK buttons.
294
315
  - `max()` on the shared controller (`useSpiceSupply`, `useSpiceLock`) resolves the fee-aware Max for the selected source, or `null` when there is none or the action fixes its output. The host sets the result as the amount.
@@ -390,7 +411,7 @@ during prewarming. The time available before typing determines how much work it
390
411
  - Declare `actionInput` for every token the action consumes and honour the amount passed to `buildActionCalls`: when fees come from an input, the action is built for the remainder. Declare `actionProceeds` for a token the action leaves in the wallet. Both are optional; with neither, only balances can pay. Omit `actionProceeds` when the output is delivered to another owner.
391
412
  - `feeFunding` overrides the level order per transaction, for example `["proceeds", "input", "balance"]`; the order inside the balance level is fixed. An empty list leaves the choice to the host's `selectedAsset`.
392
413
  - A `selectedAsset` on a fee-only action is an explicit host choice and funds the fee from that balance as before.
393
- - Account wallet withdrawals use this hierarchy automatically and display the chosen fee asset without a selector. Entered amounts and Max are total source-token budgets; applicable fees reduce the net received amount. Same-chain transfers retain the selected token. Choosing another supported chain routes through USDC escrow and delivers registered USDC, with the net output shown before submission. Withdraw discovers permitted embedded balances by default alongside escrow balances; `walletAssets` optionally supplies extra token metadata or an initial wallet selection. Custom `useSpiceSupply` actions that must preserve an exact principal can declare `feeFundingReserve: { asset, amount }` instead of offering that principal as `actionInput`.
414
+ - Account wallet withdrawals use this hierarchy automatically and display the chosen fee asset without a selector. The exact withdrawal amount is reserved before ranking balances; only its remainder can pay fees. Custom `useSpiceSupply` actions that must preserve an exact principal can declare `feeFundingReserve: { asset, amount }` instead of offering that principal as `actionInput`.
394
415
  - `feeOnlyAction` alone declares the action: `amountDirection` defaults to `"output"` and `paymentAmount` to `"0"`. Explicit values still win.
395
416
  - `submit()` on the controller runs the executor that matches `amountDirection`. `submitSupply()` and `submitPay()` remain for existing callers.
396
417
 
@@ -1,3 +1,3 @@
1
1
  "use client";
2
2
  (function(){if(typeof document==="undefined"||document.getElementById("spiceflow-styles"))return;var s=document.createElement("style");s.id="spiceflow-styles";s.textContent="@keyframes spiceflow-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@media (prefers-reduced-motion:reduce){*,:after,:before{animation-duration:.001ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.001ms!important}}.spiceflow-focus-ring:focus-visible,[data-spiceflow-focus]:focus-visible{border-radius:4px;outline:2px solid currentColor;outline-offset:2px}@media (forced-colors:active){.spiceflow-focus-ring:focus-visible,[data-spiceflow-focus]:focus-visible{outline:2px solid Highlight}}.ibm-plex-mono-thin{font-weight:100}.ibm-plex-mono-extralight,.ibm-plex-mono-thin{font-family:IBM Plex Mono,monospace!important;font-style:normal}.ibm-plex-mono-extralight{font-weight:200}.ibm-plex-mono-light{font-weight:300}.ibm-plex-mono-light,.ibm-plex-mono-regular{font-family:IBM Plex Mono,monospace!important;font-style:normal}.ibm-plex-mono-regular{font-weight:400}.ibm-plex-mono-medium{font-weight:500}.ibm-plex-mono-medium,.ibm-plex-mono-semibold{font-family:IBM Plex Mono,monospace!important;font-style:normal}.ibm-plex-mono-semibold{font-weight:600}.ibm-plex-mono-bold{font-family:IBM Plex Mono,monospace!important;font-style:normal;font-weight:700}#privy-modal-content button{border-radius:6px;font-family:IBM Plex Mono,monospace!important;font-size:small;letter-spacing:-.5px;text-transform:uppercase}#privy-modal-content input{background:#fff;border-radius:6px;padding-top:5px!important}#privy-dialog-title{display:none!important;font-size:18px;padding-bottom:10px;padding-top:10px}.AppLogoContainer-sc-a206bd44-0{display:none}#privy-modal-content{background:var(--Neutral-0,#fafafa);border:6px solid var(--Neutral-1,#e9e9e9);box-shadow:inset 0 0 0 1px rgba(0,0,0,.15),0 330px 92px transparent,0 211px 84px rgba(0,0,0,.01),0 119px 71px rgba(0,0,0,.05),0 53px 53px rgba(0,0,0,.09),0 13px 29px rgba(0,0,0,.1);height:auto!important;padding-bottom:10px}.Subtitle-sc-ddbf22b4-4{font-size:12px;margin-top:-14px;opacity:.5}.StyledLink-sc-1c6127e5-0{background:none!important}.StyledLink-sc-c8577138-0,.login-method-button{font-family:IBM Plex Mono,monospace!important}.StyledLink-sc-c8577138-0{font-style:uppercase}#protected-by-privy{color:#000!important}";document.head.appendChild(s)})();
3
- import{P as g}from"./privy-CQoRAq7w.js";import"react/jsx-runtime";import"react";import"@spicenet-io/spiceflow-core";import"@tanstack/react-query";import"viem";import"@privy-io/react-auth";import"wagmi";import"viem/actions";export{g as PrivyLogin};
3
+ import{P as g}from"./privy-BPsKHzUu.js";import"react/jsx-runtime";import"react";import"@spicenet-io/spiceflow-core";import"@tanstack/react-query";import"viem";import"@privy-io/react-auth";import"wagmi";import"viem/actions";export{g as PrivyLogin};
@@ -21,7 +21,6 @@ export type ExecutorContext = {
21
21
  isInsufficientBalance: boolean;
22
22
  isPayMode: boolean;
23
23
  isFeeInclusiveInput?: boolean;
24
- quotedInclusivePlatformFee?: boolean;
25
24
  feeOnlyAction?: boolean;
26
25
  actionProceeds?: Exclude<SpiceSupplyProps["actionProceeds"], "output">;
27
26
  validateFeeQuote?: () => void;
@@ -0,0 +1,24 @@
1
+ import { type Address } from "viem";
2
+ import type { Call, ChainBatch } from "../../../types/authorization";
3
+ import type { BuildActionCallsContext } from "../../../types/supply";
4
+ import type { ActionDefinition } from "../../../utils/actionDefinition";
5
+ import type { SupplyFeeQuote } from "./feePreview";
6
+ export declare function buildExternalAction(params: {
7
+ quote: SupplyFeeQuote;
8
+ recipient: Address;
9
+ beneficiary?: Address;
10
+ chainId: number;
11
+ token: Address;
12
+ feeExecutionMode: BuildActionCallsContext["feeExecutionMode"];
13
+ buildCalls: (amount: bigint, context: BuildActionCallsContext) => Call[] | Promise<Call[]>;
14
+ }): Promise<ActionDefinition>;
15
+ export declare function buildExternalDeliveryCalls(amount: bigint, context: BuildActionCallsContext, recipient: Address): Call[];
16
+ export declare function externalDeliveryAmount(batches: ChainBatch[], token: Address, chainId: number, recipient: Address): bigint;
17
+ export declare function verifyExternalDelivery(params: {
18
+ hash: string;
19
+ token: Address;
20
+ chainId: number;
21
+ recipient: Address;
22
+ sender: Address;
23
+ amount: bigint;
24
+ }): Promise<void>;
@@ -0,0 +1,19 @@
1
+ import type { Address } from "viem";
2
+ import type { ChainBatch } from "../../../types/authorization";
3
+ import type { FeePreviewContext, SupplyFeeQuote } from "./feePreview";
4
+ export interface ExternalGasReserve {
5
+ chainId: number;
6
+ recipient: Address;
7
+ balance: bigint;
8
+ incoming: bigint;
9
+ transactionGas: bigint;
10
+ nativeAmount: bigint;
11
+ currentTransactions: number;
12
+ currentValue: bigint;
13
+ feeAmount: bigint;
14
+ calls: ChainBatch["calls"];
15
+ }
16
+ export declare function quoteExternalGasReserve(ctx: FeePreviewContext, plan: SupplyFeeQuote): Promise<ExternalGasReserve>;
17
+ export declare function appendExternalGasReserve(batches: ChainBatch[], reserve?: ExternalGasReserve): ChainBatch[];
18
+ export declare function assertExternalGasReserveCalls(reserve: ExternalGasReserve | undefined, batches: ChainBatch[]): void;
19
+ export declare function validateExternalGasReserve(reserve?: ExternalGasReserve, batches?: ChainBatch[]): Promise<void>;
@@ -8,10 +8,12 @@ import type { DestinationTokenConfig, FeeFundingSource, PivotRoute, SpiceSupplyP
8
8
  import type { FeePreview } from "../../../types/ui";
9
9
  import type { ResolvedExactOutputSwap } from "../../../utils/swapQuotes";
10
10
  import { type FundingConversion } from "./feeConversion";
11
+ import { type ExternalGasReserve } from "./externalGasReserve";
11
12
  type EstimateFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, options?: ExecutionOptions) => Promise<FeeEstimateSummary>;
12
13
  type BuildPayBatchesFn = (options?: SupplyBatchBuildOptions) => Promise<ChainBatch[]>;
13
14
  type BuildSupplyBatchesFn = (options?: SupplyBatchBuildOptions) => Promise<ChainBatch[]>;
14
15
  export type SupplyFeeQuote = {
16
+ externalGasReserve?: ExternalGasReserve;
15
17
  fundedFeeToken?: DestinationTokenConfig;
16
18
  actionDefinition?: Parameters<NonNullable<SupplyBatchBuildOptions["onActionCalls"]>>[0];
17
19
  fundingConversion?: FundingConversion;
@@ -85,6 +87,9 @@ export declare function estimateSupplyMaxAmount(ctx: {
85
87
  feeExecutionMode: SpiceSupplyProps["feeExecutionMode"];
86
88
  }): Promise<string | null>;
87
89
  export interface FeePreviewContext {
90
+ externalGasRecipient?: Address;
91
+ externalGasCalls?: (plan: SupplyFeeQuote) => Promise<ChainBatch["calls"]>;
92
+ externalGasReserve?: ExternalGasReserve;
88
93
  feeToleranceBps?: number;
89
94
  initialFeeEstimate?: FeeEstimateSummary;
90
95
  initialSourceGasSkim?: bigint;
@@ -104,7 +109,6 @@ export interface FeePreviewContext {
104
109
  selectedAsset: SelectedAsset | null;
105
110
  isPayMode: boolean;
106
111
  isFeeInclusiveInput?: boolean;
107
- quotedInclusivePlatformFee?: boolean;
108
112
  parsedAmount: number;
109
113
  needsSwap: boolean;
110
114
  exactOutputSwap: ResolvedExactOutputSwap | null;
@@ -138,5 +142,5 @@ export declare class FeeShortfallError extends Error {
138
142
  readonly preview: FeePreview;
139
143
  constructor(preview: FeePreview);
140
144
  }
141
- export declare function supplyContextForFees(fees: FeePreview, amount: bigint, inclusive: boolean, mode: SpiceSupplyProps["feeExecutionMode"], quotedInclusivePlatformFee?: boolean): Required<Pick<import("../../../types/supply").BuildActionCallsContext, "grossAmount" | "netAmount" | "combinedFeeAmount" | "feeExecutionMode" | "feeBreakdown">>;
145
+ export declare function supplyContextForFees(fees: FeePreview, amount: bigint, inclusive: boolean, mode: SpiceSupplyProps["feeExecutionMode"], reserveFee?: bigint): Required<Pick<import("../../../types/supply").BuildActionCallsContext, "grossAmount" | "netAmount" | "combinedFeeAmount" | "feeExecutionMode" | "feeBreakdown">>;
142
146
  export {};
@@ -5,12 +5,6 @@ export declare function useSpiceEmbeddedWithdraw(params: {
5
5
  enabled: boolean;
6
6
  asset: Asset | null;
7
7
  amount: bigint;
8
- destination?: {
9
- address: Address;
10
- symbol: string;
11
- decimals: number;
12
- chainId: number;
13
- } | null;
14
8
  recipient?: Address;
15
9
  owner?: Address;
16
10
  sourceChains?: number[];
@@ -119,6 +113,6 @@ export declare function useSpiceEmbeddedWithdraw(params: {
119
113
  resetAfterSuccess: () => void;
120
114
  resetPaymentState: () => void;
121
115
  };
122
- source: Asset | null | undefined;
116
+ source: Asset | undefined;
123
117
  maximumFeeFunding: bigint | null | undefined;
124
118
  };
@@ -6,7 +6,6 @@ import type { Asset, SelectedAsset } from "../types/assets";
6
6
  import type { DestinationTokenDeclaration, SpiceSupplyProps } from "../types/supply";
7
7
  import type { FeePreview } from "../types/ui";
8
8
  export interface UseSpiceSupplyParams extends Pick<SpiceSupplyProps, "sourceChains" | "supportedSourceAssets" | "buildActionCalls" | "feeExecutionMode" | "buildSpicenetBatch" | "onPayExecute" | "resolveExactOutputSwap" | "amountDirection" | "onSubmit" | "onSuccess" | "onError" | "additionalSourceTokens" | "includeExternalWalletAssets" | "includeCrossChainEmbeddedAssets" | "feeOnlyAction" | "actionInput" | "actionProceeds" | "feeFunding" | "maxSlippage" | "resolveInputSwap"> {
9
- quotedInclusivePlatformFee?: boolean;
10
9
  enabled?: boolean;
11
10
  destinationToken: DestinationTokenDeclaration | undefined;
12
11
  selectedAsset: SelectedAsset | null;