@spicenet-io/spiceflow-ui 1.2.4 → 1.2.5

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
@@ -6141,11 +6141,9 @@ const DepositModal = React.memo(
6141
6141
  refreshAssets
6142
6142
  } = useAssets({
6143
6143
  address: sourceAddress || address,
6144
- // Prioritize external wallet for showing balances
6145
6144
  supportedChains,
6146
6145
  fetchBalances,
6147
6146
  refreshInterval: 3e4
6148
- // Refresh balances every 30 seconds
6149
6147
  });
6150
6148
  const [isExecuting, setIsExecuting] = React.useState(false);
6151
6149
  const [error, setError] = React.useState(null);
@@ -6183,29 +6181,23 @@ const DepositModal = React.memo(
6183
6181
  if (nonEip7702Mode && intentStatus?.overallStatus === "success" && postDepositInstruction && postDepositStatus === "idle") {
6184
6182
  const bridgedAmount = bridgedAmountRef.current;
6185
6183
  const depositData = depositDataRef.current;
6186
- console.log("Success detected, bridgedAmount from ref:", bridgedAmount);
6187
- console.log("Deposit data from ref:", depositData);
6188
6184
  if (bridgedAmount) {
6189
6185
  (async () => {
6190
6186
  try {
6191
- console.log(
6192
- "Calling postDepositInstruction with:",
6193
- bridgedAmount
6194
- );
6195
6187
  setPostDepositStatus("executing");
6196
6188
  await postDepositInstruction(bridgedAmount);
6197
6189
  if (depositData && depositData.length > 0) {
6198
6190
  console.log(
6199
- "Submitting deposit data to backend after successful postDepositInstruction"
6191
+ "Submitting deposit data to backend after bridging completes:",
6192
+ depositData
6200
6193
  );
6201
6194
  for (const data of depositData) {
6202
- await relayerService.submitSpiceDeposit({
6203
- ...data,
6204
- chainId: destinationChainId
6205
- // Use destination chain, not source
6206
- });
6195
+ console.log("Calling submitSpiceDeposit with:", data);
6196
+ await relayerService.submitSpiceDeposit(data);
6197
+ console.log(
6198
+ `Successfully submitted deposit for txHash: ${data.txHash} on chainId: ${data.chainId}`
6199
+ );
6207
6200
  }
6208
- console.log("All deposit data submitted successfully");
6209
6201
  }
6210
6202
  setPostDepositStatus("success");
6211
6203
  setPostDepositAmount(bridgedAmount);
@@ -6224,10 +6216,6 @@ const DepositModal = React.memo(
6224
6216
  depositDataRef.current = null;
6225
6217
  }
6226
6218
  })();
6227
- } else {
6228
- console.error(
6229
- "bridgedAmountRef.current is null/undefined when success detected"
6230
- );
6231
6219
  }
6232
6220
  }
6233
6221
  }, [intentStatus?.overallStatus, nonEip7702Mode, postDepositStatus]);
@@ -6373,15 +6361,13 @@ const DepositModal = React.memo(
6373
6361
  throw new Error(
6374
6362
  `Chain ${chainId} is not configured in your wallet. Please add it manually.`
6375
6363
  );
6376
- } else {
6377
- throw switchError;
6378
6364
  }
6365
+ throw switchError;
6379
6366
  }
6380
6367
  }
