@spicenet-io/spiceflow-ui 1.9.13 → 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
@@ -4787,9 +4787,7 @@ const DepositWidget = ({
4787
4787
  provider,
4788
4788
  actions
4789
4789
  } = wallet;
4790
- React.useContext(SpiceFlowProviderContext);
4791
4790
  const [selectedDepositAsset, setSelectedDepositAsset] = React.useState(null);
4792
- const [isPending, startTransition] = React.useTransition();
4793
4791
  const {
4794
4792
  assets: spiceAssets,
4795
4793
  loading: loadingSpiceAssets,
@@ -4804,6 +4802,7 @@ const DepositWidget = ({
4804
4802
  });
4805
4803
  const [isExecuting, setIsExecuting] = React.useState(false);
4806
4804
  const [error, setError] = React.useState(null);
4805
+ const spiceDepositSubmittedRef = React.useRef(null);
4807
4806
  const { intentStatus, startStatusPolling, clearStatus } = useStatus({
4808
4807
  checkStepStatus: (intentId, stepId) => relayerService.checkStepStatus(intentId, stepId)
4809
4808
  });
@@ -4830,7 +4829,7 @@ const DepositWidget = ({
4830
4829
  const handleDepositAmountChange = React.useCallback(
4831
4830
  (amount) => {
4832
4831
  if (selectedDepositAsset) {
4833
- startTransition(() => {
4832
+ React.startTransition(() => {
4834
4833
  setSelectedDepositAsset({
4835
4834
  ...selectedDepositAsset,
4836
4835
  amount
@@ -4903,19 +4902,34 @@ const DepositWidget = ({
4903
4902
  };
4904
4903
  const result = await relayerService.submitTransaction(submitRequest);
4905
4904
  if (result) {
4906
- const withdrawalAmount = viem.parseUnits(
4907
- selectedDepositAsset.amount,
4908
- selectedDepositAsset.asset.decimals
4909
- );
4910
- await relayerService.submitSpiceDeposit({
4911
- user: address,
4912
- txHash: result.hash,
4913
- sender: address,
4914
- tokenAddress: selectedDepositAsset.asset.address,
4915
- chainId: selectedDepositAsset.asset.chainId,
4916
- amount: withdrawalAmount.toString(),
4917
- isDeposit: false
4918
- });
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]);
4919
4933
  const getChainName = (chainId) => {
4920
4934
  return `Chain ${chainId}`;
4921
4935
  };
@@ -4942,8 +4956,7 @@ const DepositWidget = ({
4942
4956
  }
4943
4957
  return spiceAssets;
4944
4958
  }, [spiceAssets, supportedTokens]);
4945
- const isProcessingIntent = intentStatus?.overallStatus === "processing";
4946
- const canDeposit = selectedDepositAsset && selectedDepositAsset.amount && parseFloat(selectedDepositAsset.amount) > 0 && parseFloat(selectedDepositAsset.amount) <= selectedDepositAsset.asset.balanceFormatted && isConnected && !isExecuting && !isProcessingIntent && depositBatches.length > 0;
4959
+ const canDeposit = selectedDepositAsset && selectedDepositAsset.amount && parseFloat(selectedDepositAsset.amount) > 0 && parseFloat(selectedDepositAsset.amount) <= selectedDepositAsset.asset.balanceFormatted && isConnected && !isExecuting && depositBatches.length > 0;
4947
4960
  const displayError = spiceAssetsError || error;
4948
4961
  const containerStyles = {
4949
4962
  backgroundColor: styles?.container?.backgroundColor || styles?.primaryBackground || theme.colors.background,
@@ -4957,8 +4970,7 @@ const DepositWidget = ({
4957
4970
  fontFamily: theme.typography.fontFamily,
4958
4971
  boxShadow: styles?.container?.boxShadow || (theme.mode === "light" ? "0 4px 6px -1px rgb(0 0 0 / 0.1)" : "0 4px 6px -1px rgb(0 0 0 / 0.3)")
4959
4972
  };
4960
- const showStatusPanel = intentStatus && intentStatus.overallStatus !== "processing";
4961
- if (showStatusPanel) {
4973
+ if (intentStatus) {
4962
4974
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(
4963
4975
  DepositStatusPanel,
4964
4976
  {
@@ -4971,6 +4983,7 @@ const DepositWidget = ({
4971
4983
  onNewDeposit: () => {
4972
4984
  clearStatus();
4973
4985
  setSelectedDepositAsset(null);
4986
+ spiceDepositSubmittedRef.current = null;
4974
4987
  refreshSpiceAssets();
4975
4988
  },
4976
4989
  theme
@@ -5074,11 +5087,11 @@ const DepositWidget = ({
5074
5087
  variant: "outline",
5075
5088
  fullWidth: true,
5076
5089
  onClick: handleDeposit,
5077
- loading: isExecuting || isProcessingIntent,
5090
+ loading: isExecuting,
5078
5091
  disabled: !canDeposit || !isConnected,
5079
5092
  theme,
5080
5093
  styles,
5081
- children: !ready ? "Loading..." : !authenticated ? "Authentication Required" : !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : isProcessingIntent ? "Processing..." : !selectedDepositAsset ? "Select Token" : !selectedDepositAsset.amount ? "Enter Amount" : parseFloat(selectedDepositAsset.amount) > selectedDepositAsset.asset.balanceFormatted ? "Insufficient Balance" : depositBatches.length === 0 ? "No Deposit Batches" : "Execute Deposit"
5094
+ children: !ready ? "Loading..." : !authenticated ? "Authentication Required" : !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : !selectedDepositAsset ? "Select Token" : !selectedDepositAsset.amount ? "Enter Amount" : parseFloat(selectedDepositAsset.amount) > selectedDepositAsset.asset.balanceFormatted ? "Insufficient Balance" : depositBatches.length === 0 ? "No Deposit Batches" : "Execute Deposit"
5082
5095
  }
5083
5096
  )
5084
5097
  }
@@ -5808,16 +5821,7 @@ const CrossChainDepositModal = ({
5808
5821
  if (confirmations < 2) {
5809
5822
  await new Promise((resolve) => setTimeout(resolve, 3e3));
5810
5823
  }
5811
- console.log("submitting deposit to relayer with params:", {
5812
- txHash: hash,
5813
- sender: embeddedWalletAddress,
5814
- tokenAddress: asset.address,
5815
- chainId,
5816
- amount: viem.parseUnits(amount, asset.decimals).toString(),
5817
- user: embeddedWalletAddress,
5818
- isDeposit: true
5819
- });
5820
- const depositResult = await relayerService.submitSpiceDeposit({
5824
+ await relayerService.submitSpiceDeposit({
5821
5825
  txHash: hash,
5822
5826
  sender: embeddedWalletAddress,
5823
5827
  tokenAddress: asset.address,
@@ -5826,10 +5830,8 @@ const CrossChainDepositModal = ({
5826
5830
  user: embeddedWalletAddress,
5827
5831
  isDeposit: true
5828
5832
  });
5829
- console.log("Deposit result:", depositResult);
5830
5833
  results.push({ asset, txHash: hash, success: true });
5831
5834
  } catch (err) {
5832
- console.error(`Deposit error for ${asset.symbol}:`, err);
5833
5835
  const error2 = err;
5834
5836
  let errorMsg = error2?.message || "Deposit failed";
5835
5837
  if (error2?.code === 4001 || error2?.message?.includes("rejected")) {
@@ -5843,7 +5845,6 @@ const CrossChainDepositModal = ({
5843
5845
  setDepositResults(results);
5844
5846
  setIsSuccess(true);
5845
5847
  } catch (err) {
5846
- console.error("Deposit error:", err);
5847
5848
  const error2 = err;
5848
5849
  setError(error2?.message || "Deposit failed");
5849
5850
  } finally {
@@ -5856,8 +5857,7 @@ const CrossChainDepositModal = ({
5856
5857
  chainId,
5857
5858
  switchChainAsync,
5858
5859
  escrowAddress,
5859
- assets,
5860
- externalWalletAddress
5860
+ assets
5861
5861
  ]);
5862
5862
  React.useEffect(() => {
5863
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';
@@ -4785,9 +4785,7 @@ const DepositWidget = ({
4785
4785
  provider,
4786
4786
  actions
4787
4787
  } = wallet;
4788
- useContext(SpiceFlowProviderContext);
4789
4788
  const [selectedDepositAsset, setSelectedDepositAsset] = useState(null);
4790
- const [isPending, startTransition] = useTransition();
4791
4789
  const {
4792
4790
  assets: spiceAssets,
4793
4791
  loading: loadingSpiceAssets,
@@ -4802,6 +4800,7 @@ const DepositWidget = ({
4802
4800
  });
4803
4801
  const [isExecuting, setIsExecuting] = useState(false);
4804
4802
  const [error, setError] = useState(null);
4803
+ const spiceDepositSubmittedRef = useRef(null);
4805
4804
  const { intentStatus, startStatusPolling, clearStatus } = useStatus({
4806
4805
  checkStepStatus: (intentId, stepId) => relayerService.checkStepStatus(intentId, stepId)
4807
4806
  });
@@ -4901,19 +4900,34 @@ const DepositWidget = ({
4901
4900
  };
4902
4901
  const result = await relayerService.submitTransaction(submitRequest);
4903
4902
  if (result) {
4904
- const withdrawalAmount = parseUnits(
4905
- selectedDepositAsset.amount,
4906
- selectedDepositAsset.asset.decimals
4907
- );
4908
- await relayerService.submitSpiceDeposit({
4909
- user: address,
4910
- txHash: result.hash,
4911
- sender: address,
4912
- tokenAddress: selectedDepositAsset.asset.address,
4913
- chainId: selectedDepositAsset.asset.chainId,
4914
- amount: withdrawalAmount.toString(),
4915
- isDeposit: false
4916
- });
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]);
4917
4931
  const getChainName = (chainId) => {
4918
4932
  return `Chain ${chainId}`;
4919
4933
  };
@@ -4940,8 +4954,7 @@ const DepositWidget = ({
4940
4954
  }
4941
4955
  return spiceAssets;
4942
4956
  }, [spiceAssets, supportedTokens]);
4943
- const isProcessingIntent = intentStatus?.overallStatus === "processing";
4944
- const canDeposit = selectedDepositAsset && selectedDepositAsset.amount && parseFloat(selectedDepositAsset.amount) > 0 && parseFloat(selectedDepositAsset.amount) <= selectedDepositAsset.asset.balanceFormatted && isConnected && !isExecuting && !isProcessingIntent && depositBatches.length > 0;
4957
+ const canDeposit = selectedDepositAsset && selectedDepositAsset.amount && parseFloat(selectedDepositAsset.amount) > 0 && parseFloat(selectedDepositAsset.amount) <= selectedDepositAsset.asset.balanceFormatted && isConnected && !isExecuting && depositBatches.length > 0;
4945
4958
  const displayError = spiceAssetsError || error;
4946
4959
  const containerStyles = {
4947
4960
  backgroundColor: styles?.container?.backgroundColor || styles?.primaryBackground || theme.colors.background,
@@ -4955,8 +4968,7 @@ const DepositWidget = ({
4955
4968
  fontFamily: theme.typography.fontFamily,
4956
4969
  boxShadow: styles?.container?.boxShadow || (theme.mode === "light" ? "0 4px 6px -1px rgb(0 0 0 / 0.1)" : "0 4px 6px -1px rgb(0 0 0 / 0.3)")
4957
4970
  };
4958
- const showStatusPanel = intentStatus && intentStatus.overallStatus !== "processing";
4959
- if (showStatusPanel) {
4971
+ if (intentStatus) {
4960
4972
  return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
4961
4973
  DepositStatusPanel,
4962
4974
  {
@@ -4969,6 +4981,7 @@ const DepositWidget = ({
4969
4981
  onNewDeposit: () => {
4970
4982
  clearStatus();
4971
4983
  setSelectedDepositAsset(null);
4984
+ spiceDepositSubmittedRef.current = null;
4972
4985
  refreshSpiceAssets();
4973
4986
  },
4974
4987
  theme
@@ -5072,11 +5085,11 @@ const DepositWidget = ({
5072
5085
  variant: "outline",
5073
5086
  fullWidth: true,
5074
5087
  onClick: handleDeposit,
5075
- loading: isExecuting || isProcessingIntent,
5088
+ loading: isExecuting,
5076
5089
  disabled: !canDeposit || !isConnected,
5077
5090
  theme,
5078
5091
  styles,
5079
- children: !ready ? "Loading..." : !authenticated ? "Authentication Required" : !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : isProcessingIntent ? "Processing..." : !selectedDepositAsset ? "Select Token" : !selectedDepositAsset.amount ? "Enter Amount" : parseFloat(selectedDepositAsset.amount) > selectedDepositAsset.asset.balanceFormatted ? "Insufficient Balance" : depositBatches.length === 0 ? "No Deposit Batches" : "Execute Deposit"
5092
+ children: !ready ? "Loading..." : !authenticated ? "Authentication Required" : !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : !selectedDepositAsset ? "Select Token" : !selectedDepositAsset.amount ? "Enter Amount" : parseFloat(selectedDepositAsset.amount) > selectedDepositAsset.asset.balanceFormatted ? "Insufficient Balance" : depositBatches.length === 0 ? "No Deposit Batches" : "Execute Deposit"
5080
5093
  }
5081
5094
  )
5082
5095
  }
@@ -5806,16 +5819,7 @@ const CrossChainDepositModal = ({
5806
5819
  if (confirmations < 2) {
5807
5820
  await new Promise((resolve) => setTimeout(resolve, 3e3));
5808
5821
  }
5809
- console.log("submitting deposit to relayer with params:", {
5810
- txHash: hash,
5811
- sender: embeddedWalletAddress,
5812
- tokenAddress: asset.address,
5813
- chainId,
5814
- amount: parseUnits(amount, asset.decimals).toString(),
5815
- user: embeddedWalletAddress,
5816
- isDeposit: true
5817
- });
5818
- const depositResult = await relayerService.submitSpiceDeposit({
5822
+ await relayerService.submitSpiceDeposit({
5819
5823
  txHash: hash,
5820
5824
  sender: embeddedWalletAddress,
5821
5825
  tokenAddress: asset.address,
@@ -5824,10 +5828,8 @@ const CrossChainDepositModal = ({
5824
5828
  user: embeddedWalletAddress,
5825
5829
  isDeposit: true
5826
5830
  });
5827
- console.log("Deposit result:", depositResult);
5828
5831
  results.push({ asset, txHash: hash, success: true });
5829
5832
  } catch (err) {
5830
- console.error(`Deposit error for ${asset.symbol}:`, err);
5831
5833
  const error2 = err;
5832
5834
  let errorMsg = error2?.message || "Deposit failed";
5833
5835
  if (error2?.code === 4001 || error2?.message?.includes("rejected")) {
@@ -5841,7 +5843,6 @@ const CrossChainDepositModal = ({
5841
5843
  setDepositResults(results);
5842
5844
  setIsSuccess(true);
5843
5845
  } catch (err) {
5844
- console.error("Deposit error:", err);
5845
5846
  const error2 = err;
5846
5847
  setError(error2?.message || "Deposit failed");
5847
5848
  } finally {
@@ -5854,8 +5855,7 @@ const CrossChainDepositModal = ({
5854
5855
  chainId,
5855
5856
  switchChainAsync,
5856
5857
  escrowAddress,
5857
- assets,
5858
- externalWalletAddress
5858
+ assets
5859
5859
  ]);
5860
5860
  useEffect(() => {
5861
5861
  if (!isOpen) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.9.13",
3
+ "version": "1.9.15",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",