@spicenet-io/spiceflow-ui 1.7.5 → 1.7.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/index.cjs.js CHANGED
@@ -103,7 +103,7 @@ const CHAIN_CONFIGS = {
103
103
  symbol: "ETH",
104
104
  decimals: 18
105
105
  },
106
- rpc: "https://sepolia.base.org",
106
+ rpc: "https://site1.moralis-nodes.com/base-sepolia/0563a61e273c428f906716cd4befa362",
107
107
  blockExplorers: {
108
108
  default: {
109
109
  name: "Basescan",
@@ -916,12 +916,13 @@ const useAssets = ({
916
916
  address,
917
917
  supportedChains,
918
918
  fetchBalances: fetchBalances2,
919
- refreshInterval = 1e4
920
- // 30 seconds default
919
+ refreshInterval = 8e3
920
+ // 8 seconds default
921
921
  }) => {
922
922
  const [assets, setAssets] = React.useState([]);
923
923
  const [loading, setLoading] = React.useState(false);
924
924
  const [error, setError] = React.useState(null);
925
+ const isInitialLoadRef = React.useRef(true);
925
926
  const addressRef = React.useRef(address);
926
927
  const supportedChainsRef = React.useRef(supportedChains);
927
928
  const fetchBalancesRef = React.useRef(fetchBalances2);
@@ -938,7 +939,9 @@ const useAssets = ({
938
939
  setAssets([]);
939
940
  return;
940
941
  }
941
- setLoading(true);
942
+ if (isInitialLoadRef.current) {
943
+ setLoading(true);
944
+ }
942
945
  setError(null);
943
946
  try {
944
947
  const balances = await currentFetchBalances(currentAddress);
@@ -957,7 +960,10 @@ const useAssets = ({
957
960
  setError(errorMessage);
958
961
  console.error("Error fetching assets:", err);
959
962
  } finally {
960
- setLoading(false);
963
+ if (isInitialLoadRef.current) {
964
+ setLoading(false);
965
+ isInitialLoadRef.current = false;
966
+ }
961
967
  }
962
968
  }, []);
963
969
  const getAssetsByChain = React.useCallback(
@@ -971,6 +977,7 @@ const useAssets = ({
971
977
  }, [assets]);
972
978
  React.useEffect(() => {
973
979
  if (address) {
980
+ isInitialLoadRef.current = true;
974
981
  refreshAssets();
975
982
  }
976
983
  }, [address, refreshAssets]);
@@ -1661,6 +1668,31 @@ const AssetSelectorComponent = ({
1661
1668
  ]);
1662
1669
  const handleAmountChange = (value) => {
1663
1670
  const cleanValue = parseNumericInput(value);
1671
+ if (!cleanValue) {
1672
+ setLocalAmount(cleanValue);
1673
+ if (debounceTimerRef.current) {
1674
+ clearTimeout(debounceTimerRef.current);
1675
+ }
1676
+ debounceTimerRef.current = setTimeout(() => {
1677
+ onAmountChange(cleanValue);
1678
+ }, 300);
1679
+ return;
1680
+ }
1681
+ if (selectedAsset?.asset) {
1682
+ const numAmount = parseFloat(cleanValue);
1683
+ const maxBalance = selectedAsset.asset.balanceFormatted;
1684
+ if (!isNaN(numAmount) && numAmount > maxBalance) {
1685
+ const clampedAmount = maxBalance.toString();
1686
+ setLocalAmount(clampedAmount);
1687
+ if (debounceTimerRef.current) {
1688
+ clearTimeout(debounceTimerRef.current);
1689
+ }
1690
+ debounceTimerRef.current = setTimeout(() => {
1691
+ onAmountChange(clampedAmount);
1692
+ }, 300);
1693
+ return;
1694
+ }
1695
+ }
1664
1696
  setLocalAmount(cleanValue);
1665
1697
  if (debounceTimerRef.current) {
1666
1698
  clearTimeout(debounceTimerRef.current);
@@ -5534,6 +5566,84 @@ const ConnectWalletModal = ({
5534
5566
  },
5535
5567
  children: [
5536
5568
  /* @__PURE__ */ jsxRuntime.jsx(ModalHeader, { title: "Connect Wallet", onClose }),
5569
+ requiredChainId === 421614 && !isConnected && /* @__PURE__ */ jsxRuntime.jsx(
5570
+ "div",
5571
+ {
5572
+ style: {
5573
+ padding: "0 32px",
5574
+ marginTop: "20px"
5575
+ },
5576
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
5577
+ "div",
5578
+ {
5579
+ style: {
5580
+ padding: "12px 16px",
5581
+ backgroundColor: "#EFF6FF",
5582
+ borderRadius: "8px",
5583
+ border: "1px solid #BFDBFE",
5584
+ display: "flex",
5585
+ alignItems: "center",
5586
+ gap: "10px"
5587
+ },
5588
+ children: [
5589
+ /* @__PURE__ */ jsxRuntime.jsx(
5590
+ "div",
5591
+ {
5592
+ style: {
5593
+ width: "32px",
5594
+ height: "32px",
5595
+ borderRadius: "50%",
5596
+ backgroundColor: "#DBEAFE",
5597
+ display: "flex",
5598
+ alignItems: "center",
5599
+ justifyContent: "center",
5600
+ flexShrink: 0
5601
+ },
5602
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5603
+ "img",
5604
+ {
5605
+ src: img$3,
5606
+ alt: "Rabby",
5607
+ style: {
5608
+ width: "20px",
5609
+ height: "20px",
5610
+ objectFit: "contain"
5611
+ }
5612
+ }
5613
+ )
5614
+ }
5615
+ ),
5616
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1 }, children: [
5617
+ /* @__PURE__ */ jsxRuntime.jsx(
5618
+ "p",
5619
+ {
5620
+ style: {
5621
+ margin: "0 0 4px 0",
5622
+ color: "#1E40AF",
5623
+ fontSize: "13px",
5624
+ fontWeight: 600
5625
+ },
5626
+ children: "Recommended Wallet"
5627
+ }
5628
+ ),
5629
+ /* @__PURE__ */ jsxRuntime.jsx(
5630
+ "p",
5631
+ {
5632
+ style: {
5633
+ margin: 0,
5634
+ color: "#1E3A8A",
5635
+ fontSize: "12px",
5636
+ lineHeight: "1.4"
5637
+ },
5638
+ children: "For Arbitrum Sepolia, we recommend using Rabby wallet instead of MetaMask for the best experience."
5639
+ }
5640
+ )
5641
+ ] })
5642
+ ]
5643
+ }
5644
+ )
5645
+ }
5646
+ ),
5537
5647
  /* @__PURE__ */ jsxRuntime.jsxs(
5538
5648
  "div",
5539
5649
  {
@@ -5665,6 +5775,75 @@ const ConnectWalletModal = ({
5665
5775
  ]
5666
5776
  }
5667
5777
  ),
5778
+ isConnected && requiredChainId === 421614 && activeConnector && (activeConnector.name.toLowerCase().includes("metamask") || activeConnector.type === "injected") && /* @__PURE__ */ jsxRuntime.jsxs(
5779
+ "div",
5780
+ {
5781
+ style: {
5782
+ padding: "12px 16px",
5783
+ backgroundColor: "#EFF6FF",
5784
+ borderRadius: "8px",
5785
+ border: "1px solid #BFDBFE",
5786
+ display: "flex",
5787
+ alignItems: "center",
5788
+ gap: "10px"
5789
+ },
5790
+ children: [
5791
+ /* @__PURE__ */ jsxRuntime.jsx(
5792
+ "div",
5793
+ {
5794
+ style: {
5795
+ width: "32px",
5796
+ height: "32px",
5797
+ borderRadius: "50%",
5798
+ backgroundColor: "#DBEAFE",
5799
+ display: "flex",
5800
+ alignItems: "center",
5801
+ justifyContent: "center",
5802
+ flexShrink: 0
5803
+ },
5804
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5805
+ "img",
5806
+ {
5807
+ src: img$3,
5808
+ alt: "Rabby",
5809
+ style: {
5810
+ width: "20px",
5811
+ height: "20px",
5812
+ objectFit: "contain"
5813
+ }
5814
+ }
5815
+ )
5816
+ }
5817
+ ),
5818
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1 }, children: [
5819
+ /* @__PURE__ */ jsxRuntime.jsx(
5820
+ "p",
5821
+ {
5822
+ style: {
5823
+ margin: "0 0 4px 0",
5824
+ color: "#1E40AF",
5825
+ fontSize: "13px",
5826
+ fontWeight: 600
5827
+ },
5828
+ children: "Recommended Wallet"
5829
+ }
5830
+ ),
5831
+ /* @__PURE__ */ jsxRuntime.jsx(
5832
+ "p",
5833
+ {
5834
+ style: {
5835
+ margin: 0,
5836
+ color: "#1E3A8A",
5837
+ fontSize: "12px",
5838
+ lineHeight: "1.4"
5839
+ },
5840
+ children: "For Arbitrum Sepolia, we recommend using Rabby wallet instead of MetaMask for the best experience."
5841
+ }
5842
+ )
5843
+ ] })
5844
+ ]
5845
+ }
5846
+ ),
5668
5847
  isConnected && address ? /* @__PURE__ */ jsxRuntime.jsxs(
5669
5848
  "div",
5670
5849
  {
@@ -7055,7 +7234,7 @@ const DepositModal = React.memo(
7055
7234
  address: sourceAddress || address,
7056
7235
  supportedChains,
7057
7236
  fetchBalances,
7058
- refreshInterval: 3e4
7237
+ refreshInterval: 8e3
7059
7238
  });
7060
7239
  const [isExecuting, setIsExecuting] = React.useState(false);
7061
7240
  const [error, setError] = React.useState(null);
@@ -7093,6 +7272,26 @@ const DepositModal = React.memo(
7093
7272
  });
7094
7273
  }
