@spicenet-io/spiceflow-ui 4.9.3-extmode.0 → 4.9.3-extmode.2
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 +43 -0
- package/dist/auth-privy.js +1 -1
- package/dist/components/AccountDisplay/parts/AccountIdleBalances.d.ts +2 -5
- package/dist/components/AccountDisplay/parts/AccountPanel.d.ts +2 -2
- package/dist/components/AccountDisplay/types.d.ts +5 -2
- package/dist/components/SpiceWithdraw/lib/helpers.d.ts +1 -1
- package/dist/components/SpiceWithdraw/parts/WithdrawBalanceCardHeader.d.ts +0 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useDirectWithdraw.d.ts +8 -2
- package/dist/hooks/useSpiceAssets.d.ts +2 -1
- package/dist/hooks/useSpiceRollupPrices.d.ts +2 -0
- package/dist/hooks/useWalletBalances.d.ts +2 -1
- package/dist/index.cjs.js +11 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -9
- package/dist/{privy-Baz1RPs-.js → privy-DsMpmEiz.js} +1 -1
- package/dist/types/assets.d.ts +1 -0
- package/dist/types/withdraw.d.ts +1 -0
- package/dist/utils/directWithdraw.d.ts +0 -4
- package/dist/utils/prices/providerPrices.d.ts +12 -0
- package/package.json +1 -1
- package/dist/components/SpiceWithdraw/parts/WithdrawBalancePopover.d.ts +0 -15
package/README.md
CHANGED
|
@@ -108,6 +108,49 @@ 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
|
+
|
|
111
154
|
### Fee-Charging Intent Flows
|
|
112
155
|
|
|
113
156
|
- `SpiceSupply` and `SpicePay` are fee-charging intent-execution flows and must surface fee estimation before enabling submission.
|
package/dist/auth-privy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{P as g}from"./privy-
|
|
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};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpiceAsset } from "../types";
|
|
3
3
|
import type { ResolvedDarkPalette } from "../../../utils/theme";
|
|
4
|
-
|
|
5
|
-
key: string;
|
|
6
|
-
step: "pending" | "error";
|
|
7
|
-
message?: string;
|
|
8
|
-
}
|
|
4
|
+
import type { DirectWithdrawState } from "../../../hooks/useDirectWithdraw";
|
|
9
5
|
interface AccountIdleBalancesProps {
|
|
10
6
|
spiceAssets: SpiceAsset[];
|
|
11
7
|
loading: boolean;
|
|
@@ -14,6 +10,7 @@ interface AccountIdleBalancesProps {
|
|
|
14
10
|
canDirectWithdraw?: boolean;
|
|
15
11
|
onDirectWithdraw?: (asset: SpiceAsset) => void;
|
|
16
12
|
directWithdrawState?: DirectWithdrawState | null;
|
|
13
|
+
onWithdrawClick?: (receiptTokenId?: string) => void;
|
|
17
14
|
}
|
|
18
15
|
export declare const AccountIdleBalances: React.NamedExoticComponent<AccountIdleBalancesProps>;
|
|
19
16
|
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 {
|
|
5
|
+
import type { DirectWithdrawState } from "../../../hooks/useDirectWithdraw";
|
|
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?: () => void;
|
|
20
|
+
onWithdrawClick?: (receiptTokenId?: string) => void;
|
|
21
21
|
depositDisabled?: boolean;
|
|
22
22
|
onCompleteDeposit?: (deposit: VerifiedPendingDeposit) => void;
|
|
23
23
|
primaryColor?: string;
|
|
@@ -5,7 +5,8 @@ export interface CustomSectionItem {
|
|
|
5
5
|
tokenSymbol: string;
|
|
6
6
|
tokenLogoURI?: string;
|
|
7
7
|
label: string;
|
|
8
|
-
displayValue:
|
|
8
|
+
displayValue: React.ReactNode;
|
|
9
|
+
asset?: Pick<SpiceAsset, "tokenAddress" | "chainId">;
|
|
9
10
|
valueColor?: "green" | "red" | "default";
|
|
10
11
|
}
|
|
11
12
|
export interface CustomSection {
|
|
@@ -24,7 +25,9 @@ export interface SpiceAsset {
|
|
|
24
25
|
balance: string;
|
|
25
26
|
balanceFormatted: number;
|
|
26
27
|
usdValue: number;
|
|
28
|
+
priceStatus?: "fresh" | "stale" | "unavailable";
|
|
27
29
|
logoURI?: string;
|
|
30
|
+
receiptTokenId?: string;
|
|
28
31
|
directWithdraw?: boolean;
|
|
29
32
|
}
|
|
30
33
|
export interface BreakdownLabel {
|
|
@@ -48,7 +51,7 @@ export interface AccountDisplayProps {
|
|
|
48
51
|
dark?: boolean;
|
|
49
52
|
onDepositSuccess?: () => void;
|
|
50
53
|
onDepositClick?: () => void;
|
|
51
|
-
onWithdrawClick?: () => void;
|
|
54
|
+
onWithdrawClick?: (receiptTokenId?: string) => void;
|
|
52
55
|
onCompleteDeposit?: (deposit: VerifiedPendingDeposit) => void;
|
|
53
56
|
showModeToggle?: boolean;
|
|
54
57
|
defaultMode?: "7702" | "non7702";
|
|
@@ -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,
|
|
5
|
+
export declare function estimateUsd(amount: number, price?: number, stale?: boolean): string;
|
|
6
6
|
export declare function buildWithdrawFeeEstimateKey(batches: ChainBatch[], tokenAddress?: string | null): string | null;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ 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";
|
|
9
11
|
export type { ExecutionProgress, ExecutionStep, ExecutionOptions, OnProgress, } from "./useSpiceExecution";
|
|
10
12
|
export { useLockDuration } from "./useLockDuration";
|
|
11
13
|
export type { UseLockDurationReturn } from "./useLockDuration";
|
|
@@ -4,9 +4,15 @@ export interface DirectWithdrawParams {
|
|
|
4
4
|
tokenAddress: Address | string;
|
|
5
5
|
chainId: number;
|
|
6
6
|
balance: bigint;
|
|
7
|
-
recipient: Address | string;
|
|
8
7
|
onProgress?: (progress: ExecutionProgress) => void;
|
|
9
8
|
}
|
|
9
|
+
export interface DirectWithdrawState {
|
|
10
|
+
key: string;
|
|
11
|
+
step: "pending" | "error";
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
10
14
|
export declare function useDirectWithdraw(): {
|
|
11
|
-
withdraw: ({ tokenAddress, chainId, balance,
|
|
15
|
+
withdraw: ({ tokenAddress, chainId, balance, onProgress, }: DirectWithdrawParams) => Promise<string>;
|
|
16
|
+
canWithdraw: boolean;
|
|
17
|
+
state: DirectWithdrawState | null;
|
|
12
18
|
};
|
|
@@ -5,6 +5,7 @@ export interface UseSpiceAssetsConfig {
|
|
|
5
5
|
supportedChains?: number[];
|
|
6
6
|
enabled?: boolean;
|
|
7
7
|
refetchInterval?: number;
|
|
8
|
+
priceEnabled?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export interface UseSpiceAssetsReturn {
|
|
10
11
|
assets: Asset[];
|
|
@@ -14,4 +15,4 @@ export interface UseSpiceAssetsReturn {
|
|
|
14
15
|
refetch: () => Promise<void>;
|
|
15
16
|
getAssetsByChain: (chainId: number) => Asset[];
|
|
16
17
|
}
|
|
17
|
-
export declare const useSpiceAssets: ({ address, supportedChains, enabled, refetchInterval, }: UseSpiceAssetsConfig) => UseSpiceAssetsReturn;
|
|
18
|
+
export declare const useSpiceAssets: ({ address, supportedChains, enabled, refetchInterval, priceEnabled, }: UseSpiceAssetsConfig) => UseSpiceAssetsReturn;
|
|
@@ -8,6 +8,7 @@ export interface UseAssetsConfig {
|
|
|
8
8
|
fetchBalances: (address: Address, supportedChains?: number[]) => Promise<MultiChainBalances>;
|
|
9
9
|
enabled?: boolean;
|
|
10
10
|
refreshInterval?: number;
|
|
11
|
+
priceEnabled?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export interface UseAssetsReturn {
|
|
13
14
|
assets: Asset[];
|
|
@@ -17,4 +18,4 @@ export interface UseAssetsReturn {
|
|
|
17
18
|
getAssetsByChain: (chainId: number) => Asset[];
|
|
18
19
|
getNativeAssets: () => Asset[];
|
|
19
20
|
}
|
|
20
|
-
export declare const useWalletBalances: ({ address, supportedChains, fetchBalances, enabled, refreshInterval, }: UseAssetsConfig) => UseAssetsReturn;
|
|
21
|
+
export declare const useWalletBalances: ({ address, supportedChains, fetchBalances, enabled, refreshInterval, priceEnabled, }: UseAssetsConfig) => UseAssetsReturn;
|