@spicenet-io/spiceflow-ui 3.3.5 → 3.3.7
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/dist/Button-CkSwrat1.js +2 -0
- package/dist/Button-jx5yrM-s.js +2 -0
- package/dist/auth-dynamic.cjs.js +1 -1
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.cjs.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/components/AccountDisplay/AccountCustomSection.d.ts +2 -2
- package/dist/components/AccountDisplay/AccountDisplay.d.ts +1 -1
- package/dist/components/AccountDisplay/AccountHeader.d.ts +1 -1
- package/dist/components/AccountDisplay/AccountIdleBalances.d.ts +2 -2
- package/dist/components/AccountDisplay/AccountPanel.d.ts +2 -2
- package/dist/components/AccountDisplay/AccountPendingDeposits.d.ts +1 -1
- package/dist/components/AccountDisplay/index.d.ts +2 -2
- package/dist/{types/account.d.ts → components/AccountDisplay/types.d.ts} +2 -3
- package/dist/components/SpiceBalance/SpiceBalance.d.ts +1 -1
- package/dist/components/SpiceBalance/index.d.ts +1 -1
- package/dist/{types/balance.d.ts → components/SpiceBalance/types.d.ts} +1 -1
- package/dist/components/SpiceDeposit/executors.d.ts +64 -0
- package/dist/components/SpiceDeposit/feePreview.d.ts +15 -0
- package/dist/components/SpiceDeposit/views/AssetChooserList.d.ts +21 -0
- package/dist/components/SpiceDeposit/views/DepositSubtitle.d.ts +9 -0
- package/dist/components/SpiceLock/LockConfirmationPanel.d.ts +4 -0
- package/dist/components/SpiceLock/LockDurationSlider.d.ts +4 -0
- package/dist/components/SpiceLock/LockExpiryRow.d.ts +4 -0
- package/dist/components/{SpiceLockModal/SpiceLockModal.d.ts → SpiceLock/SpiceLock.d.ts} +1 -1
- package/dist/components/SpiceLock/VotingPowerRow.d.ts +4 -0
- package/dist/components/SpiceLock/executors.d.ts +54 -0
- package/dist/components/SpiceLock/helpers.d.ts +31 -0
- package/dist/components/SpiceLock/index.d.ts +2 -0
- package/dist/components/SpicePay/SpicePay.d.ts +12 -2
- package/dist/components/SpiceSupply/DestinationEstimate.d.ts +1 -1
- package/dist/components/SpiceSupply/buildBatches.d.ts +35 -0
- package/dist/components/SpiceSupply/executors.d.ts +73 -0
- package/dist/components/SpiceSupply/feePreview.d.ts +45 -0
- package/dist/components/SpiceWithdraw/executors.d.ts +50 -0
- package/dist/components/SpiceWithdraw/helpers.d.ts +6 -0
- package/dist/components/SpiceWithdraw/views/BalancePopover.d.ts +15 -0
- package/dist/components/SpiceWithdraw/views/WithdrawDetailsPanel.d.ts +39 -0
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/{useLockDuration/index.d.ts → useLockDuration.d.ts} +1 -1
- package/dist/hooks/{useSpiceAssets/index.d.ts → useSpiceAssets.d.ts} +1 -1
- package/dist/hooks/useSpiceBrand.d.ts +9 -1
- package/dist/hooks/{useGaslessExecution/index.d.ts → useSpiceExecution.d.ts} +2 -2
- package/dist/hooks/{useStatus/index.d.ts → useStatus.d.ts} +1 -1
- package/dist/hooks/{useAssets/index.d.ts → useWalletBalances.d.ts} +1 -1
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +13 -11
- package/dist/index.js +12 -12
- package/dist/{providerWallet-CIbQEcIP.js → providerWallet-6FpyLYqw.js} +1 -1
- package/dist/{providerWallet-CVHyIqiI.js → providerWallet-Ds1PM0vC.js} +1 -1
- package/dist/providers/SpiceFlowProvider.d.ts +2 -0
- package/dist/providers/dynamic.d.ts +3 -0
- package/dist/providers/privy.d.ts +3 -0
- package/dist/types/deposit.d.ts +0 -3
- package/dist/types/index.d.ts +0 -4
- package/dist/types/lock.d.ts +0 -2
- package/dist/types/theme.d.ts +20 -90
- package/dist/types/ui.d.ts +1 -1
- package/dist/types/wallet.d.ts +5 -24
- package/dist/types/withdraw.d.ts +0 -1
- package/dist/utils/addresses.d.ts +1 -0
- package/dist/utils/chains/index.d.ts +7 -0
- package/dist/utils/crossChainRouter/executeSwapThenAction.d.ts +1 -1
- package/dist/utils/errors.d.ts +11 -1
- package/dist/utils/fees.d.ts +18 -1
- package/dist/utils/relayer/index.d.ts +2 -6
- package/package.json +5 -5
- package/dist/Button-BXgazUZN.js +0 -2
- package/dist/Button-d9wfO_xs.js +0 -2
- package/dist/auth-dynamic.d.ts +0 -3
- package/dist/auth-privy.d.ts +0 -3
- package/dist/components/SpiceLockModal/LockSubComponents.d.ts +0 -7
- package/dist/components/SpiceLockModal/index.d.ts +0 -1
- package/dist/errors.d.ts +0 -8
- package/dist/types/pay.d.ts +0 -30
- package/dist/types/rollup.d.ts +0 -50
- package/dist/types/unified.d.ts +0 -85
- package/dist/utils/abis/spicenet.d.ts +0 -115
- package/dist/utils/abis/spicenetWalletManager.d.ts +0 -566
- /package/dist/hooks/{useAssetInput/index.d.ts → useAssetInput.d.ts} +0 -0
- /package/dist/utils/{loadFonts.d.ts → fonts.d.ts} +0 -0
- /package/dist/utils/{resolveTheme.d.ts → theme.d.ts} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const o=require("viem"),c=require("./Button-
|
|
2
|
+
"use strict";const o=require("viem"),c=require("./Button-CkSwrat1.js"),a=e=>{if(!e)return!1;const t=e.connector;if(!t)return!1;if(t.isEmbeddedWallet===!0)return!0;const r=(t.key||t.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(t.name||e.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},s=e=>(e?.connectedWallets||[]).find(t=>a(t))||(a(e?.primaryWallet)?e.primaryWallet:null),u=e=>(e?.connectedWallets||[]).find(t=>t?.address&&t?.connector&&!a(t))||null,l=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getWalletClient=="function"){const r=t===void 0?[void 0]:[String(t),t,void 0];let n=null;for(const d of r)try{const i=await e.getWalletClient(d);if(i)return i}catch(i){n=i}if(n)throw n}if(typeof e.getEthereumProvider=="function"){const r=await e.getEthereumProvider(),n=t?c.getChainConfig(t)?.viemChain:void 0;return o.createWalletClient({account:e.address,chain:n,transport:o.custom(r)})}throw new Error("Wallet client not available")},m=async(e,t)=>{if(!e?.address)throw new Error("Wallet not available");if(typeof e.getEthereumProvider=="function")return e.getEthereumProvider();const r=await l(e,t);return{request:n=>r.request(n)}},f=(e,t)=>({address:e?.address||t.address,chainId:Number(e?.chainId??t.chainId),contractAddress:e?.contractAddress||e?.delegate||t.contractAddress,nonce:BigInt(e?.nonce??t.nonce),r:e?.r,s:e?.s,yParity:(()=>{if(typeof e?.yParity=="number")return e.yParity;const r=Number(e?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});exports.getDynamicEmbeddedWallet=s,exports.getDynamicExternalWallet=u,exports.getProviderEthereumProvider=m,exports.getProviderWalletClient=l,exports.normalizeAuthorization=f;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./Button-
|
|
2
|
+
import{createWalletClient as l,custom as d}from"viem";import{g as c}from"./Button-jx5yrM-s.js";const o=t=>{if(!t)return!1;const e=t.connector;if(!e)return!1;if(e.isEmbeddedWallet===!0)return!0;const r=(e.key||e.connectorKey||"").toLowerCase();if(r.includes("embedded")||r.includes("turnkey"))return!0;const n=(e.name||t.walletName||"").toLowerCase();return!!(n.includes("embedded")||n.includes("turnkey"))},u=t=>(t?.connectedWallets||[]).find(e=>o(e))||(o(t?.primaryWallet)?t.primaryWallet:null),f=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!o(e))||null,i=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getWalletClient=="function"){const r=e===void 0?[void 0]:[String(e),e,void 0];let n=null;for(const s of r)try{const a=await t.getWalletClient(s);if(a)return a}catch(a){n=a}if(n)throw n}if(typeof t.getEthereumProvider=="function"){const r=await t.getEthereumProvider(),n=e?c(e)?.viemChain:void 0;return l({account:t.address,chain:n,transport:d(r)})}throw new Error("Wallet client not available")},m=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const r=await i(t,e);return{request:n=>r.request(n)}},y=(t,e)=>({address:t?.address||e.address,chainId:Number(t?.chainId??e.chainId),contractAddress:t?.contractAddress||t?.delegate||e.contractAddress,nonce:BigInt(t?.nonce??e.nonce),r:t?.r,s:t?.s,yParity:(()=>{if(typeof t?.yParity=="number")return t.yParity;const r=Number(t?.v??27);return Number.isFinite(r)?r>=27?r-27:r:0})()});export{m as a,f as b,i as c,u as g,y as n};
|
|
@@ -9,6 +9,7 @@ export declare const SpiceBrandContext: React.Context<SpiceTheme | null>;
|
|
|
9
9
|
export declare const SpiceFlowProviderContext: React.Context<{
|
|
10
10
|
provider: WalletProvider;
|
|
11
11
|
supportedChainIds: number[];
|
|
12
|
+
allowedTokens?: string[];
|
|
12
13
|
skipFlow: number[];
|
|
13
14
|
mode: SpiceFlowMode;
|
|
14
15
|
setMode: (mode: SpiceFlowMode) => void;
|
|
@@ -24,6 +25,7 @@ export interface SpiceFlowProviderProps {
|
|
|
24
25
|
privyAppId?: string;
|
|
25
26
|
dynamicEnvironmentId?: string;
|
|
26
27
|
supportedChainIds?: number[];
|
|
28
|
+
allowedTokens?: string[];
|
|
27
29
|
network?: SpiceFlowNetwork;
|
|
28
30
|
embeddedWalletConfig?: {
|
|
29
31
|
createOnLogin?: "off" | "users-without-wallets" | "all-users";
|
package/dist/types/deposit.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ export interface DepositModalProps {
|
|
|
48
48
|
assetInputHook?: UseAssetInputReturn;
|
|
49
49
|
externalWalletAddress?: Address;
|
|
50
50
|
embeddedWalletAddress?: Address | string;
|
|
51
|
-
allowedTokens?: string[];
|
|
52
51
|
onDepositAmountChange?: (amount: string) => void;
|
|
53
52
|
allowSecondAsset?: boolean;
|
|
54
53
|
destinationChainId?: number;
|
|
@@ -85,7 +84,6 @@ export interface SpiceDepositProps {
|
|
|
85
84
|
onClose: () => void;
|
|
86
85
|
styles?: CustomStyles;
|
|
87
86
|
depositBatches?: ChainBatch[] | ((context: PostDepositContext) => Promise<ChainBatch[]>) | ((depositAmount: string, depositTokenAddress: string) => Promise<ChainBatch[]>);
|
|
88
|
-
allowedTokens?: string[];
|
|
89
87
|
onDepositAmountChange?: (amount: string) => void;
|
|
90
88
|
destinationChainId?: number;
|
|
91
89
|
destinationTokenAddress?: string;
|
|
@@ -114,7 +112,6 @@ export interface SelectTokenModalProps {
|
|
|
114
112
|
prefetchedAssets?: Asset[] | null;
|
|
115
113
|
styles?: CustomStyles;
|
|
116
114
|
dark?: boolean;
|
|
117
|
-
allowedTokens?: string[];
|
|
118
115
|
}
|
|
119
116
|
export interface DepositConfirmationData {
|
|
120
117
|
network: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,8 +5,4 @@ export * from "./theme";
|
|
|
5
5
|
export * from "./status";
|
|
6
6
|
export type { Authorization, ChainBatch, IntentAuthorization, } from "./authorization";
|
|
7
7
|
export * from "./wallet";
|
|
8
|
-
export * from "./balance";
|
|
9
|
-
export * from "./unified";
|
|
10
|
-
export * from "./rollup";
|
|
11
8
|
export * from "./ui";
|
|
12
|
-
export * from "./pay";
|
package/dist/types/lock.d.ts
CHANGED
|
@@ -36,8 +36,6 @@ export interface SpiceLockModalProps {
|
|
|
36
36
|
lockChainId: number;
|
|
37
37
|
durationOptions: LockDurationOption[];
|
|
38
38
|
votingPowerEstimate?: (amount: number, months: number) => number;
|
|
39
|
-
sourceChains: number[];
|
|
40
|
-
sourceAssets?: Address[];
|
|
41
39
|
escrowAddress?: Address;
|
|
42
40
|
onLockSuccess?: (txHash?: string) => void;
|
|
43
41
|
onLockExecute?: (ctx: LockExecuteContext) => Promise<string | void>;
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export type ThemeMode = "light" | "dark";
|
|
3
|
+
export interface TextStyle {
|
|
4
|
+
color?: string;
|
|
5
|
+
fontSize?: string;
|
|
6
|
+
fontWeight?: string | number;
|
|
7
|
+
fontFamily?: string;
|
|
8
|
+
}
|
|
3
9
|
export interface SpiceTheme {
|
|
4
10
|
primaryColor: string;
|
|
5
11
|
dark?: boolean;
|
|
@@ -72,37 +78,13 @@ export interface AssetSelectorTheme {
|
|
|
72
78
|
borderColor?: string;
|
|
73
79
|
borderRadius?: string;
|
|
74
80
|
padding?: string;
|
|
75
|
-
label?:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
assetName?: {
|
|
82
|
-
color?: string;
|
|
83
|
-
fontSize?: string;
|
|
84
|
-
fontWeight?: string | number;
|
|
85
|
-
fontFamily?: string;
|
|
86
|
-
};
|
|
87
|
-
assetSymbol?: {
|
|
88
|
-
color?: string;
|
|
89
|
-
fontSize?: string;
|
|
90
|
-
fontWeight?: string | number;
|
|
91
|
-
fontFamily?: string;
|
|
92
|
-
};
|
|
93
|
-
balance?: {
|
|
94
|
-
color?: string;
|
|
95
|
-
fontSize?: string;
|
|
96
|
-
fontWeight?: string | number;
|
|
97
|
-
fontFamily?: string;
|
|
98
|
-
};
|
|
99
|
-
amountInput?: {
|
|
81
|
+
label?: TextStyle;
|
|
82
|
+
assetName?: TextStyle;
|
|
83
|
+
assetSymbol?: TextStyle;
|
|
84
|
+
balance?: TextStyle;
|
|
85
|
+
amountInput?: TextStyle & {
|
|
100
86
|
backgroundColor?: string;
|
|
101
87
|
borderColor?: string;
|
|
102
|
-
color?: string;
|
|
103
|
-
fontSize?: string;
|
|
104
|
-
fontWeight?: string | number;
|
|
105
|
-
fontFamily?: string;
|
|
106
88
|
borderRadius?: string;
|
|
107
89
|
};
|
|
108
90
|
}
|
|
@@ -115,24 +97,9 @@ export interface TokenDropdownTheme {
|
|
|
115
97
|
hoverBackgroundColor?: string;
|
|
116
98
|
borderColor?: string;
|
|
117
99
|
padding?: string;
|
|
118
|
-
tokenName?:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
fontWeight?: string | number;
|
|
122
|
-
fontFamily?: string;
|
|
123
|
-
};
|
|
124
|
-
tokenSymbol?: {
|
|
125
|
-
color?: string;
|
|
126
|
-
fontSize?: string;
|
|
127
|
-
fontWeight?: string | number;
|
|
128
|
-
fontFamily?: string;
|
|
129
|
-
};
|
|
130
|
-
tokenBalance?: {
|
|
131
|
-
color?: string;
|
|
132
|
-
fontSize?: string;
|
|
133
|
-
fontWeight?: string | number;
|
|
134
|
-
fontFamily?: string;
|
|
135
|
-
};
|
|
100
|
+
tokenName?: TextStyle;
|
|
101
|
+
tokenSymbol?: TextStyle;
|
|
102
|
+
tokenBalance?: TextStyle;
|
|
136
103
|
};
|
|
137
104
|
}
|
|
138
105
|
export interface StatusDisplayTheme {
|
|
@@ -140,12 +107,7 @@ export interface StatusDisplayTheme {
|
|
|
140
107
|
borderColor?: string;
|
|
141
108
|
borderRadius?: string;
|
|
142
109
|
padding?: string;
|
|
143
|
-
text?:
|
|
144
|
-
color?: string;
|
|
145
|
-
fontSize?: string;
|
|
146
|
-
fontWeight?: string | number;
|
|
147
|
-
fontFamily?: string;
|
|
148
|
-
};
|
|
110
|
+
text?: TextStyle;
|
|
149
111
|
successColor?: string;
|
|
150
112
|
warningColor?: string;
|
|
151
113
|
errorColor?: string;
|
|
@@ -202,34 +164,21 @@ export interface CustomStyles {
|
|
|
202
164
|
borderColor?: string;
|
|
203
165
|
borderRadius?: string;
|
|
204
166
|
padding?: string;
|
|
205
|
-
label?:
|
|
206
|
-
|
|
207
|
-
fontSize?: string;
|
|
208
|
-
fontWeight?: string | number;
|
|
209
|
-
fontFamily?: string;
|
|
210
|
-
};
|
|
211
|
-
presetButton?: {
|
|
167
|
+
label?: TextStyle;
|
|
168
|
+
presetButton?: TextStyle & {
|
|
212
169
|
backgroundColor?: string;
|
|
213
170
|
hoverBackgroundColor?: string;
|
|
214
171
|
activeBackgroundColor?: string;
|
|
215
|
-
color?: string;
|
|
216
172
|
activeColor?: string;
|
|
217
173
|
borderColor?: string;
|
|
218
174
|
activeBorderColor?: string;
|
|
219
175
|
borderRadius?: string;
|
|
220
|
-
fontSize?: string;
|
|
221
|
-
fontWeight?: string | number;
|
|
222
|
-
fontFamily?: string;
|
|
223
176
|
padding?: string;
|
|
224
177
|
};
|
|
225
|
-
customInput?: {
|
|
178
|
+
customInput?: TextStyle & {
|
|
226
179
|
backgroundColor?: string;
|
|
227
180
|
borderColor?: string;
|
|
228
181
|
focusBorderColor?: string;
|
|
229
|
-
color?: string;
|
|
230
|
-
fontSize?: string;
|
|
231
|
-
fontWeight?: string | number;
|
|
232
|
-
fontFamily?: string;
|
|
233
182
|
borderRadius?: string;
|
|
234
183
|
padding?: string;
|
|
235
184
|
};
|
|
@@ -242,18 +191,8 @@ export interface CustomStyles {
|
|
|
242
191
|
borderColor?: string;
|
|
243
192
|
borderRadius?: string;
|
|
244
193
|
padding?: string;
|
|
245
|
-
title?:
|
|
246
|
-
|
|
247
|
-
fontSize?: string;
|
|
248
|
-
fontWeight?: string | number;
|
|
249
|
-
fontFamily?: string;
|
|
250
|
-
};
|
|
251
|
-
description?: {
|
|
252
|
-
color?: string;
|
|
253
|
-
fontSize?: string;
|
|
254
|
-
fontWeight?: string | number;
|
|
255
|
-
fontFamily?: string;
|
|
256
|
-
};
|
|
194
|
+
title?: TextStyle;
|
|
195
|
+
description?: TextStyle;
|
|
257
196
|
};
|
|
258
197
|
inputVariant?: "light" | "dark";
|
|
259
198
|
}
|
|
@@ -319,12 +258,3 @@ export interface Theme {
|
|
|
319
258
|
slow: string;
|
|
320
259
|
};
|
|
321
260
|
}
|
|
322
|
-
export type SpiceBrand = SpiceTheme;
|
|
323
|
-
export type DarkPalette = CustomStyles;
|
|
324
|
-
export type PaletteOverrides = CustomStyles;
|
|
325
|
-
export type SpiceDepositStyles = Partial<SpiceTheme>;
|
|
326
|
-
export type SpiceWithdrawStyles = Partial<SpiceTheme>;
|
|
327
|
-
export type SpiceLockModalStyles = Partial<SpiceTheme>;
|
|
328
|
-
export type SpiceSupplyStyles = Partial<SpiceTheme>;
|
|
329
|
-
export type SpiceBalanceStyles = Partial<SpiceTheme>;
|
|
330
|
-
export type AccountDisplayStyles = Partial<SpiceTheme>;
|
package/dist/types/ui.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type { Theme, CustomStyles } from "./theme";
|
|
3
|
-
import type { ResolvedDarkPalette } from "../utils/
|
|
3
|
+
import type { ResolvedDarkPalette } from "../utils/theme";
|
|
4
4
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
5
|
variant?: "primary" | "secondary" | "success" | "error" | "ghost" | "outline";
|
|
6
6
|
size?: "sm" | "md" | "lg";
|
package/dist/types/wallet.d.ts
CHANGED
|
@@ -39,30 +39,7 @@ export interface WalletProviderProps {
|
|
|
39
39
|
defaultChain?: any;
|
|
40
40
|
supportedChains?: any[];
|
|
41
41
|
}
|
|
42
|
-
export interface
|
|
43
|
-
onAuthSuccess?: (address: string) => void;
|
|
44
|
-
onAuthError?: (error: string) => void;
|
|
45
|
-
theme?: "light" | "dark";
|
|
46
|
-
className?: string;
|
|
47
|
-
buttonText?: string;
|
|
48
|
-
}
|
|
49
|
-
export interface ProviderLoginProps {
|
|
50
|
-
onAuthSuccess?: (address: string) => void;
|
|
51
|
-
onAuthError?: (error: string) => void;
|
|
52
|
-
theme?: "light" | "dark";
|
|
53
|
-
className?: string;
|
|
54
|
-
buttonText?: string;
|
|
55
|
-
autoTrigger?: boolean;
|
|
56
|
-
}
|
|
57
|
-
export interface PrivyLoginProps {
|
|
58
|
-
onAuthSuccess?: (address: string) => void;
|
|
59
|
-
onAuthError?: (error: string) => void;
|
|
60
|
-
theme?: "light" | "dark";
|
|
61
|
-
className?: string;
|
|
62
|
-
buttonText?: string;
|
|
63
|
-
autoTrigger?: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface DynamicLoginProps {
|
|
42
|
+
export interface LoginProps {
|
|
66
43
|
onAuthSuccess?: (address: string) => void;
|
|
67
44
|
onAuthError?: (error: string) => void;
|
|
68
45
|
theme?: "light" | "dark";
|
|
@@ -70,6 +47,10 @@ export interface DynamicLoginProps {
|
|
|
70
47
|
buttonText?: string;
|
|
71
48
|
autoTrigger?: boolean;
|
|
72
49
|
}
|
|
50
|
+
export type WalletLoginProps = LoginProps;
|
|
51
|
+
export type ProviderLoginProps = LoginProps;
|
|
52
|
+
export type PrivyLoginProps = LoginProps;
|
|
53
|
+
export type DynamicLoginProps = LoginProps;
|
|
73
54
|
export interface ExportWalletButtonProps {
|
|
74
55
|
label?: string;
|
|
75
56
|
style?: React.CSSProperties;
|
package/dist/types/withdraw.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export interface SpiceWithdrawProps {
|
|
|
21
21
|
}) => void;
|
|
22
22
|
onWithdrawError?: (error: string) => void;
|
|
23
23
|
autoCloseDelay?: number;
|
|
24
|
-
supportedChains?: number[];
|
|
25
24
|
availableTokens?: Record<number, DestinationToken[]>;
|
|
26
25
|
buildSpicenetBatch?: (params: {
|
|
27
26
|
destinationChainId: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addressesEqual(a?: string | null, b?: string | null): boolean;
|
|
@@ -13,6 +13,13 @@ export declare const getDelegateContractAddress: (chainId: number) => string;
|
|
|
13
13
|
export declare const getExplorerUrl: (chainId: number, transactionHash: string, customExplorerUrls?: {
|
|
14
14
|
[chainId: number]: string;
|
|
15
15
|
}) => string;
|
|
16
|
+
type EthereumProvider = {
|
|
17
|
+
request: (args: {
|
|
18
|
+
method: string;
|
|
19
|
+
params?: unknown;
|
|
20
|
+
}) => Promise<unknown>;
|
|
21
|
+
};
|
|
22
|
+
export declare function ensureWalletOnChain(provider: EthereumProvider, chainId: number): Promise<void>;
|
|
16
23
|
export declare const getClientForChain: (chainId: number) => PublicClient;
|
|
17
24
|
export declare const getChainsForAssets: () => {
|
|
18
25
|
[key: number]: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Call, ChainBatch } from "../../types/authorization";
|
|
2
|
-
import type { GaslessExecutionOptions, OnProgress } from "../../hooks/
|
|
2
|
+
import type { GaslessExecutionOptions, OnProgress } from "../../hooks/useSpiceExecution";
|
|
3
3
|
export type ExecuteGaslessFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, onProgress?: OnProgress, signal?: AbortSignal, options?: GaslessExecutionOptions) => Promise<string>;
|
|
4
4
|
export interface SwapThenActionParams {
|
|
5
5
|
chainId: number;
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { type CreateActionRequest } from "@spicenet-io/spiceflow-core";
|
|
2
|
+
export type SpiceflowErrorCode = "WALLET_DISCONNECTED" | "WALLET_REJECTED" | "SIGNATURE_FAILED" | "CONCURRENT_EXECUTION" | "ABORT" | "NO_VENUE_FOR_CHAIN" | "NO_LIQUIDITY" | "VENUE_API_ERROR" | "NO_SWAP_ROUTE" | "ROUTE_TOKEN_NOT_FOUND" | "ROUTE_UNSUPPORTED_INPUT" | "ROUTE_STRATEGY_ERROR" | "INVALID_PARAMS" | "INVALID_TOKEN_TRANSFER" | "RELAYER_ERROR" | "RELAYER_EXECUTE_ERROR" | "RELAYER_STATUS_ERROR" | "ON_CHAIN_REVERT" | "POLLING_EXHAUSTED" | "POLLING_CONSECUTIVE_FAILURES" | "ALL_ATTEMPTS_FAILED";
|
|
3
|
+
export declare class SpiceflowError extends Error {
|
|
4
|
+
readonly code: SpiceflowErrorCode;
|
|
5
|
+
readonly context: Record<string, unknown>;
|
|
6
|
+
readonly name = "SpiceflowError";
|
|
7
|
+
constructor(code: SpiceflowErrorCode, message: string, context?: Record<string, unknown>);
|
|
8
|
+
}
|
|
9
|
+
export declare function isSpiceflowError(err: unknown): err is SpiceflowError;
|
|
2
10
|
export declare const isUserRejection: (error: unknown) => boolean;
|
|
11
|
+
export declare const sanitizeError: (error: unknown, fallback?: string) => string;
|
|
12
|
+
export declare function formatFeeEstimateError(request: CreateActionRequest, message: string): string;
|
package/dist/utils/fees.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { FeeEstimateBatch, FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
|
|
3
|
+
import type { FeePreview } from "../types/ui";
|
|
2
4
|
export declare function getBatchFees(batch: FeeEstimateBatch): {
|
|
3
5
|
spicenetFee: bigint;
|
|
4
6
|
gasFee: bigint;
|
|
@@ -7,3 +9,18 @@ export declare function getBatchFees(batch: FeeEstimateBatch): {
|
|
|
7
9
|
};
|
|
8
10
|
export declare function hasFeeValue(batch: FeeEstimateBatch): boolean;
|
|
9
11
|
export declare function getBatchGrossDebit(batch: FeeEstimateBatch): bigint;
|
|
12
|
+
export declare function getSingleNetOutput(feeEstimate: FeeEstimateSummary): bigint | null;
|
|
13
|
+
export declare function getLockFeePreview(feeEstimate: FeeEstimateSummary, fallback: {
|
|
14
|
+
symbol: string;
|
|
15
|
+
decimals: number;
|
|
16
|
+
}): FeePreview | null;
|
|
17
|
+
export type SupplyFeePreview = FeePreview & {
|
|
18
|
+
chainId: number;
|
|
19
|
+
tokenAddress: Address;
|
|
20
|
+
};
|
|
21
|
+
export declare function getSupplyFeePreview(feeEstimate: FeeEstimateSummary, fallback: {
|
|
22
|
+
chainId: number;
|
|
23
|
+
tokenAddress: Address;
|
|
24
|
+
symbol: string;
|
|
25
|
+
decimals: number;
|
|
26
|
+
}): SupplyFeePreview | null;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { CreateActionRequest, CreateActionResponse,
|
|
1
|
+
import type { CreateActionRequest, CreateActionResponse, ExecuteStepRequest, FeeEstimateSummary, CreateWalletRequest, WalletInfo, CreateWithdrawalRequest, CreateWithdrawalResponse, WithdrawalStatus, RollupTimestamp } from "@spicenet-io/spiceflow-core";
|
|
2
2
|
import { SwapStep } from "../../types/status";
|
|
3
3
|
import { ChainBatch } from "../../types/authorization";
|
|
4
|
-
import { CreateWalletRequest, WalletInfo, CreateWithdrawalRequest, CreateWithdrawalResponse, WithdrawalStatus, RollupTimestamp } from "../../types/rollup";
|
|
5
4
|
export declare const RELAYER_API_URL: string;
|
|
6
|
-
export declare function hasReducedFeeOutput(feeEstimate: FeeEstimateSummary): boolean;
|
|
7
5
|
export declare class RelayerService {
|
|
8
6
|
private baseUrl;
|
|
9
|
-
constructor();
|
|
10
7
|
setBaseUrl(url: string): void;
|
|
11
8
|
getBaseUrl(): string;
|
|
12
|
-
private getEffectiveBaseUrl;
|
|
13
9
|
createAction(request: CreateActionRequest): Promise<CreateActionResponse>;
|
|
14
|
-
estimateActionFees(request: CreateActionRequest): Promise<
|
|
10
|
+
estimateActionFees(request: CreateActionRequest): Promise<FeeEstimateSummary>;
|
|
15
11
|
estimateBatchGas(request: {
|
|
16
12
|
user: string;
|
|
17
13
|
outputToken: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spicenet-io/spiceflow-ui",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"description": "Spiceflow UI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.3.13",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"require": "./dist/index.cjs.js"
|
|
15
15
|
},
|
|
16
16
|
"./auth/privy": {
|
|
17
|
-
"types": "./dist/
|
|
17
|
+
"types": "./dist/providers/privy.d.ts",
|
|
18
18
|
"import": "./dist/auth-privy.js",
|
|
19
19
|
"require": "./dist/auth-privy.cjs.js"
|
|
20
20
|
},
|
|
21
21
|
"./auth/dynamic": {
|
|
22
|
-
"types": "./dist/
|
|
22
|
+
"types": "./dist/providers/dynamic.d.ts",
|
|
23
23
|
"import": "./dist/auth-dynamic.js",
|
|
24
24
|
"require": "./dist/auth-dynamic.cjs.js"
|
|
25
25
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dev": "rollup -c rollup.config.mjs --watch",
|
|
43
43
|
"dev:link": "bun run build && bun link && echo 'SDK linked globally. Run: bun link @spicenet-io/spiceflow-ui in your project'",
|
|
44
44
|
"clean": "rm -rf dist",
|
|
45
|
-
"prepublishOnly": "
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"react",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"author": "",
|
|
59
59
|
"license": "MIT",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@spicenet-io/spiceflow-core": "0.3.
|
|
61
|
+
"@spicenet-io/spiceflow-core": "^0.3.11",
|
|
62
62
|
"lucide-react": "0.562.0",
|
|
63
63
|
"tslib": "2.8.1"
|
|
64
64
|
},
|
package/dist/Button-BXgazUZN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{jsx as v,jsxs as le}from"react/jsx-runtime";import{createContext as j,useEffect as N,useState as O,useCallback as ue,useContext as fe,useMemo as pe,useRef as me}from"react";import{getChainMeta as D,getTokensForChain as ge,getDelegateContract as he,ZERO_ADDRESS as ye,isNativeToken as _,getTokenByAddress as be,getChainIdsByNetwork as we}from"@spicenet-io/spiceflow-core";import{defineChain as xe,createPublicClient as Be,http as Ee,isAddress as $e,getAddress as Se,formatUnits as J}from"viem";import{readContract as ve}from"viem/actions";class u extends Error{constructor(e,a,t={}){super(a),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,u)}}function Re(r){return r instanceof u}const W=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Ce="0xcA11bde05977b3631167028862bE2a173976CA11",Te={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},ke=new Set([5115]);function Ie(r){const e=Te[r.id]??(ke.has(r.id)?void 0:Ce);return xe({id:r.id,name:r.name,nativeCurrency:r.nativeCurrency,rpcUrls:{default:{http:[r.rpcUrl]}},blockExplorers:{default:{name:r.displayName,url:r.blockExplorer}},testnet:r.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const Ue=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],R=Object.fromEntries(Ue.map(r=>D(r)).filter(r=>r!=null).map(r=>[r.id,{...r,viemChain:Ie(r),supportedTokens:ge(r.id)}])),Ne=R;let z={};const A=new Map,Y=r=>{z={...r||{}},A.clear()},M=r=>{const e=z[r];return e&&typeof e=="string"&&e.length>0?e:R[r]?.rpcUrl},$=r=>R[r],C=r=>{const e=D(r);return e?.displayName||e?.name||`Chain ${r}`},Oe=r=>{const e=he(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);return e},_e=(r,e,a)=>{const t=$(r);return t?.blockExplorer?`${t.blockExplorer}/tx/${e}`:"#"},H=r=>{const e=$(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);const a=M(r);if(!a)throw new Error(`No RPC URL configured for chain ID: ${r}`);const t=`${r}:${a}`,o=A.get(t);if(o)return o;const s=Be({chain:e.viemChain,transport:Ee(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return A.set(t,s),s},Ae=()=>{const r={};return Object.values(R).forEach(e=>{r[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:M(e.id)||e.rpcUrl}}),r},Me=(r,e=[])=>{const a=$(r);if(!a)return[];const t=[];if(![11155111,421614,84532,688689].includes(r)){const s=e.find(n=>n.chainId===r&&n.isNative);s?t.push(s):t.push({address:ye,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:r})}if(!a.supportedTokens)return t;const o=t.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(o&&_(s.address))return;const n=e.find(l=>l.chainId===r&&l.address.toLowerCase()===s.address.toLowerCase());n?t.push(n):t.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:r})}),t},Fe=async(r,e)=>{const a=$(r);if(!a)throw new Error(`Unsupported chain ID: ${r}`);const t=e.toLowerCase();if(_(t)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${r}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const o=a.supportedTokens.find(s=>s.address.toLowerCase()===t);if(o)return o.decimals}try{if(!$e(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const o=Se(e),s=H(r),n=await ve(s,{address:o,abi:W,functionName:"decimals"});return Number(n)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${r}`)}},G=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",X="__SPICEFLOW_RELAYER_API_URL__";function Pe(r,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,t,o,s]=a,n=Number(s),l=BigInt(t),c=BigInt(o);let d;for(const f of r.intents){const w=f.chainBatches.find(S=>S.chainId===n);if(w){d=w;break}}const m=d?.tokenTransfers.find(f=>f.from==="escrow"&&f.to.toLowerCase()===r.user.toLowerCase()&&!_(f.token));if(!m)return`Amount is too small to cover the estimated fee on ${C(n)}.`;const p=be(m.token,n),y=p?.decimals??18,b=p?.symbol??"tokens",x=J(l,y),i=J(c,y);return`Amount is too small to cover the estimated fee on ${C(n)}. Amount: ${x} ${b}. Estimated fee: ${i} ${b}.`}function Le(r){return!1}function je(){if(typeof globalThis>"u")return;const r=globalThis[X];return typeof r=="string"&&r.length>0?r:void 0}class De{constructor(){this.baseUrl=G}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[X]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return je()||this.baseUrl}async createAction(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Relayer API error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions"});return t}async estimateActionFees(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.feeEstimate){const o=t.error?.message||`Relayer fee estimate error: ${a.status}`,s=Pe(e,o);throw new u("RELAYER_ERROR",s,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/fees/estimate"})}return t.data.feeEstimate}async estimateBatchGas(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.gasFee){const o=t.error?.message||`Relayer gas estimate error: ${a.status}`;throw new u("RELAYER_ERROR",o,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(t.data.gasFee),gasQuoteSource:t.data.gasQuoteSource}}async executeStep(e,a,t,o){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${a}/steps/${t}`,n=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});let l;try{l=await Promise.race([n,new Promise((d,m)=>setTimeout(()=>m(new u("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:a,stepIndex:t,endpoint:`/actions/${e}/intents/${a}/steps/${t}`})),1e4))])}catch(d){throw d}const c=await l.json();if(!l.ok||c.success===!1)throw new u("RELAYER_EXECUTE_ERROR",c.error?.message||`Execute step error: ${l.status}`,{httpStatus:l.status,responseBody:JSON.stringify(c),endpoint:`/actions/${e}/intents/${a}/steps/${t}`,actionId:e});if(c?.status==="error"||c?.status==="reverted")throw new u("RELAYER_EXECUTE_ERROR",`Step ${t} previously ${c.status}${c?.error?`: ${c.error}`:""}`,{httpStatus:l.status,responseBody:JSON.stringify(c),endpoint:`/actions/${e}/intents/${a}/steps/${t}`,actionId:e,intentIndex:a,stepIndex:t,stepStatus:c.status});return{success:!0,transactionHash:c.transactionHash}}async checkStepStatus(e,a){const t=e.split("/");let o="";if(t.length>=2){const l=t[0],c=t[1];o=`${this.getEffectiveBaseUrl()}/actions/${l}/intents/${c}/steps/${a}`}else o=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${a}`;const s=await fetch(o),n=await s.json();if(!s.ok||n.success===!1)throw new u("RELAYER_STATUS_ERROR",n.error?.message||`Intent step status check failed: ${s.status}`,{httpStatus:s.status,responseBody:JSON.stringify(n),endpoint:o,intentId:e});return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async createWallet(e,a){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),o=await t.json();if(!t.ok||o.success===!1)throw new u("RELAYER_ERROR",o.error?.message||`Create wallet error: ${t.status}`,{httpStatus:t.status,responseBody:JSON.stringify(o),endpoint:`/wallets/${e}`});return o}async getWallet(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Get wallet error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/wallets/${e}`});return t}async createWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Create withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/withdrawals"});return t}async getWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Get withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/withdrawals/${e}`});return t}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`),a=await e.json();if(!e.ok||a.success===!1)throw new u("RELAYER_ERROR",a.error?.message||`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,responseBody:JSON.stringify(a),endpoint:"/time"});return a}}const h=new De,F=new Map;async function Je(r,e){const a=r.toLowerCase(),t=F.get(a);if(t)return t;const o=(async()=>{try{await h.getWallet(r);return}catch{}const{unix_timestamp:s}=await h.getRollupTimestamp(),n=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${r.slice(2).toLowerCase()}. Nonce: ${s}`,l=await e(n),c=typeof l=="string"?l:l.signature;if(!c)throw new Error("Wallet returned no smart wallet signature");await h.createWallet(r,{timestamp:s,signature:c})})();F.set(a,o);try{await o}finally{F.delete(a)}}const We=(r,e)=>{const a=o=>e?e(o):C(o),t=[];return r.forEach((o,s)=>{const n=o.calls&&o.calls.length>0,l=o.tokenTransfers&&o.tokenTransfers.length>0;if(n||l){const c={stepId:s,status:s===0?"processing":"pending",chainId:o.chainId,chainName:a(o.chainId),description:"Processing transaction"};t.push(c)}}),t},q="spiceflow-mode",Q=()=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(q);return r==="embedded"?"7702":r==="external"?"ondemand":null}catch{return null}},ze=r=>{if(!(typeof window>"u"))try{window.localStorage.setItem(q,r==="7702"?"embedded":"external")}catch{}},Ye=()=>Q()!==null,Z=j(null),K=j(null),He=({children:r,provider:e,supportedChainIds:a,network:t="testnet",mode:o="7702",skipFlow:s=[],nativeChainId:n,appName:l="Spicenet",apiUrl:c,theme:d,rpcOverrides:m})=>{N(()=>{if(!c)return;const f=h.getBaseUrl();return h.setBaseUrl(c),()=>h.setBaseUrl(f)},[c]),N(()=>(Y(m),()=>Y(void 0)),[m]);const p=a??we(t),y=d??null,[b,x]=O(()=>Q()??o),i=ue(f=>{x(f),ze(f)},[]);return v(Z.Provider,{value:y,children:v(K.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:s,mode:b,setMode:i,network:t,nativeChainId:n,appName:l,apiUrl:c,rpcOverrides:m},children:r})})},Ge={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},Xe={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},qe={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},V=(r="light")=>({mode:r,...Ge,colors:r==="light"?Xe:qe});function T(r,e){const a=r.replace("#",""),t=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),o=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Qe(r,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??T(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??T(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function Ze(r){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function ee(r,e){const a=e?{...r,...e}:r,t=a.dark??!1,o=a.primaryColor,s=a.shell??(t?"#141414":"#ffffff");return{primaryColor:o,dark:t,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:s,shellBorder:T(s,t?.35:.085),shellInnerBorder:T(s,t?.55:.165),card:a.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:a.text??(t?"#ffffff":"#111827"),textMuted:a.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:a.border??(t?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:t?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:t?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:t?"#0a1f18":"#d1fae5",successBorder:t?"#1a4a3a":"#6ee7b7",successText:t?"#6ee7b7":"#065f46",warningBg:t?"#1f1a0d":"#fef3c7",warningBorder:t?"#4a3820":"#fde68a",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fef2f2",errorBorder:t?"#4a2020":"#fecaca",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function te(r,e){const a=fe(Z)??void 0;return pe(()=>{const t=a??{primaryColor:"#EA4B4B"},o={...r?.primaryColor?{primaryColor:r.primaryColor}:{},...r?.fontFamily?{fontFamily:r.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=ee(t,o),{dark:n,primaryColor:l,appName:c}=s,d=V(n?"dark":"light"),m={...d,colors:{...d.colors,primary:l,primaryHover:`${l}dd`},typography:{...d.typography,fontFamily:s.fontFamily}},p={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:a,theme:m,dark:n,appName:c,primaryColor:l,dk:p,palette:p}},[a,r,e])}const re="spiceflow-spinner-keyframes";function Ke(){if(typeof document>"u"||document.getElementById(re))return;const r=document.createElement("style");r.id=re,r.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(r)}const ae=({size:r=16,borderWidth:e=2,color:a="currentColor",style:t})=>{const o=me(!1);return N(()=>{o.current||(Ke(),o.current=!0)},[]),v("div",{role:"status","aria-label":"Loading",style:{width:`${r}px`,height:`${r}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...t}})},Ve=({variant:r="primary",size:e="md",loading:a=!1,fullWidth:t=!1,disabled:o,children:s,className:n="",style:l,theme:c,styles:d,dark:m,...p})=>{const{theme:y,dark:b,palette:x}=te(d,m),i=c||y,f=m??b,[w,S]=O(!1),[k,I]=O(!1),U=f?x.shell:"white",se=()=>{switch(r){case"primary":return{backgroundColor:d?.button?.backgroundColor||i.colors.primary,color:d?.button?.color||"#ffffff",border:`1px solid ${d?.button?.backgroundColor||i.colors.primary}`};case"secondary":return{backgroundColor:i.colors.secondary,color:i.colors.text,border:`1px solid ${i.colors.border}`};case"success":return{backgroundColor:i.colors.success,color:i.colors.text,border:`1px solid ${i.colors.success}`};case"error":return{backgroundColor:i.colors.error,color:i.colors.text,border:`1px solid ${i.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:i.colors.textSecondary,border:`1px solid ${i.colors.border}`};case"outline":{const g=d?.button?.backgroundColor||i.colors.primary,L=d?.button?.color||(f?"#ffffff":"#0e0d0b"),B=d?.button?.borderColor||(f?`${i.colors.primary}88`:"#0e0d0b"),E=o||a,ie=f?"1px":"1.5px",ce=d?.button?.disabledBackgroundColor||`${g}88`,de=d?.button?.disabledColor||L;return{height:"56px",backgroundColor:E?ce:k?`${g}cc`:w?`${g}ee`:g,color:E?de:L,border:`${ie} solid ${B}`,borderRadius:d?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:E?.78:1,transform:E?"none":k?"scale(0.98)":w?"translateY(-2px)":"none",boxShadow:E?`3px 3px 0px ${U}, 4px 4px 0px ${B}`:k?`2px 2px 0px ${B}`:w?`5px 5px 0px ${U}, 6px 6px 0px ${B}`:`3px 3px 0px ${U}, 4px 4px 0px ${B}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},oe=()=>{if(r==="outline")return{};switch(e){case"sm":return{padding:`${i.spacing.sm} ${i.spacing.md}`,fontSize:i.typography.fontSize.sm};case"md":return{padding:`${i.spacing.md} ${i.spacing.lg}`,fontSize:i.typography.fontSize.base};case"lg":return{padding:`${i.spacing.lg} ${i.spacing.xl}`,fontSize:i.typography.fontSize.lg};default:return{}}},ne={borderRadius:d?.button?.borderRadius||i.borderRadius.md,fontWeight:d?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:d?.button?.fontFamily||i.typography.fontFamily,fontSize:d?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:o||a?"not-allowed":"pointer",opacity:(o||a)&&r!=="outline"?.6:1,width:t?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...se(),...oe(),...d?.button?.fontSize&&{fontSize:d.button.fontSize}},P=o||a;return le("button",{type:p.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":P||void 0,style:{...ne,...l},className:n,disabled:P,onMouseEnter:g=>{S(!0),p.onMouseEnter?.(g)},onMouseLeave:g=>{S(!1),I(!1),p.onMouseLeave?.(g)},onMouseDown:g=>{I(!0),p.onMouseDown?.(g)},onMouseUp:g=>{I(!1),p.onMouseUp?.(g)},...p,children:[a&&v(ae,{size:16}),s]})};export{Ve as B,Ne as C,W as G,G as R,ae as S,Ae as a,H as b,V as c,K as d,Je as e,C as f,$ as g,_e as h,Re as i,Me as j,M as k,Oe as l,Fe as m,We as n,u as o,Le as p,Ye as q,h as r,He as s,ee as t,te as u,Qe as v,Ze as w};
|
package/dist/Button-d9wfO_xs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";const v=require("react/jsx-runtime"),h=require("react"),y=require("@spicenet-io/spiceflow-core"),b=require("viem"),ie=require("viem/actions");class u extends Error{constructor(e,a,t={}){super(a),this.code=e,this.context=t,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,u)}}function ce(r){return r instanceof u}const j=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],le="0xcA11bde05977b3631167028862bE2a173976CA11",de={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},ue=new Set([5115]);function fe(r){const e=de[r.id]??(ue.has(r.id)?void 0:le);return b.defineChain({id:r.id,name:r.name,nativeCurrency:r.nativeCurrency,rpcUrls:{default:{http:[r.rpcUrl]}},blockExplorers:{default:{name:r.displayName,url:r.blockExplorer}},testnet:r.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const pe=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],k=Object.fromEntries(pe.map(r=>y.getChainMeta(r)).filter(r=>r!=null).map(r=>[r.id,{...r,viemChain:fe(r),supportedTokens:y.getTokensForChain(r.id)}])),me=k;let D={};const _=new Map,W=r=>{D={...r||{}},_.clear()},F=r=>{const e=D[r];return e&&typeof e=="string"&&e.length>0?e:k[r]?.rpcUrl},R=r=>k[r],I=r=>{const e=y.getChainMeta(r);return e?.displayName||e?.name||`Chain ${r}`},ge=r=>{const e=y.getDelegateContract(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);return e},he=(r,e,a)=>{const t=R(r);return t?.blockExplorer?`${t.blockExplorer}/tx/${e}`:"#"},Y=r=>{const e=R(r);if(!e)throw new Error(`Unsupported chain ID: ${r}`);const a=F(r);if(!a)throw new Error(`No RPC URL configured for chain ID: ${r}`);const t=`${r}:${a}`,o=_.get(t);if(o)return o;const s=b.createPublicClient({chain:e.viemChain,transport:b.http(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return _.set(t,s),s},ye=()=>{const r={};return Object.values(k).forEach(e=>{r[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:F(e.id)||e.rpcUrl}}),r},be=(r,e=[])=>{const a=R(r);if(!a)return[];const t=[];if(![11155111,421614,84532,688689].includes(r)){const s=e.find(n=>n.chainId===r&&n.isNative);s?t.push(s):t.push({address:y.ZERO_ADDRESS,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:r})}if(!a.supportedTokens)return t;const o=t.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(o&&y.isNativeToken(s.address))return;const n=e.find(d=>d.chainId===r&&d.address.toLowerCase()===s.address.toLowerCase());n?t.push(n):t.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:r})}),t},we=async(r,e)=>{const a=R(r);if(!a)throw new Error(`Unsupported chain ID: ${r}`);const t=e.toLowerCase();if(y.isNativeToken(t)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${r}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const o=a.supportedTokens.find(s=>s.address.toLowerCase()===t);if(o)return o.decimals}try{if(!b.isAddress(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const o=b.getAddress(e),s=Y(r),n=await ie.readContract(s,{address:o,abi:j,functionName:"decimals"});return Number(n)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${r}`)}},J=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-api-devserver.spicenet.io",z="__SPICEFLOW_RELAYER_API_URL__";function xe(r,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,t,o,s]=a,n=Number(s),d=BigInt(t),c=BigInt(o);let l;for(const f of r.intents){const E=f.chainBatches.find(T=>T.chainId===n);if(E){l=E;break}}const m=l?.tokenTransfers.find(f=>f.from==="escrow"&&f.to.toLowerCase()===r.user.toLowerCase()&&!y.isNativeToken(f.token));if(!m)return`Amount is too small to cover the estimated fee on ${I(n)}.`;const p=y.getTokenByAddress(m.token,n),x=p?.decimals??18,B=p?.symbol??"tokens",S=b.formatUnits(d,x),i=b.formatUnits(c,x);return`Amount is too small to cover the estimated fee on ${I(n)}. Amount: ${S} ${B}. Estimated fee: ${i} ${B}.`}function Be(r){return!1}function Ee(){if(typeof globalThis>"u")return;const r=globalThis[z];return typeof r=="string"&&r.length>0?r:void 0}class Se{constructor(){this.baseUrl=J}setBaseUrl(e){this.baseUrl=e,typeof globalThis<"u"&&(globalThis[z]=e)}getBaseUrl(){return this.getEffectiveBaseUrl()}getEffectiveBaseUrl(){return Ee()||this.baseUrl}async createAction(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Relayer API error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions"});return t}async estimateActionFees(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/fees/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.feeEstimate){const o=t.error?.message||`Relayer fee estimate error: ${a.status}`,s=xe(e,o);throw new u("RELAYER_ERROR",s,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/fees/estimate"})}return t.data.feeEstimate}async estimateBatchGas(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/actions/gas/estimate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||!t.success||!t.data?.gasFee){const o=t.error?.message||`Relayer gas estimate error: ${a.status}`;throw new u("RELAYER_ERROR",o,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/actions/gas/estimate"})}return{gasFee:BigInt(t.data.gasFee),gasQuoteSource:t.data.gasQuoteSource}}async executeStep(e,a,t,o){const s=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/${a}/steps/${t}`,n=fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});let d;try{d=await Promise.race([n,new Promise((l,m)=>setTimeout(()=>m(new u("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${1e4/1e3}s`,{actionId:e,intentIndex:a,stepIndex:t,endpoint:`/actions/${e}/intents/${a}/steps/${t}`})),1e4))])}catch(l){throw l}const c=await d.json();if(!d.ok||c.success===!1)throw new u("RELAYER_EXECUTE_ERROR",c.error?.message||`Execute step error: ${d.status}`,{httpStatus:d.status,responseBody:JSON.stringify(c),endpoint:`/actions/${e}/intents/${a}/steps/${t}`,actionId:e});if(c?.status==="error"||c?.status==="reverted")throw new u("RELAYER_EXECUTE_ERROR",`Step ${t} previously ${c.status}${c?.error?`: ${c.error}`:""}`,{httpStatus:d.status,responseBody:JSON.stringify(c),endpoint:`/actions/${e}/intents/${a}/steps/${t}`,actionId:e,intentIndex:a,stepIndex:t,stepStatus:c.status});return{success:!0,transactionHash:c.transactionHash}}async checkStepStatus(e,a){const t=e.split("/");let o="";if(t.length>=2){const d=t[0],c=t[1];o=`${this.getEffectiveBaseUrl()}/actions/${d}/intents/${c}/steps/${a}`}else o=`${this.getEffectiveBaseUrl()}/actions/${e}/intents/0/steps/${a}`;const s=await fetch(o),n=await s.json();if(!s.ok||n.success===!1)throw new u("RELAYER_STATUS_ERROR",n.error?.message||`Intent step status check failed: ${s.status}`,{httpStatus:s.status,responseBody:JSON.stringify(n),endpoint:o,intentId:e});return{success:!0,data:{status:n.status==="error"?"reverted":n.status,transactionHash:n.txid}}}async createWallet(e,a){const t=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),o=await t.json();if(!t.ok||o.success===!1)throw new u("RELAYER_ERROR",o.error?.message||`Create wallet error: ${t.status}`,{httpStatus:t.status,responseBody:JSON.stringify(o),endpoint:`/wallets/${e}`});return o}async getWallet(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/wallets/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Get wallet error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/wallets/${e}`});return t}async createWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,(o,s)=>typeof s=="bigint"?s.toString():s)}),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Create withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:"/withdrawals"});return t}async getWithdrawal(e){const a=await fetch(`${this.getEffectiveBaseUrl()}/withdrawals/${e}`),t=await a.json();if(!a.ok||t.success===!1)throw new u("RELAYER_ERROR",t.error?.message||`Get withdrawal error: ${a.status}`,{httpStatus:a.status,responseBody:JSON.stringify(t),endpoint:`/withdrawals/${e}`});return t}async getRollupTimestamp(){const e=await fetch(`${this.getEffectiveBaseUrl()}/time`),a=await e.json();if(!e.ok||a.success===!1)throw new u("RELAYER_ERROR",a.error?.message||`Get rollup timestamp error: ${e.status}`,{httpStatus:e.status,responseBody:JSON.stringify(a),endpoint:"/time"});return a}}const w=new Se,M=new Map;async function $e(r,e){const a=r.toLowerCase(),t=M.get(a);if(t)return t;const o=(async()=>{try{await w.getWallet(r);return}catch{}const{unix_timestamp:s}=await w.getRollupTimestamp(),n=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${r.slice(2).toLowerCase()}. Nonce: ${s}`,d=await e(n),c=typeof d=="string"?d:d.signature;if(!c)throw new Error("Wallet returned no smart wallet signature");await w.createWallet(r,{timestamp:s,signature:c})})();M.set(a,o);try{await o}finally{M.delete(a)}}const Ce=(r,e)=>{const a=o=>e?e(o):I(o),t=[];return r.forEach((o,s)=>{const n=o.calls&&o.calls.length>0,d=o.tokenTransfers&&o.tokenTransfers.length>0;if(n||d){const c={stepId:s,status:s===0?"processing":"pending",chainId:o.chainId,chainName:a(o.chainId),description:"Processing transaction"};t.push(c)}}),t},H="spiceflow-mode",G=()=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(H);return r==="embedded"?"7702":r==="external"?"ondemand":null}catch{return null}},ve=r=>{if(!(typeof window>"u"))try{window.localStorage.setItem(H,r==="7702"?"embedded":"external")}catch{}},Re=()=>G()!==null,q=h.createContext(null),X=h.createContext(null),Te=({children:r,provider:e,supportedChainIds:a,network:t="testnet",mode:o="7702",skipFlow:s=[],nativeChainId:n,appName:d="Spicenet",apiUrl:c,theme:l,rpcOverrides:m})=>{h.useEffect(()=>{if(!c)return;const f=w.getBaseUrl();return w.setBaseUrl(c),()=>w.setBaseUrl(f)},[c]),h.useEffect(()=>(W(m),()=>W(void 0)),[m]);const p=a??y.getChainIdsByNetwork(t),x=l??null,[B,S]=h.useState(()=>G()??o),i=h.useCallback(f=>{S(f),ve(f)},[]);return v.jsx(q.Provider,{value:x,children:v.jsx(X.Provider,{value:{provider:e,supportedChainIds:p,skipFlow:s,mode:B,setMode:i,network:t,nativeChainId:n,appName:d,apiUrl:c,rpcOverrides:m},children:r})})},ke={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},Ie={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},Ne={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},Q=(r="light")=>({mode:r,...ke,colors:r==="light"?Ie:Ne});function N(r,e){const a=r.replace("#",""),t=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),o=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Ue(r,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??N(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??N(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function Ae(r){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function Z(r,e){const a=e?{...r,...e}:r,t=a.dark??!1,o=a.primaryColor,s=a.shell??(t?"#141414":"#ffffff");return{primaryColor:o,dark:t,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:s,shellBorder:N(s,t?.35:.085),shellInnerBorder:N(s,t?.55:.165),card:a.card??(t?"#1e1e1e":"#f9fafb"),input:t?"#171717":"#ffffff",hover:t?"#2a2a2a":"#f3f4f6",text:a.text??(t?"#ffffff":"#111827"),textMuted:a.textMuted??(t?"#888888":"#6b7280"),inputText:t?"#e0e0e0":"#111827",inputPlaceholder:t?"#555555":"#9ca3af",border:a.border??(t?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:t?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:t?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:t?"#0a1f18":"#d1fae5",successBorder:t?"#1a4a3a":"#6ee7b7",successText:t?"#6ee7b7":"#065f46",warningBg:t?"#1f1a0d":"#fef3c7",warningBorder:t?"#4a3820":"#fde68a",warningText:t?"#fbbf24":"#92400e",errorBg:t?"#1f0d0d":"#fef2f2",errorBorder:t?"#4a2020":"#fecaca",errorText:t?"#f87171":"#dc2626",infoBg:t?"#0d1325":"#dbeafe",infoBorder:t?"#2a3a5a":"#93c5fd",infoText:t?"#60a5fa":"#1e40af"}}function K(r,e){const a=h.useContext(q)??void 0;return h.useMemo(()=>{const t=a??{primaryColor:"#EA4B4B"},o={...r?.primaryColor?{primaryColor:r.primaryColor}:{},...r?.fontFamily?{fontFamily:r.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=Z(t,o),{dark:n,primaryColor:d,appName:c}=s,l=Q(n?"dark":"light"),m={...l,colors:{...l.colors,primary:d,primaryHover:`${d}dd`},typography:{...l.typography,fontFamily:s.fontFamily}},p={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText};return{brand:a,theme:m,dark:n,appName:c,primaryColor:d,dk:p,palette:p}},[a,r,e])}const V="spiceflow-spinner-keyframes";function Oe(){if(typeof document>"u"||document.getElementById(V))return;const r=document.createElement("style");r.id=V,r.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(r)}const ee=({size:r=16,borderWidth:e=2,color:a="currentColor",style:t})=>{const o=h.useRef(!1);return h.useEffect(()=>{o.current||(Oe(),o.current=!0)},[]),v.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${r}px`,height:`${r}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...t}})},_e=({variant:r="primary",size:e="md",loading:a=!1,fullWidth:t=!1,disabled:o,children:s,className:n="",style:d,theme:c,styles:l,dark:m,...p})=>{const{theme:x,dark:B,palette:S}=K(l,m),i=c||x,f=m??B,[E,T]=h.useState(!1),[U,A]=h.useState(!1),O=f?S.shell:"white",te=()=>{switch(r){case"primary":return{backgroundColor:l?.button?.backgroundColor||i.colors.primary,color:l?.button?.color||"#ffffff",border:`1px solid ${l?.button?.backgroundColor||i.colors.primary}`};case"secondary":return{backgroundColor:i.colors.secondary,color:i.colors.text,border:`1px solid ${i.colors.border}`};case"success":return{backgroundColor:i.colors.success,color:i.colors.text,border:`1px solid ${i.colors.success}`};case"error":return{backgroundColor:i.colors.error,color:i.colors.text,border:`1px solid ${i.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:i.colors.textSecondary,border:`1px solid ${i.colors.border}`};case"outline":{const g=l?.button?.backgroundColor||i.colors.primary,L=l?.button?.color||(f?"#ffffff":"#0e0d0b"),$=l?.button?.borderColor||(f?`${i.colors.primary}88`:"#0e0d0b"),C=o||a,se=f?"1px":"1.5px",oe=l?.button?.disabledBackgroundColor||`${g}88`,ne=l?.button?.disabledColor||L;return{height:"56px",backgroundColor:C?oe:U?`${g}cc`:E?`${g}ee`:g,color:C?ne:L,border:`${se} solid ${$}`,borderRadius:l?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:C?.78:1,transform:C?"none":U?"scale(0.98)":E?"translateY(-2px)":"none",boxShadow:C?`3px 3px 0px ${O}, 4px 4px 0px ${$}`:U?`2px 2px 0px ${$}`:E?`5px 5px 0px ${O}, 6px 6px 0px ${$}`:`3px 3px 0px ${O}, 4px 4px 0px ${$}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},re=()=>{if(r==="outline")return{};switch(e){case"sm":return{padding:`${i.spacing.sm} ${i.spacing.md}`,fontSize:i.typography.fontSize.sm};case"md":return{padding:`${i.spacing.md} ${i.spacing.lg}`,fontSize:i.typography.fontSize.base};case"lg":return{padding:`${i.spacing.lg} ${i.spacing.xl}`,fontSize:i.typography.fontSize.lg};default:return{}}},ae={borderRadius:l?.button?.borderRadius||i.borderRadius.md,fontWeight:l?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:l?.button?.fontFamily||i.typography.fontFamily,fontSize:l?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:o||a?"not-allowed":"pointer",opacity:(o||a)&&r!=="outline"?.6:1,width:t?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...te(),...re(),...l?.button?.fontSize&&{fontSize:l.button.fontSize}},P=o||a;return v.jsxs("button",{type:p.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":P||void 0,style:{...ae,...d},className:n,disabled:P,onMouseEnter:g=>{T(!0),p.onMouseEnter?.(g)},onMouseLeave:g=>{T(!1),A(!1),p.onMouseLeave?.(g)},onMouseDown:g=>{A(!0),p.onMouseDown?.(g)},onMouseUp:g=>{A(!1),p.onMouseUp?.(g)},...p,children:[a&&v.jsx(ee,{size:16}),s]})};exports.Button=_e,exports.CHAIN_CONFIGS=me,exports.G=j,exports.RELAYER_API_URL=J,exports.SpiceFlowProvider=Te,exports.SpiceFlowProviderContext=X,exports.SpiceflowError=u,exports.Spinner=ee,exports.buildDarkPalette=Ue,exports.buildLightPalette=Ae,exports.createInitialSteps=Ce,exports.createTheme=Q,exports.ensureSmartWallet=$e,exports.getAllAssetsForChain=be,exports.getChainConfig=R,exports.getChainName=I,exports.getChainsForAssets=ye,exports.getClientForChain=Y,exports.getDelegateContractAddress=ge,exports.getExplorerUrl=he,exports.getRpcUrlForChain=F,exports.getTokenDecimals=we,exports.hasReducedFeeOutput=Be,exports.hasStoredSpiceFlowMode=Re,exports.isSpiceflowError=ce,exports.relayerService=w,exports.resolveTheme=Z,exports.useSpiceBrand=K;
|
package/dist/auth-dynamic.d.ts
DELETED
package/dist/auth-privy.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { LockDurationSliderProps, LockExpiryRowProps, VotingPowerRowProps, LockConfirmationData, LockConfirmationPanelProps } from "../../types/lock";
|
|
3
|
-
export type { LockDurationSliderProps, LockExpiryRowProps, VotingPowerRowProps, LockConfirmationData, LockConfirmationPanelProps, };
|
|
4
|
-
export declare const LockDurationSlider: React.FC<LockDurationSliderProps>;
|
|
5
|
-
export declare const LockExpiryRow: React.FC<LockExpiryRowProps>;
|
|
6
|
-
export declare const VotingPowerRow: React.FC<VotingPowerRowProps>;
|
|
7
|
-
export declare const LockConfirmationPanel: React.FC<LockConfirmationPanelProps>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SpiceLockModal } from "./SpiceLockModal";
|
package/dist/errors.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type SpiceflowErrorCode = "WALLET_DISCONNECTED" | "WALLET_REJECTED" | "SIGNATURE_FAILED" | "CONCURRENT_EXECUTION" | "ABORT" | "NO_VENUE_FOR_CHAIN" | "NO_LIQUIDITY" | "VENUE_API_ERROR" | "NO_SWAP_ROUTE" | "ROUTE_TOKEN_NOT_FOUND" | "ROUTE_UNSUPPORTED_INPUT" | "ROUTE_STRATEGY_ERROR" | "INVALID_PARAMS" | "INVALID_TOKEN_TRANSFER" | "RELAYER_ERROR" | "RELAYER_EXECUTE_ERROR" | "RELAYER_STATUS_ERROR" | "ON_CHAIN_REVERT" | "POLLING_EXHAUSTED" | "POLLING_CONSECUTIVE_FAILURES" | "ALL_ATTEMPTS_FAILED";
|
|
2
|
-
export declare class SpiceflowError extends Error {
|
|
3
|
-
readonly code: SpiceflowErrorCode;
|
|
4
|
-
readonly context: Record<string, unknown>;
|
|
5
|
-
readonly name = "SpiceflowError";
|
|
6
|
-
constructor(code: SpiceflowErrorCode, message: string, context?: Record<string, unknown>);
|
|
7
|
-
}
|
|
8
|
-
export declare function isSpiceflowError(err: unknown): err is SpiceflowError;
|