@tradeport/sui-trading-sdk 0.4.48 → 0.4.49

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tradeport/sui-trading-sdk",
3
3
  "license": "MIT",
4
- "version": "0.4.48",
4
+ "version": "0.4.49",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
package/src/constants.ts CHANGED
@@ -1,4 +1,5 @@
1
- export const MYSTEN_TRANFER_POLICY_RULES_PACKAGE_ID = '0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879';
1
+ export const MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID = '0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879';
2
+ export const MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID_V2 = '0x0cb4bcc0560340eb1a1b929cabe56b33fc6449820ec8c1980d69bb98b649b802';
2
3
 
3
4
  export const TRADEPORT_BENEFICIARY_ADDRESS = '0xbca3b5c01c8d1a93aed3a036feff45145518292dd3c1db1d67cc99a699a7b517';
4
5
  export const TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT = 0.03;
@@ -7,7 +8,7 @@ export const TRADEPORT_LISTINGS_DEFAULT_COMMISSION_BPS = 300; // 3%
7
8
  export const TRADEPORT_LISTING_STORE = '0x47cba0b6309a12ce39f9306e28b899ed4b3698bce4f4911fd0c58ff2329a2ff6';
8
9
  export const TRADEPORT_BIDDING_STORE = '0x3d3b0c6e616fdc1a45b2b73d022bc085448e78bd729d28081c7a340abb33cba1';
9
10
  export const TRADEPORT_MARKETPLACE_OBJECT = '0xc5f87120e388b532ee774f7bac23347679f632a1f2d59f4ed2bbf2ffe5a61b6f';
10
- export const TRADEPORT_LISTINGS_PACKAGE = '0x046de0d9c1d7aea8b27744308a0607515677cf9035e1c98d88cb27bbc84a77ae';
11
+ export const TRADEPORT_LISTINGS_PACKAGE = '0x6cfe7388ccf732432906d7faebcc33fd91e11d4c2f8cb3ae0082b8d3269e3d5b';
11
12
  export const TRADEPORT_LISTINGS_STORE = '0xf96f9363ac5a64c058bf7140723226804d74c0dab2dd27516fb441a180cd763b';
12
13
  export const TRADEPORT_KIOSK_LISTING_STORE = '0xbff3161b047fb8b727883838c09b08afa9e0dd0f5488bde9e99e80643da9b9e0';
13
14
  export const TRADEPORT_KIOSK_TRANSFERS_STORE = '0xe0f61b6915d3fd4ec8bbe4618514e2152a82841605bfa00cde22ace434153a1b';
@@ -19,7 +20,7 @@ export const TRADEPORT_KIOSK_BID_NONCE_TYPE = '0xec175e537be9e48f75fa6929291de64
19
20
  export const TRADEPORT_PRICE_LOCK_PACKAGE = '0x3cb532a2548290780a3d70ad6f4f06abc5bebb75ec6f8dd0197d4d2b2860c5d8';
20
21
  export const TRADEPORT_PRICE_LOCK_STORE = '0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0c9e03cac5729c0c47946';
21
22
 
22
- export const TRADEPORT_MULTI_BID_PACKAGE = '0xd1dedf8379f1781469e95cb92eed7e155c8ad141c8528c3855f59ce2a5d9d659';
23
+ export const TRADEPORT_MULTI_BID_PACKAGE = '0x63ce6caee2ba264e92bca2d160036eb297d99b2d91d4db89d48a9bffca66e55b';
23
24
  export const TRADEPORT_MULTI_BID_PACKAGE_ORIGINAL = '0x53134eb544c5a0b5085e99efaf7eab13b28ad123de35d61f941f8c8c40b72033'; // V1
24
25
  export const TRADEPORT_MULTI_BID_STORE = '0x8aaed7e884343fb8b222c721d02eaac2c6ae2abbb4ddcdf16cb55cf8754ee860';
25
26
 
@@ -1021,3 +1022,5 @@ export const DYNAMIC_COLLECTION_IDS = [
1021
1022
  'fdf8a578-2914-47aa-a318-3a0a80b29025', // Phantom Froze Over
1022
1023
  '75381a59-abde-4e4b-aac9-b1c5ba10b4da', // Claynosaurz: Phantom Purr-ize Patch
1023
1024
  ];
1025
+
1026
+ export const XOCIETY_FRONTIER_COLLECTION_ID = '9a0fcf4f-c77c-42d8-acad-5054e025eb53';
@@ -19,6 +19,7 @@ import {
19
19
  TRADEPORT_LISTING_STORE,
20
20
  TRADEPORT_LISTINGS_PACKAGE,
21
21
  TRADEPORT_LISTINGS_STORE,
22
+ XOCIETY_FRONTIER_COLLECTION_ID,
22
23
  } from '../../constants';
