@spicenet-io/spiceflow-ui 4.14.5-limit-orders.0 → 4.15.0

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
@@ -283,6 +286,24 @@ 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.
@@ -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;
@@ -137,5 +142,5 @@ export declare class FeeShortfallError extends Error {
137
142
  readonly preview: FeePreview;
138
143
  constructor(preview: FeePreview);
139
144
  }
140
- export declare function supplyContextForFees(fees: FeePreview, amount: bigint, inclusive: boolean, mode: SpiceSupplyProps["feeExecutionMode"]): 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">>;
141
146
  export {};