@tradeport/sui-trading-sdk 0.0.2 → 0.0.3

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,11 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ff9b36e: Fix some collection txs like S Card and Unbound that did not have transfer policies indexed
8
+
3
9
  ## 0.0.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -317,32 +317,28 @@ var getSharedObjects = async (nftType) => {
317
317
  };
318
318
  };
319
319
 
320
- // src/graphql/queries/fetchTransferPoliciesByType.ts
321
- var import_graphql_request7 = require("graphql-request");
322
- var fetchTransferPoliciesByType = import_graphql_request7.gql`
323
- query fetchTransferPoliciesByType($type: String!) {
324
- transfer_policies_by_type(type: $type) {
325
- id
326
- is_origin_byte
327
- rules
328
- type
329
- }
330
- }
331
- `;
320
+ // src/apiClients/kioskClient.ts
321
+ var import_kiosk = require("@mysten/kiosk");
322
+ var kioskClient = new import_kiosk.KioskClient({
323
+ // @ts-ignore
324
+ client: suiClient_default,
325
+ network: import_kiosk.Network.MAINNET
326
+ });
327
+ var kioskClient_default = kioskClient;
332
328
 
333
- // src/helpers/kiosk/getKioskTransferPolicies.ts
334
- var getKioskTransferPolicies = async (nftType) => {
329
+ // src/utils/normalizeNftType.ts
330
+ var normalizedNftType = (nftType) => {
335
331
  const nftTypeSplit = nftType?.split("::");
336
332
  if (nftTypeSplit?.[0])
337
333
  nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
338
- const res = await gqlChainRequest({
339
- chain: "sui",
340
- query: fetchTransferPoliciesByType,
341
- variables: { type: nftTypeSplit?.join("::") }
342
- });
343
- return res?.transfer_policies_by_type?.filter((policy) => !policy?.is_origin_byte);
334
+ return nftTypeSplit?.join("::");
344
335
  };
345
336
 
337
+ // src/helpers/kiosk/getKioskTransferPolicies.ts
338
+ var getKioskTransferPolicies = async (nftType) => kioskClient_default.getTransferPolicies({
339
+ type: normalizedNftType(nftType)
340
+ });
341
+
346
342
  // src/helpers/hasTransferPolicyRules.ts
347
343
  var hasTransferPolicyRules = async (nftType) => {
348
344
  const transferPolicies = await getKioskTransferPolicies(nftType);
@@ -352,15 +348,6 @@ var hasTransferPolicyRules = async (nftType) => {
352
348
  // src/helpers/kiosk/getRulePackageId.ts
353
349
  var import_kiosk2 = require("@mysten/kiosk");
354
350
 
355
- // src/apiClients/kioskClient.ts
356
- var import_kiosk = require("@mysten/kiosk");
357
- var kioskClient = new import_kiosk.KioskClient({
358
- // @ts-ignore
359
- client: suiClient_default,
360
- network: import_kiosk.Network.MAINNET
361
- });
362
- var kioskClient_default = kioskClient;
363
-
364
351
  // src/utils/addHexPrefix.ts
365
352
  function addHexPrefix(input) {
366
353
  if (input.startsWith("0x")) {
@@ -372,7 +359,7 @@ function addHexPrefix(input) {
372
359
  // src/helpers/kiosk/getRulePackageId.ts
373
360
  var getRulePackageId = async (nftType, ruleType) => {
374
361
  const transferPolicies = await kioskClient_default.getTransferPolicies({
375
- type: nftType
362
+ type: normalizedNftType(nftType)
376
363
  });
377
364
  const rule = transferPolicies.flatMap((policy) => policy.rules).filter((rule2) => rule2?.split("::")?.[1] === ruleType)?.[0];
378
365
  const ruleDefinition = kioskClient_default.rules.find(
@@ -395,8 +382,8 @@ var isTradePortKioskBid = (bidType) => bidType === TRADEPORT_KIOSK_BID_NONCE_TYP
395
382
  var import_kiosk3 = require("@mysten/kiosk");
396
383
 
397
384
  // src/graphql/queries/fetchKiosksByOwner.ts
398
- var import_graphql_request8 = require("graphql-request");
399
- var fetchKiosksByOwner = import_graphql_request8.gql`
385
+ var import_graphql_request7 = require("graphql-request");
386
+ var fetchKiosksByOwner = import_graphql_request7.gql`
400
387
  query fetchKiosksByOwner($ownerAddress: String!) {
401
388
  kiosks: kiosks_by_owner_address(owner_address: $ownerAddress) {
402
389
  id
@@ -409,8 +396,8 @@ var fetchKiosksByOwner = import_graphql_request8.gql`
409
396
  `;
410
397
 
411
398
  // src/graphql/queries/fetchOwnerCapByKiosk.ts
412
- var import_graphql_request9 = require("graphql-request");
413
- var fetchOwnerCapByKiosk = import_graphql_request9.gql`
399
+ var import_graphql_request8 = require("graphql-request");
400
+ var fetchOwnerCapByKiosk = import_graphql_request8.gql`
414
401
  query fetchOwnerCapByKiosk($kioskId: String!) {
415
402
  ownerCap: kiosk_owner_cap_by_kiosk(kiosk_id: $kioskId) {
416
403
  id
@@ -420,8 +407,8 @@ var fetchOwnerCapByKiosk = import_graphql_request9.gql`
420
407
  `;
421
408
 
422
409
  // src/graphql/queries/fetchPersonalCapByKiosk.ts
423
- var import_graphql_request10 = require("graphql-request");
424
- var fetchPersonalCapByKiosk = import_graphql_request10.gql`
410
+ var import_graphql_request9 = require("graphql-request");
411
+ var fetchPersonalCapByKiosk = import_graphql_request9.gql`
425
412
  query fetchPersonalCapByKiosk($kioskId: String!) {
426
413
  personalCap: personal_kiosk_cap_by_kiosk(kiosk_id: $kioskId) {
427
414
  id
@@ -538,8 +525,8 @@ var createOBKiosk = async ({ txBlock, createMethod = "new" }) => {
538
525
  };
539
526
 
540
527
  // src/helpers/originByte/getOBKiosk.ts
541
- var import_graphql_request11 = require("graphql-request");
542
- var fetchAccountKiosks = import_graphql_request11.gql`
528
+ var import_graphql_request10 = require("graphql-request");
529
+ var fetchAccountKiosks = import_graphql_request10.gql`
543
530
  query fetchAccountKiosks($accountAddress: String!) {
544
531
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
545
532
  id
@@ -722,7 +709,7 @@ var resolveTransferPolicies = async ({
722
709
  shouldSkipResolvingRoyaltyRule
723
710
  }) => {
724
711
  const transferPolicies = await kioskClient_default.getTransferPolicies({
725
- type: nftType
712
+ type: normalizedNftType(nftType)
726
713
  });
727
714
  let policies = transferPolicies.length > 0 ? [
728
715
  {
@@ -734,7 +721,7 @@ var resolveTransferPolicies = async ({
734
721
  if (customTransferPolicies) {
735
722
  for (const customTransferPolicy of customTransferPolicies) {
736
723
  const customPolicy = await kioskClient_default.getTransferPolicies({
737
- type: customTransferPolicy?.type
724
+ type: normalizedNftType(customTransferPolicy?.type)
738
725
  });
739
726
  policies = [
740
727
  ...policies,
@@ -1567,8 +1554,8 @@ var acceptCollectionBid = async ({
1567
1554
  var import_transactions2 = require("@mysten/sui.js/transactions");
1568
1555
 
1569
1556
  // src/graphql/queries/fetchBidsById.ts
1570
- var import_graphql_request12 = require("graphql-request");
1571
- var fetchBidsById = import_graphql_request12.gql`
1557
+ var import_graphql_request11 = require("graphql-request");
1558
+ var fetchBidsById = import_graphql_request11.gql`
1572
1559
  query fetchBidsById($bidIds: [uuid!]) {
1573
1560
  bids(where: { id: { _in: $bidIds } }) {
1574
1561
  nonce
@@ -1656,8 +1643,8 @@ var acceptNftBids = async ({ bidIds }) => {
1656
1643
  var import_transactions3 = require("@mysten/sui.js/transactions");
1657
1644
 
1658
1645
  // src/graphql/queries/fetchListingsById.ts
1659
- var import_graphql_request13 = require("graphql-request");
1660
- var fetchListingsById = import_graphql_request13.gql`
1646
+ var import_graphql_request12 = require("graphql-request");
1647
+ var fetchListingsById = import_graphql_request12.gql`
1661
1648
  query fetchListingsById($listingIds: [uuid!]) {
1662
1649
  listings(where: { id: { _in: $listingIds } }) {
1663
1650
  seller
@@ -1692,8 +1679,8 @@ var addThirdPartyTxFee = async (txBlock, price) => {
1692
1679
  };
1693
1680
 
1694
1681
  // src/graphql/queries/fetchCommissionByListingId.ts
1695
- var import_graphql_request14 = require("graphql-request");
1696
- var fetchCommissionByNftContractId = import_graphql_request14.gql`
1682
+ var import_graphql_request13 = require("graphql-request");
1683
+ var fetchCommissionByNftContractId = import_graphql_request13.gql`
1697
1684
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
1698
1685
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
1699
1686
  is_custodial
@@ -2722,8 +2709,8 @@ var listNfts = async ({ nfts, walletAddress }) => {
2722
2709
  var import_transactions6 = require("@mysten/sui.js/transactions");
2723
2710
 
2724
2711
  // src/graphql/queries/fetchCollectionsById.ts
2725
- var import_graphql_request15 = require("graphql-request");
2726
- var fetchCollectionsById = import_graphql_request15.gql`
2712
+ var import_graphql_request14 = require("graphql-request");
2713
+ var fetchCollectionsById = import_graphql_request14.gql`
2727
2714
  query fetchCollectionsById($collectionIds: [uuid!]) {
2728
2715
  collections(where: { id: { _in: $collectionIds } }) {
2729
2716
  id
@@ -2733,7 +2720,7 @@ var fetchCollectionsById = import_graphql_request15.gql`
2733
2720
  }
2734
2721
  }
2735
2722
  `;
2736
- var fetchCollectionsByIdWithOneNft = import_graphql_request15.gql`
2723
+ var fetchCollectionsByIdWithOneNft = import_graphql_request14.gql`
2737
2724
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
2738
2725
  collections(where: { id: { _in: $collectionIds } }) {
2739
2726
  id
@@ -3347,8 +3334,8 @@ var removeNftBids = async ({ bidIds }) => {
3347
3334
  var import_transactions10 = require("@mysten/sui.js/transactions");
3348
3335
 
3349
3336
  // src/graphql/queries/fetchCryptoToUsdRate.ts
3350
- var import_graphql_request16 = require("graphql-request");
3351
- var fetchCryptoToUsdRate = import_graphql_request16.gql`
3337
+ var import_graphql_request15 = require("graphql-request");
3338
+ var fetchCryptoToUsdRate = import_graphql_request15.gql`
3352
3339
  query fetchCryptoToUsdRate($crypto: String!) {
3353
3340
  crypto_rates(where: { crypto: { _eq: $crypto }, fiat: { _eq: "USD" } }) {
3354
3341
  crypto
@@ -3386,8 +3373,8 @@ var addOneDollarFee = async (txBlock) => {
3386
3373
  };
3387
3374
 
3388
3375
  // src/graphql/queries/fetchAccountKiosks.ts
3389
- var import_graphql_request17 = require("graphql-request");
3390
- var fetchAccountKiosks2 = import_graphql_request17.gql`
3376
+ var import_graphql_request16 = require("graphql-request");
3377
+ var fetchAccountKiosks2 = import_graphql_request16.gql`
3391
3378
  query fetchAccountKiosks($accountAddress: String!) {
3392
3379
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
3393
3380
  id