@spicenet-io/spiceflow-ui 4.9.3-extmode.5 → 4.10.0-next.1

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 (48) hide show
  1. package/README.md +0 -43
  2. package/dist/auth-privy.js +1 -1
  3. package/dist/components/AccountDisplay/parts/AccountIdleBalances.d.ts +5 -2
  4. package/dist/components/AccountDisplay/parts/AccountPanel.d.ts +2 -2
  5. package/dist/components/AccountDisplay/types.d.ts +2 -5
  6. package/dist/components/SpiceSupply/lib/buildBatches.d.ts +5 -2
  7. package/dist/components/SpiceSupply/lib/controlledFunding.d.ts +53 -0
  8. package/dist/components/SpiceSupply/lib/executors.d.ts +13 -0
  9. package/dist/components/SpiceSupply/lib/externalAction.d.ts +61 -0
  10. package/dist/components/SpiceSupply/lib/feeOnlyExecution.d.ts +6 -0
  11. package/dist/components/SpiceSupply/lib/feePreview.d.ts +3 -0
  12. package/dist/components/SpiceSupply/lib/payFundingBatches.d.ts +6 -0
  13. package/dist/components/SpiceSupply/lib/sourceConversion.d.ts +12 -0
  14. package/dist/components/SpiceWithdraw/lib/helpers.d.ts +1 -1
  15. package/dist/components/SpiceWithdraw/parts/WithdrawBalanceCardHeader.d.ts +1 -0
  16. package/dist/components/SpiceWithdraw/parts/WithdrawBalancePopover.d.ts +15 -0
  17. package/dist/execution/externalWalletClient.d.ts +9 -0
  18. package/dist/execution/fundEmbeddedWallet.d.ts +4 -0
  19. package/dist/execution/sourceFunding.d.ts +28 -0
  20. package/dist/execution/transactionReceipt.d.ts +11 -0
  21. package/dist/hooks/index.d.ts +2 -2
  22. package/dist/hooks/useDirectWithdraw.d.ts +2 -8
  23. package/dist/hooks/useSourceFundingConversion.d.ts +22 -0
  24. package/dist/hooks/useSpiceAssets.d.ts +1 -2
  25. package/dist/hooks/useSpiceExecution.d.ts +3 -0
  26. package/dist/hooks/useSpiceSupply.d.ts +80 -0
  27. package/dist/hooks/useSupplyAssets.d.ts +7 -12
  28. package/dist/hooks/useSupplyQuote.d.ts +5 -1
  29. package/dist/hooks/useWalletBalances.d.ts +1 -2
  30. package/dist/index.cjs.js +7 -7
  31. package/dist/index.d.ts +13 -9
  32. package/dist/index.js +9 -9
  33. package/dist/{privy-DsMpmEiz.js → privy-D5qswtTm.js} +1 -1
  34. package/dist/types/assets.d.ts +2 -1
  35. package/dist/types/supply.d.ts +7 -1
  36. package/dist/types/withdraw.d.ts +0 -1
  37. package/dist/utils/crossChainRouter/algebra.d.ts +83 -0
  38. package/dist/utils/crossChainRouter/liquidityVenues.d.ts +7 -0
  39. package/dist/utils/crossChainRouter/nativeWrap.d.ts +2 -2
  40. package/dist/utils/crossChainRouter/sourceFundingQuote.d.ts +58 -0
  41. package/dist/utils/directWithdraw.d.ts +4 -0
  42. package/dist/utils/spiceConstants.d.ts +1 -0
  43. package/dist/utils/spicenetBatch.d.ts +18 -0
  44. package/dist/utils/swapQuotes.d.ts +1 -0
  45. package/dist/utils/tokenResolution.d.ts +1 -0
  46. package/package.json +2 -2
  47. package/dist/hooks/useSpiceRollupPrices.d.ts +0 -2
  48. package/dist/utils/prices/providerPrices.d.ts +0 -12
package/README.md CHANGED
@@ -108,49 +108,6 @@ it becomes a `protocol` everyone can name.
108
108
 
109
109
  ## Development
110
110
 
