@tradeport/sui-trading-sdk 0.5.1 → 0.5.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.
Files changed (154) hide show
  1. package/dist/index.js +19 -1
  2. package/dist/index.js.map +1 -1
  3. package/package.json +71 -66
  4. package/.babel.config.js +0 -3
  5. package/.claude/settings.json +0 -5
  6. package/.env.demo +0 -5
  7. package/.eslintrc.json +0 -46
  8. package/.prettierignore +0 -4
  9. package/.prettierrc.json +0 -7
  10. package/.vscode/launch.json +0 -23
  11. package/CHANGELOG.md +0 -746
  12. package/dist/index.d.mts +0 -193
  13. package/dist/index.mjs +0 -7386
  14. package/dist/index.mjs.map +0 -1
  15. package/jest.config.js +0 -12
  16. package/src/SuiTradingClient.ts +0 -442
  17. package/src/apiClients/createKioskClient.ts +0 -10
  18. package/src/apiClients/createSuiClient.ts +0 -5
  19. package/src/apiClients/graphqlClient.ts +0 -17
  20. package/src/bigNumberConfig.ts +0 -10
  21. package/src/constants.ts +0 -1052
  22. package/src/graphql/createChainGQLQuery.ts +0 -27
  23. package/src/graphql/gqlChainRequest.ts +0 -21
  24. package/src/graphql/queries/fetchAccountKiosks.ts +0 -12
  25. package/src/graphql/queries/fetchActiveLockStateByNftId.ts +0 -15
  26. package/src/graphql/queries/fetchBidsById.ts +0 -36
  27. package/src/graphql/queries/fetchCollectionBidById.ts +0 -21
  28. package/src/graphql/queries/fetchCollectionBidsAtSamePrice.ts +0 -29
  29. package/src/graphql/queries/fetchCollectionChainState.ts +0 -17
  30. package/src/graphql/queries/fetchCollectionFloorListingForMarket.ts +0 -28
  31. package/src/graphql/queries/fetchCollectionFloorListings.ts +0 -15
  32. package/src/graphql/queries/fetchCollectionsById.ts +0 -39
  33. package/src/graphql/queries/fetchCommissionByListingId.ts +0 -13
  34. package/src/graphql/queries/fetchCryptoToUsdRate.ts +0 -13
  35. package/src/graphql/queries/fetchKiosksByOwner.ts +0 -14
  36. package/src/graphql/queries/fetchListingsById.ts +0 -29
  37. package/src/graphql/queries/fetchListingsByNftId.ts +0 -23
  38. package/src/graphql/queries/fetchLockById.ts +0 -23
  39. package/src/graphql/queries/fetchMultibidById.ts +0 -34
  40. package/src/graphql/queries/fetchNftCollectionChainState.ts +0 -12
  41. package/src/graphql/queries/fetchNftsById.ts +0 -75
  42. package/src/graphql/queries/fetchNftsByKioskId.ts +0 -45
  43. package/src/graphql/queries/fetchOwnerCapByKiosk.ts +0 -10
  44. package/src/graphql/queries/fetchPersonalCapByKiosk.ts +0 -10
  45. package/src/graphql/queries/fetchSharedObjectsByType.ts +0 -12
  46. package/src/graphql/queries/fetchTransferPoliciesByType.ts +0 -12
  47. package/src/graphql/queries/fetchWalletKiosks.ts +0 -14
  48. package/src/graphql/queries/getCommissionByListingId.ts +0 -15
  49. package/src/helpers/addOneDollarFee.ts +0 -17
  50. package/src/helpers/addThirdPartyTxFee.ts +0 -17
  51. package/src/helpers/calculatePremium.ts +0 -9
  52. package/src/helpers/calculateRoyaltyFee.ts +0 -28
  53. package/src/helpers/destroyZeroCoin.ts +0 -14
  54. package/src/helpers/getActiveLockStateByNftId.ts +0 -15
  55. package/src/helpers/getCollectionChainState.ts +0 -31
  56. package/src/helpers/getCollectionFloorPrice.ts +0 -12
  57. package/src/helpers/getLockById.ts +0 -29
  58. package/src/helpers/getMarketFeePrice.ts +0 -82
  59. package/src/helpers/getNftType.ts +0 -38
  60. package/src/helpers/getRoyaltyRuleModule.ts +0 -7
  61. package/src/helpers/getSharedObjects.ts +0 -119
  62. package/src/helpers/getSuiToUsdRate.ts +0 -14
  63. package/src/helpers/getTradeportBiddingContractBidAmount.ts +0 -31
  64. package/src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts +0 -24
  65. package/src/helpers/hasPersonalKioskRule.ts +0 -7
  66. package/src/helpers/hasRoyaltyRule.ts +0 -7
  67. package/src/helpers/hasTransferPolicyRules.ts +0 -6
  68. package/src/helpers/isExpiredListing.ts +0 -9
  69. package/src/helpers/isNonKioskListing.ts +0 -14
  70. package/src/helpers/isSIngleBid.ts +0 -13
  71. package/src/helpers/kiosk/assertNftInSharedKiosk.ts +0 -31
  72. package/src/helpers/kiosk/getKioskCollectionRoyaltyFeeAmount.ts +0 -71
  73. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +0 -29
  74. package/src/helpers/kiosk/getKioskPlaceBidCoin.ts +0 -59
  75. package/src/helpers/kiosk/getNativeKioskTransferPolicies.ts +0 -29
  76. package/src/helpers/kiosk/getNativeKioskTransferPoliciesByNftType.ts +0 -21
  77. package/src/helpers/kiosk/getRulePackageId.ts +0 -59
  78. package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +0 -154
  79. package/src/helpers/kiosk/isBluemoveKioskBid.ts +0 -1
  80. package/src/helpers/kiosk/isTradePortKioskBid.ts +0 -4
  81. package/src/helpers/kiosk/kioskListingBcs.ts +0 -19
  82. package/src/helpers/kiosk/kioskTxWrapper.ts +0 -152
  83. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +0 -100
  84. package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +0 -171
  85. package/src/helpers/kiosk/resolveCustomTransferPolicyRules.ts +0 -75
  86. package/src/helpers/kiosk/resolveFloorPriceRule.ts +0 -21
  87. package/src/helpers/kiosk/resolveKioskLockRule.ts +0 -47
  88. package/src/helpers/kiosk/resolvePersonalKioskRule.ts +0 -23
  89. package/src/helpers/kiosk/resolveRoyaltyRule.ts +0 -57
  90. package/src/helpers/kiosk/resolveTableAllowlistRule.ts +0 -34
  91. package/src/helpers/kiosk/resolveTransferPolicies.ts +0 -158
  92. package/src/helpers/kiosk/sharedKioskState.type.ts +0 -11
  93. package/src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts +0 -50
  94. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +0 -73
  95. package/src/helpers/kiosk/upgradeKioskRulesPackageId.ts +0 -17
  96. package/src/helpers/originByte/confirmOBTranfer.ts +0 -33
  97. package/src/helpers/originByte/createOBKiosk.ts +0 -14
  98. package/src/helpers/originByte/depositNftIntoOBKiosk.ts +0 -16
  99. package/src/helpers/originByte/getOBBidderKiosk.ts +0 -12
  100. package/src/helpers/originByte/getOBKiosk.ts +0 -24
  101. package/src/helpers/originByte/getOrCreateOBKiosk.ts +0 -42
  102. package/src/helpers/originByte/isOBKiosk.ts +0 -13
  103. package/src/helpers/originByte/isOriginByteBid.ts +0 -6
  104. package/src/helpers/originByte/isOriginByteCollection.ts +0 -11
  105. package/src/helpers/originByte/shareOriginByteKiosk.ts +0 -14
  106. package/src/helpers/rpc/getAcountBalance.ts +0 -18
  107. package/src/helpers/rpc/getObjectType.ts +0 -25
  108. package/src/helpers/splitCoins.ts +0 -12
  109. package/src/helpers/track.ts +0 -20
  110. package/src/helpers/validateMinFloorPrice.ts +0 -22
  111. package/src/index.ts +0 -2
  112. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +0 -189
  113. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +0 -398
  114. package/src/methods/acceptNftBids/acceptNftBids.ts +0 -174
  115. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +0 -438
  116. package/src/methods/applyFtStrategy/applyFtStrategy.ts +0 -55
  117. package/src/methods/applyNftStrategy/applyNftStrategy.ts +0 -90
  118. package/src/methods/buyListings/addBuyListingTxs.ts +0 -803
  119. package/src/methods/buyListings/buyListings.ts +0 -230
  120. package/src/methods/cancelMultiBid/cancelMultiBid.ts +0 -51
  121. package/src/methods/cancelNftTransfers/addCancelNftTransfersTx.ts +0 -20
  122. package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +0 -118
  123. package/src/methods/claimNfts/addClaimNftsTxs.ts +0 -247
  124. package/src/methods/claimNfts/claimNfts.ts +0 -270
  125. package/src/methods/createMultiBid/createMultiBid.ts +0 -36
  126. package/src/methods/listNfts/addListTxs.ts +0 -210
  127. package/src/methods/listNfts/addRelistTxs.ts +0 -87
  128. package/src/methods/listNfts/listNfts.ts +0 -152
  129. package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +0 -226
  130. package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +0 -149
  131. package/src/methods/placeCollectionBids/placeCollectionBids.ts +0 -153
  132. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +0 -154
  133. package/src/methods/placeNftBids/placeNftBids.ts +0 -111
  134. package/src/methods/relistNft/relistNft.ts +0 -153
  135. package/src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts +0 -132
  136. package/src/methods/removeCollectionBids/removeCollectionBids.ts +0 -117
  137. package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +0 -122
  138. package/src/methods/removeNftBids/removeNftBids.ts +0 -116
  139. package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +0 -40
  140. package/src/methods/sponsorNftListing/sponsorNftListing.ts +0 -60
  141. package/src/methods/transferNfts/addTransferNftTx.ts +0 -220
  142. package/src/methods/transferNfts/transferNfts.ts +0 -216
  143. package/src/methods/unlistListings/addUnlistListingTxs.ts +0 -399
  144. package/src/methods/unlistListings/unlistListings.ts +0 -158
  145. package/src/methods/updateMultiBid/updateMultiBid.ts +0 -66
  146. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +0 -100
  147. package/src/tests/SuiWallet.ts +0 -83
  148. package/src/utils/addHexPrefix.ts +0 -7
  149. package/src/utils/addLeadingZerosAfter0x.ts +0 -9
  150. package/src/utils/normalizeNftType.ts +0 -7
  151. package/src/utils/printTxBlockTxs.ts +0 -11
  152. package/src/utils/pureValues.ts +0 -13
  153. package/src/utils/toUint8Array.ts +0 -12
  154. package/tsconfig.json +0 -16
