@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 +6 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +6 -8
- package/src/methods/transferNfts/addTransferNftTx.ts +30 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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
|
-
|
|
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)
|
|
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 >=
|
|
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)
|
|
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 >=
|
|
5244
|
+
if (currentMigrationCount >= max) {
|
|
5223
5245
|
continue;
|
|
5224
5246
|
}
|
|
5225
5247
|
const res2 = await gqlChainRequest({
|