@spicenet-io/spiceflow-ui 4.9.2 → 4.9.3-extmode.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
@@ -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-BX0ShdbI.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-Baz1RPs-.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";
@@ -26,6 +26,7 @@ export interface BatchBuilderContext {
26
26
  selectedAsset: SelectedAsset | null;
27
27
  needsSwap: boolean;
28
28
  resolvedSwap: ResolvedSwap | null;
29
+ resolveInputSwap?: (amountIn: bigint) => Promise<ResolvedSwap>;
29
30
  exactOutputSwap: ResolvedExactOutputSwap | null;
30
31
  quoteAmountOut: bigint | null;
31
32
  resolvedTokenIn: Address | null;
@@ -18,6 +18,7 @@ export type ExecutorContext = {
18
18
  currentPaymentAmount: string;
19
19
  isInsufficientBalance: boolean;
20
20
  isPayMode: boolean;
21
+ isFeeInclusiveInput?: boolean;
21
22
  isNon7702: boolean;
22
23
  isSourceDestToken: boolean;
23
24
  needsSwap: boolean;
@@ -49,6 +49,7 @@ export interface FeePreviewContext {
49
49
  signal?: AbortSignal;
50
50
  selectedAsset: SelectedAsset | null;
51
51
  isPayMode: boolean;
52
+ isFeeInclusiveInput?: boolean;
52
53
  parsedAmount: number;
53
54
  needsSwap: boolean;
54
55
  exactOutputSwap: ResolvedExactOutputSwap | null;
@@ -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 {};
@@ -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";
@@ -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
  };
@@ -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;
@@ -4,6 +4,9 @@ export declare function isSupportedSupplyAsset(asset: Pick<Asset, "address" | "c
4
4
  export declare function isSpendableSupplyAsset(asset: Pick<Asset, "address" | "chainTokens" | "chainId"> & {
5
5
  _source?: string;
6
6
  }, destinationChainId: number, supportedSourceAssets?: string[]): boolean;
7
+ export declare function isSpendableExternalAsset(asset: Pick<Asset, "address" | "chainTokens" | "chainId"> & {
8
+ _source?: string;
9
+ }, destinationToken: Pick<DestinationToken, "address" | "chainId">, isPayMode: boolean, supportedSourceAssets?: string[]): boolean;
7
10
  type DestinationToken = {
8
11
  address: Address;
9
12
  decimals: number;
@@ -8,7 +8,6 @@ export interface UseAssetsConfig {
8
8
  fetchBalances: (address: Address, supportedChains?: number[]) => Promise<MultiChainBalances>;
9
9
  enabled?: boolean;
10
10
  refreshInterval?: number;
11
- priceEnabled?: boolean;
12
11
  }
13
12
  export interface UseAssetsReturn {
14
13
  assets: Asset[];
@@ -18,4 +17,4 @@ export interface UseAssetsReturn {
18
17
  getAssetsByChain: (chainId: number) => Asset[];
19
18
  getNativeAssets: () => Asset[];
20
19
  }
21
- export declare const useWalletBalances: ({ address, supportedChains, fetchBalances, enabled, refreshInterval, priceEnabled, }: UseAssetsConfig) => UseAssetsReturn;
20
+ export declare const useWalletBalances: ({ address, supportedChains, fetchBalances, enabled, refreshInterval, }: UseAssetsConfig) => UseAssetsReturn;