@spicenet-io/spiceflow-ui 1.9.14 → 1.9.15

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.cjs.js CHANGED
@@ -4285,7 +4285,6 @@ const DepositStatusPanel = ({
4285
4285
  };
4286
4286
  if (intentStatus) {
4287
4287
  const { steps, overallStatus } = intentStatus;
4288
- const isProcessing = overallStatus === "processing";
4289
4288
  const isSuccess = overallStatus === "success";
4290
4289
  const isError = overallStatus === "failed";
4291
4290
  const stepWithTxHash = steps.find((step) => step.transactionHash);
@@ -4322,9 +4321,9 @@ const DepositStatusPanel = ({
4322
4321
  display: "flex",
4323
4322
  alignItems: "center",
4324
4323
  gap: "8px",
4325
- cursor: !isProcessing ? "pointer" : "default"
4324
+ cursor: "pointer"
4326
4325
  },
4327
- onClick: !isProcessing ? toggleDetails : void 0,
4326
+ onClick: toggleDetails,
4328
4327
  children: [
4329
4328
  /* @__PURE__ */ jsxRuntime.jsx(
4330
4329
  "span",
@@ -4338,7 +4337,7 @@ const DepositStatusPanel = ({
4338
4337
  children: "Deposit Results"
4339
4338
  }
4340
4339
  ),
4341
- !isProcessing && /* @__PURE__ */ jsxRuntime.jsx(
4340
+ /* @__PURE__ */ jsxRuntime.jsx(
4342
4341
  "svg",
4343
4342
  {
4344
4343
  width: "16",
@@ -4364,7 +4363,7 @@ const DepositStatusPanel = ({
4364
4363
  ]
4365
4364
  }
4366
4365
  ),
4367
- !isProcessing && /* @__PURE__ */ jsxRuntime.jsx(
4366
+ /* @__PURE__ */ jsxRuntime.jsx(
4368
4367
  "button",
4369
4368
  {
4370
4369
  onClick: onClose,
@@ -4393,47 +4392,7 @@ const DepositStatusPanel = ({
4393
4392
  ]
4394
4393
  }
4395
4394
  ),
4396
- isProcessing && /* @__PURE__ */ jsxRuntime.jsxs(
4397
- "div",
4398
- {
4399
- style: {
4400
- display: "flex",
4401
- flexDirection: "column",
4402
- alignItems: "center",
4403
- padding: "24px",
4404
- marginBottom: "16px"
4405
- },
4406
- children: [
4407
- /* @__PURE__ */ jsxRuntime.jsx(
4408
- "div",
4409
- {
4410
- style: {
4411
- width: "48px",
4412
- height: "48px",
4413
- border: "3px solid #e5e7eb",
4414
- borderTopColor: theme.colors.primary,
4415
- borderRadius: "50%",
4416
- animation: "spin 1s linear infinite",
4417
- marginBottom: "16px"
4418
- }
4419
- }
4420
- ),
4421
- /* @__PURE__ */ jsxRuntime.jsx(
4422
- "p",
4423
- {
4424
- style: {
4425
- fontSize: "14px",
4426
- fontWeight: 500,
4427
- color: "#374151",
4428
- margin: 0
4429
- },
4430
- children: "Processing your deposit..."
4431
- }
4432
- )
4433
- ]
4434
- }
4435
- ),
4436
- !isProcessing && /* @__PURE__ */ jsxRuntime.jsx(
4395
+ /* @__PURE__ */ jsxRuntime.jsx(
4437
4396
  "div",
4438
4397
  {
4439
4398
  style: {
@@ -4450,7 +4409,7 @@ const DepositStatusPanel = ({
4450
4409
  )
4451
4410
  }
4452
4411
  ),
4453
- !isProcessing && /* @__PURE__ */ jsxRuntime.jsx(
4412
+ /* @__PURE__ */ jsxRuntime.jsx(
4454
4413
  "div",
4455
4414
  {
4456
4415
  style: {
@@ -4510,7 +4469,7 @@ const DepositStatusPanel = ({
4510
4469
  )
4511
4470
  }
4512
4471
  ),
4513
- !isProcessing && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
4472
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
4514
4473
  isError && onRetry && /* @__PURE__ */ jsxRuntime.jsx(
4515
4474
  "button",
4516
4475
  {
@@ -4561,13 +4520,7 @@ const DepositStatusPanel = ({
4561
4520
  children: "CONTINUE \u2192"
4562
4521
  }
4563
4522
  )
4564
- ] }),
4565
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
4566
- @keyframes spin {
4567
- from { transform: rotate(0deg); }
4568
- to { transform: rotate(360deg); }
4569
- }
4570
- ` })
4523
+ ] })
4571
4524
  ]
4572
4525
  }
4573
4526
  );
@@ -4834,9 +4787,7 @@ const DepositWidget = ({
4834
4787
  provider,
4835
4788
  actions
4836
4789
  } = wallet;
4837
- React.useContext(SpiceFlowProviderContext);
4838
4790
  const [selectedDepositAsset, setSelectedDepositAsset] = React.useState(null);
4839
- const [isPending, startTransition] = React.useTransition();
4840
4791
  const {
4841
4792
  assets: spiceAssets,
4842
4793
  loading: loadingSpiceAssets,
@@ -4851,6 +4802,7 @@ const DepositWidget = ({
4851
4802
  });
4852
4803
  const [isExecuting, setIsExecuting] = React.useState(false);
4853
4804
  const [error, setError] = React.useState(null);
4805
+ const spiceDepositSubmittedRef = React.useRef(null);
4854
4806
  const { intentStatus, startStatusPolling, clearStatus } = useStatus({
4855
4807
  checkStepStatus: (intentId, stepId) => relayerService.checkStepStatus(intentId, stepId)
4856
4808
  });
@@ -4877,7 +4829,7 @@ const DepositWidget = ({
4877
4829
  const handleDepositAmountChange = React.useCallback(
4878
4830
  (amount) => {
4879
4831
  if (selectedDepositAsset) {
4880
- startTransition(() => {
4832
+ React.startTransition(() => {
4881
4833
  setSelectedDepositAsset({
4882
4834
  ...selectedDepositAsset,
4883
4835
  amount
@@ -4950,19 +4902,34 @@ const DepositWidget = ({
4950
4902
  };
4951
4903
  const result = await relayerService.submitTransaction(submitRequest);
4952
4904
  if (result) {
4953
- const withdrawalAmount = viem.parseUnits(
4954
- selectedDepositAsset.amount,
4955
- selectedDepositAsset.asset.decimals
4956
- );
4957
- await relayerService.submitSpiceDeposit({
4958
- user: address,
4959
- txHash: result.hash,
4960
- sender: address,
4961
- tokenAddress: selectedDepositAsset.asset.address,
4962
- chainId: selectedDepositAsset.asset.chainId,
4963
- amount: withdrawalAmount.toString(),
4964
- isDeposit: false
4965
- });
4905
+ React.useEffect(() => {
4906
+ if (intentStatus?.overallStatus === "success" && intentStatus.intentId && spiceDepositSubmittedRef.current !== intentStatus.intentId && selectedDepositAsset && address) {
4907
+ const stepWithTxHash = intentStatus.steps.find(
4908
+ (step) => step.transactionHash
4909
+ );
4910
+ if (stepWithTxHash?.transactionHash) {
4911
+ spiceDepositSubmittedRef.current = intentStatus.intentId;
4912
+ const withdrawalAmount = viem.parseUnits(
4913
+ selectedDepositAsset.amount,
4914
+ selectedDepositAsset.asset.decimals
4915
+ );
4916
+ relayerService.submitSpiceDeposit({
4917
+ user: address,
4918
+ txHash: stepWithTxHash.transactionHash,
4919
+ sender: address,
4920
+ tokenAddress: selectedDepositAsset.asset.address,
4921
+ chainId: selectedDepositAsset.asset.chainId,
4922
+ amount: withdrawalAmount.toString(),
4923
+ isDeposit: false
4924
+ }).then(() => {
4925
+ refreshSpiceAssets();
4926
+ }).catch((error2) => {
4927
+ console.error("Failed to submit spice deposit:", error2);
4928
+ spiceDepositSubmittedRef.current = null;
4929
+ });
4930
+ }
4931
+ }
4932
+ }, [intentStatus, selectedDepositAsset, address, refreshSpiceAssets]);
4966
4933
  const getChainName = (chainId) => {
4967
4934
  return `Chain ${chainId}`;
4968
4935
  };
@@ -5016,6 +4983,7 @@ const DepositWidget = ({
5016
4983
  onNewDeposit: () => {
5017
4984
  clearStatus();
5018
4985
  setSelectedDepositAsset(null);
4986
+ spiceDepositSubmittedRef.current = null;
5019
4987
  refreshSpiceAssets();
5020
4988
  },
5021
4989
  theme
@@ -5853,16 +5821,7 @@ const CrossChainDepositModal = ({
5853
5821
  if (confirmations < 2) {
5854
5822
  await new Promise((resolve) => setTimeout(resolve, 3e3));
5855
5823
  }
5856
- console.log("submitting deposit to relayer with params:", {
5857
- txHash: hash,
5858
- sender: embeddedWalletAddress,
5859
- tokenAddress: asset.address,
5860
- chainId,
5861
- amount: viem.parseUnits(amount, asset.decimals).toString(),
5862
- user: embeddedWalletAddress,
5863
- isDeposit: true
5864
- });
5865
- const depositResult = await relayerService.submitSpiceDeposit({
5824
+ await relayerService.submitSpiceDeposit({
5866
5825
  txHash: hash,
5867
5826
  sender: embeddedWalletAddress,
5868
5827
  tokenAddress: asset.address,
@@ -5871,10 +5830,8 @@ const CrossChainDepositModal = ({
5871
5830
  user: embeddedWalletAddress,
5872
5831
  isDeposit: true
5873
5832
  });
5874
- console.log("Deposit result:", depositResult);
5875
5833
  results.push({ asset, txHash: hash, success: true });
5876
5834
  } catch (err) {
5877
- console.error(`Deposit error for ${asset.symbol}:`, err);
5878
5835
  const error2 = err;
5879
5836
  let errorMsg = error2?.message || "Deposit failed";
5880
5837
  if (error2?.code === 4001 || error2?.message?.includes("rejected")) {
@@ -5888,7 +5845,6 @@ const CrossChainDepositModal = ({
5888
5845
  setDepositResults(results);
5889
5846
  setIsSuccess(true);
5890
5847
  } catch (err) {
5891
- console.error("Deposit error:", err);
5892
5848
  const error2 = err;
5893
5849
  setError(error2?.message || "Deposit failed");
5894
5850
  } finally {
@@ -5901,8 +5857,7 @@ const CrossChainDepositModal = ({
5901
5857
  chainId,
5902
5858
  switchChainAsync,
5903
5859
  escrowAddress,
5904
- assets,
5905
- externalWalletAddress
5860
+ assets
5906
5861
  ]);
5907
5862
  React.useEffect(() => {
5908
5863
  if (!isOpen) {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
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
- import React, { useState, useRef, useEffect, useCallback, createContext, useContext, useTransition, useMemo, forwardRef, createElement } from 'react';
5
+ import React, { useState, useRef, useEffect, useCallback, createContext, useContext, useTransition, startTransition, useMemo, forwardRef, createElement } from 'react';
6
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';
@@ -4283,7 +4283,6 @@ const DepositStatusPanel = ({
4283
4283
  };
4284
4284
  if (intentStatus) {
4285
4285
  const { steps, overallStatus } = intentStatus;
4286
- const isProcessing = overallStatus === "processing";
4287
4286
  const isSuccess = overallStatus === "success";
4288
4287
  const isError = overallStatus === "failed";
4289
4288
  const stepWithTxHash = steps.find((step) => step.transactionHash);
@@ -4320,9 +4319,9 @@ const DepositStatusPanel = ({
4320
4319
  display: "flex",
4321
4320
  alignItems: "center",
4322
4321
  gap: "8px",
4323
- cursor: !isProcessing ? "pointer" : "default"
4322
+ cursor: "pointer"
4324
4323
  },
4325
- onClick: !isProcessing ? toggleDetails : void 0,
4324
+ onClick: toggleDetails,
4326
4325
  children: [
4327
4326
  /* @__PURE__ */ jsx(
4328
4327
  "span",
@@ -4336,7 +4335,7 @@ const DepositStatusPanel = ({
4336
4335
  children: "Deposit Results"
4337
4336
  }
4338
4337
  ),
4339
- !isProcessing && /* @__PURE__ */ jsx(
4338
+ /* @__PURE__ */ jsx(
4340
4339
  "svg",
4341
4340
  {
4342
4341
  width: "16",
@@ -4362,7 +4361,7 @@ const DepositStatusPanel = ({
4362
4361
  ]
4363
4362
  }
4364
4363
  ),
4365
- !isProcessing && /* @__PURE__ */ jsx(
4364
+ /* @__PURE__ */ jsx(
4366
4365
  "button",
4367
4366
  {
4368
4367
  onClick: onClose,
@@ -4391,47 +4390,7 @@ const DepositStatusPanel = ({
4391
4390
  ]
4392
4391
  }
4393
4392
  ),
4394
- isProcessing && /* @__PURE__ */ jsxs(
4395
- "div",
4396
- {
4397
- style: {
4398
- display: "flex",
4399
- flexDirection: "column",
4400
- alignItems: "center",
4401
- padding: "24px",
4402
- marginBottom: "16px"
4403
- },
4404
- children: [
4405
- /* @__PURE__ */ jsx(
4406
- "div",
4407
- {
4408
- style: {
4409
- width: "48px",
4410
- height: "48px",
4411
- border: "3px solid #e5e7eb",
4412
- borderTopColor: theme.colors.primary,
4413
- borderRadius: "50%",
4414
- animation: "spin 1s linear infinite",
4415
- marginBottom: "16px"
4416
- }
4417
- }
4418
- ),
4419
- /* @__PURE__ */ jsx(
4420
- "p",
4421
- {
4422
- style: {
4423
- fontSize: "14px",
4424
- fontWeight: 500,
4425
- color: "#374151",
4426
- margin: 0
4427
- },
4428
- children: "Processing your deposit..."
4429
- }
4430
- )
4431
- ]
4432
- }
4433
- ),
4434
- !isProcessing && /* @__PURE__ */ jsx(
4393
+ /* @__PURE__ */ jsx(
4435
4394
  "div",
4436
4395
  {
4437
4396
  style: {
@@ -4448,7 +4407,7 @@ const DepositStatusPanel = ({
4448
4407
  )
4449
4408
  }
4450
4409
  ),
4451
- !isProcessing && /* @__PURE__ */ jsx(
4410
+ /* @__PURE__ */ jsx(
4452
4411
  "div",
4453
4412
  {
4454
4413
  style: {
@@ -4508,7 +4467,7 @@ const DepositStatusPanel = ({
4508
4467
  )
4509
4468
  }
4510
4469
  ),
4511
- !isProcessing && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
4470
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
4512
4471
  isError && onRetry && /* @__PURE__ */ jsx(
4513
4472
  "button",
4514
4473
  {
@@ -4559,13 +4518,7 @@ const DepositStatusPanel = ({
4559
4518
  children: "CONTINUE \u2192"
4560
4519
  }
4561
4520
  )
4562
- ] }),
4563
- /* @__PURE__ */ jsx("style", { children: `
4564
- @keyframes spin {
4565
- from { transform: rotate(0deg); }
4566
- to { transform: rotate(360deg); }
4567
- }
4568
- ` })
4521
+ ] })
4569
4522
  ]
4570
4523
  }
4571
4524
  );
@@ -4832,9 +4785,7 @@ const DepositWidget = ({
4832
4785
  provider,
4833
4786
  actions
4834
4787
  } = wallet;
4835
- useContext(SpiceFlowProviderContext);
4836
4788
  const [selectedDepositAsset, setSelectedDepositAsset] = useState(null);
4837
- const [isPending, startTransition] = useTransition();
4838
4789
  const {
4839
4790
  assets: spiceAssets,
4840
4791
  loading: loadingSpiceAssets,
@@ -4849,6 +4800,7 @@ const DepositWidget = ({
4849
4800
  });
4850
4801
  const [isExecuting, setIsExecuting] = useState(false);
4851
4802
  const [error, setError] = useState(null);
4803
+ const spiceDepositSubmittedRef = useRef(null);
4852
4804
  const { intentStatus, startStatusPolling, clearStatus } = useStatus({
4853
4805
  checkStepStatus: (intentId, stepId) => relayerService.checkStepStatus(intentId, stepId)
4854
4806
  });
@@ -4948,19 +4900,34 @@ const DepositWidget = ({
4948
4900
  };
4949
4901
  const result = await relayerService.submitTransaction(submitRequest);
4950
4902
  if (result) {
4951
- const withdrawalAmount = parseUnits(
4952
- selectedDepositAsset.amount,
4953
- selectedDepositAsset.asset.decimals
4954
- );
4955
- await relayerService.submitSpiceDeposit({
4956
- user: address,
4957
- txHash: result.hash,
4958
- sender: address,
4959
- tokenAddress: selectedDepositAsset.asset.address,
4960
- chainId: selectedDepositAsset.asset.chainId,
4961
- amount: withdrawalAmount.toString(),
4962
- isDeposit: false
4963
- });
4903
+ useEffect(() => {
4904
+ if (intentStatus?.overallStatus === "success" && intentStatus.intentId && spiceDepositSubmittedRef.current !== intentStatus.intentId && selectedDepositAsset && address) {
4905
+ const stepWithTxHash = intentStatus.steps.find(
4906
+ (step) => step.transactionHash
4907
+ );
4908
+ if (stepWithTxHash?.transactionHash) {
4909
+ spiceDepositSubmittedRef.current = intentStatus.intentId;
4910
+ const withdrawalAmount = parseUnits(
4911
+ selectedDepositAsset.amount,
4912
+ selectedDepositAsset.asset.decimals
4913
+ );
4914
+ relayerService.submitSpiceDeposit({
4915
+ user: address,
4916
+ txHash: stepWithTxHash.transactionHash,
4917
+ sender: address,
4918
+ tokenAddress: selectedDepositAsset.asset.address,
4919
+ chainId: selectedDepositAsset.asset.chainId,
4920
+ amount: withdrawalAmount.toString(),
4921
+ isDeposit: false
4922
+ }).then(() => {
4923
+ refreshSpiceAssets();
4924
+ }).catch((error2) => {
4925
+ console.error("Failed to submit spice deposit:", error2);
4926
+ spiceDepositSubmittedRef.current = null;
4927
+ });
4928
+ }
4929
+ }
4930
+ }, [intentStatus, selectedDepositAsset, address, refreshSpiceAssets]);
4964
4931
  const getChainName = (chainId) => {
4965
4932
  return `Chain ${chainId}`;
4966
4933
  };
@@ -5014,6 +4981,7 @@ const DepositWidget = ({
5014
4981
  onNewDeposit: () => {
5015
4982
  clearStatus();
5016
4983
  setSelectedDepositAsset(null);
4984
+ spiceDepositSubmittedRef.current = null;
5017
4985
  refreshSpiceAssets();
5018
4986
  },
5019
4987
  theme
@@ -5851,16 +5819,7 @@ const CrossChainDepositModal = ({
5851
5819
  if (confirmations < 2) {
5852
5820
  await new Promise((resolve) => setTimeout(resolve, 3e3));
5853
5821
  }
5854
- console.log("submitting deposit to relayer with params:", {
5855
- txHash: hash,
5856
- sender: embeddedWalletAddress,
5857
- tokenAddress: asset.address,
5858
- chainId,
5859
- amount: parseUnits(amount, asset.decimals).toString(),
5860
- user: embeddedWalletAddress,
5861
- isDeposit: true
5862
- });
5863
- const depositResult = await relayerService.submitSpiceDeposit({
5822
+ await relayerService.submitSpiceDeposit({
5864
5823
  txHash: hash,
5865
5824
  sender: embeddedWalletAddress,
5866
5825
  tokenAddress: asset.address,
@@ -5869,10 +5828,8 @@ const CrossChainDepositModal = ({
5869
5828
  user: embeddedWalletAddress,
5870
5829
  isDeposit: true
5871
5830
  });
5872
- console.log("Deposit result:", depositResult);
5873
5831
  results.push({ asset, txHash: hash, success: true });
5874
5832
  } catch (err) {
5875
- console.error(`Deposit error for ${asset.symbol}:`, err);
5876
5833
  const error2 = err;
5877
5834
  let errorMsg = error2?.message || "Deposit failed";
5878
5835
  if (error2?.code === 4001 || error2?.message?.includes("rejected")) {
@@ -5886,7 +5843,6 @@ const CrossChainDepositModal = ({
5886
5843
  setDepositResults(results);
5887
5844
  setIsSuccess(true);
5888
5845
  } catch (err) {
5889
- console.error("Deposit error:", err);
5890
5846
  const error2 = err;
5891
5847
  setError(error2?.message || "Deposit failed");
5892
5848
  } finally {
@@ -5899,8 +5855,7 @@ const CrossChainDepositModal = ({
5899
5855
  chainId,
5900
5856
  switchChainAsync,
5901
5857
  escrowAddress,
5902
- assets,
5903
- externalWalletAddress
5858
+ assets
5904
5859
  ]);
5905
5860
  useEffect(() => {
5906
5861
  if (!isOpen) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.9.14",
3
+ "version": "1.9.15",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",