@spicenet-io/spiceflow-ui 1.6.6 → 1.7.0

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.
@@ -16,5 +16,6 @@ export interface SpiceDepositProps {
16
16
  postDepositInstruction?: (bridgedAmount: string) => Promise<void> | void;
17
17
  postDepositInstructionLabel?: string;
18
18
  airdrop?: boolean;
19
+ sponsorGas?: boolean;
19
20
  }
20
21
  export declare const SpiceDeposit: React.FC<SpiceDepositProps>;
package/dist/index.cjs.js CHANGED
@@ -6917,7 +6917,8 @@ const DepositModal = React.memo(
6917
6917
  postDepositInstruction,
6918
6918
  postDepositInstructionLabel,
6919
6919
  nativeChainId,
6920
- airdrop = false
6920
+ airdrop = false,
6921
+ sponsorGas = false
6921
6922
  }) => {
6922
6923
  const depositAmount = depositInputHook?.depositAmount || "";
6923
6924
  const setDepositAmount = depositInputHook?.setDepositAmount || (() => {
@@ -7260,21 +7261,28 @@ const DepositModal = React.memo(
7260
7261
  console.log(`Waiting for transaction receipt: ${txHash}`);
7261
7262
  const receipt = await client.waitForTransactionReceipt({
7262
7263
  hash: txHash,
7263
- timeout: 6e4,
7264
- pollingInterval: 5e3,
7265
- confirmations: 1
7264
+ timeout: 12e4,
7265
+ pollingInterval: 2e3,
7266
+ confirmations: 2
7266
7267
  });
7267
7268
  console.log("Transaction receipt:", {
7268
7269
  hash: receipt.transactionHash,
7269
7270
  blockNumber: receipt.blockNumber,
7270
7271
  status: receipt.status,
7271
- confirmations: 1
7272
+ confirmations: 2
7272
7273
  });
7273
7274
  if (receipt.status !== "success") {
7274
7275
  throw new Error(
7275
7276
  `Transfer to delegate contract failed for ${selectedAsset.asset.symbol}`
7276
7277
  );
7277
7278
  }
7279
+ const currentBlock = await client.getBlockNumber();
7280
+ const confirmations = currentBlock - receipt.blockNumber;
7281
+ console.log(`Transaction has ${confirmations} confirmations`);
7282
+ if (confirmations < 2) {
7283
+ console.log("Waiting for additional confirmations...");
7284
+ await new Promise((resolve) => setTimeout(resolve, 3e3));
7285
+ }
7278
7286
  if (!depositDataRef.current) {
7279
7287
  depositDataRef.current = [];
7280
7288
  }
@@ -7303,11 +7311,27 @@ const DepositModal = React.memo(
7303
7311
  if (!sourceTransactionHash) {
7304
7312
  throw new Error("No transaction hash generated");
7305
7313
  }
7314
+ const finalClient = getClientForChain(chainId);
7315
+ const finalBlock = await finalClient.getBlockNumber();
7316
+ console.log(
7317
+ "Final block number before relayer submission:",
7318
+ finalBlock
7319
+ );
7320
+ console.log("All transactions confirmed, submitting to relayer...");
7306
7321
  if (!destinationTokenAddress) {
7307
7322
  throw new Error(
7308
7323
  "Destination token address is required for bridging"
7309
7324
  );
7310
7325
  }
7326
+ if (sponsorGas && nativeChainId) {
7327
+ const gasAmount = viem.parseUnits("0.0003", 18);
7328
+ tokenTransfers.push({
7329
+ tokenAddress: "0x0",
7330
+ tokenAmount: gasAmount.toString(),
7331
+ sender: sourceAddress,
7332
+ receiver: delegateContract
7333
+ });
7334
+ }
7311
7335
  const result = await relayerService.submitTransactionNon7702({
7312
7336
  tokenTransfers: [tokenTransfers],
7313
7337
  user: sourceAddress,
@@ -7376,21 +7400,28 @@ const DepositModal = React.memo(
7376
7400
  );
7377
7401
  const receipt = await client2.waitForTransactionReceipt({
7378
7402
  hash: transferToEmbeddedTx,
7379
- timeout: 6e4,
7380
- pollingInterval: 5e3,
7381
- confirmations: 1
7403
+ timeout: 12e4,
7404
+ pollingInterval: 2e3,
7405
+ confirmations: 2
7382
7406
  });
7383
7407
  console.log("Transaction receipt (EIP-7702):", {
7384
7408
  hash: receipt.transactionHash,
7385
7409
  blockNumber: receipt.blockNumber,
7386
7410
  status: receipt.status,
7387
- confirmations: 1
7411
+ confirmations: 2
7388
7412
  });
7389
7413
  if (receipt.status !== "success") {
7390
7414
  throw new Error(
7391
7415
  `Transfer to embedded wallet failed for ${selectedAsset.asset.symbol}`
7392
7416
  );
7393
7417
  }
7418
+ const currentBlock = await client2.getBlockNumber();
7419
+ const confirmations = currentBlock - receipt.blockNumber;
7420
+ console.log(`Transaction has ${confirmations} confirmations`);
7421
+ if (confirmations < 2) {
7422
+ console.log("Waiting for additional confirmations...");
7423
+ await new Promise((resolve) => setTimeout(resolve, 3e3));
7424
+ }
7394
7425
  console.log("Calling submitSpiceDeposit (EIP-7702) with:", {
7395
7426
  txHash: transferToEmbeddedTx,
7396
7427
  sender: sourceAddress,
@@ -7432,6 +7463,15 @@ const DepositModal = React.memo(
7432
7463
  receiver: isNative ? "" : escrowAddress
7433
7464
  });
7434
7465
  }
7466
+ if (sponsorGas && nativeChainId) {
7467
+ const gasAmount = viem.parseUnits("0.0003", 18);
7468
+ tokenTransfers.push({
7469
+ tokenAddress: "0x0",
7470
+ tokenAmount: gasAmount.toString(),
7471
+ sender: address,
7472
+ receiver: address
7473
+ });
7474
+ }
7435
7475
  const client = getClientForChain(chainId);
7436
7476
  const sourceRecentBlock = await client.getBlockNumber();
7437
7477
  const escrowDepositBatch = {
@@ -8093,7 +8133,8 @@ const SpiceDepositFlow = ({
8093
8133
  destinationTokenAddress,
8094
8134
  postDepositInstruction,
8095
8135
  postDepositInstructionLabel,
8096
- airdrop = false
8136
+ airdrop = false,
8137
+ sponsorGas = false
8097
8138
  }) => {
8098
8139
  const context = React.useContext(SpiceFlowProviderContext);
8099
8140
  if (!context) {
@@ -8222,7 +8263,8 @@ const SpiceDepositFlow = ({
8222
8263
  postDepositInstruction,
8223
8264
  postDepositInstructionLabel,
8224
8265
  nativeChainId,
8225
- airdrop
8266
+ airdrop,
8267
+ sponsorGas
8226
8268
  }
8227
8269
  );
8228
8270
  }
package/dist/index.js CHANGED
@@ -6915,7 +6915,8 @@ const DepositModal = React.memo(
6915
6915
  postDepositInstruction,
6916
6916
  postDepositInstructionLabel,
6917
6917
  nativeChainId,
6918
- airdrop = false
6918
+ airdrop = false,
6919
+ sponsorGas = false
6919
6920
  }) => {
6920
6921
  const depositAmount = depositInputHook?.depositAmount || "";
6921
6922
  const setDepositAmount = depositInputHook?.setDepositAmount || (() => {
@@ -7258,21 +7259,28 @@ const DepositModal = React.memo(
7258
7259
  console.log(`Waiting for transaction receipt: ${txHash}`);
7259
7260
  const receipt = await client.waitForTransactionReceipt({
7260
7261
  hash: txHash,
7261
- timeout: 6e4,
7262
- pollingInterval: 5e3,
7263
- confirmations: 1
7262
+ timeout: 12e4,
7263
+ pollingInterval: 2e3,
7264
+ confirmations: 2
7264
7265
  });
7265
7266
  console.log("Transaction receipt:", {
7266
7267
  hash: receipt.transactionHash,
7267
7268
  blockNumber: receipt.blockNumber,
7268
7269
  status: receipt.status,
7269
- confirmations: 1
7270
+ confirmations: 2
7270
7271
  });
7271
7272
  if (receipt.status !== "success") {
7272
7273
  throw new Error(
7273
7274
  `Transfer to delegate contract failed for ${selectedAsset.asset.symbol}`
7274
7275
  );
7275
7276
  }
7277
+ const currentBlock = await client.getBlockNumber();
7278
+ const confirmations = currentBlock - receipt.blockNumber;
7279
+ console.log(`Transaction has ${confirmations} confirmations`);
7280
+ if (confirmations < 2) {
7281
+ console.log("Waiting for additional confirmations...");
7282
+ await new Promise((resolve) => setTimeout(resolve, 3e3));
7283
+ }
7276
7284
  if (!depositDataRef.current) {
7277
7285
  depositDataRef.current = [];
7278
7286
  }
@@ -7301,11 +7309,27 @@ const DepositModal = React.memo(
7301
7309
  if (!sourceTransactionHash) {
7302
7310
  throw new Error("No transaction hash generated");
7303
7311
  }
7312
+ const finalClient = getClientForChain(chainId);
7313
+ const finalBlock = await finalClient.getBlockNumber();
7314
+ console.log(
7315
+ "Final block number before relayer submission:",
7316
+ finalBlock
7317
+ );
7318
+ console.log("All transactions confirmed, submitting to relayer...");
7304
7319
  if (!destinationTokenAddress) {
7305
7320
  throw new Error(
7306
7321
  "Destination token address is required for bridging"
7307
7322
  );
7308
7323
  }
7324
+ if (sponsorGas && nativeChainId) {
7325
+ const gasAmount = parseUnits("0.0003", 18);
7326
+ tokenTransfers.push({
7327
+ tokenAddress: "0x0",
7328
+ tokenAmount: gasAmount.toString(),
7329
+ sender: sourceAddress,
7330
+ receiver: delegateContract
7331
+ });
7332
+ }
7309
7333
  const result = await relayerService.submitTransactionNon7702({
7310
7334
  tokenTransfers: [tokenTransfers],
7311
7335
  user: sourceAddress,
@@ -7374,21 +7398,28 @@ const DepositModal = React.memo(
7374
7398
  );
7375
7399
  const receipt = await client2.waitForTransactionReceipt({
7376
7400
  hash: transferToEmbeddedTx,
7377
- timeout: 6e4,
7378
- pollingInterval: 5e3,
7379
- confirmations: 1
7401
+ timeout: 12e4,
7402
+ pollingInterval: 2e3,
7403
+ confirmations: 2
7380
7404
  });
7381
7405
  console.log("Transaction receipt (EIP-7702):", {
7382
7406
  hash: receipt.transactionHash,
7383
7407
  blockNumber: receipt.blockNumber,
7384
7408
  status: receipt.status,
7385
- confirmations: 1
7409
+ confirmations: 2
7386
7410
  });
7387
7411
  if (receipt.status !== "success") {
7388
7412
  throw new Error(
7389
7413
  `Transfer to embedded wallet failed for ${selectedAsset.asset.symbol}`
7390
7414
  );
7391
7415
  }
7416
+ const currentBlock = await client2.getBlockNumber();
7417
+ const confirmations = currentBlock - receipt.blockNumber;
7418
+ console.log(`Transaction has ${confirmations} confirmations`);
7419
+ if (confirmations < 2) {
7420
+ console.log("Waiting for additional confirmations...");
7421
+ await new Promise((resolve) => setTimeout(resolve, 3e3));
7422
+ }
7392
7423
  console.log("Calling submitSpiceDeposit (EIP-7702) with:", {
7393
7424
  txHash: transferToEmbeddedTx,
7394
7425
  sender: sourceAddress,
@@ -7430,6 +7461,15 @@ const DepositModal = React.memo(
7430
7461
  receiver: isNative ? "" : escrowAddress
7431
7462
  });
7432
7463
  }
7464
+ if (sponsorGas && nativeChainId) {
7465
+ const gasAmount = parseUnits("0.0003", 18);
7466
+ tokenTransfers.push({
7467
+ tokenAddress: "0x0",
7468
+ tokenAmount: gasAmount.toString(),
7469
+ sender: address,
7470
+ receiver: address
7471
+ });
7472
+ }
7433
7473
  const client = getClientForChain(chainId);
7434
7474
  const sourceRecentBlock = await client.getBlockNumber();
7435
7475
  const escrowDepositBatch = {
@@ -8091,7 +8131,8 @@ const SpiceDepositFlow = ({
8091
8131
  destinationTokenAddress,
8092
8132
  postDepositInstruction,
8093
8133
  postDepositInstructionLabel,
8094
- airdrop = false
8134
+ airdrop = false,
8135
+ sponsorGas = false
8095
8136
  }) => {
8096
8137
  const context = useContext(SpiceFlowProviderContext);
8097
8138
  if (!context) {
@@ -8220,7 +8261,8 @@ const SpiceDepositFlow = ({
8220
8261
  postDepositInstruction,
8221
8262
  postDepositInstructionLabel,
8222
8263
  nativeChainId,
8223
- airdrop
8264
+ airdrop,
8265
+ sponsorGas
8224
8266
  }
8225
8267
  );
8226
8268
  }
@@ -49,4 +49,5 @@ export interface DepositModalProps {
49
49
  postDepositInstructionLabel?: string;
50
50
  nativeChainId?: number;
51
51
  airdrop?: boolean;
52
+ sponsorGas?: boolean;
52
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.6.6",
3
+ "version": "1.7.0",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",