@@ -1,9 +0,0 @@
1
- import { PREMIUM_FEE_NOMINATOR, PREMIUM_NOMINATOR } from '../constants';
2
-
3
- export function calculatePremium(price: bigint): bigint {
4
- return (BigInt(price) * PREMIUM_NOMINATOR) / 10_000n;
5
- }
6
-
7
- export function calculatePremiumFee(premium: bigint): bigint {
8
- return (BigInt(premium) * PREMIUM_FEE_NOMINATOR) / 10_000n;
9
- }
@@ -1,28 +0,0 @@
1
- import BigNumber from '../bigNumberConfig';
2
- import { ZERO } from '../bigNumberConfig';
3
-
4
- export function calculateRoyaltyFee(
5
- transferPolicyRules: Array<{ type: string; amount_bp?: string; min_amount?: string }>,
6
- price: BigNumber,
7
- ): BigNumber {
8
- const royaltyRule = transferPolicyRules?.filter(
9
- (rule: { type: string }) => rule.type === 'royalty_rule' || rule.type === 'kiosk_royalty_rule',
10
- )?.[0];
11
-
12
- if (!royaltyRule || (!royaltyRule.amount_bp && !royaltyRule.min_amount)) {
13
- return ZERO;
14
- }
15
-
16
- const royaltyFee = royaltyRule.amount_bp
17
- ? new BigNumber(royaltyRule.amount_bp)
18
- .times(price)
19
- .div(10000)
20
- .integerValue(BigNumber.ROUND_DOWN)
21
- : ZERO;
22
-
23
- if (royaltyRule.min_amount && new BigNumber(royaltyRule.min_amount).isGreaterThan(royaltyFee)) {
24
- return new BigNumber(royaltyRule.min_amount);
25
- }
26
-
27
- return royaltyFee;
28
- }
@@ -1,14 +0,0 @@
1
- import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
2
-
3
- type Args = {
4
- tx: Transaction;
5
- coin: string | TransactionArgument;
6
- };
7
-
8
- export const destroyZeroCoin = ({ tx, coin }: Args) => {
9
- tx.moveCall({
10
- target: '0x2::coin::destroy_zero',
11
- arguments: [tx.object(coin as any)],
12
- typeArguments: ['0x2::sui::SUI'],
13
- });
14
- };
@@ -1,15 +0,0 @@
1
- import { gqlChainRequest } from '../graphql/gqlChainRequest';
2
- import { type Lock } from './getLockById';
3
- import { fetchActiveLockStateByNftId } from '../graphql/queries/fetchActiveLockStateByNftId';
4
-
5
- export const getActiveLockStateByNftId = async (
6
- nftId: string,
7
- ): Promise<Pick<Lock, 'id' | 'state'>> => {
8
- const res = await gqlChainRequest({
9
- chain: 'sui',
10
- query: fetchActiveLockStateByNftId,
11
- variables: { nftId },
12
- });
13
-
14
- return res?.locks?.[0] ?? undefined;
15
- };
@@ -1,31 +0,0 @@
1
- import { gqlChainRequest } from '../graphql/gqlChainRequest';
2
- import {
3
- fetchCollectionChainState,
4
- fetchCollectionChainStateByFtType,
5
- } from '../graphql/queries/fetchCollectionChainState';
6
-
7
- export const getCollectionChainState = async (
8
- collectionId: string,
9
- ): Promise<Record<string, unknown> | undefined> => {
10
- const res = await gqlChainRequest({
11
- chain: 'sui',
12
- query: fetchCollectionChainState,
13
- variables: { collectionId },
14
- });
15
-
16
- return res?.collections?.[0]?.chain_state;
17
- };
18
-
19
- export const getCollectionChainStateByFtType = async (
20
- ftType: string,
21
- ): Promise<Record<string, unknown> | undefined> => {
22
- const res = await gqlChainRequest({
23
- chain: 'sui',
24
- query: fetchCollectionChainStateByFtType,
25
- variables: {
26
- ftType,
27
- },
28
- });
29
-
30
- return res?.collections_by_ft_type?.[0]?.chain_state;
31
- };
@@ -1,12 +0,0 @@
1
- import { gqlChainRequest } from '../graphql/gqlChainRequest';
2
- import { fetchCollectionFloorListings } from '../graphql/queries/fetchCollectionFloorListings';
3
-
4
- export const getCollectionFloorPrice = async (collectionId: string) => {
5
- const res = await gqlChainRequest({
6
- chain: 'sui',
7
- query: fetchCollectionFloorListings,
8
- variables: { collectionId },
9
- });
10
-
11
- return res?.listings?.[0]?.price;
12
- };
@@ -1,29 +0,0 @@
1
- import { gqlChainRequest } from '../graphql/gqlChainRequest';
2
- import { fetchLockById } from '../graphql/queries/fetchLockById';
3
-
4
- export type Lock = {
5
- id: string;
6
- lock_id: string;
7
- chain_state?: Record<string, any>;
8
- nft_type: string;
9
- type: string;
10
- state: string;
11
- maker_price: bigint;
12
- maker: string;
13
- collection_id: string;
14
- expire_in: number;
15
- nft?: {
16
- id: string;
17
- token_id: string;
18
- };
19
- };
20
-
21
- export const getLockById = async (lockId: string): Promise<Lock | undefined> => {
22
- const res = await gqlChainRequest({
23
- chain: 'sui',
24
- query: fetchLockById,
25
- variables: { lockId },
26
- });
27
-
28
- return res?.locks?.[0] ?? undefined;
29
- };
@@ -1,82 +0,0 @@
1
- import {
2
- BASC_ROYALTY_DECIMAL_PERCENT,
3
- COLLECTION_IDS_WITH_ZERO_COMMISSION,
4
- DSL_LEGACY_ROYALTY_DECIMAL_PERCENT,
5
- MASC_ROYALTY_DECIMAL_PERCENT,
6
- TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT,
7
- } from '../constants';
8
-
9
- export const getMASCMarketFeePrice = (price: number) => {
10
- if (price * (MASC_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT) < 1) {
11
- return price * (MASC_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT);
12
- }
13
-
14
- return parseInt(
15
- (price * (MASC_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT))?.toFixed(0),
16
- 10,
17
- );
18
- };
19
-
20
- export const getBASCMarketFeePrice = (price: number) => {
21
- if (price * (BASC_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT) < 1) {
22
- return price * (BASC_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT);
23
- }
24
-
25
- return parseInt(
26
- (price * (BASC_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT))?.toFixed(0),
27
- 10,
28
- );
29
- };
30
-
31
- export const getDSLLegacyMarketFeePrice = (price: number) => {
32
- if (price * (DSL_LEGACY_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT) < 1) {
33
- return price * (DSL_LEGACY_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT);
34
- }
35
-
36
- return parseInt(
37
- (price * (DSL_LEGACY_ROYALTY_DECIMAL_PERCENT + TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT))?.toFixed(
38
- 0,
39
- ),
40
- 10,
41
- );
42
- };
43
-
44
- type GetMarketFeePrice = {
45
- price: number;
46
- collectionId: string;
47
- marketFeeDecimalPercent?: number;
48
- };
49
-
50
- export const getMarketFeePrice = ({
51
- price,
52
- collectionId,
53
- marketFeeDecimalPercent,
54
- }: GetMarketFeePrice) => {
55
- if (collectionId === '6824e1ff-477e-4810-9ba7-8d6387b68c7d') {
56
- return getBASCMarketFeePrice(price);
57
- }
58
-
59
- if (collectionId === '8568521c-73a3-4beb-b830-d1ff27a3f1ca') {
60
- return getMASCMarketFeePrice(price);
61
- }
62
-
63
- if (collectionId === '307c7e7a-be3a-43a5-ae44-37f3a37d01f9') {
64
- return getDSLLegacyMarketFeePrice(price);
65
- }
66
-
67
- let marketFeePrice = 0;
68
-
69
- if (!COLLECTION_IDS_WITH_ZERO_COMMISSION?.includes(collectionId)) {
70
- marketFeePrice = price * TRADEPORT_DEFAULT_FEE_DECIMAL_PERCENT;
71
-
72
- if (marketFeeDecimalPercent) {
73
- marketFeePrice = price * marketFeeDecimalPercent;
74
- }
75
- }
76
-
77
- if (marketFeePrice < 1) {
78
- return marketFeePrice;
79
- }
80
-
81
- return parseInt(marketFeePrice?.toFixed(0), 10);
82
- };
@@ -1,38 +0,0 @@
1
- interface CollectionChainState {
2
- nft_type: string;
3
- }
4
-
5
- interface NFT {
6
- properties?: {
7
- nft_type?: string;
8
- };
9
- contract?: {
10
- properties?: {
11
- nft_type?: string;
12
- };
13
- };
14
- }
15
-
16
- export const getNftType = ({
17
- collectionId,
18
- collectionChainState,
19
- nft,
20
- }: {
21
- collectionId: string;
22
- collectionChainState?: CollectionChainState;
23
- nft?: NFT;
24
- }): string => {
25
- if (collectionId === 'a6fabb11-4713-4203-bce8-a3c4f673b5a7') {
26
- // dungeon move, each nft has different type based off it's identity, so use nft.properties.nft_type
27
- return nft?.properties?.nft_type;
28
- }
29
-
30
- if (collectionChainState?.nft_type) return collectionChainState.nft_type;
31
-
32
- let nftType = nft?.properties?.nft_type;
33
- if (!nftType || nftType?.split('::')?.length <= 1) {
34
- nftType = nft?.contract?.properties?.nft_type;
35
- }
36
-
37
- return nftType ?? '';
38
- };
@@ -1,7 +0,0 @@
1
- import { normalizedNftType } from '../utils/normalizeNftType';
2
-
3
- export const getRoyaltyRuleModule = (nftType: string) =>
4
- normalizedNftType(nftType) ===
5
- '0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard'
6
- ? 'kiosk_royalty_rule'
7
- : 'royalty_rule';
@@ -1,119 +0,0 @@
1
- import {
2
- CRYPTOPEDIA_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
3
- FUDDIES_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
4
- GNOMES_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
5
- NOVAGEN_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
6
- ORIGIN_BYTE_ALLOW_LIST_OBJECT,
7
- SACABAM_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
8
- STORKS_ORIGIN_BYTE_ALLOW_LIST,
9
- SUISHI_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
10
- SUI_ECOSYSTEM_ORIGIN_BYTE_ALLOW_LIST_OBJECT,
11
- } from '../constants';
12
- import { gqlChainRequest } from '../graphql/gqlChainRequest';
13
- import { fetchSharedObjectsByType } from '../graphql/queries/fetchSharedObjectsByType';
14
- import { addLeadingZerosAfter0x } from '../utils/addLeadingZerosAfter0x';
15
-
16
- export type SuiSharedObjects = {
17
- orderbook: string;
18
- collection: string;
19
- royaltyStrategy: string;
20
- keepsakeRoyaltyStrategy: string;
21
- transferPolicy: string;
22
- marketplace: string;
23
- allowList: string;
24
- };
25
-
26
- export const getSharedObjects = async (nftType: string): Promise<SuiSharedObjects> => {
27
- const nftTypeSplit = nftType?.split('::');
28
- if (nftTypeSplit?.[0]) nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
29
-
30
- const res = await gqlChainRequest({
31
- chain: 'sui',
32
- query: fetchSharedObjectsByType,
33
- variables: { type: nftTypeSplit?.join('::') },
34
- });
35
-
36
- let allowList = res?.sharedObjects?.filter((object: any) => object?.module === 'allowlist')?.[0]
37
- ?.id;
38
- if (!allowList) allowList = ORIGIN_BYTE_ALLOW_LIST_OBJECT;
39
- if (
40
- nftType === '0x5f1fa51a6d5c52df7dfe0ff7efaab7cc769d81e51cf208a424e455575aa1ed7a::stork::Stork'
41
- ) {
42
- allowList = STORKS_ORIGIN_BYTE_ALLOW_LIST;
43
- }
44
-
45
- if (
46
- nftType === '0xf1681f601a1c021a0b4c8c8859d50917308fcbebfd19364c4e856ac670bb8496::suishi::Suishi'
47
- ) {
48
- allowList = SUISHI_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
49
- }
50
-
51
- if (
52
- nftType?.includes(
53
- 'ac176715abe5bcdaae627c5048958bbe320a8474f524674f3278e31af3c8b86b::fuddies::Fuddies',
54
- )
55
- ) {
56
- allowList = FUDDIES_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
57
- }
58
-
59
- if (
60
- nftType ===
61
- '0x71bd3651e47a7590e607b976a332338e2230e995fa96de430703af537086b643::cryptopedia::Cryptopedia'
62
- ) {
63
- allowList = CRYPTOPEDIA_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
64
- }
65
-
66
- if (
67
- nftType === '0xe81341eba87d19f8d53ee237b3666cff6a74c9fd7a960cf5753af69bc7c6a221::gnomes::Gnome'
68
- ) {
69
- allowList = GNOMES_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
70
- }
71
-
72
- if (
73
- nftType ===
74
- '0x7f481ffff2b72f3f1d9b70d5ad999d8b514a6281aa29aedbb6c537bd4b0d04ad::sacabam::Sacabam'
75
- ) {
76
- allowList = SACABAM_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
77
- }
78
-
79
- if (
80
- nftType ===
81
- '0x5fe8e884960f6977f813d871a3d43049d72d19d4ad07819b979c06434f60af4d::mint::SuiEcosystemNFT'
82
- ) {
83
- allowList = SUI_ECOSYSTEM_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
84
- }
85
-
86
- if (
87
- nftType ===
88
- '0xf417417b1914266b634b3dc90050be9f28fb755e9d29f36d1892012e0ad6f816::novagen::Novagen'
89
- ) {
90
- allowList = NOVAGEN_ORIGIN_BYTE_ALLOW_LIST_OBJECT;
91
- }
92
-
93
- const transferPolicy = res?.sharedObjects?.filter(
94
- (object: any) => object?.module === 'transfer_policy',
95
- )?.[0]?.id;
96
-
97
- let orderbook = res?.sharedObjects?.filter((object: any) => object?.module === 'orderbook')?.[0]
98
- ?.id;
99
-
100
- if (nftTypeSplit?.join('::')?.includes('keepsake_nft::KEEPSAKE')) {
101
- orderbook = null;
102
- }
103
-
104
- return {
105
- orderbook,
106
- collection: res?.sharedObjects?.filter((object: any) => object?.module === 'collection')?.[0]
107
- ?.id,
108
- marketplace: res?.sharedObjects?.filter((object: any) => object?.module === 'marketplace')?.[0]
109
- ?.id,
110
- royaltyStrategy: res?.sharedObjects?.filter(
111
- (object: any) => object?.module === 'royalty_strategy_bps',
112
- )?.[0]?.id,
113
- keepsakeRoyaltyStrategy: res?.sharedObjects?.filter(
114
- (object: any) => object?.module === 'keepsake_royalties',
115
- )?.[0]?.id,
116
- transferPolicy,
117
- allowList,
118
- };
119
- };
@@ -1,14 +0,0 @@
1
- import { gqlChainRequest } from '../graphql/gqlChainRequest';
2
- import { fetchCryptoToUsdRate } from '../graphql/queries/fetchCryptoToUsdRate';
3
-
4
- export const getSuiToUsdRate = async (): Promise<number> => {
5
- try {
6
- const res = await gqlChainRequest({
7
- chain: 'sui',
8
- query: fetchCryptoToUsdRate,
9
- variables: { crypto: 'sui' },
10
- });
11
-
12
- return res?.crypto_rates?.[0]?.rate;
13
- } catch (e) {}
14
- };
@@ -1,31 +0,0 @@
1
- import {
2
- BASC_ROYALTY_DECIMAL_PERCENT,
3
- DSL_LEGACY_ROYALTY_DECIMAL_PERCENT,
4
- MASC_ROYALTY_DECIMAL_PERCENT,
5
- } from '../constants';
6
-
7
- interface Args {
8
- bidAmount: number;
9
- collectionId: string;
10
- }
11
-
12
- export const getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }: Args) => {
13
- let amount = bidAmount;
14
-
15
- // MASC
16
- if (collectionId === '8568521c-73a3-4beb-b830-d1ff27a3f1ca') {
17
- amount = bidAmount - bidAmount * MASC_ROYALTY_DECIMAL_PERCENT;
18
- }
19
-
20
- // BASC
21
- if (collectionId === '6824e1ff-477e-4810-9ba7-8d6387b68c7d') {
22
- amount = bidAmount - bidAmount * BASC_ROYALTY_DECIMAL_PERCENT;
23
- }
24
-
25
- // DSL Legacy
26
- if (collectionId === '307c7e7a-be3a-43a5-ae44-37f3a37d01f9') {
27
- amount = bidAmount - bidAmount * DSL_LEGACY_ROYALTY_DECIMAL_PERCENT;
28
- }
29
-
30
- return amount;
31
- };
@@ -1,24 +0,0 @@
1
- import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
- import { normalizeStructTag, normalizeSuiObjectId } from '@mysten/sui/utils';
3
-
4
- export const getTransferPolicyRuleNamesFromSuiObject = async ({
5
- suiClient,
6
- transferPolicyId,
7
- }: {
8
- suiClient: SuiGrpcClient;
9
- transferPolicyId: string;
10
- }) => {
11
- const { object } = await suiClient.getObject({
12
- objectId: normalizeSuiObjectId(transferPolicyId),
13
- include: { json: true },
14
- });
15
-
16
- const content = object.json as unknown as {
17
- rules: {
18
- contents: string[];
19
- };
20
- };
21
- const ruleNames = content.rules.contents.map((rule) => normalizeStructTag(rule));
22
-
23
- return ruleNames;
24
- };
@@ -1,7 +0,0 @@
1
- import { getNativeKioskTransferPolicies } from './kiosk/getNativeKioskTransferPolicies';
2
-
3
- export const hasPersonalKioskRule = (transferPolicies: any): boolean =>
4
- getNativeKioskTransferPolicies(transferPolicies)?.some(
5
- (policy: any) =>
6
- policy?.rules?.filter((rule: any) => rule?.type?.includes('personal_kiosk_rule'))?.length > 0,
7
- );
@@ -1,7 +0,0 @@
1
- import { getNativeKioskTransferPolicies } from './kiosk/getNativeKioskTransferPolicies';
2
-
3
- export const hasRoyaltyRule = (transferPolicies: any): boolean =>
4
- getNativeKioskTransferPolicies(transferPolicies)?.some(
5
- (policy: any) =>
6
- policy?.rules?.filter((rule: any) => rule?.type?.includes('royalty_rule'))?.length > 0,
7
- );
@@ -1,6 +0,0 @@
1
- import { getNativeKioskTransferPolicies } from './kiosk/getNativeKioskTransferPolicies';
2
-
3
- export const hasNativeKioskTransferPolicyRules = (transferPolicies: any): boolean => {
4
- const nativeKioskTransferPolicies = getNativeKioskTransferPolicies(transferPolicies);
5
- return nativeKioskTransferPolicies?.some((policy: any) => policy?.rules?.length > 0);
6
- };
@@ -1,9 +0,0 @@
1
- import { normalizeSuiAddress } from '@mysten/sui/utils';
2
-
3
- export const isExpiredListing = (
4
- listing: { nonce?: string; seller?: string },
5
- walletAddress: string,
6
- ) =>
7
- listing.nonce &&
8
- listing.seller &&
9
- normalizeSuiAddress(listing.seller) === normalizeSuiAddress(walletAddress);
@@ -1,14 +0,0 @@
1
- import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
- import { NON_KIOSK_LISTING_NONCE_TYPE } from '../constants';
3
- import { getObjectType } from './rpc/getObjectType';
4
-
5
- export const isNonKioskListing = async ({
6
- suiClient,
7
- listingNonce,
8
- }: {
9
- suiClient: SuiGrpcClient;
10
- listingNonce: string;
11
- }): Promise<boolean> => {
12
- const listingType = await getObjectType({ suiClient, objectId: listingNonce });
13
- return listingType === NON_KIOSK_LISTING_NONCE_TYPE;
14
- };
@@ -1,13 +0,0 @@
1
- import { TRADEPORT_MULTI_BID_PACKAGE_ORIGINAL } from '../constants';
2
-
3
- export const isSingleBid = (bidType: string): boolean => {
4
- if (!bidType) {
5
- return false;
6
- }
7
-
8
- if (!bidType.startsWith('0x')) {
9
- bidType = `0x${bidType}`;
10
- }
11
-
12
- return bidType === `${TRADEPORT_MULTI_BID_PACKAGE_ORIGINAL}::tradeport_biddings::SingleBid`;
13
- };
@@ -1,31 +0,0 @@
1
- import { gqlChainRequest } from '../../graphql/gqlChainRequest';
2
- import { fetchKiosksByOwner } from '../../graphql/queries/fetchKiosksByOwner';
3
- import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
4
- import { type SharedKioskState } from './sharedKioskState.type';
5
-
6
- export const assertNftInSharedKiosk = async ({
7
- kioskId,
8
- walletAddress,
9
- sharedKioskState,
10
- }: {
11
- kioskId: string;
12
- walletAddress: string;
13
- sharedKioskState?: SharedKioskState;
14
- }): Promise<void> => {
15
- if (!sharedKioskState?.ownerKiosks) {
16
- const res = await gqlChainRequest({
17
- chain: 'sui',
18
- query: fetchKiosksByOwner,
19
- variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) },
20
- });
21
- if (sharedKioskState) {
22
- sharedKioskState.ownerKiosks = res?.kiosks;
23
- }
24
- }
25
-
26
- const nftKiosk = sharedKioskState?.ownerKiosks?.find((k: any) => k.id === kioskId);
27
-
28
- if (nftKiosk && !nftKiosk?.is_shared) {
29
- throw new Error('NFT is inside a kiosk that is not shared');
30
- }
31
- };
@@ -1,71 +0,0 @@
1
- import { bcs } from '@mysten/sui/bcs';
2
- import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
- import {
4
- Transaction,
5
- type TransactionArgument,
6
- type TransactionObjectInput,
7
- } from '@mysten/sui/transactions';
8
- import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
9
-
10
- interface Args {
11
- tx: Transaction;
12
- suiClient: SuiGrpcClient;
13
- walletAddress: string;
14
- royaltyRulePackageId: string;
15
- royaltyRuleModule: string;
16
- transferPolicyId: string | TransactionObjectInput;
17
- price: number | string;
18
- nftType: string;
19
- }
20
-
21
- export async function getKioskCollectionRoyaltyFeeAmount({
22
- tx,
23
- suiClient,
24
- walletAddress,
25
- royaltyRulePackageId,
26
- royaltyRuleModule,
27
- transferPolicyId,
28
- price,
29
- nftType,
30
- }: Args): Promise<TransactionArgument | bigint | undefined> {
31
- if (!royaltyRulePackageId || !royaltyRuleModule || !transferPolicyId || !nftType) {
32
- console.warn('Missing required parameters for royalty fee calculation');
33
- return undefined;
34
- }
35
-
36
- if (!price) {
37
- console.warn('Price is undefined or 0');
38
- return undefined;
39
- }
40
-
41
- const feeTx = new Transaction();
42
- feeTx.moveCall({
43
- target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
44
- arguments: [feeTx.object(transferPolicyId), feeTx.pure.u64(price)],
45
- typeArguments: [nftType],
46
- });
47
-
48
- feeTx.setSender(addLeadingZerosAfter0x(walletAddress));
49
- const res = await suiClient.simulateTransaction({
50
- transaction: feeTx,
51
- include: { commandResults: true },
52
- checksEnabled: false,
53
- });
54
-
55
- let feeAmount: TransactionArgument | bigint | undefined;
56
- const returnedAmount = res?.commandResults?.[0]?.returnValues?.[0]?.bcs;
57
- if (returnedAmount) {
58
- feeAmount = BigInt(bcs.U64.parse(returnedAmount));
59
- }
60
-
61
- // We were not able to calculate the amount outside of the transaction, so fall back to resolving it within the PTB
62
- if (!feeAmount && feeAmount !== 0n) {
63
- [feeAmount] = tx.moveCall({
64
- target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
65
- typeArguments: [nftType],
66
- arguments: [tx.object(transferPolicyId), tx.pure.u64(price)],
67
- });
68
- }
69
-
70
- return feeAmount;
71
- }
@@ -1,29 +0,0 @@
1
- import { type KioskTransaction } from '@mysten/kiosk';
2
- import { type Transaction } from '@mysten/sui/transactions';
3
-
4
- export const getKioskIdFromKioskTx = ({
5
- kioskTx,
6
- tx,
7
- }: {
8
- kioskTx: KioskTransaction;
9
- tx: Transaction;
10
- }): string => {
11
- const kioskArg = kioskTx.kiosk as any;
12
-
13
- if (!kioskArg || !('Input' in kioskArg)) {
14
- throw new Error('Invalid kiosk transaction structure');
15
- }
16
-
17
- const input = (tx as any).getData().inputs[kioskArg.Input];
18
- const kioskId =
19
- input?.UnresolvedObject?.objectId ??
20
- input?.Object?.ImmOrOwnedObject?.objectId ??
21
- input?.Object?.SharedObject?.objectId ??
22
- input?.Object?.Receiving?.objectId;
23
-
24
- if (!kioskId) {
25
- throw new Error('Invalid kiosk transaction structure');
26
- }
27
-
28
- return kioskId;
29
- };