@tradeport/sui-trading-sdk 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @tradeport/sui-trading-sdk
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 485e023: Bug Fix: Fixed handling of Suiduckz and Cyberpills txs to list on TradePort's normal contract since they are untradable on OB or Kiosk contracts
8
+
9
+ ## 0.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 131e349: Renamed user inputs of listPrice and bidAmount to listPriceInMist and bidAmountInMist
package/dist/index.d.mts CHANGED
@@ -23,14 +23,14 @@ type ClaimNfts = {
23
23
  type ListNfts = {
24
24
  nfts: Array<{
25
25
  id: string;
26
- listPrice: number;
26
+ listPriceInMist: number;
27
27
  }>;
28
28
  walletAddress: string;
29
29
  };
30
30
 
31
31
  type PlaceCollectionBid = {
32
32
  collectionId: string;
33
- bidAmount: number;
33
+ bidAmountInMist: number;
34
34
  numOfBids: number;
35
35
  walletAddress: string;
36
36
  };
@@ -38,7 +38,7 @@ type PlaceCollectionBid = {
38
38
  type PlaceNftBids = {
39
39
  nfts: Array<{
40
40
  id: string;
41
- bidAmount: number;
41
+ bidAmountInMist: number;
42
42
  }>;
43
43
  walletAddress: string;
44
44
  };
@@ -79,7 +79,7 @@ declare class SuiTradingClient {
79
79
  placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<TransactionBlock>;
80
80
  removeNftBids({ bidIds }: RemoveNftBids): Promise<TransactionBlock>;
81
81
  acceptNftBids({ bidIds }: AcceptNftBids): Promise<TransactionBlock>;
82
- placeCollectionBid({ collectionId, bidAmount, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<TransactionBlock>;
82
+ placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<TransactionBlock>;
83
83
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<TransactionBlock>;
84
84
  removeCollectionBid({ bidId }: RemoveCollectionBid): Promise<TransactionBlock>;
85
85
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<TransactionBlock>;
package/dist/index.d.ts CHANGED
@@ -23,14 +23,14 @@ type ClaimNfts = {
23
23
  type ListNfts = {
24
24
  nfts: Array<{
25
25
  id: string;
26
- listPrice: number;
26
+ listPriceInMist: number;
27
27
  }>;
28
28
  walletAddress: string;
29
29
  };
30
30
 
31
31
  type PlaceCollectionBid = {
32
32
  collectionId: string;
33
- bidAmount: number;
33
+ bidAmountInMist: number;
34
34
  numOfBids: number;
35
35
  walletAddress: string;
36
36
  };
@@ -38,7 +38,7 @@ type PlaceCollectionBid = {
38
38
  type PlaceNftBids = {
39
39
  nfts: Array<{
40
40
  id: string;
41
- bidAmount: number;
41
+ bidAmountInMist: number;
42
42
  }>;
43
43
  walletAddress: string;
44
44
  };
@@ -79,7 +79,7 @@ declare class SuiTradingClient {
79
79
  placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<TransactionBlock>;
80
80
  removeNftBids({ bidIds }: RemoveNftBids): Promise<TransactionBlock>;
81
81
  acceptNftBids({ bidIds }: AcceptNftBids): Promise<TransactionBlock>;
82
- placeCollectionBid({ collectionId, bidAmount, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<TransactionBlock>;
82
+ placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<TransactionBlock>;
83
83
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<TransactionBlock>;
84
84
  removeCollectionBid({ bidId }: RemoveCollectionBid): Promise<TransactionBlock>;
85
85
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<TransactionBlock>;
package/dist/index.js CHANGED
@@ -317,27 +317,50 @@ var getSharedObjects = async (nftType) => {
317
317
  };
318
318
  };
319
319
 
320
- // src/apiClients/kioskClient.ts
321
- var import_kiosk = require("@mysten/kiosk");
322
- var kioskClient = new import_kiosk.KioskClient({
323
- // @ts-ignore
324
- client: suiClient_default,
325
- network: import_kiosk.Network.MAINNET
326
- });
327
- var kioskClient_default = kioskClient;
320
+ // src/graphql/queries/fetchTransferPoliciesByType.ts
321
+ var import_graphql_request7 = require("graphql-request");
322
+ var fetchTransferPoliciesByType = import_graphql_request7.gql`
323
+ query fetchTransferPoliciesByType($type: String!) {
324
+ transfer_policies_by_type(type: $type) {
325
+ id
326
+ is_origin_byte
327
+ rules
328
+ type
329
+ }
330
+ }
331
+ `;
328
332
 
329
- // src/helpers/hasTransferPolicyRules.ts
330
- var hasTransferPolicyRules = async (nftType) => {
333
+ // src/helpers/kiosk/getKioskTransferPolicies.ts
334
+ var getKioskTransferPolicies = async (nftType) => {
331
335
  const nftTypeSplit = nftType?.split("::");
332
336
  if (nftTypeSplit?.[0])
333
337
  nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
334
- const res = await kioskClient_default.getTransferPolicies({ type: nftTypeSplit?.join("::") });
335
- return res?.some((policy) => policy?.rules?.length > 0);
338
+ const res = await gqlChainRequest({
339
+ chain: "sui",
340
+ query: fetchTransferPoliciesByType,
341
+ variables: { type: nftTypeSplit?.join("::") }
342
+ });
343
+ return res?.transfer_policies_by_type?.filter((policy) => !policy?.is_origin_byte);
344
+ };
345
+
346
+ // src/helpers/hasTransferPolicyRules.ts
347
+ var hasTransferPolicyRules = async (nftType) => {
348
+ const transferPolicies = await getKioskTransferPolicies(nftType);
349
+ return transferPolicies?.some((policy) => policy?.rules?.length > 0);
336
350
  };
337
351
 
338
352
  // src/helpers/kiosk/getRulePackageId.ts
339
353
  var import_kiosk2 = require("@mysten/kiosk");
340
354
 
355
+ // src/apiClients/kioskClient.ts
356
+ var import_kiosk = require("@mysten/kiosk");
357
+ var kioskClient = new import_kiosk.KioskClient({
358
+ // @ts-ignore
359
+ client: suiClient_default,
360
+ network: import_kiosk.Network.MAINNET
361
+ });
362
+ var kioskClient_default = kioskClient;
363
+
341
364
  // src/utils/addHexPrefix.ts
342
365
  function addHexPrefix(input) {
343
366
  if (input.startsWith("0x")) {
@@ -372,8 +395,8 @@ var isTradePortKioskBid = (bidType) => bidType === TRADEPORT_KIOSK_BID_NONCE_TYP
372
395
  var import_kiosk3 = require("@mysten/kiosk");
373
396
 
374
397
  // src/graphql/queries/fetchKiosksByOwner.ts
375
- var import_graphql_request7 = require("graphql-request");
376
- var fetchKiosksByOwner = import_graphql_request7.gql`
398
+ var import_graphql_request8 = require("graphql-request");
399
+ var fetchKiosksByOwner = import_graphql_request8.gql`
377
400
  query fetchKiosksByOwner($ownerAddress: String!) {
378
401
  kiosks: kiosks_by_owner_address(owner_address: $ownerAddress) {
379
402
  id
@@ -386,8 +409,8 @@ var fetchKiosksByOwner = import_graphql_request7.gql`
386
409
  `;
387
410
 
388
411
  // src/graphql/queries/fetchOwnerCapByKiosk.ts
389
- var import_graphql_request8 = require("graphql-request");
390
- var fetchOwnerCapByKiosk = import_graphql_request8.gql`
412
+ var import_graphql_request9 = require("graphql-request");
413
+ var fetchOwnerCapByKiosk = import_graphql_request9.gql`
391
414
  query fetchOwnerCapByKiosk($kioskId: String!) {
392
415
  ownerCap: kiosk_owner_cap_by_kiosk(kiosk_id: $kioskId) {
393
416
  id
@@ -397,8 +420,8 @@ var fetchOwnerCapByKiosk = import_graphql_request8.gql`
397
420
  `;
398
421
 
399
422
  // src/graphql/queries/fetchPersonalCapByKiosk.ts
400
- var import_graphql_request9 = require("graphql-request");
401
- var fetchPersonalCapByKiosk = import_graphql_request9.gql`
423
+ var import_graphql_request10 = require("graphql-request");
424
+ var fetchPersonalCapByKiosk = import_graphql_request10.gql`
402
425
  query fetchPersonalCapByKiosk($kioskId: String!) {
403
426
  personalCap: personal_kiosk_cap_by_kiosk(kiosk_id: $kioskId) {
404
427
  id
@@ -515,8 +538,8 @@ var createOBKiosk = async ({ txBlock, createMethod = "new" }) => {
515
538
  };
516
539
 
517
540
  // src/helpers/originByte/getOBKiosk.ts
518
- var import_graphql_request10 = require("graphql-request");
519
- var fetchAccountKiosks = import_graphql_request10.gql`
541
+ var import_graphql_request11 = require("graphql-request");
542
+ var fetchAccountKiosks = import_graphql_request11.gql`
520
543
  query fetchAccountKiosks($accountAddress: String!) {
521
544
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
522
545
  id
@@ -1544,8 +1567,8 @@ var acceptCollectionBid = async ({
1544
1567
  var import_transactions2 = require("@mysten/sui.js/transactions");
1545
1568
 
1546
1569
  // src/graphql/queries/fetchBidsById.ts
1547
- var import_graphql_request11 = require("graphql-request");
1548
- var fetchBidsById = import_graphql_request11.gql`
1570
+ var import_graphql_request12 = require("graphql-request");
1571
+ var fetchBidsById = import_graphql_request12.gql`
1549
1572
  query fetchBidsById($bidIds: [uuid!]) {
1550
1573
  bids(where: { id: { _in: $bidIds } }) {
1551
1574
  nonce
@@ -1633,8 +1656,8 @@ var acceptNftBids = async ({ bidIds }) => {
1633
1656
  var import_transactions3 = require("@mysten/sui.js/transactions");
1634
1657
 
1635
1658
  // src/graphql/queries/fetchListingsById.ts
1636
- var import_graphql_request12 = require("graphql-request");
1637
- var fetchListingsById = import_graphql_request12.gql`
1659
+ var import_graphql_request13 = require("graphql-request");
1660
+ var fetchListingsById = import_graphql_request13.gql`
1638
1661
  query fetchListingsById($listingIds: [uuid!]) {
1639
1662
  listings(where: { id: { _in: $listingIds } }) {
1640
1663
  seller
@@ -1669,8 +1692,8 @@ var addThirdPartyTxFee = async (txBlock, price) => {
1669
1692
  };
1670
1693
 
1671
1694
  // src/graphql/queries/fetchCommissionByListingId.ts
1672
- var import_graphql_request13 = require("graphql-request");
1673
- var fetchCommissionByNftContractId = import_graphql_request13.gql`
1695
+ var import_graphql_request14 = require("graphql-request");
1696
+ var fetchCommissionByNftContractId = import_graphql_request14.gql`
1674
1697
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
1675
1698
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
1676
1699
  is_custodial
@@ -2391,7 +2414,7 @@ var getDSLLegacyMarketFeePrice = (price) => {
2391
2414
  10
2392
2415
  );
2393
2416
  };
2394
- var getMarketFeePrice = ({ price, collectionId, walletId }) => {
2417
+ var getMarketFeePrice = ({ price, collectionId }) => {
2395
2418
  if (collectionId === "6824e1ff-477e-4810-9ba7-8d6387b68c7d") {
2396
2419
  return getBASCMarketFeePrice(price);
2397
2420
  }
@@ -2411,9 +2434,6 @@ var getMarketFeePrice = ({ price, collectionId, walletId }) => {
2411
2434
  return parseInt(marketFeePrice?.toFixed(0), 10);
2412
2435
  };
2413
2436
 
2414
- // src/utils/parseSUI.ts
2415
- var parseSUI = (num) => parseInt((1e9 * num).toFixed(0), 10);
2416
-
2417
2437
  // src/methods/listNfts/addListTxs.ts
2418
2438
  async function addOriginByteListTx({
2419
2439
  txBlock,
@@ -2439,18 +2459,13 @@ async function addOriginByteListTx({
2439
2459
  nftType
2440
2460
  });
2441
2461
  }
2442
- const parsedListPrice = parseSUI(listPrice);
2443
- const marketFeePrice = getMarketFeePrice({
2444
- price: parsedListPrice,
2445
- collectionId,
2446
- walletId: seller
2447
- });
2462
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2448
2463
  txBlock.moveCall({
2449
2464
  target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::orderbook::create_ask_with_commission",
2450
2465
  arguments: [
2451
2466
  txBlock.object(orderbook),
2452
2467
  txBlock.object(kiosk),
2453
- txBlock.pure(parsedListPrice),
2468
+ txBlock.pure(listPrice),
2454
2469
  txBlock.pure(nftTokenId),
2455
2470
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
2456
2471
  txBlock.pure(marketFeePrice)
@@ -2467,21 +2482,15 @@ function addTradePortListTx({
2467
2482
  borrowedItem,
2468
2483
  nftType,
2469
2484
  collectionId,
2470
- listPrice,
2471
- seller
2485
+ listPrice
2472
2486
  }) {
2473
- const parsedListPrice = parseSUI(listPrice);
2474
- const marketFeePrice = getMarketFeePrice({
2475
- price: parsedListPrice,
2476
- collectionId,
2477
- walletId: seller
2478
- });
2487
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2479
2488
  txBlock.moveCall({
2480
2489
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::list",
2481
2490
  arguments: [
2482
2491
  txBlock.object(TRADEPORT_LISTING_STORE),
2483
2492
  borrowedItem ? txBlock.object(borrowedItem) : txBlock.pure(nftTokenId),
2484
- txBlock.pure(parsedListPrice),
2493
+ txBlock.pure(listPrice),
2485
2494
  txBlock.pure(marketFeePrice),
2486
2495
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2487
2496
  ],
@@ -2494,15 +2503,9 @@ async function addTradePortKioskListTx({
2494
2503
  nftTokenId,
2495
2504
  nftType,
2496
2505
  collectionId,
2497
- listPrice,
2498
- seller
2506
+ listPrice
2499
2507
  }) {
2500
- const parsedListPrice = parseSUI(listPrice);
2501
- const marketFeePrice = getMarketFeePrice({
2502
- price: parsedListPrice,
2503
- collectionId,
2504
- walletId: seller
2505
- });
2508
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2506
2509
  txBlock.moveCall({
2507
2510
  target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_listings::list",
2508
2511
  arguments: [
@@ -2510,7 +2513,7 @@ async function addTradePortKioskListTx({
2510
2513
  txBlock.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
2511
2514
  txBlock.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
2512
2515
  txBlock.pure(nftTokenId),
2513
- txBlock.pure(Number(parsedListPrice) + marketFeePrice),
2516
+ txBlock.pure(listPrice + marketFeePrice),
2514
2517
  txBlock.pure(marketFeePrice),
2515
2518
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2516
2519
  ],
@@ -2575,21 +2578,15 @@ function addTradePortRelistTx({
2575
2578
  nftType,
2576
2579
  collectionId,
2577
2580
  listingNonce,
2578
- listPrice,
2579
- seller
2581
+ listPrice
2580
2582
  }) {
2581
- const parsedListPrice = parseSUI(listPrice);
2582
- const marketFeePrice = getMarketFeePrice({
2583
- price: parsedListPrice,
2584
- collectionId,
2585
- walletId: seller
2586
- });
2583
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2587
2584
  txBlock.moveCall({
2588
2585
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::relist",
2589
2586
  arguments: [
2590
2587
  txBlock.object(TRADEPORT_LISTING_STORE),
2591
2588
  txBlock.pure(listingNonce),
2592
- txBlock.pure(parsedListPrice),
2589
+ txBlock.pure(listPrice),
2593
2590
  txBlock.pure(marketFeePrice),
2594
2591
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2595
2592
  ],
@@ -2701,7 +2698,7 @@ var listNfts = async ({ nfts, walletAddress }) => {
2701
2698
  txBlock,
2702
2699
  sharedObjects,
2703
2700
  nft,
2704
- listPrice: nfts?.find((n) => n.id === nft?.id)?.listPrice,
2701
+ listPrice: nfts?.find((n) => n.id === nft?.id)?.listPriceInMist,
2705
2702
  walletAddress
2706
2703
  });
2707
2704
  } else {
@@ -2712,7 +2709,7 @@ var listNfts = async ({ nfts, walletAddress }) => {
2712
2709
  collectionId: nft?.collection_id,
2713
2710
  nftTokenId: nft?.token_id,
2714
2711
  nftType: getNftTypeFromNft(nft),
2715
- listPrice: nfts?.find((n) => n.id === nft?.id)?.listPrice,
2712
+ listPrice: nfts?.find((n) => n.id === nft?.id)?.listPriceInMist,
2716
2713
  sellerKiosk: nft?.chain_state?.kiosk_id
2717
2714
  };
2718
2715
  await addTradePortListTxHandler(listTxData);
@@ -2725,8 +2722,8 @@ var listNfts = async ({ nfts, walletAddress }) => {
2725
2722
  var import_transactions6 = require("@mysten/sui.js/transactions");
2726
2723
 
2727
2724
  // src/graphql/queries/fetchCollectionsById.ts
2728
- var import_graphql_request14 = require("graphql-request");
2729
- var fetchCollectionsById = import_graphql_request14.gql`
2725
+ var import_graphql_request15 = require("graphql-request");
2726
+ var fetchCollectionsById = import_graphql_request15.gql`
2730
2727
  query fetchCollectionsById($collectionIds: [uuid!]) {
2731
2728
  collections(where: { id: { _in: $collectionIds } }) {
2732
2729
  id
@@ -2736,7 +2733,7 @@ var fetchCollectionsById = import_graphql_request14.gql`
2736
2733
  }
2737
2734
  }
2738
2735
  `;
2739
- var fetchCollectionsByIdWithOneNft = import_graphql_request14.gql`
2736
+ var fetchCollectionsByIdWithOneNft = import_graphql_request15.gql`
2740
2737
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
2741
2738
  collections(where: { id: { _in: $collectionIds } }) {
2742
2739
  id
@@ -2754,8 +2751,8 @@ var fetchCollectionsByIdWithOneNft = import_graphql_request14.gql`
2754
2751
  }
2755
2752
  `;
2756
2753
 
2757
- // src/helpers/getTradeportBiddingContractParsedBidAmount.ts
2758
- var getTradeportBiddingContractParsedBidAmount = ({ bidAmount, collectionId }) => {
2754
+ // src/helpers/getTradeportBiddingContractBidAmount.ts
2755
+ var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
2759
2756
  let amount = bidAmount;
2760
2757
  if (collectionId === "8568521c-73a3-4beb-b830-d1ff27a3f1ca") {
2761
2758
  amount = bidAmount - bidAmount * MASC_ROYALTY_DECIMAL_PERCENT;
@@ -2766,17 +2763,14 @@ var getTradeportBiddingContractParsedBidAmount = ({ bidAmount, collectionId }) =
2766
2763
  if (collectionId === "307c7e7a-be3a-43a5-ae44-37f3a37d01f9") {
2767
2764
  amount = bidAmount - bidAmount * DSL_LEGACY_ROYALTY_DECIMAL_PERCENT;
2768
2765
  }
2769
- return Number(parseSUI(amount));
2766
+ return amount;
2770
2767
  };
2771
2768
 
2772
2769
  // src/helpers/hasRoyaltyRule.ts
2773
2770
  var hasRoyaltyRule = async (nftType) => {
2774
- const nftTypeSplit = nftType?.split("::");
2775
- if (nftTypeSplit?.[0])
2776
- nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
2777
- const res = await kioskClient_default.getTransferPolicies({ type: nftTypeSplit?.join("::") });
2778
- return res?.some(
2779
- (policy) => policy?.rules?.filter((rule) => rule?.includes("royalty_rule"))?.length > 0
2771
+ const transferPolicies = await getKioskTransferPolicies(nftType);
2772
+ return transferPolicies?.some(
2773
+ (policy) => policy?.rules?.filter((rule) => rule?.type?.includes("royalty_rule"))?.length > 0
2780
2774
  );
2781
2775
  };
2782
2776
 
@@ -2785,21 +2779,16 @@ function addTradePortCollectionBidTx({
2785
2779
  txBlock,
2786
2780
  collectionId,
2787
2781
  nftType,
2788
- bidAmount,
2789
- bidder
2782
+ bidAmount
2790
2783
  }) {
2791
- const parsedBidAmount = getTradeportBiddingContractParsedBidAmount({ bidAmount, collectionId });
2792
- const marketFeePrice = getMarketFeePrice({
2793
- price: Number(parseSUI(bidAmount)),
2794
- collectionId,
2795
- walletId: bidder
2796
- });
2797
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2784
+ const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
2785
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
2786
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(amountToBid + marketFeePrice)] });
2798
2787
  txBlock.moveCall({
2799
2788
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::biddings::collection_bid",
2800
2789
  arguments: [
2801
2790
  txBlock.object(TRADEPORT_BIDDING_STORE),
2802
- txBlock.pure(parsedBidAmount),
2791
+ txBlock.pure(amountToBid),
2803
2792
  txBlock.object(coin),
2804
2793
  txBlock.pure(marketFeePrice),
2805
2794
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
@@ -2814,65 +2803,66 @@ function addTradePortKioskCollectionBidTx({
2814
2803
  nftType,
2815
2804
  bidAmount,
2816
2805
  sharedObjects,
2817
- bidder,
2818
2806
  royaltyRulePackageId,
2819
2807
  royaltyRuleModule
2820
2808
  }) {
2821
2809
  const { transferPolicy } = sharedObjects;
2822
- const parsedBidAmount = Number(parseSUI(bidAmount));
2823
2810
  const marketFeePrice = getMarketFeePrice({
2824
- price: parsedBidAmount,
2825
- collectionId,
2826
- walletId: bidder
2827
- });
2828
- const fee = txBlock.moveCall({
2829
- target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
2830
- arguments: [txBlock.object(transferPolicy), txBlock.pure(parsedBidAmount)],
2831
- typeArguments: [nftType]
2832
- });
2833
- const [coin1, coin2] = splitCoins({
2834
- txBlock,
2835
- amounts: [txBlock.pure(parsedBidAmount + marketFeePrice), txBlock.object(fee)]
2836
- });
2837
- if (!coin1 || !coin2)
2838
- throw new Error("Coin could not be split");
2839
- txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
2811
+ price: bidAmount,
2812
+ collectionId
2813
+ });
2814
+ let coin;
2815
+ if (royaltyRulePackageId && royaltyRuleModule) {
2816
+ const fee = txBlock.moveCall({
2817
+ target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
2818
+ arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount)],
2819
+ typeArguments: [nftType]
2820
+ });
2821
+ const [coin1, coin2] = splitCoins({
2822
+ txBlock,
2823
+ amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(fee)]
2824
+ });
2825
+ coin = coin1;
2826
+ if (!coin1 || !coin2)
2827
+ throw new Error("Coin could not be split");
2828
+ txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
2829
+ } else {
2830
+ const [coin1] = splitCoins({
2831
+ txBlock,
2832
+ amounts: [txBlock.pure(bidAmount + marketFeePrice)]
2833
+ });
2834
+ coin = coin1;
2835
+ }
2840
2836
  txBlock.moveCall({
2841
2837
  target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::collection_bid",
2842
2838
  arguments: [
2843
2839
  txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
2844
- txBlock.pure(parsedBidAmount),
2845
- txBlock.object(coin1),
2840
+ txBlock.pure(bidAmount),
2841
+ txBlock.object(coin),
2846
2842
  txBlock.pure(marketFeePrice),
2847
2843
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2848
2844
  ],
2849
2845
  typeArguments: [nftType]
2850
2846
  });
2851
- destroyZeroCoin({ txBlock, coin: coin1 });
2847
+ destroyZeroCoin({ txBlock, coin });
2852
2848
  }
2853
2849
  async function addOriginByteCollectionBidTx({
2854
2850
  txBlock,
2855
2851
  collectionId,
2856
2852
  nftType,
2857
2853
  bidAmount,
2858
- bidder,
2859
2854
  sharedObjects,
2860
2855
  bidderKiosk
2861
2856
  }) {
2862
2857
  const { orderbook } = sharedObjects;
2863
- const parsedBidAmount = Number(parseSUI(bidAmount));
2864
- const marketFeePrice = getMarketFeePrice({
2865
- price: parsedBidAmount,
2866
- collectionId,
2867
- walletId: bidder
2868
- });
2869
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2858
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
2859
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(bidAmount + marketFeePrice)] });
2870
2860
  txBlock.moveCall({
2871
2861
  target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::orderbook::create_bid_with_commission",
2872
2862
  arguments: [
2873
2863
  txBlock.object(orderbook),
2874
2864
  txBlock.object(bidderKiosk),
2875
- txBlock.pure(parsedBidAmount),
2865
+ txBlock.pure(bidAmount),
2876
2866
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
2877
2867
  txBlock.pure(marketFeePrice),
2878
2868
  txBlock.object(coin)
@@ -2929,7 +2919,7 @@ var placeCollectionBids = async ({
2929
2919
  bidder: walletAddress,
2930
2920
  collectionId: collection?.id,
2931
2921
  nftType,
2932
- bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmount
2922
+ bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist
2933
2923
  };
2934
2924
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
2935
2925
  if (isOriginByteTx(txData?.sharedObjects)) {
@@ -2961,22 +2951,17 @@ function addTradePortPlaceNftBidTx({
2961
2951
  collectionId,
2962
2952
  nftTokenId,
2963
2953
  nftType,
2964
- bidAmount,
2965
- bidder
2954
+ bidAmount
2966
2955
  }) {
2967
- const parsedBidAmount = getTradeportBiddingContractParsedBidAmount({ bidAmount, collectionId });
2968
- const marketFeePrice = getMarketFeePrice({
2969
- price: Number(parseSUI(bidAmount)),
2970
- collectionId,
2971
- walletId: bidder
2972
- });
2973
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2956
+ const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
2957
+ const marketFeePrice = getMarketFeePrice({ price: amountToBid, collectionId });
2958
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(amountToBid + marketFeePrice)] });
2974
2959
  txBlock.moveCall({
2975
2960
  target: "0x398aae1ad267d989dcc99ba449b0a30101a6b851ec1284ccddab5937df66bfcf::biddings::bid",
2976
2961
  arguments: [
2977
2962
  txBlock.object(TRADEPORT_BIDDING_STORE),
2978
2963
  txBlock.pure(nftTokenId),
2979
- txBlock.pure(parsedBidAmount),
2964
+ txBlock.pure(amountToBid),
2980
2965
  txBlock.object(coin),
2981
2966
  txBlock.pure(marketFeePrice),
2982
2967
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
@@ -2992,20 +2977,18 @@ function addTradePortKioskPlaceNftBidTx({
2992
2977
  nftTokenId,
2993
2978
  nftType,
2994
2979
  bidAmount,
2995
- bidder,
2996
2980
  royaltyRulePackageId
2997
2981
  }) {
2998
2982
  const { transferPolicy } = sharedObjects;
2999
- const bidPrice = Number(parseSUI(bidAmount));
3000
- const marketFeePrice = getMarketFeePrice({ price: bidPrice, collectionId, walletId: bidder });
2983
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
3001
2984
  const royaltyCoin = txBlock.moveCall({
3002
2985
  target: `${royaltyRulePackageId}::royalty_rule::fee_amount`,
3003
- arguments: [txBlock.object(transferPolicy), txBlock.pure(bidPrice?.toString())],
2986
+ arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount?.toString())],
3004
2987
  typeArguments: [nftType]
3005
2988
  });
3006
2989
  const [coin1, coin2] = splitCoins({
3007
2990
  txBlock,
3008
- amounts: [txBlock.pure(bidPrice + marketFeePrice), txBlock.object(royaltyCoin)]
2991
+ amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(royaltyCoin)]
3009
2992
  });
3010
2993
  txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
3011
2994
  txBlock.moveCall({
@@ -3013,7 +2996,7 @@ function addTradePortKioskPlaceNftBidTx({
3013
2996
  arguments: [
3014
2997
  txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
3015
2998
  txBlock.pure(nftTokenId),
3016
- txBlock.pure(bidPrice),
2999
+ txBlock.pure(bidAmount),
3017
3000
  txBlock.object(coin1),
3018
3001
  txBlock.pure(marketFeePrice),
3019
3002
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
@@ -3034,19 +3017,14 @@ async function addOriginBytePlaceNftBidTx({
3034
3017
  address: bidder,
3035
3018
  createMethod: "create_for_sender"
3036
3019
  });
3037
- const parsedBidAmount = Number(parseSUI(bidAmount));
3038
- const marketFeePrice = getMarketFeePrice({
3039
- price: parsedBidAmount,
3040
- collectionId,
3041
- walletId: bidder
3042
- });
3043
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
3020
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
3021
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(bidAmount + marketFeePrice)] });
3044
3022
  txBlock.moveCall({
3045
3023
  target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::bidding::create_bid_with_commission",
3046
3024
  arguments: [
3047
3025
  isNewBidderKiosk ? txBlock.object(bidderKiosk) : txBlock.pure(bidderKiosk),
3048
3026
  txBlock.pure(nftTokenId),
3049
- txBlock.pure(parsedBidAmount),
3027
+ txBlock.pure(bidAmount),
3050
3028
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
3051
3029
  txBlock.pure(marketFeePrice),
3052
3030
  txBlock.object(coin)
@@ -3093,7 +3071,7 @@ var placeNftBids = async ({
3093
3071
  collectionId: nft?.collection_id,
3094
3072
  nftTokenId: nft?.token_id,
3095
3073
  nftType: nft?.properties?.nft_type || nft?.contract?.properties?.nft_type,
3096
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmount,
3074
+ bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
3097
3075
  sellerKiosk: nft?.chain_state?.kiosk_id
3098
3076
  };
3099
3077
  await addTradePortPlaceNftBidTxHandler(txData);
@@ -3369,8 +3347,8 @@ var removeNftBids = async ({ bidIds }) => {
3369
3347
  var import_transactions10 = require("@mysten/sui.js/transactions");
3370
3348
 
3371
3349
  // src/graphql/queries/fetchCryptoToUsdRate.ts
3372
- var import_graphql_request15 = require("graphql-request");
3373
- var fetchCryptoToUsdRate = import_graphql_request15.gql`
3350
+ var import_graphql_request16 = require("graphql-request");
3351
+ var fetchCryptoToUsdRate = import_graphql_request16.gql`
3374
3352
  query fetchCryptoToUsdRate($crypto: String!) {
3375
3353
  crypto_rates(where: { crypto: { _eq: $crypto }, fiat: { _eq: "USD" } }) {
3376
3354
  crypto
@@ -3408,8 +3386,8 @@ var addOneDollarFee = async (txBlock) => {
3408
3386
  };
3409
3387
 
3410
3388
  // src/graphql/queries/fetchAccountKiosks.ts
3411
- var import_graphql_request16 = require("graphql-request");
3412
- var fetchAccountKiosks2 = import_graphql_request16.gql`
3389
+ var import_graphql_request17 = require("graphql-request");
3390
+ var fetchAccountKiosks2 = import_graphql_request17.gql`
3413
3391
  query fetchAccountKiosks($accountAddress: String!) {
3414
3392
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
3415
3393
  id
@@ -3679,7 +3657,7 @@ var SuiTradingClient = class {
3679
3657
  }
3680
3658
  async placeCollectionBid({
3681
3659
  collectionId,
3682
- bidAmount,
3660
+ bidAmountInMist,
3683
3661
  numOfBids,
3684
3662
  walletAddress
3685
3663
  }) {
@@ -3687,7 +3665,7 @@ var SuiTradingClient = class {
3687
3665
  collections: [
3688
3666
  {
3689
3667
  id: collectionId,
3690
- bidAmount,
3668
+ bidAmountInMist,
3691
3669
  numOfBids
3692
3670
  }
3693
3671
  ],