@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 +6 -0
- package/dist/index.js +40 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/helpers/kiosk/getKioskTransferPolicies.ts +16 -13
- package/src/helpers/kiosk/getRulePackageId.ts +2 -1
- package/src/helpers/kiosk/resolveTransferPolicies.ts +3 -2
- package/src/utils/normalizeNftType.ts +7 -0
package/dist/index.mjs
CHANGED
|
@@ -291,32 +291,28 @@ var getSharedObjects = async (nftType) => {
|
|
|
291
291
|
};
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
// src/
|
|
295
|
-
import {
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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/
|
|
308
|
-
var
|
|
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
|
-
|
|
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
|
|
373
|
-
var fetchKiosksByOwner =
|
|
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
|
|
387
|
-
var fetchOwnerCapByKiosk =
|
|
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
|
|
398
|
-
var fetchPersonalCapByKiosk =
|
|
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
|
|
516
|
-
var fetchAccountKiosks =
|
|
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
|
|
1545
|
-
var fetchBidsById =
|
|
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
|
|
1634
|
-
var fetchListingsById =
|
|
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
|
|
1670
|
-
var fetchCommissionByNftContractId =
|
|
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
|
|
2700
|
-
var fetchCollectionsById =
|
|
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 =
|
|
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
|
|
3325
|
-
var fetchCryptoToUsdRate =
|
|
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
|
|
3364
|
-
var fetchAccountKiosks2 =
|
|
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
|