@tradeport/sui-trading-sdk 0.0.1 → 0.0.3
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 +12 -0
- package/dist/index.js +48 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/helpers/hasRoyaltyRule.ts +4 -9
- package/src/helpers/hasTransferPolicyRules.ts +3 -18
- package/src/helpers/kiosk/getKioskTransferPolicies.ts +19 -0
- package/src/helpers/kiosk/getRulePackageId.ts +2 -1
- package/src/helpers/kiosk/resolveTransferPolicies.ts +3 -2
- package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +29 -17
- package/src/utils/normalizeNftType.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @tradeport/sui-trading-sdk
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ff9b36e: Fix some collection txs like S Card and Unbound that did not have transfer policies indexed
|
|
8
|
+
|
|
9
|
+
## 0.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 485e023: Bug Fix: Fixed handling of Suiduckz and Cyberpills txs to list on TradePort's normal contract since they are untradable on OB or Kiosk contracts
|
|
14
|
+
|
|
3
15
|
## 0.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -326,13 +326,23 @@ var kioskClient = new import_kiosk.KioskClient({
|
|
|
326
326
|
});
|
|
327
327
|
var kioskClient_default = kioskClient;
|
|
328
328
|
|
|
329
|
-
// src/
|
|
330
|
-
var
|
|
329
|
+
// src/utils/normalizeNftType.ts
|
|
330
|
+
var normalizedNftType = (nftType) => {
|
|
331
331
|
const nftTypeSplit = nftType?.split("::");
|
|
332
332
|
if (nftTypeSplit?.[0])
|
|
333
333
|
nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
return nftTypeSplit?.join("::");
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// src/helpers/kiosk/getKioskTransferPolicies.ts
|
|
338
|
+
var getKioskTransferPolicies = async (nftType) => kioskClient_default.getTransferPolicies({
|
|
339
|
+
type: normalizedNftType(nftType)
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// src/helpers/hasTransferPolicyRules.ts
|
|
343
|
+
var hasTransferPolicyRules = async (nftType) => {
|
|
344
|
+
const transferPolicies = await getKioskTransferPolicies(nftType);
|
|
345
|
+
return transferPolicies?.some((policy) => policy?.rules?.length > 0);
|
|
336
346
|
};
|
|
337
347
|
|
|
338
348
|
// src/helpers/kiosk/getRulePackageId.ts
|
|
@@ -349,7 +359,7 @@ function addHexPrefix(input) {
|
|
|
349
359
|
// src/helpers/kiosk/getRulePackageId.ts
|
|
350
360
|
var getRulePackageId = async (nftType, ruleType) => {
|
|
351
361
|
const transferPolicies = await kioskClient_default.getTransferPolicies({
|
|
352
|
-
type: nftType
|
|
362
|
+
type: normalizedNftType(nftType)
|
|
353
363
|
});
|
|
354
364
|
const rule = transferPolicies.flatMap((policy) => policy.rules).filter((rule2) => rule2?.split("::")?.[1] === ruleType)?.[0];
|
|
355
365
|
const ruleDefinition = kioskClient_default.rules.find(
|
|
@@ -699,7 +709,7 @@ var resolveTransferPolicies = async ({
|
|
|
699
709
|
shouldSkipResolvingRoyaltyRule
|
|
700
710
|
}) => {
|
|
701
711
|
const transferPolicies = await kioskClient_default.getTransferPolicies({
|
|
702
|
-
type: nftType
|
|
712
|
+
type: normalizedNftType(nftType)
|
|
703
713
|
});
|
|
704
714
|
let policies = transferPolicies.length > 0 ? [
|
|
705
715
|
{
|
|
@@ -711,7 +721,7 @@ var resolveTransferPolicies = async ({
|
|
|
711
721
|
if (customTransferPolicies) {
|
|
712
722
|
for (const customTransferPolicy of customTransferPolicies) {
|
|
713
723
|
const customPolicy = await kioskClient_default.getTransferPolicies({
|
|
714
|
-
type: customTransferPolicy?.type
|
|
724
|
+
type: normalizedNftType(customTransferPolicy?.type)
|
|
715
725
|
});
|
|
716
726
|
policies = [
|
|
717
727
|
...policies,
|
|
@@ -2745,12 +2755,9 @@ var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
|
|
|
2745
2755
|
|
|
2746
2756
|
// src/helpers/hasRoyaltyRule.ts
|
|
2747
2757
|
var hasRoyaltyRule = async (nftType) => {
|
|
2748
|
-
const
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
const res = await kioskClient_default.getTransferPolicies({ type: nftTypeSplit?.join("::") });
|
|
2752
|
-
return res?.some(
|
|
2753
|
-
(policy) => policy?.rules?.filter((rule) => rule?.includes("royalty_rule"))?.length > 0
|
|
2758
|
+
const transferPolicies = await getKioskTransferPolicies(nftType);
|
|
2759
|
+
return transferPolicies?.some(
|
|
2760
|
+
(policy) => policy?.rules?.filter((rule) => rule?.type?.includes("royalty_rule"))?.length > 0
|
|
2754
2761
|
);
|
|
2755
2762
|
};
|
|
2756
2763
|
|
|
@@ -2783,36 +2790,48 @@ function addTradePortKioskCollectionBidTx({
|
|
|
2783
2790
|
nftType,
|
|
2784
2791
|
bidAmount,
|
|
2785
2792
|
sharedObjects,
|
|
2786
|
-
bidder,
|
|
2787
2793
|
royaltyRulePackageId,
|
|
2788
2794
|
royaltyRuleModule
|
|
2789
2795
|
}) {
|
|
2790
2796
|
const { transferPolicy } = sharedObjects;
|
|
2791
|
-
const marketFeePrice = getMarketFeePrice({
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2797
|
+
const marketFeePrice = getMarketFeePrice({
|
|
2798
|
+
price: bidAmount,
|
|
2799
|
+
collectionId
|
|
2800
|
+
});
|
|
2801
|
+
let coin;
|
|
2802
|
+
if (royaltyRulePackageId && royaltyRuleModule) {
|
|
2803
|
+
const fee = txBlock.moveCall({
|
|
2804
|
+
target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
|
|
2805
|
+
arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount)],
|
|
2806
|
+
typeArguments: [nftType]
|
|
2807
|
+
});
|
|
2808
|
+
const [coin1, coin2] = splitCoins({
|
|
2809
|
+
txBlock,
|
|
2810
|
+
amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(fee)]
|
|
2811
|
+
});
|
|
2812
|
+
coin = coin1;
|
|
2813
|
+
if (!coin1 || !coin2)
|
|
2814
|
+
throw new Error("Coin could not be split");
|
|
2815
|
+
txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
|
|
2816
|
+
} else {
|
|
2817
|
+
const [coin1] = splitCoins({
|
|
2818
|
+
txBlock,
|
|
2819
|
+
amounts: [txBlock.pure(bidAmount + marketFeePrice)]
|
|
2820
|
+
});
|
|
2821
|
+
coin = coin1;
|
|
2822
|
+
}
|
|
2804
2823
|
txBlock.moveCall({
|
|
2805
2824
|
target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::collection_bid",
|
|
2806
2825
|
arguments: [
|
|
2807
2826
|
txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
2808
2827
|
txBlock.pure(bidAmount),
|
|
2809
|
-
txBlock.object(
|
|
2828
|
+
txBlock.object(coin),
|
|
2810
2829
|
txBlock.pure(marketFeePrice),
|
|
2811
2830
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
|
|
2812
2831
|
],
|
|
2813
2832
|
typeArguments: [nftType]
|
|
2814
2833
|
});
|
|
2815
|
-
destroyZeroCoin({ txBlock, coin
|
|
2834
|
+
destroyZeroCoin({ txBlock, coin });
|
|
2816
2835
|
}
|
|
2817
2836
|
async function addOriginByteCollectionBidTx({
|
|
2818
2837
|
txBlock,
|