@tradeport/sui-trading-sdk 0.3.8 → 0.4.0

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +38 -2
  3. package/dist/index.d.ts +38 -2
  4. package/dist/index.js +409 -350
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +409 -350
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +1 -1
  9. package/src/SuiTradingClient.ts +23 -2
  10. package/src/constants.ts +11 -0
  11. package/src/graphql/queries/fetchBidsById.ts +1 -0
  12. package/src/graphql/queries/fetchCollectionBidById.ts +1 -0
  13. package/src/graphql/queries/fetchCollectionBidsAtSamePrice.ts +1 -0
  14. package/src/graphql/queries/fetchMultibidById.ts +10 -0
  15. package/src/helpers/isSIngleBid.ts +13 -0
  16. package/src/helpers/kiosk/getKioskTransferPolicies.ts +7 -0
  17. package/src/helpers/kiosk/kioskTxWrapper.ts +8 -5
  18. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +2 -0
  19. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +10 -1
  20. package/src/methods/acceptNftBids/acceptNftBids.ts +3 -0
  21. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +94 -1
  22. package/src/methods/cancelMultiBid/cancelMultiBid.ts +35 -0
  23. package/src/methods/createMultiBid/createMultiBid.ts +35 -0
  24. package/src/methods/placeCollectionBids/placeCollectionBids.ts +26 -11
  25. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +100 -230
  26. package/src/methods/placeNftBids/placeNftBids.ts +21 -14
  27. package/src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts +10 -1
  28. package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +30 -0
  29. package/src/methods/removeNftBids/removeNftBids.ts +2 -0
  30. package/src/methods/updateMultiBid/updateMultiBid.ts +59 -0
  31. package/src/tests/SuiWallet.ts +1 -1
package/dist/index.mjs CHANGED
@@ -64,6 +64,7 @@ var fetchCollectionBidsById = gql2`
64
64
  status
65
65
  type
66
66
  collection_id
67
+ multi_bid_id
67
68
  contract {
68
69
  properties
69
70
  }
@@ -93,6 +94,7 @@ var fetchCollectionBidsAtSamePrice = gql3`
93
94
  status
94
95
  type
95
96
  collection_id
97
+ multi_bid_id
96
98
  contract {
97
99
  properties
98
100
  }
@@ -120,6 +122,8 @@ var TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK = "0x151fbe627d3f8de855f424c879ea2176d8
120
122
  var TRADEPORT_KIOSK_BID_NONCE_TYPE = "0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Bid";
121
123
  var TRADEPORT_PRICE_LOCK_PACKAGE = "0x3cb532a2548290780a3d70ad6f4f06abc5bebb75ec6f8dd0197d4d2b2860c5d8";
122
124
  var TRADEPORT_PRICE_LOCK_STORE = "0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0c9e03cac5729c0c47946";
125
+ var TRADEPORT_MULTI_BID_PACKAGE = "0xb32c899d9fb0d79a7e384bfbf2830a19ee26ccf51d6cadaaf1a14c4a2817886a";
126
+ var TRADEPORT_MULTI_BID_STORE = "0x2617658a6b03dcf6df2df4d256341bc4690d3a3d299c9552ca6ac9799ceb0ed7";
123
127
  var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
124
128
  ""
125
129
  ];
@@ -1069,6 +1073,18 @@ var DELOREAN_TOKEN_IDS_TO_DISABLE = [
1069
1073
  "0x8045e771ecd3c409c4245a003887b90964e31b63717252cfe4cd13d86ceaa2c3",
1070
1074
  "0xbd494f677ec2361dda0fefe2ec9689f8d4c8ab585e5a39884290850e5a4e28df"
1071
1075
  ];
1076
+ var DYNAMIC_COLLECTION_IDS = [
1077
+ "67aca668-31b0-4713-91cf-079d392b041a",
1078
+ // Kumo
1079
+ "b5d64823-54b5-43ff-b58f-8b8abf08d27b",
1080
+ // Hunting Snake Legends
1081
+ "5ea655c3-b8f9-4882-9090-3c59d1635d00",
1082
+ // Fever Maniac
1083
+ "f7ccba9d-04f8-49c4-8e1f-d264b122584d",
1084
+ // SuiFrens: Capys
1085
+ "a8c93237-922f-4d6c-825f-bdcbc4bf10fc"
1086
+ // Anima Genesis Avatars
1087
+ ];
1072
1088
 
1073
1089
  // src/graphql/queries/fetchNftsById.ts
1074
1090
  import { gql as gql4 } from "graphql-request";
@@ -1277,6 +1293,12 @@ var getKioskTransferPolicies = async (nftType) => {
1277
1293
  }
1278
1294
  return transferPolicies;
1279
1295
  };
1296
+ var knownTransferPolicyRules = [
1297
+ "royalty_rule",
1298
+ "kiosk_lock_rule",
1299
+ "personal_kiosk_rule",
1300
+ "floor_price_rule"
1301
+ ];
1280
1302
 
1281
1303
  // src/helpers/hasPersonalKioskRule.ts
