@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/dist/index.mjs CHANGED
@@ -291,27 +291,50 @@ var getSharedObjects = async (nftType) => {
291
291
  };
292
292
  };
293
293
 
294
- // src/apiClients/kioskClient.ts
295
- import { KioskClient, Network } from "@mysten/kiosk";
296
- var kioskClient = new KioskClient({
297
- // @ts-ignore
298
- client: suiClient_default,
299
- network: Network.MAINNET
300
- });
301
- var kioskClient_default = kioskClient;
294
+ // src/graphql/queries/fetchTransferPoliciesByType.ts
295
+ import { gql as gql6 } from "graphql-request";
296
+ var fetchTransferPoliciesByType = gql6`
297
+ query fetchTransferPoliciesByType($type: String!) {
298
+ transfer_policies_by_type(type: $type) {
299
+ id
300
+ is_origin_byte
301
+ rules
302
+ type
303
+ }
304
+ }
305
+ `;
302
306
 
303
- // src/helpers/hasTransferPolicyRules.ts
304
- var hasTransferPolicyRules = async (nftType) => {
307
+ // src/helpers/kiosk/getKioskTransferPolicies.ts
308
+ var getKioskTransferPolicies = async (nftType) => {
305
309
  const nftTypeSplit = nftType?.split("::");
306
310
  if (nftTypeSplit?.[0])
307
311
  nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
308
- const res = await kioskClient_default.getTransferPolicies({ type: nftTypeSplit?.join("::") });
309
- return res?.some((policy) => policy?.rules?.length > 0);
312
+ const res = await gqlChainRequest({
313
+ chain: "sui",
314
+ query: fetchTransferPoliciesByType,
315
+ variables: { type: nftTypeSplit?.join("::") }
316
+ });
317
+ return res?.transfer_policies_by_type?.filter((policy) => !policy?.is_origin_byte);
318
+ };
319
+
320
+ // src/helpers/hasTransferPolicyRules.ts
321
+ var hasTransferPolicyRules = async (nftType) => {
322
+ const transferPolicies = await getKioskTransferPolicies(nftType);
323
+ return transferPolicies?.some((policy) => policy?.rules?.length > 0);
310
324
  };
311
325
 
312
326
  // src/helpers/kiosk/getRulePackageId.ts
313
327
  import { getNormalizedRuleType } from "@mysten/kiosk";
314
328
 
329
+ // src/apiClients/kioskClient.ts
330
+ import { KioskClient, Network } from "@mysten/kiosk";
331
+ var kioskClient = new KioskClient({
332
+ // @ts-ignore
333
+ client: suiClient_default,
334
+ network: Network.MAINNET
335
+ });
336
+ var kioskClient_default = kioskClient;
337
+
315
338
  // src/utils/addHexPrefix.ts
316
339
  function addHexPrefix(input) {
317
340
  if (input.startsWith("0x")) {
@@ -346,8 +369,8 @@ var isTradePortKioskBid = (bidType) => bidType === TRADEPORT_KIOSK_BID_NONCE_TYP
346
369
  import { KioskTransaction } from "@mysten/kiosk";
347
370
 
348
371
  // src/graphql/queries/fetchKiosksByOwner.ts
349
- import { gql as gql6 } from "graphql-request";
350
- var fetchKiosksByOwner = gql6`
372
+ import { gql as gql7 } from "graphql-request";
373
+ var fetchKiosksByOwner = gql7`
351
374
  query fetchKiosksByOwner($ownerAddress: String!) {
352
375
  kiosks: kiosks_by_owner_address(owner_address: $ownerAddress) {
353
376
  id
@@ -360,8 +383,8 @@ var fetchKiosksByOwner = gql6`
360
383
  `;
361
384
 
362
385
  // src/graphql/queries/fetchOwnerCapByKiosk.ts
363
- import { gql as gql7 } from "graphql-request";
364
- var fetchOwnerCapByKiosk = gql7`
386
+ import { gql as gql8 } from "graphql-request";
387
+ var fetchOwnerCapByKiosk = gql8`
365
388
  query fetchOwnerCapByKiosk($kioskId: String!) {
366
389
  ownerCap: kiosk_owner_cap_by_kiosk(kiosk_id: $kioskId) {
367
390
  id
@@ -371,8 +394,8 @@ var fetchOwnerCapByKiosk = gql7`
371
394
  `;
372
395
 
373
396
  // src/graphql/queries/fetchPersonalCapByKiosk.ts
374
- import { gql as gql8 } from "graphql-request";
375
- var fetchPersonalCapByKiosk = gql8`
397
+ import { gql as gql9 } from "graphql-request";
398
+ var fetchPersonalCapByKiosk = gql9`
376
399
  query fetchPersonalCapByKiosk($kioskId: String!) {
377
400
  personalCap: personal_kiosk_cap_by_kiosk(kiosk_id: $kioskId) {
378
401
  id
@@ -489,8 +512,8 @@ var createOBKiosk = async ({ txBlock, createMethod = "new" }) => {
489
512
  };
490
513
 
491
514
  // src/helpers/originByte/getOBKiosk.ts
492
- import { gql as gql9 } from "graphql-request";
493
- var fetchAccountKiosks = gql9`
515
+ import { gql as gql10 } from "graphql-request";
516
+ var fetchAccountKiosks = gql10`
494
517
  query fetchAccountKiosks($accountAddress: String!) {
495
518
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
496
519
  id
@@ -1518,8 +1541,8 @@ var acceptCollectionBid = async ({
1518
1541
  import { TransactionBlock as TransactionBlock2 } from "@mysten/sui.js/transactions";
1519
1542
 
1520
1543
  // src/graphql/queries/fetchBidsById.ts
1521
- import { gql as gql10 } from "graphql-request";
1522
- var fetchBidsById = gql10`
1544
+ import { gql as gql11 } from "graphql-request";
1545
+ var fetchBidsById = gql11`
1523
1546
  query fetchBidsById($bidIds: [uuid!]) {
1524
1547
  bids(where: { id: { _in: $bidIds } }) {
1525
1548
  nonce
@@ -1607,8 +1630,8 @@ var acceptNftBids = async ({ bidIds }) => {
1607
1630
  import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
1608
1631
 
1609
1632
  // src/graphql/queries/fetchListingsById.ts
1610
- import { gql as gql11 } from "graphql-request";
1611
- var fetchListingsById = gql11`
1633
+ import { gql as gql12 } from "graphql-request";
1634
+ var fetchListingsById = gql12`
1612
1635
  query fetchListingsById($listingIds: [uuid!]) {
1613
1636
  listings(where: { id: { _in: $listingIds } }) {
1614
1637
  seller
@@ -1643,8 +1666,8 @@ var addThirdPartyTxFee = async (txBlock, price) => {
1643
1666
  };
1644
1667
 
1645
1668
  // src/graphql/queries/fetchCommissionByListingId.ts
1646
- import { gql as gql12 } from "graphql-request";
1647
- var fetchCommissionByNftContractId = gql12`
1669
+ import { gql as gql13 } from "graphql-request";
1670
+ var fetchCommissionByNftContractId = gql13`
1648
1671
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
1649
1672
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
1650
1673
  is_custodial
@@ -2365,7 +2388,7 @@ var getDSLLegacyMarketFeePrice = (price) => {
2365
2388
  10
2366
2389
  );
2367
2390
  };
2368
- var getMarketFeePrice = ({ price, collectionId, walletId }) => {
2391
+ var getMarketFeePrice = ({ price, collectionId }) => {
2369
2392
  if (collectionId === "6824e1ff-477e-4810-9ba7-8d6387b68c7d") {
2370
2393
  return getBASCMarketFeePrice(price);
2371
2394
  }
@@ -2385,9 +2408,6 @@ var getMarketFeePrice = ({ price, collectionId, walletId }) => {
2385
2408
  return parseInt(marketFeePrice?.toFixed(0), 10);
2386
2409
  };
2387
2410
 
2388
- // src/utils/parseSUI.ts
2389
- var parseSUI = (num) => parseInt((1e9 * num).toFixed(0), 10);
2390
-
2391
2411
  // src/methods/listNfts/addListTxs.ts
2392
2412
  async function addOriginByteListTx({
2393
2413
  txBlock,
@@ -2413,18 +2433,13 @@ async function addOriginByteListTx({
2413
2433
  nftType
2414
2434
  });
2415
2435
  }
2416
- const parsedListPrice = parseSUI(listPrice);
2417
- const marketFeePrice = getMarketFeePrice({
2418
- price: parsedListPrice,
2419
- collectionId,
2420
- walletId: seller
2421
- });
2436
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2422
2437
  txBlock.moveCall({
2423
2438
  target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::orderbook::create_ask_with_commission",
2424
2439
  arguments: [
2425
2440
  txBlock.object(orderbook),
2426
2441
  txBlock.object(kiosk),
2427
- txBlock.pure(parsedListPrice),
2442
+ txBlock.pure(listPrice),
2428
2443
  txBlock.pure(nftTokenId),
2429
2444
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
2430
2445
  txBlock.pure(marketFeePrice)
@@ -2441,21 +2456,15 @@ function addTradePortListTx({
2441
2456
  borrowedItem,
2442
2457
  nftType,
2443
2458
  collectionId,
2444
- listPrice,
2445
- seller
2459
+ listPrice
2446
2460
  }) {
2447
- const parsedListPrice = parseSUI(listPrice);
2448
- const marketFeePrice = getMarketFeePrice({
2449
- price: parsedListPrice,
2450
- collectionId,
2451
- walletId: seller
2452
- });
2461
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2453
2462
  txBlock.moveCall({
2454
2463
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::list",
2455
2464
  arguments: [
2456
2465
  txBlock.object(TRADEPORT_LISTING_STORE),
2457
2466
  borrowedItem ? txBlock.object(borrowedItem) : txBlock.pure(nftTokenId),
2458
- txBlock.pure(parsedListPrice),
2467
+ txBlock.pure(listPrice),
2459
2468
  txBlock.pure(marketFeePrice),
2460
2469
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2461
2470
  ],
@@ -2468,15 +2477,9 @@ async function addTradePortKioskListTx({
2468
2477
  nftTokenId,
2469
2478
  nftType,
2470
2479
  collectionId,
2471
- listPrice,
2472
- seller
2480
+ listPrice
2473
2481
  }) {
2474
- const parsedListPrice = parseSUI(listPrice);
2475
- const marketFeePrice = getMarketFeePrice({
2476
- price: parsedListPrice,
2477
- collectionId,
2478
- walletId: seller
2479
- });
2482
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2480
2483
  txBlock.moveCall({
2481
2484
  target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_listings::list",
2482
2485
  arguments: [
@@ -2484,7 +2487,7 @@ async function addTradePortKioskListTx({
2484
2487
  txBlock.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
2485
2488
  txBlock.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
2486
2489
  txBlock.pure(nftTokenId),
2487
- txBlock.pure(Number(parsedListPrice) + marketFeePrice),
2490
+ txBlock.pure(listPrice + marketFeePrice),
2488
2491
  txBlock.pure(marketFeePrice),
2489
2492
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2490
2493
  ],
@@ -2549,21 +2552,15 @@ function addTradePortRelistTx({
2549
2552
  nftType,
2550
2553
  collectionId,
2551
2554
  listingNonce,
2552
- listPrice,
2553
- seller
2555
+ listPrice
2554
2556
  }) {
2555
- const parsedListPrice = parseSUI(listPrice);
2556
- const marketFeePrice = getMarketFeePrice({
2557
- price: parsedListPrice,
2558
- collectionId,
2559
- walletId: seller
2560
- });
2557
+ const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2561
2558
  txBlock.moveCall({
2562
2559
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::relist",
2563
2560
  arguments: [
2564
2561
  txBlock.object(TRADEPORT_LISTING_STORE),
2565
2562
  txBlock.pure(listingNonce),
2566
- txBlock.pure(parsedListPrice),
2563
+ txBlock.pure(listPrice),
2567
2564
  txBlock.pure(marketFeePrice),
2568
2565
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2569
2566
  ],
@@ -2675,7 +2672,7 @@ var listNfts = async ({ nfts, walletAddress }) => {
2675
2672
  txBlock,
2676
2673
  sharedObjects,
2677
2674
  nft,
2678
- listPrice: nfts?.find((n) => n.id === nft?.id)?.listPrice,
2675
+ listPrice: nfts?.find((n) => n.id === nft?.id)?.listPriceInMist,
2679
2676
  walletAddress
2680
2677
  });
2681
2678
  } else {
@@ -2686,7 +2683,7 @@ var listNfts = async ({ nfts, walletAddress }) => {
2686
2683
  collectionId: nft?.collection_id,
2687
2684
  nftTokenId: nft?.token_id,
2688
2685
  nftType: getNftTypeFromNft(nft),
2689
- listPrice: nfts?.find((n) => n.id === nft?.id)?.listPrice,
2686
+ listPrice: nfts?.find((n) => n.id === nft?.id)?.listPriceInMist,
2690
2687
  sellerKiosk: nft?.chain_state?.kiosk_id
2691
2688
  };
2692
2689
  await addTradePortListTxHandler(listTxData);
@@ -2699,8 +2696,8 @@ var listNfts = async ({ nfts, walletAddress }) => {
2699
2696
  import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
2700
2697
 
2701
2698
  // src/graphql/queries/fetchCollectionsById.ts
2702
- import { gql as gql13 } from "graphql-request";
2703
- var fetchCollectionsById = gql13`
2699
+ import { gql as gql14 } from "graphql-request";
2700
+ var fetchCollectionsById = gql14`
2704
2701
  query fetchCollectionsById($collectionIds: [uuid!]) {
2705
2702
  collections(where: { id: { _in: $collectionIds } }) {
2706
2703
  id
@@ -2710,7 +2707,7 @@ var fetchCollectionsById = gql13`
2710
2707
  }
2711
2708
  }
2712
2709
  `;
2713
- var fetchCollectionsByIdWithOneNft = gql13`
2710
+ var fetchCollectionsByIdWithOneNft = gql14`
2714
2711
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
2715
2712
  collections(where: { id: { _in: $collectionIds } }) {
2716
2713
  id
@@ -2728,8 +2725,8 @@ var fetchCollectionsByIdWithOneNft = gql13`
2728
2725
  }
2729
2726
  `;
2730
2727
 
2731
- // src/helpers/getTradeportBiddingContractParsedBidAmount.ts
2732
- var getTradeportBiddingContractParsedBidAmount = ({ bidAmount, collectionId }) => {
2728
+ // src/helpers/getTradeportBiddingContractBidAmount.ts
2729
+ var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
2733
2730
  let amount = bidAmount;
2734
2731
  if (collectionId === "8568521c-73a3-4beb-b830-d1ff27a3f1ca") {
2735
2732
  amount = bidAmount - bidAmount * MASC_ROYALTY_DECIMAL_PERCENT;
@@ -2740,17 +2737,14 @@ var getTradeportBiddingContractParsedBidAmount = ({ bidAmount, collectionId }) =
2740
2737
  if (collectionId === "307c7e7a-be3a-43a5-ae44-37f3a37d01f9") {
2741
2738
  amount = bidAmount - bidAmount * DSL_LEGACY_ROYALTY_DECIMAL_PERCENT;
2742
2739
  }
2743
- return Number(parseSUI(amount));
2740
+ return amount;
2744
2741
  };
2745
2742
 
2746
2743
  // src/helpers/hasRoyaltyRule.ts
2747
2744
  var hasRoyaltyRule = async (nftType) => {
2748
- const nftTypeSplit = nftType?.split("::");
2749
- if (nftTypeSplit?.[0])
2750
- nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
2751
- const res = await kioskClient_default.getTransferPolicies({ type: nftTypeSplit?.join("::") });
2752
- return res?.some(
2753
- (policy) => policy?.rules?.filter((rule) => rule?.includes("royalty_rule"))?.length > 0
2745
+ const transferPolicies = await getKioskTransferPolicies(nftType);
2746
+ return transferPolicies?.some(
2747
+ (policy) => policy?.rules?.filter((rule) => rule?.type?.includes("royalty_rule"))?.length > 0
2754
2748
  );
2755
2749
  };
2756
2750
 
@@ -2759,21 +2753,16 @@ function addTradePortCollectionBidTx({
2759
2753
  txBlock,
2760
2754
  collectionId,
2761
2755
  nftType,
2762
- bidAmount,
2763
- bidder
2756
+ bidAmount
2764
2757
  }) {
2765
- const parsedBidAmount = getTradeportBiddingContractParsedBidAmount({ bidAmount, collectionId });
2766
- const marketFeePrice = getMarketFeePrice({
2767
- price: Number(parseSUI(bidAmount)),
2768
- collectionId,
2769
- walletId: bidder
2770
- });
2771
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2758
+ const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
2759
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
2760
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(amountToBid + marketFeePrice)] });
2772
2761
  txBlock.moveCall({
2773
2762
  target: "0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::biddings::collection_bid",
2774
2763
  arguments: [
2775
2764
  txBlock.object(TRADEPORT_BIDDING_STORE),
2776
- txBlock.pure(parsedBidAmount),
2765
+ txBlock.pure(amountToBid),
2777
2766
  txBlock.object(coin),
2778
2767
  txBlock.pure(marketFeePrice),
2779
2768
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
@@ -2788,65 +2777,66 @@ function addTradePortKioskCollectionBidTx({
2788
2777
  nftType,
2789
2778
  bidAmount,
2790
2779
  sharedObjects,
2791
- bidder,
2792
2780
  royaltyRulePackageId,
2793
2781
  royaltyRuleModule
2794
2782
  }) {
2795
2783
  const { transferPolicy } = sharedObjects;
2796
- const parsedBidAmount = Number(parseSUI(bidAmount));
2797
2784
  const marketFeePrice = getMarketFeePrice({
2798
- price: parsedBidAmount,
2799
- collectionId,
2800
- walletId: bidder
2801
- });
2802
- const fee = txBlock.moveCall({
2803
- target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
2804
- arguments: [txBlock.object(transferPolicy), txBlock.pure(parsedBidAmount)],
2805
- typeArguments: [nftType]
2806
- });
2807
- const [coin1, coin2] = splitCoins({
2808
- txBlock,
2809
- amounts: [txBlock.pure(parsedBidAmount + marketFeePrice), txBlock.object(fee)]
2810
- });
2811
- if (!coin1 || !coin2)
2812
- throw new Error("Coin could not be split");
2813
- txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
2785
+ price: bidAmount,
2786
+ collectionId
2787
+ });
2788
+ let coin;
2789
+ if (royaltyRulePackageId && royaltyRuleModule) {
2790
+ const fee = txBlock.moveCall({
2791
+ target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
2792
+ arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount)],
2793
+ typeArguments: [nftType]
2794
+ });
2795
+ const [coin1, coin2] = splitCoins({
2796
+ txBlock,
2797
+ amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(fee)]
2798
+ });
2799
+ coin = coin1;
2800
+ if (!coin1 || !coin2)
2801
+ throw new Error("Coin could not be split");
2802
+ txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
2803
+ } else {
2804
+ const [coin1] = splitCoins({
2805
+ txBlock,
2806
+ amounts: [txBlock.pure(bidAmount + marketFeePrice)]
2807
+ });
2808
+ coin = coin1;
2809
+ }
2814
2810
  txBlock.moveCall({
2815
2811
  target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::collection_bid",
2816
2812
  arguments: [
2817
2813
  txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
2818
- txBlock.pure(parsedBidAmount),
2819
- txBlock.object(coin1),
2814
+ txBlock.pure(bidAmount),
2815
+ txBlock.object(coin),
2820
2816
  txBlock.pure(marketFeePrice),
2821
2817
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
2822
2818
  ],
2823
2819
  typeArguments: [nftType]
2824
2820
  });
2825
- destroyZeroCoin({ txBlock, coin: coin1 });
2821
+ destroyZeroCoin({ txBlock, coin });
2826
2822
  }
2827
2823
  async function addOriginByteCollectionBidTx({
2828
2824
  txBlock,
2829
2825
  collectionId,
2830
2826
  nftType,
2831
2827
  bidAmount,
2832
- bidder,
2833
2828
  sharedObjects,
2834
2829
  bidderKiosk
2835
2830
  }) {
2836
2831
  const { orderbook } = sharedObjects;
2837
- const parsedBidAmount = Number(parseSUI(bidAmount));
2838
- const marketFeePrice = getMarketFeePrice({
2839
- price: parsedBidAmount,
2840
- collectionId,
2841
- walletId: bidder
2842
- });
2843
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2832
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
2833
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(bidAmount + marketFeePrice)] });
2844
2834
  txBlock.moveCall({
2845
2835
  target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::orderbook::create_bid_with_commission",
2846
2836
  arguments: [
2847
2837
  txBlock.object(orderbook),
2848
2838
  txBlock.object(bidderKiosk),
2849
- txBlock.pure(parsedBidAmount),
2839
+ txBlock.pure(bidAmount),
2850
2840
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
2851
2841
  txBlock.pure(marketFeePrice),
2852
2842
  txBlock.object(coin)
@@ -2903,7 +2893,7 @@ var placeCollectionBids = async ({
2903
2893
  bidder: walletAddress,
2904
2894
  collectionId: collection?.id,
2905
2895
  nftType,
2906
- bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmount
2896
+ bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist
2907
2897
  };
2908
2898
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
2909
2899
  if (isOriginByteTx(txData?.sharedObjects)) {
@@ -2935,22 +2925,17 @@ function addTradePortPlaceNftBidTx({
2935
2925
  collectionId,
2936
2926
  nftTokenId,
2937
2927
  nftType,
2938
- bidAmount,
2939
- bidder
2928
+ bidAmount
2940
2929
  }) {
2941
- const parsedBidAmount = getTradeportBiddingContractParsedBidAmount({ bidAmount, collectionId });
2942
- const marketFeePrice = getMarketFeePrice({
2943
- price: Number(parseSUI(bidAmount)),
2944
- collectionId,
2945
- walletId: bidder
2946
- });
2947
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2930
+ const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
2931
+ const marketFeePrice = getMarketFeePrice({ price: amountToBid, collectionId });
2932
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(amountToBid + marketFeePrice)] });
2948
2933
  txBlock.moveCall({
2949
2934
  target: "0x398aae1ad267d989dcc99ba449b0a30101a6b851ec1284ccddab5937df66bfcf::biddings::bid",
2950
2935
  arguments: [
2951
2936
  txBlock.object(TRADEPORT_BIDDING_STORE),
2952
2937
  txBlock.pure(nftTokenId),
2953
- txBlock.pure(parsedBidAmount),
2938
+ txBlock.pure(amountToBid),
2954
2939
  txBlock.object(coin),
2955
2940
  txBlock.pure(marketFeePrice),
2956
2941
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
@@ -2966,20 +2951,18 @@ function addTradePortKioskPlaceNftBidTx({
2966
2951
  nftTokenId,
2967
2952
  nftType,
2968
2953
  bidAmount,
2969
- bidder,
2970
2954
  royaltyRulePackageId
2971
2955
  }) {
2972
2956
  const { transferPolicy } = sharedObjects;
2973
- const bidPrice = Number(parseSUI(bidAmount));
2974
- const marketFeePrice = getMarketFeePrice({ price: bidPrice, collectionId, walletId: bidder });
2957
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
2975
2958
  const royaltyCoin = txBlock.moveCall({
2976
2959
  target: `${royaltyRulePackageId}::royalty_rule::fee_amount`,
2977
- arguments: [txBlock.object(transferPolicy), txBlock.pure(bidPrice?.toString())],
2960
+ arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount?.toString())],
2978
2961
  typeArguments: [nftType]
2979
2962
  });
2980
2963
  const [coin1, coin2] = splitCoins({
2981
2964
  txBlock,
2982
- amounts: [txBlock.pure(bidPrice + marketFeePrice), txBlock.object(royaltyCoin)]
2965
+ amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(royaltyCoin)]
2983
2966
  });
2984
2967
  txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
2985
2968
  txBlock.moveCall({
@@ -2987,7 +2970,7 @@ function addTradePortKioskPlaceNftBidTx({
2987
2970
  arguments: [
2988
2971
  txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
2989
2972
  txBlock.pure(nftTokenId),
2990
- txBlock.pure(bidPrice),
2973
+ txBlock.pure(bidAmount),
2991
2974
  txBlock.object(coin1),
2992
2975
  txBlock.pure(marketFeePrice),
2993
2976
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS)
@@ -3008,19 +2991,14 @@ async function addOriginBytePlaceNftBidTx({
3008
2991
  address: bidder,
3009
2992
  createMethod: "create_for_sender"
3010
2993
  });
3011
- const parsedBidAmount = Number(parseSUI(bidAmount));
3012
- const marketFeePrice = getMarketFeePrice({
3013
- price: parsedBidAmount,
3014
- collectionId,
3015
- walletId: bidder
3016
- });
3017
- const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(parsedBidAmount + marketFeePrice)] });
2994
+ const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
2995
+ const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(bidAmount + marketFeePrice)] });
3018
2996
  txBlock.moveCall({
3019
2997
  target: "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::bidding::create_bid_with_commission",
3020
2998
  arguments: [
3021
2999
  isNewBidderKiosk ? txBlock.object(bidderKiosk) : txBlock.pure(bidderKiosk),
3022
3000
  txBlock.pure(nftTokenId),
3023
- txBlock.pure(parsedBidAmount),
3001
+ txBlock.pure(bidAmount),
3024
3002
  txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
3025
3003
  txBlock.pure(marketFeePrice),
3026
3004
  txBlock.object(coin)
@@ -3067,7 +3045,7 @@ var placeNftBids = async ({
3067
3045
  collectionId: nft?.collection_id,
3068
3046
  nftTokenId: nft?.token_id,
3069
3047
  nftType: nft?.properties?.nft_type || nft?.contract?.properties?.nft_type,
3070
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmount,
3048
+ bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
3071
3049
  sellerKiosk: nft?.chain_state?.kiosk_id
3072
3050
  };
3073
3051
  await addTradePortPlaceNftBidTxHandler(txData);
@@ -3343,8 +3321,8 @@ var removeNftBids = async ({ bidIds }) => {
3343
3321
  import { TransactionBlock as TransactionBlock10 } from "@mysten/sui.js/transactions";
3344
3322
 
3345
3323
  // src/graphql/queries/fetchCryptoToUsdRate.ts
3346
- import { gql as gql14 } from "graphql-request";
3347
- var fetchCryptoToUsdRate = gql14`
3324
+ import { gql as gql15 } from "graphql-request";
3325
+ var fetchCryptoToUsdRate = gql15`
3348
3326
  query fetchCryptoToUsdRate($crypto: String!) {
3349
3327
  crypto_rates(where: { crypto: { _eq: $crypto }, fiat: { _eq: "USD" } }) {
3350
3328
  crypto
@@ -3382,8 +3360,8 @@ var addOneDollarFee = async (txBlock) => {
3382
3360
  };
3383
3361
 
3384
3362
  // src/graphql/queries/fetchAccountKiosks.ts
3385
- import { gql as gql15 } from "graphql-request";
3386
- var fetchAccountKiosks2 = gql15`
3363
+ import { gql as gql16 } from "graphql-request";
3364
+ var fetchAccountKiosks2 = gql16`
3387
3365
  query fetchAccountKiosks($accountAddress: String!) {
3388
3366
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
3389
3367
  id
@@ -3653,7 +3631,7 @@ var SuiTradingClient = class {
3653
3631
  }
3654
3632
  async placeCollectionBid({
3655
3633
  collectionId,
3656
- bidAmount,
3634
+ bidAmountInMist,
3657
3635
  numOfBids,
3658
3636
  walletAddress
3659
3637
  }) {
@@ -3661,7 +3639,7 @@ var SuiTradingClient = class {
3661
3639
  collections: [
3662
3640
  {
3663
3641
  id: collectionId,
3664
- bidAmount,
3642
+ bidAmountInMist,
3665
3643
  numOfBids
3666
3644
  }
3667
3645
  ],