@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.js CHANGED
@@ -90,6 +90,7 @@ var fetchCollectionBidsById = import_graphql_request3.gql`
90
90
  status
91
91
  type
92
92
  collection_id
93
+ multi_bid_id
93
94
  contract {
94
95
  properties
95
96
  }
@@ -119,6 +120,7 @@ var fetchCollectionBidsAtSamePrice = import_graphql_request4.gql`
119
120
  status
120
121
  type
121
122
  collection_id
123
+ multi_bid_id
122
124
  contract {
123
125
  properties
124
126
  }
@@ -146,6 +148,8 @@ var TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK = "0x151fbe627d3f8de855f424c879ea2176d8
146
148
  var TRADEPORT_KIOSK_BID_NONCE_TYPE = "0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Bid";
147
149
  var TRADEPORT_PRICE_LOCK_PACKAGE = "0x3cb532a2548290780a3d70ad6f4f06abc5bebb75ec6f8dd0197d4d2b2860c5d8";
148
150
  var TRADEPORT_PRICE_LOCK_STORE = "0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0c9e03cac5729c0c47946";
151
+ var TRADEPORT_MULTI_BID_PACKAGE = "0xb32c899d9fb0d79a7e384bfbf2830a19ee26ccf51d6cadaaf1a14c4a2817886a";
152
+ var TRADEPORT_MULTI_BID_STORE = "0x2617658a6b03dcf6df2df4d256341bc4690d3a3d299c9552ca6ac9799ceb0ed7";
149
153
  var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
150
154
  ""
151
155
  ];
@@ -1095,6 +1099,18 @@ var DELOREAN_TOKEN_IDS_TO_DISABLE = [
1095
1099
  "0x8045e771ecd3c409c4245a003887b90964e31b63717252cfe4cd13d86ceaa2c3",
1096
1100
  "0xbd494f677ec2361dda0fefe2ec9689f8d4c8ab585e5a39884290850e5a4e28df"
1097
1101
  ];
1102
+ var DYNAMIC_COLLECTION_IDS = [
1103
+ "67aca668-31b0-4713-91cf-079d392b041a",
1104
+ // Kumo
1105
+ "b5d64823-54b5-43ff-b58f-8b8abf08d27b",
1106
+ // Hunting Snake Legends
1107
+ "5ea655c3-b8f9-4882-9090-3c59d1635d00",
1108
+ // Fever Maniac
1109
+ "f7ccba9d-04f8-49c4-8e1f-d264b122584d",
1110
+ // SuiFrens: Capys
1111
+ "a8c93237-922f-4d6c-825f-bdcbc4bf10fc"
1112
+ // Anima Genesis Avatars
1113
+ ];
1098
1114
 
1099
1115
  // src/graphql/queries/fetchNftsById.ts
1100
1116
  var import_graphql_request5 = require("graphql-request");
@@ -1303,6 +1319,12 @@ var getKioskTransferPolicies = async (nftType) => {
1303
1319
  }
1304
1320
  return transferPolicies;
1305
1321
  };
1322
+ var knownTransferPolicyRules = [
1323
+ "royalty_rule",
1324
+ "kiosk_lock_rule",
1325
+ "personal_kiosk_rule",
1326
+ "floor_price_rule"
1327
+ ];
1306
1328
 
1307
1329
  // src/helpers/hasPersonalKioskRule.ts
