@spicenet-io/spiceflow-ui 1.9.1 → 1.9.3

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/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use client";
2
- import { defineChain, createPublicClient, http, isAddress, getAddress, parseEther, parseUnits, encodeFunctionData } from 'viem';
2
+ import { defineChain, createPublicClient, http, isAddress, getAddress, parseEther, parseUnits, erc20Abi, encodeFunctionData } from 'viem';
3
3
  import { basecampTestnet, citreaTestnet, baseSepolia, arbitrumSepolia, sepolia } from 'viem/chains';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import React, { useState, useRef, useEffect, useCallback, createContext, useContext, useTransition, useMemo, forwardRef, createElement } from 'react';
6
- import { c as createTheme, B as Button, d as defaultTheme } from './Button-aWXByNBC.js';
6
+ import { c as createTheme, B as Button, d as defaultTheme } from './Button-CWjGZdAM.js';
7
7
  import { getBalance, readContract } from 'viem/actions';
8
8
  import { createPortal } from 'react-dom';
9
9
  import { useWallets, usePrivy, useSign7702Authorization, useSignMessage } from '@privy-io/react-auth';
10
10
  import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
11
11
  import { getAccountNonce, hashChainBatches, getAuthorizationHash } from 'spiceflow-core-test';
12
- import { useAccount, useConnect, useDisconnect, useSwitchChain, useWalletClient, http as http$1, createConfig, WagmiProvider } from 'wagmi';
12
+ import { useAccount, useWalletClient, useSwitchChain, useReadContracts, useConnect, useDisconnect, http as http$1, createConfig, WagmiProvider } from 'wagmi';
13
13
  import { DynamicLogin } from './auth-dynamic.js';
14
14
  import { PrivyLogin } from './auth-privy.js';
15
15
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
@@ -4129,11 +4129,13 @@ const DepositStatusPanel = ({
4129
4129
  border: `1px solid ${theme.colors.border}`,
4130
4130
  borderRadius: theme.borderRadius.lg,
4131
4131
  padding: theme.spacing.lg,
4132
- color: theme.colors.text
4132
+ color: theme.colors.text,
4133
+ overflow: "visible"
4133
4134
  };
4134
4135
  const headerStyles = {
4135
4136
  textAlign: "center",
4136
- marginBottom: theme.spacing.lg
4137
+ marginBottom: theme.spacing.lg,
4138
+ overflow: "visible"
4137
4139
  };
4138
4140
  const iconContainerStyles = {
4139
4141
  width: "5rem",
@@ -4155,7 +4157,10 @@ const DepositStatusPanel = ({
4155
4157
  };
4156
4158
  const descriptionStyles = {
4157
4159
  fontSize: theme.typography.fontSize.sm,
4158
- color: theme.colors.textMuted
4160
+ color: theme.colors.textMuted,
4161
+ wordWrap: "break-word",
4162
+ overflowWrap: "break-word",
4163
+ whiteSpace: "normal"
4159
4164
  };
4160
4165
  const buttonContainerStyles = {
4161
4166
  display: "flex",
@@ -4309,11 +4314,80 @@ const DepositStatusPanel = ({
4309
4314
  fullWidth: true,
4310
4315
  onClick: onNewDeposit,
4311
4316
  theme,
4317
+ style: {
4318
+ width: "100%",
4319
+ padding: "16px",
4320
+ backgroundColor: "#ea4b4b",
4321
+ color: "#0e0d0b",
4322
+ border: "1px solid #0e0d0b",
4323
+ fontWeight: 500,
4324
+ fontSize: "18px",
4325
+ textTransform: "uppercase",
4326
+ cursor: "pointer",
4327
+ marginTop: "20px",
4328
+ display: "flex",
4329
+ alignItems: "center",
4330
+ justifyContent: "center",
4331
+ gap: "8px",
4332
+ transition: "all 150ms ease"
4333
+ },
4312
4334
  children: "New Deposit"
4313
4335
  }
4314
4336
  ),
4315
- intentStatus.overallStatus === "failed" && onRetry && /* @__PURE__ */ jsx(Button, { variant: "error", fullWidth: true, onClick: onRetry, theme, children: "Try Again" }),
4316
- intentStatus.overallStatus === "processing" && /* @__PURE__ */ jsx(Button, { variant: "ghost", fullWidth: true, onClick: onClose, theme, children: "Cancel" })
4337
+ intentStatus.overallStatus === "failed" && onRetry && /* @__PURE__ */ jsx(
4338
+ Button,
4339
+ {
4340
+ variant: "error",
4341
+ fullWidth: true,
4342
+ onClick: onRetry,
4343
+ theme,
4344
+ style: {
4345
+ width: "100%",
4346
+ padding: "16px",
4347
+ backgroundColor: "#ea4b4b",
4348
+ color: "#0e0d0b",
4349
+ border: "1px solid #0e0d0b",
4350
+ fontWeight: 500,
4351
+ fontSize: "18px",
4352
+ textTransform: "uppercase",
4353
+ cursor: "pointer",
4354
+ marginTop: "20px",
4355
+ display: "flex",
4356
+ alignItems: "center",
4357
+ justifyContent: "center",
4358
+ gap: "8px",
4359
+ transition: "all 150ms ease"
4360
+ },
4361
+ children: "Try Again"
4362
+ }
4363
+ ),
4364
+ intentStatus.overallStatus === "processing" && /* @__PURE__ */ jsx(
4365
+ Button,
4366
+ {
4367
+ variant: "ghost",
4368
+ fullWidth: true,
4369
+ onClick: onClose,
4370
+ theme,
4371
+ style: {
4372
+ width: "100%",
4373
+ padding: "16px",
4374
+ backgroundColor: "#ea4b4b",
4375
+ color: "#0e0d0b",
4376
+ border: "1px solid #0e0d0b",
4377
+ fontWeight: 500,
4378
+ fontSize: "18px",
4379
+ textTransform: "uppercase",
4380
+ cursor: "pointer",
4381
+ marginTop: "20px",
4382
+ display: "flex",
4383
+ alignItems: "center",
4384
+ justifyContent: "center",
4385
+ gap: "8px",
4386
+ transition: "all 150ms ease"
4387
+ },
4388
+ children: "Cancel"
4389
+ }
4390
+ )
4317
4391
  ] })
4318
4392
  ] });