23
24
  import { getCommissionByNftContractId } from '../../graphql/queries/getCommissionByListingId';
24
25
  import { destroyZeroCoin } from '../../helpers/destroyZeroCoin';
@@ -36,6 +37,7 @@ import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
36
37
  import { type BuyTx, type TocenBuyTx } from './buyListings';
37
38
  import BigNumber from '../../bigNumberConfig';
38
39
  import { calculateRoyaltyFee } from '../../helpers/calculateRoyaltyFee';
40
+ import { takeAndBorrowNftFromKiosk } from '../../helpers/kiosk/takeAndBorrowNftFromKiosk';
39
41
 
40
42
  export function addLegacyTradePortBuyTx({
41
43
  tx,
@@ -601,6 +603,25 @@ export async function addTradePortBuyTxHandler(txData: BuyTx) {
601
603
  ...txData,
602
604
  kioskTx,
603
605
  });
606
+
607
+ // If XOCIETY Frontier collection, take NFT out of kiosk and transfer it back to user (buyer)
608
+ if (txData?.collectionId === XOCIETY_FRONTIER_COLLECTION_ID) {
609
+ const borrowedItem = await takeAndBorrowNftFromKiosk({
610
+ tx: txData?.tx,
611
+ transferPolicies: txData?.transferPolicies,
612
+ kioskTx,
613
+ kioskClient: txData?.kioskClient,
614
+ nftTokenId: txData?.nftTokenId,
615
+ nftType: txData?.nftType,
616
+ suiClient: txData?.suiClient,
617
+ kioskOwner: txData?.buyer,
618
+ });
619
+
620
+ txData?.tx.transferObjects(
621
+ [txData?.tx.object(borrowedItem)],
622
+ txData?.tx.pure.address(addLeadingZerosAfter0x(txData?.buyer)),
623
+ );
624
+ }
604
625
  },
605
626
  });
606
627
  }
@@ -2,7 +2,8 @@ import { type KioskClient } from '@mysten/kiosk';
2
2
  import { type SuiClient } from '@mysten/sui/client';
3
3
  import { type Transaction } from '@mysten/sui/transactions';
4
4
  import {
5
- MYSTEN_TRANFER_POLICY_RULES_PACKAGE_ID,
5
+ MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID,
6
+ MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID_V2,
6
7
  TRADEPORT_KIOSK_TRANSFERS_STORE,
7
8
  } from '../../constants';
8
9
  import { destroyZeroCoin } from '../../helpers/destroyZeroCoin';
@@ -112,19 +113,6 @@ export async function addTradeportKioskDirectTransferTx(
112
113
  return;
113
114
  }
114
115
 
