@tradeport/sui-trading-sdk 0.3.3 → 0.3.5

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.3.3",
4
+ "version": "0.3.5",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -130,10 +130,6 @@ export const kioskTxWrapper = async ({
130
130
  version: '',
131
131
  },
132
132
  });
133
-
134
- if (shouldConvertToPersonalKiosk) {
135
- kioskTx.convertToPersonal(true);
136
- }
137
133
  } else {
138
134
  // creating new personal kiosk
139
135
  kioskTx = new KioskTransaction({ transactionBlock: tx as any, kioskClient });
@@ -11,10 +11,11 @@ import { addTradeportKioskTransferTx } from '../transferNfts/addTransferNftTx';
11
11
 
12
12
  export type MigrateNftsFromUnsharedToSharedKiosks = {
13
13
  walletAddress: string;
14
+ max?: number;
14
15
  };
15
16
 
16
17
  export async function migrateNftsFromUnsharedToSharedKiosks(
17
- { walletAddress }: MigrateNftsFromUnsharedToSharedKiosks,
18
+ { walletAddress, max = 5 }: MigrateNftsFromUnsharedToSharedKiosks,
18
19
  context: RequestContext,
19
20
  ): Promise<Transaction> {
20
21
  const tx = new Transaction();
@@ -29,9 +30,15 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
29
30
  ?.filter((k: any) => !k.is_shared && k.is_origin_byte)
30
31
  ?.map((k: any) => k.id);
31
32
 
33
+ let currentMigrationCount = 0;
34
+
32
35
  const sharedOBKiosk = res?.kiosks?.filter((k: any) => k.is_shared && k.is_origin_byte)?.[0]?.id;
33
36
 
34
37
  for (const unsharedOBKiosk of unsharedOBKiosks) {
38
+ if (currentMigrationCount >= max) {
39
+ continue;
40
+ }
41
+
35
42
  const res = await gqlChainRequest({
36
43
  chain: 'sui',
37
44
  query: fetchNftsByKioskId,
@@ -40,6 +47,10 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
40
47
 
41
48
  const nfts = res?.nfts;
42
49
 
50
+ if (nfts.length > 0) {
51
+ currentMigrationCount++;
52
+ }
53
+
43
54
  for (const nft of nfts) {
44
55
  if (nft?.chain_state?.claimable_trade_id) {
45
56
  // origin byte trade hold, so they are stuck and cannot be migrated
@@ -90,6 +101,10 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
90
101
  ?.map((k: any) => k.id);
91
102
 
92
103
  for (const unsharedNativeKiosk of unsharedNativeKiosks) {
104
+ if (currentMigrationCount >= max) {
105
+ continue;
106
+ }
107
+
93
108
  const res = await gqlChainRequest({
94
109
  chain: 'sui',
95
110
  query: fetchNftsByKioskId,
@@ -98,6 +113,10 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
98
113
 
99
114
  const nfts = res?.nfts;
100
115
 
116
+ if (nfts?.length > 0) {
117
+ currentMigrationCount++;
118
+ }
119
+
101
120
  for (const nft of nfts) {
102
121
  if (nft?.claimable_reason === 'offer-transfer') {
103
122
  // native kiosk kiosk_transfers transfer hold. Transfer needs to be cancelled first in order to be migrated