@tradeport/sui-trading-sdk 0.4.16 → 0.4.18
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.js +28 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/helpers/kiosk/resolveTransferPolicies.ts +29 -27
- package/src/methods/transferNfts/transferNfts.ts +1 -10
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1724,26 +1724,8 @@ var resolveTransferPolicies = async ({
|
|
|
1724
1724
|
coinToSplit,
|
|
1725
1725
|
beforeResolveKioskTransferRequest
|
|
1726
1726
|
}) => {
|
|
1727
|
-
const transferPoliciesFromMystenSdk = await kioskClient.getTransferPolicies({
|
|
1728
|
-
type: normalizedNftType(nftType)
|
|
1729
|
-
});
|
|
1730
1727
|
let policies = [];
|
|
1731
|
-
if (
|
|
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) {
|
|
1728
|
+
if (transferPolicies.length > 0) {
|
|
1747
1729
|
const transferPolicyId = getNativeKioskTransferPolicies(transferPolicies)?.at(0)?.id;
|
|
1748
1730
|
if (transferPolicyId) {
|
|
1749
1731
|
const ruleNames = await getTransferPolicyRuleNamesFromSuiObject({
|
|
@@ -1763,12 +1745,32 @@ var resolveTransferPolicies = async ({
|
|
|
1763
1745
|
];
|
|
1764
1746
|
}
|
|
1765
1747
|
}
|
|
1766
|
-
} else
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1748
|
+
} else {
|
|
1749
|
+
const transferPoliciesFromMystenSdk = await kioskClient.getTransferPolicies({
|
|
1750
|
+
type: normalizedNftType(nftType)
|
|
1751
|
+
});
|
|
1752
|
+
if (transferPoliciesFromMystenSdk.length > 0) {
|
|
1753
|
+
policies = [
|
|
1754
|
+
{
|
|
1755
|
+
data: (
|
|
1756
|
+
// Find first policy with relevant rules, or fall back to first policy
|
|
1757
|
+
transferPoliciesFromMystenSdk.find(
|
|
1758
|
+
(policy) => policy?.rules?.some(
|
|
1759
|
+
(rule) => knownTransferPolicyRules.some((ruleType) => rule?.includes(ruleType))
|
|
1760
|
+
)
|
|
1761
|
+
) ?? transferPoliciesFromMystenSdk[0]
|
|
1762
|
+
),
|
|
1763
|
+
transferRequest,
|
|
1764
|
+
isCustom: false
|
|
1765
|
+
}
|
|
1766
|
+
];
|
|
1767
|
+
} else if ((customTransferPolicies ?? []).every(
|
|
1768
|
+
(p) => p.transferRequest !== transferRequest
|
|
1769
|
+
)) {
|
|
1770
|
+
throw new Error(
|
|
1771
|
+
`Missing transfer policy of ${nftType}. No way to resolve the transfer request.`
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1772
1774
|
}
|
|
1773
1775
|
if (customTransferPolicies) {
|
|
1774
1776
|
for (const customTransferPolicy of customTransferPolicies) {
|
|
@@ -6503,29 +6505,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
|
6503
6505
|
|
|
6504
6506
|
// src/methods/transferNfts/transferNfts.ts
|
|
6505
6507
|
var import_transactions24 = require("@mysten/sui/transactions");
|
|
6506
|
-
|
|
6507
|
-
// src/helpers/rpc/getAcountBalance.ts
|
|
6508
|
-
var getAccountBalance = async ({ suiClient, owner }) => {
|
|
6509
|
-
try {
|
|
6510
|
-
const res = await suiClient.getBalance({
|
|
6511
|
-
owner: addLeadingZerosAfter0x(owner)
|
|
6512
|
-
});
|
|
6513
|
-
return Number(res?.totalBalance);
|
|
6514
|
-
} catch (err) {
|
|
6515
|
-
return 0;
|
|
6516
|
-
}
|
|
6517
|
-
};
|
|
6518
|
-
|
|
6519
|
-
// src/methods/transferNfts/transferNfts.ts
|
|
6520
6508
|
var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context) => {
|
|
6521
6509
|
if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
|
|
6522
6510
|
throw new Error("Cannot transfer to self");
|
|
6523
6511
|
}
|
|
6524
|
-
|
|
6525
|
-
suiClient: context.suiClient,
|
|
6526
|
-
owner: recipientAddress
|
|
6527
|
-
});
|
|
6528
|
-
if (!recipientAddressBalance || !recipientAddress?.includes("0x") || recipientAddress?.length < 65) {
|
|
6512
|
+
if (!recipientAddress?.includes("0x") || recipientAddress?.length < 65) {
|
|
6529
6513
|
throw new Error("Invalid recipient address");
|
|
6530
6514
|
}
|
|
6531
6515
|
const res = await gqlChainRequest({
|