@tradeport/sui-trading-sdk 0.4.14 → 0.4.16
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.js +625 -391
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +615 -381
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts +36 -0
- package/src/helpers/hasTransferPolicyRules.ts +4 -2
- package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +21 -0
- package/src/helpers/kiosk/getRulePackageId.ts +26 -4
- package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +2 -8
- package/src/helpers/kiosk/resolveTransferPolicies.ts +47 -33
- package/src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts +50 -0
- package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +77 -0
- package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +24 -8
- package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +15 -2
- package/src/methods/buyListings/addBuyListingTxs.ts +7 -2
- package/src/methods/claimNfts/addClaimNftsTxs.ts +4 -0
- package/src/methods/exerciseLongLocks/exerciseLongLocks.ts +2 -0
- package/src/methods/exerciseShortLocks/exerciseShortLocks.ts +1 -0
- package/src/methods/listNfts/addListTxs.ts +13 -5
- package/src/methods/listNfts/addRelistTxs.ts +6 -4
- package/src/methods/listNfts/listNfts.ts +3 -1
- package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +1 -0
- package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +2 -0
- package/src/methods/transferNfts/addTransferNftTx.ts +6 -25
- package/src/methods/transferNfts/transferNfts.ts +35 -0
- package/src/methods/unlistListings/addUnlistListingTxs.ts +22 -0
package/dist/index.js
CHANGED
|
@@ -1280,7 +1280,7 @@ var getSharedObjects = async (nftType) => {
|
|
|
1280
1280
|
};
|
|
1281
1281
|
|
|
1282
1282
|
// src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts
|
|
1283
|
-
var
|
|
1283
|
+
var import_utils4 = require("@mysten/sui/utils");
|
|
1284
1284
|
|
|
1285
1285
|
// src/utils/normalizeNftType.ts
|
|
1286
1286
|
var normalizedNftType = (nftType) => {
|
|
@@ -1319,7 +1319,10 @@ var hasPersonalKioskRule = (transferPolicies) => getNativeKioskTransferPolicies(
|
|
|
1319
1319
|
);
|
|
1320
1320
|
|
|
1321
1321
|
// src/helpers/hasTransferPolicyRules.ts
|
|
1322
|
-
var hasNativeKioskTransferPolicyRules = (transferPolicies) =>
|
|
1322
|
+
var hasNativeKioskTransferPolicyRules = (transferPolicies) => {
|
|
1323
|
+
const nativeKioskTransferPolicies = getNativeKioskTransferPolicies(transferPolicies);
|
|
1324
|
+
return nativeKioskTransferPolicies?.some((policy) => policy?.rules?.length > 0);
|
|
1325
|
+
};
|
|
1323
1326
|
|
|
1324
1327
|
// src/helpers/isSIngleBid.ts
|
|
1325
1328
|
var isSingleBid = (bidType) => {
|
|
@@ -1379,16 +1382,52 @@ function addHexPrefix(input) {
|
|
|
1379
1382
|
return "0x" + input;
|
|
1380
1383
|
}
|
|
1381
1384
|
|
|
1385
|
+
// src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts
|
|
1386
|
+
var import_utils = require("@mysten/sui/utils");
|
|
1387
|
+
var getTransferPolicyRuleNamesFromSuiObject = async ({
|
|
1388
|
+
suiClient,
|
|
1389
|
+
transferPolicyId
|
|
1390
|
+
}) => {
|
|
1391
|
+
const { data, error } = await suiClient.getObject({
|
|
1392
|
+
id: (0, import_utils.normalizeSuiObjectId)(transferPolicyId),
|
|
1393
|
+
options: {
|
|
1394
|
+
showContent: true
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
if (error) {
|
|
1398
|
+
throw new Error(`Error on getting SUI object ${transferPolicyId}: ${error.code}`);
|
|
1399
|
+
}
|
|
1400
|
+
const content = data.content;
|
|
1401
|
+
const ruleNames = content.fields.rules.fields.contents.map(
|
|
1402
|
+
(rule) => (0, import_utils.normalizeStructTag)(rule.fields.name)
|
|
1403
|
+
);
|
|
1404
|
+
return ruleNames;
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1382
1407
|
// src/helpers/kiosk/getRulePackageId.ts
|
|
1383
1408
|
var getRulePackageId = async ({
|
|
1409
|
+
transferPolicies,
|
|
1384
1410
|
nftType,
|
|
1385
1411
|
ruleType,
|
|
1386
|
-
kioskClient
|
|
1412
|
+
kioskClient,
|
|
1413
|
+
suiClient
|
|
1387
1414
|
}) => {
|
|
1388
|
-
const
|
|
1415
|
+
const transferPoliciesFromMystenSdk = await kioskClient.getTransferPolicies({
|
|
1389
1416
|
type: normalizedNftType(nftType)
|
|
1390
1417
|
});
|
|
1391
|
-
|
|
1418
|
+
let rule;
|
|
1419
|
+
if (transferPoliciesFromMystenSdk.length > 0) {
|
|
1420
|
+
rule = transferPoliciesFromMystenSdk.flatMap((policy) => policy.rules).filter((rule2) => rule2?.split("::")?.[1] === ruleType)?.[0];
|
|
1421
|
+
} else if (transferPolicies.length > 0) {
|
|
1422
|
+
const transferPolicyId = getNativeKioskTransferPolicies(transferPolicies)?.at(0)?.id;
|
|
1423
|
+
const ruleNames = await getTransferPolicyRuleNamesFromSuiObject({
|
|
1424
|
+
suiClient,
|
|
1425
|
+
transferPolicyId
|
|
1426
|
+
});
|
|
1427
|
+
rule = ruleNames.filter((ruleName) => ruleName?.split("::")?.[1] === ruleType)?.[0];
|
|
1428
|
+
} else {
|
|
1429
|
+
throw new Error(`No transfer policy found for ${nftType}`);
|
|
1430
|
+
}
|
|
1392
1431
|
const ruleDefinition = kioskClient.rules.find(
|
|
1393
1432
|
(x) => (0, import_kiosk2.getNormalizedRuleType)(x.rule) === (0, import_kiosk2.getNormalizedRuleType)(rule)
|
|
1394
1433
|
);
|
|
@@ -1525,211 +1564,16 @@ var kioskTxWrapper = async ({
|
|
|
1525
1564
|
}
|
|
1526
1565
|
};
|
|
1527
1566
|
|
|
1528
|
-
// src/helpers/
|
|
1529
|
-
var
|
|
1530
|
-
tx.moveCall({
|
|
1531
|
-
target: "0x6f42ec2355fcda5ebeee2399d901ae9f71cb214e640a45a0007f1f1cdf9f7b5e::transfer_allowlist::confirm_transfer",
|
|
1532
|
-
arguments: [tx.object(sharedObjects?.allowList), tx.object(transferRequest)],
|
|
1533
|
-
typeArguments: [nftType]
|
|
1534
|
-
});
|
|
1535
|
-
if (sharedObjects?.royaltyStrategy) {
|
|
1536
|
-
tx.moveCall({
|
|
1537
|
-
target: "0x6f42ec2355fcda5ebeee2399d901ae9f71cb214e640a45a0007f1f1cdf9f7b5e::royalty_strategy_bps::confirm_transfer",
|
|
1538
|
-
arguments: [tx.object(sharedObjects?.royaltyStrategy), tx.object(transferRequest)],
|
|
1539
|
-
typeArguments: [nftType, "0x2::sui::SUI"]
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
tx.moveCall({
|
|
1543
|
-
target: "0xadf32ebafc587cc86e1e56e59f7b17c7e8cbeb3315193be63c6f73157d4e88b9::transfer_request::confirm",
|
|
1544
|
-
arguments: [tx.object(transferRequest), tx.object(sharedObjects?.transferPolicy)],
|
|
1545
|
-
typeArguments: [nftType, "0x2::sui::SUI"]
|
|
1546
|
-
});
|
|
1547
|
-
};
|
|
1548
|
-
|
|
1549
|
-
// src/helpers/originByte/depositNftIntoOBKiosk.ts
|
|
1550
|
-
var depositItemIntoOBKiosk = ({ tx, kiosk, nftTokenId, nftType }) => {
|
|
1551
|
-
tx.moveCall({
|
|
1552
|
-
target: "0x2678c98fe23173eebea384509464eb81b1f3035a57419cb46d025000c337451a::ob_kiosk::deposit",
|
|
1553
|
-
arguments: [tx.object(kiosk), tx.object(nftTokenId)],
|
|
1554
|
-
typeArguments: [nftType]
|
|
1555
|
-
});
|
|
1556
|
-
};
|
|
1557
|
-
|
|
1558
|
-
// src/helpers/originByte/createOBKiosk.ts
|
|
1559
|
-
var createOBKiosk = async ({ tx, createMethod = "new" }) => {
|
|
1560
|
-
const [kiosk] = tx.moveCall({
|
|
1561
|
-
target: `0x2678c98fe23173eebea384509464eb81b1f3035a57419cb46d025000c337451a::ob_kiosk::${createMethod}`,
|
|
1562
|
-
arguments: [],
|
|
1563
|
-
typeArguments: []
|
|
1564
|
-
});
|
|
1565
|
-
return [kiosk];
|
|
1566
|
-
};
|
|
1567
|
-
|
|
1568
|
-
// src/graphql/queries/fetchWalletKiosks.ts
|
|
1569
|
-
var import_graphql_request10 = require("graphql-request");
|
|
1570
|
-
var fetchWalletKiosks = import_graphql_request10.gql`
|
|
1571
|
-
query fetchWalletKiosks($wallet: String!) {
|
|
1572
|
-
kiosks: kiosks_by_owner_address(owner_address: $wallet) {
|
|
1573
|
-
id
|
|
1574
|
-
is_origin_byte
|
|
1575
|
-
is_personal
|
|
1576
|
-
owner_address
|
|
1577
|
-
profits
|
|
1578
|
-
is_shared
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
`;
|
|
1582
|
-
|
|
1583
|
-
// src/helpers/originByte/getOBKiosk.ts
|
|
1584
|
-
var getOBKiosk = async (wallet) => {
|
|
1585
|
-
const res = await gqlChainRequest({
|
|
1586
|
-
chain: "sui",
|
|
1587
|
-
query: fetchWalletKiosks,
|
|
1588
|
-
variables: { wallet: addLeadingZerosAfter0x(wallet) }
|
|
1589
|
-
});
|
|
1590
|
-
return res?.kiosks?.filter((kiosk) => kiosk?.is_origin_byte && kiosk?.is_shared)?.[0]?.id;
|
|
1591
|
-
};
|
|
1592
|
-
|
|
1593
|
-
// src/helpers/originByte/getOrCreateOBKiosk.ts
|
|
1594
|
-
var getOrCreateOBKiosk = async ({
|
|
1595
|
-
tx,
|
|
1596
|
-
address,
|
|
1597
|
-
kioskToUseIfExists,
|
|
1598
|
-
createMethod
|
|
1599
|
-
}) => {
|
|
1600
|
-
if (kioskToUseIfExists) {
|
|
1601
|
-
return {
|
|
1602
|
-
kiosk: kioskToUseIfExists,
|
|
1603
|
-
isNewKiosk: false
|
|
1604
|
-
};
|
|
1605
|
-
}
|
|
1606
|
-
const existingKiosk = await getOBKiosk(address);
|
|
1607
|
-
if (existingKiosk) {
|
|
1608
|
-
return {
|
|
1609
|
-
kiosk: existingKiosk,
|
|
1610
|
-
isNewKiosk: false
|
|
1611
|
-
};
|
|
1612
|
-
}
|
|
1613
|
-
const [newKiosk] = await createOBKiosk({ tx, createMethod });
|
|
1614
|
-
return {
|
|
1615
|
-
kiosk: newKiosk,
|
|
1616
|
-
isNewKiosk: true
|
|
1617
|
-
};
|
|
1618
|
-
};
|
|
1619
|
-
|
|
1620
|
-
// src/helpers/originByte/isOriginByteBid.ts
|
|
1621
|
-
var isOriginByteBid = (bidType) => bidType === ORIGIN_BYTE_BID_NONCE_TYPE || bidType === "0x2::Kiosk::Kiosk" || bidType === "0x2::kiosk::Kiosk";
|
|
1622
|
-
|
|
1623
|
-
// src/helpers/originByte/isOriginByteCollection.ts
|
|
1624
|
-
var isOriginByteCollection = (transferPolicies) => {
|
|
1625
|
-
const hasOriginBytePolicies = transferPolicies?.filter((policy) => policy?.is_origin_byte)?.length > 0;
|
|
1626
|
-
const hasNonOriginBytePoliciesWithRules = transferPolicies?.filter((policy) => !policy?.is_origin_byte)?.some((policy) => policy?.rules?.length > 0);
|
|
1627
|
-
return Boolean(hasOriginBytePolicies && !hasNonOriginBytePoliciesWithRules);
|
|
1628
|
-
};
|
|
1629
|
-
|
|
1630
|
-
// src/helpers/originByte/shareOriginByteKiosk.ts
|
|
1631
|
-
var shareOriginByteKiosk = async ({ tx, kiosk }) => {
|
|
1632
|
-
tx.moveCall({
|
|
1633
|
-
target: "0x2::transfer::public_share_object",
|
|
1634
|
-
arguments: [tx.object(kiosk)],
|
|
1635
|
-
typeArguments: ["0x2::kiosk::Kiosk"]
|
|
1636
|
-
});
|
|
1637
|
-
};
|
|
1638
|
-
|
|
1639
|
-
// src/helpers/rpc/getObjectType.ts
|
|
1640
|
-
var import_utils = require("@mysten/sui/utils");
|
|
1641
|
-
var getObjectType = async ({
|
|
1642
|
-
suiClient,
|
|
1643
|
-
objectId
|
|
1644
|
-
}) => {
|
|
1645
|
-
const normalizedObjectId = objectId.startsWith("0x") ? addLeadingZerosAfter0x(objectId) : objectId;
|
|
1646
|
-
if ((0, import_utils.isValidSuiObjectId)(normalizedObjectId)) {
|
|
1647
|
-
const res = await suiClient.getObject({ id: normalizedObjectId, options: { showType: true } });
|
|
1648
|
-
return res.data.type;
|
|
1649
|
-
}
|
|
1650
|
-
return "";
|
|
1651
|
-
};
|
|
1652
|
-
|
|
1653
|
-
// src/methods/acceptNftBids/addAcceptNftBidTxs.ts
|
|
1654
|
-
var import_utils2 = require("@mysten/sui/utils");
|
|
1655
|
-
|
|
1656
|
-
// src/graphql/queries/fetchMultibidById.ts
|
|
1657
|
-
var import_graphql_request11 = require("graphql-request");
|
|
1658
|
-
var fetchMultibidChainIdById = import_graphql_request11.gql`
|
|
1659
|
-
query fetchMultibidById($multiBidId: uuid!) {
|
|
1660
|
-
multi_bids(where: { id: { _eq: $multiBidId } }) {
|
|
1661
|
-
chain_id
|
|
1662
|
-
cancelled_at
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
`;
|
|
1666
|
-
|
|
1667
|
-
// src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts
|
|
1668
|
-
var lockNftInsideKioskIfNotLocked = async ({
|
|
1669
|
-
tx,
|
|
1670
|
-
kioskClient,
|
|
1567
|
+
// src/helpers/kiosk/getKioskIdFromKioskTx.ts
|
|
1568
|
+
var getKioskIdFromKioskTx = ({
|
|
1671
1569
|
kioskTx,
|
|
1672
|
-
|
|
1673
|
-
nftType,
|
|
1674
|
-
transferPolicyId
|
|
1570
|
+
tx
|
|
1675
1571
|
}) => {
|
|
1676
|
-
if (lockNftInsideKioskIfKioskCreatedInThisTx({ tx, kioskTx, nftTokenId, nftType, transferPolicyId })) {
|
|
1677
|
-
return;
|
|
1678
|
-
}
|
|
1679
1572
|
const kioskId = "value" in kioskTx.kiosk ? kioskTx.kiosk.value : "Input" in kioskTx.kiosk ? tx.blockData.inputs[kioskTx.kiosk.Input].value : (() => {
|
|
1680
1573
|
throw new Error("Invalid kiosk transaction structure");
|
|
1681
1574
|
})();
|
|
1682
|
-
|
|
1683
|
-
const nftInKiosk = res.items.find((i) => i.objectId === nftTokenId);
|
|
1684
|
-
let takeFromKiosk = true;
|
|
1685
|
-
if (!nftInKiosk) {
|
|
1686
|
-
const result = await kioskClient.client.getObject({
|
|
1687
|
-
id: nftTokenId,
|
|
1688
|
-
options: { showOwner: true }
|
|
1689
|
-
});
|
|
1690
|
-
if (result.data.owner.AddressOwner) {
|
|
1691
|
-
takeFromKiosk = false;
|
|
1692
|
-
} else {
|
|
1693
|
-
throw new Error(`NFT ${nftTokenId} is not found in kiosk ${kioskId}`);
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
if (!nftInKiosk?.isLocked) {
|
|
1697
|
-
let takenNftId;
|
|
1698
|
-
if (takeFromKiosk) {
|
|
1699
|
-
const takenNft = kioskTx.take({
|
|
1700
|
-
itemId: nftTokenId,
|
|
1701
|
-
itemType: nftType
|
|
1702
|
-
});
|
|
1703
|
-
takenNftId = "value" in takenNft ? takenNft.value : takenNft;
|
|
1704
|
-
}
|
|
1705
|
-
kioskTx.lock({
|
|
1706
|
-
itemId: takenNftId ?? nftTokenId,
|
|
1707
|
-
itemType: nftType,
|
|
1708
|
-
policy: transferPolicyId
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1575
|
+
return kioskId;
|
|
1711
1576
|
};
|
|
1712
|
-
function lockNftInsideKioskIfKioskCreatedInThisTx({
|
|
1713
|
-
tx,
|
|
1714
|
-
kioskTx,
|
|
1715
|
-
nftTokenId,
|
|
1716
|
-
nftType,
|
|
1717
|
-
transferPolicyId
|
|
1718
|
-
}) {
|
|
1719
|
-
if (Array.isArray(kioskTx.kiosk.NestedResult)) {
|
|
1720
|
-
const transaction = tx.blockData.transactions[kioskTx.kiosk.NestedResult[0]];
|
|
1721
|
-
if (transaction.target === "0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::new" || transaction.target === "0x0000000000000000000000000000000000000000000000000000000000000002::personal_kiosk::new") {
|
|
1722
|
-
kioskTx.lock({
|
|
1723
|
-
itemId: nftTokenId,
|
|
1724
|
-
itemType: nftType,
|
|
1725
|
-
policy: transferPolicyId
|
|
1726
|
-
});
|
|
1727
|
-
return true;
|
|
1728
|
-
}
|
|
1729
|
-
throw new Error(`Unsupported kiosk move call ${transaction.target}`);
|
|
1730
|
-
}
|
|
1731
|
-
return false;
|
|
1732
|
-
}
|
|
1733
1577
|
|
|
1734
1578
|
// src/helpers/kiosk/resolveTransferPolicies.ts
|
|
1735
1579
|
var import_kiosk4 = require("@mysten/kiosk");
|
|
@@ -1860,161 +1704,474 @@ async function resolveRoyaltyRule({
|
|
|
1860
1704
|
});
|
|
1861
1705
|
}
|
|
1862
1706
|
|
|
1863
|
-
// src/helpers/kiosk/resolveTransferPolicies.ts
|
|
1864
|
-
var originByteRuleModules = ["royalty_strategy_bps", "transfer_allowlist"];
|
|
1865
|
-
var resolveTransferPolicies = async ({
|
|
1707
|
+
// src/helpers/kiosk/resolveTransferPolicies.ts
|
|
1708
|
+
var originByteRuleModules = ["royalty_strategy_bps", "transfer_allowlist"];
|
|
1709
|
+
var resolveTransferPolicies = async ({
|
|
1710
|
+
tx,
|
|
1711
|
+
transferPolicies,
|
|
1712
|
+
suiClient,
|
|
1713
|
+
walletAddress,
|
|
1714
|
+
kioskClient,
|
|
1715
|
+
kioskTx,
|
|
1716
|
+
nftType,
|
|
1717
|
+
kioskToLockRuleProve,
|
|
1718
|
+
kioskItem,
|
|
1719
|
+
transferRequest,
|
|
1720
|
+
customTransferPolicies,
|
|
1721
|
+
price,
|
|
1722
|
+
shouldSkipKioskLocking,
|
|
1723
|
+
shouldSkipResolvingRoyaltyRule,
|
|
1724
|
+
coinToSplit,
|
|
1725
|
+
beforeResolveKioskTransferRequest
|
|
1726
|
+
}) => {
|
|
1727
|
+
const transferPoliciesFromMystenSdk = await kioskClient.getTransferPolicies({
|
|
1728
|
+
type: normalizedNftType(nftType)
|
|
1729
|
+
});
|
|
1730
|
+
let policies = [];
|
|
1731
|
+
if (transferPoliciesFromMystenSdk.length > 0) {
|
|
1732
|
+
policies = [
|
|
1733
|
+
{
|
|
1734
|
+
data: (
|
|
1735
|
+
// Find first policy with relevant rules, or fall back to first policy
|
|
1736
|
+
transferPoliciesFromMystenSdk.find(
|
|
1737
|
+
(policy) => policy?.rules?.some(
|
|
1738
|
+
(rule) => knownTransferPolicyRules.some((ruleType) => rule?.includes(ruleType))
|
|
1739
|
+
)
|
|
1740
|
+
) ?? transferPoliciesFromMystenSdk[0]
|
|
1741
|
+
),
|
|
1742
|
+
transferRequest,
|
|
1743
|
+
isCustom: false
|
|
1744
|
+
}
|
|
1745
|
+
];
|
|
1746
|
+
} else if (transferPolicies.length > 0) {
|
|
1747
|
+
const transferPolicyId = getNativeKioskTransferPolicies(transferPolicies)?.at(0)?.id;
|
|
1748
|
+
if (transferPolicyId) {
|
|
1749
|
+
const ruleNames = await getTransferPolicyRuleNamesFromSuiObject({
|
|
1750
|
+
suiClient,
|
|
1751
|
+
transferPolicyId
|
|
1752
|
+
});
|
|
1753
|
+
if (ruleNames.length > 0) {
|
|
1754
|
+
policies = [
|
|
1755
|
+
{
|
|
1756
|
+
data: {
|
|
1757
|
+
id: transferPolicyId,
|
|
1758
|
+
rules: ruleNames
|
|
1759
|
+
},
|
|
1760
|
+
transferRequest,
|
|
1761
|
+
isCustom: false
|
|
1762
|
+
}
|
|
1763
|
+
];
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
} else if ((customTransferPolicies ?? []).every(
|
|
1767
|
+
(p) => p.transferRequest !== transferRequest
|
|
1768
|
+
)) {
|
|
1769
|
+
throw new Error(
|
|
1770
|
+
`Missing transfer policy of ${nftType}. No way to resolve the transfer request.`
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
if (customTransferPolicies) {
|
|
1774
|
+
for (const customTransferPolicy of customTransferPolicies) {
|
|
1775
|
+
const customPolicy = await kioskClient.getTransferPolicies({
|
|
1776
|
+
type: normalizedNftType(customTransferPolicy?.type)
|
|
1777
|
+
});
|
|
1778
|
+
policies = [
|
|
1779
|
+
...policies,
|
|
1780
|
+
{
|
|
1781
|
+
data: customPolicy[0],
|
|
1782
|
+
transferRequest: customTransferPolicy?.transferRequest,
|
|
1783
|
+
isCustom: true,
|
|
1784
|
+
type: customTransferPolicy?.type
|
|
1785
|
+
}
|
|
1786
|
+
];
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
let canTransferOutsideKiosk = true;
|
|
1790
|
+
for (const policy of policies) {
|
|
1791
|
+
const kioskLockRule = policy?.data?.rules.find(
|
|
1792
|
+
(rule) => rule?.includes("kiosk_lock_rule")
|
|
1793
|
+
);
|
|
1794
|
+
const personalKioskRule = policy.data.rules.find(
|
|
1795
|
+
(rule) => rule.includes("personal_kiosk_rule")
|
|
1796
|
+
);
|
|
1797
|
+
const otherRules = policy.data.rules.filter(
|
|
1798
|
+
(rule) => !rule?.includes("kiosk_lock_rule") && !rule?.includes("personal_kiosk_rule")
|
|
1799
|
+
);
|
|
1800
|
+
const sortedRules = [kioskLockRule, personalKioskRule, ...otherRules].filter(Boolean);
|
|
1801
|
+
for (const rule of sortedRules) {
|
|
1802
|
+
const ruleDefinition = kioskClient.rules.find(
|
|
1803
|
+
(x) => (0, import_kiosk4.getNormalizedRuleType)(x.rule) === (0, import_kiosk4.getNormalizedRuleType)(rule)
|
|
1804
|
+
);
|
|
1805
|
+
let rulePackageId = ruleDefinition?.packageId;
|
|
1806
|
+
if (!rulePackageId) {
|
|
1807
|
+
rulePackageId = rule?.split("::")?.[0];
|
|
1808
|
+
}
|
|
1809
|
+
const moduleName = rule?.split("::")?.[1];
|
|
1810
|
+
if (originByteRuleModules.includes(moduleName)) {
|
|
1811
|
+
throw new Error(`Using Origin Byte rule ${rule} inside the native kiosk transaction`);
|
|
1812
|
+
}
|
|
1813
|
+
switch (moduleName) {
|
|
1814
|
+
case "kiosk_lock_rule":
|
|
1815
|
+
canTransferOutsideKiosk = false;
|
|
1816
|
+
resolveKioskLockRule({
|
|
1817
|
+
tx,
|
|
1818
|
+
packageId: rulePackageId,
|
|
1819
|
+
policyId: policy.data.id,
|
|
1820
|
+
transferRequest: policy.transferRequest,
|
|
1821
|
+
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1822
|
+
kiosk: kioskToLockRuleProve ? kioskToLockRuleProve : kioskTx.kiosk,
|
|
1823
|
+
kioskCap: kioskTx.kioskCap,
|
|
1824
|
+
kioskItem,
|
|
1825
|
+
shouldSkipLocking: shouldSkipKioskLocking
|
|
1826
|
+
});
|
|
1827
|
+
break;
|
|
1828
|
+
case "personal_kiosk_rule":
|
|
1829
|
+
resolvePersonalKioskRule({
|
|
1830
|
+
tx,
|
|
1831
|
+
packageId: rulePackageId,
|
|
1832
|
+
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1833
|
+
kiosk: kioskTx.kiosk,
|
|
1834
|
+
transferRequest: policy.transferRequest
|
|
1835
|
+
});
|
|
1836
|
+
break;
|
|
1837
|
+
case "royalty_rule":
|
|
1838
|
+
case "kiosk_royalty_rule":
|
|
1839
|
+
if (shouldSkipResolvingRoyaltyRule) break;
|
|
1840
|
+
await resolveRoyaltyRule({
|
|
1841
|
+
tx,
|
|
1842
|
+
suiClient,
|
|
1843
|
+
walletAddress,
|
|
1844
|
+
packageId: rulePackageId,
|
|
1845
|
+
moduleName,
|
|
1846
|
+
policyId: policy.data.id,
|
|
1847
|
+
transferRequest: policy.transferRequest,
|
|
1848
|
+
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1849
|
+
price,
|
|
1850
|
+
coinToSplit
|
|
1851
|
+
});
|
|
1852
|
+
break;
|
|
1853
|
+
case "floor_price_rule":
|
|
1854
|
+
resolveFloorPriceRule({
|
|
1855
|
+
tx,
|
|
1856
|
+
packageId: rulePackageId,
|
|
1857
|
+
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1858
|
+
policyId: policy.data.id,
|
|
1859
|
+
transferRequest: policy.transferRequest
|
|
1860
|
+
});
|
|
1861
|
+
break;
|
|
1862
|
+
default:
|
|
1863
|
+
throw new Error(`No resolver for the following rule: ${rule}.`);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
if (canTransferOutsideKiosk && kioskItem) {
|
|
1868
|
+
kioskTx.place({ itemType: nftType, item: kioskItem });
|
|
1869
|
+
}
|
|
1870
|
+
await beforeResolveKioskTransferRequest?.(transferRequest);
|
|
1871
|
+
for (const policy of policies) {
|
|
1872
|
+
tx.moveCall({
|
|
1873
|
+
target: "0x2::transfer_policy::confirm_request",
|
|
1874
|
+
arguments: [tx.object(policy.data.id), policy.transferRequest],
|
|
1875
|
+
typeArguments: [policy.isCustom && policy.type ? policy.type : nftType]
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
// src/helpers/kiosk/takeLockedNftFromKiosk.ts
|
|
1881
|
+
var takeLockedNftFromKiosk = async ({
|
|
1882
|
+
tx,
|
|
1883
|
+
transferPolicies,
|
|
1884
|
+
suiClient,
|
|
1885
|
+
kioskTx,
|
|
1886
|
+
kioskClient,
|
|
1887
|
+
nftTokenId,
|
|
1888
|
+
nftType,
|
|
1889
|
+
kioskOwner
|
|
1890
|
+
}) => {
|
|
1891
|
+
const transferPolicy = getNativeKioskTransferPolicies(transferPolicies)?.at(0);
|
|
1892
|
+
const hasFloorPriceRule = transferPolicy?.rules?.some(
|
|
1893
|
+
(rule) => rule.type === "floor_price_rule"
|
|
1894
|
+
);
|
|
1895
|
+
if (hasFloorPriceRule) {
|
|
1896
|
+
throw new Error("Cannot take locked NFT from kiosk with a minimum floor price rule");
|
|
1897
|
+
}
|
|
1898
|
+
const [purchase_cap] = tx.moveCall({
|
|
1899
|
+
target: "0x2::kiosk::list_with_purchase_cap",
|
|
1900
|
+
arguments: [
|
|
1901
|
+
tx.object("value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
|
|
1902
|
+
tx.object("value" in kioskTx.kioskCap ? kioskTx.kioskCap.value : kioskTx.kioskCap),
|
|
1903
|
+
tx.pure.address(nftTokenId),
|
|
1904
|
+
tx.pure.u64(0)
|
|
1905
|
+
],
|
|
1906
|
+
typeArguments: [nftType]
|
|
1907
|
+
});
|
|
1908
|
+
const [zeroCoin] = tx.moveCall({
|
|
1909
|
+
target: "0x2::coin::zero",
|
|
1910
|
+
arguments: [],
|
|
1911
|
+
typeArguments: ["0x2::sui::SUI"]
|
|
1912
|
+
});
|
|
1913
|
+
const [nft, transferRequest] = tx.moveCall({
|
|
1914
|
+
target: "0x2::kiosk::purchase_with_cap",
|
|
1915
|
+
arguments: [
|
|
1916
|
+
tx.object("value" in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
|
|
1917
|
+
purchase_cap,
|
|
1918
|
+
zeroCoin
|
|
1919
|
+
],
|
|
1920
|
+
typeArguments: [nftType]
|
|
1921
|
+
});
|
|
1922
|
+
await resolveTransferPolicies({
|
|
1923
|
+
tx,
|
|
1924
|
+
transferPolicies,
|
|
1925
|
+
suiClient,
|
|
1926
|
+
walletAddress: kioskOwner,
|
|
1927
|
+
kioskTx,
|
|
1928
|
+
kioskClient,
|
|
1929
|
+
nftType,
|
|
1930
|
+
price: "0",
|
|
1931
|
+
transferRequest,
|
|
1932
|
+
shouldSkipKioskLocking: true
|
|
1933
|
+
});
|
|
1934
|
+
return nft;
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1937
|
+
// src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts
|
|
1938
|
+
var takeAndBorrowNftFromKiosk = async ({
|
|
1939
|
+
tx,
|
|
1940
|
+
transferPolicies,
|
|
1941
|
+
kioskTx,
|
|
1942
|
+
kioskClient,
|
|
1943
|
+
nftTokenId,
|
|
1944
|
+
nftType,
|
|
1945
|
+
suiClient,
|
|
1946
|
+
kioskOwner
|
|
1947
|
+
}) => {
|
|
1948
|
+
const kioskId = getKioskIdFromKioskTx({ kioskTx, tx });
|
|
1949
|
+
const res = await kioskClient.getKiosk({ id: kioskId });
|
|
1950
|
+
const nftInKiosk = res.items.find((i) => i.objectId === nftTokenId);
|
|
1951
|
+
let borrowedNft = null;
|
|
1952
|
+
if (nftInKiosk?.isLocked) {
|
|
1953
|
+
borrowedNft = await takeLockedNftFromKiosk({
|
|
1954
|
+
tx,
|
|
1955
|
+
transferPolicies,
|
|
1956
|
+
kioskTx,
|
|
1957
|
+
nftTokenId,
|
|
1958
|
+
nftType,
|
|
1959
|
+
suiClient,
|
|
1960
|
+
kioskClient,
|
|
1961
|
+
kioskOwner
|
|
1962
|
+
});
|
|
1963
|
+
} else {
|
|
1964
|
+
borrowedNft = kioskTx.take({
|
|
1965
|
+
itemId: nftTokenId,
|
|
1966
|
+
itemType: nftType
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
return borrowedNft;
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
// src/helpers/originByte/confirmOBTranfer.ts
|
|
1973
|
+
var confirmOBTranfer = ({ tx, sharedObjects, transferRequest, nftType }) => {
|
|
1974
|
+
tx.moveCall({
|
|
1975
|
+
target: "0x6f42ec2355fcda5ebeee2399d901ae9f71cb214e640a45a0007f1f1cdf9f7b5e::transfer_allowlist::confirm_transfer",
|
|
1976
|
+
arguments: [tx.object(sharedObjects?.allowList), tx.object(transferRequest)],
|
|
1977
|
+
typeArguments: [nftType]
|
|
1978
|
+
});
|
|
1979
|
+
if (sharedObjects?.royaltyStrategy) {
|
|
1980
|
+
tx.moveCall({
|
|
1981
|
+
target: "0x6f42ec2355fcda5ebeee2399d901ae9f71cb214e640a45a0007f1f1cdf9f7b5e::royalty_strategy_bps::confirm_transfer",
|
|
1982
|
+
arguments: [tx.object(sharedObjects?.royaltyStrategy), tx.object(transferRequest)],
|
|
1983
|
+
typeArguments: [nftType, "0x2::sui::SUI"]
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
tx.moveCall({
|
|
1987
|
+
target: "0xadf32ebafc587cc86e1e56e59f7b17c7e8cbeb3315193be63c6f73157d4e88b9::transfer_request::confirm",
|
|
1988
|
+
arguments: [tx.object(transferRequest), tx.object(sharedObjects?.transferPolicy)],
|
|
1989
|
+
typeArguments: [nftType, "0x2::sui::SUI"]
|
|
1990
|
+
});
|
|
1991
|
+
};
|
|
1992
|
+
|
|
1993
|
+
// src/helpers/originByte/depositNftIntoOBKiosk.ts
|
|
1994
|
+
var depositItemIntoOBKiosk = ({ tx, kiosk, nftTokenId, nftType }) => {
|
|
1995
|
+
tx.moveCall({
|
|
1996
|
+
target: "0x2678c98fe23173eebea384509464eb81b1f3035a57419cb46d025000c337451a::ob_kiosk::deposit",
|
|
1997
|
+
arguments: [tx.object(kiosk), tx.object(nftTokenId)],
|
|
1998
|
+
typeArguments: [nftType]
|
|
1999
|
+
});
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
// src/helpers/originByte/createOBKiosk.ts
|
|
2003
|
+
var createOBKiosk = async ({ tx, createMethod = "new" }) => {
|
|
2004
|
+
const [kiosk] = tx.moveCall({
|
|
2005
|
+
target: `0x2678c98fe23173eebea384509464eb81b1f3035a57419cb46d025000c337451a::ob_kiosk::${createMethod}`,
|
|
2006
|
+
arguments: [],
|
|
2007
|
+
typeArguments: []
|
|
2008
|
+
});
|
|
2009
|
+
return [kiosk];
|
|
2010
|
+
};
|
|
2011
|
+
|
|
2012
|
+
// src/graphql/queries/fetchWalletKiosks.ts
|
|
2013
|
+
var import_graphql_request10 = require("graphql-request");
|
|
2014
|
+
var fetchWalletKiosks = import_graphql_request10.gql`
|
|
2015
|
+
query fetchWalletKiosks($wallet: String!) {
|
|
2016
|
+
kiosks: kiosks_by_owner_address(owner_address: $wallet) {
|
|
2017
|
+
id
|
|
2018
|
+
is_origin_byte
|
|
2019
|
+
is_personal
|
|
2020
|
+
owner_address
|
|
2021
|
+
profits
|
|
2022
|
+
is_shared
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
`;
|
|
2026
|
+
|
|
2027
|
+
// src/helpers/originByte/getOBKiosk.ts
|
|
2028
|
+
var getOBKiosk = async (wallet) => {
|
|
2029
|
+
const res = await gqlChainRequest({
|
|
2030
|
+
chain: "sui",
|
|
2031
|
+
query: fetchWalletKiosks,
|
|
2032
|
+
variables: { wallet: addLeadingZerosAfter0x(wallet) }
|
|
2033
|
+
});
|
|
2034
|
+
return res?.kiosks?.filter((kiosk) => kiosk?.is_origin_byte && kiosk?.is_shared)?.[0]?.id;
|
|
2035
|
+
};
|
|
2036
|
+
|
|
2037
|
+
// src/helpers/originByte/getOrCreateOBKiosk.ts
|
|
2038
|
+
var getOrCreateOBKiosk = async ({
|
|
2039
|
+
tx,
|
|
2040
|
+
address,
|
|
2041
|
+
kioskToUseIfExists,
|
|
2042
|
+
createMethod
|
|
2043
|
+
}) => {
|
|
2044
|
+
if (kioskToUseIfExists) {
|
|
2045
|
+
return {
|
|
2046
|
+
kiosk: kioskToUseIfExists,
|
|
2047
|
+
isNewKiosk: false
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
const existingKiosk = await getOBKiosk(address);
|
|
2051
|
+
if (existingKiosk) {
|
|
2052
|
+
return {
|
|
2053
|
+
kiosk: existingKiosk,
|
|
2054
|
+
isNewKiosk: false
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
const [newKiosk] = await createOBKiosk({ tx, createMethod });
|
|
2058
|
+
return {
|
|
2059
|
+
kiosk: newKiosk,
|
|
2060
|
+
isNewKiosk: true
|
|
2061
|
+
};
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
// src/helpers/originByte/isOriginByteBid.ts
|
|
2065
|
+
var isOriginByteBid = (bidType) => bidType === ORIGIN_BYTE_BID_NONCE_TYPE || bidType === "0x2::Kiosk::Kiosk" || bidType === "0x2::kiosk::Kiosk";
|
|
2066
|
+
|
|
2067
|
+
// src/helpers/originByte/isOriginByteCollection.ts
|
|
2068
|
+
var isOriginByteCollection = (transferPolicies) => {
|
|
2069
|
+
const hasOriginBytePolicies = transferPolicies?.filter((policy) => policy?.is_origin_byte)?.length > 0;
|
|
2070
|
+
const hasNonOriginBytePoliciesWithRules = transferPolicies?.filter((policy) => !policy?.is_origin_byte)?.some((policy) => policy?.rules?.length > 0);
|
|
2071
|
+
return Boolean(hasOriginBytePolicies && !hasNonOriginBytePoliciesWithRules);
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
// src/helpers/originByte/shareOriginByteKiosk.ts
|
|
2075
|
+
var shareOriginByteKiosk = async ({ tx, kiosk }) => {
|
|
2076
|
+
tx.moveCall({
|
|
2077
|
+
target: "0x2::transfer::public_share_object",
|
|
2078
|
+
arguments: [tx.object(kiosk)],
|
|
2079
|
+
typeArguments: ["0x2::kiosk::Kiosk"]
|
|
2080
|
+
});
|
|
2081
|
+
};
|
|
2082
|
+
|
|
2083
|
+
// src/helpers/rpc/getObjectType.ts
|
|
2084
|
+
var import_utils2 = require("@mysten/sui/utils");
|
|
2085
|
+
var getObjectType = async ({
|
|
2086
|
+
suiClient,
|
|
2087
|
+
objectId
|
|
2088
|
+
}) => {
|
|
2089
|
+
const normalizedObjectId = objectId.startsWith("0x") ? addLeadingZerosAfter0x(objectId) : objectId;
|
|
2090
|
+
if ((0, import_utils2.isValidSuiObjectId)(normalizedObjectId)) {
|
|
2091
|
+
const res = await suiClient.getObject({ id: normalizedObjectId, options: { showType: true } });
|
|
2092
|
+
return res.data.type;
|
|
2093
|
+
}
|
|
2094
|
+
return "";
|
|
2095
|
+
};
|
|
2096
|
+
|
|
2097
|
+
// src/methods/acceptNftBids/addAcceptNftBidTxs.ts
|
|
2098
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
2099
|
+
|
|
2100
|
+
// src/graphql/queries/fetchMultibidById.ts
|
|
2101
|
+
var import_graphql_request11 = require("graphql-request");
|
|
2102
|
+
var fetchMultibidChainIdById = import_graphql_request11.gql`
|
|
2103
|
+
query fetchMultibidById($multiBidId: uuid!) {
|
|
2104
|
+
multi_bids(where: { id: { _eq: $multiBidId } }) {
|
|
2105
|
+
chain_id
|
|
2106
|
+
cancelled_at
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
`;
|
|
2110
|
+
|
|
2111
|
+
// src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts
|
|
2112
|
+
var lockNftInsideKioskIfNotLocked = async ({
|
|
1866
2113
|
tx,
|
|
1867
|
-
suiClient,
|
|
1868
|
-
walletAddress,
|
|
1869
2114
|
kioskClient,
|
|
1870
2115
|
kioskTx,
|
|
2116
|
+
nftTokenId,
|
|
1871
2117
|
nftType,
|
|
1872
|
-
|
|
1873
|
-
kioskItem,
|
|
1874
|
-
transferRequest,
|
|
1875
|
-
customTransferPolicies,
|
|
1876
|
-
price,
|
|
1877
|
-
shouldSkipKioskLocking,
|
|
1878
|
-
shouldSkipResolvingRoyaltyRule,
|
|
1879
|
-
coinToSplit,
|
|
1880
|
-
beforeResolveKioskTransferRequest
|
|
2118
|
+
transferPolicyId
|
|
1881
2119
|
}) => {
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
});
|
|
1885
|
-
if (transferPolicies.length === 0 && (customTransferPolicies ?? []).every(
|
|
1886
|
-
(p) => p.transferRequest !== transferRequest
|
|
1887
|
-
)) {
|
|
1888
|
-
throw new Error(
|
|
1889
|
-
`Missing transfer policy of ${nftType}. No way to resolve the transfer request.`
|
|
1890
|
-
);
|
|
2120
|
+
if (lockNftInsideKioskIfKioskCreatedInThisTx({ tx, kioskTx, nftTokenId, nftType, transferPolicyId })) {
|
|
2121
|
+
return;
|
|
1891
2122
|
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
2123
|
+
const kioskId = getKioskIdFromKioskTx({ kioskTx, tx });
|
|
2124
|
+
const res = await kioskClient.getKiosk({ id: kioskId });
|
|
2125
|
+
const nftInKiosk = res.items.find((i) => i.objectId === nftTokenId);
|
|
2126
|
+
let takeFromKiosk = true;
|
|
2127
|
+
if (!nftInKiosk) {
|
|
2128
|
+
const result = await kioskClient.client.getObject({
|
|
2129
|
+
id: nftTokenId,
|
|
2130
|
+
options: { showOwner: true }
|
|
2131
|
+
});
|
|
2132
|
+
if (result.data.owner.AddressOwner) {
|
|
2133
|
+
takeFromKiosk = false;
|
|
2134
|
+
} else {
|
|
2135
|
+
throw new Error(`NFT ${nftTokenId} is not found in kiosk ${kioskId}`);
|
|
1901
2136
|
}
|
|
1902
|
-
] : [];
|
|
1903
|
-
if (!policies?.[0]?.data && transferPolicies.length > 0) {
|
|
1904
|
-
policies = [
|
|
1905
|
-
{
|
|
1906
|
-
data: transferPolicies?.[0],
|
|
1907
|
-
transferRequest,
|
|
1908
|
-
isCustom: false
|
|
1909
|
-
}
|
|
1910
|
-
];
|
|
1911
2137
|
}
|
|
1912
|
-
if (
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2138
|
+
if (!nftInKiosk?.isLocked) {
|
|
2139
|
+
let takenNftId;
|
|
2140
|
+
if (takeFromKiosk) {
|
|
2141
|
+
const takenNft = kioskTx.take({
|
|
2142
|
+
itemId: nftTokenId,
|
|
2143
|
+
itemType: nftType
|
|
1916
2144
|
});
|
|
1917
|
-
|
|
1918
|
-
...policies,
|
|
1919
|
-
{
|
|
1920
|
-
data: customPolicy[0],
|
|
1921
|
-
transferRequest: customTransferPolicy?.transferRequest,
|
|
1922
|
-
isCustom: true,
|
|
1923
|
-
type: customTransferPolicy?.type
|
|
1924
|
-
}
|
|
1925
|
-
];
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
let canTransferOutsideKiosk = true;
|
|
1929
|
-
for (const policy of policies) {
|
|
1930
|
-
const kioskLockRule = policy?.data?.rules.find(
|
|
1931
|
-
(rule) => rule?.includes("kiosk_lock_rule")
|
|
1932
|
-
);
|
|
1933
|
-
const personalKioskRule = policy.data.rules.find(
|
|
1934
|
-
(rule) => rule.includes("personal_kiosk_rule")
|
|
1935
|
-
);
|
|
1936
|
-
const otherRules = policy.data.rules.filter(
|
|
1937
|
-
(rule) => !rule?.includes("kiosk_lock_rule") && !rule?.includes("personal_kiosk_rule")
|
|
1938
|
-
);
|
|
1939
|
-
const sortedRules = [kioskLockRule, personalKioskRule, ...otherRules].filter(Boolean);
|
|
1940
|
-
for (const rule of sortedRules) {
|
|
1941
|
-
const ruleDefinition = kioskClient.rules.find(
|
|
1942
|
-
(x) => (0, import_kiosk4.getNormalizedRuleType)(x.rule) === (0, import_kiosk4.getNormalizedRuleType)(rule)
|
|
1943
|
-
);
|
|
1944
|
-
let rulePackageId = ruleDefinition?.packageId;
|
|
1945
|
-
if (!rulePackageId) {
|
|
1946
|
-
rulePackageId = rule?.split("::")?.[0];
|
|
1947
|
-
}
|
|
1948
|
-
const moduleName = rule?.split("::")?.[1];
|
|
1949
|
-
if (originByteRuleModules.includes(moduleName)) {
|
|
1950
|
-
throw new Error(`Using Origin Byte rule ${rule} inside the native kiosk transaction`);
|
|
1951
|
-
}
|
|
1952
|
-
switch (moduleName) {
|
|
1953
|
-
case "kiosk_lock_rule":
|
|
1954
|
-
canTransferOutsideKiosk = false;
|
|
1955
|
-
resolveKioskLockRule({
|
|
1956
|
-
tx,
|
|
1957
|
-
packageId: rulePackageId,
|
|
1958
|
-
policyId: policy.data.id,
|
|
1959
|
-
transferRequest: policy.transferRequest,
|
|
1960
|
-
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1961
|
-
kiosk: kioskToLockRuleProve ? kioskToLockRuleProve : kioskTx.kiosk,
|
|
1962
|
-
kioskCap: kioskTx.kioskCap,
|
|
1963
|
-
kioskItem,
|
|
1964
|
-
shouldSkipLocking: shouldSkipKioskLocking
|
|
1965
|
-
});
|
|
1966
|
-
break;
|
|
1967
|
-
case "personal_kiosk_rule":
|
|
1968
|
-
resolvePersonalKioskRule({
|
|
1969
|
-
tx,
|
|
1970
|
-
packageId: rulePackageId,
|
|
1971
|
-
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1972
|
-
kiosk: kioskTx.kiosk,
|
|
1973
|
-
transferRequest: policy.transferRequest
|
|
1974
|
-
});
|
|
1975
|
-
break;
|
|
1976
|
-
case "royalty_rule":
|
|
1977
|
-
case "kiosk_royalty_rule":
|
|
1978
|
-
if (shouldSkipResolvingRoyaltyRule) break;
|
|
1979
|
-
await resolveRoyaltyRule({
|
|
1980
|
-
tx,
|
|
1981
|
-
suiClient,
|
|
1982
|
-
walletAddress,
|
|
1983
|
-
packageId: rulePackageId,
|
|
1984
|
-
moduleName,
|
|
1985
|
-
policyId: policy.data.id,
|
|
1986
|
-
transferRequest: policy.transferRequest,
|
|
1987
|
-
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1988
|
-
price,
|
|
1989
|
-
coinToSplit
|
|
1990
|
-
});
|
|
1991
|
-
break;
|
|
1992
|
-
case "floor_price_rule":
|
|
1993
|
-
resolveFloorPriceRule({
|
|
1994
|
-
tx,
|
|
1995
|
-
packageId: rulePackageId,
|
|
1996
|
-
nftType: policy.isCustom && policy.type ? policy.type : nftType,
|
|
1997
|
-
policyId: policy.data.id,
|
|
1998
|
-
transferRequest: policy.transferRequest
|
|
1999
|
-
});
|
|
2000
|
-
break;
|
|
2001
|
-
default:
|
|
2002
|
-
throw new Error(`No resolver for the following rule: ${rule}.`);
|
|
2003
|
-
}
|
|
2145
|
+
takenNftId = "value" in takenNft ? takenNft.value : takenNft;
|
|
2004
2146
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
await beforeResolveKioskTransferRequest?.(transferRequest);
|
|
2010
|
-
for (const policy of policies) {
|
|
2011
|
-
tx.moveCall({
|
|
2012
|
-
target: "0x2::transfer_policy::confirm_request",
|
|
2013
|
-
arguments: [tx.object(policy.data.id), policy.transferRequest],
|
|
2014
|
-
typeArguments: [policy.isCustom && policy.type ? policy.type : nftType]
|
|
2147
|
+
kioskTx.lock({
|
|
2148
|
+
itemId: takenNftId ?? nftTokenId,
|
|
2149
|
+
itemType: nftType,
|
|
2150
|
+
policy: transferPolicyId
|
|
2015
2151
|
});
|
|
2016
2152
|
}
|
|
2017
2153
|
};
|
|
2154
|
+
function lockNftInsideKioskIfKioskCreatedInThisTx({
|
|
2155
|
+
tx,
|
|
2156
|
+
kioskTx,
|
|
2157
|
+
nftTokenId,
|
|
2158
|
+
nftType,
|
|
2159
|
+
transferPolicyId
|
|
2160
|
+
}) {
|
|
2161
|
+
if (Array.isArray(kioskTx.kiosk.NestedResult)) {
|
|
2162
|
+
const transaction = tx.blockData.transactions[kioskTx.kiosk.NestedResult[0]];
|
|
2163
|
+
if (transaction.target === "0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::new" || transaction.target === "0x0000000000000000000000000000000000000000000000000000000000000002::personal_kiosk::new") {
|
|
2164
|
+
kioskTx.lock({
|
|
2165
|
+
itemId: nftTokenId,
|
|
2166
|
+
itemType: nftType,
|
|
2167
|
+
policy: transferPolicyId
|
|
2168
|
+
});
|
|
2169
|
+
return true;
|
|
2170
|
+
}
|
|
2171
|
+
throw new Error(`Unsupported kiosk move call ${transaction.target}`);
|
|
2172
|
+
}
|
|
2173
|
+
return false;
|
|
2174
|
+
}
|
|
2018
2175
|
|
|
2019
2176
|
// src/helpers/originByte/getOBBidderKiosk.ts
|
|
2020
2177
|
var getOBBidderKiosk = async ({
|
|
@@ -2101,6 +2258,7 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
2101
2258
|
await beforeResolveKioskTransferRequest?.(feeCoin, transferRequest);
|
|
2102
2259
|
await resolveTransferPolicies({
|
|
2103
2260
|
tx,
|
|
2261
|
+
transferPolicies,
|
|
2104
2262
|
suiClient,
|
|
2105
2263
|
walletAddress: seller,
|
|
2106
2264
|
kioskTx,
|
|
@@ -2133,6 +2291,7 @@ async function addTradeportKioskAcceptNftBidTx({
|
|
|
2133
2291
|
}
|
|
2134
2292
|
await resolveTransferPolicies({
|
|
2135
2293
|
tx,
|
|
2294
|
+
transferPolicies,
|
|
2136
2295
|
suiClient,
|
|
2137
2296
|
walletAddress: seller,
|
|
2138
2297
|
kioskTx,
|
|
@@ -2215,7 +2374,7 @@ function addBluemoveAcceptNftBidTx({
|
|
|
2215
2374
|
});
|
|
2216
2375
|
}
|
|
2217
2376
|
async function addSingleBidAcceptNftBidTx(txData) {
|
|
2218
|
-
const { nftType, tx, bidNonce, multiBidId, kioskClient, nftTokenId } = txData;
|
|
2377
|
+
const { nftType, tx, bidNonce, multiBidId, kioskClient, nftTokenId, suiClient } = txData;
|
|
2219
2378
|
const transferPolicies = getNativeKioskTransferPolicies(txData?.transferPolicies);
|
|
2220
2379
|
const transferPolicy = transferPolicies?.find(
|
|
2221
2380
|
(policy) => policy?.rules?.length > 0
|
|
@@ -2230,9 +2389,15 @@ async function addSingleBidAcceptNftBidTx(txData) {
|
|
|
2230
2389
|
}
|
|
2231
2390
|
if (transferPolicy) {
|
|
2232
2391
|
const transferPolicies2 = await kioskClient.getTransferPolicies({
|
|
2233
|
-
type: (0,
|
|
2392
|
+
type: (0, import_utils3.normalizeStructTag)(nftType)
|
|
2234
2393
|
});
|
|
2235
|
-
|
|
2394
|
+
let { rules: allRules } = transferPolicies2.find((p) => p.id === transferPolicy.id);
|
|
2395
|
+
if (allRules.length === 0) {
|
|
2396
|
+
allRules = await getTransferPolicyRuleNamesFromSuiObject({
|
|
2397
|
+
suiClient,
|
|
2398
|
+
transferPolicyId: transferPolicy.id
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2236
2401
|
const unsupportedRule = allRules.find(
|
|
2237
2402
|
(r) => !knownTransferPolicyRules.includes(r.split("::").at(1))
|
|
2238
2403
|
);
|
|
@@ -2252,9 +2417,9 @@ async function addSingleBidAcceptNftBidTx(txData) {
|
|
|
2252
2417
|
target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_with_transfer_policy`,
|
|
2253
2418
|
typeArguments: [nftType],
|
|
2254
2419
|
arguments: [
|
|
2255
|
-
tx.object(
|
|
2420
|
+
tx.object(import_utils3.SUI_CLOCK_OBJECT_ID),
|
|
2256
2421
|
tx.object(TRADEPORT_MULTI_BID_STORE),
|
|
2257
|
-
tx.pure.id((0,
|
|
2422
|
+
tx.pure.id((0, import_utils3.normalizeSuiObjectId)(bidNonce)),
|
|
2258
2423
|
tx.pure.option("id", multiBidChainId),
|
|
2259
2424
|
tx.object(kioskTx.getKiosk()),
|
|
2260
2425
|
tx.object(kioskTx.getKioskCap()),
|
|
@@ -2274,7 +2439,7 @@ async function addSingleBidAcceptNftBidTx(txData) {
|
|
|
2274
2439
|
target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::accept_bid_without_transfer_policy`,
|
|
2275
2440
|
typeArguments: [nftType],
|
|
2276
2441
|
arguments: [
|
|
2277
|
-
tx.object(
|
|
2442
|
+
tx.object(import_utils3.SUI_CLOCK_OBJECT_ID),
|
|
2278
2443
|
tx.object(TRADEPORT_MULTI_BID_STORE),
|
|
2279
2444
|
tx.pure.id(bidNonce),
|
|
2280
2445
|
tx.pure.option("id", multiBidChainId),
|
|
@@ -2285,7 +2450,7 @@ async function addSingleBidAcceptNftBidTx(txData) {
|
|
|
2285
2450
|
async function addTradePortAcceptNftBidTxHandler(txData) {
|
|
2286
2451
|
const bidType = await getObjectType({
|
|
2287
2452
|
suiClient: txData?.suiClient,
|
|
2288
|
-
objectId: (0,
|
|
2453
|
+
objectId: (0, import_utils3.normalizeSuiObjectId)(txData?.bidNonce)
|
|
2289
2454
|
});
|
|
2290
2455
|
if (isSingleBid(bidType)) {
|
|
2291
2456
|
await addSingleBidAcceptNftBidTx(txData);
|
|
@@ -2305,6 +2470,8 @@ async function addTradePortAcceptNftBidTxHandler(txData) {
|
|
|
2305
2470
|
if (txData?.sellerKiosk) {
|
|
2306
2471
|
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
2307
2472
|
const royaltyRulePackageId = await getRulePackageId({
|
|
2473
|
+
transferPolicies: txData?.transferPolicies,
|
|
2474
|
+
suiClient: txData?.suiClient,
|
|
2308
2475
|
nftType: txData?.nftType,
|
|
2309
2476
|
ruleType: "royalty_rule",
|
|
2310
2477
|
kioskClient: txData?.kioskClient
|
|
@@ -2490,6 +2657,22 @@ async function addTradePortUnlistTxHandler(txData) {
|
|
|
2490
2657
|
...txData,
|
|
2491
2658
|
kioskTx
|
|
2492
2659
|
});
|
|
2660
|
+
if (!hasNativeKioskTransferPolicyRules(txData?.transferPolicies)) {
|
|
2661
|
+
const borrowedItem = await takeAndBorrowNftFromKiosk({
|
|
2662
|
+
tx: txData?.tx,
|
|
2663
|
+
transferPolicies: txData?.transferPolicies,
|
|
2664
|
+
kioskTx,
|
|
2665
|
+
kioskClient: txData?.kioskClient,
|
|
2666
|
+
nftTokenId: txData?.nftTokenId,
|
|
2667
|
+
nftType: txData?.nftType,
|
|
2668
|
+
suiClient: txData?.suiClient,
|
|
2669
|
+
kioskOwner: txData?.seller
|
|
2670
|
+
});
|
|
2671
|
+
txData?.tx.transferObjects(
|
|
2672
|
+
[txData?.tx.object(borrowedItem)],
|
|
2673
|
+
txData?.tx.pure.address(addLeadingZerosAfter0x(txData?.seller))
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2493
2676
|
}
|
|
2494
2677
|
});
|
|
2495
2678
|
}
|
|
@@ -2730,7 +2913,7 @@ function addTocenAcceptCollectionBidTx({
|
|
|
2730
2913
|
async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
2731
2914
|
const bidType = await getObjectType({
|
|
2732
2915
|
suiClient: txData?.suiClient,
|
|
2733
|
-
objectId: (0,
|
|
2916
|
+
objectId: (0, import_utils4.normalizeSuiObjectId)(txData?.bidNonce)
|
|
2734
2917
|
});
|
|
2735
2918
|
if (isSingleBid(bidType)) {
|
|
2736
2919
|
await addSingleBidAcceptNftBidTx(txData);
|
|
@@ -2755,17 +2938,25 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
|
2755
2938
|
kiosk: txData?.sellerKiosk,
|
|
2756
2939
|
shouldAssertNftInSharedKiosk: true,
|
|
2757
2940
|
async runCommands(kioskTx) {
|
|
2758
|
-
const
|
|
2759
|
-
|
|
2760
|
-
|
|
2941
|
+
const borrowedItem = await takeAndBorrowNftFromKiosk({
|
|
2942
|
+
tx: txData?.tx,
|
|
2943
|
+
transferPolicies: txData?.transferPolicies,
|
|
2944
|
+
kioskTx,
|
|
2945
|
+
kioskClient: txData?.kioskClient,
|
|
2946
|
+
nftTokenId: txData?.nftTokenId,
|
|
2947
|
+
nftType: txData?.nftType,
|
|
2948
|
+
suiClient: txData?.suiClient,
|
|
2949
|
+
kioskOwner: txData?.seller
|
|
2761
2950
|
});
|
|
2762
|
-
addTradeportAcceptCollectionBidTx({ ...txData, itemTakenOutOfNativeKiosk:
|
|
2951
|
+
addTradeportAcceptCollectionBidTx({ ...txData, itemTakenOutOfNativeKiosk: borrowedItem });
|
|
2763
2952
|
}
|
|
2764
2953
|
});
|
|
2765
2954
|
}
|
|
2766
2955
|
if (isTradePortKioskBid(bidType)) {
|
|
2767
2956
|
const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
|
|
2768
2957
|
const royaltyRulePackageId = await getRulePackageId({
|
|
2958
|
+
transferPolicies: txData?.transferPolicies,
|
|
2959
|
+
suiClient: txData?.suiClient,
|
|
2769
2960
|
nftType: txData?.nftType,
|
|
2770
2961
|
ruleType: "royalty_rule",
|
|
2771
2962
|
kioskClient: txData?.kioskClient
|
|
@@ -2835,11 +3026,17 @@ async function addBluemoveAcceptCollectionBidTxHandler(txData) {
|
|
|
2835
3026
|
kiosk: txData?.sellerKiosk,
|
|
2836
3027
|
shouldAssertNftInSharedKiosk: true,
|
|
2837
3028
|
async runCommands(kioskTx) {
|
|
2838
|
-
const
|
|
2839
|
-
|
|
2840
|
-
|
|
3029
|
+
const borrowedItem = await takeAndBorrowNftFromKiosk({
|
|
3030
|
+
tx: txData?.tx,
|
|
3031
|
+
transferPolicies: txData?.transferPolicies,
|
|
3032
|
+
kioskTx,
|
|
3033
|
+
kioskClient: txData?.kioskClient,
|
|
3034
|
+
nftTokenId: txData?.nftTokenId,
|
|
3035
|
+
nftType: txData?.nftType,
|
|
3036
|
+
suiClient: txData?.suiClient,
|
|
3037
|
+
kioskOwner: txData?.itemOwner
|
|
2841
3038
|
});
|
|
2842
|
-
addBluemoveAcceptCollectionBidTx({ ...txData, itemTakenOutOfNativeKiosk:
|
|
3039
|
+
addBluemoveAcceptCollectionBidTx({ ...txData, itemTakenOutOfNativeKiosk: borrowedItem });
|
|
2843
3040
|
}
|
|
2844
3041
|
});
|
|
2845
3042
|
}
|
|
@@ -3075,7 +3272,7 @@ var acceptNftBids = async ({
|
|
|
3075
3272
|
var import_transactions6 = require("@mysten/sui/transactions");
|
|
3076
3273
|
|
|
3077
3274
|
// src/methods/buyLocks/buyLocks.ts
|
|
3078
|
-
var
|
|
3275
|
+
var import_utils5 = require("@mysten/sui.js/utils");
|
|
3079
3276
|
var import_transactions4 = require("@mysten/sui/transactions");
|
|
3080
3277
|
|
|
3081
3278
|
// src/helpers/calculatePremium.ts
|
|
@@ -3241,7 +3438,7 @@ async function buyLocks({ lockIds, transaction }, context) {
|
|
|
3241
3438
|
typeArguments: [lock.nft_type],
|
|
3242
3439
|
arguments: [
|
|
3243
3440
|
tx.object(TRADEPORT_PRICE_LOCK_STORE),
|
|
3244
|
-
tx.object(
|
|
3441
|
+
tx.object(import_utils5.SUI_CLOCK_OBJECT_ID),
|
|
3245
3442
|
tx.pure.id(lock.lock_id),
|
|
3246
3443
|
tx.pure.u64(lock.maker_price),
|
|
3247
3444
|
tx.pure.u64(marketplaceFee),
|
|
@@ -3255,7 +3452,7 @@ async function buyLocks({ lockIds, transaction }, context) {
|
|
|
3255
3452
|
}
|
|
3256
3453
|
|
|
3257
3454
|
// src/methods/exerciseLongLocks/exerciseLongLocks.ts
|
|
3258
|
-
var
|
|
3455
|
+
var import_utils6 = require("@mysten/sui.js/utils");
|
|
3259
3456
|
var import_transactions5 = require("@mysten/sui/transactions");
|
|
3260
3457
|
async function exerciseLongLocks({ walletAddress, transaction, locks }, context) {
|
|
3261
3458
|
const tx = transaction ?? new import_transactions5.Transaction();
|
|
@@ -3313,7 +3510,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
|
|
|
3313
3510
|
typeArguments: [lock.nft_type],
|
|
3314
3511
|
arguments: [
|
|
3315
3512
|
tx.object(TRADEPORT_PRICE_LOCK_STORE),
|
|
3316
|
-
tx.object(
|
|
3513
|
+
tx.object(import_utils6.SUI_CLOCK_OBJECT_ID),
|
|
3317
3514
|
tx.pure.id(lock.lock_id),
|
|
3318
3515
|
tx.object(lock.chain_state.makerKioskId),
|
|
3319
3516
|
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
@@ -3323,6 +3520,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
|
|
|
3323
3520
|
});
|
|
3324
3521
|
await resolveTransferPolicies({
|
|
3325
3522
|
tx,
|
|
3523
|
+
transferPolicies,
|
|
3326
3524
|
suiClient: context.suiClient,
|
|
3327
3525
|
walletAddress,
|
|
3328
3526
|
kioskTx,
|
|
@@ -3390,6 +3588,7 @@ async function exerciseLongLocks({ walletAddress, transaction, locks }, context)
|
|
|
3390
3588
|
});
|
|
3391
3589
|
await resolveTransferPolicies({
|
|
3392
3590
|
tx,
|
|
3591
|
+
transferPolicies,
|
|
3393
3592
|
suiClient: context.suiClient,
|
|
3394
3593
|
walletAddress,
|
|
3395
3594
|
kioskTx,
|
|
@@ -3418,7 +3617,7 @@ async function buyAndExerciseLongLocks({ walletAddress, locks, tx: existingTx },
|
|
|
3418
3617
|
var import_transactions9 = require("@mysten/sui/transactions");
|
|
3419
3618
|
|
|
3420
3619
|
// src/methods/exerciseShortLocks/exerciseShortLocks.ts
|
|
3421
|
-
var
|
|
3620
|
+
var import_utils7 = require("@mysten/sui.js/utils");
|
|
3422
3621
|
var import_transactions8 = require("@mysten/sui/transactions");
|
|
3423
3622
|
|
|
3424
3623
|
// src/graphql/queries/fetchListingsById.ts
|
|
@@ -3542,6 +3741,7 @@ function addTradePortBuyTx({ tx, nftType, listingNonce, price, sharedObjects })
|
|
|
3542
3741
|
}
|
|
3543
3742
|
var addTradeportKioskBuyTx = async ({
|
|
3544
3743
|
tx,
|
|
3744
|
+
transferPolicies,
|
|
3545
3745
|
kioskTx,
|
|
3546
3746
|
suiClient,
|
|
3547
3747
|
kioskClient,
|
|
@@ -3578,6 +3778,7 @@ var addTradeportKioskBuyTx = async ({
|
|
|
3578
3778
|
});
|
|
3579
3779
|
await resolveTransferPolicies({
|
|
3580
3780
|
tx,
|
|
3781
|
+
transferPolicies,
|
|
3581
3782
|
suiClient,
|
|
3582
3783
|
walletAddress: seller,
|
|
3583
3784
|
kioskTx,
|
|
@@ -3630,6 +3831,7 @@ async function addOriginByteBuyTx({
|
|
|
3630
3831
|
}
|
|
3631
3832
|
var addHyperspaceKioskBuyTx = async ({
|
|
3632
3833
|
tx,
|
|
3834
|
+
transferPolicies,
|
|
3633
3835
|
suiClient,
|
|
3634
3836
|
kioskTx,
|
|
3635
3837
|
kioskClient,
|
|
@@ -3661,6 +3863,7 @@ var addHyperspaceKioskBuyTx = async ({
|
|
|
3661
3863
|
await beforeResolveKioskTransferRequest?.(transferRequest);
|
|
3662
3864
|
await resolveTransferPolicies({
|
|
3663
3865
|
tx,
|
|
3866
|
+
transferPolicies,
|
|
3664
3867
|
suiClient,
|
|
3665
3868
|
walletAddress: seller,
|
|
3666
3869
|
kioskTx,
|
|
@@ -3725,6 +3928,7 @@ async function addBluemoveKioskBuyTx({
|
|
|
3725
3928
|
await beforeResolveKioskTransferRequest?.(transferRequest);
|
|
3726
3929
|
await resolveTransferPolicies({
|
|
3727
3930
|
tx,
|
|
3931
|
+
transferPolicies,
|
|
3728
3932
|
suiClient,
|
|
3729
3933
|
walletAddress: seller,
|
|
3730
3934
|
kioskTx,
|
|
@@ -4141,7 +4345,7 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
|
|
|
4141
4345
|
typeArguments: [lock.nft_type],
|
|
4142
4346
|
arguments: [
|
|
4143
4347
|
tx.object(TRADEPORT_PRICE_LOCK_STORE),
|
|
4144
|
-
tx.object(
|
|
4348
|
+
tx.object(import_utils7.SUI_CLOCK_OBJECT_ID),
|
|
4145
4349
|
tx.pure.id(lock.lock_id)
|
|
4146
4350
|
]
|
|
4147
4351
|
});
|
|
@@ -4192,6 +4396,7 @@ async function exerciseShortLocks({ walletAddress, transaction, locks }, context
|
|
|
4192
4396
|
});
|
|
4193
4397
|
await resolveTransferPolicies({
|
|
4194
4398
|
tx,
|
|
4399
|
+
transferPolicies,
|
|
4195
4400
|
suiClient: context.suiClient,
|
|
4196
4401
|
walletAddress,
|
|
4197
4402
|
kioskTx,
|
|
@@ -4222,7 +4427,7 @@ async function buyAndExerciseShortLocks({ walletAddress, locks, tx: existingTx }
|
|
|
4222
4427
|
}
|
|
4223
4428
|
|
|
4224
4429
|
// src/methods/cancelLocks/cancelLocks.ts
|
|
4225
|
-
var
|
|
4430
|
+
var import_utils8 = require("@mysten/sui.js/utils");
|
|
4226
4431
|
var import_transactions10 = require("@mysten/sui/transactions");
|
|
4227
4432
|
async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context) {
|
|
4228
4433
|
const tx = existingTx ?? new import_transactions10.Transaction();
|
|
@@ -4245,7 +4450,7 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
|
|
|
4245
4450
|
typeArguments: [lock.nft_type],
|
|
4246
4451
|
arguments: [
|
|
4247
4452
|
tx.object(TRADEPORT_PRICE_LOCK_STORE),
|
|
4248
|
-
tx.object(
|
|
4453
|
+
tx.object(import_utils8.SUI_CLOCK_OBJECT_ID),
|
|
4249
4454
|
tx.pure.id(lock.lock_id),
|
|
4250
4455
|
tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk)
|
|
4251
4456
|
]
|
|
@@ -4423,6 +4628,7 @@ var addClaimAcceptedBidNftTx = async ({
|
|
|
4423
4628
|
});
|
|
4424
4629
|
await resolveTransferPolicies({
|
|
4425
4630
|
tx,
|
|
4631
|
+
transferPolicies,
|
|
4426
4632
|
suiClient,
|
|
4427
4633
|
walletAddress: claimer,
|
|
4428
4634
|
kioskTx,
|
|
@@ -4459,6 +4665,7 @@ var addClaimAcceptedBidNftWithPurchaseCapTx = async ({
|
|
|
4459
4665
|
});
|
|
4460
4666
|
await resolveTransferPolicies({
|
|
4461
4667
|
tx,
|
|
4668
|
+
transferPolicies,
|
|
4462
4669
|
suiClient,
|
|
4463
4670
|
walletAddress: claimer,
|
|
4464
4671
|
kioskTx,
|
|
@@ -4494,6 +4701,7 @@ var addClaimTransferredNftTx = async ({
|
|
|
4494
4701
|
});
|
|
4495
4702
|
await resolveTransferPolicies({
|
|
4496
4703
|
tx,
|
|
4704
|
+
transferPolicies,
|
|
4497
4705
|
suiClient,
|
|
4498
4706
|
walletAddress: claimer,
|
|
4499
4707
|
kioskTx,
|
|
@@ -4531,6 +4739,7 @@ var addClaimTransferredNftWithPurchaseCapTx = async ({
|
|
|
4531
4739
|
});
|
|
4532
4740
|
await resolveTransferPolicies({
|
|
4533
4741
|
tx,
|
|
4742
|
+
transferPolicies,
|
|
4534
4743
|
suiClient,
|
|
4535
4744
|
walletAddress: claimer,
|
|
4536
4745
|
kioskTx,
|
|
@@ -5076,9 +5285,15 @@ async function addTradePortListTxHandler(txData) {
|
|
|
5076
5285
|
kiosk: txData?.sellerKiosk,
|
|
5077
5286
|
shouldAssertNftInSharedKiosk: true,
|
|
5078
5287
|
async runCommands(kioskTx) {
|
|
5079
|
-
const borrowedItem =
|
|
5080
|
-
|
|
5081
|
-
|
|
5288
|
+
const borrowedItem = await takeAndBorrowNftFromKiosk({
|
|
5289
|
+
tx: txData?.tx,
|
|
5290
|
+
transferPolicies: txData?.transferPolicies,
|
|
5291
|
+
kioskTx,
|
|
5292
|
+
kioskClient: txData?.kioskClient,
|
|
5293
|
+
nftTokenId: txData?.nftTokenId,
|
|
5294
|
+
nftType: txData?.nftType,
|
|
5295
|
+
suiClient: txData?.suiClient,
|
|
5296
|
+
kioskOwner: txData?.seller
|
|
5082
5297
|
});
|
|
5083
5298
|
addTradePortListTx({ ...txData, borrowedItem });
|
|
5084
5299
|
}
|
|
@@ -5099,7 +5314,7 @@ async function addTradePortListTxHandler(txData) {
|
|
|
5099
5314
|
}
|
|
5100
5315
|
});
|
|
5101
5316
|
}
|
|
5102
|
-
if (!txData?.sellerKiosk &&
|
|
5317
|
+
if (!txData?.sellerKiosk && hasNativeKioskTransferPolicyRules(txData?.transferPolicies)) {
|
|
5103
5318
|
return kioskTxWrapper({
|
|
5104
5319
|
tx: txData?.tx,
|
|
5105
5320
|
kioskClient: txData?.kioskClient,
|
|
@@ -5142,22 +5357,22 @@ function addTradePortRelistTx({
|
|
|
5142
5357
|
});
|
|
5143
5358
|
}
|
|
5144
5359
|
function addBlueMoveRelistTx(txData) {
|
|
5145
|
-
const { tx, nftTokenId, nftType, listPrice } = txData;
|
|
5360
|
+
const { tx, nftTokenId, nftType, listPrice, suiClient } = txData;
|
|
5146
5361
|
const borrowedItem = tx.moveCall({
|
|
5147
5362
|
target: "0xd5dd28cc24009752905689b2ba2bf90bfc8de4549b9123f93519bb8ba9bf9981::marketplace::delist",
|
|
5148
5363
|
arguments: [tx.object(BLUEMOVE_MARKET_CONFIG_OBJECT), tx.pure.address(nftTokenId)],
|
|
5149
5364
|
typeArguments: [nftType, nftType]
|
|
5150
5365
|
});
|
|
5151
|
-
addTradePortListTx({ ...txData, listPrice, borrowedItem });
|
|
5366
|
+
addTradePortListTx({ ...txData, listPrice, borrowedItem, suiClient });
|
|
5152
5367
|
}
|
|
5153
5368
|
function addTocenRelistTx(txData) {
|
|
5154
|
-
const { tx, nftTokenId, nftType, listPrice } = txData;
|
|
5369
|
+
const { tx, nftTokenId, nftType, listPrice, suiClient } = txData;
|
|
5155
5370
|
const borrowedItem = tx.moveCall({
|
|
5156
5371
|
target: "0x3605d91c559e80cf8fdeabae9abaccb0bc38f96eac0b32bf47e95a9159a5277f::tocen_marketplace::delist",
|
|
5157
5372
|
arguments: [tx.object(TOCEN_MARKETPLACE_OBJECT), tx.pure.address(nftTokenId)],
|
|
5158
5373
|
typeArguments: [nftType]
|
|
5159
5374
|
});
|
|
5160
|
-
addTradePortListTx({ ...txData, listPrice, borrowedItem });
|
|
5375
|
+
addTradePortListTx({ ...txData, listPrice, borrowedItem, suiClient });
|
|
5161
5376
|
}
|
|
5162
5377
|
|
|
5163
5378
|
// src/methods/relistNft/relistNft.ts
|
|
@@ -5288,6 +5503,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
|
|
|
5288
5503
|
} else {
|
|
5289
5504
|
const listTxData = {
|
|
5290
5505
|
tx,
|
|
5506
|
+
suiClient: context.suiClient,
|
|
5291
5507
|
kioskClient: context.kioskClient,
|
|
5292
5508
|
transferPolicies,
|
|
5293
5509
|
seller: walletAddress,
|
|
@@ -5360,7 +5576,6 @@ var fetchBulkNftsByKioskId = import_graphql_request19.gql`
|
|
|
5360
5576
|
`;
|
|
5361
5577
|
|
|
5362
5578
|
// src/methods/transferNfts/addTransferNftTx.ts
|
|
5363
|
-
var import_utils8 = require("@mysten/sui/utils");
|
|
5364
5579
|
async function addOriginByteTransferNftTx({
|
|
5365
5580
|
tx,
|
|
5366
5581
|
nftTokenId,
|
|
@@ -5499,19 +5714,10 @@ async function getTransferPolicyForDirectTransfer(suiClient, collectionChainStat
|
|
|
5499
5714
|
).length === 0
|
|
5500
5715
|
);
|
|
5501
5716
|
if (validateRules && candidatePolicy) {
|
|
5502
|
-
const
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
showContent: true
|
|
5506
|
-
}
|
|
5717
|
+
const ruleNames = await getTransferPolicyRuleNamesFromSuiObject({
|
|
5718
|
+
suiClient,
|
|
5719
|
+
transferPolicyId: candidatePolicy.id
|
|
5507
5720
|
});
|
|
5508
|
-
if (error) {
|
|
5509
|
-
throw new Error(`Error on getting SUI object ${candidatePolicy.id}: ${error.code}`);
|
|
5510
|
-
}
|
|
5511
|
-
const content = data.content;
|
|
5512
|
-
const ruleNames = content.fields.rules.fields.contents.map(
|
|
5513
|
-
(rule) => (0, import_utils8.normalizeStructTag)(rule.fields.name)
|
|
5514
|
-
);
|
|
5515
5721
|
if (!ruleNames.every((name) => name.startsWith(MYSTEN_TRANFER_POLICY_RULES_PACKAGE_ID))) {
|
|
5516
5722
|
return void 0;
|
|
5517
5723
|
}
|
|
@@ -5643,6 +5849,7 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 50 }
|
|
|
5643
5849
|
tx,
|
|
5644
5850
|
kioskTx,
|
|
5645
5851
|
kioskClient: context?.kioskClient,
|
|
5852
|
+
suiClient: context?.suiClient,
|
|
5646
5853
|
senderKiosk: unsharedNativeKiosk,
|
|
5647
5854
|
senderAddress: walletAddress,
|
|
5648
5855
|
recipientAddress: walletAddress,
|
|
@@ -6347,6 +6554,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6347
6554
|
const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
|
|
6348
6555
|
const txData = {
|
|
6349
6556
|
tx,
|
|
6557
|
+
suiClient: context.suiClient,
|
|
6350
6558
|
kioskClient: context.kioskClient,
|
|
6351
6559
|
nftType,
|
|
6352
6560
|
nftTokenId: nft?.token_id,
|
|
@@ -6355,6 +6563,32 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6355
6563
|
recipientAddress,
|
|
6356
6564
|
transferPolicies
|
|
6357
6565
|
};
|
|
6566
|
+
if (txData?.senderKiosk && !hasNativeKioskTransferPolicyRules(txData?.transferPolicies)) {
|
|
6567
|
+
await kioskTxWrapper({
|
|
6568
|
+
tx: txData?.tx,
|
|
6569
|
+
kioskClient: txData?.kioskClient,
|
|
6570
|
+
kioskOwner: txData?.senderAddress,
|
|
6571
|
+
kiosk: txData?.senderKiosk,
|
|
6572
|
+
shouldAssertNftInSharedKiosk: true,
|
|
6573
|
+
async runCommands(kioskTx) {
|
|
6574
|
+
const borrowedItem = await takeAndBorrowNftFromKiosk({
|
|
6575
|
+
tx: txData?.tx,
|
|
6576
|
+
transferPolicies: txData?.transferPolicies,
|
|
6577
|
+
kioskTx,
|
|
6578
|
+
kioskClient: txData?.kioskClient,
|
|
6579
|
+
nftTokenId: txData?.nftTokenId,
|
|
6580
|
+
nftType: txData?.nftType,
|
|
6581
|
+
suiClient: txData?.suiClient,
|
|
6582
|
+
kioskOwner: txData?.senderAddress
|
|
6583
|
+
});
|
|
6584
|
+
tx.transferObjects(
|
|
6585
|
+
[tx.object(borrowedItem)],
|
|
6586
|
+
tx.pure.address(addLeadingZerosAfter0x(recipientAddress))
|
|
6587
|
+
);
|
|
6588
|
+
}
|
|
6589
|
+
});
|
|
6590
|
+
continue;
|
|
6591
|
+
}
|
|
6358
6592
|
if (!txData.senderKiosk) {
|
|
6359
6593
|
tx.transferObjects(
|
|
6360
6594
|
[tx.object(txData.nftTokenId)],
|