@tradeport/sui-trading-sdk 0.3.4 → 0.3.6

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,11 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - b821140: Updated transfer policy selection for direct transfers
8
+
3
9
  ## 0.3.4
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -109,7 +109,7 @@ type ListNfts = {
109
109
 
110
110
  type MigrateNftsFromUnsharedToSharedKiosks = {
111
111
  walletAddress: string;
112
- max: number;
112
+ max?: number;
113
113
  };
114
114
 
115
115
  type PlaceCollectionBid = {
package/dist/index.d.ts CHANGED
@@ -109,7 +109,7 @@ type ListNfts = {
109
109
 
110
110
  type MigrateNftsFromUnsharedToSharedKiosks = {
111
111
  walletAddress: string;
112
- max: number;
112
+ max?: number;
113
113
  };
114
114
 
115
115
  type PlaceCollectionBid = {
package/dist/index.js CHANGED
@@ -5153,26 +5153,48 @@ function canBeTransferedDirectly(collectionChainState) {
5153
5153
  return getTransferPolicyForDirectTransfer(collectionChainState) !== void 0;
5154
5154
  }
5155
5155
  function getTransferPolicyForDirectTransfer(collectionChainState) {
5156
- return collectionChainState?.transfer_policies?.find(
5156
+ if (!collectionChainState?.transfer_policies?.length) {
5157
+ return void 0;
5158
+ }
5159
+ const usablePolicies = collectionChainState.transfer_policies.filter(
5157
5160
  (policy) => !policy.is_origin_byte && policy.rules?.filter(
5158
5161
  (rule) => rule.type !== "kiosk_lock_rule" && rule.type !== "royalty_rule"
5159
5162
  ).length === 0
5160
5163
  );
5164
+ const lockAndRoyaltyPolicy = usablePolicies.find(
5165
+ (policy) => policy.rules?.some((rule) => rule.type === "kiosk_lock_rule") && !policy.rules?.some((rule) => rule.type === "royalty_rule")
5166
+ );
5167
+ if (lockAndRoyaltyPolicy) {
5168
+ return lockAndRoyaltyPolicy;
5169
+ }
5170
+ const royaltyPolicy = usablePolicies.find(
5171
+ (policy) => policy.rules?.some((rule) => rule.type === "royalty_rule")
5172
+ );
5173
+ if (royaltyPolicy) {
5174
+ return royaltyPolicy;
5175
+ }
5176
+ const lockPolicy = usablePolicies.find(
5177
+ (policy) => policy.rules?.some((rule) => rule.type === "kiosk_lock_rule")
5178
+ );
5179
+ if (lockPolicy) {
5180
+ return lockPolicy;
5181
+ }
5182
+ return usablePolicies[0];
5161
5183
  }
5162
5184
 
5163
5185
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5164
- async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max }, context) {
5186
+ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 }, context) {
5165
5187
  const tx = new import_transactions16.Transaction();
5166
5188
  const res = await gqlChainRequest({
5167
5189
  chain: "sui",
5168
5190
  query: fetchKiosksByOwner,
5169
5191
  variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) }
5170
5192
  });
5171
- const unsharedOBKiosks = res?.kiosks?.filter((k) => !k.is_shared && k.is_origin_byte)?.map((k) => k.id)?.slice(0, 5);
5193
+ const unsharedOBKiosks = res?.kiosks?.filter((k) => !k.is_shared && k.is_origin_byte)?.map((k) => k.id);
5172
5194
  let currentMigrationCount = 0;
5173
5195
  const sharedOBKiosk = res?.kiosks?.filter((k) => k.is_shared && k.is_origin_byte)?.[0]?.id;
5174
5196
  for (const unsharedOBKiosk of unsharedOBKiosks) {
5175
- if (currentMigrationCount >= (max ?? 5)) {
5197
+ if (currentMigrationCount >= max) {
5176
5198
  continue;
5177
5199
  }
5178
5200
  const res2 = await gqlChainRequest({
@@ -5217,9 +5239,9 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max }, con
5217
5239
  }
5218
5240
  }
5219
5241
  }
5220
- const unsharedNativeKiosks = res?.kiosks?.filter((k) => !k.is_shared && !k.is_origin_byte)?.map((k) => k.id)?.slice(0, 5);
5242
+ const unsharedNativeKiosks = res?.kiosks?.filter((k) => !k.is_shared && !k.is_origin_byte)?.map((k) => k.id);
5221
5243
  for (const unsharedNativeKiosk of unsharedNativeKiosks) {
5222
- if (currentMigrationCount >= 5) {
5244
+ if (currentMigrationCount >= max) {
5223
5245
  continue;
5224
5246
  }
5225
5247
  const res2 = await gqlChainRequest({