@spicenet-io/spiceflow-ui 1.8.5 → 1.8.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/components/DepositWidget/DepositStatusPanel.d.ts +12 -0
- package/dist/index.cjs.js +223 -61
- package/dist/index.js +224 -62
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IntentStatus } from "../../types/status";
|
|
3
|
+
import { Theme } from "../../types/theme";
|
|
4
|
+
interface DepositStatusPanelProps {
|
|
5
|
+
intentStatus: IntentStatus;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onRetry?: () => void;
|
|
8
|
+
onNewDeposit?: () => void;
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
}
|
|
11
|
+
export declare const DepositStatusPanel: React.FC<DepositStatusPanelProps>;
|
|
12
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -4083,6 +4083,211 @@ const useSpiceAssets = ({
|
|
|
4083
4083
|
};
|
|
4084
4084
|
};
|
|
4085
4085
|
|
|
4086
|
+
const DepositStatusPanel = ({
|
|
4087
|
+
intentStatus,
|
|
4088
|
+
onClose,
|
|
4089
|
+
onRetry,
|
|
4090
|
+
onNewDeposit,
|
|
4091
|
+
theme: providedTheme
|
|
4092
|
+
}) => {
|
|
4093
|
+
const theme = providedTheme || Button.createTheme("dark");
|
|
4094
|
+
const containerStyles = {
|
|
4095
|
+
width: "100%",
|
|
4096
|
+
maxWidth: "28rem",
|
|
4097
|
+
margin: "0 auto",
|
|
4098
|
+
backgroundColor: theme.colors.background,
|
|
4099
|
+
border: `1px solid ${theme.colors.border}`,
|
|
4100
|
+
borderRadius: theme.borderRadius.lg,
|
|
4101
|
+
padding: theme.spacing.lg,
|
|
4102
|
+
color: theme.colors.text
|
|
4103
|
+
};
|
|
4104
|
+
const headerStyles = {
|
|
4105
|
+
textAlign: "center",
|
|
4106
|
+
marginBottom: theme.spacing.lg
|
|
4107
|
+
};
|
|
4108
|
+
const iconContainerStyles = {
|
|
4109
|
+
width: "5rem",
|
|
4110
|
+
height: "5rem",
|
|
4111
|
+
margin: "0 auto",
|
|
4112
|
+
backgroundColor: theme.colors.surface,
|
|
4113
|
+
borderRadius: "50%",
|
|
4114
|
+
display: "flex",
|
|
4115
|
+
alignItems: "center",
|
|
4116
|
+
justifyContent: "center",
|
|
4117
|
+
border: `2px solid ${theme.colors.border}`,
|
|
4118
|
+
marginBottom: theme.spacing.md
|
|
4119
|
+
};
|
|
4120
|
+
const titleStyles = {
|
|
4121
|
+
fontSize: theme.typography.fontSize.lg,
|
|
4122
|
+
fontWeight: theme.typography.fontWeight.semibold,
|
|
4123
|
+
color: theme.colors.text,
|
|
4124
|
+
marginBottom: theme.spacing.sm
|
|
4125
|
+
};
|
|
4126
|
+
const descriptionStyles = {
|
|
4127
|
+
fontSize: theme.typography.fontSize.sm,
|
|
4128
|
+
color: theme.colors.textMuted
|
|
4129
|
+
};
|
|
4130
|
+
const buttonContainerStyles = {
|
|
4131
|
+
display: "flex",
|
|
4132
|
+
flexDirection: "column",
|
|
4133
|
+
gap: theme.spacing.sm,
|
|
4134
|
+
marginTop: theme.spacing.lg
|
|
4135
|
+
};
|
|
4136
|
+
const getStatusContent = () => {
|
|
4137
|
+
switch (intentStatus.overallStatus) {
|
|
4138
|
+
case "success":
|
|
4139
|
+
return {
|
|
4140
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4141
|
+
"svg",
|
|
4142
|
+
{
|
|
4143
|
+
width: "32",
|
|
4144
|
+
height: "32",
|
|
4145
|
+
fill: "none",
|
|
4146
|
+
stroke: theme.colors.success,
|
|
4147
|
+
viewBox: "0 0 24 24",
|
|
4148
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4149
|
+
"path",
|
|
4150
|
+
{
|
|
4151
|
+
strokeLinecap: "round",
|
|
4152
|
+
strokeLinejoin: "round",
|
|
4153
|
+
strokeWidth: 2,
|
|
4154
|
+
d: "M5 13l4 4L19 7"
|
|
4155
|
+
}
|
|
4156
|
+
)
|
|
4157
|
+
}
|
|
4158
|
+
),
|
|
4159
|
+
title: "Deposit Completed!",
|
|
4160
|
+
description: "Your tokens have been successfully deposited.",
|
|
4161
|
+
borderColor: theme.colors.success
|
|
4162
|
+
};
|
|
4163
|
+
case "failed":
|
|
4164
|
+
return {
|
|
4165
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4166
|
+
"svg",
|
|
4167
|
+
{
|
|
4168
|
+
width: "32",
|
|
4169
|
+
height: "32",
|
|
4170
|
+
fill: "none",
|
|
4171
|
+
stroke: theme.colors.error,
|
|
4172
|
+
viewBox: "0 0 24 24",
|
|
4173
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4174
|
+
"path",
|
|
4175
|
+
{
|
|
4176
|
+
strokeLinecap: "round",
|
|
4177
|
+
strokeLinejoin: "round",
|
|
4178
|
+
strokeWidth: 2,
|
|
4179
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
4180
|
+
}
|
|
4181
|
+
)
|
|
4182
|
+
}
|
|
4183
|
+
),
|
|
4184
|
+
title: "Deposit Failed",
|
|
4185
|
+
description: "Something went wrong. Please try again.",
|
|
4186
|
+
borderColor: theme.colors.error
|
|
4187
|
+
};
|
|
4188
|
+
default:
|
|
4189
|
+
return {
|
|
4190
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4191
|
+
"div",
|
|
4192
|
+
{
|
|
4193
|
+
style: {
|
|
4194
|
+
width: "2rem",
|
|
4195
|
+
height: "2rem",
|
|
4196
|
+
border: `3px solid ${theme.colors.primary}`,
|
|
4197
|
+
borderTop: "3px solid transparent",
|
|
4198
|
+
borderRadius: "50%",
|
|
4199
|
+
animation: "spin 1s linear infinite"
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
),
|
|
4203
|
+
title: "Processing Deposit",
|
|
4204
|
+
description: "Please wait while your deposit is being processed...",
|
|
4205
|
+
borderColor: theme.colors.primary
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
};
|
|
4209
|
+
const statusContent = getStatusContent();
|
|
4210
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: containerStyles, children: [
|
|
4211
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
4212
|
+
@keyframes spin {
|
|
4213
|
+
0% { transform: rotate(0deg); }
|
|
4214
|
+
100% { transform: rotate(360deg); }
|
|
4215
|
+
}
|
|
4216
|
+
` }),
|
|
4217
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: headerStyles, children: [
|
|
4218
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4219
|
+
"div",
|
|
4220
|
+
{
|
|
4221
|
+
style: {
|
|
4222
|
+
...iconContainerStyles,
|
|
4223
|
+
borderColor: statusContent.borderColor
|
|
4224
|
+
},
|
|
4225
|
+
children: statusContent.icon
|
|
4226
|
+
}
|
|
4227
|
+
),
|
|
4228
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: titleStyles, children: statusContent.title }),
|
|
4229
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: descriptionStyles, children: statusContent.description })
|
|
4230
|
+
] }),
|
|
4231
|
+
intentStatus.overallStatus === "processing" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4232
|
+
"div",
|
|
4233
|
+
{
|
|
4234
|
+
style: {
|
|
4235
|
+
backgroundColor: theme.colors.surface,
|
|
4236
|
+
borderRadius: theme.borderRadius.md,
|
|
4237
|
+
padding: theme.spacing.md,
|
|
4238
|
+
marginBottom: theme.spacing.md
|
|
4239
|
+
},
|
|
4240
|
+
children: [
|
|
4241
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4242
|
+
"div",
|
|
4243
|
+
{
|
|
4244
|
+
style: {
|
|
4245
|
+
height: "4px",
|
|
4246
|
+
backgroundColor: `${theme.colors.primary}30`,
|
|
4247
|
+
borderRadius: "2px",
|
|
4248
|
+
overflow: "hidden"
|
|
4249
|
+
},
|
|
4250
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4251
|
+
"div",
|
|
4252
|
+
{
|
|
4253
|
+
style: {
|
|
4254
|
+
width: "30%",
|
|
4255
|
+
height: "100%",
|
|
4256
|
+
backgroundColor: theme.colors.primary,
|
|
4257
|
+
borderRadius: "2px",
|
|
4258
|
+
animation: "progress 1.5s ease-in-out infinite"
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
)
|
|
4262
|
+
}
|
|
4263
|
+
),
|
|
4264
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
4265
|
+
@keyframes progress {
|
|
4266
|
+
0% { transform: translateX(-100%); width: 30%; }
|
|
4267
|
+
50% { width: 60%; }
|
|
4268
|
+
100% { transform: translateX(400%); width: 30%; }
|
|
4269
|
+
}
|
|
4270
|
+
` })
|
|
4271
|
+
]
|
|
4272
|
+
}
|
|
4273
|
+
),
|
|
4274
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: buttonContainerStyles, children: [
|
|
4275
|
+
intentStatus.overallStatus === "success" && onNewDeposit && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4276
|
+
Button.Button,
|
|
4277
|
+
{
|
|
4278
|
+
variant: "success",
|
|
4279
|
+
fullWidth: true,
|
|
4280
|
+
onClick: onNewDeposit,
|
|
4281
|
+
theme,
|
|
4282
|
+
children: "New Deposit"
|
|
4283
|
+
}
|
|
4284
|
+
),
|
|
4285
|
+
intentStatus.overallStatus === "failed" && onRetry && /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { variant: "error", fullWidth: true, onClick: onRetry, theme, children: "Try Again" }),
|
|
4286
|
+
intentStatus.overallStatus === "processing" && /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { variant: "ghost", fullWidth: true, onClick: onClose, theme, children: "Cancel" })
|
|
4287
|
+
] })
|
|
4288
|
+
] });
|
|
4289
|
+
};
|
|
4290
|
+
|
|
4086
4291
|
const DepositWidget = ({
|
|
4087
4292
|
depositBatches,
|
|
4088
4293
|
tokenAddress,
|
|
@@ -4186,62 +4391,7 @@ const DepositWidget = ({
|
|
|
4186
4391
|
setIsExecuting(true);
|
|
4187
4392
|
setError(null);
|
|
4188
4393
|
try {
|
|
4189
|
-
const
|
|
4190
|
-
selectedDepositAsset.asset.chainId
|
|
4191
|
-
);
|
|
4192
|
-
const depositRecentBlock = await depositClient.getBlockNumber();
|
|
4193
|
-
let depositAssetBatch;
|
|
4194
|
-
if (selectedDepositAsset.asset.isNative) {
|
|
4195
|
-
depositAssetBatch = {
|
|
4196
|
-
chainId: selectedDepositAsset.asset.chainId,
|
|
4197
|
-
recentBlock: depositRecentBlock,
|
|
4198
|
-
calls: [
|
|
4199
|
-
{
|
|
4200
|
-
to: "0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
4201
|
-
value: viem.parseEther(selectedDepositAsset.amount),
|
|
4202
|
-
data: "0x"
|
|
4203
|
-
}
|
|
4204
|
-
]
|
|
4205
|
-
};
|
|
4206
|
-
} else {
|
|
4207
|
-
depositAssetBatch = {
|
|
4208
|
-
chainId: selectedDepositAsset.asset.chainId,
|
|
4209
|
-
recentBlock: depositRecentBlock,
|
|
4210
|
-
calls: [
|
|
4211
|
-
{
|
|
4212
|
-
to: selectedDepositAsset.asset.address,
|
|
4213
|
-
value: BigInt(0),
|
|
4214
|
-
data: viem.encodeFunctionData({
|
|
4215
|
-
abi: viem.erc20Abi,
|
|
4216
|
-
functionName: "approve",
|
|
4217
|
-
args: [
|
|
4218
|
-
"0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
4219
|
-
viem.parseUnits(
|
|
4220
|
-
selectedDepositAsset.amount,
|
|
4221
|
-
selectedDepositAsset.asset.decimals
|
|
4222
|
-
)
|
|
4223
|
-
]
|
|
4224
|
-
})
|
|
4225
|
-
},
|
|
4226
|
-
{
|
|
4227
|
-
to: selectedDepositAsset.asset.address,
|
|
4228
|
-
value: BigInt(0),
|
|
4229
|
-
data: viem.encodeFunctionData({
|
|
4230
|
-
abi: viem.erc20Abi,
|
|
4231
|
-
functionName: "transfer",
|
|
4232
|
-
args: [
|
|
4233
|
-
"0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
4234
|
-
viem.parseUnits(
|
|
4235
|
-
selectedDepositAsset.amount,
|
|
4236
|
-
selectedDepositAsset.asset.decimals
|
|
4237
|
-
)
|
|
4238
|
-
]
|
|
4239
|
-
})
|
|
4240
|
-
}
|
|
4241
|
-
]
|
|
4242
|
-
};
|
|
4243
|
-
}
|
|
4244
|
-
const allChainBatches = [depositAssetBatch, ...depositBatches];
|
|
4394
|
+
const allChainBatches = [...depositBatches];
|
|
4245
4395
|
const uniqueChainIds = [
|
|
4246
4396
|
...new Set(allChainBatches.map((batch) => batch.chainId))
|
|
4247
4397
|
];
|
|
@@ -4281,13 +4431,27 @@ const DepositWidget = ({
|
|
|
4281
4431
|
tokenAmount: viem.parseUnits(
|
|
4282
4432
|
selectedDepositAsset.amount,
|
|
4283
4433
|
tokenDecimals
|
|
4284
|
-
)
|
|
4434
|
+
),
|
|
4435
|
+
receiver: address
|
|
4285
4436
|
}
|
|
4286
4437
|
]
|
|
4287
4438
|
]
|
|
4288
4439
|
};
|
|
4289
4440
|
const result = await relayerService.submitTransaction(submitRequest);
|
|
4290
4441
|
if (result) {
|
|
4442
|
+
const withdrawalAmount = viem.parseUnits(
|
|
4443
|
+
selectedDepositAsset.amount,
|
|
4444
|
+
selectedDepositAsset.asset.decimals
|
|
4445
|
+
);
|
|
4446
|
+
await relayerService.submitSpiceDeposit({
|
|
4447
|
+
user: address,
|
|
4448
|
+
txHash: result.hash,
|
|
4449
|
+
sender: address,
|
|
4450
|
+
tokenAddress: selectedDepositAsset.asset.address,
|
|
4451
|
+
chainId: selectedDepositAsset.asset.chainId,
|
|
4452
|
+
amount: withdrawalAmount.toString(),
|
|
4453
|
+
isDeposit: false
|
|
4454
|
+
});
|
|
4291
4455
|
const getChainName = (chainId) => {
|
|
4292
4456
|
return `Chain ${chainId}`;
|
|
4293
4457
|
};
|
|
@@ -4330,7 +4494,7 @@ const DepositWidget = ({
|
|
|
4330
4494
|
};
|
|
4331
4495
|
if (intentStatus) {
|
|
4332
4496
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4333
|
-
|
|
4497
|
+
DepositStatusPanel,
|
|
4334
4498
|
{
|
|
4335
4499
|
intentStatus,
|
|
4336
4500
|
onClose: clearStatus,
|
|
@@ -4338,13 +4502,11 @@ const DepositWidget = ({
|
|
|
4338
4502
|
clearStatus();
|
|
4339
4503
|
handleDeposit();
|
|
4340
4504
|
},
|
|
4341
|
-
|
|
4342
|
-
onNewTx: () => {
|
|
4505
|
+
onNewDeposit: () => {
|
|
4343
4506
|
clearStatus();
|
|
4344
4507
|
setSelectedDepositAsset(null);
|
|
4345
4508
|
refreshSpiceAssets();
|
|
4346
4509
|
},
|
|
4347
|
-
explorerUrlBuilder: (chainId, txHash) => getExplorerUrl(chainId, txHash),
|
|
4348
4510
|
theme
|
|
4349
4511
|
}
|
|
4350
4512
|
) });
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { defineChain, createPublicClient, http, isAddress, getAddress, parseEther,
|
|
2
|
+
import { defineChain, createPublicClient, http, isAddress, getAddress, parseEther, parseUnits, 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';
|
|
@@ -4081,6 +4081,211 @@ const useSpiceAssets = ({
|
|
|
4081
4081
|
};
|
|
4082
4082
|
};
|
|
4083
4083
|
|
|
4084
|
+
const DepositStatusPanel = ({
|
|
4085
|
+
intentStatus,
|
|
4086
|
+
onClose,
|
|
4087
|
+
onRetry,
|
|
4088
|
+
onNewDeposit,
|
|
4089
|
+
theme: providedTheme
|
|
4090
|
+
}) => {
|
|
4091
|
+
const theme = providedTheme || createTheme("dark");
|
|
4092
|
+
const containerStyles = {
|
|
4093
|
+
width: "100%",
|
|
4094
|
+
maxWidth: "28rem",
|
|
4095
|
+
margin: "0 auto",
|
|
4096
|
+
backgroundColor: theme.colors.background,
|
|
4097
|
+
border: `1px solid ${theme.colors.border}`,
|
|
4098
|
+
borderRadius: theme.borderRadius.lg,
|
|
4099
|
+
padding: theme.spacing.lg,
|
|
4100
|
+
color: theme.colors.text
|
|
4101
|
+
};
|
|
4102
|
+
const headerStyles = {
|
|
4103
|
+
textAlign: "center",
|
|
4104
|
+
marginBottom: theme.spacing.lg
|
|
4105
|
+
};
|
|
4106
|
+
const iconContainerStyles = {
|
|
4107
|
+
width: "5rem",
|
|
4108
|
+
height: "5rem",
|
|
4109
|
+
margin: "0 auto",
|
|
4110
|
+
backgroundColor: theme.colors.surface,
|
|
4111
|
+
borderRadius: "50%",
|
|
4112
|
+
display: "flex",
|
|
4113
|
+
alignItems: "center",
|
|
4114
|
+
justifyContent: "center",
|
|
4115
|
+
border: `2px solid ${theme.colors.border}`,
|
|
4116
|
+
marginBottom: theme.spacing.md
|
|
4117
|
+
};
|
|
4118
|
+
const titleStyles = {
|
|
4119
|
+
fontSize: theme.typography.fontSize.lg,
|
|
4120
|
+
fontWeight: theme.typography.fontWeight.semibold,
|
|
4121
|
+
color: theme.colors.text,
|
|
4122
|
+
marginBottom: theme.spacing.sm
|
|
4123
|
+
};
|
|
4124
|
+
const descriptionStyles = {
|
|
4125
|
+
fontSize: theme.typography.fontSize.sm,
|
|
4126
|
+
color: theme.colors.textMuted
|
|
4127
|
+
};
|
|
4128
|
+
const buttonContainerStyles = {
|
|
4129
|
+
display: "flex",
|
|
4130
|
+
flexDirection: "column",
|
|
4131
|
+
gap: theme.spacing.sm,
|
|
4132
|
+
marginTop: theme.spacing.lg
|
|
4133
|
+
};
|
|
4134
|
+
const getStatusContent = () => {
|
|
4135
|
+
switch (intentStatus.overallStatus) {
|
|
4136
|
+
case "success":
|
|
4137
|
+
return {
|
|
4138
|
+
icon: /* @__PURE__ */ jsx(
|
|
4139
|
+
"svg",
|
|
4140
|
+
{
|
|
4141
|
+
width: "32",
|
|
4142
|
+
height: "32",
|
|
4143
|
+
fill: "none",
|
|
4144
|
+
stroke: theme.colors.success,
|
|
4145
|
+
viewBox: "0 0 24 24",
|
|
4146
|
+
children: /* @__PURE__ */ jsx(
|
|
4147
|
+
"path",
|
|
4148
|
+
{
|
|
4149
|
+
strokeLinecap: "round",
|
|
4150
|
+
strokeLinejoin: "round",
|
|
4151
|
+
strokeWidth: 2,
|
|
4152
|
+
d: "M5 13l4 4L19 7"
|
|
4153
|
+
}
|
|
4154
|
+
)
|
|
4155
|
+
}
|
|
4156
|
+
),
|
|
4157
|
+
title: "Deposit Completed!",
|
|
4158
|
+
description: "Your tokens have been successfully deposited.",
|
|
4159
|
+
borderColor: theme.colors.success
|
|
4160
|
+
};
|
|
4161
|
+
case "failed":
|
|
4162
|
+
return {
|
|
4163
|
+
icon: /* @__PURE__ */ jsx(
|
|
4164
|
+
"svg",
|
|
4165
|
+
{
|
|
4166
|
+
width: "32",
|
|
4167
|
+
height: "32",
|
|
4168
|
+
fill: "none",
|
|
4169
|
+
stroke: theme.colors.error,
|
|
4170
|
+
viewBox: "0 0 24 24",
|
|
4171
|
+
children: /* @__PURE__ */ jsx(
|
|
4172
|
+
"path",
|
|
4173
|
+
{
|
|
4174
|
+
strokeLinecap: "round",
|
|
4175
|
+
strokeLinejoin: "round",
|
|
4176
|
+
strokeWidth: 2,
|
|
4177
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
4178
|
+
}
|
|
4179
|
+
)
|
|
4180
|
+
}
|
|
4181
|
+
),
|
|
4182
|
+
title: "Deposit Failed",
|
|
4183
|
+
description: "Something went wrong. Please try again.",
|
|
4184
|
+
borderColor: theme.colors.error
|
|
4185
|
+
};
|
|
4186
|
+
default:
|
|
4187
|
+
return {
|
|
4188
|
+
icon: /* @__PURE__ */ jsx(
|
|
4189
|
+
"div",
|
|
4190
|
+
{
|
|
4191
|
+
style: {
|
|
4192
|
+
width: "2rem",
|
|
4193
|
+
height: "2rem",
|
|
4194
|
+
border: `3px solid ${theme.colors.primary}`,
|
|
4195
|
+
borderTop: "3px solid transparent",
|
|
4196
|
+
borderRadius: "50%",
|
|
4197
|
+
animation: "spin 1s linear infinite"
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
),
|
|
4201
|
+
title: "Processing Deposit",
|
|
4202
|
+
description: "Please wait while your deposit is being processed...",
|
|
4203
|
+
borderColor: theme.colors.primary
|
|
4204
|
+
};
|
|
4205
|
+
}
|
|
4206
|
+
};
|
|
4207
|
+
const statusContent = getStatusContent();
|
|
4208
|
+
return /* @__PURE__ */ jsxs("div", { style: containerStyles, children: [
|
|
4209
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
4210
|
+
@keyframes spin {
|
|
4211
|
+
0% { transform: rotate(0deg); }
|
|
4212
|
+
100% { transform: rotate(360deg); }
|
|
4213
|
+
}
|
|
4214
|
+
` }),
|
|
4215
|
+
/* @__PURE__ */ jsxs("div", { style: headerStyles, children: [
|
|
4216
|
+
/* @__PURE__ */ jsx(
|
|
4217
|
+
"div",
|
|
4218
|
+
{
|
|
4219
|
+
style: {
|
|
4220
|
+
...iconContainerStyles,
|
|
4221
|
+
borderColor: statusContent.borderColor
|
|
4222
|
+
},
|
|
4223
|
+
children: statusContent.icon
|
|
4224
|
+
}
|
|
4225
|
+
),
|
|
4226
|
+
/* @__PURE__ */ jsx("h3", { style: titleStyles, children: statusContent.title }),
|
|
4227
|
+
/* @__PURE__ */ jsx("p", { style: descriptionStyles, children: statusContent.description })
|
|
4228
|
+
] }),
|
|
4229
|
+
intentStatus.overallStatus === "processing" && /* @__PURE__ */ jsxs(
|
|
4230
|
+
"div",
|
|
4231
|
+
{
|
|
4232
|
+
style: {
|
|
4233
|
+
backgroundColor: theme.colors.surface,
|
|
4234
|
+
borderRadius: theme.borderRadius.md,
|
|
4235
|
+
padding: theme.spacing.md,
|
|
4236
|
+
marginBottom: theme.spacing.md
|
|
4237
|
+
},
|
|
4238
|
+
children: [
|
|
4239
|
+
/* @__PURE__ */ jsx(
|
|
4240
|
+
"div",
|
|
4241
|
+
{
|
|
4242
|
+
style: {
|
|
4243
|
+
height: "4px",
|
|
4244
|
+
backgroundColor: `${theme.colors.primary}30`,
|
|
4245
|
+
borderRadius: "2px",
|
|
4246
|
+
overflow: "hidden"
|
|
4247
|
+
},
|
|
4248
|
+
children: /* @__PURE__ */ jsx(
|
|
4249
|
+
"div",
|
|
4250
|
+
{
|
|
4251
|
+
style: {
|
|
4252
|
+
width: "30%",
|
|
4253
|
+
height: "100%",
|
|
4254
|
+
backgroundColor: theme.colors.primary,
|
|
4255
|
+
borderRadius: "2px",
|
|
4256
|
+
animation: "progress 1.5s ease-in-out infinite"
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
)
|
|
4260
|
+
}
|
|
4261
|
+
),
|
|
4262
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
4263
|
+
@keyframes progress {
|
|
4264
|
+
0% { transform: translateX(-100%); width: 30%; }
|
|
4265
|
+
50% { width: 60%; }
|
|
4266
|
+
100% { transform: translateX(400%); width: 30%; }
|
|
4267
|
+
}
|
|
4268
|
+
` })
|
|
4269
|
+
]
|
|
4270
|
+
}
|
|
4271
|
+
),
|
|
4272
|
+
/* @__PURE__ */ jsxs("div", { style: buttonContainerStyles, children: [
|
|
4273
|
+
intentStatus.overallStatus === "success" && onNewDeposit && /* @__PURE__ */ jsx(
|
|
4274
|
+
Button,
|
|
4275
|
+
{
|
|
4276
|
+
variant: "success",
|
|
4277
|
+
fullWidth: true,
|
|
4278
|
+
onClick: onNewDeposit,
|
|
4279
|
+
theme,
|
|
4280
|
+
children: "New Deposit"
|
|
4281
|
+
}
|
|
4282
|
+
),
|
|
4283
|
+
intentStatus.overallStatus === "failed" && onRetry && /* @__PURE__ */ jsx(Button, { variant: "error", fullWidth: true, onClick: onRetry, theme, children: "Try Again" }),
|
|
4284
|
+
intentStatus.overallStatus === "processing" && /* @__PURE__ */ jsx(Button, { variant: "ghost", fullWidth: true, onClick: onClose, theme, children: "Cancel" })
|
|
4285
|
+
] })
|
|
4286
|
+
] });
|
|
4287
|
+
};
|
|
4288
|
+
|
|
4084
4289
|
const DepositWidget = ({
|
|
4085
4290
|
depositBatches,
|
|
4086
4291
|
tokenAddress,
|
|
@@ -4184,62 +4389,7 @@ const DepositWidget = ({
|
|
|
4184
4389
|
setIsExecuting(true);
|
|
4185
4390
|
setError(null);
|
|
4186
4391
|
try {
|
|
4187
|
-
const
|
|
4188
|
-
selectedDepositAsset.asset.chainId
|
|
4189
|
-
);
|
|
4190
|
-
const depositRecentBlock = await depositClient.getBlockNumber();
|
|
4191
|
-
let depositAssetBatch;
|
|
4192
|
-
if (selectedDepositAsset.asset.isNative) {
|
|
4193
|
-
depositAssetBatch = {
|
|
4194
|
-
chainId: selectedDepositAsset.asset.chainId,
|
|
4195
|
-
recentBlock: depositRecentBlock,
|
|
4196
|
-
calls: [
|
|
4197
|
-
{
|
|
4198
|
-
to: "0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
4199
|
-
value: parseEther(selectedDepositAsset.amount),
|
|
4200
|
-
data: "0x"
|
|
4201
|
-
}
|
|
4202
|
-
]
|
|
4203
|
-
};
|
|
4204
|
-
} else {
|
|
4205
|
-
depositAssetBatch = {
|
|
4206
|
-
chainId: selectedDepositAsset.asset.chainId,
|
|
4207
|
-
recentBlock: depositRecentBlock,
|
|
4208
|
-
calls: [
|
|
4209
|
-
{
|
|
4210
|
-
to: selectedDepositAsset.asset.address,
|
|
4211
|
-
value: BigInt(0),
|
|
4212
|
-
data: encodeFunctionData({
|
|
4213
|
-
abi: erc20Abi,
|
|
4214
|
-
functionName: "approve",
|
|
4215
|
-
args: [
|
|
4216
|
-
"0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
4217
|
-
parseUnits(
|
|
4218
|
-
selectedDepositAsset.amount,
|
|
4219
|
-
selectedDepositAsset.asset.decimals
|
|
4220
|
-
)
|
|
4221
|
-
]
|
|
4222
|
-
})
|
|
4223
|
-
},
|
|
4224
|
-
{
|
|
4225
|
-
to: selectedDepositAsset.asset.address,
|
|
4226
|
-
value: BigInt(0),
|
|
4227
|
-
data: encodeFunctionData({
|
|
4228
|
-
abi: erc20Abi,
|
|
4229
|
-
functionName: "transfer",
|
|
4230
|
-
args: [
|
|
4231
|
-
"0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",
|
|
4232
|
-
parseUnits(
|
|
4233
|
-
selectedDepositAsset.amount,
|
|
4234
|
-
selectedDepositAsset.asset.decimals
|
|
4235
|
-
)
|
|
4236
|
-
]
|
|
4237
|
-
})
|
|
4238
|
-
}
|
|
4239
|
-
]
|
|
4240
|
-
};
|
|
4241
|
-
}
|
|
4242
|
-
const allChainBatches = [depositAssetBatch, ...depositBatches];
|
|
4392
|
+
const allChainBatches = [...depositBatches];
|
|
4243
4393
|
const uniqueChainIds = [
|
|
4244
4394
|
...new Set(allChainBatches.map((batch) => batch.chainId))
|
|
4245
4395
|
];
|
|
@@ -4279,13 +4429,27 @@ const DepositWidget = ({
|
|
|
4279
4429
|
tokenAmount: parseUnits(
|
|
4280
4430
|
selectedDepositAsset.amount,
|
|
4281
4431
|
tokenDecimals
|
|
4282
|
-
)
|
|
4432
|
+
),
|
|
4433
|
+
receiver: address
|
|
4283
4434
|
}
|
|
4284
4435
|
]
|
|
4285
4436
|
]
|
|
4286
4437
|
};
|
|
4287
4438
|
const result = await relayerService.submitTransaction(submitRequest);
|
|
4288
4439
|
if (result) {
|
|
4440
|
+
const withdrawalAmount = parseUnits(
|
|
4441
|
+
selectedDepositAsset.amount,
|
|
4442
|
+
selectedDepositAsset.asset.decimals
|
|
4443
|
+
);
|
|
4444
|
+
await relayerService.submitSpiceDeposit({
|
|
4445
|
+
user: address,
|
|
4446
|
+
txHash: result.hash,
|
|
4447
|
+
sender: address,
|
|
4448
|
+
tokenAddress: selectedDepositAsset.asset.address,
|
|
4449
|
+
chainId: selectedDepositAsset.asset.chainId,
|
|
4450
|
+
amount: withdrawalAmount.toString(),
|
|
4451
|
+
isDeposit: false
|
|
4452
|
+
});
|
|
4289
4453
|
const getChainName = (chainId) => {
|
|
4290
4454
|
return `Chain ${chainId}`;
|
|
4291
4455
|
};
|
|
@@ -4328,7 +4492,7 @@ const DepositWidget = ({
|
|
|
4328
4492
|
};
|
|
4329
4493
|
if (intentStatus) {
|
|
4330
4494
|
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
|
|
4331
|
-
|
|
4495
|
+
DepositStatusPanel,
|
|
4332
4496
|
{
|
|
4333
4497
|
intentStatus,
|
|
4334
4498
|
onClose: clearStatus,
|
|
@@ -4336,13 +4500,11 @@ const DepositWidget = ({
|
|
|
4336
4500
|
clearStatus();
|
|
4337
4501
|
handleDeposit();
|
|
4338
4502
|
},
|
|
4339
|
-
|
|
4340
|
-
onNewTx: () => {
|
|
4503
|
+
onNewDeposit: () => {
|
|
4341
4504
|
clearStatus();
|
|
4342
4505
|
setSelectedDepositAsset(null);
|
|
4343
4506
|
refreshSpiceAssets();
|
|
4344
4507
|
},
|
|
4345
|
-
explorerUrlBuilder: (chainId, txHash) => getExplorerUrl(chainId, txHash),
|
|
4346
4508
|
theme
|
|
4347
4509
|
}
|
|
4348
4510
|
) });
|