@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/dist/index.mjs CHANGED
@@ -291,32 +291,28 @@ var getSharedObjects = async (nftType) => {
291
291
  };
292
292
  };
293
293
 
294
- // src/graphql/queries/fetchTransferPoliciesByType.ts
295
- import { gql as gql6 } from "graphql-request";
296
- var fetchTransferPoliciesByType = gql6`
297
- query fetchTransferPoliciesByType($type: String!) {
298
- transfer_policies_by_type(type: $type) {
299
- id
300
- is_origin_byte
301
- rules
302
- type
303
- }
304
- }
305
- `;
294
+ // src/apiClients/kioskClient.ts
295
+ import { KioskClient, Network } from "@mysten/kiosk";
296
+ var kioskClient = new KioskClient({
297
+ // @ts-ignore
298
+ client: suiClient_default,
299
+ network: Network.MAINNET
300
+ });
301
+ var kioskClient_default = kioskClient;
306
302
 
307
- // src/helpers/kiosk/getKioskTransferPolicies.ts
308
- var getKioskTransferPolicies = async (nftType) => {
303
+ // src/utils/normalizeNftType.ts
304
+ var normalizedNftType = (nftType) => {
309
305
  const nftTypeSplit = nftType?.split("::");
310
306
  if (nftTypeSplit?.[0])
311
307
  nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
312
- const res = await gqlChainRequest({
313
- chain: "sui",
314
- query: fetchTransferPoliciesByType,
315
- variables: { type: nftTypeSplit?.join("::") }
316
- });
317
- return res?.transfer_policies_by_type?.filter((policy) => !policy?.is_origin_byte);
308
+ return nftTypeSplit?.join("::");
318
309
  };
319
310
 
311
+ // src/helpers/kiosk/getKioskTransferPolicies.ts
312
+ var getKioskTransferPolicies = async (nftType) => kioskClient_default.getTransferPolicies({
313
+ type: normalizedNftType(nftType)
314
+ });
315
+
320
316
  // src/helpers/hasTransferPolicyRules.ts
321
317
  var hasTransferPolicyRules = async (nftType) => {
322
318
  const transferPolicies = await getKioskTransferPolicies(nftType);
@@ -326,15 +322,6 @@ var hasTransferPolicyRules = async (nftType) => {
326
322
  // src/helpers/kiosk/getRulePackageId.ts
327
323
  import { getNormalizedRuleType } from "@mysten/kiosk";
328
324
 
329
- // src/apiClients/kioskClient.ts
330
- import { KioskClient, Network } from "@mysten/kiosk";
331
- var kioskClient = new KioskClient({
332
- // @ts-ignore
333
- client: suiClient_default,
334
- network: Network.MAINNET
335
- });
336
- var kioskClient_default = kioskClient;
337
-
338
325
  // src/utils/addHexPrefix.ts
339
326
  function addHexPrefix(input) {
340
327
  if (input.startsWith("0x")) {
@@ -346,7 +333,7 @@ function addHexPrefix(input) {
346
333
  // src/helpers/kiosk/getRulePackageId.ts
347
334
  var getRulePackageId = async (nftType, ruleType) => {
348
335
  const transferPolicies = await kioskClient_default.getTransferPolicies({
349
- type: nftType
336
+ type: normalizedNftType(nftType)
350
337
  });
351
338
  const rule = transferPolicies.flatMap((policy) => policy.rules).filter((rule2) => rule2?.split("::")?.[1] === ruleType)?.[0];
352
339
  const ruleDefinition = kioskClient_default.rules.find(
@@ -369,8 +356,8 @@ var isTradePortKioskBid = (bidType) => bidType === TRADEPORT_KIOSK_BID_NONCE_TYP
369
356
  import { KioskTransaction } from "@mysten/kiosk";
370
357
 
371
358
  // src/graphql/queries/fetchKiosksByOwner.ts
372
- import { gql as gql7 } from "graphql-request";
373
- var fetchKiosksByOwner = gql7`
359
+ import { gql as gql6 } from "graphql-request";
360
+ var fetchKiosksByOwner = gql6`
374
361
  query fetchKiosksByOwner($ownerAddress: String!) {
375
362
  kiosks: kiosks_by_owner_address(owner_address: $ownerAddress) {
376
363
  id
@@ -383,8 +370,8 @@ var fetchKiosksByOwner = gql7`
383
370
  `;
384
371
 
385
372
  // src/graphql/queries/fetchOwnerCapByKiosk.ts
386
- import { gql as gql8 } from "graphql-request";
387
- var fetchOwnerCapByKiosk = gql8`
373
+ import { gql as gql7 } from "graphql-request";
374
+ var fetchOwnerCapByKiosk = gql7`
388
375
  query fetchOwnerCapByKiosk($kioskId: String!) {
389
376
  ownerCap: kiosk_owner_cap_by_kiosk(kiosk_id: $kioskId) {
390
377
  id
@@ -394,8 +381,8 @@ var fetchOwnerCapByKiosk = gql8`
394
381
  `;
395
382
 
396
383
  // src/graphql/queries/fetchPersonalCapByKiosk.ts
397
- import { gql as gql9 } from "graphql-request";
398
- var fetchPersonalCapByKiosk = gql9`
384
+ import { gql as gql8 } from "graphql-request";
385
+ var fetchPersonalCapByKiosk = gql8`
399
386
  query fetchPersonalCapByKiosk($kioskId: String!) {
400
387
  personalCap: personal_kiosk_cap_by_kiosk(kiosk_id: $kioskId) {
401
388
  id
@@ -512,8 +499,8 @@ var createOBKiosk = async ({ txBlock, createMethod = "new" }) => {
512
499
  };
513
500
 
514
501
  // src/helpers/originByte/getOBKiosk.ts
515
- import { gql as gql10 } from "graphql-request";
516
- var fetchAccountKiosks = gql10`
502
+ import { gql as gql9 } from "graphql-request";
503
+ var fetchAccountKiosks = gql9`
517
504
  query fetchAccountKiosks($accountAddress: String!) {
518
505
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
519
506
  id
@@ -696,7 +683,7 @@ var resolveTransferPolicies = async ({
696
683
  shouldSkipResolvingRoyaltyRule
697
684
  }) => {
698
685
  const transferPolicies = await kioskClient_default.getTransferPolicies({
699
- type: nftType
686
+ type: normalizedNftType(nftType)
700
687
  });
701
688
  let policies = transferPolicies.length > 0 ? [
702
689
  {
@@ -708,7 +695,7 @@ var resolveTransferPolicies = async ({
708
695
  if (customTransferPolicies) {
709
696
  for (const customTransferPolicy of customTransferPolicies) {
710
697
  const customPolicy = await kioskClient_default.getTransferPolicies({
711
- type: customTransferPolicy?.type
698
+ type: normalizedNftType(customTransferPolicy?.type)
712
699
  });
713
700
  policies = [
714
701
  ...policies,
@@ -1541,8 +1528,8 @@ var acceptCollectionBid = async ({
1541
1528
  import { TransactionBlock as TransactionBlock2 } from "@mysten/sui.js/transactions";
1542
1529
 
1543
1530
  // src/graphql/queries/fetchBidsById.ts
1544
- import { gql as gql11 } from "graphql-request";
1545
- var fetchBidsById = gql11`
1531
+ import { gql as gql10 } from "graphql-request";
1532
+ var fetchBidsById = gql10`
1546
1533
  query fetchBidsById($bidIds: [uuid!]) {
1547
1534
  bids(where: { id: { _in: $bidIds } }) {
1548
1535
  nonce
@@ -1630,8 +1617,8 @@ var acceptNftBids = async ({ bidIds }) => {
1630
1617
  import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
1631
1618
 
1632
1619
  // src/graphql/queries/fetchListingsById.ts
1633
- import { gql as gql12 } from "graphql-request";
1634
- var fetchListingsById = gql12`
1620
+ import { gql as gql11 } from "graphql-request";
1621
+ var fetchListingsById = gql11`
1635
1622
  query fetchListingsById($listingIds: [uuid!]) {
1636
1623
  listings(where: { id: { _in: $listingIds } }) {
1637
1624
  seller
@@ -1666,8 +1653,8 @@ var addThirdPartyTxFee = async (txBlock, price) => {
1666
1653
  };
1667
1654
 
1668
1655
  // src/graphql/queries/fetchCommissionByListingId.ts
1669
- import { gql as gql13 } from "graphql-request";
1670
- var fetchCommissionByNftContractId = gql13`
1656
+ import { gql as gql12 } from "graphql-request";
1657
+ var fetchCommissionByNftContractId = gql12`
1671
1658
  query fetchCommissionByNftContractId($nftContractId: uuid!) {
1672
1659
  commissions(where: { contract_id: { _eq: $nftContractId } }) {
1673
1660
  is_custodial
@@ -2696,8 +2683,8 @@ var listNfts = async ({ nfts, walletAddress }) => {
2696
2683
  import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
2697
2684
 
2698
2685
  // src/graphql/queries/fetchCollectionsById.ts
2699
- import { gql as gql14 } from "graphql-request";
2700
- var fetchCollectionsById = gql14`
2686
+ import { gql as gql13 } from "graphql-request";
2687
+ var fetchCollectionsById = gql13`
2701
2688
  query fetchCollectionsById($collectionIds: [uuid!]) {
2702
2689
  collections(where: { id: { _in: $collectionIds } }) {
2703
2690
  id
@@ -2707,7 +2694,7 @@ var fetchCollectionsById = gql14`
2707
2694
  }
2708
2695
  }
2709
2696
  `;
2710
- var fetchCollectionsByIdWithOneNft = gql14`
2697
+ var fetchCollectionsByIdWithOneNft = gql13`
2711
2698
  query fetchCollectionsByIdWithOneNft($collectionIds: [uuid!]) {
2712
2699
  collections(where: { id: { _in: $collectionIds } }) {
2713
2700
  id
@@ -3321,8 +3308,8 @@ var removeNftBids = async ({ bidIds }) => {
3321
3308
  import { TransactionBlock as TransactionBlock10 } from "@mysten/sui.js/transactions";
3322
3309
 
3323
3310
  // src/graphql/queries/fetchCryptoToUsdRate.ts
3324
- import { gql as gql15 } from "graphql-request";
3325
- var fetchCryptoToUsdRate = gql15`
3311
+ import { gql as gql14 } from "graphql-request";
3312
+ var fetchCryptoToUsdRate = gql14`
3326
3313
  query fetchCryptoToUsdRate($crypto: String!) {
3327
3314
  crypto_rates(where: { crypto: { _eq: $crypto }, fiat: { _eq: "USD" } }) {
3328
3315
  crypto
@@ -3360,8 +3347,8 @@ var addOneDollarFee = async (txBlock) => {
3360
3347
  };
3361
3348
 
3362
3349
  // src/graphql/queries/fetchAccountKiosks.ts
3363
- import { gql as gql16 } from "graphql-request";
3364
- var fetchAccountKiosks2 = gql16`
3350
+ import { gql as gql15 } from "graphql-request";
3351
+ var fetchAccountKiosks2 = gql15`
3365
3352
  query fetchAccountKiosks($accountAddress: String!) {
3366
3353
  kiosks: kiosks_by_owner_address(owner_address: $accountAddress) {
3367
3354
  id