@tradeport/sui-trading-sdk 0.1.22 → 0.1.24

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.24
4
+
5
+ ### Patch Changes
6
+
7
+ - b28ad7b: Fixed price locks
8
+
9
+ ## 0.1.23
10
+
11
+ ### Patch Changes
12
+
13
+ - ce63fb8: Fixed price lock issues
14
+
3
15
  ## 0.1.22
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -11,6 +11,7 @@ type AcceptNftBids = {
11
11
  bidIds: string[];
12
12
  tx?: Transaction;
13
13
  kioskTx?: KioskTransaction;
14
+ beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
14
15
  };
15
16
 
16
17
  type BuyAndExerciseLongLocks = {
@@ -27,6 +28,7 @@ type BuyListings = {
27
28
  walletAddress: string;
28
29
  tx?: Transaction;
29
30
  kioskTx?: KioskTransaction;
31
+ beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
30
32
  };
31
33
 
32
34
  type BuyLocks = {
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ type AcceptNftBids = {
11
11
  bidIds: string[];
12
12
  tx?: Transaction;
13
13
  kioskTx?: KioskTransaction;
14
+ beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
14
15
  };
15
16
 
16
17
  type BuyAndExerciseLongLocks = {
@@ -27,6 +28,7 @@ type BuyListings = {
27
28
  walletAddress: string;
28
29
  tx?: Transaction;
29
30
  kioskTx?: KioskTransaction;
31
+ beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
30
32
  };
31
33
 
32
34
  type BuyLocks = {
package/dist/index.js CHANGED
@@ -200,8 +200,8 @@ var TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK = "0xa677dab85a93bd8d6845b6cc7914f3bb
200
200
  var TRADEPORT_KIOSK_BIDDING_STORE = "0x1e5e7f38e3a61d1d189506d0fc6b7e47e935a292d9e1b23c0f3f1c0f94227772";
201
201
  var TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK = "0x151fbe627d3f8de855f424c879ea2176d89282185a4b9226a7157172dd2919cc";
202
202
  var TRADEPORT_KIOSK_BID_NONCE_TYPE = "0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Bid";
203
- var TRADEPORT_PRICE_LOCK_PACKAGE = "0x5a3fd22413e0340f27353cb2f1b693f1ec83587e979fd07a099ec9793aabbf14";
204
- var TRADEPORT_PRICE_LOCK_STORE = "0x56fa8d9303151c699c02931dc911c1974674355c5901d6ebf21ba18ee491586a";
203
+ var TRADEPORT_PRICE_LOCK_PACKAGE = "0x027c64473c0b9bc5364a22a08e7fc9af059151433b4e631c4baf25f540426977";
204
+ var TRADEPORT_PRICE_LOCK_STORE = "0xaf60ed2cb8c671dcc27e5721371869f0ae9c508297a011716244b50ec12d02a1";
205
205
  var COLLECTION_IDS_WITH_ZERO_COMMISSION = [
206
206
  ""
207
207
  ];
@@ -243,7 +243,6 @@ var MASC_ROYALTY_DECIMAL_PERCENT = 0.085;
243
243
  var BASC_ROYALTY_DECIMAL_PERCENT = 0.055;
244
244
  var DSL_LEGACY_ROYALTY_DECIMAL_PERCENT = 0.05;
245
245
  var PREMIUM_NOMINATOR = 300n;
246
- var PREMIUM_FEE_NOMINATOR = 2500n;
247
246
  var ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK = [
248
247
  "0xc4fc5b341858ac6fff4859d8105e345b195847cd230e8538d61a2f319ae8093c::bluemove_launchpad::GOATsOfSui"
249
248
  ];
@@ -870,7 +869,8 @@ async function addTradeportKioskAcceptNftBidTx({
870
869
  nftTokenId,
871
870
  nftType,
872
871
  royaltyRulePackageId,
873
- royaltyRuleModule
872
+ royaltyRuleModule,
873
+ beforeResolveKioskTransferRequest
874
874
  }) {
875
875
  const { transferPolicy } = sharedObjects;
876
876
  const [feeCoin, transferRequest] = tx.moveCall({
@@ -889,6 +889,7 @@ async function addTradeportKioskAcceptNftBidTx({
889
889
  typeArguments: [nftType],
890
890
  arguments: [tx.object(transferPolicy), transferRequest, feeCoin]
891
891
  });
892
+ await beforeResolveKioskTransferRequest?.(transferRequest);
892
893
  await resolveTransferPolicies({
893
894
  tx,
894
895
  kioskTx,
@@ -1501,7 +1502,14 @@ function addTocenAcceptCollectionBidTxHandler(txData) {
1501
1502
 
1502
1503
  // src/methods/acceptCollectionBid/acceptCollectionBid.ts
1503
1504
  var ERROR_UNLIST_FIRST = "Item must be unlisted first before you can accept a collection bid with it";
1504
- var acceptCollectionBid = async ({ bid, nftId, walletAddress, tx: existingTx, kioskTx }, context) => {
1505
+ var acceptCollectionBid = async ({
1506
+ bid,
1507
+ nftId,
1508
+ walletAddress,
1509
+ tx: existingTx,
1510
+ kioskTx,
1511
+ beforeResolveKioskTransferRequest
1512
+ }, context) => {
1505
1513
  const nftRes = await gqlChainRequest({
1506
1514
  chain: "sui",
1507
1515
  query: fetchNftById,
@@ -1532,7 +1540,8 @@ var acceptCollectionBid = async ({ bid, nftId, walletAddress, tx: existingTx, ki
1532
1540
  sellerKiosk: nft?.chain_state?.kiosk_id,
1533
1541
  collectionId: nft?.collection_id,
1534
1542
  isListedOnBluemove: nft?.listings?.[0]?.market_name === "bluemove",
1535
- bidMarketName: bid?.market_contract?.name
1543
+ bidMarketName: bid?.market_contract?.name,
1544
+ beforeResolveKioskTransferRequest
1536
1545
  };
1537
1546
  switch (txData.bidMarketName) {
1538
1547
  case "tradeport":
@@ -1607,7 +1616,7 @@ var fetchBidsById = import_graphql_request12.gql`
1607
1616
 
1608
1617
  // src/methods/acceptNftBids/acceptNftBids.ts
1609
1618
  var ERROR_UNLIST_FIRST2 = "Item must be unlisted first before you can accept a solo bid on it";
1610
- var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx }, context) => {
1619
+ var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx, beforeResolveKioskTransferRequest }, context) => {
1611
1620
  const res = await gqlChainRequest({
1612
1621
  chain: "sui",
1613
1622
  query: fetchBidsById,
@@ -1640,7 +1649,8 @@ var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx }, context) => {
1640
1649
  bidAmount: bid?.price,
1641
1650
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
1642
1651
  isListedOnBluemove: bid?.nft?.listings?.[0]?.market_name === "bluemove",
1643
- bidMarketName: bid?.market_contract?.name
1652
+ bidMarketName: bid?.market_contract?.name,
1653
+ beforeResolveKioskTransferRequest
1644
1654
  };
1645
1655
  switch (txData.bidMarketName) {
1646
1656
  case "tradeport":
@@ -1683,9 +1693,6 @@ var import_transactions3 = require("@mysten/sui/transactions");
1683
1693
  function calculatePremium(price) {
1684
1694
  return BigInt(price) * PREMIUM_NOMINATOR / 10000n;
1685
1695
  }
1686
- function calculatePremiumFee(premium) {
1687
- return BigInt(premium) * PREMIUM_FEE_NOMINATOR / 10000n;
1688
- }
1689
1696
 
1690
1697
  // src/graphql/queries/fetchLockById.ts
1691
1698
  var import_graphql_request13 = require("graphql-request");
@@ -1732,8 +1739,7 @@ async function buyLocks({ lockIds, transaction }) {
1732
1739
  throw new Error(`Lock ${lockId} must be in active state`);
1733
1740
  }
1734
1741
  const premiumAmount = calculatePremium(lock.maker_price);
1735
- const premiumFee = calculatePremiumFee(premiumAmount);
1736
- const [premium] = tx.splitCoins(tx.gas, [premiumAmount + premiumFee]);
1742
+ const [premium] = tx.splitCoins(tx.gas, [premiumAmount]);
1737
1743
  tx.moveCall({
1738
1744
  target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::buy_lock`,
1739
1745
  typeArguments: [lock.nft_type],
@@ -1850,11 +1856,11 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
1850
1856
  collectionId: lock.collection_id
1851
1857
  })
1852
1858
  );
1853
- const [creatorRewardWithFee] = tx.splitCoins(tx.gas, [
1859
+ const [makerRewardWithFee] = tx.splitCoins(tx.gas, [
1854
1860
  BigInt(lock.maker_price) + marketplaceFee
1855
1861
  ]);
1856
- const [transferRequest] = tx.moveCall({
1857
- target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::confirm_long_lock`,
1862
+ const [transferRequest, confirmLockRequest] = tx.moveCall({
1863
+ target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::start_confirm_long_lock`,
1858
1864
  typeArguments: [lock.nft_type],
1859
1865
  arguments: [
1860
1866
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
@@ -1863,9 +1869,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
1863
1869
  tx.object(lock.chain_state.makerKioskId),
1864
1870
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
1865
1871
  tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
1866
- tx.object(transferPolicyId),
1867
- tx.pure.u64(bid?.price ?? 0n),
1868
- creatorRewardWithFee
1872
+ tx.object(transferPolicyId)
1869
1873
  ]
1870
1874
  });
1871
1875
  await resolveTransferPolicies({
@@ -1877,14 +1881,36 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
1877
1881
  shouldSkipKioskLocking: true
1878
1882
  });
1879
1883
  if (bid) {
1884
+ const beforeResolveKioskTransferRequest = (transferRequest2) => {
1885
+ tx.moveCall({
1886
+ target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::end_confirm_long_lock_with_bid`,
1887
+ typeArguments: [lock.nft_type],
1888
+ arguments: [
1889
+ tx.object(TRADEPORT_PRICE_LOCK_STORE),
1890
+ confirmLockRequest,
1891
+ transferRequest2,
1892
+ makerRewardWithFee
1893
+ ]
1894
+ });
1895
+ };
1880
1896
  switch (bid.type) {
1881
1897
  case "solo": {
1882
- await acceptNftBids({ bidIds: [bidId], tx, kioskTx }, context);
1898
+ await acceptNftBids(
1899
+ { bidIds: [bidId], tx, kioskTx, beforeResolveKioskTransferRequest },
1900
+ context
1901
+ );
1883
1902
  break;
1884
1903
  }
1885
1904
  case "collection": {
1886
1905
  await acceptCollectionBid(
1887
- { bid, tx, nftId: lock.nft?.id, walletAddress, kioskTx },
1906
+ {
1907
+ bid,
1908
+ tx,
1909
+ nftId: lock.nft?.id,
1910
+ walletAddress,
1911
+ kioskTx,
1912
+ beforeResolveKioskTransferRequest
1913
+ },
1888
1914
  context
1889
1915
  );
1890
1916
  break;
@@ -1893,6 +1919,25 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
1893
1919
  throw new Error(`Unsupported bid type ${bid.type}`);
1894
1920
  }
1895
1921
  }
1922
+ } else {
1923
+ const [transferRequest2] = tx.moveCall({
1924
+ target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::end_confirm_long_lock`,
1925
+ typeArguments: [lock.nft_type],
1926
+ arguments: [
1927
+ tx.object(TRADEPORT_PRICE_LOCK_STORE),
1928
+ confirmLockRequest,
1929
+ tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
1930
+ makerRewardWithFee
1931
+ ]
1932
+ });
1933
+ await resolveTransferPolicies({
1934
+ tx,
1935
+ kioskTx,
1936
+ nftType: lock.nft_type,
1937
+ price: lock.maker_price.toString(),
1938
+ transferRequest: transferRequest2,
1939
+ shouldSkipKioskLocking: true
1940
+ });
1896
1941
  }
1897
1942
  }
1898
1943
  });
@@ -2024,7 +2069,8 @@ var addTradeportKioskBuyTx = async ({
2024
2069
  nftType,
2025
2070
  nftTokenId,
2026
2071
  price,
2027
- sellerKiosk
2072
+ sellerKiosk,
2073
+ beforeResolveKioskTransferRequest
2028
2074
  }) => {
2029
2075
  const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
2030
2076
  if (!coin)
@@ -2040,6 +2086,7 @@ var addTradeportKioskBuyTx = async ({
2040
2086
  ],
2041
2087
  typeArguments: [nftType]
2042
2088
  });
2089
+ await beforeResolveKioskTransferRequest?.(transferRequest);
2043
2090
  await resolveTransferPolicies({
2044
2091
  tx,
2045
2092
  kioskTx,
@@ -2091,7 +2138,8 @@ var addHyperspaceKioskBuyTx = async ({
2091
2138
  nftType,
2092
2139
  nftTokenId,
2093
2140
  price,
2094
- sellerKiosk
2141
+ sellerKiosk,
2142
+ beforeResolveKioskTransferRequest
2095
2143
  }) => {
2096
2144
  const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(price)] });
2097
2145
  if (!coin)
@@ -2111,6 +2159,7 @@ var addHyperspaceKioskBuyTx = async ({
2111
2159
  transferRequest: hyperspaceMpTransferRequest
2112
2160
  }
2113
2161
  ];
2162
+ await beforeResolveKioskTransferRequest?.(transferRequest);
2114
2163
  await resolveTransferPolicies({
2115
2164
  tx,
2116
2165
  kioskTx,
@@ -2145,7 +2194,8 @@ async function addBluemoveKioskBuyTx({
2145
2194
  nftTokenId,
2146
2195
  nftType,
2147
2196
  price,
2148
- sellerKiosk
2197
+ sellerKiosk,
2198
+ beforeResolveKioskTransferRequest
2149
2199
  }) {
2150
2200
  const { transferPolicy } = sharedObjects;
2151
2201
  const [coin1, coin2] = splitCoins({
@@ -2168,6 +2218,7 @@ async function addBluemoveKioskBuyTx({
2168
2218
  ],
2169
2219
  typeArguments: [nftType]
2170
2220
  });
2221
+ await beforeResolveKioskTransferRequest?.(transferRequest);
2171
2222
  await resolveTransferPolicies({
2172
2223
  tx,
2173
2224
  kioskTx,
@@ -2395,7 +2446,13 @@ function addTocenBuyTxHandler(txData) {
2395
2446
  }
2396
2447
 
2397
2448
  // src/methods/buyListings/buyListings.ts
2398
- var buyListings = async ({ listingIds, walletAddress, tx: existingTx, kioskTx }, context) => {
2449
+ var buyListings = async ({
2450
+ listingIds,
2451
+ walletAddress,
2452
+ tx: existingTx,
2453
+ kioskTx,
2454
+ beforeResolveKioskTransferRequest
2455
+ }, context) => {
2399
2456
  const res = await gqlChainRequest({
2400
2457
  chain: "sui",
2401
2458
  query: fetchListingsById,
@@ -2428,7 +2485,8 @@ var buyListings = async ({ listingIds, walletAddress, tx: existingTx, kioskTx },
2428
2485
  price: listing?.price,
2429
2486
  sellerKiosk: listing.nft?.chain_state?.kiosk_id,
2430
2487
  collectionId: listing?.nft?.collection_id,
2431
- nftContractId: listing?.nft?.contract_id
2488
+ nftContractId: listing?.nft?.contract_id,
2489
+ beforeResolveKioskTransferRequest
2432
2490
  };
2433
2491
  switch (listing?.market_name) {
2434
2492
  case "tradeport":
@@ -2798,6 +2856,17 @@ var getActiveLockStateByNftId = async (nftId) => {
2798
2856
  return res?.locks?.[0] ?? void 0;
2799
2857
  };
2800
2858
 
2859
+ // src/helpers/calculateRoyaltyFee.ts
2860
+ function calculateRoyaltyFee(transferPolicyRules, price) {
2861
+ const royaltyRules = transferPolicyRules.filter(
2862
+ (rule) => rule.type === "royalty_rule"
2863
+ );
2864
+ return royaltyRules.reduce(
2865
+ (sum, rule) => sum + BigInt(rule.min_amount) + BigInt(rule.amount_bp) * price / 10000n,
2866
+ 0n
2867
+ );
2868
+ }
2869
+
2801
2870
  // src/methods/createLongLocks/createLongLocks.ts
2802
2871
  async function createLongLocks({
2803
2872
  walletAddress,
@@ -2820,6 +2889,11 @@ async function createLongLocks({
2820
2889
  variables: { nftId: argNft.id }
2821
2890
  }))?.nfts?.[0];
2822
2891
  const nftType = getNftTypeFromNft(nft);
2892
+ const transferPolicy = (await getKioskTransferPolicies(nftType))?.at(0);
2893
+ if (!transferPolicy) {
2894
+ throw new Error(`Missing transfer policy for ${nftType}`);
2895
+ }
2896
+ const royalty = calculateRoyaltyFee(transferPolicy.rules, BigInt(argNft.priceInMist));
2823
2897
  await kioskTxWrapper({
2824
2898
  tx,
2825
2899
  kioskOwner: walletAddress,
@@ -2842,6 +2916,7 @@ async function createLongLocks({
2842
2916
  })
2843
2917
  )
2844
2918
  ),
2919
+ tx.pure.u64(royalty),
2845
2920
  tx.pure.u64(premium),
2846
2921
  tx.pure.u64(expireIn)
2847
2922
  ]
@@ -2854,19 +2929,6 @@ async function createLongLocks({
2854
2929
 
2855
2930
  // src/methods/createShortLocks/createShortLocks.ts
2856
2931
  var import_transactions10 = require("@mysten/sui/transactions");
2857
-
2858
- // src/helpers/calculateRoyaltyFee.ts
2859
- function calculateRoyaltyFee(transferPolicyRules, price) {
2860
- const royaltyRules = transferPolicyRules.filter(
2861
- (rule) => rule.type === "royalty_rule"
2862
- );
2863
- return royaltyRules.reduce(
2864
- (sum, rule) => sum + BigInt(rule.min_amount) + BigInt(rule.amount_bp) * price / 10000n,
2865
- 0n
2866
- );
2867
- }
2868
-
2869
- // src/methods/createShortLocks/createShortLocks.ts
2870
2932
  async function createShortLocks({ nfts }) {
2871
2933
  const expireIn = 7 * 24 * 3600 * 1e3;
2872
2934
  const tx = new import_transactions10.Transaction();
@@ -2885,10 +2947,9 @@ async function createShortLocks({ nfts }) {
2885
2947
  collectionId: argNft.collectionId
2886
2948
  })
2887
2949
  );
2888
- const transferFees = calculateRoyaltyFee(transferPolicy.rules, 0n) + // transfer
2889
- calculateRoyaltyFee(transferPolicy.rules, BigInt(argNft.priceInMist));
2950
+ const royalty = calculateRoyaltyFee(transferPolicy.rules, BigInt(argNft.priceInMist));
2890
2951
  const [deposit] = tx.splitCoins(tx.gas, [
2891
- BigInt(argNft.priceInMist) + marketplaceFee + transferFees
2952
+ BigInt(argNft.priceInMist) + royalty + marketplaceFee
2892
2953
  ]);
2893
2954
  tx.moveCall({
2894
2955
  target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::create_short_lock`,
@@ -2897,6 +2958,7 @@ async function createShortLocks({ nfts }) {
2897
2958
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
2898
2959
  tx.pure.u64(BigInt(argNft.priceInMist)),
2899
2960
  tx.pure.u64(marketplaceFee),
2961
+ tx.pure.u64(royalty),
2900
2962
  tx.pure.u64(premium),
2901
2963
  tx.pure.u64(expireIn),
2902
2964
  deposit
@@ -2920,12 +2982,10 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
2920
2982
  if (!transferPolicy) {
2921
2983
  throw new Error(`Transfer policy is not found for ${lock.nft_type}`);
2922
2984
  }
2923
- const transferPolicyId = transferPolicy?.id;
2924
2985
  const sharedObjects = await getSharedObjects(lock.nft_type);
2925
2986
  if (lock.nft?.token_id) {
2926
2987
  throw new Error(`The short lock ${lockId} must not have any nft`);
2927
2988
  }
2928
- const requiredCoins = BigInt(lock.maker_price) + calculateRoyaltyFee(transferPolicy.rules, 0n);
2929
2989
  let listing = null;
2930
2990
  if (listingId) {
2931
2991
  const res = await gqlChainRequest({
@@ -2969,51 +3029,66 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
2969
3029
  kioskOwner: walletAddress,
2970
3030
  kiosk: nftIdArg ? nft?.chain_state?.kiosk_id : null,
2971
3031
  async runCommands(kioskTx) {
2972
- const [request] = tx.moveCall({
2973
- target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::start_confirm_short_lock`,
2974
- typeArguments: [lock.nft_type],
2975
- arguments: [
2976
- tx.object(TRADEPORT_PRICE_LOCK_STORE),
2977
- tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
2978
- tx.pure.id(lock.lock_id),
2979
- tx.pure.u64(requiredCoins)
2980
- ]
2981
- });
3032
+ let confirmLockRequest;
2982
3033
  if (listing) {
3034
+ const beforeResolveKioskTransferRequest = async (transferRequest) => {
3035
+ const [request] = tx.moveCall({
3036
+ target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::start_confirm_short_lock_with_buy_listing`,
3037
+ typeArguments: [lock.nft_type],
3038
+ arguments: [
3039
+ tx.object(TRADEPORT_PRICE_LOCK_STORE),
3040
+ tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
3041
+ tx.pure.id(lock.lock_id),
3042
+ tx.pure.u64(listing.price),
3043
+ tx.pure.u64(calculateRoyaltyFee(transferPolicy.rules, BigInt(listing.price))),
3044
+ transferRequest
3045
+ ]
3046
+ });
3047
+ confirmLockRequest = request;
3048
+ };
2983
3049
  await buyListings(
2984
3050
  {
2985
3051
  listingIds: [listingId],
2986
3052
  walletAddress,
2987
3053
  tx,
2988
- kioskTx
3054
+ kioskTx,
3055
+ beforeResolveKioskTransferRequest
2989
3056
  },
2990
3057
  context
2991
3058
  );
3059
+ } else {
3060
+ const [buyListinTransferRequest, request] = tx.moveCall({
3061
+ target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::start_confirm_short_lock`,
3062
+ typeArguments: [lock.nft_type],
3063
+ arguments: [
3064
+ tx.object(TRADEPORT_PRICE_LOCK_STORE),
3065
+ tx.object(import_utils4.SUI_CLOCK_OBJECT_ID),
3066
+ tx.pure.id(lock.lock_id),
3067
+ tx.pure.id(nft.token_id),
3068
+ tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk)
3069
+ ]
3070
+ });
3071
+ confirmLockRequest = request;
3072
+ await resolveTransferPolicies({
3073
+ tx,
3074
+ kioskTx,
3075
+ nftType: lock.nft_type,
3076
+ price: lock.maker_price.toString(),
3077
+ transferRequest: buyListinTransferRequest,
3078
+ shouldSkipKioskLocking: true
3079
+ });
2992
3080
  }
2993
- const [transferRequest] = tx.moveCall({
3081
+ tx.moveCall({
2994
3082
  target: `${TRADEPORT_PRICE_LOCK_PACKAGE}::tradeport_price_lock::end_confirm_short_lock`,
2995
3083
  typeArguments: [lock.nft_type],
2996
3084
  arguments: [
2997
3085
  tx.object(TRADEPORT_PRICE_LOCK_STORE),
2998
3086
  tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
2999
- request,
3000
- tx.pure.id(nft.token_id),
3001
- tx.object(TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK),
3087
+ confirmLockRequest,
3002
3088
  tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
3003
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
3004
- tx.object(transferPolicyId),
3005
- tx.pure.u64(listing?.price ?? 0n)
3089
+ tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap)
3006
3090
  ]
3007
3091
  });
3008
- await resolveTransferPolicies({
3009
- tx,
3010
- kioskTx,
3011
- nftType: lock.nft_type,
3012
- price: "0",
3013
- transferRequest,
3014
- kioskToLockRuleProve: TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK,
3015
- shouldSkipKioskLocking: true
3016
- });
3017
3092
  }
3018
3093
  });
3019
3094
  }