1308
1330
  var hasPersonalKioskRule = async (nftType) => {
@@ -1435,6 +1457,9 @@ var kioskTxWrapper = async ({
1435
1457
  await runCommands(kioskTx);
1436
1458
  return;
1437
1459
  }
1460
+ if (!kioskOwner) {
1461
+ throw new Error("No kiosk owner provided");
1462
+ }
1438
1463
  let kiosks = kioskOwnerKiosks ?? ((await gqlChainRequest({
1439
1464
  chain: "sui",
1440
1465
  query: fetchKiosksByOwner,
@@ -1480,7 +1505,10 @@ var kioskTxWrapper = async ({
1480
1505
  version: ""
1481
1506
  }
1482
1507
  });
1483
- } else if (kiosks.length > 0) {
1508
+ } else if (shouldConvertToPersonalKiosk || kiosks.length === 0) {
1509
+ kioskTx = new import_kiosk3.KioskTransaction({ transactionBlock: tx, kioskClient });
1510
+ kioskTx.createPersonal(true);
1511
+ } else {
1484
1512
  const kioskCapId = (await gqlChainRequest({
1485
1513
  chain: "sui",
1486
1514
  query: fetchOwnerCapByKiosk,
@@ -1497,9 +1525,6 @@ var kioskTxWrapper = async ({
1497
1525
  version: ""
1498
1526
  }
1499
1527
  });
1500
- } else {
1501
- kioskTx = new import_kiosk3.KioskTransaction({ transactionBlock: tx, kioskClient });
1502
- kioskTx.createPersonal(true);
1503
1528
  }
1504
1529
  await runCommands(kioskTx);
1505
1530
  kioskTx.finalize();
@@ -1989,6 +2014,31 @@ var getOBBidderKiosk = async ({
1989
2014
  return bidObject.data?.content?.fields?.kiosk;
1990
2015
  };
1991
2016
 
2017
+ // src/helpers/isSIngleBid.ts
2018
+ var isSingleBid = (bidType) => {
2019
+ if (!bidType) {
2020
+ return false;
2021
+ }
2022
+ if (!bidType.startsWith("0x")) {
2023
+ bidType = `0x${bidType}`;
2024
+ }
2025
+ return bidType === `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::SingleBid`;
2026
+ };
2027
+
2028
+ // src/methods/acceptNftBids/addAcceptNftBidTxs.ts
2029
+ var import_utils2 = require("@mysten/sui/utils");
2030
+
2031
+ // src/graphql/queries/fetchMultibidById.ts
2032
+ var import_graphql_request12 = require("graphql-request");
2033
+ var fetchMultibidChainIdById = import_graphql_request12.gql`
2034
+ query fetchMultibidById($multiBidId: uuid!) {
2035
+ multi_bids(where: { id: { _eq: $multiBidId } }) {
2036
+ chain_id
2037
+ cancelled_at
2038
+ }
2039
+ }
2040
+ `;
2041
+
1992
2042
  // src/methods/acceptNftBids/addAcceptNftBidTxs.ts
1993
2043
  function addTradeportAcceptNftBidTx({
1994
2044
  tx,
@@ -2174,8 +2224,80 @@ function addBluemoveAcceptNftBidTx({
2174
2224
  typeArguments: [nftType]
2175
2225
  });
2176
2226
  }
2227
+ async function addSingleBidAcceptNftBidTx(txData) {
2228
+ const { nftType, tx, bidNonce, multiBidId, kioskClient, nftTokenId } = txData;
2229
+ const transferPolicies = await getKioskTransferPolicies(nftType);
2230
+ const transferPolicy = transferPolicies?.find(
2231
+ (policy) => policy?.rules?.length > 0
2232
+ );
2233
+ const { chain_id: multiBidChainId, cancelled_at } = multiBidId ? (await gqlChainRequest({
2234
+ chain: "sui",
2235
+ query: fetchMultibidChainIdById,
2236
+ variables: { multiBidId }
2237
+ }))?.multi_bids?.[0] ?? {} : {};
2238
+ if (multiBidChainId && cancelled_at) {
2239
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
2240
+ }
2241
+ if (transferPolicy) {
2242
+ const transferPolicies2 = await kioskClient.getTransferPolicies({
2243
+ type: (0, import_utils2.normalizeStructTag)(nftType)
2244
+ });
2245
+ const { rules: allRules } = transferPolicies2.find((p) => p.id === transferPolicy.id);
2246
+ const unsupportedRule = allRules.find(
2247
+ (r) => !knownTransferPolicyRules.includes(r.split("::").at(1))
2248
+ );
2249
+ if (unsupportedRule) {
2250
+ throw new Error(
2251
+ `Found unsupported transfer policy rule ${unsupportedRule} for ${transferPolicy.id} of ${nftType}`
2252
+ );
2253
+ }
2254
+ return kioskTxWrapper({
2255
+ tx: txData?.tx,
2256
+ kioskClient: txData?.kioskClient,
2257
+ kioskTx: txData?.kioskTx,
2258
+ kioskOwner: txData?.seller,
2259
+ kiosk: txData?.sellerKiosk,
2260
+ async runCommands(kioskTx) {
2261
+ const [transferRequest] = tx.moveCall({
2262
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_with_transfer_policy`,
2263
+ typeArguments: [nftType],
2264
+ arguments: [
2265
+ tx.object(import_utils2.SUI_CLOCK_OBJECT_ID),
2266
+ tx.object(TRADEPORT_MULTI_BID_STORE),
2267
+ tx.pure.id(bidNonce),
2268
+ tx.pure.option("id", multiBidChainId),
2269
+ tx.object(kioskTx.getKiosk()),
2270
+ tx.object(kioskTx.getKioskCap()),
2271
+ tx.pure.id(nftTokenId),
2272
+ tx.object(transferPolicy.id)
2273
+ ]
2274
+ });
2275
+ tx.moveCall({
2276
+ target: "0x2::transfer_policy::confirm_request",
2277
+ arguments: [tx.object(transferPolicy.id), transferRequest],
2278
+ typeArguments: [nftType]
2279
+ });
2280
+ }
2281
+ });
2282
+ }
2283
+ tx.moveCall({
2284
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_without_transfer_policy`,
2285
+ typeArguments: [nftType],
2286
+ arguments: [
2287
+ tx.object(import_utils2.SUI_CLOCK_OBJECT_ID),
2288
+ tx.object(TRADEPORT_MULTI_BID_STORE),
2289
+ tx.pure.id(bidNonce),
2290
+ tx.pure.option("id", multiBidChainId),
2291
+ tx.object(nftTokenId)
2292
+ ]
2293
+ });
2294
+ }
2177
2295
  async function addTradePortAcceptNftBidTxHandler(txData) {
2178
2296
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
2297
+ if (isSingleBid(bidType)) {
2298
+ await addSingleBidAcceptNftBidTx(txData);
2299
+ return;
2300
+ }
2179
2301
  if (isOriginByteBid(bidType)) {
2180
2302
  if (isOriginByteTx(txData?.sharedObjects)) {
2181
2303
  await addOriginByteAcceptNftBidTx(txData);
@@ -2606,6 +2728,10 @@ function addTocenAcceptCollectionBidTx({
2606
2728
  }
2607
2729
  async function addTradePortAcceptCollectionBidTxHandler(txData) {
2608
2730
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
2731
+ if (isSingleBid(bidType)) {
2732
+ await addSingleBidAcceptNftBidTx(txData);
2733
+ return;
2734
+ }
2609
2735
  if (isOriginByteBid(bidType)) {
2610
2736
  if (isOriginByteTx(txData?.sharedObjects)) {
2611
2737
  await addOriginByteAcceptCollectionBidTx(txData);
@@ -2767,6 +2893,7 @@ var acceptCollectionBid = async ({
2767
2893
  collectionId: nft?.collection_id,
2768
2894
  isListedOnBluemove: nft?.listings?.[0]?.market_name === "bluemove",
2769
2895
  bidMarketName: bid?.market_contract?.name,
2896
+ multiBidId: bid.multi_bid_id,
2770
2897
  shouldSplitRoyaltyFromUserGasCoins,
2771
2898
  beforeResolveKioskTransferRequest
2772
2899
  };
@@ -2810,8 +2937,8 @@ var acceptCollectionBid = async ({
2810
2937
  var import_transactions3 = require("@mysten/sui/transactions");
2811
2938
 
2812
2939
  // src/graphql/queries/fetchBidsById.ts
2813
- var import_graphql_request12 = require("graphql-request");
2814
- var fetchBidsById = import_graphql_request12.gql`
2940
+ var import_graphql_request13 = require("graphql-request");
2941
+ var fetchBidsById = import_graphql_request13.gql`
2815
2942
  query fetchBidsById($bidIds: [uuid!]) {
2816
2943
  bids(where: { id: { _in: $bidIds } }) {
2817
2944
  nonce
@@ -2820,6 +2947,7 @@ var fetchBidsById = import_graphql_request12.gql`
2820
2947
  type
2821
2948
  receiver
2822
2949
  bidder
2950
+ multi_bid_id
2823
2951
  nft {
2824
2952
  token_id
2825
2953
  properties
@@ -2896,8 +3024,10 @@ var acceptNftBids = async ({
2896
3024
  itemOwner: bid?.nft?.owner,
2897
3025
  bidAmount: bid?.price,
2898
3026
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
3027
+ seller: bid?.nft?.owner,
2899
3028
  isListedOnBluemove: bid?.nft?.listings?.[0]?.market_name === "bluemove",
2900
3029
  bidMarketName: bid?.market_contract?.name,
3030
+ multiBidId: bid?.multi_bid_id,
2901
3031
  beforeResolveKioskTransferRequest
2902
3032
  };
2903
3033
  switch (txData.bidMarketName) {
@@ -2934,7 +3064,7 @@ var acceptNftBids = async ({
2934
3064
  var import_transactions6 = require("@mysten/sui/transactions");
2935
3065
 
2936
3066
  // src/methods/buyLocks/buyLocks.ts
2937
- var import_utils2 = require("@mysten/sui.js/utils");
3067
+ var import_utils3 = require("@mysten/sui.js/utils");
2938
3068
  var import_transactions4 = require("@mysten/sui/transactions");
2939
3069
 
2940
3070
  // src/helpers/calculatePremium.ts
@@ -2958,8 +3088,8 @@ function calculateRoyaltyFee(transferPolicyRules, price) {
2958
3088
  }
2959
3089
 
2960
3090
  // src/graphql/queries/fetchLockById.ts
2961
- var import_graphql_request13 = require("graphql-request");
2962
- var fetchLockById = import_graphql_request13.gql`
3091
+ var import_graphql_request14 = require("graphql-request");
3092
+ var fetchLockById = import_graphql_request14.gql`
2963
3093
  query fetchLockById($lockId: uuid!) {
2964
3094
  locks(where: { id: { _eq: $lockId } }) {
2965
3095
  id
@@ -3077,7 +3207,7 @@ async function buyLocks({ lockIds, transaction }, context) {
3077
3207
  typeArguments: [lock.nft_type],
3078
3208
  arguments: [
3079
3209
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3080
- tx.object(import_utils2.SUI_CLOCK_OBJECT_ID),
3210
+ tx.object(import_utils3.SUI_CLOCK_OBJECT_ID),
3081
3211
  tx.pure.id(lock.lock_id),
3082
3212
  tx.pure.u64(lock.maker_price),
3083
3213
  tx.pure.u64(marketplaceFee),
@@ -3091,7 +3221,7 @@ async function buyLocks({ lockIds, transaction }, context) {
3091
3221
  }
3092
3222
 
3093
3223
  // src/methods/exerciseLongLocks/exerciseLongLocks.ts
3094
- var import_utils3 = require("@mysten/sui.js/utils");
3224
+ var import_utils4 = require("@mysten/sui.js/utils");
3095
3225
  var import_transactions5 = require("@mysten/sui/transactions");
3096
3226
  async function exerciseLongLocks({ walletAddress, transaction, locks }, context) {
3097
3227
  const tx = transaction ?? new import_transactions5.Transaction();
@@ -3149,7 +3279,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
3149
3279
  typeArguments: [lock.nft_type],
3150
3280
  arguments: [
3151
3281
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3152
- tx.object(import_utils3.SUI_CLOCK_OBJECT_ID),
3282
+ tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
3153
3283
  tx.pure.id(lock.lock_id),
3154
3284
  tx.object(lock.chain_state.makerKioskId),
3155
3285
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
@@ -3254,12 +3384,12 @@ async function buyAndExerciseLongLocks({ walletAddress, locks, tx: existingTx },
3254
3384
  var import_transactions9 = require("@mysten/sui/transactions");
3255
3385
 
3256
3386
  // src/methods/exerciseShortLocks/exerciseShortLocks.ts
3257
- var import_utils4 = require("@mysten/sui.js/utils");
3387
+ var import_utils5 = require("@mysten/sui.js/utils");
3258
3388
  var import_transactions8 = require("@mysten/sui/transactions");
3259
3389
 
3260
3390
  // src/graphql/queries/fetchListingsById.ts
3261
- var import_graphql_request14 = require("graphql-request");
3262
- var fetchListingsById = import_graphql_request14.gql`
3391
+ var import_graphql_request15 = require("graphql-request");
3392
+ var fetchListingsById = import_graphql_request15.gql`
3263
3393
  query fetchListingsById($listingIds: [uuid!]) {
3264
3394
  listings(where: { id: { _in: $listingIds } }) {
3265
3395
  seller
@@ -3304,8 +3434,8 @@ var addThirdPartyTxFee = async (tx, price) => {
3304
3434
  var import_bcs2 = require("@mysten/sui/bcs");
3305
3435
 
3306
3436
  // src/graphql/queries/fetchCommissionByListingId.ts
3307
- var import_graphql_request15 = require("graphql-request");
3308
- var fetchCommissionByNftContractId = import_graphql_request15.gql`
3437
+ var import_graphql_request16 = require("graphql-request");
3438
+ var fetchCommissionByNftContractId = import_graphql_request16.gql`
3309
3439
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
3310
3440
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
3311
3441
  is_custodial
@@ -3963,7 +4093,7 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
3963
4093
  typeArguments: [lock.nft_type],
3964
4094
  arguments: [
3965
4095
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
3966
- tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
4096
+ tx.object(import_utils5.SUI_CLOCK_OBJECT_ID),
3967
4097
  tx.pure.id(lock.lock_id)
3968
4098
  ]
3969
4099
  });
@@ -4044,7 +4174,7 @@ async function buyAndExerciseShortLocks({ walletAddress, locks, tx: existingTx }
4044
4174
  }
4045
4175
 
4046
4176
  // src/methods/cancelLocks/cancelLocks.ts
4047
- var import_utils5 = require("@mysten/sui.js/utils");
4177
+ var import_utils6 = require("@mysten/sui.js/utils");
4048
4178
  var import_transactions10 = require("@mysten/sui/transactions");
4049
4179
  async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context) {
4050
4180
  const tx = existingTx ?? new import_transactions10.Transaction();
@@ -4067,7 +4197,7 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4067
4197
  typeArguments: [lock.nft_type],
4068
4198
  arguments: [
4069
4199
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
4070
- tx.object(import_utils5.SUI_CLOCK_OBJECT_ID),
4200
+ tx.object(import_utils6.SUI_CLOCK_OBJECT_ID),
4071
4201
  tx.pure.id(lock.lock_id),
4072
4202
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk)
4073
4203
  ]
@@ -4082,8 +4212,8 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4082
4212
  var import_transactions11 = require("@mysten/sui/transactions");
4083
4213
 
4084
4214
  // src/graphql/queries/fetchAccountKiosks.ts
4085
- var import_graphql_request16 = require("graphql-request");
4086
- var fetchAccountKiosks = import_graphql_request16.gql`
4215
+ var import_graphql_request17 = require("graphql-request");
4216
+ var fetchAccountKiosks = import_graphql_request17.gql`
4087
4217
  query fetchAccountKiosks($accountAddress: String!) {
4088
4218
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
4089
4219
  id
@@ -4529,8 +4659,8 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
4529
4659
  var import_transactions13 = require("@mysten/sui/transactions");
4530
4660
 
4531
4661
  // src/graphql/queries/fetchActiveLockStateByNftId.ts
4532
- var import_graphql_request17 = require("graphql-request");
4533
- var fetchActiveLockStateByNftId = import_graphql_request17.gql`
4662
+ var import_graphql_request18 = require("graphql-request");
4663
+ var fetchActiveLockStateByNftId = import_graphql_request18.gql`
4534
4664
  query fetchActiveLockStateByNftId($nftId: uuid!) {
4535
4665
  locks(
4536
4666
  where: {
@@ -5014,8 +5144,8 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5014
5144
  var import_transactions16 = require("@mysten/sui/transactions");
5015
5145
 
5016
5146
  // src/graphql/queries/fetchNftsByKioskId.ts
5017
- var import_graphql_request18 = require("graphql-request");
5018
- var fetchNftsByKioskId = import_graphql_request18.gql`
5147
+ var import_graphql_request19 = require("graphql-request");
5148
+ var fetchNftsByKioskId = import_graphql_request19.gql`
5019
5149
  query fetchNftsByKioskId($jsonFilter: jsonb) {
5020
5150
  nfts(where: { chain_state: { _contains: $jsonFilter } }) {
5021
5151
  id
@@ -5300,8 +5430,8 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 },
5300
5430
  var import_transactions17 = require("@mysten/sui/transactions");
5301
5431
 
5302
5432
  // src/graphql/queries/fetchCollectionsById.ts
5303
- var import_graphql_request19 = require("graphql-request");
5304
- var fetchCollectionsById = import_graphql_request19.gql`
5433
+ var import_graphql_request20 = require("graphql-request");
5434
+ var fetchCollectionsById = import_graphql_request20.gql`
5305
5435
  query fetchCollectionsById($collectionIds: [uuid!]) {
5306
5436
  collections(where: { id: { _in: $collectionIds } }) {
5307
5437
  id
@@ -5311,7 +5441,7 @@ var fetchCollectionsById = import_graphql_request19.gql`
5311
5441
  }
5312
5442
  }
5313
5443
  `;
5314
- var fetchCollectionsByIdWithOneNft = import_graphql_request19.gql`
5444
+ var fetchCollectionsByIdWithOneNft = import_graphql_request20.gql`
5315
5445
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
5316
5446
  collections(where: { id: { _in: $collectionIds } }) {
5317
5447
  id
@@ -5329,7 +5459,7 @@ var fetchCollectionsByIdWithOneNft = import_graphql_request19.gql`
5329
5459
  }
5330
5460
  }
5331
5461
  `;
5332
- var fetchCollectionsBySlug = import_graphql_request19.gql`
5462
+ var fetchCollectionsBySlug = import_graphql_request20.gql`
5333
5463
  query fetchCollectionsBySlug($slug: String!) {
5334
5464
  collections(where: { slug: { _eq: $slug } }) {
5335
5465
  id
@@ -5338,8 +5468,8 @@ var fetchCollectionsBySlug = import_graphql_request19.gql`
5338
5468
  `;
5339
5469
 
5340
5470
  // src/graphql/queries/fetchCollectionFloorListings.ts
5341
- var import_graphql_request20 = require("graphql-request");
5342
- var fetchCollectionFloorListings = import_graphql_request20.gql`
5471
+ var import_graphql_request21 = require("graphql-request");
5472
+ var fetchCollectionFloorListings = import_graphql_request21.gql`
5343
5473
  query fetchCollectionFloorListings($collectionId: uuid!) {
5344
5474
  listings(
5345
5475
  where: { collection_id: { _eq: $collectionId }, listed: { _eq: true }, nft: {} }
@@ -5363,132 +5493,7 @@ var getCollectionFloorPrice = async (collectionId) => {
5363
5493
  return res?.listings?.[0]?.price;
5364
5494
  };
5365
5495
 
5366
- // src/helpers/getTradeportBiddingContractBidAmount.ts
5367
- var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
5368
- let amount = bidAmount;
5369
- if (collectionId === "8568521c-73a3-4beb-b830-d1ff27a3f1ca") {
5370
- amount = bidAmount - bidAmount * MASC_ROYALTY_DECIMAL_PERCENT;
5371
- }
5372
- if (collectionId === "6824e1ff-477e-4810-9ba7-8d6387b68c7d") {
5373
- amount = bidAmount - bidAmount * BASC_ROYALTY_DECIMAL_PERCENT;
5374
- }
5375
- if (collectionId === "307c7e7a-be3a-43a5-ae44-37f3a37d01f9") {
5376
- amount = bidAmount - bidAmount * DSL_LEGACY_ROYALTY_DECIMAL_PERCENT;
5377
- }
5378
- return amount;
5379
- };
5380
-
5381
- // src/helpers/hasRoyaltyRule.ts
5382
- var hasRoyaltyRule = async (nftType) => {
5383
- const transferPolicies = await getKioskTransferPolicies(nftType);
5384
- return transferPolicies?.some(
5385
- (policy) => policy?.rules?.filter((rule) => rule?.type?.includes("royalty_rule"))?.length > 0
5386
- );
5387
- };
5388
-
5389
- // src/helpers/kiosk/getKioskPlaceBidCoin.ts
5390
- async function getKioskPlaceBidCoin({
5391
- tx,
5392
- suiClient,
5393
- bidder,
5394
- nftType,
5395
- bidAmount,
5396
- marketFeePrice,
5397
- royaltyRulePackageId,
5398
- royaltyRuleModule,
5399
- transferPolicyId
5400
- }) {
5401
- let coin;
5402
- if (royaltyRulePackageId && royaltyRuleModule) {
5403
- const royaltyFeeAmount = await getKioskCollectionRoyaltyFeeAmount({
5404
- tx,
5405
- suiClient,
5406
- walletAddress: bidder,
5407
- royaltyRulePackageId,
5408
- royaltyRuleModule,
5409
- transferPolicyId,
5410
- price: bidAmount,
5411
- nftType
5412
- });
5413
- const [coin1, coin2] = splitCoins({
5414
- tx,
5415
- amounts: [tx.pure.u64(bidAmount + marketFeePrice), royaltyFeeAmount]
5416
- });
5417
- coin = coin1;
5418
- if (!coin1 || !coin2) throw new Error("Coin could not be split");
5419
- tx.mergeCoins(tx.object(coin1), [tx.object(coin2)]);
5420
- } else {
5421
- const [coin1] = splitCoins({
5422
- tx,
5423
- amounts: [tx.pure.u64(bidAmount + marketFeePrice)]
5424
- });
5425
- coin = coin1;
5426
- }
5427
- return coin;
5428
- }
5429
-
5430
5496
  // src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts
5431
- function addTradePortCollectionBidTx({
5432
- tx,
5433
- collectionId,
5434
- nftType,
5435
- bidAmount
5436
- }) {
5437
- const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
5438
- const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
5439
- const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(amountToBid + marketFeePrice)] });
5440
- tx.moveCall({
5441
- target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::biddings::collection_bid",
5442
- arguments: [
5443
- tx.object(TRADEPORT_BIDDING_STORE),
5444
- tx.pure.u64(amountToBid),
5445
- tx.object(coin),
5446
- tx.pure.u64(marketFeePrice),
5447
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5448
- ],
5449
- typeArguments: [nftType]
5450
- });
5451
- destroyZeroCoin({ tx, coin });
5452
- }
5453
- async function addTradePortKioskCollectionBidTx({
5454
- tx,
5455
- suiClient,
5456
- bidder,
5457
- collectionId,
5458
- nftType,
5459
- bidAmount,
5460
- royaltyRulePackageId,
5461
- royaltyRuleModule
5462
- }) {
5463
- const transferPolicyId = (await getKioskTransferPolicies(nftType))?.at(0)?.id;
5464
- const marketFeePrice = getMarketFeePrice({
5465
- price: bidAmount,
5466
- collectionId
5467
- });
5468
- const coin = await getKioskPlaceBidCoin({
5469
- tx,
5470
- suiClient,
5471
- bidder,
5472
- nftType,
5473
- bidAmount,
5474
- marketFeePrice,
5475
- royaltyRulePackageId,
5476
- royaltyRuleModule,
5477
- transferPolicyId
5478
- });
5479
- tx.moveCall({
5480
- target: "0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_biddings::collection_bid",
5481
- arguments: [
5482
- tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
5483
- tx.pure.u64(bidAmount),
5484
- tx.object(coin),
5485
- tx.pure.u64(marketFeePrice),
5486
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5487
- ],
5488
- typeArguments: [nftType]
5489
- });
5490
- destroyZeroCoin({ tx, coin });
5491
- }
5492
5497
  async function addOriginByteCollectionBidTx({
5493
5498
  tx,
5494
5499
  collectionId,
@@ -5518,22 +5523,112 @@ async function addOriginByteCollectionBidTx({
5518
5523
  });
5519
5524
  destroyZeroCoin({ tx, coin });
5520
5525
  }
5521
- async function addTradePortPlaceCollectionBidTxHandler(txData) {
5522
- if (await hasRoyaltyRule(txData?.nftType)) {
5523
- const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
5524
- const royaltyRulePackageId = await getRulePackageId({
5525
- nftType: txData.nftType,
5526
- ruleType: getRoyaltyRuleModule(txData?.collectionId),
5527
- kioskClient: txData?.kioskClient
5528
- });
5529
- await addTradePortKioskCollectionBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
5530
- return;
5526
+
5527
+ // src/methods/placeNftBids/addPlaceNftBidTxs.ts
5528
+ var import_utils7 = require("@mysten/sui/utils");
5529
+ async function addTradePortPlaceNftBidTxHandler(txData) {
5530
+ if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
5531
+ throw new Error("OriginByte bidding not supported currently");
5532
+ }
5533
+ const {
5534
+ tx,
5535
+ nftType,
5536
+ multiBidId,
5537
+ multiBidChainId: existingMultiBidChainId,
5538
+ nftTokenId,
5539
+ collectionId,
5540
+ bcsHex,
5541
+ expireAt
5542
+ } = txData;
5543
+ let bcs3;
5544
+ if (nftTokenId && isDynamicCollection(collectionId)) {
5545
+ if (!bcsHex) {
5546
+ throw new Error(`No BCS found for token ${nftTokenId}`);
5547
+ }
5548
+ bcs3 = (0, import_utils7.fromHex)(bcsHex);
5549
+ }
5550
+ let multiBidChainId;
5551
+ if (existingMultiBidChainId) {
5552
+ multiBidChainId = existingMultiBidChainId;
5553
+ } else {
5554
+ const { chain_id: chainId, cancelled_at } = multiBidId ? (await gqlChainRequest({
5555
+ chain: "sui",
5556
+ query: fetchMultibidChainIdById,
5557
+ variables: { multiBidId }
5558
+ }))?.multi_bids?.[0] ?? {} : {};
5559
+ if (chainId && cancelled_at) {
5560
+ throw new Error(`MultiBid ${chainId} already cancelled`);
5561
+ }
5562
+ multiBidChainId = chainId;
5563
+ }
5564
+ const transferPolicies = await getKioskTransferPolicies(nftType);
5565
+ const transferPolicy = transferPolicies?.find(
5566
+ (policy) => policy?.rules?.length > 0
5567
+ );
5568
+ const price = BigInt(txData?.bidAmount ?? 0n);
5569
+ const fee = BigInt(txData?.bidAmount ?? 0) * await getBidFeeBps(txData?.suiClient) / 10000n;
5570
+ let royalty = 0n;
5571
+ const royaltyRule = (transferPolicy?.rules ?? []).find(
5572
+ (r) => r.type.endsWith("royalty_rule")
5573
+ );
5574
+ if (royaltyRule) {
5575
+ const { amount_bp, min_amount } = royaltyRule;
5576
+ royalty = BigInt(price * BigInt(amount_bp) / 10000n);
5577
+ if (royalty < BigInt(min_amount ?? 0n)) {
5578
+ royalty = BigInt(min_amount ?? 0n);
5579
+ }
5531
5580
  }
5532
- addTradePortCollectionBidTx(txData);
5581
+ const [coin] = tx.splitCoins(tx.gas, [multiBidChainId ? 0n : price + fee + royalty]);
5582
+ tx.moveCall({
5583
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_bid_with${transferPolicy ? "" : "out"}_transfer_policy`,
5584
+ typeArguments: [nftType],
5585
+ arguments: [
5586
+ tx.object(TRADEPORT_MULTI_BID_STORE),
5587
+ tx.pure.u64(nftTokenId ? 1 : 0),
5588
+ multiBidChainId ? typeof multiBidChainId === "string" ? tx.pure.option("id", (0, import_utils7.normalizeSuiObjectId)(multiBidChainId)) : tx.moveCall({
5589
+ target: "0x1::option::some",
5590
+ typeArguments: ["0x2::object::ID"],
5591
+ arguments: [multiBidChainId]
5592
+ }) : void 0,
5593
+ tx.pure.option("id", nftTokenId ? (0, import_utils7.normalizeSuiObjectId)(nftTokenId) : void 0),
5594
+ tx.pure.option("vector<u8>", bcs3 ? [...bcs3] : void 0),
5595
+ tx.pure.option("u64", expireAt?.getTime()),
5596
+ tx.pure.u64(price),
5597
+ ...transferPolicy ? [tx.object(transferPolicy.id)] : [],
5598
+ tx.object(coin)
5599
+ ]
5600
+ });
5601
+ }
5602
+ var bidFeeBps;
5603
+ async function getBidFeeBps(suiClient) {
5604
+ if (bidFeeBps !== void 0) {
5605
+ return bidFeeBps;
5606
+ }
5607
+ const res = await suiClient.getObject({
5608
+ id: TRADEPORT_MULTI_BID_STORE,
5609
+ options: { showContent: true }
5610
+ });
5611
+ if (res.error) {
5612
+ throw new Error(`Error on getting SUI object ${TRADEPORT_MULTI_BID_STORE}: ${res.error.code}`);
5613
+ }
5614
+ bidFeeBps = BigInt(
5615
+ res?.data?.content?.fields?.fee_bps ?? 0
5616
+ );
5617
+ return bidFeeBps;
5618
+ }
5619
+ function isDynamicCollection(collectionId) {
5620
+ return DYNAMIC_COLLECTION_IDS.includes(collectionId);
5533
5621
  }
5534
5622
 
5535
5623
  // src/methods/placeCollectionBids/placeCollectionBids.ts
5536
- var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5624
+ var placeCollectionBids = async ({
5625
+ collections,
5626
+ walletAddress,
5627
+ multiBidId,
5628
+ multiBidChainId,
5629
+ expireAt,
5630
+ tx: existingTx
5631
+ }, context) => {
5537
5632
  const res = await gqlChainRequest({
5538
5633
  chain: "sui",
5539
5634
  query: fetchCollectionsByIdWithOneNft,
@@ -5542,11 +5637,8 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5542
5637
  if (res?.collections?.length === 0) {
5543
5638
  throw new Error("No collection found");
5544
5639
  }
5545
- if (res?.collections?.length === 0) {
5546
- throw new Error("No collection found");
5547
- }
5548
5640
  const collectionsForTracking = [];
5549
- const tx = new import_transactions17.Transaction();
5641
+ const tx = existingTx ?? new import_transactions17.Transaction();
5550
5642
  for (const collection of res.collections) {
5551
5643
  const nftType = getNftType({
5552
5644
  collectionId: collection?.id,
@@ -5562,7 +5654,10 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5562
5654
  bidder: walletAddress,
5563
5655
  collectionId: collection?.id,
5564
5656
  nftType,
5565
- bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist
5657
+ bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist,
5658
+ multiBidId,
5659
+ multiBidChainId,
5660
+ expireAt
5566
5661
  };
5567
5662
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
5568
5663
  if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -5578,7 +5673,7 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5578
5673
  }
5579
5674
  } else {
5580
5675
  for (let i = 0; i < numOfBids; i++) {
5581
- await addTradePortPlaceCollectionBidTxHandler(txData);
5676
+ await addTradePortPlaceNftBidTxHandler({ ...txData, bidAmount: BigInt(txData.bidAmount) });
5582
5677
  }
5583
5678
  }
5584
5679
  collectionsForTracking.push({
@@ -5593,172 +5688,8 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
5593
5688
 
5594
5689
  // src/methods/placeNftBids/placeNftBids.ts
5595
5690
  var import_transactions18 = require("@mysten/sui/transactions");
5596
-
5597
- // src/methods/placeNftBids/addPlaceNftBidTxs.ts
5598
- function addTradePortPlaceNftBidTx({
5599
- tx,
5600
- collectionId,
5601
- nftTokenId,
5602
- nftType,
5603
- bidAmount
5604
- }) {
5605
- const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
5606
- const marketFeePrice = getMarketFeePrice({ price: amountToBid, collectionId });
5607
- const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(amountToBid + marketFeePrice)] });
5608
- tx.moveCall({
5609
- target: "0x398aae1ad267d989dcc99ba449b0a30101a6b851ec1284ccddab5937df66bfcf::biddings::bid",
5610
- arguments: [
5611
- tx.object(TRADEPORT_BIDDING_STORE),
5612
- tx.pure.address(nftTokenId),
5613
- tx.pure.u64(amountToBid),
5614
- tx.object(coin),
5615
- tx.pure.u64(marketFeePrice),
5616
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5617
- ],
5618
- typeArguments: [nftType]
5619
- });
5620
- destroyZeroCoin({ tx, coin });
5621
- }
5622
- async function addTradePortKioskPlaceNftBidTx({
5623
- tx,
5624
- suiClient,
5625
- bidder,
5626
- collectionId,
5627
- nftTokenId,
5628
- nftType,
5629
- bidAmount,
5630
- royaltyRulePackageId,
5631
- royaltyRuleModule
5632
- }) {
5633
- const transferPolicyId = await getKioskTransferPolicies(nftType).then(
5634
- (policies) => policies?.[0]?.id
5635
- );
5636
- const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
5637
- const coin = await getKioskPlaceBidCoin({
5638
- tx,
5639
- suiClient,
5640
- bidder,
5641
- nftType,
5642
- bidAmount,
5643
- marketFeePrice,
5644
- royaltyRulePackageId,
5645
- royaltyRuleModule,
5646
- transferPolicyId
5647
- });
5648
- tx.moveCall({
5649
- target: "0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_biddings::bid",
5650
- arguments: [
5651
- tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
5652
- tx.pure.address(nftTokenId),
5653
- tx.pure.u64(bidAmount),
5654
- tx.object(coin),
5655
- tx.pure.u64(marketFeePrice),
5656
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS)
5657
- ],
5658
- typeArguments: [nftType]
5659
- });
5660
- destroyZeroCoin({ tx, coin });
5661
- }
5662
- async function addKumoTradePortKioskPlaceNftBidTx({
5663
- tx,
5664
- suiClient,
5665
- bidder,
5666
- collectionId,
5667
- nftTokenId,
5668
- nftType,
5669
- bidAmount,
5670
- royaltyRulePackageId,
5671
- royaltyRuleModule
5672
- }) {
5673
- const transferPolicyId = await getKioskTransferPolicies(nftType).then(
5674
- (policies) => policies?.[0]?.id
5675
- );
5676
- const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
5677
- const coin = await getKioskPlaceBidCoin({
5678
- tx,
5679
- suiClient,
5680
- bidder,
5681
- nftType,
5682
- bidAmount,
5683
- marketFeePrice,
5684
- royaltyRulePackageId,
5685
- royaltyRuleModule,
5686
- transferPolicyId
5687
- });
5688
- const kumoAttributes = await fetchKumoNftAttributes(suiClient, nftTokenId);
5689
- const normalizedAttributes = normalizeKumoAttributes(kumoAttributes);
5690
- tx.moveCall({
5691
- target: "0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_biddings::kumo_bid",
5692
- arguments: [
5693
- tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
5694
- tx.pure.address(nftTokenId),
5695
- tx.pure.u64(bidAmount),
5696
- tx.object(coin),
5697
- tx.pure.u64(marketFeePrice),
5698
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS),
5699
- ...Object.values(normalizedAttributes).map((attr) => tx.pure.option("string", attr))
5700
- ],
5701
- typeArguments: [nftType]
5702
- });
5703
- destroyZeroCoin({ tx, coin });
5704
- }
5705
- async function addTradePortPlaceNftBidTxHandler(txData) {
5706
- if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
5707
- throw new Error("OriginByte bidding not supported currently");
5708
- }
5709
- if (await hasTransferPolicyRules(txData?.nftType) && txData?.sellerKiosk) {
5710
- const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
5711
- const royaltyRulePackageId = await getRulePackageId({
5712
- nftType: txData?.nftType,
5713
- ruleType: royaltyRuleModule,
5714
- kioskClient: txData?.kioskClient
5715
- });
5716
- if (txData?.collectionId === "67aca668-31b0-4713-91cf-079d392b041a") {
5717
- await addKumoTradePortKioskPlaceNftBidTx({
5718
- ...txData,
5719
- royaltyRulePackageId,
5720
- royaltyRuleModule
5721
- });
5722
- return;
5723
- }
5724
- await addTradePortKioskPlaceNftBidTx({ ...txData, royaltyRulePackageId, royaltyRuleModule });
5725
- return;
5726
- }
5727
- addTradePortPlaceNftBidTx(txData);
5728
- }
5729
- async function fetchKumoNftAttributes(suiClient, nftTokenId) {
5730
- if (!nftTokenId) {
5731
- throw new Error("NFT Token ID is required to fetch Kumo attributes");
5732
- }
5733
- let res;
5734
- try {
5735
- res = await suiClient.getObject({
5736
- id: nftTokenId,
5737
- options: { showContent: true }
5738
- });
5739
- } catch (error) {
5740
- throw new Error(
5741
- `Failed to fetch Kumo token object data: ${error instanceof Error ? error.message : "Unknown error"}`
5742
- );
5743
- }
5744
- if (!res.data) {
5745
- throw new Error(`NFT object data not found: ${nftTokenId}`);
5746
- }
5747
- if (res.data?.content?.dataType !== "moveObject") {
5748
- throw new Error("Invalid NFT Token ID - not a move object");
5749
- }
5750
- const { accessory, background, eyes, fur_colour, mouth, tail, one_of_one } = res.data?.content?.fields || {};
5751
- return { accessory, background, eyes, fur_colour, mouth, tail, one_of_one };
5752
- }
5753
- function normalizeKumoAttributes(attributes) {
5754
- const normalizeAttribute = (attr) => !attr || attr === "Default" || attr === "None" ? null : attr;
5755
- return Object.fromEntries(
5756
- Object.entries(attributes).map(([key, value]) => [key, normalizeAttribute(value)])
5757
- );
5758
- }
5759
-
5760
- // src/methods/placeNftBids/placeNftBids.ts
5761
- var placeNftBids = async ({ nfts, walletAddress }, context) => {
5691
+ var placeNftBids = async ({ nfts, walletAddress, multiBidId, multiBidChainId, expireAt, tx: existingTx }, context) => {
5692
+ const tx = existingTx ?? new import_transactions18.Transaction();
5762
5693
  const res = await gqlChainRequest({
5763
5694
  chain: "sui",
5764
5695
  query: fetchNftsById,
@@ -5768,7 +5699,6 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
5768
5699
  throw new Error("No nfts found");
5769
5700
  }
5770
5701
  const nftsForTracking = [];
5771
- const tx = new import_transactions18.Transaction();
5772
5702
  for (const nft of res.nfts) {
5773
5703
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
5774
5704
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5782,14 +5712,16 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
5782
5712
  const txData = {
5783
5713
  tx,
5784
5714
  suiClient: context.suiClient,
5785
- kioskClient: context.kioskClient,
5786
5715
  sharedObjects,
5787
5716
  bidder: walletAddress,
5788
5717
  collectionId: nft?.collection_id,
5789
5718
  nftTokenId: nft?.token_id,
5790
5719
  nftType,
5791
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
5792
- sellerKiosk: nft?.chain_state?.kiosk_id
5720
+ bidAmount: BigInt(nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist ?? 0n),
5721
+ bcsHex: nft.chain_state?.bcs?.bcsHex,
5722
+ multiBidId,
5723
+ multiBidChainId,
5724
+ expireAt
5793
5725
  };
5794
5726
  await addTradePortPlaceNftBidTxHandler(txData);
5795
5727
  nftsForTracking.push({
@@ -5849,8 +5781,27 @@ function addTocenRemoveNftBidTx({ tx, nftTokenId, bidAmount }) {
5849
5781
  typeArguments: []
5850
5782
  });
5851
5783
  }
5784
+ async function addSingleBidRemoveNftBidTx({ tx, bidNonce, multiBidId }) {
5785
+ const multiBidChainId = multiBidId ? (await gqlChainRequest({
5786
+ chain: "sui",
5787
+ query: fetchMultibidChainIdById,
5788
+ variables: { multiBidId }
5789
+ }))?.multi_bids?.[0]?.chain_id : void 0;
5790
+ tx.moveCall({
5791
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_bid`,
5792
+ arguments: [
5793
+ tx.object(TRADEPORT_MULTI_BID_STORE),
5794
+ tx.pure.id(bidNonce),
5795
+ tx.pure.option("id", multiBidChainId)
5796
+ ]
5797
+ });
5798
+ }
5852
5799
  async function addTradePortRemoveNftBidTxHandler(txData) {
5853
5800
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
5801
+ if (isSingleBid(bidType)) {
5802
+ await addSingleBidRemoveNftBidTx(txData);
5803
+ return;
5804
+ }
5854
5805
  if (isOriginByteBid(bidType)) {
5855
5806
  addOriginByteRemoveNftBidTx(txData);
5856
5807
  return;
@@ -5933,6 +5884,10 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
5933
5884
  }
5934
5885
  async function addBluemoveRemoveCollectionBidTxHandler(txData) {
5935
5886
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
5887
+ if (isSingleBid(bidType)) {
5888
+ await addSingleBidRemoveNftBidTx(txData);
5889
+ return;
5890
+ }
5936
5891
  if (isOriginByteBid(bidType)) {
5937
5892
  const sharedObjects = await getSharedObjects(txData?.nftType);
5938
5893
  addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
@@ -6040,7 +5995,8 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6040
5995
  nftTokenId: bid?.nft?.token_id,
6041
5996
  bidAmount: bid?.price,
6042
5997
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
6043
- bidMarketName: bid?.market_contract?.name
5998
+ bidMarketName: bid?.market_contract?.name,
5999
+ multiBidId: bid?.multi_bid_id
6044
6000
  };
6045
6001
  switch (txData.bidMarketName) {
6046
6002
  case "tradeport":
@@ -6316,6 +6272,94 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6316
6272
  return import_transactions23.Transaction.from(tx);
6317
6273
  }
6318
6274
 
6275
+ // src/methods/createMultiBid/createMultiBid.ts
6276
+ var import_transactions25 = require("@mysten/sui/transactions");
6277
+
6278
+ // src/methods/updateMultiBid/updateMultiBid.ts
6279
+ var import_transactions24 = require("@mysten/sui/transactions");
6280
+ async function updateMultiBid({
6281
+ multiBidId,
6282
+ name,
6283
+ amount,
6284
+ amountToWithdraw,
6285
+ tx: existingTx,
6286
+ multiBidChainId
6287
+ }) {
6288
+ const tx = existingTx ?? new import_transactions24.Transaction();
6289
+ if (!multiBidChainId) {
6290
+ const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
6291
+ chain: "sui",
6292
+ query: fetchMultibidChainIdById,
6293
+ variables: { multiBidId }
6294
+ }))?.multi_bids?.[0] ?? {};
6295
+ if (!chainId) {
6296
+ throw new Error(`MultiBid ${multiBidId} not found`);
6297
+ }
6298
+ if (cancelled_at) {
6299
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
6300
+ }
6301
+ multiBidChainId = chainId;
6302
+ }
6303
+ const [coin] = tx.splitCoins(tx.gas, [amount ?? 0n]);
6304
+ tx.moveCall({
6305
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
6306
+ arguments: [
6307
+ tx.object(TRADEPORT_MULTI_BID_STORE),
6308
+ typeof multiBidChainId === "string" ? tx.pure.id(multiBidChainId) : multiBidChainId,
6309
+ tx.pure.option("string", name),
6310
+ coin,
6311
+ tx.pure.option("u64", amountToWithdraw)
6312
+ ]
6313
+ });
6314
+ return tx;
6315
+ }
6316
+
6317
+ // src/methods/createMultiBid/createMultiBid.ts
6318
+ async function createMultiBid({
6319
+ walletAddress,
6320
+ name,
6321
+ amount,
6322
+ tx: existingTx
6323
+ }) {
6324
+ const tx = existingTx ?? new import_transactions25.Transaction();
6325
+ const multiBidChainId = tx.moveCall({
6326
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
6327
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
6328
+ });
6329
+ if (amount > 0n) {
6330
+ await updateMultiBid({
6331
+ walletAddress,
6332
+ multiBidChainId,
6333
+ amount,
6334
+ name,
6335
+ tx
6336
+ });
6337
+ }
6338
+ return { multiBidChainId, tx };
6339
+ }
6340
+
6341
+ // src/methods/cancelMultiBid/cancelMultiBid.ts
6342
+ var import_transactions26 = require("@mysten/sui/transactions");
6343
+ async function cancelMultiBid({ multiBidId }) {
6344
+ const { chain_id: multiBidChainId, cancelled_at } = (await gqlChainRequest({
6345
+ chain: "sui",
6346
+ query: fetchMultibidChainIdById,
6347
+ variables: { multiBidId }
6348
+ }))?.multi_bids?.[0] ?? {};
6349
+ if (!multiBidChainId) {
6350
+ throw new Error(`MultiBid ${multiBidId} not found`);
6351
+ }
6352
+ if (cancelled_at) {
6353
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
6354
+ }
6355
+ const tx = new import_transactions26.Transaction();
6356
+ tx.moveCall({
6357
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_multi_bid`,
6358
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.id(multiBidChainId)]
6359
+ });
6360
+ return tx;
6361
+ }
6362
+
6319
6363
  // src/SuiTradingClient.ts
6320
6364
  var SuiTradingClient = class {
6321
6365
  constructor({ apiUser, apiKey, suiNodeUrl, graphQLClient }) {
@@ -6359,14 +6403,14 @@ var SuiTradingClient = class {
6359
6403
  };
6360
6404
  return unlistListings({ listingIds, walletAddress }, context);
6361
6405
  }
6362
- async placeNftBids({ nfts, walletAddress }) {
6406
+ async placeNftBids(data) {
6363
6407
  const context = {
6364
6408
  apiUser: this.apiUser,
6365
6409
  apiKey: this.apiKey,
6366
6410
  suiClient: this.suiClient,
6367
6411
  kioskClient: this.kioskClient
6368
6412
  };
6369
- return placeNftBids({ nfts, walletAddress }, context);
6413
+ return placeNftBids(data, context);
6370
6414
  }
6371
6415
  async removeNftBids({ bidIds, tx }) {
6372
6416
  const context = {
@@ -6390,7 +6434,10 @@ var SuiTradingClient = class {
6390
6434
  collectionId,
6391
6435
  bidAmountInMist,
6392
6436
  numOfBids,
6393
- walletAddress
6437
+ walletAddress,
6438
+ multiBidId,
6439
+ multiBidChainId,
6440
+ expireAt
6394
6441
  }) {
6395
6442
  const context = {
6396
6443
  apiUser: this.apiUser,
@@ -6407,7 +6454,10 @@ var SuiTradingClient = class {
6407
6454
  numOfBids
6408
6455
  }
6409
6456
  ],
6410
- walletAddress
6457
+ walletAddress,
6458
+ multiBidId,
6459
+ multiBidChainId,
6460
+ expireAt
6411
6461
  },
6412
6462
  context
6413
6463
  );
@@ -6632,6 +6682,15 @@ var SuiTradingClient = class {
6632
6682
  };
6633
6683
  return migrateNftsFromUnsharedToSharedKiosks(args, context);
6634
6684
  }
6685
+ async createMultiBid(args) {
6686
+ return createMultiBid(args);
6687
+ }
6688
+ async cancelMultiBid(args) {
6689
+ return cancelMultiBid(args);
6690
+ }
6691
+ async updateMultiBid(args) {
6692
+ return updateMultiBid(args);
6693
+ }
6635
6694
  };
6636
6695
  var SuiTradingClient_default = SuiTradingClient;
6637
6696
  // Annotate the CommonJS export names for ESM import in node: