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