@tradeport/sui-trading-sdk 0.1.36 → 0.1.37
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/CHANGELOG.md +6 -0
- package/dist/index.js +44 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SuiTradingClient.ts +28 -0
- package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +4 -0
- package/src/methods/acceptNftBids/acceptNftBids.ts +1 -0
- package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +17 -7
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -858,6 +858,11 @@ var getOBBidderKiosk = async (bidNonce) => {
|
|
|
858
858
|
return bidObject.data?.content?.fields?.kiosk;
|
|
859
859
|
};
|
|
860
860
|
|
|
861
|
+
// src/utils/printTxBlockTxs.ts
|
|
862
|
+
var printTxBlockTxs = async (tx) => {
|
|
863
|
+
console.log(JSON.stringify(tx?.getData(), null, 2));
|
|
864
|
+
};
|
|
865
|
+
|
|
861
866
|
// src/methods/acceptNftBids/addAcceptNftBidTxs.ts
|
|
862
867
|
function addTradeportAcceptNftBidTx({
|
|
863
868
|
tx,
|
|
@@ -902,6 +907,7 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
902
907
|
royaltyRulePackageId,
|
|
903
908
|
royaltyRuleModule,
|
|
904
909
|
bidAmount,
|
|
910
|
+
shouldSplitRoyaltyFromUserGasCoins,
|
|
905
911
|
beforeResolveKioskTransferRequest
|
|
906
912
|
}) {
|
|
907
913
|
const { transferPolicy } = sharedObjects;
|
|
@@ -940,20 +946,26 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
940
946
|
],
|
|
941
947
|
typeArguments: [nftType]
|
|
942
948
|
});
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
949
|
+
if (!shouldSplitRoyaltyFromUserGasCoins) {
|
|
950
|
+
tx.moveCall({
|
|
951
|
+
target: `${royaltyRulePackageId}::${royaltyRuleModule}::pay`,
|
|
952
|
+
typeArguments: [nftType],
|
|
953
|
+
arguments: [tx.object(transferPolicy), transferRequest, feeCoin]
|
|
954
|
+
});
|
|
955
|
+
}
|
|
948
956
|
await resolveTransferPolicies({
|
|
949
957
|
tx,
|
|
950
958
|
kioskTx,
|
|
951
959
|
nftType,
|
|
952
|
-
price: "0",
|
|
960
|
+
price: shouldSplitRoyaltyFromUserGasCoins ? bidAmount?.toString() : "0",
|
|
953
961
|
transferRequest,
|
|
954
962
|
shouldSkipKioskLocking: true,
|
|
955
|
-
shouldSkipResolvingRoyaltyRule:
|
|
963
|
+
shouldSkipResolvingRoyaltyRule: !shouldSplitRoyaltyFromUserGasCoins
|
|
956
964
|
});
|
|
965
|
+
if (shouldSplitRoyaltyFromUserGasCoins) {
|
|
966
|
+
tx.transferObjects([tx.object(feeCoin)], tx.pure.address(addLeadingZerosAfter0x(seller)));
|
|
967
|
+
}
|
|
968
|
+
await printTxBlockTxs(tx);
|
|
957
969
|
}
|
|
958
970
|
}
|
|
959
971
|
async function addOriginByteAcceptNftBidTx({
|
|
@@ -1564,6 +1576,7 @@ var acceptCollectionBid = async ({
|
|
|
1564
1576
|
walletAddress,
|
|
1565
1577
|
tx: existingTx,
|
|
1566
1578
|
kioskTx,
|
|
1579
|
+
shouldSplitRoyaltyFromUserGasCoins,
|
|
1567
1580
|
beforeResolveKioskTransferRequest
|
|
1568
1581
|
}, context) => {
|
|
1569
1582
|
const nftRes = await gqlChainRequest({
|
|
@@ -1597,6 +1610,7 @@ var acceptCollectionBid = async ({
|
|
|
1597
1610
|
collectionId: nft?.collection_id,
|
|
1598
1611
|
isListedOnBluemove: nft?.listings?.[0]?.market_name === "bluemove",
|
|
1599
1612
|
bidMarketName: bid?.market_contract?.name,
|
|
1613
|
+
shouldSplitRoyaltyFromUserGasCoins,
|
|
1600
1614
|
beforeResolveKioskTransferRequest
|
|
1601
1615
|
};
|
|
1602
1616
|
switch (txData.bidMarketName) {
|
|
@@ -4557,6 +4571,29 @@ var SuiTradingClient = class {
|
|
|
4557
4571
|
return tx;
|
|
4558
4572
|
} catch (err) {
|
|
4559
4573
|
if (i === allBidsWithSameHighestPrice.length - 1) {
|
|
4574
|
+
for (let j = 0; j < allBidsWithSameHighestPrice?.length; j++) {
|
|
4575
|
+
try {
|
|
4576
|
+
const tx = await acceptCollectionBid(
|
|
4577
|
+
{
|
|
4578
|
+
bid: allBidsWithSameHighestPrice?.[j],
|
|
4579
|
+
nftId,
|
|
4580
|
+
walletAddress,
|
|
4581
|
+
shouldSplitRoyaltyFromUserGasCoins: true
|
|
4582
|
+
},
|
|
4583
|
+
context
|
|
4584
|
+
);
|
|
4585
|
+
tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
|
|
4586
|
+
const rawTransaction = await tx.build({ client: suiClient_default });
|
|
4587
|
+
await suiClient_default.dryRunTransactionBlock({
|
|
4588
|
+
transactionBlock: rawTransaction
|
|
4589
|
+
});
|
|
4590
|
+
return tx;
|
|
4591
|
+
} catch (err2) {
|
|
4592
|
+
if (j === allBidsWithSameHighestPrice.length - 1) {
|
|
4593
|
+
throw err2;
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4560
4597
|
throw err;
|
|
4561
4598
|
}
|
|
4562
4599
|
}
|