@multiversx/sdk-dapp-liquidity 1.1.0-alpha.15 → 1.1.0-alpha.16

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/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/multiversx/mx-sdk-dapp-liquidity#readme",
30
30
  "license": "MIT",
31
- "version": "1.1.0-alpha.15",
31
+ "version": "1.1.0-alpha.16",
32
32
  "main": "index.js",
33
33
  "module": "index.mjs",
34
34
  "types": "index.d.ts",
@@ -388,33 +388,23 @@ const BridgeForm = ({
388
388
  setPendingSigning(true);
389
389
  setSigningTransactionsCount(() => transactions.length);
390
390
  try {
391
- switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
392
- case types_chainType.ChainType.sol:
393
- try {
394
- for (const transaction of transactions) {
391
+ let txIndex = -1;
392
+ for (const transaction of transactions) {
393
+ ++txIndex;
394
+ let txHash;
395
+ try {
396
+ switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
397
+ case types_chainType.ChainType.sol:
395
398
  if (!transaction.instructions || !transaction.feePayer) {
396
- continue;
399
+ break;
397
400
  }
398
- await solana.signTransaction({
401
+ txHash = await solana.signTransaction({
399
402
  feePayer: transaction.feePayer,
400
403
  instructions: transaction.instructions
401
404
  });
402
- }
403
- setPendingSigning(false);
404
- } catch (e) {
405
- reactToastify.toast.dismiss();
406
- reactToastify.toast.error("Transaction aborted");
407
- onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
408
- setPendingSigning(false);
409
- return;
410
- }
411
- break;
412
- case types_chainType.ChainType.evm:
413
- let txIndex = -1;
414
- for (const transaction of transactions) {
415
- ++txIndex;
416
- try {
417
- const txHash = await evm.signTransaction({
405
+ break;
406
+ case types_chainType.ChainType.evm:
407
+ txHash = await evm.signTransaction({
418
408
  ...transaction,
419
409
  value: BigInt(transaction.value),
420
410
  gas: BigInt(transaction.gasLimit),
@@ -424,46 +414,43 @@ const BridgeForm = ({
424
414
  ...transaction,
425
415
  txHash
426
416
  });
427
- setSigningTransactionsCount(
428
- () => transactions.length - 1 - txIndex
429
- );
430
- if (txIndex === transactions.length - 1) {
431
- continue;
432
- }
433
- const transactionReceipt = await waitForTransactionReceipt(
434
- config,
435
- {
436
- confirmations: 1,
437
- hash: txHash
438
- }
439
- );
440
- console.info({
441
- transactionReceipt,
442
- hash: txHash
443
- });
444
- } catch (e) {
445
- reactToastify.toast.dismiss();
446
- reactToastify.toast.error("Transaction aborted");
447
- onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
417
+ break;
418
+ default:
419
+ reactToastify.toast.error("Provider not supported");
448
420
  setPendingSigning(false);
449
421
  return;
450
- }
451
422
  }
452
- await sendTransactions({
453
- transactions: signedTransactions,
454
- provider,
455
- url: helpers_getApiURL.getApiURL() ?? "",
456
- token: nativeAuthToken ?? ""
423
+ setSigningTransactionsCount(
424
+ () => transactions.length - 1 - txIndex
425
+ );
426
+ if (txIndex === transactions.length - 1 || !txHash || (selectedChainOption == null ? void 0 : selectedChainOption.chainType) !== types_chainType.ChainType.evm) {
427
+ continue;
428
+ }
429
+ const transactionReceipt = await waitForTransactionReceipt(config, {
430
+ confirmations: 1,
431
+ hash: txHash
457
432
  });
458
- const txHashes = signedTransactions.map((tx) => tx.txHash);
459
- onSuccess(txHashes);
460
- setPendingSigning(false);
461
- break;
462
- default:
463
- reactToastify.toast.error("Provider not supported");
433
+ console.info({
434
+ transactionReceipt,
435
+ hash: txHash
436
+ });
437
+ } catch (e) {
438
+ reactToastify.toast.dismiss();
439
+ reactToastify.toast.error("Transaction aborted");
440
+ onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
464
441
  setPendingSigning(false);
465
442
  return;
443
+ }
466
444
  }
445
+ await sendTransactions({
446
+ transactions: signedTransactions,
447
+ provider,
448
+ url: helpers_getApiURL.getApiURL() ?? "",
449
+ token: nativeAuthToken ?? ""
450
+ });
451
+ const txHashes = signedTransactions.map((tx) => tx.txHash);
452
+ onSuccess(txHashes);
453
+ setPendingSigning(false);
467
454
  } catch (e) {
468
455
  console.error(e);
469
456
  reactToastify.toast.dismiss();
@@ -385,33 +385,23 @@ const BridgeForm = ({
385
385
  setPendingSigning(true);
386
386
  setSigningTransactionsCount(() => transactions.length);
387
387
  try {
388
- switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
389
- case ChainType.sol:
390
- try {
391
- for (const transaction of transactions) {
388
+ let txIndex = -1;
389
+ for (const transaction of transactions) {
390
+ ++txIndex;
391
+ let txHash;
392
+ try {
393
+ switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
394
+ case ChainType.sol:
392
395
  if (!transaction.instructions || !transaction.feePayer) {
393
- continue;
396
+ break;
394
397
  }
395
- await solana.signTransaction({
398
+ txHash = await solana.signTransaction({
396
399
  feePayer: transaction.feePayer,
397
400
  instructions: transaction.instructions
398
401
  });
399
- }
400
- setPendingSigning(false);
401
- } catch (e) {
402
- toast.dismiss();
403
- toast.error("Transaction aborted");
404
- onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
405
- setPendingSigning(false);
406
- return;
407
- }
408
- break;
409
- case ChainType.evm:
410
- let txIndex = -1;
411
- for (const transaction of transactions) {
412
- ++txIndex;
413
- try {
414
- const txHash = await evm.signTransaction({
402
+ break;
403
+ case ChainType.evm:
404
+ txHash = await evm.signTransaction({
415
405
  ...transaction,
416
406
  value: BigInt(transaction.value),
417
407
  gas: BigInt(transaction.gasLimit),
@@ -421,46 +411,43 @@ const BridgeForm = ({
421
411
  ...transaction,
422
412
  txHash
423
413
  });
424
- setSigningTransactionsCount(
425
- () => transactions.length - 1 - txIndex
426
- );
427
- if (txIndex === transactions.length - 1) {
428
- continue;
429
- }
430
- const transactionReceipt = await waitForTransactionReceipt(
431
- config,
432
- {
433
- confirmations: 1,
434
- hash: txHash
435
- }
436
- );
437
- console.info({
438
- transactionReceipt,
439
- hash: txHash
440
- });
441
- } catch (e) {
442
- toast.dismiss();
443
- toast.error("Transaction aborted");
444
- onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
414
+ break;
415
+ default:
416
+ toast.error("Provider not supported");
445
417
  setPendingSigning(false);
446
418
  return;
447
- }
448
419
  }
449
- await sendTransactions({
450
- transactions: signedTransactions,
451
- provider,
452
- url: getApiURL() ?? "",
453
- token: nativeAuthToken ?? ""
420
+ setSigningTransactionsCount(
421
+ () => transactions.length - 1 - txIndex
422
+ );
423
+ if (txIndex === transactions.length - 1 || !txHash || (selectedChainOption == null ? void 0 : selectedChainOption.chainType) !== ChainType.evm) {
424
+ continue;
425
+ }
426
+ const transactionReceipt = await waitForTransactionReceipt(config, {
427
+ confirmations: 1,
428
+ hash: txHash
454
429
  });
455
- const txHashes = signedTransactions.map((tx) => tx.txHash);
456
- onSuccess(txHashes);
457
- setPendingSigning(false);
458
- break;
459
- default:
460
- toast.error("Provider not supported");
430
+ console.info({
431
+ transactionReceipt,
432
+ hash: txHash
433
+ });
434
+ } catch (e) {
435
+ toast.dismiss();
436
+ toast.error("Transaction aborted");
437
+ onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
461
438
  setPendingSigning(false);
462
439
  return;
440
+ }
463
441
  }
442
+ await sendTransactions({
443
+ transactions: signedTransactions,
444
+ provider,
445
+ url: getApiURL() ?? "",
446
+ token: nativeAuthToken ?? ""
447
+ });
448
+ const txHashes = signedTransactions.map((tx) => tx.txHash);
449
+ onSuccess(txHashes);
450
+ setPendingSigning(false);
464
451
  } catch (e) {
465
452
  console.error(e);
466
453
  toast.dismiss();
@@ -75,7 +75,7 @@ export declare const useSignTransaction: () => {
75
75
  signTransaction: ({ feePayer, instructions }: {
76
76
  feePayer: string;
77
77
  instructions: ServerTransactionInstruction[];
78
- }) => Promise<void>;
78
+ }) => Promise<string | undefined>;
79
79
  connection: import('@solana/web3.js').Connection | undefined;
80
80
  walletProvider: Provider;
81
81
  };
@@ -34,7 +34,7 @@ const useSignTransaction = () => {
34
34
  if (connection) {
35
35
  transaction.recentBlockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
36
36
  }
37
- await walletProvider.signAndSendTransaction(transaction);
37
+ return await walletProvider.signAndSendTransaction(transaction);
38
38
  }
39
39
  }
40
40
  return {
@@ -31,7 +31,7 @@ const useSignTransaction = () => {
31
31
  if (connection) {
32
32
  transaction.recentBlockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
33
33
  }
34
- await walletProvider.signAndSendTransaction(transaction);
34
+ return await walletProvider.signAndSendTransaction(transaction);
35
35
  }
36
36
  }
37
37
  return {