111
- ### Rollup balance pricing
112
-
113
- Rollup USD values use the host-configured RPC provider's pricing capability when the balance API has no valid value. The built-in account panel and withdrawal modal enable this while open; custom `useSpiceAssets` consumers can opt in with `priceEnabled`. Quantities arrive independently. Lookups follow receipt mappings, prefer `nativeChainId`, and fall back to other supported chains with a configured Alchemy endpoint. Explicit account `tokenPrices` overrides still take precedence over provider quotes.
114
-
115
- Wallet discovery and rollup balances share a one-minute quote cache. Pricing polls only while the view is open and the page is visible. A failed refresh can retain a marked stale quote for up to five minutes; an unavailable quote displays `—`. No extra key, internal RPC, or symbol-based ERC-20 price fallback is used.
116
-
117
- ### Direct withdrawal in a custom balance row
118
-
119
- `useSpiceDirectWithdraw()` uses the same embedded-wallet transfer and fee path as the account panel's direct Withdraw buttons. It selects the connected external wallet as recipient, exposes `canWithdraw` and `state`, and rejects duplicate submissions while pending. Pass the raw `bigint` balance to `withdraw({ tokenAddress, chainId, balance })` and refresh the host's balance after it resolves. Rejections are available as `state.message` for the host to render.
120
-
121
- Custom account rows accept React content in `displayValue`, so a host can render its own button with that controller. Set the row's `asset: { tokenAddress, chainId }` when it represents an on-chain balance; the account panel then omits that token from discovered idle balances. Existing string values continue to work.
122
-
123
- ### Withdraw from an account balance
124
-
125
- `AccountDisplay.onWithdrawClick` receives the rollup receipt-token ID when a
126
- user clicks Withdraw on an idle rollup balance. The main Withdraw button calls
127
- it without an ID. Pass the ID to `SpiceWithdraw.initialSourceAssetId` to open
128
- the existing modal with that asset selected; the user chooses the destination
129
- network inside the modal. Existing callbacks that take no arguments continue
130
- to work.
131
-
132
- ```tsx
133
- const [withdrawOpen, setWithdrawOpen] = useState(false);
134
- const [withdrawAssetId, setWithdrawAssetId] = useState<string>();
135
-
136
- <AccountDisplay
137
- onWithdrawClick={(receiptTokenId) => {
138
- setWithdrawAssetId(receiptTokenId);
139
- setWithdrawOpen(true);
140
- }}
141
- />
142
- <SpiceWithdraw
143
- isOpen={withdrawOpen}
144
- onClose={() => setWithdrawOpen(false)}
145
- initialSourceAssetId={withdrawAssetId}
146
- buildSpicenetBatch={buildSpicenetWithdrawalBatch}
147
- />
148
- ```
149
-
150
- Keep the integration's existing withdrawal batch builder and callbacks.
151
- `initialSourceAssetId` selects a current balance by ID; it does not supply a
152
- cached balance or change the receipt's supported withdrawal routes.
153
-
154
111
  ### Fee-Charging Intent Flows
155
112
 
156
113
  - `SpiceSupply` and `SpicePay` are fee-charging intent-execution flows and must surface fee estimation before enabling submission.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{P as g}from"./privy-DsMpmEiz.js";import"react/jsx-runtime";import"react";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@privy-io/react-auth";import"wagmi";import"@tanstack/react-query";export{g as PrivyLogin};
2
+ import{P as g}from"./privy-D5qswtTm.js";import"react/jsx-runtime";import"react";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@privy-io/react-auth";import"wagmi";import"@tanstack/react-query";export{g as PrivyLogin};
@@ -1,7 +1,11 @@
1
1
  import React from "react";
2
2
  import { SpiceAsset } from "../types";
3
3
  import type { ResolvedDarkPalette } from "../../../utils/theme";
