@scallop-io/sui-scallop-sdk 0.46.51 → 0.46.53

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.js CHANGED
@@ -539,8 +539,7 @@ var ScallopCache = class {
539
539
  );
540
540
  }
541
541
  return balances;
542
- },
543
- staleTime: 5e3
542
+ }
544
543
  });
545
544
  }
546
545
  async queryGetCoinBalance(input) {
@@ -5770,10 +5769,9 @@ var requireStakeAccounts = async (...params) => {
5770
5769
  }) : stakeAccounts[stakeMarketCoinName];
5771
5770
  return specificStakeAccounts;
5772
5771
  };
5773
- var stakeHelper = async (builder, txBlock, stakeAccount, coinType, coinName, amount, sender, isSCoin = false) => {
5772
+ var stakeHelper = async (builder, txBlock, stakeAccount, coinName, amount, sender, isSCoin = false) => {
5774
5773
  try {
5775
- const coins = await builder.utils.selectCoins(amount, coinType, sender);
5776
- const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
5774
+ const { takeCoin, leftCoin, totalAmount } = isSCoin ? await builder.selectSCoin(txBlock, coinName, amount, sender) : await builder.selectMarketCoin(txBlock, coinName, amount, sender);
5777
5775
  if (isSCoin) {
5778
5776
  const marketCoin = txBlock.burnSCoin(coinName, takeCoin);
5779
5777
  txBlock.stake(stakeAccount, marketCoin, coinName);
@@ -5781,9 +5779,9 @@ var stakeHelper = async (builder, txBlock, stakeAccount, coinType, coinName, amo
5781
5779
  txBlock.stake(stakeAccount, takeCoin, coinName);
5782
5780
  }
5783
5781
  txBlock.transferObjects([leftCoin], sender);
5784
- return true;
5782
+ return totalAmount;
5785
5783
  } catch (e) {
5786
- return false;
5784
+ return 0;
5787
5785
  }
5788
5786
  };
5789
5787
  var generateSpoolNormalMethod = ({
@@ -5858,24 +5856,21 @@ var generateSpoolQuickMethod = ({
5858
5856
  stakeMarketCoinName,
5859
5857
  stakeAccountId
5860
5858
  );
5861
- const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
5862
- const sCoinType = builder.utils.parseSCoinType(stakeMarketCoinName);
5863
5859
  if (typeof amountOrMarketCoin === "number") {
5864
- const stakeMarketCoinRes = await stakeHelper(
5860
+ const stakedMarketCoinAmount = await stakeHelper(
5865
5861
  builder,
5866
5862
  txBlock,
5867
5863
  stakeAccountIds[0],
5868
- marketCoinType,
5869
5864
  stakeMarketCoinName,
5870
5865
  amountOrMarketCoin,
5871
5866
  sender
5872
5867
  );
5873
- if (!stakeMarketCoinRes) {
5868
+ amountOrMarketCoin -= stakedMarketCoinAmount;
5869
+ if (amountOrMarketCoin > 0) {
5874
5870
  await stakeHelper(
5875
5871
  builder,
5876
5872
  txBlock,
5877
5873
  stakeAccountIds[0],
5878
- sCoinType,
5879
5874
  stakeMarketCoinName,
5880
5875
  amountOrMarketCoin,
5881
5876
  sender,
@@ -7500,11 +7495,10 @@ var ScallopClient = class {
7500
7495
  this.utils.parseMarketCoinType(sCoinName),
7501
7496
  this.walletAddress
7502
7497
  );
7503
- const mergedMarketCoin = marketCoins2[0];
7498
+ toDestroyMarketCoin = marketCoins2[0];
7504
7499
  if (marketCoins2.length > 1) {
7505
- txBlock.mergeCoins(mergedMarketCoin, marketCoins2.slice(1));
7500
+ txBlock.mergeCoins(toDestroyMarketCoin, marketCoins2.slice(1));
7506
7501
  }
7507
- toDestroyMarketCoin = mergedMarketCoin;
7508
7502
  } catch (e) {
7509
7503
  const errMsg = e.toString();
7510
7504
  if (!errMsg.includes("No valid coins found for the transaction"))
@@ -7521,15 +7515,8 @@ var ScallopClient = class {
7521
7515
  this.utils.parseSCoinType(sCoinName),
7522
7516
  this.walletAddress
7523
7517
  );
7524
- const mergedSCoin = existSCoins[0];
7525
- if (existSCoins.length > 1) {
7526
- txBlock.mergeCoins(mergedSCoin, existSCoins.slice(1));
7527
- }
7528
- txBlock.mergeCoins(sCoin, [mergedSCoin]);
7518
+ txBlock.mergeCoins(sCoin, existSCoins);
7529
7519
  } catch (e) {
7530
- const errMsg = e.toString();
7531
- if (!errMsg.includes("No valid coins found for the transaction"))
7532
- throw e;
7533
7520
  }
7534
7521
  sCoins2.push(sCoin);
7535
7522
  }
@@ -7543,9 +7530,6 @@ var ScallopClient = class {
7543
7530
  sCoins2.push(sCoin);
7544
7531
  }
7545
7532
  } catch (e) {
7546
- const errMsg = e.toString();
7547
- if (!errMsg.includes("No stake account found"))
7548
- throw e;
7549
7533
  }
7550
7534
  }
7551
7535
  if (sCoins2.length > 0) {