@tradeport/sui-trading-sdk 0.3.6 → 0.3.8

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
@@ -2823,7 +2823,13 @@ var fetchBidsById = gql11`
2823
2823
 
2824
2824
  // src/methods/acceptNftBids/acceptNftBids.ts
2825
2825
  var ERROR_UNLIST_FIRST2 = "Item must be unlisted first before you can accept a solo bid on it";
2826
- var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx, beforeResolveKioskTransferRequest }, context) => {
2826
+ var acceptNftBids = async ({
2827
+ bidIds,
2828
+ walletAddress,
2829
+ tx: existingTx,
2830
+ kioskTx,
2831
+ beforeResolveKioskTransferRequest
2832
+ }, context) => {
2827
2833
  const res = await gqlChainRequest({
2828
2834
  chain: "sui",
2829
2835
  query: fetchBidsById,
@@ -2838,6 +2844,9 @@ var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx, beforeResolveKiosk
2838
2844
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
2839
2845
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
2840
2846
  }
2847
+ if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
2848
+ throw new Error("Wallet cannot accept its own bid");
2849
+ }
2841
2850
  if (bid?.status !== "active") {
2842
2851
  throw new Error("Bid not active");
2843
2852
  }
@@ -5129,33 +5138,11 @@ function canBeTransferedDirectly(collectionChainState) {
5129
5138
  return getTransferPolicyForDirectTransfer(collectionChainState) !== void 0;
5130
5139
  }
5131
5140
  function getTransferPolicyForDirectTransfer(collectionChainState) {
5132
- if (!collectionChainState?.transfer_policies?.length) {
5133
- return void 0;
5134
- }
5135
- const usablePolicies = collectionChainState.transfer_policies.filter(
5136
- (policy) => !policy.is_origin_byte && policy.rules?.filter(
5141
+ return collectionChainState?.transfer_policies?.find(
5142
+ (policy) => !policy.is_origin_byte && policy.rules.length > 0 && policy.rules?.filter(
5137
5143
  (rule) => rule.type !== "kiosk_lock_rule" && rule.type !== "royalty_rule"
5138
5144
  ).length === 0
5139
5145
  );
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];
5159
5146
  }
5160
5147
 
5161
5148
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
@@ -6366,14 +6353,14 @@ var SuiTradingClient = class {
6366
6353
  };
6367
6354
  return removeNftBids({ bidIds, tx }, context);
6368
6355
  }
6369
- async acceptNftBids({ bidIds }) {
6356
+ async acceptNftBids({ bidIds, walletAddress }) {
6370
6357
  const context = {
6371
6358
  apiUser: this.apiUser,
6372
6359
  apiKey: this.apiKey,
6373
6360
  suiClient: this.suiClient,
6374
6361
  kioskClient: this.kioskClient
6375
6362
  };
6376
- return acceptNftBids({ bidIds }, context);
6363
+ return acceptNftBids({ bidIds, walletAddress }, context);
6377
6364
  }
6378
6365
  async placeCollectionBid({
6379
6366
  collectionId,
@@ -6417,6 +6404,9 @@ var SuiTradingClient = class {
6417
6404
  if (!bid) {
6418
6405
  throw new Error("No bid found");
6419
6406
  }
6407
+ if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
6408
+ throw new Error("Wallet cannot accept its own bid");
6409
+ }
6420
6410
  if (bid?.status !== "active") {
6421
6411
  throw new Error("Bid not active");
6422
6412
  }