@tradeport/sui-trading-sdk 0.1.87 → 0.1.89
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 +177 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/helpers/kiosk/getKioskPlaceBidCoin.ts +48 -0
- package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +1 -1
- package/src/methods/buyListings/addBuyListingTxs.ts +1 -1
- package/src/methods/claimNfts/addClaimNftsTxs.ts +2 -2
- package/src/methods/listNfts/addListTxs.ts +1 -1
- package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +11 -25
- package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +119 -11
- package/src/methods/placeNftBids/placeNftBids.ts +3 -0
- package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +1 -1
- package/src/methods/unlistListings/addUnlistListingTxs.ts +1 -6
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -55,8 +55,7 @@ function createChainGQLQuery({ chain, query }) {
|
|
|
55
55
|
throw new Error("Invalid query string format");
|
|
56
56
|
}
|
|
57
57
|
const [, queryName, argsString, bodyString] = matches;
|
|
58
|
-
if (!argsString || !bodyString)
|
|
59
|
-
return "";
|
|
58
|
+
if (!argsString || !bodyString) return "";
|
|
60
59
|
const args = argsString.trim().length ? `(${argsString.trim()})` : "";
|
|
61
60
|
const body = bodyString.trim();
|
|
62
61
|
const wrappedBody = `${chain} {
|
|
@@ -212,8 +211,7 @@ var getNftType = ({
|
|
|
212
211
|
if (collectionId === "a6fabb11-4713-4203-bce8-a3c4f673b5a7") {
|
|
213
212
|
return nft?.properties?.nft_type;
|
|
214
213
|
}
|
|
215
|
-
if (collectionChainState?.nft_type)
|
|
216
|
-
return collectionChainState.nft_type;
|
|
214
|
+
if (collectionChainState?.nft_type) return collectionChainState.nft_type;
|
|
217
215
|
let nftType = nft?.properties?.nft_type;
|
|
218
216
|
if (!nftType || nftType?.split("::")?.length <= 1) {
|
|
219
217
|
nftType = nft?.contract?.properties?.nft_type;
|
|
@@ -300,16 +298,14 @@ var addLeadingZerosAfter0x = (str) => `0x${str?.replace("0x", "").padStart(64, "
|
|
|
300
298
|
// src/helpers/getSharedObjects.ts
|
|
301
299
|
var getSharedObjects = async (nftType) => {
|
|
302
300
|
const nftTypeSplit = nftType?.split("::");
|
|
303
|
-
if (nftTypeSplit?.[0])
|
|
304
|
-
nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
301
|
+
if (nftTypeSplit?.[0]) nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
305
302
|
const res = await gqlChainRequest({
|
|
306
303
|
chain: "sui",
|
|
307
304
|
query: fetchSharedObjectsByType,
|
|
308
305
|
variables: { type: nftTypeSplit?.join("::") }
|
|
309
306
|
});
|
|
310
307
|
let allowList = res?.sharedObjects?.filter((object) => object?.module === "allowlist")?.[0]?.id;
|
|
311
|
-
if (!allowList)
|
|
312
|
-
allowList = ORIGIN_BYTE_ALLOW_LIST_OBJECT;
|
|
308
|
+
if (!allowList) allowList = ORIGIN_BYTE_ALLOW_LIST_OBJECT;
|
|
313
309
|
if (nftType === "0x5f1fa51a6d5c52df7dfe0ff7efaab7cc769d81e51cf208a424e455575aa1ed7a::stork::Stork") {
|
|
314
310
|
allowList = STORKS_ORIGIN_BYTE_ALLOW_LIST;
|
|
315
311
|
}
|
|
@@ -361,8 +357,7 @@ var getSharedObjects = async (nftType) => {
|
|
|
361
357
|
// src/utils/normalizeNftType.ts
|
|
362
358
|
var normalizedNftType = (nftType) => {
|
|
363
359
|
const nftTypeSplit = nftType?.split("::");
|
|
364
|
-
if (nftTypeSplit?.[0])
|
|
365
|
-
nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
360
|
+
if (nftTypeSplit?.[0]) nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
366
361
|
return nftTypeSplit?.join("::");
|
|
367
362
|
};
|
|
368
363
|
|
|
@@ -740,8 +735,7 @@ var lockNftInsideKioskIfNotLocked = async ({
|
|
|
740
735
|
const res = await kioskClient.getKiosk({ id: sellerKiosk });
|
|
741
736
|
isLocked = res?.items?.find((i) => i.objectId === nftTokenId)?.isLocked;
|
|
742
737
|
}
|
|
743
|
-
if (isLocked)
|
|
744
|
-
return;
|
|
738
|
+
if (isLocked) return;
|
|
745
739
|
const item = kioskTx.take({
|
|
746
740
|
itemId: nftTokenId,
|
|
747
741
|
itemType: nftType
|
|
@@ -785,11 +779,9 @@ function resolveKioskLockRule({
|
|
|
785
779
|
kioskItem,
|
|
786
780
|
shouldSkipLocking
|
|
787
781
|
}) {
|
|
788
|
-
if (!kiosk || !kioskCap)
|
|
789
|
-
throw new Error("Missing Owned Kiosk or Owned Kiosk Cap");
|
|
782
|
+
if (!kiosk || !kioskCap) throw new Error("Missing Owned Kiosk or Owned Kiosk Cap");
|
|
790
783
|
if (!shouldSkipLocking) {
|
|
791
|
-
if (!kioskItem)
|
|
792
|
-
throw new Error("Missing Kiosk Item");
|
|
784
|
+
if (!kioskItem) throw new Error("Missing Kiosk Item");
|
|
793
785
|
tx.moveCall({
|
|
794
786
|
target: "0x2::kiosk::lock",
|
|
795
787
|
typeArguments: [nftType],
|
|
@@ -805,8 +797,7 @@ function resolveKioskLockRule({
|
|
|
805
797
|
|
|
806
798
|
// src/helpers/kiosk/resolvePersonalKioskRule.ts
|
|
807
799
|
function resolvePersonalKioskRule({ tx, packageId, nftType, kiosk, transferRequest }) {
|
|
808
|
-
if (!kiosk)
|
|
809
|
-
throw new Error("Missing owned Kiosk.");
|
|
800
|
+
if (!kiosk) throw new Error("Missing owned Kiosk.");
|
|
810
801
|
tx.moveCall({
|
|
811
802
|
target: `${packageId}::personal_kiosk_rule::prove`,
|
|
812
803
|
typeArguments: [nftType],
|
|
@@ -956,8 +947,7 @@ var resolveTransferPolicies = async ({
|
|
|
956
947
|
break;
|
|
957
948
|
case "royalty_rule":
|
|
958
949
|
case "kiosk_royalty_rule":
|
|
959
|
-
if (shouldSkipResolvingRoyaltyRule)
|
|
960
|
-
break;
|
|
950
|
+
if (shouldSkipResolvingRoyaltyRule) break;
|
|
961
951
|
resolveRoyaltyRule({
|
|
962
952
|
tx,
|
|
963
953
|
packageId: rulePackageId,
|
|
@@ -1093,7 +1083,7 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
1093
1083
|
transferPolicyId
|
|
1094
1084
|
});
|
|
1095
1085
|
const [feeCoin, transferRequest] = tx.moveCall({
|
|
1096
|
-
target: "
|
|
1086
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::accept_bid_with_purchase_cap",
|
|
1097
1087
|
arguments: [
|
|
1098
1088
|
tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
1099
1089
|
tx.pure.address(bidNonce),
|
|
@@ -1244,12 +1234,6 @@ var isNonKioskListing = async ({
|
|
|
1244
1234
|
return listingType === NON_KIOSK_LISTING_NONCE_TYPE;
|
|
1245
1235
|
};
|
|
1246
1236
|
|
|
1247
|
-
// src/helpers/splitCoins.ts
|
|
1248
|
-
var splitCoins = ({ tx, amounts }) => {
|
|
1249
|
-
const res = tx.splitCoins(tx.gas, amounts);
|
|
1250
|
-
return res;
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
1237
|
// src/methods/unlistListings/addUnlistListingTxs.ts
|
|
1254
1238
|
function addTradePortUnlistTx({ tx, listingNonce, nftType }) {
|
|
1255
1239
|
tx.moveCall({
|
|
@@ -1265,7 +1249,7 @@ async function addTradePortKioskUnlistTx({
|
|
|
1265
1249
|
nftType
|
|
1266
1250
|
}) {
|
|
1267
1251
|
tx.moveCall({
|
|
1268
|
-
target: "
|
|
1252
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_listings::unlist",
|
|
1269
1253
|
arguments: [
|
|
1270
1254
|
tx.object(TRADEPORT_KIOSK_LISTING_STORE),
|
|
1271
1255
|
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
@@ -1342,7 +1326,6 @@ async function addHyperspaceKioskUnlistTx({
|
|
|
1342
1326
|
nftTokenId,
|
|
1343
1327
|
nftType
|
|
1344
1328
|
}) {
|
|
1345
|
-
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(1)] });
|
|
1346
1329
|
tx.moveCall({
|
|
1347
1330
|
target: "0x6ea97b03c441edd54ae89224bf9560e583ee66c37e6c246f5db35258e580ba94::hyperspace::delist",
|
|
1348
1331
|
arguments: [
|
|
@@ -1352,7 +1335,6 @@ async function addHyperspaceKioskUnlistTx({
|
|
|
1352
1335
|
],
|
|
1353
1336
|
typeArguments: [nftType, HYPERSPACE_MP_TRANSFER_POLICY_TYPE]
|
|
1354
1337
|
});
|
|
1355
|
-
tx.transferObjects([tx.object(coin)], tx.object(nftTokenId));
|
|
1356
1338
|
}
|
|
1357
1339
|
function addTocenUnlistTx({ tx, nftTokenId, nftType }) {
|
|
1358
1340
|
tx.moveCall({
|
|
@@ -2221,6 +2203,13 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
|
|
|
2221
2203
|
});
|
|
2222
2204
|
};
|
|
2223
2205
|
switch (bid.type) {
|
|
2206
|
+
// case 'solo': {
|
|
2207
|
+
// await acceptNftBids(
|
|
2208
|
+
// { bidIds: [bidId], tx, kioskTx, beforeResolveKioskTransferRequest },
|
|
2209
|
+
// context,
|
|
2210
|
+
// );
|
|
2211
|
+
// break;
|
|
2212
|
+
// }
|
|
2224
2213
|
case "collection": {
|
|
2225
2214
|
await acceptCollectionBid(
|
|
2226
2215
|
{
|
|
@@ -2367,11 +2356,16 @@ var destroyZeroCoin = ({ tx, coin }) => {
|
|
|
2367
2356
|
});
|
|
2368
2357
|
};
|
|
2369
2358
|
|
|
2359
|
+
// src/helpers/splitCoins.ts
|
|
2360
|
+
var splitCoins = ({ tx, amounts }) => {
|
|
2361
|
+
const res = tx.splitCoins(tx.gas, amounts);
|
|
2362
|
+
return res;
|
|
2363
|
+
};
|
|
2364
|
+
|
|
2370
2365
|
// src/methods/buyListings/addBuyListingTxs.ts
|
|
2371
2366
|
function addTradePortBuyTx({ tx, nftType, listingNonce, price, sharedObjects }) {
|
|
2372
2367
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
|
|
2373
|
-
if (!coin)
|
|
2374
|
-
throw new Error("Coin could not be split");
|
|
2368
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2375
2369
|
const { collection, royaltyStrategy } = sharedObjects;
|
|
2376
2370
|
if (collection && royaltyStrategy) {
|
|
2377
2371
|
tx.moveCall({
|
|
@@ -2422,10 +2416,9 @@ var addTradeportKioskBuyTx = async ({
|
|
|
2422
2416
|
const coin = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [
|
|
2423
2417
|
tx.pure.u64(price + Number(response.data.content.fields.commission))
|
|
2424
2418
|
]);
|
|
2425
|
-
if (!coin)
|
|
2426
|
-
throw new Error("Coin could not be split");
|
|
2419
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2427
2420
|
const [kioskItem, transferRequest, kioskPrice] = tx.moveCall({
|
|
2428
|
-
target: "
|
|
2421
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_listings::buy",
|
|
2429
2422
|
arguments: [
|
|
2430
2423
|
tx.object(TRADEPORT_KIOSK_LISTING_STORE),
|
|
2431
2424
|
tx.object(sellerKiosk),
|
|
@@ -2466,8 +2459,7 @@ async function addOriginByteBuyTx({
|
|
|
2466
2459
|
address: buyer
|
|
2467
2460
|
});
|
|
2468
2461
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
|
|
2469
|
-
if (!coin)
|
|
2470
|
-
throw new Error("Coin could not be split");
|
|
2462
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2471
2463
|
const transferRequest = tx.moveCall({
|
|
2472
2464
|
target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::orderbook::buy_nft",
|
|
2473
2465
|
arguments: [
|
|
@@ -2499,8 +2491,7 @@ var addHyperspaceKioskBuyTx = async ({
|
|
|
2499
2491
|
}) => {
|
|
2500
2492
|
await assertNftInSharedKiosk({ kioskId: sellerKiosk, walletAddress: seller });
|
|
2501
2493
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
|
|
2502
|
-
if (!coin)
|
|
2503
|
-
throw new Error("Coin could not be split");
|
|
2494
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2504
2495
|
const [kioskItem, transferRequest, hyperspaceTransferRequest, hyperspaceMpTransferRequest] = tx.moveCall({
|
|
2505
2496
|
target: "0x6ea97b03c441edd54ae89224bf9560e583ee66c37e6c246f5db35258e580ba94::hyperspace::purchase",
|
|
2506
2497
|
arguments: [tx.object(sellerKiosk), tx.pure.address(nftTokenId), tx.object(coin)],
|
|
@@ -2530,8 +2521,7 @@ var addHyperspaceKioskBuyTx = async ({
|
|
|
2530
2521
|
};
|
|
2531
2522
|
function addBluemoveBuyTx({ tx, nftTokenId, nftType, price }) {
|
|
2532
2523
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
|
|
2533
|
-
if (!coin)
|
|
2534
|
-
throw new Error("Coin could not be split");
|
|
2524
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2535
2525
|
tx.moveCall({
|
|
2536
2526
|
target: "0xd5dd28cc24009752905689b2ba2bf90bfc8de4549b9123f93519bb8ba9bf9981::marketplace::buy_and_take",
|
|
2537
2527
|
arguments: [
|
|
@@ -2562,8 +2552,7 @@ async function addBluemoveKioskBuyTx({
|
|
|
2562
2552
|
tx,
|
|
2563
2553
|
amounts: [tx.pure.u64(price), tx.pure.u64(price * 0.025)]
|
|
2564
2554
|
});
|
|
2565
|
-
if (!coin1 || !coin2)
|
|
2566
|
-
throw new Error("Coin could not be split");
|
|
2555
|
+
if (!coin1 || !coin2) throw new Error("Coin could not be split");
|
|
2567
2556
|
tx.mergeCoins(tx.object(coin1), [tx.object(coin2)]);
|
|
2568
2557
|
const [kioskItem, transferRequest] = tx.moveCall({
|
|
2569
2558
|
target: "0xcc97b74ed95c8e8a3ed88050a898727dee37896da579fc400d482b64db6149ff::kiosk_trade::kiosk_buy_v2",
|
|
@@ -2625,8 +2614,7 @@ async function addSouffl3BuyTx({ tx, nftType, price, listingNonce, collectionId
|
|
|
2625
2614
|
}
|
|
2626
2615
|
function addSomisBuyTx({ tx, sharedObjects, nftTokenId, nftType, price }) {
|
|
2627
2616
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
|
|
2628
|
-
if (!coin)
|
|
2629
|
-
throw new Error("Coin could not be split");
|
|
2617
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2630
2618
|
tx.moveCall({
|
|
2631
2619
|
target: "0xf0b0beb956e26bde50dbd6ac393026c4525aee3b194a9478f09748f7211b5a02::marketplace::buy_nft",
|
|
2632
2620
|
arguments: [
|
|
@@ -2655,15 +2643,13 @@ async function addKeepsakeBuyTx({
|
|
|
2655
2643
|
tx.pure.u64(price * Number(royalty) / 100 + price * Number(royalty) * 5e-5)
|
|
2656
2644
|
]
|
|
2657
2645
|
});
|
|
2658
|
-
if (!coin1 || !coin2)
|
|
2659
|
-
throw new Error("Coin could not be split");
|
|
2646
|
+
if (!coin1 || !coin2) throw new Error("Coin could not be split");
|
|
2660
2647
|
const [balance] = tx.moveCall({
|
|
2661
2648
|
target: "0x2::coin::into_balance",
|
|
2662
2649
|
arguments: [tx.object(coin2)],
|
|
2663
2650
|
typeArguments: ["0x2::sui::SUI"]
|
|
2664
2651
|
});
|
|
2665
|
-
if (!balance)
|
|
2666
|
-
throw new Error("Coin into_balance failed");
|
|
2652
|
+
if (!balance) throw new Error("Coin into_balance failed");
|
|
2667
2653
|
const [transferRequest] = tx.moveCall({
|
|
2668
2654
|
target: "0x02be8c4a1a3cea4d3255d870d367c87838a8cc2bfe4f216a6b67b153027087a7::keepsake_marketplace::buy",
|
|
2669
2655
|
arguments: [
|
|
@@ -2674,8 +2660,7 @@ async function addKeepsakeBuyTx({
|
|
|
2674
2660
|
],
|
|
2675
2661
|
typeArguments: [nftType]
|
|
2676
2662
|
});
|
|
2677
|
-
if (!transferRequest)
|
|
2678
|
-
throw new Error("Transfer request could not be created");
|
|
2663
|
+
if (!transferRequest) throw new Error("Transfer request could not be created");
|
|
2679
2664
|
tx.moveCall({
|
|
2680
2665
|
target: "0x02be8c4a1a3cea4d3255d870d367c87838a8cc2bfe4f216a6b67b153027087a7::keepsake_royalties::confirm_transfer_with_balance",
|
|
2681
2666
|
arguments: [tx.object(keepsakeRoyaltyStrategy), tx.object(transferRequest), tx.object(balance)],
|
|
@@ -2691,8 +2676,7 @@ async function addKeepsakeBuyTx({
|
|
|
2691
2676
|
arguments: [tx.object(balance)],
|
|
2692
2677
|
typeArguments: ["0x2::sui::SUI"]
|
|
2693
2678
|
});
|
|
2694
|
-
if (!balanceToTransfer)
|
|
2695
|
-
throw new Error("Coin from_balance failed");
|
|
2679
|
+
if (!balanceToTransfer) throw new Error("Coin from_balance failed");
|
|
2696
2680
|
tx.transferObjects(
|
|
2697
2681
|
[tx.object(balanceToTransfer)],
|
|
2698
2682
|
tx.pure.address(addLeadingZerosAfter0x(buyer))
|
|
@@ -2700,8 +2684,7 @@ async function addKeepsakeBuyTx({
|
|
|
2700
2684
|
}
|
|
2701
2685
|
var addTocenBuyTx = ({ tx, nftTokenIds, nftType, price }) => {
|
|
2702
2686
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
|
|
2703
|
-
if (!coin)
|
|
2704
|
-
throw new Error("Coin could not be split");
|
|
2687
|
+
if (!coin) throw new Error("Coin could not be split");
|
|
2705
2688
|
tx.moveCall({
|
|
2706
2689
|
target: "0x3605d91c559e80cf8fdeabae9abaccb0bc38f96eac0b32bf47e95a9159a5277f::tocen_marketplace::buy_cart",
|
|
2707
2690
|
arguments: [
|
|
@@ -3234,7 +3217,7 @@ var addClaimAcceptedBidNftTx = async ({
|
|
|
3234
3217
|
}) => {
|
|
3235
3218
|
const transferPolicyId = (await getKioskTransferPolicies(nftType))?.at(0)?.id;
|
|
3236
3219
|
const [transferRequest] = tx.moveCall({
|
|
3237
|
-
target: "
|
|
3220
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::claim_bid",
|
|
3238
3221
|
arguments: [
|
|
3239
3222
|
tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
3240
3223
|
tx.object(TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK),
|
|
@@ -3265,7 +3248,7 @@ var addClaimAcceptedBidNftWithPurchaseCapTx = async ({
|
|
|
3265
3248
|
}) => {
|
|
3266
3249
|
const transferPolicyId = (await getKioskTransferPolicies(nftType))?.at(0)?.id;
|
|
3267
3250
|
const [transferRequest] = tx.moveCall({
|
|
3268
|
-
target: "
|
|
3251
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::claim_bid_with_purchase_cap",
|
|
3269
3252
|
arguments: [
|
|
3270
3253
|
tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
3271
3254
|
tx.object(sellerKiosk),
|
|
@@ -3742,7 +3725,7 @@ async function addTradePortKioskListTx({
|
|
|
3742
3725
|
}
|
|
3743
3726
|
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
3744
3727
|
tx.moveCall({
|
|
3745
|
-
target: "
|
|
3728
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_listings::list",
|
|
3746
3729
|
arguments: [
|
|
3747
3730
|
tx.object(TRADEPORT_KIOSK_LISTING_STORE),
|
|
3748
3731
|
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
@@ -4289,6 +4272,40 @@ var hasRoyaltyRule = async (nftType) => {
|
|
|
4289
4272
|
);
|
|
4290
4273
|
};
|
|
4291
4274
|
|
|
4275
|
+
// src/helpers/kiosk/getKioskPlaceBidCoin.ts
|
|
4276
|
+
async function getKioskPlaceBidCoin({
|
|
4277
|
+
tx,
|
|
4278
|
+
nftType,
|
|
4279
|
+
bidAmount,
|
|
4280
|
+
marketFeePrice,
|
|
4281
|
+
royaltyRulePackageId,
|
|
4282
|
+
royaltyRuleModule,
|
|
4283
|
+
transferPolicyId
|
|
4284
|
+
}) {
|
|
4285
|
+
let coin;
|
|
4286
|
+
if (royaltyRulePackageId && royaltyRuleModule) {
|
|
4287
|
+
const fee = tx.moveCall({
|
|
4288
|
+
target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
|
|
4289
|
+
arguments: [tx.object(transferPolicyId), tx.pure.u64(bidAmount)],
|
|
4290
|
+
typeArguments: [nftType]
|
|
4291
|
+
});
|
|
4292
|
+
const [coin1, coin2] = splitCoins({
|
|
4293
|
+
tx,
|
|
4294
|
+
amounts: [tx.pure.u64(bidAmount + marketFeePrice), tx.object(fee)]
|
|
4295
|
+
});
|
|
4296
|
+
coin = coin1;
|
|
4297
|
+
if (!coin1 || !coin2) throw new Error("Coin could not be split");
|
|
4298
|
+
tx.mergeCoins(tx.object(coin1), [tx.object(coin2)]);
|
|
4299
|
+
} else {
|
|
4300
|
+
const [coin1] = splitCoins({
|
|
4301
|
+
tx,
|
|
4302
|
+
amounts: [tx.pure.u64(bidAmount + marketFeePrice)]
|
|
4303
|
+
});
|
|
4304
|
+
coin = coin1;
|
|
4305
|
+
}
|
|
4306
|
+
return coin;
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4292
4309
|
// src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts
|
|
4293
4310
|
function addTradePortCollectionBidTx({
|
|
4294
4311
|
tx,
|
|
@@ -4325,30 +4342,17 @@ async function addTradePortKioskCollectionBidTx({
|
|
|
4325
4342
|
price: bidAmount,
|
|
4326
4343
|
collectionId
|
|
4327
4344
|
});
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
amounts: [tx.pure.u64(bidAmount + marketFeePrice), tx.object(fee)]
|
|
4338
|
-
});
|
|
4339
|
-
coin = coin1;
|
|
4340
|
-
if (!coin1 || !coin2)
|
|
4341
|
-
throw new Error("Coin could not be split");
|
|
4342
|
-
tx.mergeCoins(tx.object(coin1), [tx.object(coin2)]);
|
|
4343
|
-
} else {
|
|
4344
|
-
const [coin1] = splitCoins({
|
|
4345
|
-
tx,
|
|
4346
|
-
amounts: [tx.pure.u64(bidAmount + marketFeePrice)]
|
|
4347
|
-
});
|
|
4348
|
-
coin = coin1;
|
|
4349
|
-
}
|
|
4345
|
+
const coin = await getKioskPlaceBidCoin({
|
|
4346
|
+
tx,
|
|
4347
|
+
nftType,
|
|
4348
|
+
bidAmount,
|
|
4349
|
+
marketFeePrice,
|
|
4350
|
+
royaltyRulePackageId,
|
|
4351
|
+
royaltyRuleModule,
|
|
4352
|
+
transferPolicyId
|
|
4353
|
+
});
|
|
4350
4354
|
tx.moveCall({
|
|
4351
|
-
target: "
|
|
4355
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::collection_bid",
|
|
4352
4356
|
arguments: [
|
|
4353
4357
|
tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
4354
4358
|
tx.pure.u64(bidAmount),
|
|
@@ -4498,7 +4502,6 @@ function addTradePortPlaceNftBidTx({
|
|
|
4498
4502
|
}
|
|
4499
4503
|
async function addTradePortKioskPlaceNftBidTx({
|
|
4500
4504
|
tx,
|
|
4501
|
-
sharedObjects,
|
|
4502
4505
|
collectionId,
|
|
4503
4506
|
nftTokenId,
|
|
4504
4507
|
nftType,
|
|
@@ -4506,31 +4509,72 @@ async function addTradePortKioskPlaceNftBidTx({
|
|
|
4506
4509
|
royaltyRulePackageId,
|
|
4507
4510
|
royaltyRuleModule
|
|
4508
4511
|
}) {
|
|
4509
|
-
const transferPolicyId =
|
|
4512
|
+
const transferPolicyId = await getKioskTransferPolicies(nftType).then(
|
|
4513
|
+
(policies) => policies?.[0]?.id
|
|
4514
|
+
);
|
|
4510
4515
|
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
4511
|
-
const
|
|
4512
|
-
|
|
4513
|
-
|
|
4516
|
+
const coin = await getKioskPlaceBidCoin({
|
|
4517
|
+
tx,
|
|
4518
|
+
nftType,
|
|
4519
|
+
bidAmount,
|
|
4520
|
+
marketFeePrice,
|
|
4521
|
+
royaltyRulePackageId,
|
|
4522
|
+
royaltyRuleModule,
|
|
4523
|
+
transferPolicyId
|
|
4524
|
+
});
|
|
4525
|
+
tx.moveCall({
|
|
4526
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::bid",
|
|
4527
|
+
arguments: [
|
|
4528
|
+
tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
4529
|
+
tx.pure.address(nftTokenId),
|
|
4530
|
+
tx.pure.u64(bidAmount),
|
|
4531
|
+
tx.object(coin),
|
|
4532
|
+
tx.pure.u64(marketFeePrice),
|
|
4533
|
+
tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
|
|
4534
|
+
],
|
|
4514
4535
|
typeArguments: [nftType]
|
|
4515
4536
|
});
|
|
4516
|
-
|
|
4537
|
+
destroyZeroCoin({ tx, coin });
|
|
4538
|
+
}
|
|
4539
|
+
async function addKumoTradePortKioskPlaceNftBidTx({
|
|
4540
|
+
tx,
|
|
4541
|
+
suiClient,
|
|
4542
|
+
collectionId,
|
|
4543
|
+
nftTokenId,
|
|
4544
|
+
nftType,
|
|
4545
|
+
bidAmount,
|
|
4546
|
+
royaltyRulePackageId,
|
|
4547
|
+
royaltyRuleModule
|
|
4548
|
+
}) {
|
|
4549
|
+
const transferPolicyId = await getKioskTransferPolicies(nftType).then(
|
|
4550
|
+
(policies) => policies?.[0]?.id
|
|
4551
|
+
);
|
|
4552
|
+
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
4553
|
+
const coin = await getKioskPlaceBidCoin({
|
|
4517
4554
|
tx,
|
|
4518
|
-
|
|
4555
|
+
nftType,
|
|
4556
|
+
bidAmount,
|
|
4557
|
+
marketFeePrice,
|
|
4558
|
+
royaltyRulePackageId,
|
|
4559
|
+
royaltyRuleModule,
|
|
4560
|
+
transferPolicyId
|
|
4519
4561
|
});
|
|
4520
|
-
|
|
4562
|
+
const kumoAttributes = await fetchKumoNftAttributes(suiClient, nftTokenId);
|
|
4563
|
+
const normalizedAttributes = normalizeKumoAttributes(kumoAttributes);
|
|
4521
4564
|
tx.moveCall({
|
|
4522
|
-
target: "
|
|
4565
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::kumo_bid",
|
|
4523
4566
|
arguments: [
|
|
4524
4567
|
tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
4525
4568
|
tx.pure.address(nftTokenId),
|
|
4526
4569
|
tx.pure.u64(bidAmount),
|
|
4527
|
-
tx.object(
|
|
4570
|
+
tx.object(coin),
|
|
4528
4571
|
tx.pure.u64(marketFeePrice),
|
|
4529
|
-
tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
|
|
4572
|
+
tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
4573
|
+
...Object.values(normalizedAttributes).map((attr) => tx.pure.option("string", attr))
|
|
4530
4574
|
],
|
|
4531
4575
|
typeArguments: [nftType]
|
|
4532
4576
|
});
|
|
4533
|
-
destroyZeroCoin({ tx, coin
|
|
4577
|
+
destroyZeroCoin({ tx, coin });
|
|
4534
4578
|
}
|
|
4535
4579
|
async function addTradePortPlaceNftBidTxHandler(txData) {
|
|
4536
4580
|
if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
|
|
@@ -4543,11 +4587,49 @@ async function addTradePortPlaceNftBidTxHandler(txData) {
|
|
|
4543
4587
|
ruleType: royaltyRuleModule,
|
|
4544
4588
|
kioskClient: txData?.kioskClient
|
|
4545
4589
|
});
|
|
4590
|
+
if (txData?.collectionId === "67aca668-31b0-4713-91cf-079d392b041a") {
|
|
4591
|
+
await addKumoTradePortKioskPlaceNftBidTx({
|
|
4592
|
+
...txData,
|
|
4593
|
+
royaltyRulePackageId,
|
|
4594
|
+
royaltyRuleModule
|
|
4595
|
+
});
|
|
4596
|
+
return;
|
|
4597
|
+
}
|
|
4546
4598
|
await addTradePortKioskPlaceNftBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
|
|
4547
4599
|
return;
|
|
4548
4600
|
}
|
|
4549
4601
|
addTradePortPlaceNftBidTx(txData);
|
|
4550
4602
|
}
|
|
4603
|
+
async function fetchKumoNftAttributes(suiClient, nftTokenId) {
|
|
4604
|
+
if (!nftTokenId) {
|
|
4605
|
+
throw new Error("NFT Token ID is required to fetch Kumo attributes");
|
|
4606
|
+
}
|
|
4607
|
+
let res;
|
|
4608
|
+
try {
|
|
4609
|
+
res = await suiClient.getObject({
|
|
4610
|
+
id: nftTokenId,
|
|
4611
|
+
options: { showContent: true }
|
|
4612
|
+
});
|
|
4613
|
+
} catch (error) {
|
|
4614
|
+
throw new Error(
|
|
4615
|
+
`Failed to fetch Kumo token object data: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
4616
|
+
);
|
|
4617
|
+
}
|
|
4618
|
+
if (!res.data) {
|
|
4619
|
+
throw new Error(`NFT object data not found: ${nftTokenId}`);
|
|
4620
|
+
}
|
|
4621
|
+
if (res.data?.content?.dataType !== "moveObject") {
|
|
4622
|
+
throw new Error("Invalid NFT Token ID - not a move object");
|
|
4623
|
+
}
|
|
4624
|
+
const { accessory, background, eyes, fur_colour, mouth, tail, one_of_one } = res.data?.content?.fields || {};
|
|
4625
|
+
return { accessory, background, eyes, fur_colour, mouth, tail, one_of_one };
|
|
4626
|
+
}
|
|
4627
|
+
function normalizeKumoAttributes(attributes) {
|
|
4628
|
+
const normalizeAttribute = (attr) => !attr || attr === "Default" || attr === "None" ? null : attr;
|
|
4629
|
+
return Object.fromEntries(
|
|
4630
|
+
Object.entries(attributes).map(([key, value]) => [key, normalizeAttribute(value)])
|
|
4631
|
+
);
|
|
4632
|
+
}
|
|
4551
4633
|
|
|
4552
4634
|
// src/methods/placeNftBids/placeNftBids.ts
|
|
4553
4635
|
var placeNftBids = async ({ nfts, walletAddress }, context) => {
|
|
@@ -4570,6 +4652,7 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
|
|
|
4570
4652
|
const sharedObjects = await getSharedObjects(nftType);
|
|
4571
4653
|
const txData = {
|
|
4572
4654
|
tx,
|
|
4655
|
+
suiClient: context.suiClient,
|
|
4573
4656
|
kioskClient: context.kioskClient,
|
|
4574
4657
|
sharedObjects,
|
|
4575
4658
|
bidder: walletAddress,
|
|
@@ -4603,7 +4686,7 @@ function addTradeportRemoveNftBidTx({ tx, bidNonce, nftType }) {
|
|
|
4603
4686
|
}
|
|
4604
4687
|
function addTradeportKioskRemoveNftBidTx({ tx, bidNonce, nftType }) {
|
|
4605
4688
|
tx.moveCall({
|
|
4606
|
-
target: "
|
|
4689
|
+
target: "0x38b992a0be4a6128d39a593c77a82dc2cc156a2560d2a999813463f376b04085::kiosk_biddings::cancel_bid",
|
|
4607
4690
|
arguments: [tx.object(TRADEPORT_KIOSK_BIDDING_STORE), tx.pure.address(bidNonce)],
|
|
4608
4691
|
typeArguments: [nftType]
|
|
4609
4692
|
});
|