@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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - d3982a6: Added restriction for accepting own bids
8
+
9
+ ## 0.3.7
10
+
11
+ ### Patch Changes
12
+
13
+ - b66637a: Further updated transfer policy selection for direct transfers
14
+
3
15
  ## 0.3.6
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -10,6 +10,7 @@ type AcceptCollectionBid = {
10
10
 
11
11
  type AcceptNftBids = {
12
12
  bidIds: string[];
13
+ walletAddress: string;
13
14
  tx?: Transaction;
14
15
  kioskTx?: KioskTransaction;
15
16
  beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
@@ -170,7 +171,7 @@ declare class SuiTradingClient {
170
171
  unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
171
172
  placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<Transaction>;
172
173
  removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
173
- acceptNftBids({ bidIds }: AcceptNftBids): Promise<Transaction>;
174
+ acceptNftBids({ bidIds, walletAddress }: AcceptNftBids): Promise<Transaction>;
174
175
  placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<Transaction>;
175
176
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
176
177
  removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ type AcceptCollectionBid = {
10
10
 
11
11
  type AcceptNftBids = {
12
12
  bidIds: string[];
13
+ walletAddress: string;
13
14
  tx?: Transaction;
14
15
  kioskTx?: KioskTransaction;
15
16
  beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
@@ -170,7 +171,7 @@ declare class SuiTradingClient {
170
171
  unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
171
172
  placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<Transaction>;
172
173
  removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
173
- acceptNftBids({ bidIds }: AcceptNftBids): Promise<Transaction>;
174
+ acceptNftBids({ bidIds, walletAddress }: AcceptNftBids): Promise<Transaction>;
174
175
  placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<Transaction>;
175
176
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
176
177
  removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
package/dist/index.js CHANGED
@@ -2847,7 +2847,13 @@ var fetchBidsById = import_graphql_request12.gql`
2847
2847
 
2848
2848
  // src/methods/acceptNftBids/acceptNftBids.ts
2849
2849
  var ERROR_UNLIST_FIRST2 = "Item must be unlisted first before you can accept a solo bid on it";
2850
- var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx, beforeResolveKioskTransferRequest }, context) => {
2850
+ var acceptNftBids = async ({
2851
+ bidIds,
2852
+ walletAddress,
2853
+ tx: existingTx,
2854
+ kioskTx,
2855
+ beforeResolveKioskTransferRequest
2856
+ }, context) => {
2851
2857
  const res = await gqlChainRequest({
2852
2858
  chain: "sui",
2853
2859
  query: fetchBidsById,
@@ -2862,6 +2868,9 @@ var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx, beforeResolveKiosk
2862
2868
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
2863
2869
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
2864
2870
  }
2871
+ if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
2872
+ throw new Error("Wallet cannot accept its own bid");
2873
+ }
2865
2874
  if (bid?.status !== "active") {
2866
2875
  throw new Error("Bid not active");
2867
2876
  }
@@ -5153,33 +5162,11 @@ function canBeTransferedDirectly(collectionChainState) {
5153
5162
  return getTransferPolicyForDirectTransfer(collectionChainState) !== void 0;
5154
5163
  }
5155
5164
  function getTransferPolicyForDirectTransfer(collectionChainState) {
5156
- if (!collectionChainState?.transfer_policies?.length) {
5157
- return void 0;
5158
- }
5159
- const usablePolicies = collectionChainState.transfer_policies.filter(
5160
- (policy) => !policy.is_origin_byte && policy.rules?.filter(
5165
+ return collectionChainState?.transfer_policies?.find(
5166
+ (policy) => !policy.is_origin_byte && policy.rules.length > 0 && policy.rules?.filter(
5161
5167
  (rule) => rule.type !== "kiosk_lock_rule" && rule.type !== "royalty_rule"
5162
5168
  ).length === 0
5163
5169
  );
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];
5183
5170
  }
5184
5171
 
5185
5172
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
@@ -6390,14 +6377,14 @@ var SuiTradingClient = class {
6390
6377
  };
6391
6378
  return removeNftBids({ bidIds, tx }, context);
6392
6379
  }
6393
- async acceptNftBids({ bidIds }) {
6380
+ async acceptNftBids({ bidIds, walletAddress }) {
6394
6381
  const context = {
6395
6382
  apiUser: this.apiUser,
6396
6383
  apiKey: this.apiKey,
6397
6384
  suiClient: this.suiClient,
6398
6385
  kioskClient: this.kioskClient
6399
6386
  };
6400
- return acceptNftBids({ bidIds }, context);
6387
+ return acceptNftBids({ bidIds, walletAddress }, context);
6401
6388
  }
6402
6389
  async placeCollectionBid({
6403
6390
  collectionId,
@@ -6441,6 +6428,9 @@ var SuiTradingClient = class {
6441
6428
  if (!bid) {
6442
6429
  throw new Error("No bid found");
6443
6430
  }
6431
+ if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
6432
+ throw new Error("Wallet cannot accept its own bid");
6433
+ }
6444
6434
  if (bid?.status !== "active") {
6445
6435
  throw new Error("Bid not active");
6446
6436
  }