6381
6368
  if (nonEip7702Mode) {
6382
6369
  const isNativeChainDeposit = nativeChainId && chainId === nativeChainId;
6383
6370
  if (isNativeChainDeposit) {
6384
- console.log("Native chain detected, skipping bridging");
6385
6371
  if (!postDepositInstruction) {
6386
6372
  throw new Error(
6387
6373
  "Post-deposit instruction is required for native chain deposits"
@@ -6396,7 +6382,7 @@ const DepositModal = React.memo(
6396
6382
  chainId
6397
6383
  });
6398
6384
  setShowConfirmation(true);
6399
- if (validAssets.length > 0 && validAssets[0]?.amount) {
6385
+ if (validAssets[0]?.amount) {
6400
6386
  const amountToStore = validAssets[0].amount;
6401
6387
  setPostDepositStatus("executing");
6402
6388
  try {
@@ -6404,29 +6390,6 @@ const DepositModal = React.memo(
6404
6390
  setPostDepositStatus("success");
6405
6391
  setPostDepositAmount(amountToStore);
6406
6392
  setPostDepositSuccess(true);
6407
- for (const selectedAsset of validAssets) {
6408
- const amount = viem.parseUnits(
6409
- selectedAsset.amount,
6410
- selectedAsset.asset.decimals
6411
- );
6412
- let tokenAddress = selectedAsset.asset.address;
6413
- if ([
6414
- "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
6415
- "0x0000000000000000000000000000000000000000"
6416
- ].includes(tokenAddress.toLowerCase())) {
6417
- tokenAddress = "0x0";
6418
- }
6419
- await relayerService.submitSpiceDeposit({
6420
- txHash: "0x0",
6421
- // Placeholder for native chain deposits
6422
- sender: sourceAddress,
6423
- tokenAddress: destinationTokenAddress ? destinationTokenAddress : tokenAddress,
6424
- chainId,
6425
- // Native chain = destination chain
6426
- amount: amount.toString(),
6427
- user: sourceAddress
6428
- });
6429
- }
6430
6393
  } catch (error2) {
6431
6394
  console.error("postDepositInstruction failed:", error2);
6432
6395
  setPostDepositStatus("error");
@@ -6449,11 +6412,6 @@ const DepositModal = React.memo(
6449
6412
  const tokenTransfers = [];
6450
6413
  let sourceTransactionHash = null;
6451
6414
  for (const selectedAsset of validAssets) {
6452
- console.log(
6453
- selectedAsset.asset.symbol,
6454
- selectedAsset.amount,
6455
- selectedAsset.asset.decimals
6456
- );
6457
6415
  const amount = viem.parseUnits(
6458
6416
  selectedAsset.amount,
6459
6417
  selectedAsset.asset.decimals
@@ -6466,35 +6424,34 @@ const DepositModal = React.memo(
6466
6424
  tokenAddress = "0x0";
6467
6425
  }
6468
6426
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
6469
- let txHash;
6470
- if (isNative) {
6471
- txHash = await externalWalletClient.sendTransaction({
6472
- to: delegateContract,
6473
- value: amount
6474
- });
6475
- } else {
6476
- const transferData2 = viem.encodeFunctionData({
6427
+ const txHash = isNative ? await externalWalletClient.sendTransaction({
6428
+ to: delegateContract,
6429
+ value: amount
6430
+ }) : await externalWalletClient.sendTransaction({
6431
+ to: tokenAddress,
6432
+ data: viem.encodeFunctionData({
6477
6433
  abi: erc20ABI,
6478
6434
  functionName: "transfer",
6479
6435
  args: [delegateContract, amount]
6480
- });
6481
- txHash = await externalWalletClient.sendTransaction({
6482
- to: tokenAddress,
6483
- data: transferData2
6484
- });
6485
- }
6436
+ })
6437
+ });
6486
6438
  if (!sourceTransactionHash) {
6487
6439
  sourceTransactionHash = txHash;
6488
6440
  }
6489
- console.log("txHash", txHash);
6490
6441
  const client = getClientForChain(chainId);
6491
- console.log(client.chain?.id);
6442
+ console.log(`Waiting for transaction receipt: ${txHash}`);
6492
6443
  const receipt = await client.waitForTransactionReceipt({
6493
6444
  hash: txHash,
6494
6445
  timeout: 6e4,
6495
6446
  pollingInterval: 5e3,
6496
6447
  confirmations: 1
6497
6448
  });
6449
+ console.log("Transaction receipt:", {
6450
+ hash: receipt.transactionHash,
6451
+ blockNumber: receipt.blockNumber,
6452
+ status: receipt.status,
6453
+ confirmations: 1
6454
+ });
6498
6455
  if (receipt.status !== "success") {
6499
6456
  throw new Error(
6500
6457
  `Transfer to delegate contract failed for ${selectedAsset.asset.symbol}`
@@ -6511,13 +6468,19 @@ const DepositModal = React.memo(
6511
6468
  amount: amount.toString(),
6512
6469
  user: sourceAddress
6513
6470
  });
6514
- const transferData = {
6471
+ console.log("Stored deposit data for later submission:", {
6472
+ txHash,
6473
+ sender: sourceAddress,
6474
+ tokenAddress,
6475
+ chainId,
6476
+ amount: amount.toString()
6477
+ });
6478
+ tokenTransfers.push({
6515
6479
  tokenAddress,
6516
6480
  tokenAmount: amount.toString(),
6517
6481
  sender: sourceAddress,
6518
6482
  receiver: delegateContract
6519
- };
6520
- tokenTransfers.push(transferData);
6483
+ });
6521
6484
  }
6522
6485
  if (!sourceTransactionHash) {
6523
6486
  throw new Error("No transaction hash generated");
@@ -6537,20 +6500,8 @@ const DepositModal = React.memo(
6537
6500
  });
6538
6501
  if (result.success && result.data) {
6539
6502
  const transactionId = result.data.transactionId;
6540
- if (validAssets.length > 0 && validAssets[0]?.amount) {
6541
- const amountToStore = validAssets[0].amount;
6542
- bridgedAmountRef.current = amountToStore;
6543
- console.log(
6544
- "Stored bridged amount in ref:",
6545
- amountToStore,
6546
- "Ref now:",
6547
- bridgedAmountRef.current
6548
- );
6549
- } else {
6550
- console.log(
6551
- "No valid assets or amount found. validAssets:",
6552
- validAssets
6553
- );
6503
+ if (validAssets[0]?.amount) {
6504
+ bridgedAmountRef.current = validAssets[0].amount;
6554
6505
  }
6555
6506
  if (transactionId) {
6556
6507
  const chainConfig = getChainConfig(chainId);
@@ -6590,39 +6541,46 @@ const DepositModal = React.memo(
6590
6541
  tokenAddress = "0x0";
6591
6542
  }
6592
6543
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
6593
- let transferToEmbeddedTx;
6594
- if (isNative) {
6595
- transferToEmbeddedTx = await externalWalletClient.sendTransaction(
6596
- {
6597
- to: address,
6598
- value: amount
6599
- }
6600
- );
6601
- } else {
6602
- const transferToEmbeddedData = viem.encodeFunctionData({
6544
+ const transferToEmbeddedTx = isNative ? await externalWalletClient.sendTransaction({
6545
+ to: address,
6546
+ value: amount
6547
+ }) : await externalWalletClient.sendTransaction({
6548
+ to: tokenAddress,
6549
+ data: viem.encodeFunctionData({
6603
6550
  abi: erc20ABI,
6604
6551
  functionName: "transfer",
6605
6552
  args: [address, amount]
6606
- });
6607
- transferToEmbeddedTx = await externalWalletClient.sendTransaction(
6608
- {
6609
- to: tokenAddress,
6610
- data: transferToEmbeddedData
6611
- }
6612
- );
6613
- }
6553
+ })
6554
+ });
6614
6555
  const client2 = getClientForChain(chainId);
6556
+ console.log(
6557
+ `Waiting for transaction receipt (EIP-7702): ${transferToEmbeddedTx}`
6558
+ );
6615
6559
  const receipt = await client2.waitForTransactionReceipt({
6616
6560
  hash: transferToEmbeddedTx,
6617
6561
  timeout: 6e4,
6618
- pollingInterval: 5e3
6562
+ pollingInterval: 5e3,
6563
+ confirmations: 1
6564
+ });
6565
+ console.log("Transaction receipt (EIP-7702):", {
6566
+ hash: receipt.transactionHash,
6567
+ blockNumber: receipt.blockNumber,
6568
+ status: receipt.status,
6569
+ confirmations: 1
6619
6570
  });
6620
6571
  if (receipt.status !== "success") {
6621
6572
  throw new Error(
6622
6573
  `Transfer to embedded wallet failed for ${selectedAsset.asset.symbol}`
6623
6574
  );
6624
6575
  }
6625
- console.log("Submitting deposit to API");
6576
+ console.log("Calling submitSpiceDeposit (EIP-7702) with:", {
6577
+ txHash: transferToEmbeddedTx,
6578
+ sender: sourceAddress,
6579
+ tokenAddress,
6580
+ chainId,
6581
+ amount: amount.toString(),
6582
+ user: address
6583
+ });
6626
6584
  await relayerService.submitSpiceDeposit({
6627
6585
  txHash: transferToEmbeddedTx,
6628
6586
  sender: sourceAddress,
@@ -6631,15 +6589,15 @@ const DepositModal = React.memo(
6631
6589
  amount: amount.toString(),
6632
6590
  user: address
6633
6591
  });
6634
- console.log("Deposit successfully submitted to API");
6635
- if (isNative) {
6636
- escrowCalls.push({
6592
+ console.log(
6593
+ `Successfully submitted deposit for txHash: ${transferToEmbeddedTx}`
6594
+ );
6595
+ escrowCalls.push(
6596
+ isNative ? {
6637
6597
  to: escrowAddress,
6638
6598
  value: amount,
6639
6599
  data: "0x"
6640
- });
6641
- } else {
6642
- escrowCalls.push({
6600
+ } : {
6643
6601
  to: tokenAddress,
6644
6602
  value: BigInt(0),
6645
6603
  data: viem.encodeFunctionData({
@@ -6647,18 +6605,14 @@ const DepositModal = React.memo(
6647
6605
  functionName: "transfer",
6648
6606
  args: [escrowAddress, amount]
6649
6607
  })
6650
- });
6651
- }
6652
- let transferData = {
6608
+ }
6609
+ );
6610
+ tokenTransfers.push({
6653
6611
  tokenAddress,
6654
6612
  tokenAmount: amount,
6655
6613
  sender: address,
6656
- receiver: ""
6657
- };
6658
- if (!isNative) {
6659
- transferData.receiver = escrowAddress;
6660
- }
6661
- tokenTransfers.push(transferData);
6614
+ receiver: isNative ? "" : escrowAddress
6615
+ });
6662
6616
  }
6663
6617
  const client = getClientForChain(chainId);
6664
6618
  const sourceRecentBlock = await client.getBlockNumber();
@@ -6767,13 +6721,24 @@ const DepositModal = React.memo(
6767
6721
  return allAvailable;
6768
6722
  }, [supportedChains, assets, allowedTokens]);
6769
6723
  const secondAssetOptions = React.useMemo(() => {
6770
- if (selectedDepositAssets.length === 0 || !selectedDepositAssets[0]?.asset) {
6724
+ if (!selectedDepositAssets[0]?.asset) {
6771
6725
  return [];
6772
6726
  }
6773
6727
  const firstChainId = selectedDepositAssets[0].asset.chainId;
6774
6728
  return depositAssets.filter((asset) => asset.chainId === firstChainId);
6775
6729
  }, [depositAssets, selectedDepositAssets]);
6776
6730
  const canDeposit = selectedDepositAssets.length > 0 && selectedDepositAssets[0]?.asset && selectedDepositAssets[0]?.amount && parseFloat(selectedDepositAssets[0].amount) > 0 && isConnected && !isExecuting;
6731
+ const getButtonLabel = () => {
6732
+ if (isExecuting) return "Executing Deposit...";
6733
+ if (!isConnected) return "Wallet Not Connected";
6734
+ if (!nonEip7702Mode) {
6735
+ if (!ready) return "Loading...";
6736
+ if (!authenticated) return "Authentication Required";
6737
+ }
6738
+ if (!selectedDepositAssets[0]?.asset) return "SELECT TOKEN";
6739
+ if (!selectedDepositAssets[0]?.amount) return "ENTER AMOUNT";
6740
+ return "DEPOSIT";
6741
+ };
6777
6742
  if (!isOpen) return null;
6778
6743
  const subtitle = /* @__PURE__ */ jsxRuntime.jsxs(
6779
6744
  "div",
@@ -6825,7 +6790,6 @@ const DepositModal = React.memo(
6825
6790
  theme,
6826
6791
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "24px 24px 5px 24px" }, children: [
6827
6792
  selectedDepositAssets.map((selectedAsset, index) => {
6828
- const assetKey = `asset-${index}`;
6829
6793
  const label = selectedDepositAssets.length === 1 ? "Deposit" : `Asset ${index + 1}`;
6830
6794
  return /* @__PURE__ */ jsxRuntime.jsxs(
6831
6795
  "div",
@@ -6891,7 +6855,7 @@ const DepositModal = React.memo(
6891
6855
  )
6892
6856
  ]
6893
6857
  },
6894
- assetKey
6858
+ `asset-${index}`
6895
6859
  );
6896
6860
  }),
6897
6861
  selectedDepositAssets.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginBottom: theme.spacing.md }, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -7019,7 +6983,7 @@ const DepositModal = React.memo(
7019
6983
  ...styles?.button
7020
6984
  }
7021
6985
  },
7022
- children: nonEip7702Mode ? !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : selectedDepositAssets.length === 0 || !selectedDepositAssets[0]?.asset ? "SELECT TOKEN" : !selectedDepositAssets[0]?.amount ? "ENTER AMOUNT" : "DEPOSIT" : !ready ? "Loading..." : !authenticated ? "Authentication Required" : !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : selectedDepositAssets.length === 0 || !selectedDepositAssets[0]?.asset ? "SELECT TOKEN" : !selectedDepositAssets[0]?.amount ? "ENTER AMOUNT" : "DEPOSIT"
6986
+ children: getButtonLabel()
7023
6987
  }
7024
6988
  )
7025
6989
  }
package/dist/index.js CHANGED
@@ -6139,11 +6139,9 @@ const DepositModal = React.memo(
6139
6139
  refreshAssets
6140
6140
  } = useAssets({
6141
6141
  address: sourceAddress || address,
6142
- // Prioritize external wallet for showing balances
6143
6142
  supportedChains,
6144
6143
  fetchBalances,
6145
6144
  refreshInterval: 3e4
6146
- // Refresh balances every 30 seconds
6147
6145
  });
6148
6146
  const [isExecuting, setIsExecuting] = useState(false);
6149
6147
  const [error, setError] = useState(null);
@@ -6181,29 +6179,23 @@ const DepositModal = React.memo(
6181
6179
  if (nonEip7702Mode && intentStatus?.overallStatus === "success" && postDepositInstruction && postDepositStatus === "idle") {
6182
6180
  const bridgedAmount = bridgedAmountRef.current;
6183
6181
  const depositData = depositDataRef.current;
6184
- console.log("Success detected, bridgedAmount from ref:", bridgedAmount);
6185
- console.log("Deposit data from ref:", depositData);
6186
6182
  if (bridgedAmount) {
6187
6183
  (async () => {
6188
6184
  try {
6189
- console.log(
6190
- "Calling postDepositInstruction with:",
6191
- bridgedAmount
6192
- );
6193
6185
  setPostDepositStatus("executing");
6194
6186
  await postDepositInstruction(bridgedAmount);
6195
6187
  if (depositData && depositData.length > 0) {
6196
6188
  console.log(
6197
- "Submitting deposit data to backend after successful postDepositInstruction"
6189
+ "Submitting deposit data to backend after bridging completes:",
6190
+ depositData
6198
6191
  );
6199
6192
  for (const data of depositData) {
6200
- await relayerService.submitSpiceDeposit({
6201
- ...data,
6202
- chainId: destinationChainId
6203
- // Use destination chain, not source
6204
- });
6193
+ console.log("Calling submitSpiceDeposit with:", data);
6194
+ await relayerService.submitSpiceDeposit(data);
6195
+ console.log(
6196
+ `Successfully submitted deposit for txHash: ${data.txHash} on chainId: ${data.chainId}`
6197
+ );
6205
6198
  }
6206
- console.log("All deposit data submitted successfully");
6207
6199
  }
6208
6200
  setPostDepositStatus("success");
6209
6201
  setPostDepositAmount(bridgedAmount);
@@ -6222,10 +6214,6 @@ const DepositModal = React.memo(
6222
6214
  depositDataRef.current = null;
6223
6215
  }
6224
6216
  })();
6225
- } else {
6226
- console.error(
6227
- "bridgedAmountRef.current is null/undefined when success detected"
6228
- );
6229
6217
  }
6230
6218
  }
6231
6219
  }, [intentStatus?.overallStatus, nonEip7702Mode, postDepositStatus]);
@@ -6371,15 +6359,13 @@ const DepositModal = React.memo(
6371
6359
  throw new Error(
6372
6360
  `Chain ${chainId} is not configured in your wallet. Please add it manually.`
6373
6361
  );
6374
- } else {
6375
- throw switchError;
6376
6362
  }
6363
+ throw switchError;
6377
6364
  }
6378
6365
  }
6379
6366
  if (nonEip7702Mode) {
6380
6367
  const isNativeChainDeposit = nativeChainId && chainId === nativeChainId;
6381
6368
  if (isNativeChainDeposit) {
6382
- console.log("Native chain detected, skipping bridging");
6383
6369
  if (!postDepositInstruction) {
6384
6370
  throw new Error(
6385
6371
  "Post-deposit instruction is required for native chain deposits"
@@ -6394,7 +6380,7 @@ const DepositModal = React.memo(
6394
6380
  chainId
6395
6381
  });
6396
6382
  setShowConfirmation(true);
6397
- if (validAssets.length > 0 && validAssets[0]?.amount) {
6383
+ if (validAssets[0]?.amount) {
6398
6384
  const amountToStore = validAssets[0].amount;
6399
6385
  setPostDepositStatus("executing");
6400
6386
  try {
@@ -6402,29 +6388,6 @@ const DepositModal = React.memo(
6402
6388
  setPostDepositStatus("success");
6403
6389
  setPostDepositAmount(amountToStore);
6404
6390
  setPostDepositSuccess(true);
6405
- for (const selectedAsset of validAssets) {
6406
- const amount = parseUnits(
6407
- selectedAsset.amount,
6408
- selectedAsset.asset.decimals
6409
- );
6410
- let tokenAddress = selectedAsset.asset.address;
6411
- if ([
6412
- "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
6413
- "0x0000000000000000000000000000000000000000"
6414
- ].includes(tokenAddress.toLowerCase())) {
6415
- tokenAddress = "0x0";
6416
- }
6417
- await relayerService.submitSpiceDeposit({
6418
- txHash: "0x0",
6419
- // Placeholder for native chain deposits
6420
- sender: sourceAddress,
6421
- tokenAddress: destinationTokenAddress ? destinationTokenAddress : tokenAddress,
6422
- chainId,
6423
- // Native chain = destination chain
6424
- amount: amount.toString(),
6425
- user: sourceAddress
6426
- });
6427
- }
6428
6391
  } catch (error2) {
6429
6392
  console.error("postDepositInstruction failed:", error2);
6430
6393
  setPostDepositStatus("error");
@@ -6447,11 +6410,6 @@ const DepositModal = React.memo(
6447
6410
  const tokenTransfers = [];
6448
6411
  let sourceTransactionHash = null;
6449
6412
  for (const selectedAsset of validAssets) {
6450
- console.log(
6451
- selectedAsset.asset.symbol,
6452
- selectedAsset.amount,
6453
- selectedAsset.asset.decimals
6454
- );
6455
6413
  const amount = parseUnits(
6456
6414
  selectedAsset.amount,
6457
6415
  selectedAsset.asset.decimals
@@ -6464,35 +6422,34 @@ const DepositModal = React.memo(
6464
6422
  tokenAddress = "0x0";
6465
6423
  }
6466
6424
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
6467
- let txHash;
6468
- if (isNative) {
6469
- txHash = await externalWalletClient.sendTransaction({
6470
- to: delegateContract,
6471
- value: amount
6472
- });
6473
- } else {
6474
- const transferData2 = encodeFunctionData({
6425
+ const txHash = isNative ? await externalWalletClient.sendTransaction({
6426
+ to: delegateContract,
6427
+ value: amount
6428
+ }) : await externalWalletClient.sendTransaction({
6429
+ to: tokenAddress,
6430
+ data: encodeFunctionData({
6475
6431
  abi: erc20ABI,
6476
6432
  functionName: "transfer",
6477
6433
  args: [delegateContract, amount]
6478
- });
6479
- txHash = await externalWalletClient.sendTransaction({
6480
- to: tokenAddress,
6481
- data: transferData2
6482
- });
6483
- }
6434
+ })
6435
+ });
6484
6436
  if (!sourceTransactionHash) {
6485
6437
  sourceTransactionHash = txHash;
6486
6438
  }
6487
- console.log("txHash", txHash);
6488
6439
  const client = getClientForChain(chainId);
6489
- console.log(client.chain?.id);
6440
+ console.log(`Waiting for transaction receipt: ${txHash}`);
6490
6441
  const receipt = await client.waitForTransactionReceipt({
6491
6442
  hash: txHash,
6492
6443
  timeout: 6e4,
6493
6444
  pollingInterval: 5e3,
6494
6445
  confirmations: 1
6495
6446
  });
6447
+ console.log("Transaction receipt:", {
6448
+ hash: receipt.transactionHash,
6449
+ blockNumber: receipt.blockNumber,
6450
+ status: receipt.status,
6451
+ confirmations: 1
6452
+ });
6496
6453
  if (receipt.status !== "success") {
6497
6454
  throw new Error(
6498
6455
  `Transfer to delegate contract failed for ${selectedAsset.asset.symbol}`
@@ -6509,13 +6466,19 @@ const DepositModal = React.memo(
6509
6466
  amount: amount.toString(),
6510
6467
  user: sourceAddress
6511
6468
  });
6512
- const transferData = {
6469
+ console.log("Stored deposit data for later submission:", {
6470
+ txHash,
6471
+ sender: sourceAddress,
6472
+ tokenAddress,
6473
+ chainId,
6474
+ amount: amount.toString()
6475
+ });
6476
+ tokenTransfers.push({
6513
6477
  tokenAddress,
6514
6478
  tokenAmount: amount.toString(),
6515
6479
  sender: sourceAddress,
6516
6480
  receiver: delegateContract
6517
- };
6518
- tokenTransfers.push(transferData);
6481
+ });
6519
6482
  }
6520
6483
  if (!sourceTransactionHash) {
6521
6484
  throw new Error("No transaction hash generated");
@@ -6535,20 +6498,8 @@ const DepositModal = React.memo(
6535
6498
  });
6536
6499
  if (result.success && result.data) {
6537
6500
  const transactionId = result.data.transactionId;
6538
- if (validAssets.length > 0 && validAssets[0]?.amount) {
6539
- const amountToStore = validAssets[0].amount;
6540
- bridgedAmountRef.current = amountToStore;
6541
- console.log(
6542
- "Stored bridged amount in ref:",
6543
- amountToStore,
6544
- "Ref now:",
6545
- bridgedAmountRef.current
6546
- );
6547
- } else {
6548
- console.log(
6549
- "No valid assets or amount found. validAssets:",
6550
- validAssets
6551
- );
6501
+ if (validAssets[0]?.amount) {
6502
+ bridgedAmountRef.current = validAssets[0].amount;
6552
6503
  }
6553
6504
  if (transactionId) {
6554
6505
  const chainConfig = getChainConfig(chainId);
@@ -6588,39 +6539,46 @@ const DepositModal = React.memo(
6588
6539
  tokenAddress = "0x0";
6589
6540
  }
6590
6541
  const isNative = selectedAsset.asset.isNative || tokenAddress.toLowerCase() === "0x0";
6591
- let transferToEmbeddedTx;
6592
- if (isNative) {
6593
- transferToEmbeddedTx = await externalWalletClient.sendTransaction(
6594
- {
6595
- to: address,
6596
- value: amount
6597
- }
6598
- );
6599
- } else {
6600
- const transferToEmbeddedData = encodeFunctionData({
6542
+ const transferToEmbeddedTx = isNative ? await externalWalletClient.sendTransaction({
6543
+ to: address,
6544
+ value: amount
6545
+ }) : await externalWalletClient.sendTransaction({
6546
+ to: tokenAddress,
6547
+ data: encodeFunctionData({
6601
6548
  abi: erc20ABI,
6602
6549
  functionName: "transfer",
6603
6550
  args: [address, amount]
6604
- });
6605
- transferToEmbeddedTx = await externalWalletClient.sendTransaction(
6606
- {
6607
- to: tokenAddress,
6608
- data: transferToEmbeddedData
6609
- }
6610
- );
6611
- }
6551
+ })
6552
+ });
6612
6553
  const client2 = getClientForChain(chainId);
6554
+ console.log(
6555
+ `Waiting for transaction receipt (EIP-7702): ${transferToEmbeddedTx}`
6556
+ );
6613
6557
  const receipt = await client2.waitForTransactionReceipt({
6614
6558
  hash: transferToEmbeddedTx,
6615
6559
  timeout: 6e4,
6616
- pollingInterval: 5e3
6560
+ pollingInterval: 5e3,
6561
+ confirmations: 1
6562
+ });
6563
+ console.log("Transaction receipt (EIP-7702):", {
6564
+ hash: receipt.transactionHash,
6565
+ blockNumber: receipt.blockNumber,
6566
+ status: receipt.status,
6567
+ confirmations: 1
6617
6568
  });
6618
6569
  if (receipt.status !== "success") {
6619
6570
  throw new Error(
6620
6571
  `Transfer to embedded wallet failed for ${selectedAsset.asset.symbol}`
6621
6572
  );
6622
6573
  }
6623
- console.log("Submitting deposit to API");
6574
+ console.log("Calling submitSpiceDeposit (EIP-7702) with:", {
6575
+ txHash: transferToEmbeddedTx,
6576
+ sender: sourceAddress,
6577
+ tokenAddress,
6578
+ chainId,
6579
+ amount: amount.toString(),
6580
+ user: address
6581
+ });
6624
6582
  await relayerService.submitSpiceDeposit({
6625
6583
  txHash: transferToEmbeddedTx,
6626
6584
  sender: sourceAddress,
@@ -6629,15 +6587,15 @@ const DepositModal = React.memo(
6629
6587
  amount: amount.toString(),
6630
6588
  user: address
6631
6589
  });
6632
- console.log("Deposit successfully submitted to API");
6633
- if (isNative) {
6634
- escrowCalls.push({
6590
+ console.log(
6591
+ `Successfully submitted deposit for txHash: ${transferToEmbeddedTx}`
6592
+ );
6593
+ escrowCalls.push(
6594
+ isNative ? {
6635
6595
  to: escrowAddress,
6636
6596
  value: amount,
6637
6597
  data: "0x"
6638
- });
6639
- } else {
6640
- escrowCalls.push({
6598
+ } : {
6641
6599
  to: tokenAddress,
6642
6600
  value: BigInt(0),
6643
6601
  data: encodeFunctionData({
@@ -6645,18 +6603,14 @@ const DepositModal = React.memo(
6645
6603
  functionName: "transfer",
6646
6604
  args: [escrowAddress, amount]
6647
6605
  })
6648
- });
6649
- }
6650
- let transferData = {
6606
+ }
6607
+ );
6608
+ tokenTransfers.push({
6651
6609
  tokenAddress,
6652
6610
  tokenAmount: amount,
6653
6611
  sender: address,
6654
- receiver: ""
6655
- };
6656
- if (!isNative) {
6657
- transferData.receiver = escrowAddress;
6658
- }
6659
- tokenTransfers.push(transferData);
6612
+ receiver: isNative ? "" : escrowAddress
6613
+ });
6660
6614
  }
6661
6615
  const client = getClientForChain(chainId);
6662
6616
  const sourceRecentBlock = await client.getBlockNumber();
@@ -6765,13 +6719,24 @@ const DepositModal = React.memo(
6765
6719
  return allAvailable;
6766
6720
  }, [supportedChains, assets, allowedTokens]);
6767
6721
  const secondAssetOptions = useMemo(() => {
6768
- if (selectedDepositAssets.length === 0 || !selectedDepositAssets[0]?.asset) {
6722
+ if (!selectedDepositAssets[0]?.asset) {
6769
6723
  return [];
6770
6724
  }
6771
6725
  const firstChainId = selectedDepositAssets[0].asset.chainId;
6772
6726
  return depositAssets.filter((asset) => asset.chainId === firstChainId);
6773
6727
  }, [depositAssets, selectedDepositAssets]);
6774
6728
  const canDeposit = selectedDepositAssets.length > 0 && selectedDepositAssets[0]?.asset && selectedDepositAssets[0]?.amount && parseFloat(selectedDepositAssets[0].amount) > 0 && isConnected && !isExecuting;
6729
+ const getButtonLabel = () => {
6730
+ if (isExecuting) return "Executing Deposit...";
6731
+ if (!isConnected) return "Wallet Not Connected";
6732
+ if (!nonEip7702Mode) {
6733
+ if (!ready) return "Loading...";
6734
+ if (!authenticated) return "Authentication Required";
6735
+ }
6736
+ if (!selectedDepositAssets[0]?.asset) return "SELECT TOKEN";
6737
+ if (!selectedDepositAssets[0]?.amount) return "ENTER AMOUNT";
6738
+ return "DEPOSIT";
6739
+ };
6775
6740
  if (!isOpen) return null;
6776
6741
  const subtitle = /* @__PURE__ */ jsxs(
6777
6742
  "div",
@@ -6823,7 +6788,6 @@ const DepositModal = React.memo(
6823
6788
  theme,
6824
6789
  children: /* @__PURE__ */ jsxs("div", { style: { padding: "24px 24px 5px 24px" }, children: [
6825
6790
  selectedDepositAssets.map((selectedAsset, index) => {
6826
- const assetKey = `asset-${index}`;
6827
6791
  const label = selectedDepositAssets.length === 1 ? "Deposit" : `Asset ${index + 1}`;
6828
6792
  return /* @__PURE__ */ jsxs(
6829
6793
  "div",
@@ -6889,7 +6853,7 @@ const DepositModal = React.memo(
6889
6853
  )
6890
6854
  ]
6891
6855
  },
6892
- assetKey
6856
+ `asset-${index}`
6893
6857
  );
6894
6858
  }),
6895
6859
  selectedDepositAssets.length === 0 && /* @__PURE__ */ jsx("div", { style: { marginBottom: theme.spacing.md }, children: /* @__PURE__ */ jsx(
@@ -7017,7 +6981,7 @@ const DepositModal = React.memo(
7017
6981
  ...styles?.button
7018
6982
  }
7019
6983
  },
7020
- children: nonEip7702Mode ? !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : selectedDepositAssets.length === 0 || !selectedDepositAssets[0]?.asset ? "SELECT TOKEN" : !selectedDepositAssets[0]?.amount ? "ENTER AMOUNT" : "DEPOSIT" : !ready ? "Loading..." : !authenticated ? "Authentication Required" : !isConnected ? "Wallet Not Connected" : isExecuting ? "Executing Deposit..." : selectedDepositAssets.length === 0 || !selectedDepositAssets[0]?.asset ? "SELECT TOKEN" : !selectedDepositAssets[0]?.amount ? "ENTER AMOUNT" : "DEPOSIT"
6984
+ children: getButtonLabel()
7021
6985
  }
7022
6986
  )
7023
6987
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",