@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 +10 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/builders/spoolBuilder.ts +8 -12
- package/src/models/scallopClient.ts +4 -18
package/dist/index.mjs
CHANGED
|
@@ -5698,10 +5698,9 @@ var requireStakeAccounts = async (...params) => {
|
|
|
5698
5698
|
}) : stakeAccounts[stakeMarketCoinName];
|
|
5699
5699
|
return specificStakeAccounts;
|
|
5700
5700
|
};
|
|
5701
|
-
var stakeHelper = async (builder, txBlock, stakeAccount,
|
|
5701
|
+
var stakeHelper = async (builder, txBlock, stakeAccount, coinName, amount, sender, isSCoin = false) => {
|
|
5702
5702
|
try {
|
|
5703
|
-
const
|
|
5704
|
-
const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
|
|
5703
|
+
const { takeCoin, leftCoin, totalAmount } = isSCoin ? await builder.selectSCoin(txBlock, coinName, amount, sender) : await builder.selectMarketCoin(txBlock, coinName, amount, sender);
|
|
5705
5704
|
if (isSCoin) {
|
|
5706
5705
|
const marketCoin = txBlock.burnSCoin(coinName, takeCoin);
|
|
5707
5706
|
txBlock.stake(stakeAccount, marketCoin, coinName);
|
|
@@ -5709,9 +5708,9 @@ var stakeHelper = async (builder, txBlock, stakeAccount, coinType, coinName, amo
|
|
|
5709
5708
|
txBlock.stake(stakeAccount, takeCoin, coinName);
|
|
5710
5709
|
}
|
|
5711
5710
|
txBlock.transferObjects([leftCoin], sender);
|
|
5712
|
-
return
|
|
5711
|
+
return totalAmount;
|
|
5713
5712
|
} catch (e) {
|
|
5714
|
-
return
|
|
5713
|
+
return 0;
|
|
5715
5714
|
}
|
|
5716
5715
|
};
|
|
5717
5716
|
var generateSpoolNormalMethod = ({
|
|
@@ -5786,24 +5785,21 @@ var generateSpoolQuickMethod = ({
|
|
|
5786
5785
|
stakeMarketCoinName,
|
|
5787
5786
|
stakeAccountId
|
|
5788
5787
|
);
|
|
5789
|
-
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5790
|
-
const sCoinType = builder.utils.parseSCoinType(stakeMarketCoinName);
|
|
5791
5788
|
if (typeof amountOrMarketCoin === "number") {
|
|
5792
|
-
const
|
|
5789
|
+
const stakedMarketCoinAmount = await stakeHelper(
|
|
5793
5790
|
builder,
|
|
5794
5791
|
txBlock,
|
|
5795
5792
|
stakeAccountIds[0],
|
|
5796
|
-
marketCoinType,
|
|
5797
5793
|
stakeMarketCoinName,
|
|
5798
5794
|
amountOrMarketCoin,
|
|
5799
5795
|
sender
|
|
5800
5796
|
);
|
|
5801
|
-
|
|
5797
|
+
amountOrMarketCoin -= stakedMarketCoinAmount;
|
|
5798
|
+
if (amountOrMarketCoin > 0) {
|
|
5802
5799
|
await stakeHelper(
|
|
5803
5800
|
builder,
|
|
5804
5801
|
txBlock,
|
|
5805
5802
|
stakeAccountIds[0],
|
|
5806
|
-
sCoinType,
|
|
5807
5803
|
stakeMarketCoinName,
|
|
5808
5804
|
amountOrMarketCoin,
|
|
5809
5805
|
sender,
|
|
@@ -7439,11 +7435,10 @@ var ScallopClient = class {
|
|
|
7439
7435
|
this.utils.parseMarketCoinType(sCoinName),
|
|
7440
7436
|
this.walletAddress
|
|
7441
7437
|
);
|
|
7442
|
-
|
|
7438
|
+
toDestroyMarketCoin = marketCoins2[0];
|
|
7443
7439
|
if (marketCoins2.length > 1) {
|
|
7444
|
-
txBlock.mergeCoins(
|
|
7440
|
+
txBlock.mergeCoins(toDestroyMarketCoin, marketCoins2.slice(1));
|
|
7445
7441
|
}
|
|
7446
|
-
toDestroyMarketCoin = mergedMarketCoin;
|
|
7447
7442
|
} catch (e) {
|
|
7448
7443
|
const errMsg = e.toString();
|
|
7449
7444
|
if (!errMsg.includes("No valid coins found for the transaction"))
|
|
@@ -7460,15 +7455,8 @@ var ScallopClient = class {
|
|
|
7460
7455
|
this.utils.parseSCoinType(sCoinName),
|
|
7461
7456
|
this.walletAddress
|
|
7462
7457
|
);
|
|
7463
|
-
|
|
7464
|
-
if (existSCoins.length > 1) {
|
|
7465
|
-
txBlock.mergeCoins(mergedSCoin, existSCoins.slice(1));
|
|
7466
|
-
}
|
|
7467
|
-
txBlock.mergeCoins(sCoin, [mergedSCoin]);
|
|
7458
|
+
txBlock.mergeCoins(sCoin, existSCoins);
|
|
7468
7459
|
} catch (e) {
|
|
7469
|
-
const errMsg = e.toString();
|
|
7470
|
-
if (!errMsg.includes("No valid coins found for the transaction"))
|
|
7471
|
-
throw e;
|
|
7472
7460
|
}
|
|
7473
7461
|
sCoins2.push(sCoin);
|
|
7474
7462
|
}
|
|
@@ -7482,9 +7470,6 @@ var ScallopClient = class {
|
|
|
7482
7470
|
sCoins2.push(sCoin);
|
|
7483
7471
|
}
|
|
7484
7472
|
} catch (e) {
|
|
7485
|
-
const errMsg = e.toString();
|
|
7486
|
-
if (!errMsg.includes("No stake account found"))
|
|
7487
|
-
throw e;
|
|
7488
7473
|
}
|
|
7489
7474
|
}
|
|
7490
7475
|
if (sCoins2.length > 0) {
|