4319
4393
  };
@@ -5082,6 +5156,825 @@ const DepositWidgetModal = ({
5082
5156
  );
5083
5157
  };
5084
5158
 
5159
+ const AssetInput = ({
5160
+ asset,
5161
+ amount,
5162
+ onAmountChange,
5163
+ onPercentageClick,
5164
+ usdValue,
5165
+ disabled,
5166
+ styles,
5167
+ theme
5168
+ }) => {
5169
+ const balance = asset.balanceFormatted ?? 0;
5170
+ const numericAmount = parseFloat(amount) || 0;
5171
+ const currentPercentage = balance > 0 ? numericAmount / balance * 100 : 0;
5172
+ const handleInputChange = (e) => {
5173
+ const value = e.target.value;
5174
+ if (value === "" || /^\d*\.?\d*$/.test(value)) {
5175
+ onAmountChange(value);
5176
+ }
5177
+ };
5178
+ return /* @__PURE__ */ jsx(
5179
+ "div",
5180
+ {
5181
+ style: {
5182
+ backgroundColor: "#e9e9e9",
5183
+ border: "0.5px solid #a8a8a7",
5184
+ borderRadius: "6px",
5185
+ padding: "16px",
5186
+ height: "144px",
5187
+ display: "flex",
5188
+ flexDirection: "column",
5189
+ gap: "8px",
5190
+ position: "relative"
5191
+ },
5192
+ children: /* @__PURE__ */ jsxs(
5193
+ "div",
5194
+ {
5195
+ style: {
5196
+ flex: 1,
5197
+ display: "flex",
5198
+ alignItems: "center",
5199
+ justifyContent: "space-between"
5200
+ },
5201
+ children: [
5202
+ /* @__PURE__ */ jsx(
5203
+ "div",
5204
+ {
5205
+ style: {
5206
+ display: "flex",
5207
+ flexDirection: "column",
5208
+ justifyContent: "space-between",
5209
+ height: "100%"
5210
+ },
5211
+ children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
5212
+ /* @__PURE__ */ jsx(
5213
+ "span",
5214
+ {
5215
+ style: {
5216
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily,
5217
+ fontSize: "16px",
5218
+ fontWeight: 500,
5219
+ color: "#7d7c7b",
5220
+ lineHeight: "24px"
5221
+ },
5222
+ children: "Amount"
5223
+ }
5224
+ ),
5225
+ /* @__PURE__ */ jsx(
5226
+ "input",
5227
+ {
5228
+ type: "text",
5229
+ value: amount,
5230
+ onChange: handleInputChange,
5231
+ placeholder: "0.00",
5232
+ disabled,
5233
+ style: {
5234
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily,
5235
+ fontSize: "40px",
5236
+ fontWeight: 700,
5237
+ color: disabled ? "rgba(14, 13, 11, 0.16)" : amount ? "#0e0d0b" : "#d1d5db",
5238
+ lineHeight: "1.08",
5239
+ letterSpacing: "-1.2px",
5240
+ backgroundColor: "transparent",
5241
+ border: "none",
5242
+ outline: "none",
5243
+ padding: 0,
5244
+ width: "100%",
5245
+ maxWidth: "200px"
5246
+ }
5247
+ }
5248
+ )
5249
+ ] })
5250
+ }
5251
+ ),
5252
+ /* @__PURE__ */ jsxs(
5253
+ "div",
5254
+ {
5255
+ style: {
5256
+ display: "flex",
5257
+ flexDirection: "column",
5258
+ alignItems: "flex-end",
5259
+ justifyContent: "space-between",
5260
+ height: "100%",
5261
+ gap: "12px"
5262
+ },
5263
+ children: [
5264
+ /* @__PURE__ */ jsxs(
5265
+ "div",
5266
+ {
5267
+ style: {
5268
+ display: "flex",
5269
+ flexDirection: "column",
5270
+ gap: "8px",
5271
+ alignItems: "flex-end"
5272
+ },
5273
+ children: [
5274
+ /* @__PURE__ */ jsxs(
5275
+ "span",
5276
+ {
5277
+ style: {
5278
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily,
5279
+ fontSize: "12px",
5280
+ fontWeight: 500,
5281
+ color: "#71757a",
5282
+ lineHeight: "16px"
5283
+ },
5284
+ children: [
5285
+ "Balance: ",
5286
+ balance.toFixed(4)
5287
+ ]
5288
+ }
5289
+ ),
5290
+ /* @__PURE__ */ jsx("div", { style: { width: "128px" }, children: /* @__PURE__ */ jsxs(
5291
+ "div",
5292
+ {
5293
+ style: {
5294
+ border: "1px solid #CDCFD1",
5295
+ borderRadius: "6px 6px 6px 6px",
5296
+ backgroundColor: "#ffffff",
5297
+ padding: "8px 12px 8px 8px",
5298
+ display: "flex",
5299
+ alignItems: "center",
5300
+ gap: "8px"
5301
+ },
5302
+ children: [
5303
+ /* @__PURE__ */ jsx(
5304
+ TokenIcon,
5305
+ {
5306
+ symbol: asset.symbol,
5307
+ logoURI: asset.logoURI,
5308
+ size: 30,
5309
+ theme
5310
+ }
5311
+ ),
5312
+ /* @__PURE__ */ jsx(
5313
+ "span",
5314
+ {
5315
+ style: {
5316
+ fontFamily: styles?.fontFamily || theme.typography.fontFamily,
5317
+ fontSize: "16px",
5318
+ fontWeight: 500,
5319
+ color: "#3c3e42",
5320
+ lineHeight: "1.5"
5321
+ },
5322
+ children: asset.symbol
5323
+ }
5324
+ )
5325
+ ]
5326
+ }
5327
+ ) })
5328
+ ]
5329
+ }
5330
+ ),
5331
+ /* @__PURE__ */ jsx(
5332
+ "div",
5333
+ {
5334
+ style: {
5335
+ display: "flex",
5336
+ gap: "10px",
5337
+ height: "14px",
5338
+ alignItems: "center",
5339
+ justifyContent: "flex-end"
5340
+ },
5341
+ children: [0, 25, 50, 75, 100].map((pct, index) => {
5342
+ const isActive = Math.abs(currentPercentage - pct) < 1;
5343
+ const isLast = index === 4;
5344
+ const fillPercent = pct / 100;
5345
+ return /* @__PURE__ */ jsx(
5346
+ "button",
5347
+ {
5348
+ onClick: () => onPercentageClick(pct),
5349
+ disabled,
5350
+ title: `${pct}%`,
5351
+ style: {
5352
+ width: "14px",
5353
+ height: "14px",
5354
+ padding: 0,
5355
+ border: "none",
5356
+ backgroundColor: "transparent",
5357
+ cursor: disabled ? "not-allowed" : "pointer",
5358
+ opacity: isActive ? 1 : 0.5
5359
+ },
5360
+ children: /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", children: [
5361
+ /* @__PURE__ */ jsx(
5362
+ "circle",
5363
+ {
5364
+ cx: "7",
5365
+ cy: "7",
5366
+ r: "6.84375",
5367
+ fill: isLast ? "#ea4b4b" : "none",
5368
+ stroke: isLast ? "#ea4b4b" : "#3C3E42",
5369
+ strokeWidth: "0.3125"
5370
+ }
5371
+ ),
5372
+ !isLast && fillPercent > 0 && /* @__PURE__ */ jsx(
5373
+ "path",
5374
+ {
5375
+ d: `M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${fillPercent > 0.5 ? 1 : 0} 1 ${7 + 6.84375 * Math.sin(fillPercent * 2 * Math.PI)} ${7 - 6.84375 * Math.cos(fillPercent * 2 * Math.PI)} Z`,
5376
+ fill: "#3C3E42"
5377
+ }
5378
+ )
5379
+ ] })
5380
+ },
5381
+ pct
5382
+ );
5383
+ })
5384
+ }
5385
+ )
5386
+ ]
5387
+ }
5388
+ )
5389
+ ]
5390
+ }
5391
+ )
5392
+ }
5393
+ );
5394
+ };
5395
+
5396
+ const CrossChainDepositModal = ({
5397
+ isOpen,
5398
+ onClose,
5399
+ onComplete,
5400
+ chainId,
5401
+ externalWalletAddress,
5402
+ escrowAddress = "0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
5403
+ getChainConfig,
5404
+ getSupportedTokens
5405
+ }) => {
5406
+ const theme = createTheme("light");
5407
+ const [selectedAssets, setSelectedAssets] = useState(/* @__PURE__ */ new Map());
5408
+ const [isExecuting, setIsExecuting] = useState(false);
5409
+ const [error, setError] = useState(null);
5410
+ const [depositResults, setDepositResults] = useState([]);
5411
+ const [isSuccess, setIsSuccess] = useState(false);
5412
+ const { chain: currentChain } = useAccount();
5413
+ const { data: walletClient, isLoading: isWalletClientLoading } = useWalletClient();
5414
+ const { switchChainAsync } = useSwitchChain();
5415
+ const supportedTokens = useMemo(
5416
+ () => getSupportedTokens(chainId),
5417
+ [chainId, getSupportedTokens]
5418
+ );
5419
+ const { data: tokenBalances } = useReadContracts({
5420
+ contracts: supportedTokens.map((token) => ({
5421
+ address: token.address,
5422
+ abi: erc20Abi,
5423
+ functionName: "balanceOf",
5424
+ args: [externalWalletAddress],
5425
+ chainId
5426
+ }))
5427
+ });
5428
+ const assets = useMemo(() => {
5429
+ const chainConfig2 = getChainConfig(chainId);
5430
+ if (!chainConfig2) return [];
5431
+ const assetList = [];
5432
+ supportedTokens.forEach((token, index) => {
5433
+ const balanceResult = tokenBalances?.[index];
5434
+ const balance = balanceResult?.status === "success" ? balanceResult.result : BigInt(0);
5435
+ const balanceFormatted = Number(balance) / Math.pow(10, token.decimals);
5436
+ assetList.push({
5437
+ address: token.address,
5438
+ symbol: token.symbol,
5439
+ name: token.name,
5440
+ decimals: token.decimals,
5441
+ isNative: false,
5442
+ chainId,
5443
+ balance,
5444
+ balanceFormatted
5445
+ });
5446
+ });
5447
+ return assetList;
5448
+ }, [chainId, tokenBalances, supportedTokens, getChainConfig]);
5449
+ useEffect(() => {
5450
+ if (assets.length > 0 && selectedAssets.size > 0) {
5451
+ const updatedSelections = new Map(selectedAssets);
5452
+ let hasChanges = false;
5453
+ selectedAssets.forEach((selection, address) => {
5454
+ const updatedAsset = assets.find((a) => a.address === address);
5455
+ if (updatedAsset && updatedAsset.balanceFormatted !== selection.asset.balanceFormatted) {
5456
+ updatedSelections.set(address, { ...selection, asset: updatedAsset });
5457
+ hasChanges = true;
5458
+ }
5459
+ });
5460
+ if (hasChanges) {
5461
+ setSelectedAssets(updatedSelections);
5462
+ }
5463
+ }
5464
+ }, [assets, selectedAssets]);
5465
+ const chainConfig = getChainConfig(chainId);
5466
+ const toggleAssetSelection = (asset) => {
5467
+ const newSelections = new Map(selectedAssets);
5468
+ if (newSelections.has(asset.address)) {
5469
+ newSelections.delete(asset.address);
5470
+ } else {
5471
+ newSelections.set(asset.address, { asset, amount: "" });
5472
+ }
5473
+ setSelectedAssets(newSelections);
5474
+ setError(null);
5475
+ };
5476
+ const handleAmountChange = (address, value) => {
5477
+ if (value === "" || /^\d*\.?\d*$/.test(value)) {
5478
+ const newSelections = new Map(selectedAssets);
5479
+ const selection = newSelections.get(address);
5480
+ if (selection) {
5481
+ newSelections.set(address, { ...selection, amount: value });
5482
+ setSelectedAssets(newSelections);
5483
+ setError(null);
5484
+ }
5485
+ }
5486
+ };
5487
+ const handlePercentageClick = (address, percentage) => {
5488
+ const selection = selectedAssets.get(address);
5489
+ if (selection?.asset.balanceFormatted !== void 0) {
5490
+ const amount = selection.asset.balanceFormatted * percentage / 100;
5491
+ handleAmountChange(address, amount.toString());
5492
+ }
5493
+ };
5494
+ const executeDeposit = useCallback(async () => {
5495
+ if (selectedAssets.size === 0) {
5496
+ setError("Please select at least one asset");
5497
+ return;
5498
+ }
5499
+ for (const [address, selection] of Array.from(selectedAssets.entries())) {
5500
+ if (!selection.amount) {
5501
+ setError(`Please enter an amount for ${selection.asset.symbol}`);
5502
+ return;
5503
+ }
5504
+ const amount = parseFloat(selection.amount);
5505
+ if (isNaN(amount) || amount <= 0) {
5506
+ setError(`Please enter a valid amount for ${selection.asset.symbol}`);
5507
+ return;
5508
+ }
5509
+ const currentAsset = assets.find((a) => a.address === address);
5510
+ const currentBalance = currentAsset?.balanceFormatted ?? selection.asset.balanceFormatted;
5511
+ if (currentBalance !== void 0 && amount > currentBalance) {
5512
+ setError(`Insufficient ${selection.asset.symbol} balance`);
5513
+ return;
5514
+ }
5515
+ }
5516
+ if (!walletClient) {
5517
+ setError("Wallet not connected. Please reconnect your external wallet.");
5518
+ return;
5519
+ }
5520
+ setIsExecuting(true);
5521
+ setError(null);
5522
+ const results = [];
5523
+ try {
5524
+ if (currentChain?.id !== chainId) {
5525
+ await switchChainAsync({
5526
+ chainId
5527
+ });
5528
+ }
5529
+ for (const [, selection] of Array.from(selectedAssets.entries())) {
5530
+ const { asset, amount } = selection;
5531
+ try {
5532
+ const amountWei = parseUnits(amount, asset.decimals);
5533
+ let hash;
5534
+ if (asset.isNative) {
5535
+ hash = await walletClient.sendTransaction({
5536
+ to: escrowAddress,
5537
+ value: amountWei
5538
+ });
5539
+ } else {
5540
+ const data = encodeFunctionData({
5541
+ abi: erc20Abi,
5542
+ functionName: "transfer",
5543
+ args: [escrowAddress, amountWei]
5544
+ });
5545
+ hash = await walletClient.sendTransaction({
5546
+ to: asset.address,
5547
+ data
5548
+ });
5549
+ }
5550
+ await relayerService.submitSpiceDeposit({
5551
+ txHash: hash,
5552
+ sender: externalWalletAddress,
5553
+ tokenAddress: asset.address,
5554
+ chainId,
5555
+ amount: amount.toString(),
5556
+ user: escrowAddress,
5557
+ isDeposit: true
5558
+ });
5559
+ results.push({ asset, txHash: hash, success: true });
5560
+ } catch (err) {
5561
+ console.error(`Deposit error for ${asset.symbol}:`, err);
5562
+ const error2 = err;
5563
+ let errorMsg = error2?.message || "Deposit failed";
5564
+ if (error2?.code === 4001 || error2?.message?.includes("rejected")) {
5565
+ errorMsg = "Transaction rejected by user";
5566
+ } else if (error2?.message?.includes("insufficient funds")) {
5567
+ errorMsg = "Insufficient funds for transaction";
5568
+ }
5569
+ results.push({ asset, txHash: "", success: false, error: errorMsg });
5570
+ }
5571
+ }
5572
+ setDepositResults(results);
5573
+ setIsSuccess(true);
5574
+ } catch (err) {
5575
+ console.error("Deposit error:", err);
5576
+ const error2 = err;
5577
+ setError(error2?.message || "Deposit failed");
5578
+ } finally {
5579
+ setIsExecuting(false);
5580
+ }
5581
+ }, [
5582
+ selectedAssets,
5583
+ walletClient,
5584
+ currentChain,
5585
+ chainId,
5586
+ switchChainAsync,
5587
+ escrowAddress,
5588
+ assets,
5589
+ externalWalletAddress
5590
+ ]);
5591
+ useEffect(() => {
5592
+ if (!isOpen) {
5593
+ setSelectedAssets(/* @__PURE__ */ new Map());
5594
+ setError(null);
5595
+ setDepositResults([]);
5596
+ setIsSuccess(false);
5597
+ setIsExecuting(false);
5598
+ }
5599
+ }, [isOpen]);
5600
+ const canDeposit = selectedAssets.size > 0 && Array.from(selectedAssets.values()).every(
5601
+ (s) => s.amount && parseFloat(s.amount) > 0
5602
+ ) && !isExecuting && !isSuccess && walletClient;
5603
+ const subtitle = /* @__PURE__ */ jsxs(
5604
+ "div",
5605
+ {
5606
+ style: {
5607
+ display: "flex",
5608
+ alignItems: "flex-start",
5609
+ gap: "5px",
5610
+ backgroundColor: "#f9fafb",
5611
+ border: "1px solid #ed6969",
5612
+ borderRadius: "8px",
5613
+ padding: "10px",
5614
+ margin: "0 0 0 0"
5615
+ },
5616
+ children: [
5617
+ /* @__PURE__ */ jsx(
5618
+ "img",
5619
+ {
5620
+ src: img$c,
5621
+ alt: "Info",
5622
+ style: {
5623
+ width: "14px",
5624
+ height: "14px",
5625
+ marginTop: "2px",
5626
+ flexShrink: 0
5627
+ }
5628
+ }
5629
+ ),
5630
+ /* @__PURE__ */ jsxs(
5631
+ "p",
5632
+ {
5633
+ style: {
5634
+ fontSize: "13px",
5635
+ color: "#374151",
5636
+ margin: 0,
5637
+ lineHeight: "1.5"
5638
+ },
5639
+ children: [
5640
+ "Select tokens and enter amounts to deposit to your Spicenet Account on",
5641
+ " ",
5642
+ chainConfig?.displayName || `Chain ${chainId}`,
5643
+ "."
5644
+ ]
5645
+ }
5646
+ )
5647
+ ]
5648
+ }
5649
+ );
5650
+ const successOverlay = isSuccess && depositResults.length > 0 ? /* @__PURE__ */ jsxs(
5651
+ "div",
5652
+ {
5653
+ style: {
5654
+ position: "absolute",
5655
+ inset: 0,
5656
+ backgroundColor: "white",
5657
+ zIndex: 10,
5658
+ borderRadius: "12px",
5659
+ padding: "24px",
5660
+ display: "flex",
5661
+ flexDirection: "column",
5662
+ alignItems: "center",
5663
+ justifyContent: "flex-start",
5664
+ gap: "16px",
5665
+ overflowY: "auto",
5666
+ paddingTop: "40px"
5667
+ },
5668
+ children: [
5669
+ /* @__PURE__ */ jsx(
5670
+ "div",
5671
+ {
5672
+ style: {
5673
+ width: "64px",
5674
+ height: "64px",
5675
+ borderRadius: "50%",
5676
+ backgroundColor: "#dcfce7",
5677
+ display: "flex",
5678
+ alignItems: "center",
5679
+ justifyContent: "center"
5680
+ },
5681
+ children: /* @__PURE__ */ jsx("span", { style: { fontSize: "28px", color: "#16a34a" }, children: "\u2713" })
5682
+ }
5683
+ ),
5684
+ /* @__PURE__ */ jsx(
5685
+ "p",
5686
+ {
5687
+ style: {
5688
+ fontWeight: 600,
5689
+ fontSize: "18px",
5690
+ color: "#166534",
5691
+ margin: 0
5692
+ },
5693
+ children: "Deposits Complete!"
5694
+ }
5695
+ ),
5696
+ /* @__PURE__ */ jsx(
5697
+ "div",
5698
+ {
5699
+ style: {
5700
+ width: "100%",
5701
+ maxHeight: "200px",
5702
+ overflowY: "auto",
5703
+ display: "flex",
5704
+ flexDirection: "column",
5705
+ gap: "8px"
5706
+ },
5707
+ children: depositResults.map((result, idx) => /* @__PURE__ */ jsxs(
5708
+ "div",
5709
+ {
5710
+ style: {
5711
+ padding: "12px",
5712
+ borderRadius: "8px",
5713
+ border: `1px solid ${result.success ? "#bbf7d0" : "#fecaca"}`,
5714
+ backgroundColor: result.success ? "#f0fdf4" : "#fef2f2",
5715
+ overflow: "visible"
5716
+ },
5717
+ children: [
5718
+ /* @__PURE__ */ jsxs(
5719
+ "div",
5720
+ {
5721
+ style: {
5722
+ display: "flex",
5723
+ justifyContent: "space-between",
5724
+ alignItems: "center"
5725
+ },
5726
+ children: [
5727
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 500 }, children: result.asset.symbol }),
5728
+ /* @__PURE__ */ jsx(
5729
+ "span",
5730
+ {
5731
+ style: {
5732
+ color: result.success ? "#16a34a" : "#dc2626",
5733
+ fontSize: "14px"
5734
+ },
5735
+ children: result.success ? "\u2713 Success" : "\u2717 Failed"
5736
+ }
5737
+ )
5738
+ ]
5739
+ }
5740
+ ),
5741
+ result.success && result.txHash && /* @__PURE__ */ jsx(
5742
+ "a",
5743
+ {
5744
+ href: `${chainConfig?.blockExplorers?.default?.url}/tx/${result.txHash}`,
5745
+ target: "_blank",
5746
+ rel: "noopener noreferrer",
5747
+ style: {
5748
+ fontSize: "12px",
5749
+ color: theme.colors.primary,
5750
+ textDecoration: "none"
5751
+ },
5752
+ children: "View on Explorer \u2192"
5753
+ }
5754
+ ),
5755
+ result.error && /* @__PURE__ */ jsx(
5756
+ "p",
5757
+ {
5758
+ style: {
5759
+ fontSize: "12px",
5760
+ color: "#dc2626",
5761
+ margin: "4px 0 0 0",
5762
+ wordWrap: "break-word",
5763
+ overflowWrap: "break-word",
5764
+ whiteSpace: "normal"
5765
+ },
5766
+ children: result.error
5767
+ }
5768
+ )
5769
+ ]
5770
+ },
5771
+ idx
5772
+ ))
5773
+ }
5774
+ ),
5775
+ /* @__PURE__ */ jsx(
5776
+ "button",
5777
+ {
5778
+ onClick: onComplete,
5779
+ style: {
5780
+ width: "100%",
5781
+ padding: "14px",
5782
+ borderRadius: "8px",
5783
+ backgroundColor: theme.colors.primary,
5784
+ color: "white",
5785
+ border: "none",
5786
+ fontWeight: 600,
5787
+ fontSize: "16px",
5788
+ cursor: "pointer",
5789
+ marginTop: "8px"
5790
+ },
5791
+ children: "Done"
5792
+ }
5793
+ )
5794
+ ]
5795
+ }
5796
+ ) : null;
5797
+ return /* @__PURE__ */ jsx(
5798
+ SpiceModalShell,
5799
+ {
5800
+ isOpen,
5801
+ onClose,
5802
+ title: "Deposit to Spicenet",
5803
+ subtitle,
5804
+ theme,
5805
+ maxWidth: "480px",
5806
+ children: /* @__PURE__ */ jsxs("div", { style: { padding: "0 24px 24px 24px", position: "relative" }, children: [
5807
+ successOverlay,
5808
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
5809
+ /* @__PURE__ */ jsxs(
5810
+ "div",
5811
+ {
5812
+ style: {
5813
+ display: "flex",
5814
+ alignItems: "center",
5815
+ gap: "6px",
5816
+ marginBottom: "12px"
5817
+ },
5818
+ children: [
5819
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", color: "#6b7280" }, children: "\u25CE" }),
5820
+ /* @__PURE__ */ jsx(
5821
+ "label",
5822
+ {
5823
+ style: {
5824
+ fontSize: "14px",
5825
+ fontWeight: 500,
5826
+ color: "#374151"
5827
+ },
5828
+ children: "Select Assets to Deposit"
5829
+ }
5830
+ )
5831
+ ]
5832
+ }
5833
+ ),
5834
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: assets.map((asset) => {
5835
+ const isSelected = selectedAssets.has(asset.address);
5836
+ return /* @__PURE__ */ jsxs(
5837
+ "button",
5838
+ {
5839
+ onClick: () => toggleAssetSelection(asset),
5840
+ style: {
5841
+ padding: "8px 16px",
5842
+ borderRadius: "8px",
5843
+ border: `2px solid ${isSelected ? theme.colors.primary : "#e5e7eb"}`,
5844
+ backgroundColor: isSelected ? "#FEF2F2" : "white",
5845
+ cursor: "pointer",
5846
+ display: "flex",
5847
+ alignItems: "center",
5848
+ gap: "8px",
5849
+ transition: "all 150ms ease"
5850
+ },
5851
+ children: [
5852
+ /* @__PURE__ */ jsx(
5853
+ "div",
5854
+ {
5855
+ style: {
5856
+ width: "24px",
5857
+ height: "24px",
5858
+ borderRadius: "50%",
5859
+ backgroundColor: asset.symbol === "USDC" ? "#2775CA" : asset.symbol === "USDT" ? "#26A17B" : "#F7931A",
5860
+ display: "flex",
5861
+ alignItems: "center",
5862
+ justifyContent: "center",
5863
+ color: "white",
5864
+ fontSize: "10px",
5865
+ fontWeight: 700
5866
+ },
5867
+ children: asset.symbol === "USDC" ? "$" : asset.symbol === "USDT" ? "\u20AE" : "\u20BF"
5868
+ }
5869
+ ),
5870
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, color: "#111827" }, children: asset.symbol }),
5871
+ asset.balanceFormatted !== void 0 && /* @__PURE__ */ jsxs(
5872
+ "span",
5873
+ {
5874
+ style: {
5875
+ fontSize: "13px",
5876
+ color: "#9ca3af",
5877
+ fontFamily: "monospace"
5878
+ },
5879
+ children: [
5880
+ "(",
5881
+ asset.balanceFormatted.toFixed(4),
5882
+ ")"
5883
+ ]
5884
+ }
5885
+ )
5886
+ ]
5887
+ },
5888
+ asset.address
5889
+ );
5890
+ }) })
5891
+ ] }),
5892
+ selectedAssets.size > 0 && /* @__PURE__ */ jsx(
5893
+ "div",
5894
+ {
5895
+ style: { display: "flex", flexDirection: "column", gap: "16px" },
5896
+ children: Array.from(selectedAssets.values()).map(({ asset, amount }) => /* @__PURE__ */ jsx(
5897
+ AssetInput,
5898
+ {
5899
+ asset,
5900
+ amount,
5901
+ onAmountChange: (value) => handleAmountChange(asset.address, value),
5902
+ onPercentageClick: (pct) => handlePercentageClick(asset.address, pct),
5903
+ theme,
5904
+ disabled: isExecuting
5905
+ },
5906
+ asset.address
5907
+ ))
5908
+ }
5909
+ ),
5910
+ error && /* @__PURE__ */ jsx(
5911
+ "div",
5912
+ {
5913
+ style: {
5914
+ padding: "12px",
5915
+ backgroundColor: "#fef2f2",
5916
+ border: "1px solid #fecaca",
5917
+ borderRadius: "8px",
5918
+ marginTop: "16px"
5919
+ },
5920
+ children: /* @__PURE__ */ jsx("p", { style: { fontSize: "14px", color: "#dc2626", margin: 0 }, children: error })
5921
+ }
5922
+ ),
5923
+ !isSuccess && /* @__PURE__ */ jsx(
5924
+ Button,
5925
+ {
5926
+ variant: "outline",
5927
+ fullWidth: true,
5928
+ onClick: executeDeposit,
5929
+ loading: isExecuting,
5930
+ disabled: !canDeposit,
5931
+ theme,
5932
+ style: {
5933
+ width: "100%",
5934
+ padding: "16px",
5935
+ backgroundColor: "#ea4b4b",
5936
+ color: "#0e0d0b",
5937
+ border: "1px solid #0e0d0b",
5938
+ fontWeight: 500,
5939
+ fontSize: "18px",
5940
+ textTransform: "uppercase",
5941
+ cursor: canDeposit ? "pointer" : "not-allowed",
5942
+ marginTop: "20px",
5943
+ display: "flex",
5944
+ alignItems: "center",
5945
+ justifyContent: "center",
5946
+ gap: "8px",
5947
+ transition: "all 150ms ease"
5948
+ },
5949
+ children: isExecuting ? /* @__PURE__ */ jsxs(Fragment, { children: [
5950
+ /* @__PURE__ */ jsx(
5951
+ "div",
5952
+ {
5953
+ style: {
5954
+ width: "18px",
5955
+ height: "18px",
5956
+ border: "2px solid white",
5957
+ borderTopColor: "transparent",
5958
+ borderRadius: "50%",
5959
+ animation: "spin 1s linear infinite"
5960
+ }
5961
+ }
5962
+ ),
5963
+ /* @__PURE__ */ jsx("span", { children: "PROCESSING..." })
5964
+ ] }) : isWalletClientLoading ? "CONNECTING WALLET..." : !walletClient ? "WALLET NOT CONNECTED" : selectedAssets.size === 0 ? "SELECT ASSETS" : !Array.from(selectedAssets.values()).every((s) => s.amount) ? "ENTER AMOUNTS" : "DEPOSIT"
5965
+ }
5966
+ ),
5967
+ /* @__PURE__ */ jsx("style", { children: `
5968
+ @keyframes spin {
5969
+ from { transform: rotate(0deg); }
5970
+ to { transform: rotate(360deg); }
5971
+ }
5972
+ ` })
5973
+ ] })
5974
+ }
5975
+ );
5976
+ };
5977
+
5085
5978
  /**
5086
5979
  * @license lucide-react v0.383.0 - ISC
5087
5980
  *
@@ -12651,4 +13544,4 @@ const useDepositInput = () => {
12651
13544
  };
12652
13545
  };
12653
13546
 
12654
- export { ConnectWalletModal, DepositModal, DepositWidget, DepositWidgetModal, LpModal, ProviderLogin, SelectChainModal, SpiceBalance, SpiceDeposit, SpiceFlowProvider, SpiceFlowProviderContext, SpiceWithdraw, SwapWidget, WithdrawModal, fetchBalances, relayerService, useAssets, useDepositInput, useFromInput, useSpiceBalance, useStatus, useToInputUpdate, useWallet };
13547
+ export { ConnectWalletModal, CrossChainDepositModal, DepositModal, DepositWidget, DepositWidgetModal, LpModal, ProviderLogin, SelectChainModal, SpiceBalance, SpiceDeposit, SpiceFlowProvider, SpiceFlowProviderContext, SpiceWithdraw, SwapWidget, WithdrawModal, fetchBalances, relayerService, useAssets, useDepositInput, useFromInput, useSpiceBalance, useStatus, useToInputUpdate, useWallet };