@tradeport/sui-trading-sdk 0.1.1 → 0.1.2
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 +37 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/helpers/getRoyaltyRuleModule.ts +7 -0
- package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +1 -0
- package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +7 -2
- package/src/methods/acceptNftBids/acceptNftBids.ts +2 -1
- package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +6 -2
- package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +6 -5
- package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +6 -3
- package/src/methods/placeNftBids/placeNftBids.ts +1 -0
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -321,6 +321,17 @@ var getSharedObjects = async (nftType) => {
|
|
|
321
321
|
};
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
+
// src/utils/normalizeNftType.ts
|
|
325
|
+
var normalizedNftType = (nftType) => {
|
|
326
|
+
const nftTypeSplit = nftType?.split("::");
|
|
327
|
+
if (nftTypeSplit?.[0])
|
|
328
|
+
nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
329
|
+
return nftTypeSplit?.join("::");
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// src/helpers/getRoyaltyRuleModule.ts
|
|
333
|
+
var getRoyaltyRuleModule = (nftType) => normalizedNftType(nftType) === "0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard" ? "kiosk_royalty_rule" : "royalty_rule";
|
|
334
|
+
|
|
324
335
|
// src/graphql/queries/fetchTransferPoliciesByType.ts
|
|
325
336
|
var import_graphql_request7 = require("graphql-request");
|
|
326
337
|
var fetchTransferPoliciesByType = import_graphql_request7.gql`
|
|
@@ -334,14 +345,6 @@ var fetchTransferPoliciesByType = import_graphql_request7.gql`
|
|
|
334
345
|
}
|
|
335
346
|
`;
|
|
336
347
|
|
|
337
|
-
// src/utils/normalizeNftType.ts
|
|
338
|
-
var normalizedNftType = (nftType) => {
|
|
339
|
-
const nftTypeSplit = nftType?.split("::");
|
|
340
|
-
if (nftTypeSplit?.[0])
|
|
341
|
-
nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
342
|
-
return nftTypeSplit?.join("::");
|
|
343
|
-
};
|
|
344
|
-
|
|
345
348
|
// src/helpers/kiosk/getKioskTransferPolicies.ts
|
|
346
349
|
var getKioskTransferPolicies = async (nftType) => {
|
|
347
350
|
const res = await gqlChainRequest({
|
|
@@ -865,7 +868,8 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
865
868
|
bidNonce,
|
|
866
869
|
nftTokenId,
|
|
867
870
|
nftType,
|
|
868
|
-
royaltyRulePackageId
|
|
871
|
+
royaltyRulePackageId,
|
|
872
|
+
royaltyRuleModule
|
|
869
873
|
}) {
|
|
870
874
|
const { transferPolicy } = sharedObjects;
|
|
871
875
|
const [feeCoin, transferRequest] = tx.moveCall({
|
|
@@ -882,7 +886,7 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
882
886
|
typeArguments: [nftType]
|
|
883
887
|
});
|
|
884
888
|
tx.moveCall({
|
|
885
|
-
target: `${royaltyRulePackageId}::
|
|
889
|
+
target: `${royaltyRulePackageId}::${royaltyRuleModule}::pay`,
|
|
886
890
|
typeArguments: [nftType],
|
|
887
891
|
arguments: [tx.object(transferPolicy), transferRequest, feeCoin]
|
|
888
892
|
});
|
|
@@ -970,7 +974,8 @@ async function addTradePortAcceptNftBidTxHandler(txData) {
|
|
|
970
974
|
}
|
|
971
975
|
if (isTradePortKioskBid(bidType)) {
|
|
972
976
|
if (txData?.sellerKiosk) {
|
|
973
|
-
const
|
|
977
|
+
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
978
|
+
const royaltyRulePackageId = await getRulePackageId(txData.nftType, royaltyRuleModule);
|
|
974
979
|
return kioskTxWrapper({
|
|
975
980
|
tx: txData?.tx,
|
|
976
981
|
kioskTx: txData?.kioskTx,
|
|
@@ -980,7 +985,8 @@ async function addTradePortAcceptNftBidTxHandler(txData) {
|
|
|
980
985
|
await addTradeportKioskAcceptNftBidTx({
|
|
981
986
|
...txData,
|
|
982
987
|
kioskTx,
|
|
983
|
-
royaltyRulePackageId
|
|
988
|
+
royaltyRulePackageId,
|
|
989
|
+
royaltyRuleModule
|
|
984
990
|
});
|
|
985
991
|
}
|
|
986
992
|
});
|
|
@@ -1399,7 +1405,8 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
|
1399
1405
|
}
|
|
1400
1406
|
if (isTradePortKioskBid(bidType)) {
|
|
1401
1407
|
if (txData?.sellerKiosk) {
|
|
1402
|
-
const
|
|
1408
|
+
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
1409
|
+
const royaltyRulePackageId = await getRulePackageId(txData.nftType, royaltyRuleModule);
|
|
1403
1410
|
return kioskTxWrapper({
|
|
1404
1411
|
tx: txData?.tx,
|
|
1405
1412
|
kioskOwner: txData?.itemOwner,
|
|
@@ -1408,13 +1415,15 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
|
1408
1415
|
await addTradeportKioskAcceptCollectionBidTx({
|
|
1409
1416
|
...txData,
|
|
1410
1417
|
kioskTx,
|
|
1411
|
-
royaltyRulePackageId
|
|
1418
|
+
royaltyRulePackageId,
|
|
1419
|
+
royaltyRuleModule
|
|
1412
1420
|
});
|
|
1413
1421
|
}
|
|
1414
1422
|
});
|
|
1415
1423
|
}
|
|
1416
1424
|
if (await hasTransferPolicyRules(txData?.nftType) && !txData?.sellerKiosk) {
|
|
1417
|
-
const
|
|
1425
|
+
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
1426
|
+
const royaltyRulePackageId = await getRulePackageId(txData.nftType, royaltyRuleModule);
|
|
1418
1427
|
return kioskTxWrapper({
|
|
1419
1428
|
tx: txData?.tx,
|
|
1420
1429
|
kioskOwner: txData?.seller,
|
|
@@ -1427,7 +1436,8 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
|
1427
1436
|
await addTradeportKioskAcceptCollectionBidTx({
|
|
1428
1437
|
...txData,
|
|
1429
1438
|
kioskTx,
|
|
1430
|
-
royaltyRulePackageId
|
|
1439
|
+
royaltyRulePackageId,
|
|
1440
|
+
royaltyRuleModule
|
|
1431
1441
|
});
|
|
1432
1442
|
}
|
|
1433
1443
|
});
|
|
@@ -2880,8 +2890,11 @@ async function addOriginByteCollectionBidTx({
|
|
|
2880
2890
|
}
|
|
2881
2891
|
async function addTradePortPlaceCollectionBidTxHandler(txData) {
|
|
2882
2892
|
if (await hasRoyaltyRule(txData?.nftType)) {
|
|
2883
|
-
const royaltyRuleModule = txData?.
|
|
2884
|
-
const royaltyRulePackageId = await getRulePackageId(
|
|
2893
|
+
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
2894
|
+
const royaltyRulePackageId = await getRulePackageId(
|
|
2895
|
+
txData.nftType,
|
|
2896
|
+
getRoyaltyRuleModule(txData?.collectionId)
|
|
2897
|
+
);
|
|
2885
2898
|
addTradePortKioskCollectionBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
|
|
2886
2899
|
return;
|
|
2887
2900
|
}
|
|
@@ -2984,12 +2997,13 @@ function addTradePortKioskPlaceNftBidTx({
|
|
|
2984
2997
|
nftTokenId,
|
|
2985
2998
|
nftType,
|
|
2986
2999
|
bidAmount,
|
|
2987
|
-
royaltyRulePackageId
|
|
3000
|
+
royaltyRulePackageId,
|
|
3001
|
+
royaltyRuleModule
|
|
2988
3002
|
}) {
|
|
2989
3003
|
const { transferPolicy } = sharedObjects;
|
|
2990
3004
|
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
2991
3005
|
const royaltyCoin = tx.moveCall({
|
|
2992
|
-
target: `${royaltyRulePackageId}::
|
|
3006
|
+
target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
|
|
2993
3007
|
arguments: [tx.object(transferPolicy), tx.pure.u64(bidAmount?.toString())],
|
|
2994
3008
|
typeArguments: [nftType]
|
|
2995
3009
|
});
|
|
@@ -3046,8 +3060,9 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
|
|
|
3046
3060
|
return;
|
|
3047
3061
|
}
|
|
3048
3062
|
if (await hasTransferPolicyRules(txData?.nftType) && txData?.sellerKiosk) {
|
|
3049
|
-
const
|
|
3050
|
-
|
|
3063
|
+
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
3064
|
+
const royaltyRulePackageId = await getRulePackageId(txData.nftType, royaltyRuleModule);
|
|
3065
|
+
addTradePortKioskPlaceNftBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
|
|
3051
3066
|
return;
|
|
3052
3067
|
}
|
|
3053
3068
|
addTradePortPlaceNftBidTx(txData);
|