7095
7274
  }, [depositAmount]);
7275
+ React.useEffect(() => {
7276
+ if (selectedDepositAssets.length === 0) return;
7277
+ setSelectedDepositAssets((prev) => {
7278
+ return prev.map((selectedItem) => {
7279
+ if (!selectedItem.asset) return selectedItem;
7280
+ const freshAsset = depositAssets.find(
7281
+ (a) => a.chainId === selectedItem.asset.chainId && a.address.toLowerCase() === selectedItem.asset.address.toLowerCase()
7282
+ );
7283
+ if (freshAsset) {
7284
+ return {
7285
+ ...selectedItem,
7286
+ asset: freshAsset,
7287
+ // Preserve the user's entered amount
7288
+ amount: selectedItem.amount
7289
+ };
7290
+ }
7291
+ return selectedItem;
7292
+ });
7293
+ });
7294
+ }, [assets]);
7096
7295
  React.useEffect(() => {
7097
7296
  if (nonEip7702Mode && intentStatus?.overallStatus === "success" && postDepositInstruction && postDepositStatus === "idle") {
7098
7297
  const bridgedAmount = bridgedAmountRef.current;
@@ -7143,8 +7342,16 @@ const DepositModal = React.memo(
7143
7342
  const errorMessage = error2?.message || String(error2 || "");
7144
7343
  const errorDetails = error2?.details || "";
7145
7344
  const errorString = `${errorMessage} ${errorDetails}`.toLowerCase();
7345
+ console.error("RPC Error Details:", {
7346
+ code: error2?.code,
7347
+ message: errorMessage,
7348
+ details: errorDetails,
7349
+ data: error2?.data,
7350
+ stack: error2?.stack,
7351
+ fullError: error2
7352
+ });
7146
7353
  if (errorString.includes("internal json-rpc error") || errorString.includes("internal error") || errorString.includes("an internal error was received")) {
7147
- return "Network error occurred. Please try again.";
7354
+ return "RPC Network error. Try switching your MetaMask RPC endpoint or try again.";
7148
7355
  }
7149
7356
  return errorMessage || "Transaction failed";
7150
7357
  }, []);
@@ -7234,6 +7441,7 @@ const DepositModal = React.memo(
7234
7441
  }
7235
7442
  setAirdropMessage("Airdrop requested successfully.");
7236
7443
  } catch (e) {
7444
+ console.log(e);
7237
7445
  const msg = handleRpcError(e);
7238
7446
  setAirdropError(msg);
7239
7447
  } finally {
@@ -7357,6 +7565,11 @@ const DepositModal = React.memo(
7357
7565
  }
7358
7566
  if (currentChain?.id !== chainId) {
7359
7567
  setError("Wrong chain selected. Switching network...");
7568
+ console.log("Attempting to switch to chain:", {
7569
+ chainId,
7570
+ currentChainId: currentChain?.id,
7571
+ chainName: getChainName$1(chainId)
7572
+ });
7360
7573
  try {
7361
7574
  await switchChainAsync({ chainId });
7362
7575
  let attempts = 0;
@@ -7443,6 +7656,14 @@ const DepositModal = React.memo(
7443
7656
  tokenAddress = "0x0";
7444
7657
  }
7445
7658
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
7659
+ console.log("Sending transaction via MetaMask:", {
7660
+ chainId,
7661
+ isNative,
7662
+ tokenAddress,
7663
+ delegateContract,
7664
+ amount: amount.toString(),
7665
+ walletChainId: externalWalletClient.chain?.id
7666
+ });
7446
7667
  const txHash = isNative ? await externalWalletClient.sendTransaction({
7447
7668
  to: delegateContract,
7448
7669
  value: amount
@@ -7583,6 +7804,14 @@ const DepositModal = React.memo(
7583
7804
  tokenAddress = "0x0";
7584
7805
  }
7585
7806
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
7807
+ console.log("Sending EIP-7702 transaction via MetaMask:", {
7808
+ chainId,
7809
+ isNative,
7810
+ tokenAddress,
7811
+ amount: amount.toString(),
7812
+ recipient: address,
7813
+ walletChainId: externalWalletClient.chain?.id
7814
+ });
7586
7815
  const transferToEmbeddedTx = isNative ? await externalWalletClient.sendTransaction({
7587
7816
  to: address,
7588
7817
  value: amount
@@ -10210,7 +10439,7 @@ const SpiceWithdraw = (props) => {
10210
10439
  }
10211
10440
  const transports = {};
10212
10441
  chains.forEach((chain) => {
10213
- transports[chain.id] = wagmi.http();
10442
+ transports[chain.id] = wagmi.http(chain.rpc);
10214
10443
  });
10215
10444
  const connectorsList = [connectors.metaMask()];
10216
10445
  if (walletConnectProjectId) {
package/dist/index.js CHANGED
@@ -101,7 +101,7 @@ const CHAIN_CONFIGS = {
101
101
  symbol: "ETH",
102
102
  decimals: 18
103
103
  },
104
- rpc: "https://sepolia.base.org",
104
+ rpc: "https://site1.moralis-nodes.com/base-sepolia/0563a61e273c428f906716cd4befa362",
105
105
  blockExplorers: {
106
106
  default: {
107
107
  name: "Basescan",
@@ -914,12 +914,13 @@ const useAssets = ({
914
914
  address,
915
915
  supportedChains,
916
916
  fetchBalances: fetchBalances2,
917
- refreshInterval = 1e4
918
- // 30 seconds default
917
+ refreshInterval = 8e3
918
+ // 8 seconds default
919
919
  }) => {
920
920
  const [assets, setAssets] = useState([]);
921
921
  const [loading, setLoading] = useState(false);
922
922
  const [error, setError] = useState(null);
923
+ const isInitialLoadRef = useRef(true);
923
924
  const addressRef = useRef(address);
924
925
  const supportedChainsRef = useRef(supportedChains);
925
926
  const fetchBalancesRef = useRef(fetchBalances2);
@@ -936,7 +937,9 @@ const useAssets = ({
936
937
  setAssets([]);
937
938
  return;
938
939
  }
939
- setLoading(true);
940
+ if (isInitialLoadRef.current) {
941
+ setLoading(true);
942
+ }
940
943
  setError(null);
941
944
  try {
942
945
  const balances = await currentFetchBalances(currentAddress);
@@ -955,7 +958,10 @@ const useAssets = ({
955
958
  setError(errorMessage);
956
959
  console.error("Error fetching assets:", err);
957
960
  } finally {
958
- setLoading(false);
961
+ if (isInitialLoadRef.current) {
962
+ setLoading(false);
963
+ isInitialLoadRef.current = false;
964
+ }
959
965
  }
960
966
  }, []);
961
967
  const getAssetsByChain = useCallback(
@@ -969,6 +975,7 @@ const useAssets = ({
969
975
  }, [assets]);
970
976
  useEffect(() => {
971
977
  if (address) {
978
+ isInitialLoadRef.current = true;
972
979
  refreshAssets();
973
980
  }
974
981
  }, [address, refreshAssets]);
@@ -1659,6 +1666,31 @@ const AssetSelectorComponent = ({
1659
1666
  ]);
1660
1667
  const handleAmountChange = (value) => {
1661
1668
  const cleanValue = parseNumericInput(value);
1669
+ if (!cleanValue) {
1670
+ setLocalAmount(cleanValue);
1671
+ if (debounceTimerRef.current) {
1672
+ clearTimeout(debounceTimerRef.current);
1673
+ }
1674
+ debounceTimerRef.current = setTimeout(() => {
1675
+ onAmountChange(cleanValue);
1676
+ }, 300);
1677
+ return;
1678
+ }
1679
+ if (selectedAsset?.asset) {
1680
+ const numAmount = parseFloat(cleanValue);
1681
+ const maxBalance = selectedAsset.asset.balanceFormatted;
1682
+ if (!isNaN(numAmount) && numAmount > maxBalance) {
1683
+ const clampedAmount = maxBalance.toString();
1684
+ setLocalAmount(clampedAmount);
1685
+ if (debounceTimerRef.current) {
1686
+ clearTimeout(debounceTimerRef.current);
1687
+ }
1688
+ debounceTimerRef.current = setTimeout(() => {
1689
+ onAmountChange(clampedAmount);
1690
+ }, 300);
1691
+ return;
1692
+ }
1693
+ }
1662
1694
  setLocalAmount(cleanValue);
1663
1695
  if (debounceTimerRef.current) {
1664
1696
  clearTimeout(debounceTimerRef.current);
@@ -5532,6 +5564,84 @@ const ConnectWalletModal = ({
5532
5564
  },
5533
5565
  children: [
5534
5566
  /* @__PURE__ */ jsx(ModalHeader, { title: "Connect Wallet", onClose }),
5567
+ requiredChainId === 421614 && !isConnected && /* @__PURE__ */ jsx(
5568
+ "div",
5569
+ {
5570
+ style: {
5571
+ padding: "0 32px",
5572
+ marginTop: "20px"
5573
+ },
5574
+ children: /* @__PURE__ */ jsxs(
5575
+ "div",
5576
+ {
5577
+ style: {
5578
+ padding: "12px 16px",
5579
+ backgroundColor: "#EFF6FF",
5580
+ borderRadius: "8px",
5581
+ border: "1px solid #BFDBFE",
5582
+ display: "flex",
5583
+ alignItems: "center",
5584
+ gap: "10px"
5585
+ },
5586
+ children: [
5587
+ /* @__PURE__ */ jsx(
5588
+ "div",
5589
+ {
5590
+ style: {
5591
+ width: "32px",
5592
+ height: "32px",
5593
+ borderRadius: "50%",
5594
+ backgroundColor: "#DBEAFE",
5595
+ display: "flex",
5596
+ alignItems: "center",
5597
+ justifyContent: "center",
5598
+ flexShrink: 0
5599
+ },
5600
+ children: /* @__PURE__ */ jsx(
5601
+ "img",
5602
+ {
5603
+ src: img$3,
5604
+ alt: "Rabby",
5605
+ style: {
5606
+ width: "20px",
5607
+ height: "20px",
5608
+ objectFit: "contain"
5609
+ }
5610
+ }
5611
+ )
5612
+ }
5613
+ ),
5614
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
5615
+ /* @__PURE__ */ jsx(
5616
+ "p",
5617
+ {
5618
+ style: {
5619
+ margin: "0 0 4px 0",
5620
+ color: "#1E40AF",
5621
+ fontSize: "13px",
5622
+ fontWeight: 600
5623
+ },
5624
+ children: "Recommended Wallet"
5625
+ }
5626
+ ),
5627
+ /* @__PURE__ */ jsx(
5628
+ "p",
5629
+ {
5630
+ style: {
5631
+ margin: 0,
5632
+ color: "#1E3A8A",
5633
+ fontSize: "12px",
5634
+ lineHeight: "1.4"
5635
+ },
5636
+ children: "For Arbitrum Sepolia, we recommend using Rabby wallet instead of MetaMask for the best experience."
5637
+ }
5638
+ )
5639
+ ] })
5640
+ ]
5641
+ }
5642
+ )
5643
+ }
5644
+ ),
5535
5645
  /* @__PURE__ */ jsxs(
5536
5646
  "div",
5537
5647
  {
@@ -5663,6 +5773,75 @@ const ConnectWalletModal = ({
5663
5773
  ]
5664
5774
  }
5665
5775
  ),
5776
+ isConnected && requiredChainId === 421614 && activeConnector && (activeConnector.name.toLowerCase().includes("metamask") || activeConnector.type === "injected") && /* @__PURE__ */ jsxs(
5777
+ "div",
5778
+ {
5779
+ style: {
5780
+ padding: "12px 16px",
5781
+ backgroundColor: "#EFF6FF",
5782
+ borderRadius: "8px",
5783
+ border: "1px solid #BFDBFE",
5784
+ display: "flex",
5785
+ alignItems: "center",
5786
+ gap: "10px"
5787
+ },
5788
+ children: [
5789
+ /* @__PURE__ */ jsx(
5790
+ "div",
5791
+ {
5792
+ style: {
5793
+ width: "32px",
5794
+ height: "32px",
5795
+ borderRadius: "50%",
5796
+ backgroundColor: "#DBEAFE",
5797
+ display: "flex",
5798
+ alignItems: "center",
5799
+ justifyContent: "center",
5800
+ flexShrink: 0
5801
+ },
5802
+ children: /* @__PURE__ */ jsx(
5803
+ "img",
5804
+ {
5805
+ src: img$3,
5806
+ alt: "Rabby",
5807
+ style: {
5808
+ width: "20px",
5809
+ height: "20px",
5810
+ objectFit: "contain"
5811
+ }
5812
+ }
5813
+ )
5814
+ }
5815
+ ),
5816
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
5817
+ /* @__PURE__ */ jsx(
5818
+ "p",
5819
+ {
5820
+ style: {
5821
+ margin: "0 0 4px 0",
5822
+ color: "#1E40AF",
5823
+ fontSize: "13px",
5824
+ fontWeight: 600
5825
+ },
5826
+ children: "Recommended Wallet"
5827
+ }
5828
+ ),
5829
+ /* @__PURE__ */ jsx(
5830
+ "p",
5831
+ {
5832
+ style: {
5833
+ margin: 0,
5834
+ color: "#1E3A8A",
5835
+ fontSize: "12px",
5836
+ lineHeight: "1.4"
5837
+ },
5838
+ children: "For Arbitrum Sepolia, we recommend using Rabby wallet instead of MetaMask for the best experience."
5839
+ }
5840
+ )
5841
+ ] })
5842
+ ]
5843
+ }
5844
+ ),
5666
5845
  isConnected && address ? /* @__PURE__ */ jsxs(
5667
5846
  "div",
5668
5847
  {
@@ -7053,7 +7232,7 @@ const DepositModal = React.memo(
7053
7232
  address: sourceAddress || address,
7054
7233
  supportedChains,
7055
7234
  fetchBalances,
7056
- refreshInterval: 3e4
7235
+ refreshInterval: 8e3
7057
7236
  });
7058
7237
  const [isExecuting, setIsExecuting] = useState(false);
7059
7238
  const [error, setError] = useState(null);
@@ -7091,6 +7270,26 @@ const DepositModal = React.memo(
7091
7270
  });
7092
7271
  }
7093
7272
  }, [depositAmount]);
7273
+ useEffect(() => {
7274
+ if (selectedDepositAssets.length === 0) return;
7275
+ setSelectedDepositAssets((prev) => {
7276
+ return prev.map((selectedItem) => {
7277
+ if (!selectedItem.asset) return selectedItem;
7278
+ const freshAsset = depositAssets.find(
7279
+ (a) => a.chainId === selectedItem.asset.chainId && a.address.toLowerCase() === selectedItem.asset.address.toLowerCase()
7280
+ );
7281
+ if (freshAsset) {
7282
+ return {
7283
+ ...selectedItem,
7284
+ asset: freshAsset,
7285
+ // Preserve the user's entered amount
7286
+ amount: selectedItem.amount
7287
+ };
7288
+ }
7289
+ return selectedItem;
7290
+ });
7291
+ });
7292
+ }, [assets]);
7094
7293
  useEffect(() => {
7095
7294
  if (nonEip7702Mode && intentStatus?.overallStatus === "success" && postDepositInstruction && postDepositStatus === "idle") {
7096
7295
  const bridgedAmount = bridgedAmountRef.current;
@@ -7141,8 +7340,16 @@ const DepositModal = React.memo(
7141
7340
  const errorMessage = error2?.message || String(error2 || "");
7142
7341
  const errorDetails = error2?.details || "";
7143
7342
  const errorString = `${errorMessage} ${errorDetails}`.toLowerCase();
7343
+ console.error("RPC Error Details:", {
7344
+ code: error2?.code,
7345
+ message: errorMessage,
7346
+ details: errorDetails,
7347
+ data: error2?.data,
7348
+ stack: error2?.stack,
7349
+ fullError: error2
7350
+ });
7144
7351
  if (errorString.includes("internal json-rpc error") || errorString.includes("internal error") || errorString.includes("an internal error was received")) {
7145
- return "Network error occurred. Please try again.";
7352
+ return "RPC Network error. Try switching your MetaMask RPC endpoint or try again.";
7146
7353
  }
7147
7354
  return errorMessage || "Transaction failed";
7148
7355
  }, []);
@@ -7232,6 +7439,7 @@ const DepositModal = React.memo(
7232
7439
  }
7233
7440
  setAirdropMessage("Airdrop requested successfully.");
7234
7441
  } catch (e) {
7442
+ console.log(e);
7235
7443
  const msg = handleRpcError(e);
7236
7444
  setAirdropError(msg);
7237
7445
  } finally {
@@ -7355,6 +7563,11 @@ const DepositModal = React.memo(
7355
7563
  }
7356
7564
  if (currentChain?.id !== chainId) {
7357
7565
  setError("Wrong chain selected. Switching network...");
7566
+ console.log("Attempting to switch to chain:", {
7567
+ chainId,
7568
+ currentChainId: currentChain?.id,
7569
+ chainName: getChainName$1(chainId)
7570
+ });
7358
7571
  try {
7359
7572
  await switchChainAsync({ chainId });
7360
7573
  let attempts = 0;
@@ -7441,6 +7654,14 @@ const DepositModal = React.memo(
7441
7654
  tokenAddress = "0x0";
7442
7655
  }
7443
7656
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
7657
+ console.log("Sending transaction via MetaMask:", {
7658
+ chainId,
7659
+ isNative,
7660
+ tokenAddress,
7661
+ delegateContract,
7662
+ amount: amount.toString(),
7663
+ walletChainId: externalWalletClient.chain?.id
7664
+ });
7444
7665
  const txHash = isNative ? await externalWalletClient.sendTransaction({
7445
7666
  to: delegateContract,
7446
7667
  value: amount
@@ -7581,6 +7802,14 @@ const DepositModal = React.memo(
7581
7802
  tokenAddress = "0x0";
7582
7803
  }
7583
7804
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
7805
+ console.log("Sending EIP-7702 transaction via MetaMask:", {
7806
+ chainId,
7807
+ isNative,
7808
+ tokenAddress,
7809
+ amount: amount.toString(),
7810
+ recipient: address,
7811
+ walletChainId: externalWalletClient.chain?.id
7812
+ });
7584
7813
  const transferToEmbeddedTx = isNative ? await externalWalletClient.sendTransaction({
7585
7814
  to: address,
7586
7815
  value: amount
@@ -10208,7 +10437,7 @@ const SpiceWithdraw = (props) => {
10208
10437
  }
10209
10438
  const transports = {};
10210
10439
  chains.forEach((chain) => {
10211
- transports[chain.id] = http$1();
10440
+ transports[chain.id] = http$1(chain.rpc);
10212
10441
  });
10213
10442
  const connectorsList = [metaMask()];
10214
10443
  if (walletConnectProjectId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",