4
- import type { DirectWithdrawState } from "../../../hooks/useDirectWithdraw";
4
+ export interface DirectWithdrawState {
5
+ key: string;
6
+ step: "pending" | "error";
7
+ message?: string;
8
+ }
5
9
  interface AccountIdleBalancesProps {
6
10
  spiceAssets: SpiceAsset[];
7
11
  loading: boolean;
@@ -10,7 +14,6 @@ interface AccountIdleBalancesProps {
10
14
  canDirectWithdraw?: boolean;
11
15
  onDirectWithdraw?: (asset: SpiceAsset) => void;
12
16
  directWithdrawState?: DirectWithdrawState | null;
13
- onWithdrawClick?: (receiptTokenId?: string) => void;
14
17
  }
15
18
  export declare const AccountIdleBalances: React.NamedExoticComponent<AccountIdleBalancesProps>;
16
19
  export {};
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { SpiceAsset, CustomSection, AccountNotice } from "../types";
3
3
  import { VerifiedPendingDeposit } from "../../../hooks/usePendingDeposit";
4
4
  import type { ResolvedDarkPalette } from "../../../utils/theme";
5
- import type { DirectWithdrawState } from "../../../hooks/useDirectWithdraw";
5
+ import { type DirectWithdrawState } from "./AccountIdleBalances";
6
6
  interface AccountPanelProps {
7
7
  appName: string;
8
8
  status: "active" | "inactive";
@@ -17,7 +17,7 @@ interface AccountPanelProps {
17
17
  customSections: CustomSection[];
18
18
  notice?: AccountNotice | null;
19
19
  onDepositClick?: () => void;
20
- onWithdrawClick?: (receiptTokenId?: string) => void;
20
+ onWithdrawClick?: () => void;
21
21
  depositDisabled?: boolean;
22
22
  onCompleteDeposit?: (deposit: VerifiedPendingDeposit) => void;
23
23
  primaryColor?: string;
@@ -5,8 +5,7 @@ export interface CustomSectionItem {
5
5
  tokenSymbol: string;
6
6
  tokenLogoURI?: string;
7
7
  label: string;
8
- displayValue: React.ReactNode;
9
- asset?: Pick<SpiceAsset, "tokenAddress" | "chainId">;
8
+ displayValue: string;
10
9
  valueColor?: "green" | "red" | "default";
11
10
  }
12
11
  export interface CustomSection {
@@ -25,9 +24,7 @@ export interface SpiceAsset {
25
24
  balance: string;
26
25
  balanceFormatted: number;
27
26
  usdValue: number;
28
- priceStatus?: "fresh" | "stale" | "unavailable";
29
27
  logoURI?: string;
30
- receiptTokenId?: string;
31
28
  directWithdraw?: boolean;
32
29
  }
33
30
  export interface BreakdownLabel {
@@ -51,7 +48,7 @@ export interface AccountDisplayProps {
51
48
  dark?: boolean;
52
49
  onDepositSuccess?: () => void;
53
50
  onDepositClick?: () => void;
54
- onWithdrawClick?: (receiptTokenId?: string) => void;
51
+ onWithdrawClick?: () => void;
55
52
  onCompleteDeposit?: (deposit: VerifiedPendingDeposit) => void;
56
53
  showModeToggle?: boolean;
57
54
  defaultMode?: "7702" | "non7702";
@@ -7,9 +7,11 @@ import type { ResolvedExactOutputSwap } from "../../../utils/swapQuotes";
7
7
  import type { ExecutionOptions } from "../../../hooks/useSpiceExecution";
8
8
  import type { FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
9
9
  type EstimateFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, options?: ExecutionOptions) => Promise<FeeEstimateSummary>;
10
- export declare function isExternalInPlacePaySource(selectedAsset: SelectedAsset | null, isNon7702: boolean, resolvedChainId: number): boolean;
10
+ export declare function buildEmbeddedEscrowDepositBatch(token: Address, amount: bigint, chainId: number): ChainBatch;
11
+ export declare function isExternalSource(asset: SelectedAsset["asset"] | null | undefined, isNon7702: boolean): boolean;
11
12
  export declare function stripSpicenetFundingBatches(batches: ChainBatch[]): ChainBatch[];
12
13
  export declare function scaleTokenAmount(amount: bigint, fromDecimals: number, toDecimals: number): bigint;
14
+ export declare function resolveSupplyTokenDecimals(asset: SelectedAsset["asset"], destination: SpiceSupplyProps["destinationToken"], token: Address): Promise<number>;
13
15
  export interface BatchBuilderContext {
14
16
  currentPaymentAmount: string;
15
17
  destinationToken: SpiceSupplyProps["destinationToken"];
@@ -18,8 +20,10 @@ export interface BatchBuilderContext {
18
20
  externalWalletAddress: string | null | undefined;
19
21
  address: string | null | undefined;
20
22
  recipient?: Address;
23
+ swapOutputRecipient?: Address;
21
24
  isNon7702: boolean;
22
25
  isPayMode: boolean;
26
+ feeOnlyAction?: boolean;
23
27
  resolvedChainId: number;
24
28
  buildActionCalls: SpiceSupplyProps["buildActionCalls"];
25
29
  feeExecutionMode: SpiceSupplyProps["feeExecutionMode"];
@@ -27,7 +31,6 @@ export interface BatchBuilderContext {
27
31
  selectedAsset: SelectedAsset | null;
28
32
  needsSwap: boolean;
29
33
  resolvedSwap: ResolvedSwap | null;
30
- resolveInputSwap?: (amountIn: bigint) => Promise<ResolvedSwap>;
31
34
  exactOutputSwap: ResolvedExactOutputSwap | null;
32
35
  quoteAmountOut: bigint | null;
33
36
  resolvedTokenIn: Address | null;
@@ -0,0 +1,53 @@
1
+ import { type SourceFundingState } from "../../../execution/sourceFunding";
2
+ import { type ExecutorContext } from "./executors";
3
+ import type { Asset, SelectedAsset } from "../../../types/assets";
4
+ import type { DestinationTokenConfig } from "../../../types/supply";
5
+ export declare const SOURCE_FUNDING_EVENT = "spiceflow:source-funding";
6
+ type StoredSelectedAsset = {
7
+ asset: Omit<Asset, "balance"> & {
8
+ balance: string;
9
+ };
10
+ amount: string;
11
+ };
12
+ export interface SourceFundingProgress {
13
+ feeOnlyAction: boolean;
14
+ phase: "funding" | "routing";
15
+ confirmedAmount: string;
16
+ matchesSelection: boolean;
17
+ matchesPurpose: boolean;
18
+ requiresRecovery: boolean;
19
+ recoveryKey: string;
20
+ selectedAsset: SelectedAsset;
21
+ destinationToken: DestinationTokenConfig;
22
+ paymentAmount: string;
23
+ amountDirection: "input" | "input-inclusive" | "output";
24
+ }
25
+ export interface FundingRecord {
26
+ feeOnlyAction?: boolean;
27
+ version: 2;
28
+ scope: string;
29
+ identity: string;
30
+ funding: SourceFundingState;
31
+ submitted: boolean;
32
+ recoveryKey: string;
33
+ selectedAsset: StoredSelectedAsset;
34
+ destinationToken: DestinationTokenConfig;
35
+ paymentAmount: string;
36
+ amountDirection: SourceFundingProgress["amountDirection"];
37
+ route?: {
38
+ actionId: string;
39
+ intentId: string;
40
+ intentIndex: number;
41
+ spicenetSteps: boolean[];
42
+ };
43
+ }
44
+ export declare function controlledFundingProgress(record: FundingRecord, ctx: ExecutorContext): SourceFundingProgress;
45
+ export declare function readControlledFunding(scope: string): FundingRecord | null;
46
+ export declare function executeWithSourceFunding(params: {
47
+ scope: string;
48
+ ctx: ExecutorContext;
49
+ run: (ctx: ExecutorContext) => Promise<void>;
50
+ isCurrent: () => boolean;
51
+ onRecord?: (record: FundingRecord | null) => void;
52
+ }): Promise<void>;
53
+ export {};
@@ -1,5 +1,8 @@
1
+ import { type SourceConversionExecution } from "./sourceConversion";
1
2
  import type { Dispatch, MutableRefObject, SetStateAction } from "react";
2
3
  import { type Address } from "viem";
4
+ import { type TransactionObserver } from "../../../execution/externalWalletClient";
5
+ import { type SourceFundingState } from "../../../execution/sourceFunding";
3
6
  import type { SelectedAsset } from "../../../types/assets";
4
7
  import type { BuildPayBatchesFn, BuildSupplyBatchesFn, SpiceSupplyProps } from "../../../types/supply";
5
8
  import { type SupplyFeeQuote } from "./feePreview";
@@ -12,6 +15,7 @@ export type PaymentResult = {
12
15
  txHash?: string;
13
16
  error?: string;
14
17
  };
18
+ export { isExternalSource } from "./buildBatches";
15
19
  export type ExecutorContext = {
16
20
  selectedAsset: SelectedAsset | null;
17
21
  parsedAmount: number;
@@ -19,6 +23,7 @@ export type ExecutorContext = {
19
23
  isInsufficientBalance: boolean;
20
24
  isPayMode: boolean;
21
25
  isFeeInclusiveInput?: boolean;
26
+ feeOnlyAction?: boolean;
22
27
  isNon7702: boolean;
23
28
  isSourceDestToken: boolean;
24
29
  needsSwap: boolean;
@@ -43,7 +48,14 @@ export type ExecutorContext = {
43
48
  provider: string | null | undefined;
44
49
  resolvedChainId: number;
45
50
  executionTokenAddress: Address;
51
+ executionTokenDecimals?: number;
46
52
  feeQuote: SupplyFeeQuote | null;
53
+ fundingObserver?: TransactionObserver;
54
+ sourceFunding?: SourceFundingState;
55
+ sourceFundingRecoveryKey?: string;
56
+ sourceConversion?: SourceConversionExecution;
57
+ sourceConversionRequired?: boolean;
58
+ onSourceFundingChange?: (state: SourceFundingState) => void;
47
59
  execution: ExecutionRunner & {
48
60
  buildPayChainBatches: BuildPayBatchesFn;
49
61
  buildSupplyChainBatches: BuildSupplyBatchesFn;
@@ -63,5 +75,6 @@ export type ExecutorContext = {
63
75
  abortControllerRef: MutableRefObject<AbortController | null>;
64
76
  };
65
77
  } & Pick<SpiceSupplyProps, "destinationToken" | "buildActionCalls" | "feeExecutionMode" | "buildSpicenetBatch" | "onPayExecute" | "onSuccess">;
78
+ export declare function sourceFundingIdentity(ctx: ExecutorContext): string;
66
79
  export declare function executeSupply(ctx: ExecutorContext): Promise<void>;
67
80
  export declare function executePay(ctx: ExecutorContext): Promise<void>;
@@ -0,0 +1,61 @@
1
+ import { type Address } from "viem";
2
+ import { type SourceFundingState } from "../../../execution/sourceFunding";
3
+ import { type ExecutorContext } from "./executors";
4
+ import type { BuildActionCallsContext, SpiceSupplyProps } from "../../../types/supply";
5
+ import type { Call } from "../../../types/authorization";
6
+ export type ExternalActionExecution = {
7
+ wallet: "external";
8
+ recoveryKey: string;
9
+ };
10
+ export interface ExternalActionProgress {
11
+ destinationToken: Address;
12
+ destinationDecimals: number;
13
+ phase: "funding" | "routing" | "action" | "complete";
14
+ confirmedCalls: number;
15
+ totalCalls: number;
16
+ amount?: string;
17
+ requiresRecovery: boolean;
18
+ }
19
+ type PendingTransaction = {
20
+ chainId: number;
21
+ hash?: `0x${string}`;
22
+ };
23
+ type StoredCall = {
24
+ to: Address;
25
+ value: string;
26
+ data: `0x${string}`;
27
+ };
28
+ export interface ExternalActionRecord {
29
+ version: 2;
30
+ scope: string;
31
+ destinationToken: Address;
32
+ destinationDecimals: number;
33
+ sourceKey: string;
34
+ phase: ExternalActionProgress["phase"];
35
+ amount?: string;
36
+ calls?: StoredCall[];
37
+ confirmedCalls: number;
38
+ sourceFunding?: SourceFundingState;
39
+ pendingCall?: PendingTransaction;
40
+ routeSubmitted: boolean;
41
+ route?: {
42
+ actionId: string;
43
+ intentId: string;
44
+ intentIndex: number;
45
+ spicenetSteps: boolean[];
46
+ };
47
+ lastHash?: `0x${string}`;
48
+ }
49
+ export declare function externalActionScope(network: string, chainId: number, external: string, embedded: string, recoveryKey: string): string;
50
+ export declare function readExternalAction(scope: string): ExternalActionRecord | null;
51
+ export declare function externalActionProgress(record: ExternalActionRecord): ExternalActionProgress;
52
+ export declare function clearCompletedExternalAction(scope: string): void;
53
+ export declare function buildExternalDeliveryCalls(amount: bigint, context: BuildActionCallsContext, recipient: Address): Call[];
54
+ export declare function executeExternalActionSupply(params: {
55
+ scope: string;
56
+ ctx: ExecutorContext;
57
+ buildActionCalls: SpiceSupplyProps["buildActionCalls"];
58
+ onRecord: (record: ExternalActionRecord) => void;
59
+ isCurrent?: () => boolean;
60
+ }): Promise<void>;
61
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type Address } from "viem";
2
+ import type { ChainBatch } from "../../../types/authorization";
3
+ import type { ExecutionOptions } from "../../../hooks/useSpiceExecution";
4
+ import type { ExecutorContext } from "./executors";
5
+ export declare function stripFeeOnlyCalls(batches: ChainBatch[], chainId: number, token: Address): ChainBatch[];
6
+ export declare function feeOnlyExecutionOptions(ctx: ExecutorContext, token: Address, fundingCap: bigint): Pick<ExecutionOptions, "prepareForSigning" | "validateBeforeSubmit">;
@@ -18,6 +18,7 @@ export type SupplyFeeQuote = {
18
18
  export declare function solveGrossFunding(fees: Pick<FeePreview, "grossAmount" | "gasFee" | "spicenetFee" | "bridgeFee">, requiredNetFunding: bigint): bigint;
19
19
  export declare function estimatePayFunding(args: {
20
20
  requiredNetFunding: bigint;
21
+ feeOnlyAction?: boolean;
21
22
  buildBatches: (gross: bigint) => ChainBatch[] | Promise<ChainBatch[]>;
22
23
  fundingToken: Address;
23
24
  estimate: EstimateFn;
@@ -36,6 +37,7 @@ export declare function estimatePayFunding(args: {
36
37
  export declare function estimateSupplyMaxAmount(ctx: {
37
38
  asset: Asset;
38
39
  isPayMode: boolean;
40
+ isFeeInclusiveInput?: boolean;
39
41
  isNon7702: boolean;
40
42
  needsSwap: boolean;
41
43
  isQuoting: boolean;
@@ -50,6 +52,7 @@ export interface FeePreviewContext {
50
52
  selectedAsset: SelectedAsset | null;
51
53
  isPayMode: boolean;
52
54
  isFeeInclusiveInput?: boolean;
55
+ feeOnlyAction?: boolean;
53
56
  parsedAmount: number;
54
57
  needsSwap: boolean;
55
58
  exactOutputSwap: ResolvedExactOutputSwap | null;
@@ -0,0 +1,6 @@
1
+ import type { Address } from "viem";
2
+ import type { FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
3
+ import type { ChainBatch } from "../../../types/authorization";
4
+ export declare function wrapPayWithSpicenet(raw: ChainBatch[], fundingRecipient: Address, feeEstimate?: FeeEstimateSummary, opts?: {
5
+ payoutAlreadyGross?: boolean;
6
+ }): ChainBatch[];
@@ -0,0 +1,12 @@
1
+ import type { ExecutorContext } from "./executors";
2
+ import type { ChainBatch } from "../../../types/authorization";
3
+ import type { SelectedAsset } from "../../../types/assets";
4
+ import type { SourceFundingExecutionPlan } from "../../../utils/crossChainRouter/sourceFundingQuote";
5
+ export interface SourceConversionExecution {
6
+ virtualSelectedAsset: SelectedAsset;
7
+ acceptedSourceAmountInMax: bigint;
8
+ getPlan: (batches: ChainBatch[]) => SourceFundingExecutionPlan | undefined;
9
+ isCurrent: () => boolean;
10
+ }
11
+ export declare function sourceBatchKey(batch: ChainBatch): string;
12
+ export declare function executeSourceConversion(ctx: ExecutorContext, run: (ctx: ExecutorContext) => Promise<void>, fundExternal: (amount: bigint) => Promise<void>): Promise<void>;
@@ -2,5 +2,5 @@ import type { ChainBatch } from "../../../types/authorization";
2
2
  export declare function normalizeTokenLabel(value?: string | null): string;
3
3
  export declare function formatTokenAmount(rawAmount: bigint, decimals: number): string;
4
4
  export declare function scaleAmountBetweenDecimals(amount: bigint, fromDecimals: number, toDecimals: number): bigint;
5
- export declare function estimateUsd(amount: number, price?: number, stale?: boolean): string;
5
+ export declare function estimateUsd(amount: number, symbol?: string): string;
6
6
  export declare function buildWithdrawFeeEstimateKey(batches: ChainBatch[], tokenAddress?: string | null): string | null;
@@ -4,6 +4,7 @@ interface WithdrawBalanceCardHeaderProps {
4
4
  label: string;
5
5
  spiceAssetsLoading: boolean;
6
6
  totalSelectedBalance: number;
7
+ onOpenBalancePopover: (anchor: HTMLElement | null) => void;
7
8
  dark: boolean;
8
9
  dk: ResolvedDarkPalette;
9
10
  }
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { ResolvedDarkPalette } from "../../../utils/theme";
3
+ interface BalancePopoverProps {
4
+ show: boolean;
5
+ position: {
6
+ top: number;
7
+ left: number;
8
+ } | null;
9
+ popoverRef: React.RefObject<HTMLDivElement>;
10
+ spiceAssets: any[] | null | undefined;
11
+ dark: boolean;
12
+ dk: ResolvedDarkPalette;
13
+ }
14
+ export declare const BalancePopover: React.FC<BalancePopoverProps>;
15
+ export {};
@@ -1,5 +1,13 @@
1
1
  import { type Address } from "viem";
2
2
  import type { Call } from "../types/authorization";
3
+ export interface TransactionObserver {
4
+ onSending?: (index: number) => void | Promise<void>;
5
+ onSubmitted?: (index: number, hash: `0x${string}`) => void;
6
+ onConfirmed?: (index: number, hash: `0x${string}`) => void;
7
+ onReverted?: (index: number, hash: `0x${string}`) => void;
8
+ onRejected?: (index: number) => void;
9
+ }
10
+ export declare function isWalletRejection(error: unknown): boolean;
3
11
  export declare function createExternalWalletClient(params: {
4
12
  wallet?: {
5
13
  getEthereumProvider: () => Promise<any>;
@@ -18,4 +26,5 @@ export declare function sendCallsWithExternalWallet(params: {
18
26
  calls: Call[];
19
27
  viemChain?: any;
20
28
  errorMessage: string;
29
+ observer?: TransactionObserver;
21
30
  }): Promise<`0x${string}` | undefined>;
@@ -1,4 +1,7 @@
1
1
  import { type Address } from "viem";
2
+ import { type TransactionObserver } from "./externalWalletClient";
3
+ import type { Call } from "../types/authorization";
4
+ export declare function tokenTransferCall(recipient: Address, tokenAddr: Address, isNative: boolean, amount: bigint): Call;
2
5
  export declare function sendTokenTransferTx(extWc: any, params: {
3
6
  recipient: Address;
4
7
  tokenAddr: Address;
@@ -14,4 +17,5 @@ export declare function fundEmbeddedWallet(params: {
14
17
  isNative: boolean;
15
18
  amount: bigint;
16
19
  viemChain?: unknown;
20
+ observer?: TransactionObserver;
17
21
  }): Promise<void>;
@@ -0,0 +1,28 @@
1
+ import { type Address } from "viem";
2
+ import type { TransactionObserver } from "./externalWalletClient";
3
+ export interface SourceFundingState {
4
+ version: 1;
5
+ identity: string;
6
+ baseline: string;
7
+ confirmedAmount: string;
8
+ pending?: {
9
+ amount: string;
10
+ hash?: `0x${string}`;
11
+ };
12
+ }
13
+ export declare function isSourceFundingState(value: unknown): value is SourceFundingState;
14
+ export declare function fundSelectedExternalSource(params: {
15
+ identity: string;
16
+ state?: SourceFundingState;
17
+ onState: (state: SourceFundingState) => void;
18
+ createWallet: () => Promise<{
19
+ extWc: any;
20
+ viemChain?: any;
21
+ }>;
22
+ sourceClient: any;
23
+ recipient: Address;
24
+ tokenAddr: Address;
25
+ isNative: boolean;
26
+ requiredAmount: bigint;
27
+ observer?: TransactionObserver;
28
+ }): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import type { Call } from "../types/authorization";
2
+ export declare function waitForExpectedTransactionReceipt(params: {
3
+ client: any;
4
+ hash: `0x${string}`;
5
+ call: Call;
6
+ onRepriced?: (hash: `0x${string}`) => void;
7
+ onCancelled?: () => void;
8
+ }): Promise<{
9
+ receipt: any;
10
+ hash: `0x${string}`;
11
+ }>;
@@ -6,8 +6,6 @@ export type { UseWalletReturn, WalletState, WalletActions } from "./useWallet";
6
6
  export { useSpiceAssets } from "./useSpiceAssets";
7
7
  export type { UseSpiceAssetsConfig, UseSpiceAssetsReturn, } from "./useSpiceAssets";
8
8
  export { useSpiceExecution } from "./useSpiceExecution";
9
- export { useDirectWithdraw as useSpiceDirectWithdraw } from "./useDirectWithdraw";
10
- export type { DirectWithdrawParams, DirectWithdrawState, } from "./useDirectWithdraw";
11
9
  export type { ExecutionProgress, ExecutionStep, ExecutionOptions, OnProgress, } from "./useSpiceExecution";
12
10
  export { useLockDuration } from "./useLockDuration";
13
11
  export type { UseLockDurationReturn } from "./useLockDuration";
@@ -21,3 +19,5 @@ export type { PartnerWhitelistCheckResponse, UseIsUserWhitelistedOptions, } from
21
19
  export { useSupplyAssets, isSupportedSupplyAsset } from "./useSupplyAssets";
22
20
  export { useSupplyQuote, resolveInputSupplySwapQuote } from "./useSupplyQuote";
23
21
  export type { UseSupplyQuoteOpts, SupplyQuoteResult } from "./useSupplyQuote";
22
+ export { useSpiceSupply } from "./useSpiceSupply";
23
+ export type { ExternalActionExecution, ExternalActionProgress, SourceFundingProgress, UseSpiceSupplyParams, UseSpiceSupplyResult, } from "./useSpiceSupply";
@@ -4,15 +4,9 @@ export interface DirectWithdrawParams {
4
4
  tokenAddress: Address | string;
5
5
  chainId: number;
6
6
  balance: bigint;
7
+ recipient: Address | string;
7
8
  onProgress?: (progress: ExecutionProgress) => void;
8
9
  }
9
- export interface DirectWithdrawState {
10
- key: string;
11
- step: "pending" | "error";
12
- message?: string;
13
- }
14
10
  export declare function useDirectWithdraw(): {
15
- withdraw: ({ tokenAddress, chainId, balance, onProgress, }: DirectWithdrawParams) => Promise<string>;
16
- canWithdraw: boolean;
17
- state: DirectWithdrawState | null;
11
+ withdraw: ({ tokenAddress, chainId, balance, recipient, onProgress, }: DirectWithdrawParams) => Promise<string>;
18
12
  };
@@ -0,0 +1,22 @@
1
+ import { type Address } from "viem";
2
+ import { type SourceFundingExecutionPlan } from "../utils/crossChainRouter/sourceFundingQuote";
3
+ import type { SelectedAsset } from "../types/assets";
4
+ import type { DestinationTokenConfig } from "../types/supply";
5
+ export declare function useSourceFundingConversion(params: {
6
+ enabled: boolean;
7
+ selectedAsset: SelectedAsset | null;
8
+ destinationToken: DestinationTokenConfig;
9
+ executorAddress?: Address;
10
+ direction: "input" | "input-inclusive" | "output";
11
+ maxSlippage?: number;
12
+ outputAmount?: bigint;
13
+ }): {
14
+ required: boolean;
15
+ plan: import("../utils/crossChainRouter/sourceFundingQuote").SourceFundingPlan | null;
16
+ key: string;
17
+ virtualSelectedAsset: SelectedAsset | null;
18
+ prepare: (requiredBridgeAmount?: bigint) => Promise<SourceFundingExecutionPlan>;
19
+ getPrepared: (amount?: bigint) => SourceFundingExecutionPlan | null;
20
+ error: string | null;
21
+ isCurrent: () => boolean;
22
+ };
@@ -5,7 +5,6 @@ export interface UseSpiceAssetsConfig {
5
5
  supportedChains?: number[];
6
6
  enabled?: boolean;
7
7
  refetchInterval?: number;
8
- priceEnabled?: boolean;
9
8
  }
10
9
  export interface UseSpiceAssetsReturn {
11
10
  assets: Asset[];
@@ -15,4 +14,4 @@ export interface UseSpiceAssetsReturn {
15
14
  refetch: () => Promise<void>;
16
15
  getAssetsByChain: (chainId: number) => Asset[];
17
16
  }
18
- export declare const useSpiceAssets: ({ address, supportedChains, enabled, refetchInterval, priceEnabled, }: UseSpiceAssetsConfig) => UseSpiceAssetsReturn;
17
+ export declare const useSpiceAssets: ({ address, supportedChains, enabled, refetchInterval, }: UseSpiceAssetsConfig) => UseSpiceAssetsReturn;
@@ -31,6 +31,9 @@ export interface ExecutionOptions {
31
31
  }) => ChainBatch[] | null | Promise<ChainBatch[] | null>;
32
32
  skipPreSubmitFeeEstimate?: boolean;
33
33
  submittedFeeEstimate?: FeeEstimateSummary;
34
+ validateBeforeSubmit?: (chainBatches: ChainBatch[]) => void | Promise<void>;
35
+ requireDestinationReceipt?: boolean;
36
+ prepareForSigning?: (chainBatches: ChainBatch[]) => Promise<ChainBatch[]>;
34
37
  skipUserFundingPreflight?: boolean;
35
38
  signal?: AbortSignal;
36
39
  }
@@ -0,0 +1,80 @@
1
+ import { type Address } from "viem";
2
+ import { type PaymentResult, type SupplyStep } from "../components/SpiceSupply/lib/executors";
3
+ import { type SourceFundingProgress } from "../components/SpiceSupply/lib/controlledFunding";
4
+ import { type ExternalActionExecution, type ExternalActionProgress } from "../components/SpiceSupply/lib/externalAction";
5
+ export type { ExternalActionExecution, ExternalActionProgress, } from "../components/SpiceSupply/lib/externalAction";
6
+ export type { SourceFundingProgress } from "../components/SpiceSupply/lib/controlledFunding";
7
+ import { useSupplyAssets } from "./useSupplyAssets";
8
+ import { useSupplyQuote } from "./useSupplyQuote";
9
+ import type { LiquidityVenue } from "../utils/crossChainRouter/liquidityVenues";
10
+ import type { SpiceSupplyProps } from "../types/supply";
11
+ import type { Asset, SelectedAsset } from "../types/assets";
12
+ import type { FeePreview } from "../types/ui";
13
+ export interface UseSpiceSupplyParams extends Pick<SpiceSupplyProps, "destinationToken" | "sourceChains" | "supportedSourceAssets" | "includeExternalWalletAssets" | "includeCrossChainEmbeddedAssets" | "sourceFundingRecoveryKey" | "feeOnlyAction" | "buildActionCalls" | "feeExecutionMode" | "buildSpicenetBatch" | "onPayExecute" | "resolveExactOutputSwap" | "amountDirection" | "onSuccess" | "onError"> {
14
+ enabled: boolean;
15
+ actionExecution?: ExternalActionExecution;
16
+ selectedAsset: SelectedAsset | null;
17
+ paymentAmount?: string;
18
+ recipient?: Address;
19
+ maxSlippage?: number;
20
+ resolveInputSwap?: LiquidityVenue["resolve"];
21
+ prependSourceEscrow?: boolean;
22
+ isZeroAmountPay?: boolean;
23
+ }
24
+ export interface UseSpiceSupplyResult {
25
+ assets: ReturnType<typeof useSupplyAssets> & {
26
+ selectable: Asset[];
27
+ };
28
+ quote: ReturnType<typeof useSupplyQuote> & {
29
+ hasSourceConversion: boolean;
30
+ executionInput: {
31
+ address: Address;
32
+ chainId: number;
33
+ decimals: number;
34
+ amount: bigint;
35
+ } | null;
36
+ };
37
+ fees: {
38
+ preview: FeePreview | null;
39
+ source: {
40
+ symbol: string;
41
+ decimals: number;
42
+ gasFee: bigint;
43
+ spicenetFee: bigint;
44
+ } | null;
45
+ isLoading: boolean;
46
+ ready: boolean;
47
+ error: string | null;
48
+ };
49
+ amount: {
50
+ parsed: number;
51
+ isInsufficientBalance: boolean;
52
+ sourceBalance: number;
53
+ feesExceedAmount: boolean;
54
+ sourceRequiredAmount: bigint | null;
55
+ };
56
+ status: {
57
+ step: SupplyStep;
58
+ statusMsg: string;
59
+ txHash: string | null;
60
+ isExecuting: boolean;
61
+ error: string | null;
62
+ showStatusPanel: boolean;
63
+ paymentResult: PaymentResult | null;
64
+ externalAction: ExternalActionProgress | null;
65
+ sourceFunding: SourceFundingProgress | null;
66
+ };
67
+ flags: {
68
+ directExecutionFeeNote: boolean;
69
+ };
70
+ canExecute: boolean;
71
+ submitSupply: () => Promise<void>;
72
+ submitPay: () => Promise<void>;
73
+ fundEmbeddedSource: (amount: bigint) => Promise<void>;
74
+ retrySupply: () => void;
75
+ dismissPaymentStatus: () => void;
76
+ resolveMaxAmount: (asset: Asset) => Promise<string | null>;
77
+ resetAfterSuccess: () => void;
78
+ resetPaymentState: () => void;
79
+ }
80
+ export declare function useSpiceSupply(params: UseSpiceSupplyParams): UseSpiceSupplyResult;