@spicenet-io/spiceflow-ui 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-dynamic.js +1 -1
- package/dist/auth-privy.js +1 -1
- package/dist/components/DepositWidget/CrossChainDepositModal.d.ts +21 -2
- package/dist/components/DepositWidget/index.d.ts +2 -0
- package/dist/index.cjs.js +772 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +775 -4
- package/dist/types/deposit.d.ts +1 -12
- package/package.json +1 -1
- /package/dist/{Button-aWXByNBC.js → Button-CWjGZdAM.js} +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -5084,6 +5084,777 @@ const DepositWidgetModal = ({
|
|
|
5084
5084
|
);
|
|
5085
5085
|
};
|
|
5086
5086
|
|
|
5087
|
+
const CrossChainDepositModal = ({
|
|
5088
|
+
isOpen,
|
|
5089
|
+
onClose,
|
|
5090
|
+
onComplete,
|
|
5091
|
+
chainId,
|
|
5092
|
+
externalWalletAddress,
|
|
5093
|
+
escrowAddress = "0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
5094
|
+
getChainConfig,
|
|
5095
|
+
getSupportedTokens
|
|
5096
|
+
}) => {
|
|
5097
|
+
const theme = Button.createTheme("light");
|
|
5098
|
+
const [selectedAssets, setSelectedAssets] = React.useState(/* @__PURE__ */ new Map());
|
|
5099
|
+
const [isExecuting, setIsExecuting] = React.useState(false);
|
|
5100
|
+
const [error, setError] = React.useState(null);
|
|
5101
|
+
const [depositResults, setDepositResults] = React.useState([]);
|
|
5102
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
5103
|
+
const { chain: currentChain } = wagmi.useAccount();
|
|
5104
|
+
const { data: walletClient, isLoading: isWalletClientLoading } = wagmi.useWalletClient();
|
|
5105
|
+
const { switchChainAsync } = wagmi.useSwitchChain();
|
|
5106
|
+
const supportedTokens = React.useMemo(
|
|
5107
|
+
() => getSupportedTokens(chainId),
|
|
5108
|
+
[chainId, getSupportedTokens]
|
|
5109
|
+
);
|
|
5110
|
+
const { data: tokenBalances } = wagmi.useReadContracts({
|
|
5111
|
+
contracts: supportedTokens.map((token) => ({
|
|
5112
|
+
address: token.address,
|
|
5113
|
+
abi: viem.erc20Abi,
|
|
5114
|
+
functionName: "balanceOf",
|
|
5115
|
+
args: [externalWalletAddress],
|
|
5116
|
+
chainId
|
|
5117
|
+
}))
|
|
5118
|
+
});
|
|
5119
|
+
const assets = React.useMemo(() => {
|
|
5120
|
+
const chainConfig2 = getChainConfig(chainId);
|
|
5121
|
+
if (!chainConfig2) return [];
|
|
5122
|
+
const assetList = [];
|
|
5123
|
+
supportedTokens.forEach((token, index) => {
|
|
5124
|
+
const balanceResult = tokenBalances?.[index];
|
|
5125
|
+
const balance = balanceResult?.status === "success" ? balanceResult.result : BigInt(0);
|
|
5126
|
+
const balanceFormatted = Number(balance) / Math.pow(10, token.decimals);
|
|
5127
|
+
assetList.push({
|
|
5128
|
+
address: token.address,
|
|
5129
|
+
symbol: token.symbol,
|
|
5130
|
+
name: token.name,
|
|
5131
|
+
decimals: token.decimals,
|
|
5132
|
+
isNative: false,
|
|
5133
|
+
chainId,
|
|
5134
|
+
balance,
|
|
5135
|
+
balanceFormatted
|
|
5136
|
+
});
|
|
5137
|
+
});
|
|
5138
|
+
return assetList;
|
|
5139
|
+
}, [chainId, tokenBalances, supportedTokens, getChainConfig]);
|
|
5140
|
+
React.useEffect(() => {
|
|
5141
|
+
if (assets.length > 0 && selectedAssets.size > 0) {
|
|
5142
|
+
const updatedSelections = new Map(selectedAssets);
|
|
5143
|
+
let hasChanges = false;
|
|
5144
|
+
selectedAssets.forEach((selection, address) => {
|
|
5145
|
+
const updatedAsset = assets.find((a) => a.address === address);
|
|
5146
|
+
if (updatedAsset && updatedAsset.balanceFormatted !== selection.asset.balanceFormatted) {
|
|
5147
|
+
updatedSelections.set(address, { ...selection, asset: updatedAsset });
|
|
5148
|
+
hasChanges = true;
|
|
5149
|
+
}
|
|
5150
|
+
});
|
|
5151
|
+
if (hasChanges) {
|
|
5152
|
+
setSelectedAssets(updatedSelections);
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
}, [assets, selectedAssets]);
|
|
5156
|
+
const chainConfig = getChainConfig(chainId);
|
|
5157
|
+
const toggleAssetSelection = (asset) => {
|
|
5158
|
+
const newSelections = new Map(selectedAssets);
|
|
5159
|
+
if (newSelections.has(asset.address)) {
|
|
5160
|
+
newSelections.delete(asset.address);
|
|
5161
|
+
} else {
|
|
5162
|
+
newSelections.set(asset.address, { asset, amount: "" });
|
|
5163
|
+
}
|
|
5164
|
+
setSelectedAssets(newSelections);
|
|
5165
|
+
setError(null);
|
|
5166
|
+
};
|
|
5167
|
+
const handleAmountChange = (address, value) => {
|
|
5168
|
+
if (value === "" || /^\d*\.?\d*$/.test(value)) {
|
|
5169
|
+
const newSelections = new Map(selectedAssets);
|
|
5170
|
+
const selection = newSelections.get(address);
|
|
5171
|
+
if (selection) {
|
|
5172
|
+
newSelections.set(address, { ...selection, amount: value });
|
|
5173
|
+
setSelectedAssets(newSelections);
|
|
5174
|
+
setError(null);
|
|
5175
|
+
}
|
|
5176
|
+
}
|
|
5177
|
+
};
|
|
5178
|
+
const handlePercentageClick = (address, percentage) => {
|
|
5179
|
+
const selection = selectedAssets.get(address);
|
|
5180
|
+
if (selection?.asset.balanceFormatted !== void 0) {
|
|
5181
|
+
const amount = selection.asset.balanceFormatted * percentage / 100;
|
|
5182
|
+
handleAmountChange(address, amount.toString());
|
|
5183
|
+
}
|
|
5184
|
+
};
|
|
5185
|
+
const executeDeposit = React.useCallback(async () => {
|
|
5186
|
+
if (selectedAssets.size === 0) {
|
|
5187
|
+
setError("Please select at least one asset");
|
|
5188
|
+
return;
|
|
5189
|
+
}
|
|
5190
|
+
for (const [address, selection] of Array.from(selectedAssets.entries())) {
|
|
5191
|
+
if (!selection.amount) {
|
|
5192
|
+
setError(`Please enter an amount for ${selection.asset.symbol}`);
|
|
5193
|
+
return;
|
|
5194
|
+
}
|
|
5195
|
+
const amount = parseFloat(selection.amount);
|
|
5196
|
+
if (isNaN(amount) || amount <= 0) {
|
|
5197
|
+
setError(`Please enter a valid amount for ${selection.asset.symbol}`);
|
|
5198
|
+
return;
|
|
5199
|
+
}
|
|
5200
|
+
const currentAsset = assets.find((a) => a.address === address);
|
|
5201
|
+
const currentBalance = currentAsset?.balanceFormatted ?? selection.asset.balanceFormatted;
|
|
5202
|
+
if (currentBalance !== void 0 && amount > currentBalance) {
|
|
5203
|
+
setError(`Insufficient ${selection.asset.symbol} balance`);
|
|
5204
|
+
return;
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
if (!walletClient) {
|
|
5208
|
+
setError("Wallet not connected. Please reconnect your external wallet.");
|
|
5209
|
+
return;
|
|
5210
|
+
}
|
|
5211
|
+
setIsExecuting(true);
|
|
5212
|
+
setError(null);
|
|
5213
|
+
const results = [];
|
|
5214
|
+
try {
|
|
5215
|
+
if (currentChain?.id !== chainId) {
|
|
5216
|
+
await switchChainAsync({
|
|
5217
|
+
chainId
|
|
5218
|
+
});
|
|
5219
|
+
}
|
|
5220
|
+
for (const [, selection] of Array.from(selectedAssets.entries())) {
|
|
5221
|
+
const { asset, amount } = selection;
|
|
5222
|
+
try {
|
|
5223
|
+
const amountWei = viem.parseUnits(amount, asset.decimals);
|
|
5224
|
+
let hash;
|
|
5225
|
+
if (asset.isNative) {
|
|
5226
|
+
hash = await walletClient.sendTransaction({
|
|
5227
|
+
to: escrowAddress,
|
|
5228
|
+
value: amountWei
|
|
5229
|
+
});
|
|
5230
|
+
} else {
|
|
5231
|
+
const data = viem.encodeFunctionData({
|
|
5232
|
+
abi: viem.erc20Abi,
|
|
5233
|
+
functionName: "transfer",
|
|
5234
|
+
args: [escrowAddress, amountWei]
|
|
5235
|
+
});
|
|
5236
|
+
hash = await walletClient.sendTransaction({
|
|
5237
|
+
to: asset.address,
|
|
5238
|
+
data
|
|
5239
|
+
});
|
|
5240
|
+
}
|
|
5241
|
+
await relayerService.submitSpiceDeposit({
|
|
5242
|
+
txHash: hash,
|
|
5243
|
+
sender: externalWalletAddress,
|
|
5244
|
+
tokenAddress: asset.address,
|
|
5245
|
+
chainId,
|
|
5246
|
+
amount: amount.toString(),
|
|
5247
|
+
user: escrowAddress,
|
|
5248
|
+
isDeposit: true
|
|
5249
|
+
});
|
|
5250
|
+
results.push({ asset, txHash: hash, success: true });
|
|
5251
|
+
} catch (err) {
|
|
5252
|
+
console.error(`Deposit error for ${asset.symbol}:`, err);
|
|
5253
|
+
const error2 = err;
|
|
5254
|
+
let errorMsg = error2?.message || "Deposit failed";
|
|
5255
|
+
if (error2?.code === 4001 || error2?.message?.includes("rejected")) {
|
|
5256
|
+
errorMsg = "Transaction rejected by user";
|
|
5257
|
+
} else if (error2?.message?.includes("insufficient funds")) {
|
|
5258
|
+
errorMsg = "Insufficient funds for transaction";
|
|
5259
|
+
}
|
|
5260
|
+
results.push({ asset, txHash: "", success: false, error: errorMsg });
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
setDepositResults(results);
|
|
5264
|
+
setIsSuccess(true);
|
|
5265
|
+
} catch (err) {
|
|
5266
|
+
console.error("Deposit error:", err);
|
|
5267
|
+
const error2 = err;
|
|
5268
|
+
setError(error2?.message || "Deposit failed");
|
|
5269
|
+
} finally {
|
|
5270
|
+
setIsExecuting(false);
|
|
5271
|
+
}
|
|
5272
|
+
}, [
|
|
5273
|
+
selectedAssets,
|
|
5274
|
+
walletClient,
|
|
5275
|
+
currentChain,
|
|
5276
|
+
chainId,
|
|
5277
|
+
switchChainAsync,
|
|
5278
|
+
escrowAddress,
|
|
5279
|
+
assets,
|
|
5280
|
+
externalWalletAddress
|
|
5281
|
+
]);
|
|
5282
|
+
React.useEffect(() => {
|
|
5283
|
+
if (!isOpen) {
|
|
5284
|
+
setSelectedAssets(/* @__PURE__ */ new Map());
|
|
5285
|
+
setError(null);
|
|
5286
|
+
setDepositResults([]);
|
|
5287
|
+
setIsSuccess(false);
|
|
5288
|
+
setIsExecuting(false);
|
|
5289
|
+
}
|
|
5290
|
+
}, [isOpen]);
|
|
5291
|
+
const canDeposit = selectedAssets.size > 0 && Array.from(selectedAssets.values()).every(
|
|
5292
|
+
(s) => s.amount && parseFloat(s.amount) > 0
|
|
5293
|
+
) && !isExecuting && !isSuccess && walletClient;
|
|
5294
|
+
const subtitle = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5295
|
+
"div",
|
|
5296
|
+
{
|
|
5297
|
+
style: {
|
|
5298
|
+
display: "flex",
|
|
5299
|
+
alignItems: "flex-start",
|
|
5300
|
+
gap: "8px",
|
|
5301
|
+
backgroundColor: "#f9fafb",
|
|
5302
|
+
border: "1px solid #e5e7eb",
|
|
5303
|
+
borderRadius: "8px",
|
|
5304
|
+
padding: "12px",
|
|
5305
|
+
margin: "-16px 0 0 0"
|
|
5306
|
+
},
|
|
5307
|
+
children: [
|
|
5308
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5309
|
+
"img",
|
|
5310
|
+
{
|
|
5311
|
+
src: img$c,
|
|
5312
|
+
alt: "Info",
|
|
5313
|
+
style: {
|
|
5314
|
+
width: "14px",
|
|
5315
|
+
height: "14px",
|
|
5316
|
+
marginTop: "2px",
|
|
5317
|
+
flexShrink: 0
|
|
5318
|
+
}
|
|
5319
|
+
}
|
|
5320
|
+
),
|
|
5321
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5322
|
+
"p",
|
|
5323
|
+
{
|
|
5324
|
+
style: {
|
|
5325
|
+
fontSize: "13px",
|
|
5326
|
+
color: "#374151",
|
|
5327
|
+
margin: 0,
|
|
5328
|
+
lineHeight: "1.5"
|
|
5329
|
+
},
|
|
5330
|
+
children: [
|
|
5331
|
+
"Select tokens and enter amounts to deposit to your Spicenet Account on",
|
|
5332
|
+
" ",
|
|
5333
|
+
chainConfig?.displayName || `Chain ${chainId}`,
|
|
5334
|
+
"."
|
|
5335
|
+
]
|
|
5336
|
+
}
|
|
5337
|
+
)
|
|
5338
|
+
]
|
|
5339
|
+
}
|
|
5340
|
+
);
|
|
5341
|
+
const successOverlay = isSuccess && depositResults.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5342
|
+
"div",
|
|
5343
|
+
{
|
|
5344
|
+
style: {
|
|
5345
|
+
position: "absolute",
|
|
5346
|
+
inset: 0,
|
|
5347
|
+
backgroundColor: "white",
|
|
5348
|
+
zIndex: 10,
|
|
5349
|
+
borderRadius: "12px",
|
|
5350
|
+
padding: "24px",
|
|
5351
|
+
display: "flex",
|
|
5352
|
+
flexDirection: "column",
|
|
5353
|
+
alignItems: "center",
|
|
5354
|
+
justifyContent: "center",
|
|
5355
|
+
gap: "16px"
|
|
5356
|
+
},
|
|
5357
|
+
children: [
|
|
5358
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5359
|
+
"div",
|
|
5360
|
+
{
|
|
5361
|
+
style: {
|
|
5362
|
+
width: "64px",
|
|
5363
|
+
height: "64px",
|
|
5364
|
+
borderRadius: "50%",
|
|
5365
|
+
backgroundColor: "#dcfce7",
|
|
5366
|
+
display: "flex",
|
|
5367
|
+
alignItems: "center",
|
|
5368
|
+
justifyContent: "center"
|
|
5369
|
+
},
|
|
5370
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "28px", color: "#16a34a" }, children: "\u2713" })
|
|
5371
|
+
}
|
|
5372
|
+
),
|
|
5373
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5374
|
+
"p",
|
|
5375
|
+
{
|
|
5376
|
+
style: {
|
|
5377
|
+
fontWeight: 600,
|
|
5378
|
+
fontSize: "18px",
|
|
5379
|
+
color: "#166534",
|
|
5380
|
+
margin: 0
|
|
5381
|
+
},
|
|
5382
|
+
children: "Deposits Complete!"
|
|
5383
|
+
}
|
|
5384
|
+
),
|
|
5385
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5386
|
+
"div",
|
|
5387
|
+
{
|
|
5388
|
+
style: {
|
|
5389
|
+
width: "100%",
|
|
5390
|
+
maxHeight: "200px",
|
|
5391
|
+
overflowY: "auto",
|
|
5392
|
+
display: "flex",
|
|
5393
|
+
flexDirection: "column",
|
|
5394
|
+
gap: "8px"
|
|
5395
|
+
},
|
|
5396
|
+
children: depositResults.map((result, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5397
|
+
"div",
|
|
5398
|
+
{
|
|
5399
|
+
style: {
|
|
5400
|
+
padding: "12px",
|
|
5401
|
+
borderRadius: "8px",
|
|
5402
|
+
border: `1px solid ${result.success ? "#bbf7d0" : "#fecaca"}`,
|
|
5403
|
+
backgroundColor: result.success ? "#f0fdf4" : "#fef2f2"
|
|
5404
|
+
},
|
|
5405
|
+
children: [
|
|
5406
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5407
|
+
"div",
|
|
5408
|
+
{
|
|
5409
|
+
style: {
|
|
5410
|
+
display: "flex",
|
|
5411
|
+
justifyContent: "space-between",
|
|
5412
|
+
alignItems: "center"
|
|
5413
|
+
},
|
|
5414
|
+
children: [
|
|
5415
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500 }, children: result.asset.symbol }),
|
|
5416
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5417
|
+
"span",
|
|
5418
|
+
{
|
|
5419
|
+
style: {
|
|
5420
|
+
color: result.success ? "#16a34a" : "#dc2626",
|
|
5421
|
+
fontSize: "14px"
|
|
5422
|
+
},
|
|
5423
|
+
children: result.success ? "\u2713 Success" : "\u2717 Failed"
|
|
5424
|
+
}
|
|
5425
|
+
)
|
|
5426
|
+
]
|
|
5427
|
+
}
|
|
5428
|
+
),
|
|
5429
|
+
result.success && result.txHash && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5430
|
+
"a",
|
|
5431
|
+
{
|
|
5432
|
+
href: `${chainConfig?.blockExplorers?.default?.url}/tx/${result.txHash}`,
|
|
5433
|
+
target: "_blank",
|
|
5434
|
+
rel: "noopener noreferrer",
|
|
5435
|
+
style: {
|
|
5436
|
+
fontSize: "12px",
|
|
5437
|
+
color: theme.colors.primary,
|
|
5438
|
+
textDecoration: "none"
|
|
5439
|
+
},
|
|
5440
|
+
children: "View on Explorer \u2192"
|
|
5441
|
+
}
|
|
5442
|
+
),
|
|
5443
|
+
result.error && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5444
|
+
"p",
|
|
5445
|
+
{
|
|
5446
|
+
style: {
|
|
5447
|
+
fontSize: "12px",
|
|
5448
|
+
color: "#dc2626",
|
|
5449
|
+
margin: "4px 0 0 0"
|
|
5450
|
+
},
|
|
5451
|
+
children: result.error
|
|
5452
|
+
}
|
|
5453
|
+
)
|
|
5454
|
+
]
|
|
5455
|
+
},
|
|
5456
|
+
idx
|
|
5457
|
+
))
|
|
5458
|
+
}
|
|
5459
|
+
),
|
|
5460
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5461
|
+
"button",
|
|
5462
|
+
{
|
|
5463
|
+
onClick: onComplete,
|
|
5464
|
+
style: {
|
|
5465
|
+
width: "100%",
|
|
5466
|
+
padding: "14px",
|
|
5467
|
+
borderRadius: "8px",
|
|
5468
|
+
backgroundColor: theme.colors.primary,
|
|
5469
|
+
color: "white",
|
|
5470
|
+
border: "none",
|
|
5471
|
+
fontWeight: 600,
|
|
5472
|
+
fontSize: "16px",
|
|
5473
|
+
cursor: "pointer",
|
|
5474
|
+
marginTop: "8px"
|
|
5475
|
+
},
|
|
5476
|
+
children: "Done"
|
|
5477
|
+
}
|
|
5478
|
+
)
|
|
5479
|
+
]
|
|
5480
|
+
}
|
|
5481
|
+
) : null;
|
|
5482
|
+
const PercentageButton = ({ percentage, isSelected, onClick }) => {
|
|
5483
|
+
const getFillLevel = () => {
|
|
5484
|
+
if (percentage === 0) return "empty";
|
|
5485
|
+
if (percentage === 25) return "quarter";
|
|
5486
|
+
if (percentage === 50) return "half";
|
|
5487
|
+
if (percentage === 75) return "three-quarter";
|
|
5488
|
+
return "full";
|
|
5489
|
+
};
|
|
5490
|
+
const fillLevel = getFillLevel();
|
|
5491
|
+
const size = 20;
|
|
5492
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5493
|
+
"button",
|
|
5494
|
+
{
|
|
5495
|
+
onClick,
|
|
5496
|
+
style: {
|
|
5497
|
+
width: size,
|
|
5498
|
+
height: size,
|
|
5499
|
+
borderRadius: "50%",
|
|
5500
|
+
border: `2px solid ${isSelected ? theme.colors.primary : "#d1d5db"}`,
|
|
5501
|
+
backgroundColor: "transparent",
|
|
5502
|
+
cursor: "pointer",
|
|
5503
|
+
padding: 0,
|
|
5504
|
+
position: "relative",
|
|
5505
|
+
overflow: "hidden"
|
|
5506
|
+
},
|
|
5507
|
+
title: `${percentage}%`,
|
|
5508
|
+
children: fillLevel === "full" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5509
|
+
"div",
|
|
5510
|
+
{
|
|
5511
|
+
style: {
|
|
5512
|
+
position: "absolute",
|
|
5513
|
+
inset: 0,
|
|
5514
|
+
backgroundColor: theme.colors.primary,
|
|
5515
|
+
borderRadius: "50%"
|
|
5516
|
+
}
|
|
5517
|
+
}
|
|
5518
|
+
) : fillLevel !== "empty" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5519
|
+
"div",
|
|
5520
|
+
{
|
|
5521
|
+
style: {
|
|
5522
|
+
position: "absolute",
|
|
5523
|
+
bottom: 0,
|
|
5524
|
+
left: 0,
|
|
5525
|
+
right: 0,
|
|
5526
|
+
height: fillLevel === "quarter" ? "25%" : fillLevel === "half" ? "50%" : "75%",
|
|
5527
|
+
backgroundColor: "#9ca3af"
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5530
|
+
)
|
|
5531
|
+
}
|
|
5532
|
+
);
|
|
5533
|
+
};
|
|
5534
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5535
|
+
SpiceModalShell,
|
|
5536
|
+
{
|
|
5537
|
+
isOpen,
|
|
5538
|
+
onClose,
|
|
5539
|
+
title: "Deposit to Spicenet",
|
|
5540
|
+
subtitle,
|
|
5541
|
+
theme,
|
|
5542
|
+
maxWidth: "480px",
|
|
5543
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "0 24px 24px 24px", position: "relative" }, children: [
|
|
5544
|
+
successOverlay,
|
|
5545
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
5546
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5547
|
+
"div",
|
|
5548
|
+
{
|
|
5549
|
+
style: {
|
|
5550
|
+
display: "flex",
|
|
5551
|
+
alignItems: "center",
|
|
5552
|
+
gap: "6px",
|
|
5553
|
+
marginBottom: "12px"
|
|
5554
|
+
},
|
|
5555
|
+
children: [
|
|
5556
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", color: "#6b7280" }, children: "\u25CE" }),
|
|
5557
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5558
|
+
"label",
|
|
5559
|
+
{
|
|
5560
|
+
style: {
|
|
5561
|
+
fontSize: "14px",
|
|
5562
|
+
fontWeight: 500,
|
|
5563
|
+
color: "#374151"
|
|
5564
|
+
},
|
|
5565
|
+
children: "Select Assets to Deposit"
|
|
5566
|
+
}
|
|
5567
|
+
)
|
|
5568
|
+
]
|
|
5569
|
+
}
|
|
5570
|
+
),
|
|
5571
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: assets.map((asset) => {
|
|
5572
|
+
const isSelected = selectedAssets.has(asset.address);
|
|
5573
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5574
|
+
"button",
|
|
5575
|
+
{
|
|
5576
|
+
onClick: () => toggleAssetSelection(asset),
|
|
5577
|
+
style: {
|
|
5578
|
+
padding: "8px 16px",
|
|
5579
|
+
borderRadius: "8px",
|
|
5580
|
+
border: `2px solid ${isSelected ? theme.colors.primary : "#e5e7eb"}`,
|
|
5581
|
+
backgroundColor: isSelected ? "#FEF2F2" : "white",
|
|
5582
|
+
cursor: "pointer",
|
|
5583
|
+
display: "flex",
|
|
5584
|
+
alignItems: "center",
|
|
5585
|
+
gap: "8px",
|
|
5586
|
+
transition: "all 150ms ease"
|
|
5587
|
+
},
|
|
5588
|
+
children: [
|
|
5589
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5590
|
+
"div",
|
|
5591
|
+
{
|
|
5592
|
+
style: {
|
|
5593
|
+
width: "24px",
|
|
5594
|
+
height: "24px",
|
|
5595
|
+
borderRadius: "50%",
|
|
5596
|
+
backgroundColor: asset.symbol === "USDC" ? "#2775CA" : asset.symbol === "USDT" ? "#26A17B" : "#F7931A",
|
|
5597
|
+
display: "flex",
|
|
5598
|
+
alignItems: "center",
|
|
5599
|
+
justifyContent: "center",
|
|
5600
|
+
color: "white",
|
|
5601
|
+
fontSize: "10px",
|
|
5602
|
+
fontWeight: 700
|
|
5603
|
+
},
|
|
5604
|
+
children: asset.symbol === "USDC" ? "$" : asset.symbol === "USDT" ? "\u20AE" : "\u20BF"
|
|
5605
|
+
}
|
|
5606
|
+
),
|
|
5607
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600, color: "#111827" }, children: asset.symbol }),
|
|
5608
|
+
asset.balanceFormatted !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5609
|
+
"span",
|
|
5610
|
+
{
|
|
5611
|
+
style: {
|
|
5612
|
+
fontSize: "13px",
|
|
5613
|
+
color: "#9ca3af",
|
|
5614
|
+
fontFamily: "monospace"
|
|
5615
|
+
},
|
|
5616
|
+
children: [
|
|
5617
|
+
"(",
|
|
5618
|
+
asset.balanceFormatted.toFixed(4),
|
|
5619
|
+
")"
|
|
5620
|
+
]
|
|
5621
|
+
}
|
|
5622
|
+
)
|
|
5623
|
+
]
|
|
5624
|
+
},
|
|
5625
|
+
asset.address
|
|
5626
|
+
);
|
|
5627
|
+
}) })
|
|
5628
|
+
] }),
|
|
5629
|
+
selectedAssets.size > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5630
|
+
"div",
|
|
5631
|
+
{
|
|
5632
|
+
style: { display: "flex", flexDirection: "column", gap: "16px" },
|
|
5633
|
+
children: Array.from(selectedAssets.values()).map(({ asset, amount }) => {
|
|
5634
|
+
const numericAmount = parseFloat(amount) || 0;
|
|
5635
|
+
const balance = asset.balanceFormatted || 0;
|
|
5636
|
+
const percentage = balance > 0 ? numericAmount / balance * 100 : 0;
|
|
5637
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5638
|
+
"div",
|
|
5639
|
+
{
|
|
5640
|
+
style: {
|
|
5641
|
+
backgroundColor: "#f9fafb",
|
|
5642
|
+
borderRadius: "12px",
|
|
5643
|
+
padding: "16px",
|
|
5644
|
+
border: "1px solid #e5e7eb"
|
|
5645
|
+
},
|
|
5646
|
+
children: [
|
|
5647
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5648
|
+
"div",
|
|
5649
|
+
{
|
|
5650
|
+
style: {
|
|
5651
|
+
display: "flex",
|
|
5652
|
+
justifyContent: "space-between",
|
|
5653
|
+
alignItems: "center",
|
|
5654
|
+
marginBottom: "12px"
|
|
5655
|
+
},
|
|
5656
|
+
children: [
|
|
5657
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5658
|
+
"span",
|
|
5659
|
+
{
|
|
5660
|
+
style: {
|
|
5661
|
+
fontSize: "14px",
|
|
5662
|
+
fontWeight: 500,
|
|
5663
|
+
color: "#374151"
|
|
5664
|
+
},
|
|
5665
|
+
children: [
|
|
5666
|
+
asset.symbol,
|
|
5667
|
+
" Amount"
|
|
5668
|
+
]
|
|
5669
|
+
}
|
|
5670
|
+
),
|
|
5671
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5672
|
+
"div",
|
|
5673
|
+
{
|
|
5674
|
+
style: {
|
|
5675
|
+
display: "flex",
|
|
5676
|
+
alignItems: "center",
|
|
5677
|
+
gap: "8px"
|
|
5678
|
+
},
|
|
5679
|
+
children: [
|
|
5680
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "13px", color: "#6b7280" }, children: [
|
|
5681
|
+
"Balance: ",
|
|
5682
|
+
(asset.balanceFormatted || 0).toFixed(4)
|
|
5683
|
+
] }),
|
|
5684
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5685
|
+
"div",
|
|
5686
|
+
{
|
|
5687
|
+
style: {
|
|
5688
|
+
display: "flex",
|
|
5689
|
+
alignItems: "center",
|
|
5690
|
+
gap: "6px",
|
|
5691
|
+
padding: "4px 10px",
|
|
5692
|
+
backgroundColor: "white",
|
|
5693
|
+
borderRadius: "20px",
|
|
5694
|
+
border: "1px solid #e5e7eb"
|
|
5695
|
+
},
|
|
5696
|
+
children: [
|
|
5697
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5698
|
+
"div",
|
|
5699
|
+
{
|
|
5700
|
+
style: {
|
|
5701
|
+
width: "20px",
|
|
5702
|
+
height: "20px",
|
|
5703
|
+
borderRadius: "50%",
|
|
5704
|
+
backgroundColor: asset.symbol === "USDC" ? "#2775CA" : asset.symbol === "USDT" ? "#26A17B" : "#F7931A",
|
|
5705
|
+
display: "flex",
|
|
5706
|
+
alignItems: "center",
|
|
5707
|
+
justifyContent: "center",
|
|
5708
|
+
color: "white",
|
|
5709
|
+
fontSize: "9px",
|
|
5710
|
+
fontWeight: 700
|
|
5711
|
+
},
|
|
5712
|
+
children: asset.symbol === "USDC" ? "$" : asset.symbol === "USDT" ? "\u20AE" : "\u20BF"
|
|
5713
|
+
}
|
|
5714
|
+
),
|
|
5715
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5716
|
+
"span",
|
|
5717
|
+
{
|
|
5718
|
+
style: {
|
|
5719
|
+
fontSize: "13px",
|
|
5720
|
+
fontWeight: 500,
|
|
5721
|
+
color: "#111827"
|
|
5722
|
+
},
|
|
5723
|
+
children: asset.symbol
|
|
5724
|
+
}
|
|
5725
|
+
)
|
|
5726
|
+
]
|
|
5727
|
+
}
|
|
5728
|
+
)
|
|
5729
|
+
]
|
|
5730
|
+
}
|
|
5731
|
+
)
|
|
5732
|
+
]
|
|
5733
|
+
}
|
|
5734
|
+
),
|
|
5735
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5736
|
+
"div",
|
|
5737
|
+
{
|
|
5738
|
+
style: {
|
|
5739
|
+
display: "flex",
|
|
5740
|
+
alignItems: "center",
|
|
5741
|
+
gap: "12px"
|
|
5742
|
+
},
|
|
5743
|
+
children: [
|
|
5744
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5745
|
+
"input",
|
|
5746
|
+
{
|
|
5747
|
+
type: "text",
|
|
5748
|
+
value: amount,
|
|
5749
|
+
onChange: (e) => handleAmountChange(asset.address, e.target.value),
|
|
5750
|
+
placeholder: "0.00",
|
|
5751
|
+
style: {
|
|
5752
|
+
flex: 1,
|
|
5753
|
+
fontSize: "32px",
|
|
5754
|
+
fontWeight: 600,
|
|
5755
|
+
color: amount ? "#111827" : "#d1d5db",
|
|
5756
|
+
backgroundColor: "transparent",
|
|
5757
|
+
border: "none",
|
|
5758
|
+
outline: "none",
|
|
5759
|
+
padding: 0,
|
|
5760
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5763
|
+
),
|
|
5764
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5765
|
+
"div",
|
|
5766
|
+
{
|
|
5767
|
+
style: {
|
|
5768
|
+
display: "flex",
|
|
5769
|
+
gap: "6px",
|
|
5770
|
+
alignItems: "center"
|
|
5771
|
+
},
|
|
5772
|
+
children: [0, 25, 50, 75, 100].map((pct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5773
|
+
PercentageButton,
|
|
5774
|
+
{
|
|
5775
|
+
percentage: pct,
|
|
5776
|
+
isSelected: Math.abs(percentage - pct) < 1,
|
|
5777
|
+
onClick: () => handlePercentageClick(asset.address, pct)
|
|
5778
|
+
},
|
|
5779
|
+
pct
|
|
5780
|
+
))
|
|
5781
|
+
}
|
|
5782
|
+
)
|
|
5783
|
+
]
|
|
5784
|
+
}
|
|
5785
|
+
)
|
|
5786
|
+
]
|
|
5787
|
+
},
|
|
5788
|
+
asset.address
|
|
5789
|
+
);
|
|
5790
|
+
})
|
|
5791
|
+
}
|
|
5792
|
+
),
|
|
5793
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5794
|
+
"div",
|
|
5795
|
+
{
|
|
5796
|
+
style: {
|
|
5797
|
+
padding: "12px",
|
|
5798
|
+
backgroundColor: "#fef2f2",
|
|
5799
|
+
border: "1px solid #fecaca",
|
|
5800
|
+
borderRadius: "8px",
|
|
5801
|
+
marginTop: "16px"
|
|
5802
|
+
},
|
|
5803
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "14px", color: "#dc2626", margin: 0 }, children: error })
|
|
5804
|
+
}
|
|
5805
|
+
),
|
|
5806
|
+
!isSuccess && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5807
|
+
"button",
|
|
5808
|
+
{
|
|
5809
|
+
onClick: executeDeposit,
|
|
5810
|
+
disabled: !canDeposit,
|
|
5811
|
+
style: {
|
|
5812
|
+
width: "100%",
|
|
5813
|
+
padding: "16px",
|
|
5814
|
+
borderRadius: "8px",
|
|
5815
|
+
backgroundColor: canDeposit ? theme.colors.primary : "#e5e7eb",
|
|
5816
|
+
color: canDeposit ? "white" : "#9ca3af",
|
|
5817
|
+
border: "none",
|
|
5818
|
+
fontWeight: 600,
|
|
5819
|
+
fontSize: "15px",
|
|
5820
|
+
letterSpacing: "0.5px",
|
|
5821
|
+
cursor: canDeposit ? "pointer" : "not-allowed",
|
|
5822
|
+
marginTop: "20px",
|
|
5823
|
+
display: "flex",
|
|
5824
|
+
alignItems: "center",
|
|
5825
|
+
justifyContent: "center",
|
|
5826
|
+
gap: "8px",
|
|
5827
|
+
transition: "all 150ms ease"
|
|
5828
|
+
},
|
|
5829
|
+
children: isExecuting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5830
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5831
|
+
"div",
|
|
5832
|
+
{
|
|
5833
|
+
style: {
|
|
5834
|
+
width: "18px",
|
|
5835
|
+
height: "18px",
|
|
5836
|
+
border: "2px solid white",
|
|
5837
|
+
borderTopColor: "transparent",
|
|
5838
|
+
borderRadius: "50%",
|
|
5839
|
+
animation: "spin 1s linear infinite"
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
),
|
|
5843
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "PROCESSING..." })
|
|
5844
|
+
] }) : isWalletClientLoading ? "CONNECTING WALLET..." : !walletClient ? "WALLET NOT CONNECTED" : selectedAssets.size === 0 ? "SELECT ASSETS" : !Array.from(selectedAssets.values()).every((s) => s.amount) ? "ENTER AMOUNTS" : "DEPOSIT"
|
|
5845
|
+
}
|
|
5846
|
+
),
|
|
5847
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
5848
|
+
@keyframes spin {
|
|
5849
|
+
from { transform: rotate(0deg); }
|
|
5850
|
+
to { transform: rotate(360deg); }
|
|
5851
|
+
}
|
|
5852
|
+
` })
|
|
5853
|
+
] })
|
|
5854
|
+
}
|
|
5855
|
+
);
|
|
5856
|
+
};
|
|
5857
|
+
|
|
5087
5858
|
/**
|
|
5088
5859
|
* @license lucide-react v0.383.0 - ISC
|
|
5089
5860
|
*
|
|
@@ -12654,6 +13425,7 @@ const useDepositInput = () => {
|
|
|
12654
13425
|
};
|
|
12655
13426
|
|
|
12656
13427
|
exports.ConnectWalletModal = ConnectWalletModal;
|
|
13428
|
+
exports.CrossChainDepositModal = CrossChainDepositModal;
|
|
12657
13429
|
exports.DepositModal = DepositModal;
|
|
12658
13430
|
exports.DepositWidget = DepositWidget;
|
|
12659
13431
|
exports.DepositWidgetModal = DepositWidgetModal;
|