115
- const [receiverKiosk, receiverKioskCap] = tx.moveCall({
116
- target: '0x2::kiosk::new',
117
- arguments: [],
118
- });
119
- const recipientAddressWithPrefix = addLeadingZerosAfter0x(recipientAddress);
120
- tx.moveCall({
121
- target: '0x2::kiosk::set_owner_custom',
122
- arguments: [
123
- tx.object(receiverKiosk),
124
- tx.object(receiverKioskCap),
125
- tx.pure.address(recipientAddressWithPrefix),
126
- ],
127
- });
128
116
  const transferPolicies = new Map<string, TransferPolicy>(
129
117
  await Promise.all(
130
118
  nfts.map(
@@ -158,12 +146,11 @@ export async function addTradeportKioskDirectTransferTx(
158
146
  async runCommands(kioskTx) {
159
147
  tx.moveCall({
160
148
  target:
161
- '0xd0ad5bf7ac7d372cdcfee5273d5e487dabad724040e089c626cba2a01127ccd6::kiosk_transfers::direct_transfer',
149
+ '0x4acc0efedd243eb61ab8f8a3e9c24b09a1838c43d16029e8c8985004dfd67239::kiosk_transfers::direct_transfer_to_receiver',
162
150
  arguments: [
163
151
  tx.object(kioskTx.getKiosk() as any),
164
152
  tx.object(kioskTx.getKioskCap() as any),
165
- tx.object(receiverKiosk),
166
- tx.object(receiverKioskCap),
153
+ tx.pure.address(recipientAddress),
167
154
  tx.pure.id(nft.token_id),
168
155
  tx.object(transferPolicies.get(nft.id).id),
169
156
  royaltyCoin,
@@ -174,12 +161,6 @@ export async function addTradeportKioskDirectTransferTx(
174
161
  });
175
162
  }
176
163
 
177
- tx.transferObjects([receiverKioskCap], tx.pure.address(recipientAddressWithPrefix));
178
- tx.moveCall({
179
- target: '0x2::transfer::public_share_object',
180
- arguments: [receiverKiosk],
181
- typeArguments: ['0x2::kiosk::Kiosk'],
182
- });
183
164
  destroyZeroCoin({ tx, coin: royaltyCoin });
184
165
  }
185
166
 
@@ -203,7 +184,10 @@ export async function getTransferPolicyForDirectTransfer(
203
184
  !policy.is_disabled &&
204
185
  policy.rules.length > 0 &&
205
186
  policy.rules?.filter(
206
- (rule) => rule.type !== 'kiosk_lock_rule' && rule.type !== 'royalty_rule',
187
+ (rule) =>
188
+ rule.type !== 'kiosk_lock_rule' &&
189
+ rule.type !== 'royalty_rule' &&
190
+ rule.type !== 'personal_kiosk_rule',
207
191
  ).length === 0,
208
192
  );
209
193
 
@@ -212,7 +196,13 @@ export async function getTransferPolicyForDirectTransfer(
212
196
  suiClient,
213
197
  transferPolicyId: candidatePolicy.id,
214
198
  });
215
- if (!ruleNames.every((name) => name.startsWith(MYSTEN_TRANFER_POLICY_RULES_PACKAGE_ID))) {
199
+ if (
200
+ !ruleNames.every(
201
+ (name) =>
202
+ name.startsWith(MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID) ||
203
+ name.startsWith(MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID_V2),
204
+ )
205
+ ) {
216
206
  return undefined;
217
207
  }
218
208
  }
@@ -5,6 +5,7 @@ import { type RequestContext } from '../../SuiTradingClient';
5
5
  import {
6
6
  DELOREAN_TOKEN_IDS_TO_DISABLE,
7
7
  DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE,
8
+ XOCIETY_FRONTIER_COLLECTION_ID,
8
9
  } from '../../constants';
9
10
  import { gqlChainRequest } from '../../graphql/gqlChainRequest';
10
11
  import { fetchNftsById } from '../../graphql/queries/fetchNftsById';
@@ -122,8 +123,12 @@ export const transferNfts = async (
122
123
  continue;
123
124
  }
124
125
 
125
- // if nft is inside native kiosk and has no transfer policy rules, take it out of the kiosk and transfer it directly
126
- if (txData?.senderKiosk && !hasNativeKioskTransferPolicyRules(txData?.transferPolicies)) {
126
+ // If NFT is inside native kiosk and has no transfer policy rules or is XOCIETY Frontier collection, take it out of the kiosk and transfer it directly
127
+ if (
128
+ txData?.senderKiosk &&
129
+ (!hasNativeKioskTransferPolicyRules(txData?.transferPolicies) ||
130
+ nft?.collection?.id === XOCIETY_FRONTIER_COLLECTION_ID)
131
+ ) {
127
132
  await kioskTxWrapper({
128
133
  tx: txData?.tx,
129
134
  kioskClient: txData?.kioskClient,
@@ -11,6 +11,7 @@ import {
11
11
  TRADEPORT_LISTING_STORE,
12
12
  TRADEPORT_LISTINGS_PACKAGE,
13
13
  TRADEPORT_LISTINGS_STORE,
14
+ XOCIETY_FRONTIER_COLLECTION_ID,
14
15
  } from '../../constants';
15
16
  import { getSharedObjects } from '../../helpers/getSharedObjects';
16
17
  import { hasNativeKioskTransferPolicyRules } from '../../helpers/hasTransferPolicyRules';
@@ -224,6 +225,25 @@ export async function addTradePortUnlistTxHandler(txData: UnlistListingTx) {
224
225
  ...txData,
225
226
  kioskTx,
226
227
  });
228
+
229
+ // If XOCIETY Frontier collection, take NFT out of kiosk and transfer it back to user (seller)
230
+ if (txData?.collectionId === XOCIETY_FRONTIER_COLLECTION_ID) {
231
+ const borrowedItem = await takeAndBorrowNftFromKiosk({
232
+ tx: txData?.tx,
233
+ transferPolicies: txData?.transferPolicies,
234
+ kioskTx,
235
+ kioskClient: txData?.kioskClient,
236
+ nftTokenId: txData?.nftTokenId,
237
+ nftType: txData?.nftType,
238
+ suiClient: txData?.suiClient,
239
+ kioskOwner: txData?.seller,
240
+ });
241
+
242
+ txData?.tx.transferObjects(
243
+ [txData?.tx.object(borrowedItem)],
244
+ txData?.tx.pure.address(addLeadingZerosAfter0x(txData?.seller)),
245
+ );
246
+ }
227
247
  },
228
248
  });
229
249
  }