@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/dist/index.mjs CHANGED
@@ -5129,26 +5129,48 @@ function canBeTransferedDirectly(collectionChainState) {
5129
5129
  return getTransferPolicyForDirectTransfer(collectionChainState) !== void 0;
5130
5130
  }
5131
5131
  function getTransferPolicyForDirectTransfer(collectionChainState) {
5132
- return collectionChainState?.transfer_policies?.find(
5132
+ if (!collectionChainState?.transfer_policies?.length) {
5133
+ return void 0;
5134
+ }
5135
+ const usablePolicies = collectionChainState.transfer_policies.filter(
5133
5136
  (policy) => !policy.is_origin_byte && policy.rules?.filter(
5134
5137
  (rule) => rule.type !== "kiosk_lock_rule" && rule.type !== "royalty_rule"
5135
5138
  ).length === 0
5136
5139
  );
5140
+ const lockAndRoyaltyPolicy = usablePolicies.find(
5141
+ (policy) => policy.rules?.some((rule) => rule.type === "kiosk_lock_rule") && !policy.rules?.some((rule) => rule.type === "royalty_rule")
5142
+ );
5143
+ if (lockAndRoyaltyPolicy) {
5144
+ return lockAndRoyaltyPolicy;
5145
+ }
5146
+ const royaltyPolicy = usablePolicies.find(
5147
+ (policy) => policy.rules?.some((rule) => rule.type === "royalty_rule")
5148
+ );
5149
+ if (royaltyPolicy) {
5150
+ return royaltyPolicy;
5151
+ }
5152
+ const lockPolicy = usablePolicies.find(
5153
+ (policy) => policy.rules?.some((rule) => rule.type === "kiosk_lock_rule")
5154
+ );
5155
+ if (lockPolicy) {
5156
+ return lockPolicy;
5157
+ }
5158
+ return usablePolicies[0];
5137
5159
  }
5138
5160
 
5139
5161
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5140
- async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max }, context) {
5162
+ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 }, context) {
5141
5163
  const tx = new Transaction16();
5142
5164
  const res = await gqlChainRequest({
5143
5165
  chain: "sui",
5144
5166
  query: fetchKiosksByOwner,
5145
5167
  variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) }
5146
5168
  });
5147
- const unsharedOBKiosks = res?.kiosks?.filter((k) => !k.is_shared && k.is_origin_byte)?.map((k) => k.id)?.slice(0, 5);
5169
+ const unsharedOBKiosks = res?.kiosks?.filter((k) => !k.is_shared && k.is_origin_byte)?.map((k) => k.id);
5148
5170
  let currentMigrationCount = 0;
5149
5171
  const sharedOBKiosk = res?.kiosks?.filter((k) => k.is_shared && k.is_origin_byte)?.[0]?.id;
5150
5172
  for (const unsharedOBKiosk of unsharedOBKiosks) {
5151
- if (currentMigrationCount >= (max ?? 5)) {
5173
+ if (currentMigrationCount >= max) {
5152
5174
  continue;
5153
5175
  }
5154
5176
  const res2 = await gqlChainRequest({
@@ -5193,9 +5215,9 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max }, con
5193
5215
  }
5194
5216
  }
5195
5217
  }
5196
- const unsharedNativeKiosks = res?.kiosks?.filter((k) => !k.is_shared && !k.is_origin_byte)?.map((k) => k.id)?.slice(0, 5);
5218
+ const unsharedNativeKiosks = res?.kiosks?.filter((k) => !k.is_shared && !k.is_origin_byte)?.map((k) => k.id);
5197
5219
  for (const unsharedNativeKiosk of unsharedNativeKiosks) {
5198
- if (currentMigrationCount >= 5) {
5220
+ if (currentMigrationCount >= max) {
5199
5221
  continue;
5200
5222
  }
5201
5223
  const res2 = await gqlChainRequest({