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