@tradeport/sui-trading-sdk 0.1.12 → 0.1.14

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.1.14
4
+
5
+ ### Patch Changes
6
+
7
+ - cd4da4d: Updated to new personal kiosk compatible kiosk_biddings and kiosk_transfers modules
8
+
9
+ ## 0.1.13
10
+
11
+ ### Patch Changes
12
+
13
+ - 7157dff: Fixed exerciseShortLocks
14
+
3
15
  ## 0.1.12
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -874,15 +874,13 @@ async function addTradeportKioskAcceptNftBidTx({
874
874
  }) {
875
875
  const { transferPolicy } = sharedObjects;
876
876
  const [feeCoin, transferRequest] = tx.moveCall({
877
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::accept_bid",
877
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_biddings::accept_bid_with_purchase_cap",
878
878
  arguments: [
879
879
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
880
880
  tx.pure.address(bidNonce),
881
- tx.object(TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK),
882
881
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
883
882
  tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
884
- tx.pure.address(nftTokenId),
885
- tx.object(transferPolicy)
883
+ tx.pure.address(nftTokenId)
886
884
  ],
887
885
  typeArguments: [nftType]
888
886
  });
@@ -897,7 +895,6 @@ async function addTradeportKioskAcceptNftBidTx({
897
895
  nftType,
898
896
  price: "0",
899
897
  transferRequest,
900
- kioskToLockRuleProve: TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK,
901
898
  shouldSkipKioskLocking: true,
902
899
  shouldSkipResolvingRoyaltyRule: true
903
900
  });
@@ -1026,7 +1023,7 @@ async function addTradePortKioskUnlistTx({
1026
1023
  nftType
1027
1024
  }) {
1028
1025
  tx.moveCall({
1029
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_listings::unlist",
1026
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_listings::unlist",
1030
1027
  arguments: [
1031
1028
  tx.object(TRADEPORT_KIOSK_LISTING_STORE),
1032
1029
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
@@ -1827,9 +1824,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
1827
1824
  query: fetchBidsById,
1828
1825
  variables: { bidIds: [bidId] }
1829
1826
  });
1830
- bid = res.bids.find(
1831
- (bid2) => bid2.status === "active"
1832
- );
1827
+ bid = res.bids.find((bid2) => bid2.status === "active");
1833
1828
  if (!bid) {
1834
1829
  throw new Error(`Active bid ${bidId} is missing for ${lock.nft_type}`);
1835
1830
  }
@@ -2026,7 +2021,7 @@ var addTradeportKioskBuyTx = async ({
2026
2021
  if (!coin)
2027
2022
  throw new Error("Coin could not be split");
2028
2023
  const [kioskItem, transferRequest, kioskPrice] = tx.moveCall({
2029
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_listings::buy",
2024
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_listings::buy",
2030
2025
  arguments: [
2031
2026
  tx.object(TRADEPORT_KIOSK_LISTING_STORE),
2032
2027
  tx.object(sellerKiosk),
@@ -2544,7 +2539,7 @@ var addClaimAcceptedBidNftTx = async ({
2544
2539
  }) => {
2545
2540
  const { transferPolicy } = sharedObjects;
2546
2541
  const [transferRequest] = tx.moveCall({
2547
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::claim_bid",
2542
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_biddings::claim_bid",
2548
2543
  arguments: [
2549
2544
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
2550
2545
  tx.object(TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK),
@@ -2564,6 +2559,36 @@ var addClaimAcceptedBidNftTx = async ({
2564
2559
  shouldSkipKioskLocking: true
2565
2560
  });
2566
2561
  };
2562
+ var addClaimAcceptedBidNftWithPurchaseCapTx = async ({
2563
+ tx,
2564
+ kioskTx,
2565
+ sharedObjects,
2566
+ nftTokenId,
2567
+ nftType,
2568
+ sellerKiosk
2569
+ }) => {
2570
+ const { transferPolicy } = sharedObjects;
2571
+ const [transferRequest] = tx.moveCall({
2572
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_biddings::claim_bid_with_purchase_cap",
2573
+ arguments: [
2574
+ tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
2575
+ tx.object(sellerKiosk),
2576
+ tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
2577
+ tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
2578
+ tx.pure.address(nftTokenId),
2579
+ tx.object(transferPolicy)
2580
+ ],
2581
+ typeArguments: [nftType]
2582
+ });
2583
+ await resolveTransferPolicies({
2584
+ tx,
2585
+ kioskTx,
2586
+ nftType,
2587
+ price: "0",
2588
+ transferRequest,
2589
+ shouldSkipKioskLocking: true
2590
+ });
2591
+ };
2567
2592
  var addClaimTransferredNftTx = async ({
2568
2593
  tx,
2569
2594
  sharedObjects,
@@ -2573,7 +2598,7 @@ var addClaimTransferredNftTx = async ({
2573
2598
  }) => {
2574
2599
  const { transferPolicy } = sharedObjects;
2575
2600
  const [transferRequest] = tx.moveCall({
2576
- target: "0x78eae99d1a7edae714b5de107f4b44ccbdf5f9ca6919498d9b024ef378dc13f7::kiosk_transfers::claim",
2601
+ target: "0x49642273ca7db3d942f9fd810c93467974c40e73ea7f03e8e7a632f1222aca73::kiosk_transfers::claim",
2577
2602
  arguments: [
2578
2603
  tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
2579
2604
  tx.object(TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK),
@@ -2593,6 +2618,36 @@ var addClaimTransferredNftTx = async ({
2593
2618
  shouldSkipKioskLocking: true
2594
2619
  });
2595
2620
  };
2621
+ var addClaimTransferredNftWithPurchaseCapTx = async ({
2622
+ tx,
2623
+ sharedObjects,
2624
+ kioskTx,
2625
+ nftTokenId,
2626
+ nftType,
2627
+ sellerKiosk
2628
+ }) => {
2629
+ const { transferPolicy } = sharedObjects;
2630
+ const [transferRequest] = tx.moveCall({
2631
+ target: "0x49642273ca7db3d942f9fd810c93467974c40e73ea7f03e8e7a632f1222aca73::kiosk_transfers::claim_with_purchase_cap",
2632
+ arguments: [
2633
+ tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
2634
+ tx.object(sellerKiosk),
2635
+ tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
2636
+ tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
2637
+ tx.pure.address(nftTokenId),
2638
+ tx.object(transferPolicy)
2639
+ ],
2640
+ typeArguments: [nftType]
2641
+ });
2642
+ await resolveTransferPolicies({
2643
+ tx,
2644
+ kioskTx,
2645
+ nftType,
2646
+ price: "0",
2647
+ transferRequest,
2648
+ shouldSkipKioskLocking: true
2649
+ });
2650
+ };
2596
2651
 
2597
2652
  // src/methods/claimNfts/claimNfts.ts
2598
2653
  var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context) => {
@@ -2639,14 +2694,25 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context) => {
2639
2694
  nftTokenId: nft?.token_id,
2640
2695
  sellerKiosk: nft?.chain_state?.kiosk_id
2641
2696
  };
2642
- await kioskTxWrapper({
2643
- tx,
2644
- kioskOwner: txData?.claimer,
2645
- kiosk: txData?.sellerKiosk,
2646
- async runCommands(kioskTx) {
2647
- await addClaimAcceptedBidNftTx({ ...txData, kioskTx });
2648
- }
2649
- });
2697
+ try {
2698
+ await kioskTxWrapper({
2699
+ tx,
2700
+ kioskOwner: txData?.claimer,
2701
+ kiosk: txData?.sellerKiosk,
2702
+ async runCommands(kioskTx) {
2703
+ await addClaimAcceptedBidNftWithPurchaseCapTx({ ...txData, kioskTx });
2704
+ }
2705
+ });
2706
+ } catch {
2707
+ await kioskTxWrapper({
2708
+ tx,
2709
+ kioskOwner: txData?.claimer,
2710
+ kiosk: txData?.sellerKiosk,
2711
+ async runCommands(kioskTx) {
2712
+ await addClaimAcceptedBidNftTx({ ...txData, kioskTx });
2713
+ }
2714
+ });
2715
+ }
2650
2716
  continue;
2651
2717
  }
2652
2718
  if (nft?.chain_state?.claimable_reason === "offer-transfer") {
@@ -2658,14 +2724,25 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context) => {
2658
2724
  nftTokenId: nft?.token_id,
2659
2725
  sellerKiosk: nft?.chain_state?.kiosk_id
2660
2726
  };
2661
- await kioskTxWrapper({
2662
- tx,
2663
- kioskOwner: txData?.claimer,
2664
- kiosk: txData?.sellerKiosk,
2665
- async runCommands(kioskTx) {
2666
- await addClaimTransferredNftTx({ ...txData, kioskTx });
2667
- }
2668
- });
2727
+ try {
2728
+ await kioskTxWrapper({
2729
+ tx,
2730
+ kioskOwner: txData?.claimer,
2731
+ kiosk: txData?.sellerKiosk,
2732
+ async runCommands(kioskTx) {
2733
+ await addClaimTransferredNftWithPurchaseCapTx({ ...txData, kioskTx });
2734
+ }
2735
+ });
2736
+ } catch {
2737
+ await kioskTxWrapper({
2738
+ tx,
2739
+ kioskOwner: txData?.claimer,
2740
+ kiosk: txData?.sellerKiosk,
2741
+ async runCommands(kioskTx) {
2742
+ await addClaimTransferredNftTx({ ...txData, kioskTx });
2743
+ }
2744
+ });
2745
+ }
2669
2746
  }
2670
2747
  nftsForTracking.push({
2671
2748
  nftType: getNftTypeFromNft(nft),
@@ -2794,52 +2871,53 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
2794
2871
  }
2795
2872
  const transferPolicyId = transferPolicy?.id;
2796
2873
  const sharedObjects = await getSharedObjects(lock.nft_type);
2874
+ if (lock.nft?.token_id) {
2875
+ throw new Error(`The short lock ${lockId} must not have any nft`);
2876
+ }
2877
+ let requiredCoins = BigInt(lock.maker_price) + calculateRoyaltyFee(transferPolicy.rules, 0n);
2878
+ let listing = null;
2879
+ if (listingId) {
2880
+ const res = await gqlChainRequest({
2881
+ chain: "sui",
2882
+ query: fetchListingsById,
2883
+ variables: { listingIds: [listingId] }
2884
+ });
2885
+ listing = res.listings[0];
2886
+ if (!listing) {
2887
+ throw new Error(`Missing listing ${listingId}`);
2888
+ }
2889
+ }
2890
+ if (listing) {
2891
+ if (nftId && listing.nft.id !== nftId) {
2892
+ throw new Error(`The listing ${listingId} must be for token ${listing.nft.token_id}`);
2893
+ }
2894
+ if (!nftId) {
2895
+ nftId = listing.nft.id;
2896
+ }
2897
+ if (listing.nonce && isOriginByteTx(sharedObjects) || !listing.nft?.chain_state?.kiosk_id) {
2898
+ throw new Error(`The listing ${listingId} must be for native kiosk`);
2899
+ }
2900
+ requiredCoins += calculateRoyaltyFee(transferPolicy.rules, BigInt(listing.price));
2901
+ }
2902
+ if (!nftId) {
2903
+ throw new Error(`nftId is required for shorts`);
2904
+ }
2905
+ const nft = (await gqlChainRequest({
2906
+ chain: "sui",
2907
+ query: fetchNftById,
2908
+ variables: { nftId }
2909
+ }))?.nfts?.[0];
2910
+ if (!nft) {
2911
+ throw new Error(`No nft ${nftId} found`);
2912
+ }
2913
+ if (!listing && nft.owner !== walletAddress) {
2914
+ throw new Error(`The nft ${nftId} must be owned by ${walletAddress}`);
2915
+ }
2797
2916
  await kioskTxWrapper({
2798
2917
  tx,
2799
2918
  kioskOwner: walletAddress,
2919
+ kiosk: nft?.chain_state?.kiosk_id,
2800
2920
  async runCommands(kioskTx) {
2801
- if (lock.nft?.token_id) {
2802
- throw new Error(`The short lock ${lockId} must not have any nft`);
2803
- }
2804
- let requiredCoins = BigInt(lock.maker_price) + calculateRoyaltyFee(transferPolicy.rules, 0n);
2805
- let listing = null;
2806
- if (listingId) {
2807
- const res = await gqlChainRequest({
2808
- chain: "sui",
2809
- query: fetchListingsById,
2810
- variables: { listingIds: [listingId] }
2811
- });
2812
- listing = res.listings[0];
2813
- if (!listing) {
2814
- throw new Error(`Missing listing ${listingId}`);
2815
- }
2816
- }
2817
- if (listing) {
2818
- if (nftId && listing.nft.id !== nftId) {
2819
- throw new Error(`The listing ${listingId} must be for token ${listing.nft.token_id}`);
2820
- }
2821
- if (!nftId) {
2822
- nftId = listing.nft.id;
2823
- }
2824
- if (listing.nonce && isOriginByteTx(sharedObjects) || !listing.nft?.chain_state?.kiosk_id) {
2825
- throw new Error(`The listing ${listingId} must be for native kiosk`);
2826
- }
2827
- requiredCoins += calculateRoyaltyFee(transferPolicy.rules, BigInt(listing.price));
2828
- }
2829
- if (!nftId) {
2830
- throw new Error(`nftId is required for shorts`);
2831
- }
2832
- const nft = (await gqlChainRequest({
2833
- chain: "sui",
2834
- query: fetchNftById,
2835
- variables: { nftId }
2836
- }))?.nfts?.[0];
2837
- if (!nft) {
2838
- throw new Error(`No nft ${nftId} found`);
2839
- }
2840
- if (!listing && nft.owner !== walletAddress) {
2841
- throw new Error(`The nft ${nftId} must be owned by ${walletAddress}`);
2842
- }
2843
2921
  const [request] = tx.moveCall({
2844
2922
  target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::start_confirm_short_lock`,
2845
2923
  typeArguments: [lock.nft_type],
@@ -2882,6 +2960,7 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
2882
2960
  nftType: lock.nft_type,
2883
2961
  price: "0",
2884
2962
  transferRequest,
2963
+ kioskToLockRuleProve: TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK,
2885
2964
  shouldSkipKioskLocking: true
2886
2965
  });
2887
2966
  }
@@ -2966,7 +3045,7 @@ async function addTradePortKioskListTx({
2966
3045
  }) {
2967
3046
  const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
2968
3047
  tx.moveCall({
2969
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_listings::list",
3048
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_listings::list",
2970
3049
  arguments: [
2971
3050
  tx.object(TRADEPORT_KIOSK_LISTING_STORE),
2972
3051
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
@@ -3309,7 +3388,7 @@ function addTradePortKioskCollectionBidTx({
3309
3388
  coin = coin1;
3310
3389
  }
3311
3390
  tx.moveCall({
3312
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::collection_bid",
3391
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_biddings::collection_bid",
3313
3392
  arguments: [
3314
3393
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
3315
3394
  tx.pure.u64(bidAmount),
@@ -3475,7 +3554,7 @@ function addTradePortKioskPlaceNftBidTx({
3475
3554
  });
3476
3555
  tx.mergeCoins(tx.object(coin1), [tx.object(coin2)]);
3477
3556
  tx.moveCall({
3478
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::bid",
3557
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_biddings::bid",
3479
3558
  arguments: [
3480
3559
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
3481
3560
  tx.pure.address(nftTokenId),
@@ -3580,7 +3659,7 @@ function addTradeportRemoveNftBidTx({ tx, bidNonce, nftType }) {
3580
3659
  }
3581
3660
  function addTradeportKioskRemoveNftBidTx({ tx, bidNonce, nftType }) {
3582
3661
  tx.moveCall({
3583
- target: "0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::cancel_bid",
3662
+ target: "0xc94af80a10796ad0732cca33b38a858f712256da0763a65bafb2a63cf3e6a0d0::kiosk_biddings::cancel_bid",
3584
3663
  arguments: [tx.object(TRADEPORT_KIOSK_BIDDING_STORE), tx.pure.address(bidNonce)],
3585
3664
  typeArguments: [nftType]
3586
3665
  });
@@ -3938,35 +4017,22 @@ async function addOriginByteTransferNftTx({
3938
4017
  }
3939
4018
  async function addTradeportKioskTransferTx({
3940
4019
  tx,
3941
- sharedObjects,
3942
4020
  kioskTx,
3943
4021
  nftTokenId,
3944
4022
  nftType,
3945
4023
  recipientAddress
3946
4024
  }) {
3947
- const { transferPolicy } = sharedObjects;
3948
- const [transferRequest] = tx.moveCall({
3949
- target: "0x78eae99d1a7edae714b5de107f4b44ccbdf5f9ca6919498d9b024ef378dc13f7::kiosk_transfers::transfer",
4025
+ tx.moveCall({
4026
+ target: "0x49642273ca7db3d942f9fd810c93467974c40e73ea7f03e8e7a632f1222aca73::kiosk_transfers::transfer_with_purchase_capability",
3950
4027
  arguments: [
3951
4028
  tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
3952
- tx.object(TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK),
3953
4029
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
3954
4030
  tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
3955
4031
  tx.pure.address(nftTokenId),
3956
- tx.pure.address(addLeadingZerosAfter0x(recipientAddress)),
3957
- tx.object(transferPolicy)
4032
+ tx.pure.address(addLeadingZerosAfter0x(recipientAddress))
3958
4033
  ],
3959
4034
  typeArguments: [nftType]
3960
4035
  });
3961
- await resolveTransferPolicies({
3962
- tx,
3963
- kioskTx,
3964
- nftType,
3965
- price: "0",
3966
- transferRequest,
3967
- kioskToLockRuleProve: TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK,
3968
- shouldSkipKioskLocking: true
3969
- });
3970
4036
  }
3971
4037
 
3972
4038
  // src/methods/transferNfts/transferNfts.ts