@tradeport/sui-trading-sdk 0.4.3 → 0.4.4

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.3",
4
+ "version": "0.4.4",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import { type SuiClient } from '@mysten/sui/client';
2
2
  import { isValidSuiObjectId } from '@mysten/sui/utils';
3
+ import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
3
4
 
4
5
  export const getObjectType = async ({
5
6
  suiClient,
@@ -8,8 +9,11 @@ export const getObjectType = async ({
8
9
  suiClient: SuiClient;
9
10
  objectId: string;
10
11
  }): Promise<string> => {
11
- if (isValidSuiObjectId(objectId)) {
12
- const res = await suiClient.getObject({ id: objectId, options: { showType: true } });
12
+ const normalizedObjectId = objectId.startsWith('0x')
13
+ ? addLeadingZerosAfter0x(objectId)
14
+ : objectId;
15
+ if (isValidSuiObjectId(normalizedObjectId)) {
16
+ const res = await suiClient.getObject({ id: normalizedObjectId, options: { showType: true } });
13
17
  return res.data.type;
14
18
  }
15
19
 
@@ -90,7 +90,9 @@ export const claimNfts = async (
90
90
  });
91
91
  const walletAddressKiosks = kiosksByOwnerRes?.kiosks;
92
92
 
93
+ let globalKioskTx: any;
93
94
  for (const nft of res.nfts) {
95
+ let existingKioskTx;
94
96
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
95
97
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
96
98
  }
@@ -151,9 +153,11 @@ export const claimNfts = async (
151
153
  kioskOwner: txData?.claimer,
152
154
  kioskOwnerKiosks: walletAddressKiosks,
153
155
  kiosk: txData?.sellerKiosk,
156
+ kioskTx: globalKioskTx,
154
157
  shouldConvertToPersonalKiosk: true,
155
158
  shouldAllowNftUnsharedKiosk: true,
156
159
  async runCommands(kioskTx) {
160
+ existingKioskTx = kioskTx;
157
161
  await addBluemoveClaimAcceptedBidNft({
158
162
  ...txData,
159
163
  suiClient: context.suiClient,
@@ -172,9 +176,11 @@ export const claimNfts = async (
172
176
  kioskOwner: txData?.claimer,
173
177
  kioskOwnerKiosks: walletAddressKiosks,
174
178
  kiosk: txData?.sellerKiosk,
179
+ kioskTx: globalKioskTx,
175
180
  shouldConvertToPersonalKiosk: true,
176
181
  shouldAllowNftUnsharedKiosk: true,
177
182
  async runCommands(kioskTx) {
183
+ existingKioskTx = kioskTx;
178
184
  await addClaimAcceptedBidNftTx({ ...txData, kioskTx });
179
185
  },
180
186
  });
@@ -185,9 +191,11 @@ export const claimNfts = async (
185
191
  kioskOwner: txData?.claimer,
186
192
  kioskOwnerKiosks: walletAddressKiosks,
187
193
  kiosk: txData?.sellerKiosk,
194
+ kioskTx: globalKioskTx,
188
195
  shouldConvertToPersonalKiosk: true,
189
196
  shouldAssertNftInSharedKiosk: true,
190
197
  async runCommands(kioskTx) {
198
+ existingKioskTx = kioskTx;
191
199
  await addClaimAcceptedBidNftWithPurchaseCapTx({ ...txData, kioskTx });
192
200
  },
193
201
  });
@@ -217,9 +225,11 @@ export const claimNfts = async (
217
225
  kiosk: txData?.sellerKiosk,
218
226
  kioskOwnerKiosks: walletAddressKiosks,
219
227
  kioskStrategy: 'exclude',
228
+ kioskTx: globalKioskTx,
220
229
  shouldConvertToPersonalKiosk: true,
221
230
  shouldAllowNftUnsharedKiosk: true,
222
231
  async runCommands(kioskTx) {
232
+ existingKioskTx = kioskTx;
223
233
  await addClaimTransferredNftTx({ ...txData, kioskTx });
224
234
  },
225
235
  });
@@ -231,9 +241,11 @@ export const claimNfts = async (
231
241
  kiosk: txData?.sellerKiosk,
232
242
  kioskOwnerKiosks: walletAddressKiosks,
233
243
  kioskStrategy: 'exclude',
244
+ kioskTx: globalKioskTx,
234
245
  shouldConvertToPersonalKiosk: true,
235
246
  shouldAllowNftUnsharedKiosk: true,
236
247
  async runCommands(kioskTx) {
248
+ existingKioskTx = kioskTx;
237
249
  await addClaimTransferredNftWithPurchaseCapTx({ ...txData, kioskTx });
238
250
  },
239
251
  });
@@ -245,6 +257,7 @@ export const claimNfts = async (
245
257
  // claimer: walletAddress,
246
258
  // claimReason: nft?.chain_state?.claimable_reason,
247
259
  // });
260
+ globalKioskTx = existingKioskTx;
248
261
  }
249
262
 
250
263
  // if (process.env.ENABLE_SEGMENT_TRACKING === 'true' && nftsForTracking.length > 0) {
@@ -256,5 +269,6 @@ export const claimNfts = async (
256
269
  // });
257
270
  // }
258
271
 
272
+ globalKioskTx?.finalize();
259
273
  return Transaction.from(tx);
260
274
  };
@@ -99,8 +99,6 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
99
99
  ?.filter((k: any) => !k.is_shared && !k.is_origin_byte)
100
100
  ?.map((k: any) => k.id);
101
101
 
102
- let globalKioskTx: any;
103
-
104
102
  const allNfts = await gqlChainRequest({
105
103
  chain: 'sui',
106
104
  query: fetchBulkNftsByKioskId,
@@ -133,7 +131,7 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
133
131
  }, []);
134
132
 
135
133
  const transferPolicies = await Promise.all(
136
- allNftTypes.map((type: string) => getKioskTransferPolicies(type)),
134
+ allNftTypes.map(async (type: string) => getKioskTransferPolicies(type)),
137
135
  );
138
136
 
139
137
  const mappedTrasferPolicies: Record<string, any> = {};
@@ -141,6 +139,7 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
141
139
  mappedTrasferPolicies[tp.transfer_policies_by_type?.[0]?.type] = tp.transfer_policies_by_type;
142
140
  });
143
141
 
142
+ let globalKioskTx: any;
144
143
  for (const unsharedNativeKiosk of unsharedNativeKiosks) {
145
144
  if (currentMigrationCount >= max) {
146
145
  continue;