1282
1304
  var hasPersonalKioskRule = async (nftType) => {
@@ -1409,6 +1431,9 @@ var kioskTxWrapper = async ({
1409
1431
  await runCommands(kioskTx);
1410
1432
  return;
1411
1433
  }
1434
+ if (!kioskOwner) {
1435
+ throw new Error("No kiosk owner provided");
1436
+ }
1412
1437
  let kiosks = kioskOwnerKiosks ?? ((await gqlChainRequest({
1413
1438
  chain: "sui",
1414
1439
  query: fetchKiosksByOwner,
@@ -1454,7 +1479,10 @@ var kioskTxWrapper = async ({
1454
1479
  version: ""
1455
1480
  }
1456
1481
  });
1457
- } else if (kiosks.length > 0) {
1482
+ } else if (shouldConvertToPersonalKiosk || kiosks.length === 0) {
1483
+ kioskTx = new KioskTransaction({ transactionBlock: tx, kioskClient });
1484
+ kioskTx.createPersonal(true);
1485
+ } else {
1458
1486
  const kioskCapId = (await gqlChainRequest({
1459
1487
  chain: "sui",
1460
1488
  query: fetchOwnerCapByKiosk,
@@ -1471,9 +1499,6 @@ var kioskTxWrapper = async ({
1471
1499
  version: ""
1472
1500
  }
1473
1501
  });
1474
- } else {
1475
- kioskTx = new KioskTransaction({ transactionBlock: tx, kioskClient });
1476
- kioskTx.createPersonal(true);
1477
1502
  }
1478
1503
  await runCommands(kioskTx);
1479
1504
  kioskTx.finalize();
@@ -1965,6 +1990,31 @@ var getOBBidderKiosk = async ({
1965
1990
  return bidObject.data?.content?.fields?.kiosk;
1966
1991
  };
1967
1992
 
1993
+ // src/helpers/isSIngleBid.ts
1994
+ var isSingleBid = (bidType) => {
1995
+ if (!bidType) {
1996
+ return false;
1997
+ }
1998
+ if (!bidType.startsWith("0x")) {
1999
+ bidType = `0x${bidType}`;
2000
+ }
2001
+ return bidType === `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::SingleBid`;
2002
+ };
2003
+
2004
+ // src/methods/acceptNftBids/addAcceptNftBidTxs.ts
2005
+ import { normalizeStructTag, SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
2006
+
2007
+ // src/graphql/queries/fetchMultibidById.ts
2008
+ import { gql as gql11 } from "graphql-request";
2009
+ var fetchMultibidChainIdById = gql11`
2010
+ query fetchMultibidById($multiBidId: uuid!) {
2011
+ multi_bids(where: { id: { _eq: $multiBidId } }) {
2012
+ chain_id
2013
+ cancelled_at
2014
+ }
2015
+ }
2016
+ `;
2017
+
1968
2018
  // src/methods/acceptNftBids/addAcceptNftBidTxs.ts
1969
2019
  function addTradeportAcceptNftBidTx({
1970
2020
  tx,
@@ -2150,8 +2200,80 @@ function addBluemoveAcceptNftBidTx({
2150
2200
  typeArguments: [nftType]
2151
2201
  });
2152
2202
  }
2203
+ async function addSingleBidAcceptNftBidTx(txData) {
2204
+ const { nftType, tx, bidNonce, multiBidId, kioskClient, nftTokenId } = txData;
2205
+ const transferPolicies = await getKioskTransferPolicies(nftType);
2206
+ const transferPolicy = transferPolicies?.find(
2207
+ (policy) => policy?.rules?.length > 0
2208
+ );
2209
+ const { chain_id: multiBidChainId, cancelled_at } = multiBidId ? (await gqlChainRequest({
2210
+ chain: "sui",
2211
+ query: fetchMultibidChainIdById,
2212
+ variables: { multiBidId }
2213
+ }))?.multi_bids?.[0] ?? {} : {};
2214
+ if (multiBidChainId && cancelled_at) {
2215
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
2216
+ }
2217
+ if (transferPolicy) {
2218
+ const transferPolicies2 = await kioskClient.getTransferPolicies({
2219
+ type: normalizeStructTag(nftType)
2220
+ });
2221
+ const { rules: allRules } = transferPolicies2.find((p) => p.id === transferPolicy.id);
2222
+ const unsupportedRule = allRules.find(
2223
+ (r) => !knownTransferPolicyRules.includes(r.split("::").at(1))
2224
+ );
2225
+ if (unsupportedRule) {
2226
+ throw new Error(
2227
+ `Found unsupported transfer policy rule ${unsupportedRule} for ${transferPolicy.id} of ${nftType}`
2228
+ );
2229
+ }
2230
+ return kioskTxWrapper({
2231
+ tx: txData?.tx,
2232
+ kioskClient: txData?.kioskClient,
2233
+ kioskTx: txData?.kioskTx,
2234
+ kioskOwner: txData?.seller,
2235
+ kiosk: txData?.sellerKiosk,
2236
+ async runCommands(kioskTx) {
2237
+ const [transferRequest] = tx.moveCall({
2238
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_with_transfer_policy`,
2239
+ typeArguments: [nftType],
2240
+ arguments: [
2241
+ tx.object(SUI_CLOCK_OBJECT_ID),
2242
+ tx.object(TRADEPORT_MULTI_BID_STORE),
2243
+ tx.pure.id(bidNonce),
2244
+ tx.pure.option("id", multiBidChainId),
2245
+ tx.object(kioskTx.getKiosk()),
2246
+ tx.object(kioskTx.getKioskCap()),
2247
+ tx.pure.id(nftTokenId),
2248
+ tx.object(transferPolicy.id)
2249
+ ]
2250
+ });
2251
+ tx.moveCall({
2252
+ target: "0x2::transfer_policy::confirm_request",
2253
+ arguments: [tx.object(transferPolicy.id), transferRequest],
2254
+ typeArguments: [nftType]
2255
+ });
2256
+ }
2257
+ });
2258
+ }
2259
+ tx.moveCall({
2260
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_without_transfer_policy`,
2261
+ typeArguments: [nftType],
2262
+ arguments: [
2263
+ tx.object(SUI_CLOCK_OBJECT_ID),
2264
+ tx.object(TRADEPORT_MULTI_BID_STORE),
2265
+ tx.pure.id(bidNonce),
2266
+ tx.pure.option("id", multiBidChainId),
2267
+ tx.object(nftTokenId)
2268
+ ]
2269
+ });
2270
+ }
2153
2271
  async function addTradePortAcceptNftBidTxHandler(txData) {
2154
2272
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
2273
+ if (isSingleBid(bidType)) {
2274
+ await addSingleBidAcceptNftBidTx(txData);
2275
+ return;
2276
+ }
2155
2277
  if (isOriginByteBid(bidType)) {
2156
2278
  if (isOriginByteTx(txData?.sharedObjects)) {
2157
2279
  await addOriginByteAcceptNftBidTx(txData);
@@ -2582,6 +2704,10 @@ function addTocenAcceptCollectionBidTx({
2582
2704
  }
2583
2705
  async function addTradePortAcceptCollectionBidTxHandler(txData) {
2584
2706
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
2707
+ if (isSingleBid(bidType)) {
2708
+ await addSingleBidAcceptNftBidTx(txData);
2709
+ return;
2710
+ }
2585
2711
  if (isOriginByteBid(bidType)) {
2586
2712
  if (isOriginByteTx(txData?.sharedObjects)) {
2587
2713
  await addOriginByteAcceptCollectionBidTx(txData);
@@ -2743,6 +2869,7 @@ var acceptCollectionBid = async ({
2743
2869
  collectionId: nft?.collection_id,
2744
2870
  isListedOnBluemove: nft?.listings?.[0]?.market_name === "bluemove",
2745
2871
  bidMarketName: bid?.market_contract?.name,
2872
+ multiBidId: bid.multi_bid_id,
2746
2873
  shouldSplitRoyaltyFromUserGasCoins,
2747
2874
  beforeResolveKioskTransferRequest
2748
2875
  };
@@ -2786,8 +2913,8 @@ var acceptCollectionBid = async ({
2786
2913
  import { Transaction as Transaction3 } from "@mysten/sui/transactions";
2787
2914
 
2788
2915
  // src/graphql/queries/fetchBidsById.ts
2789
- import { gql as gql11 } from "graphql-request";
2790
- var fetchBidsById = gql11`
2916
+ import { gql as gql12 } from "graphql-request";
2917
+ var fetchBidsById = gql12`
2791
2918
  query fetchBidsById($bidIds: [uuid!]) {
2792
2919
  bids(where: { id: { _in: $bidIds } }) {
2793
2920
  nonce
@@ -2796,6 +2923,7 @@ var fetchBidsById = gql11`
2796
2923
  type
2797
2924
  receiver
2798
2925
  bidder
2926
+ multi_bid_id
2799
2927
  nft {
2800
2928
  token_id
2801
2929
  properties
@@ -2872,8 +3000,10 @@ var acceptNftBids = async ({
2872
3000
  itemOwner: bid?.nft?.owner,
2873
3001
  bidAmount: bid?.price,
2874
3002
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
3003
+ seller: bid?.nft?.owner,
2875
3004
  isListedOnBluemove: bid?.nft?.listings?.[0]?.market_name === "bluemove",
2876
3005
  bidMarketName: bid?.market_contract?.name,
3006
+ multiBidId: bid?.multi_bid_id,
2877
3007
  beforeResolveKioskTransferRequest
2878
3008
  };
2879
3009
  switch (txData.bidMarketName) {
@@ -2910,7 +3040,7 @@ var acceptNftBids = async ({
2910
3040
  import { Transaction as Transaction6 } from "@mysten/sui/transactions";
2911
3041
 
2912
3042
  // src/methods/buyLocks/buyLocks.ts
2913
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui.js/utils";
3043
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui.js/utils";
2914
3044
  import { Transaction as Transaction4 } from "@mysten/sui/transactions";
2915
3045
 
2916
3046
  // src/helpers/calculatePremium.ts
@@ -2934,8 +3064,8 @@ function calculateRoyaltyFee(transferPolicyRules, price) {
2934
3064
  }
2935
3065
 
2936
3066
  // src/graphql/queries/fetchLockById.ts
2937
- import { gql as gql12 } from "graphql-request";
2938
- var fetchLockById = gql12`
3067
+ import { gql as gql13 } from "graphql-request";
3068
+ var fetchLockById = gql13`
2939
3069
  query fetchLockById($lockId: uuid!) {
2940
3070
  locks(where: { id: { _eq: $lockId } }) {
2941
3071
  id
@@ -3053,7 +3183,7 @@ async function buyLocks({ lockIds, transaction }, context) {
3053
3183
  typeArguments: [lock.nft_type],
3054
3184
  arguments: [
3055
3185
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3056
- tx.object(SUI_CLOCK_OBJECT_ID),
3186
+ tx.object(SUI_CLOCK_OBJECT_ID2),
3057
3187
  tx.pure.id(lock.lock_id),
3058
3188
  tx.pure.u64(lock.maker_price),
3059
3189
  tx.pure.u64(marketplaceFee),
@@ -3067,7 +3197,7 @@ async function buyLocks({ lockIds, transaction }, context) {
3067
3197
  }
3068
3198
 
3069
3199
  // src/methods/exerciseLongLocks/exerciseLongLocks.ts
3070
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui.js/utils";
3200
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui.js/utils";
3071
3201
  import { Transaction as Transaction5 } from "@mysten/sui/transactions";
3072
3202
  async function exerciseLongLocks({ walletAddress, transaction, locks }, context) {
3073
3203
  const tx = transaction ?? new Transaction5();
@@ -3125,7 +3255,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
3125
3255
  typeArguments: [lock.nft_type],
3126
3256
  arguments: [
3127
3257
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3128
- tx.object(SUI_CLOCK_OBJECT_ID2),
3258
+ tx.object(SUI_CLOCK_OBJECT_ID3),
3129
3259
  tx.pure.id(lock.lock_id),
3130
3260
  tx.object(lock.chain_state.makerKioskId),
3131
3261
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
@@ -3230,12 +3360,12 @@ async function buyAndExerciseLongLocks({ walletAddress, locks, tx: existingTx },
3230
3360
  import { Transaction as Transaction9 } from "@mysten/sui/transactions";
3231
3361
 
3232
3362
  // src/methods/exerciseShortLocks/exerciseShortLocks.ts
3233
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui.js/utils";
3363
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui.js/utils";
3234
3364
  import { Transaction as Transaction8 } from "@mysten/sui/transactions";
3235
3365
 
3236
3366
  // src/graphql/queries/fetchListingsById.ts
3237
- import { gql as gql13 } from "graphql-request";
3238
- var fetchListingsById = gql13`
3367
+ import { gql as gql14 } from "graphql-request";
3368
+ var fetchListingsById = gql14`
3239
3369
  query fetchListingsById($listingIds: [uuid!]) {
3240
3370
  listings(where: { id: { _in: $listingIds } }) {
3241
3371
  seller
@@ -3280,8 +3410,8 @@ var addThirdPartyTxFee = async (tx, price) => {
3280
3410
  import { bcs as bcs2 } from "@mysten/sui/bcs";
3281
3411
 
3282
3412
  // src/graphql/queries/fetchCommissionByListingId.ts
3283
- import { gql as gql14 } from "graphql-request";
3284
- var fetchCommissionByNftContractId = gql14`
3413
+ import { gql as gql15 } from "graphql-request";
3414
+ var fetchCommissionByNftContractId = gql15`
3285
3415
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
3286
3416
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
3287
3417
  is_custodial
@@ -3939,7 +4069,7 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
3939
4069
  typeArguments: [lock.nft_type],
3940
4070
  arguments: [
3941
4071
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3942
- tx.object(SUI_CLOCK_OBJECT_ID3),
4072
+ tx.object(SUI_CLOCK_OBJECT_ID4),
3943
4073
  tx.pure.id(lock.lock_id)
3944
4074
  ]
3945
4075
  });
@@ -4020,7 +4150,7 @@ async function buyAndExerciseShortLocks({ walletAddress, locks, tx: existingTx }
4020
4150
  }
4021
4151
 
4022
4152
  // src/methods/cancelLocks/cancelLocks.ts
4023
- import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui.js/utils";
4153
+ import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5 } from "@mysten/sui.js/utils";
4024
4154
  import { Transaction as Transaction10 } from "@mysten/sui/transactions";
4025
4155
  async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context) {
4026
4156
  const tx = existingTx ?? new Transaction10();
@@ -4043,7 +4173,7 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4043
4173
  typeArguments: [lock.nft_type],
4044
4174
  arguments: [
4045
4175
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
4046
- tx.object(SUI_CLOCK_OBJECT_ID4),
4176
+ tx.object(SUI_CLOCK_OBJECT_ID5),
4047
4177
  tx.pure.id(lock.lock_id),
4048
4178
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk)
4049
4179
  ]
@@ -4058,8 +4188,8 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4058
4188
  import { Transaction as Transaction11 } from "@mysten/sui/transactions";
4059
4189
 
4060
4190
  // src/graphql/queries/fetchAccountKiosks.ts
4061
- import { gql as gql15 } from "graphql-request";
4062
- var fetchAccountKiosks = gql15`
4191
+ import { gql as gql16 } from "graphql-request";
4192
+ var fetchAccountKiosks = gql16`
4063
4193
  query fetchAccountKiosks($accountAddress: String!) {
4064
4194
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
4065
4195
  id
@@ -4505,8 +4635,8 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
4505
4635
  import { Transaction as Transaction13 } from "@mysten/sui/transactions";
4506
4636
 
4507
4637
  // src/graphql/queries/fetchActiveLockStateByNftId.ts
4508
- import { gql as gql16 } from "graphql-request";
4509
- var fetchActiveLockStateByNftId = gql16`
4638
+ import { gql as gql17 } from "graphql-request";
4639
+ var fetchActiveLockStateByNftId = gql17`
4510
4640
  query fetchActiveLockStateByNftId($nftId: uuid!) {
4511
4641
  locks(
4512
4642
  where: {
@@ -4990,8 +5120,8 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
4990
5120
  import { Transaction as Transaction16 } from "@mysten/sui/transactions";
4991
5121
 
4992
5122
  // src/graphql/queries/fetchNftsByKioskId.ts
4993
- import { gql as gql17 } from "graphql-request";
4994
- var fetchNftsByKioskId = gql17`
5123
+ import { gql as gql18 } from "graphql-request";
5124
+ var fetchNftsByKioskId = gql18`
4995
5125
  query fetchNftsByKioskId($jsonFilter: jsonb) {
4996
5126
  nfts(where: { chain_state: { _contains: $jsonFilter } }) {
4997
5127
  id
@@ -5276,8 +5406,8 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 },
5276
5406
  import { Transaction as Transaction17 } from "@mysten/sui/transactions";
5277
5407
 
5278
5408
  // src/graphql/queries/fetchCollectionsById.ts
5279
- import { gql as gql18 } from "graphql-request";
5280
- var fetchCollectionsById = gql18`
5409
+ import { gql as gql19 } from "graphql-request";
5410
+ var fetchCollectionsById = gql19`
5281
5411
  query fetchCollectionsById($collectionIds: [uuid!]) {
5282
5412
  collections(where: { id: { _in: $collectionIds } }) {
5283
5413
  id
@@ -5287,7 +5417,7 @@ var fetchCollectionsById = gql18`
5287
5417
  }
5288
5418
  }
5289
5419
  `;
5290
- var fetchCollectionsByIdWithOneNft = gql18`
5420
+ var fetchCollectionsByIdWithOneNft = gql19`
5291
5421
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
5292
5422
  collections(where: { id: { _in: $collectionIds } }) {
5293
5423
  id
@@ -5305,7 +5435,7 @@ var fetchCollectionsByIdWithOneNft = gql18`
5305
5435
  }
5306
5436
  }
5307
5437
  `;
5308
- var fetchCollectionsBySlug = gql18`
5438
+ var fetchCollectionsBySlug = gql19`
5309
5439
  query fetchCollectionsBySlug($slug: String!) {
5310
5440
  collections(where: { slug: { _eq: $slug } }) {
5311
5441
  id
@@ -5314,8 +5444,8 @@ var fetchCollectionsBySlug = gql18`
5314
5444
  `;
5315
5445
 
5316
5446
  // src/graphql/queries/fetchCollectionFloorListings.ts
5317
- import { gql as gql19 } from "graphql-request";
5318
- var fetchCollectionFloorListings = gql19`
5447
+ import { gql as gql20 } from "graphql-request";
5448
+ var fetchCollectionFloorListings = gql20`
5319
5449
  query fetchCollectionFloorListings($collectionId: uuid!) {
5320
5450
  listings(
5321
5451
  where: { collection_id: { _eq: $collectionId }, listed: { _eq: true }, nft: {} }
@@ -5339,132 +5469,7 @@ var getCollectionFloorPrice = async (collectionId) => {
5339
5469
  return res?.listings?.[0]?.price;
5340
5470
  };
5341
5471
 
5342
- // src/helpers/getTradeportBiddingContractBidAmount.ts
5343
- var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
5344
- let amount = bidAmount;
5345
- if (collectionId === "8568521c-73a3-4beb-b830-d1ff27a3f1ca") {
5346
- amount = bidAmount - bidAmount * MASC_ROYALTY_DECIMAL_PERCENT;
5347
- }
5348
- if (collectionId === "6824e1ff-477e-4810-9ba7-8d6387b68c7d") {
5349
- amount = bidAmount - bidAmount * BASC_ROYALTY_DECIMAL_PERCENT;
5350
- }
5351
- if (collectionId === "307c7e7a-be3a-43a5-ae44-37f3a37d01f9") {
5352
- amount = bidAmount - bidAmount * DSL_LEGACY_ROYALTY_DECIMAL_PERCENT;
5353
- }
5354
- return amount;
5355
- };
5356
-
5357
- // src/helpers/hasRoyaltyRule.ts
5358
- var hasRoyaltyRule = async (nftType) => {
5359
- const transferPolicies = await getKioskTransferPolicies(nftType);
5360
- return transferPolicies?.some(
5361
- (policy) => policy?.rules?.filter((rule) => rule?.type?.includes("royalty_rule"))?.length > 0
5362
- );
5363
- };
5364
-
5365
- // src/helpers/kiosk/getKioskPlaceBidCoin.ts
5366
- async function getKioskPlaceBidCoin({
5367
- tx,
5368
- suiClient,
5369
- bidder,
5370
- nftType,
5371
- bidAmount,
5372
- marketFeePrice,
5373
- royaltyRulePackageId,
5374
- royaltyRuleModule,
5375
- transferPolicyId
5376
- }) {
5377
- let coin;
5378
- if (royaltyRulePackageId && royaltyRuleModule) {
5379
- const royaltyFeeAmount = await getKioskCollectionRoyaltyFeeAmount({
5380
- tx,
5381
- suiClient,
5382
- walletAddress: bidder,
5383
- royaltyRulePackageId,
5384
- royaltyRuleModule,
5385
- transferPolicyId,
5386
- price: bidAmount,
5387
- nftType
5388
- });
5389
- const [coin1, coin2] = splitCoins({
5390
- tx,
5391
- amounts: [tx.pure.u64(bidAmount + marketFeePrice), royaltyFeeAmount]
5392
- });
5393
- coin = coin1;
5394
- if (!coin1 || !coin2) throw new Error("Coin could not be split");
5395
- tx.mergeCoins(tx.object(coin1), [tx.object(coin2)]);
5396
- } else {
5397
- const [coin1] = splitCoins({
5398
- tx,
5399
- amounts: [tx.pure.u64(bidAmount + marketFeePrice)]
5400
- });
5401
- coin = coin1;
5402
- }
5403
- return coin;
5404
- }
5405
-
5406
5472
  // src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts
5407
- function addTradePortCollectionBidTx({
5408
- tx,
5409
- collectionId,
5410
- nftType,
5411
- bidAmount
5412
- }) {
5413
- const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
5414
- const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
5415
- const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(amountToBid + marketFeePrice)] });
5416
- tx.moveCall({
5417
- target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::biddings::collection_bid",
5418
- arguments: [
5419
- tx.object(TRADEPORT_BIDDING_STORE),
5420
- tx.pure.u64(amountToBid),
5421
- tx.object(coin),
5422
- tx.pure.u64(marketFeePrice),
5423
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5424
- ],
5425
- typeArguments: [nftType]
5426
- });
5427
- destroyZeroCoin({ tx, coin });
5428
- }
5429
- async function addTradePortKioskCollectionBidTx({
5430
- tx,
5431
- suiClient,
5432
- bidder,
5433
- collectionId,
5434
- nftType,
5435
- bidAmount,
5436
- royaltyRulePackageId,
5437
- royaltyRuleModule
5438
- }) {
5439
- const transferPolicyId = (await getKioskTransferPolicies(nftType))?.at(0)?.id;
5440
- const marketFeePrice = getMarketFeePrice({
5441
- price: bidAmount,
5442
- collectionId
5443
- });
5444
- const coin = await getKioskPlaceBidCoin({
5445
- tx,
5446
- suiClient,
5447
- bidder,
5448
- nftType,
5449
- bidAmount,
5450
- marketFeePrice,
5451
- royaltyRulePackageId,
5452
- royaltyRuleModule,
5453
- transferPolicyId
5454
- });
5455
- tx.moveCall({
5456
- target: "0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_biddings::collection_bid",
5457
- arguments: [
5458
- tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
5459
- tx.pure.u64(bidAmount),
5460
- tx.object(coin),
5461
- tx.pure.u64(marketFeePrice),
5462
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5463
- ],
5464
- typeArguments: [nftType]
5465
- });
5466
- destroyZeroCoin({ tx, coin });
5467
- }
5468
5473
  async function addOriginByteCollectionBidTx({
5469
5474
  tx,
5470
5475
  collectionId,
@@ -5494,22 +5499,112 @@ async function addOriginByteCollectionBidTx({
5494
5499
  });
5495
5500
  destroyZeroCoin({ tx, coin });
5496
5501
  }
5497
- async function addTradePortPlaceCollectionBidTxHandler(txData) {
5498
- if (await hasRoyaltyRule(txData?.nftType)) {
5499
- const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
5500
- const royaltyRulePackageId = await getRulePackageId({
5501
- nftType: txData.nftType,
5502
- ruleType: getRoyaltyRuleModule(txData?.collectionId),
5503
- kioskClient: txData?.kioskClient
5504
- });
5505
- await addTradePortKioskCollectionBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
5506
- return;
5502
+
5503
+ // src/methods/placeNftBids/addPlaceNftBidTxs.ts
5504
+ import { fromHex, normalizeSuiObjectId } from "@mysten/sui/utils";
5505
+ async function addTradePortPlaceNftBidTxHandler(txData) {
5506
+ if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
5507
+ throw new Error("OriginByte bidding not supported currently");
5508
+ }
5509
+ const {
5510
+ tx,
5511
+ nftType,
5512
+ multiBidId,
5513
+ multiBidChainId: existingMultiBidChainId,
5514
+ nftTokenId,
5515
+ collectionId,
5516
+ bcsHex,
5517
+ expireAt
5518
+ } = txData;
5519
+ let bcs3;
5520
+ if (nftTokenId && isDynamicCollection(collectionId)) {
5521
+ if (!bcsHex) {
5522
+ throw new Error(`No BCS found for token ${nftTokenId}`);
5523
+ }
5524
+ bcs3 = fromHex(bcsHex);
5525
+ }
5526
+ let multiBidChainId;
5527
+ if (existingMultiBidChainId) {
5528
+ multiBidChainId = existingMultiBidChainId;
5529
+ } else {
5530
+ const { chain_id: chainId, cancelled_at } = multiBidId ? (await gqlChainRequest({
5531
+ chain: "sui",
5532
+ query: fetchMultibidChainIdById,
5533
+ variables: { multiBidId }
5534
+ }))?.multi_bids?.[0] ?? {} : {};
5535
+ if (chainId && cancelled_at) {
5536
+ throw new Error(`MultiBid ${chainId} already cancelled`);
5537
+ }
5538
+ multiBidChainId = chainId;
5539
+ }
5540
+ const transferPolicies = await getKioskTransferPolicies(nftType);
5541
+ const transferPolicy = transferPolicies?.find(
5542
+ (policy) => policy?.rules?.length > 0
5543
+ );
5544
+ const price = BigInt(txData?.bidAmount ?? 0n);
5545
+ const fee = BigInt(txData?.bidAmount ?? 0) * await getBidFeeBps(txData?.suiClient) / 10000n;
5546
+ let royalty = 0n;
5547
+ const royaltyRule = (transferPolicy?.rules ?? []).find(
5548
+ (r) => r.type.endsWith("royalty_rule")
5549
+ );
5550
+ if (royaltyRule) {
5551
+ const { amount_bp, min_amount } = royaltyRule;
5552
+ royalty = BigInt(price * BigInt(amount_bp) / 10000n);
5553
+ if (royalty < BigInt(min_amount ?? 0n)) {
5554
+ royalty = BigInt(min_amount ?? 0n);
5555
+ }
5507
5556
  }
5508
- addTradePortCollectionBidTx(txData);
5557
+ const [coin] = tx.splitCoins(tx.gas, [multiBidChainId ? 0n : price + fee + royalty]);
5558
+ tx.moveCall({
5559
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_bid_with${transferPolicy ? "" : "out"}_transfer_policy`,
5560
+ typeArguments: [nftType],
5561
+ arguments: [
5562
+ tx.object(TRADEPORT_MULTI_BID_STORE),
5563
+ tx.pure.u64(nftTokenId ? 1 : 0),
5564
+ multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", normalizeSuiObjectId(multiBidChainId)) : tx.moveCall({
5565
+ target: "0x1::option::some",
5566
+ typeArguments: ["0x2::object::ID"],
5567
+ arguments: [multiBidChainId]
5568
+ }) : void 0,
5569
+ tx.pure.option("id", nftTokenId ? normalizeSuiObjectId(nftTokenId) : void 0),
5570
+ tx.pure.option("vector<u8>", bcs3 ? [...bcs3] : void 0),
5571
+ tx.pure.option("u64", expireAt?.getTime()),
5572
+ tx.pure.u64(price),
5573
+ ...transferPolicy ? [tx.object(transferPolicy.id)] : [],
5574
+ tx.object(coin)
5575
+ ]
5576
+ });
5577
+ }
5578
+ var bidFeeBps;
5579
+ async function getBidFeeBps(suiClient) {
5580
+ if (bidFeeBps !== void 0) {
5581
+ return bidFeeBps;
5582
+ }
5583
+ const res = await suiClient.getObject({
5584
+ id: TRADEPORT_MULTI_BID_STORE,
5585
+ options: { showContent: true }
5586
+ });
5587
+ if (res.error) {
5588
+ throw new Error(`Error on getting SUI object ${TRADEPORT_MULTI_BID_STORE}: ${res.error.code}`);
5589
+ }
5590
+ bidFeeBps = BigInt(
5591
+ res?.data?.content?.fields?.fee_bps ?? 0
5592
+ );
5593
+ return bidFeeBps;
5594
+ }
5595
+ function isDynamicCollection(collectionId) {
5596
+ return DYNAMIC_COLLECTION_IDS.includes(collectionId);
5509
5597
  }
5510
5598
 
5511
5599
  // src/methods/placeCollectionBids/placeCollectionBids.ts
5512
- var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5600
+ var placeCollectionBids = async ({
5601
+ collections,
5602
+ walletAddress,
5603
+ multiBidId,
5604
+ multiBidChainId,
5605
+ expireAt,
5606
+ tx: existingTx
5607
+ }, context) => {
5513
5608
  const res = await gqlChainRequest({
5514
5609
  chain: "sui",
5515
5610
  query: fetchCollectionsByIdWithOneNft,
@@ -5518,11 +5613,8 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5518
5613
  if (res?.collections?.length === 0) {
5519
5614
  throw new Error("No collection found");
5520
5615
  }
5521
- if (res?.collections?.length === 0) {
5522
- throw new Error("No collection found");
5523
- }
5524
5616
  const collectionsForTracking = [];
5525
- const tx = new Transaction17();
5617
+ const tx = existingTx ?? new Transaction17();
5526
5618
  for (const collection of res.collections) {
5527
5619
  const nftType = getNftType({
5528
5620
  collectionId: collection?.id,
@@ -5538,7 +5630,10 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5538
5630
  bidder: walletAddress,
5539
5631
  collectionId: collection?.id,
5540
5632
  nftType,
5541
- bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist
5633
+ bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist,
5634
+ multiBidId,
5635
+ multiBidChainId,
5636
+ expireAt
5542
5637
  };
5543
5638
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
5544
5639
  if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -5554,7 +5649,7 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5554
5649
  }
5555
5650
  } else {
5556
5651
  for (let i = 0; i < numOfBids; i++) {
5557
- await addTradePortPlaceCollectionBidTxHandler(txData);
5652
+ await addTradePortPlaceNftBidTxHandler({ ...txData, bidAmount: BigInt(txData.bidAmount) });
5558
5653
  }
5559
5654
  }
5560
5655
  collectionsForTracking.push({
@@ -5569,172 +5664,8 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5569
5664
 
5570
5665
  // src/methods/placeNftBids/placeNftBids.ts
5571
5666
  import { Transaction as Transaction18 } from "@mysten/sui/transactions";
5572
-
5573
- // src/methods/placeNftBids/addPlaceNftBidTxs.ts
5574
- function addTradePortPlaceNftBidTx({
5575
- tx,
5576
- collectionId,
5577
- nftTokenId,
5578
- nftType,
5579
- bidAmount
5580
- }) {
5581
- const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
5582
- const marketFeePrice = getMarketFeePrice({ price: amountToBid, collectionId });
5583
- const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(amountToBid + marketFeePrice)] });
5584
- tx.moveCall({
5585
- target: "0x398aae1ad267d989dcc99ba449b0a30101a6b851ec1284ccddab5937df66bfcf::biddings::bid",
5586
- arguments: [
5587
- tx.object(TRADEPORT_BIDDING_STORE),
5588
- tx.pure.address(nftTokenId),
5589
- tx.pure.u64(amountToBid),
5590
- tx.object(coin),
5591
- tx.pure.u64(marketFeePrice),
5592
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5593
- ],
5594
- typeArguments: [nftType]
5595
- });
5596
- destroyZeroCoin({ tx, coin });
5597
- }
5598
- async function addTradePortKioskPlaceNftBidTx({
5599
- tx,
5600
- suiClient,
5601
- bidder,
5602
- collectionId,
5603
- nftTokenId,
5604
- nftType,
5605
- bidAmount,
5606
- royaltyRulePackageId,
5607
- royaltyRuleModule
5608
- }) {
5609
- const transferPolicyId = await getKioskTransferPolicies(nftType).then(
5610
- (policies) => policies?.[0]?.id
5611
- );
5612
- const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
5613
- const coin = await getKioskPlaceBidCoin({
5614
- tx,
5615
- suiClient,
5616
- bidder,
5617
- nftType,
5618
- bidAmount,
5619
- marketFeePrice,
5620
- royaltyRulePackageId,
5621
- royaltyRuleModule,
5622
- transferPolicyId
5623
- });
5624
- tx.moveCall({
5625
- target: "0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_biddings::bid",
5626
- arguments: [
5627
- tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
5628
- tx.pure.address(nftTokenId),
5629
- tx.pure.u64(bidAmount),
5630
- tx.object(coin),
5631
- tx.pure.u64(marketFeePrice),
5632
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5633
- ],
5634
- typeArguments: [nftType]
5635
- });
5636
- destroyZeroCoin({ tx, coin });
5637
- }
5638
- async function addKumoTradePortKioskPlaceNftBidTx({
5639
- tx,
5640
- suiClient,
5641
- bidder,
5642
- collectionId,
5643
- nftTokenId,
5644
- nftType,
5645
- bidAmount,
5646
- royaltyRulePackageId,
5647
- royaltyRuleModule
5648
- }) {
5649
- const transferPolicyId = await getKioskTransferPolicies(nftType).then(
5650
- (policies) => policies?.[0]?.id
5651
- );
5652
- const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
5653
- const coin = await getKioskPlaceBidCoin({
5654
- tx,
5655
- suiClient,
5656
- bidder,
5657
- nftType,
5658
- bidAmount,
5659
- marketFeePrice,
5660
- royaltyRulePackageId,
5661
- royaltyRuleModule,
5662
- transferPolicyId
5663
- });
5664
- const kumoAttributes = await fetchKumoNftAttributes(suiClient, nftTokenId);
5665
- const normalizedAttributes = normalizeKumoAttributes(kumoAttributes);
5666
- tx.moveCall({
5667
- target: "0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_biddings::kumo_bid",
5668
- arguments: [
5669
- tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
5670
- tx.pure.address(nftTokenId),
5671
- tx.pure.u64(bidAmount),
5672
- tx.object(coin),
5673
- tx.pure.u64(marketFeePrice),
5674
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS),
5675
- ...Object.values(normalizedAttributes).map((attr) => tx.pure.option("string", attr))
5676
- ],
5677
- typeArguments: [nftType]
5678
- });
5679
- destroyZeroCoin({ tx, coin });
5680
- }
5681
- async function addTradePortPlaceNftBidTxHandler(txData) {
5682
- if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
5683
- throw new Error("OriginByte bidding not supported currently");
5684
- }
5685
- if (await hasTransferPolicyRules(txData?.nftType) && txData?.sellerKiosk) {
5686
- const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
5687
- const royaltyRulePackageId = await getRulePackageId({
5688
- nftType: txData?.nftType,
5689
- ruleType: royaltyRuleModule,
5690
- kioskClient: txData?.kioskClient
5691
- });
5692
- if (txData?.collectionId === "67aca668-31b0-4713-91cf-079d392b041a") {
5693
- await addKumoTradePortKioskPlaceNftBidTx({
5694
- ...txData,
5695
- royaltyRulePackageId,
5696
- royaltyRuleModule
5697
- });
5698
- return;
5699
- }
5700
- await addTradePortKioskPlaceNftBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
5701
- return;
5702
- }
5703
- addTradePortPlaceNftBidTx(txData);
5704
- }
5705
- async function fetchKumoNftAttributes(suiClient, nftTokenId) {
5706
- if (!nftTokenId) {
5707
- throw new Error("NFT Token ID is required to fetch Kumo attributes");
5708
- }
5709
- let res;
5710
- try {
5711
- res = await suiClient.getObject({
5712
- id: nftTokenId,
5713
- options: { showContent: true }
5714
- });
5715
- } catch (error) {
5716
- throw new Error(
5717
- `Failed to fetch Kumo token object data: ${error instanceof Error ? error.message : "Unknown error"}`
5718
- );
5719
- }
5720
- if (!res.data) {
5721
- throw new Error(`NFT object data not found: ${nftTokenId}`);
5722
- }
5723
- if (res.data?.content?.dataType !== "moveObject") {
5724
- throw new Error("Invalid NFT Token ID - not a move object");
5725
- }
5726
- const { accessory, background, eyes, fur_colour, mouth, tail, one_of_one } = res.data?.content?.fields || {};
5727
- return { accessory, background, eyes, fur_colour, mouth, tail, one_of_one };
5728
- }
5729
- function normalizeKumoAttributes(attributes) {
5730
- const normalizeAttribute = (attr) => !attr || attr === "Default" || attr === "None" ? null : attr;
5731
- return Object.fromEntries(
5732
- Object.entries(attributes).map(([key, value]) => [key, normalizeAttribute(value)])
5733
- );
5734
- }
5735
-
5736
- // src/methods/placeNftBids/placeNftBids.ts
5737
- var placeNftBids = async ({ nfts, walletAddress }, context) => {
5667
+ var placeNftBids = async ({ nfts, walletAddress, multiBidId, multiBidChainId, expireAt, tx: existingTx }, context) => {
5668
+ const tx = existingTx ?? new Transaction18();
5738
5669
  const res = await gqlChainRequest({
5739
5670
  chain: "sui",
5740
5671
  query: fetchNftsById,
@@ -5744,7 +5675,6 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
5744
5675
  throw new Error("No nfts found");
5745
5676
  }
5746
5677
  const nftsForTracking = [];
5747
- const tx = new Transaction18();
5748
5678
  for (const nft of res.nfts) {
5749
5679
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
5750
5680
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5758,14 +5688,16 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
5758
5688
  const txData = {
5759
5689
  tx,
5760
5690
  suiClient: context.suiClient,
5761
- kioskClient: context.kioskClient,
5762
5691
  sharedObjects,
5763
5692
  bidder: walletAddress,
5764
5693
  collectionId: nft?.collection_id,
5765
5694
  nftTokenId: nft?.token_id,
5766
5695
  nftType,
5767
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
5768
- sellerKiosk: nft?.chain_state?.kiosk_id
5696
+ bidAmount: BigInt(nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist ?? 0n),
5697
+ bcsHex: nft.chain_state?.bcs?.bcsHex,
5698
+ multiBidId,
5699
+ multiBidChainId,
5700
+ expireAt
5769
5701
  };
5770
5702
  await addTradePortPlaceNftBidTxHandler(txData);
5771
5703
  nftsForTracking.push({
@@ -5825,8 +5757,27 @@ function addTocenRemoveNftBidTx({ tx, nftTokenId, bidAmount }) {
5825
5757
  typeArguments: []
5826
5758
  });
5827
5759
  }
5760
+ async function addSingleBidRemoveNftBidTx({ tx, bidNonce, multiBidId }) {
5761
+ const multiBidChainId = multiBidId ? (await gqlChainRequest({
5762
+ chain: "sui",
5763
+ query: fetchMultibidChainIdById,
5764
+ variables: { multiBidId }
5765
+ }))?.multi_bids?.[0]?.chain_id : void 0;
5766
+ tx.moveCall({
5767
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_bid`,
5768
+ arguments: [
5769
+ tx.object(TRADEPORT_MULTI_BID_STORE),
5770
+ tx.pure.id(bidNonce),
5771
+ tx.pure.option("id", multiBidChainId)
5772
+ ]
5773
+ });
5774
+ }
5828
5775
  async function addTradePortRemoveNftBidTxHandler(txData) {
5829
5776
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
5777
+ if (isSingleBid(bidType)) {
5778
+ await addSingleBidRemoveNftBidTx(txData);
5779
+ return;
5780
+ }
5830
5781
  if (isOriginByteBid(bidType)) {
5831
5782
  addOriginByteRemoveNftBidTx(txData);
5832
5783
  return;
@@ -5909,6 +5860,10 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
5909
5860
  }
5910
5861
  async function addBluemoveRemoveCollectionBidTxHandler(txData) {
5911
5862
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
5863
+ if (isSingleBid(bidType)) {
5864
+ await addSingleBidRemoveNftBidTx(txData);
5865
+ return;
5866
+ }
5912
5867
  if (isOriginByteBid(bidType)) {
5913
5868
  const sharedObjects = await getSharedObjects(txData?.nftType);
5914
5869
  addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
@@ -6016,7 +5971,8 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6016
5971
  nftTokenId: bid?.nft?.token_id,
6017
5972
  bidAmount: bid?.price,
6018
5973
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
6019
- bidMarketName: bid?.market_contract?.name
5974
+ bidMarketName: bid?.market_contract?.name,
5975
+ multiBidId: bid?.multi_bid_id
6020
5976
  };
6021
5977
  switch (txData.bidMarketName) {
6022
5978
  case "tradeport":
@@ -6292,6 +6248,94 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6292
6248
  return Transaction23.from(tx);
6293
6249
  }
6294
6250
 
6251
+ // src/methods/createMultiBid/createMultiBid.ts
6252
+ import { Transaction as Transaction25 } from "@mysten/sui/transactions";
6253
+
6254
+ // src/methods/updateMultiBid/updateMultiBid.ts
6255
+ import { Transaction as Transaction24 } from "@mysten/sui/transactions";
6256
+ async function updateMultiBid({
6257
+ multiBidId,
6258
+ name,
6259
+ amount,
6260
+ amountToWithdraw,
6261
+ tx: existingTx,
6262
+ multiBidChainId
6263
+ }) {
6264
+ const tx = existingTx ?? new Transaction24();
6265
+ if (!multiBidChainId) {
6266
+ const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
6267
+ chain: "sui",
6268
+ query: fetchMultibidChainIdById,
6269
+ variables: { multiBidId }
6270
+ }))?.multi_bids?.[0] ?? {};
6271
+ if (!chainId) {
6272
+ throw new Error(`MultiBid ${multiBidId} not found`);
6273
+ }
6274
+ if (cancelled_at) {
6275
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
6276
+ }
6277
+ multiBidChainId = chainId;
6278
+ }
6279
+ const [coin] = tx.splitCoins(tx.gas, [amount ?? 0n]);
6280
+ tx.moveCall({
6281
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
6282
+ arguments: [
6283
+ tx.object(TRADEPORT_MULTI_BID_STORE),
6284
+ typeof multiBidChainId === "string" ? tx.pure.id(multiBidChainId) : multiBidChainId,
6285
+ tx.pure.option("string", name),
6286
+ coin,
6287
+ tx.pure.option("u64", amountToWithdraw)
6288
+ ]
6289
+ });
6290
+ return tx;
6291
+ }
6292
+
6293
+ // src/methods/createMultiBid/createMultiBid.ts
6294
+ async function createMultiBid({
6295
+ walletAddress,
6296
+ name,
6297
+ amount,
6298
+ tx: existingTx
6299
+ }) {
6300
+ const tx = existingTx ?? new Transaction25();
6301
+ const multiBidChainId = tx.moveCall({
6302
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
6303
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
6304
+ });
6305
+ if (amount > 0n) {
6306
+ await updateMultiBid({
6307
+ walletAddress,
6308
+ multiBidChainId,
6309
+ amount,
6310
+ name,
6311
+ tx
6312
+ });
6313
+ }
6314
+ return { multiBidChainId, tx };
6315
+ }
6316
+
6317
+ // src/methods/cancelMultiBid/cancelMultiBid.ts
6318
+ import { Transaction as Transaction26 } from "@mysten/sui/transactions";
6319
+ async function cancelMultiBid({ multiBidId }) {
6320
+ const { chain_id: multiBidChainId, cancelled_at } = (await gqlChainRequest({
6321
+ chain: "sui",
6322
+ query: fetchMultibidChainIdById,
6323
+ variables: { multiBidId }
6324
+ }))?.multi_bids?.[0] ?? {};
6325
+ if (!multiBidChainId) {
6326
+ throw new Error(`MultiBid ${multiBidId} not found`);
6327
+ }
6328
+ if (cancelled_at) {
6329
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
6330
+ }
6331
+ const tx = new Transaction26();
6332
+ tx.moveCall({
6333
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_multi_bid`,
6334
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.id(multiBidChainId)]
6335
+ });
6336
+ return tx;
6337
+ }
6338
+
6295
6339
  // src/SuiTradingClient.ts
6296
6340
  var SuiTradingClient = class {
6297
6341
  constructor({ apiUser, apiKey, suiNodeUrl, graphQLClient }) {
@@ -6335,14 +6379,14 @@ var SuiTradingClient = class {
6335
6379
  };
6336
6380
  return unlistListings({ listingIds, walletAddress }, context);
6337
6381
  }
6338
- async placeNftBids({ nfts, walletAddress }) {
6382
+ async placeNftBids(data) {
6339
6383
  const context = {
6340
6384
  apiUser: this.apiUser,
6341
6385
  apiKey: this.apiKey,
6342
6386
  suiClient: this.suiClient,
6343
6387
  kioskClient: this.kioskClient
6344
6388
  };
6345
- return placeNftBids({ nfts, walletAddress }, context);
6389
+ return placeNftBids(data, context);
6346
6390
  }
6347
6391
  async removeNftBids({ bidIds, tx }) {
6348
6392
  const context = {
@@ -6366,7 +6410,10 @@ var SuiTradingClient = class {
6366
6410
  collectionId,
6367
6411
  bidAmountInMist,
6368
6412
  numOfBids,
6369
- walletAddress
6413
+ walletAddress,
6414
+ multiBidId,
6415
+ multiBidChainId,
6416
+ expireAt
6370
6417
  }) {
6371
6418
  const context = {
6372
6419
  apiUser: this.apiUser,
@@ -6383,7 +6430,10 @@ var SuiTradingClient = class {
6383
6430
  numOfBids
6384
6431
  }
6385
6432
  ],
6386
- walletAddress
6433
+ walletAddress,
6434
+ multiBidId,
6435
+ multiBidChainId,
6436
+ expireAt
6387
6437
  },
6388
6438
  context
6389
6439
  );
@@ -6608,6 +6658,15 @@ var SuiTradingClient = class {
6608
6658
  };
6609
6659
  return migrateNftsFromUnsharedToSharedKiosks(args, context);
6610
6660
  }
6661
+ async createMultiBid(args) {
6662
+ return createMultiBid(args);
6663
+ }
6664
+ async cancelMultiBid(args) {
6665
+ return cancelMultiBid(args);
6666
+ }
6667
+ async updateMultiBid(args) {
6668
+ return updateMultiBid(args);
6669
+ }
6611
6670
  };
6612
6671
  var SuiTradingClient_default = SuiTradingClient;
6613
6672
  export {