@tradeport/sui-trading-sdk 0.3.3 → 0.3.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.3.3",
4
+ "version": "0.3.4",
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 }: MigrateNftsFromUnsharedToSharedKiosks,
18
19
  context: RequestContext,
19
20
  ): Promise<Transaction> {
20
21
  const tx = new Transaction();
@@ -27,11 +28,18 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
27
28
 
28
29
  const unsharedOBKiosks = res?.kiosks
29
30
  ?.filter((k: any) => !k.is_shared && k.is_origin_byte)
30
- ?.map((k: any) => k.id);
31
+ ?.map((k: any) => k.id)
32
+ ?.slice(0, 5);
33
+
34
+ let currentMigrationCount = 0;
31
35
 
32
36
  const sharedOBKiosk = res?.kiosks?.filter((k: any) => k.is_shared && k.is_origin_byte)?.[0]?.id;
33
37
 
34
38
  for (const unsharedOBKiosk of unsharedOBKiosks) {
39
+ if (currentMigrationCount >= (max ?? 5)) {
40
+ continue;
41
+ }
42
+
35
43
  const res = await gqlChainRequest({
36
44
  chain: 'sui',
37
45
  query: fetchNftsByKioskId,
@@ -40,6 +48,10 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
40
48
 
41
49
  const nfts = res?.nfts;
42
50
 
51
+ if (nfts.length > 0) {
52
+ currentMigrationCount++;
53
+ }
54
+
43
55
  for (const nft of nfts) {
44
56
  if (nft?.chain_state?.claimable_trade_id) {
45
57
  // origin byte trade hold, so they are stuck and cannot be migrated
@@ -87,9 +99,14 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
87
99
 
88
100
  const unsharedNativeKiosks = res?.kiosks
89
101
  ?.filter((k: any) => !k.is_shared && !k.is_origin_byte)
90
- ?.map((k: any) => k.id);
102
+ ?.map((k: any) => k.id)
103
+ ?.slice(0, 5);
91
104
 
92
105
  for (const unsharedNativeKiosk of unsharedNativeKiosks) {
106
+ if (currentMigrationCount >= 5) {
107
+ continue;
108
+ }
109
+
93
110
  const res = await gqlChainRequest({
94
111
  chain: 'sui',
95
112
  query: fetchNftsByKioskId,
@@ -98,6 +115,10 @@ export async function migrateNftsFromUnsharedToSharedKiosks(
98
115
 
99
116
  const nfts = res?.nfts;
100
117
 
118
+ if (nfts?.length > 0) {
119
+ currentMigrationCount++;
120
+ }
121
+
101
122
  for (const nft of nfts) {
102
123
  if (nft?.claimable_reason === 'offer-transfer') {
103
124
  // native kiosk kiosk_transfers transfer hold. Transfer needs to be cancelled first in order to be migrated