@scallop-io/sui-scallop-sdk 0.46.46 → 0.46.47

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.mjs CHANGED
@@ -5821,22 +5821,24 @@ var generateSpoolQuickMethod = ({
5821
5821
  if (amount === 0)
5822
5822
  break;
5823
5823
  }
5824
- const mergedSCoin = sCoins2[0];
5825
- if (sCoins2.length > 1) {
5826
- txBlock.mergeCoins(mergedSCoin, sCoins2.slice(1));
5827
- }
5828
- try {
5829
- const existingCoins = await builder.utils.selectCoins(
5830
- Number.MAX_SAFE_INTEGER,
5831
- builder.utils.parseSCoinType(stakeMarketCoinName),
5832
- requireSender(txBlock)
5833
- );
5834
- if (existingCoins.length > 0) {
5835
- txBlock.mergeCoins(mergedSCoin, existingCoins);
5824
+ if (sCoins2.length > 0) {
5825
+ const mergedSCoin = sCoins2[0];
5826
+ if (sCoins2.length > 1) {
5827
+ txBlock.mergeCoins(mergedSCoin, sCoins2.slice(1));
5836
5828
  }
5837
- } catch (e) {
5829
+ try {
5830
+ const existingCoins = await builder.utils.selectCoins(
5831
+ Number.MAX_SAFE_INTEGER,
5832
+ builder.utils.parseSCoinType(stakeMarketCoinName),
5833
+ requireSender(txBlock)
5834
+ );
5835
+ if (existingCoins.length > 0) {
5836
+ txBlock.mergeCoins(mergedSCoin, existingCoins);
5837
+ }
5838
+ } catch (e) {
5839
+ }
5840
+ return mergedSCoin;
5838
5841
  }
5839
- return mergedSCoin;
5840
5842
  },
5841
5843
  claimQuick: async (stakeMarketCoinName, stakeAccountId) => {
5842
5844
  const stakeAccountIds = await requireStakeAccountIds(
@@ -7270,8 +7272,10 @@ var ScallopClient = class {
7270
7272
  stakeAccountId
7271
7273
  );
7272
7274
  const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
7273
- const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
7274
- txBlock.transferObjects([coin], sender);
7275
+ if (stakeMarketCoin) {
7276
+ const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
7277
+ txBlock.transferObjects([coin], sender);
7278
+ }
7275
7279
  if (sign) {
7276
7280
  return await this.suiKit.signAndSendTxn(
7277
7281
  txBlock
@@ -7386,6 +7390,7 @@ var ScallopClient = class {
7386
7390
  const toTransfer = [];
7387
7391
  await Promise.all(
7388
7392
  SUPPORT_SCOIN.map(async (sCoinName) => {
7393
+ const sCoins2 = [];
7389
7394
  let toDestroyMarketCoin;
7390
7395
  try {
7391
7396
  const marketCoins2 = await this.utils.selectCoins(
@@ -7403,23 +7408,6 @@ var ScallopClient = class {
7403
7408
  if (!errMsg.includes("No valid coins found for the transaction"))
7404
7409
  throw e;
7405
7410
  }
7406
- if (SUPPORT_SPOOLS.includes(sCoinName)) {
7407
- try {
7408
- const stakedMarketCoin = await txBlock.unstakeQuick(
7409
- Number.MAX_SAFE_INTEGER,
7410
- sCoinName
7411
- );
7412
- if (toDestroyMarketCoin) {
7413
- txBlock.mergeCoins(toDestroyMarketCoin, [stakedMarketCoin]);
7414
- } else {
7415
- toDestroyMarketCoin = stakedMarketCoin;
7416
- }
7417
- } catch (e) {
7418
- const errMsg = e.toString();
7419
- if (!errMsg.includes("No stake account found"))
7420
- throw e;
7421
- }
7422
- }
7423
7411
  if (toDestroyMarketCoin) {
7424
7412
  const sCoin = txBlock.mintSCoin(
7425
7413
  sCoinName,
@@ -7441,7 +7429,29 @@ var ScallopClient = class {
7441
7429
  if (!errMsg.includes("No valid coins found for the transaction"))
7442
7430
  throw e;
7443
7431
  }
7444
- toTransfer.push(sCoin);
7432
+ sCoins2.push(sCoin);
7433
+ }
7434
+ if (SUPPORT_SPOOLS.includes(sCoinName)) {
7435
+ try {
7436
+ const sCoin = await txBlock.unstakeQuick(
7437
+ Number.MAX_SAFE_INTEGER,
7438
+ sCoinName
7439
+ );
7440
+ if (sCoin) {
7441
+ sCoins2.push(sCoin);
7442
+ }
7443
+ } catch (e) {
7444
+ const errMsg = e.toString();
7445
+ if (!errMsg.includes("No stake account found"))
7446
+ throw e;
7447
+ }
7448
+ }
7449
+ if (sCoins2.length > 0) {
7450
+ const mergedSCoin = sCoins2[0];
7451
+ if (sCoins2.length > 1) {
7452
+ txBlock.mergeCoins(mergedSCoin, sCoins2.slice(1));
7453
+ }
7454
+ toTransfer.push(mergedSCoin);
7445
7455
  }
7446
7456
  })
7447
7457
  );