@tradeport/sui-trading-sdk 0.0.0

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 (103) hide show
  1. package/.babel.config.js +3 -0
  2. package/.env.demo +4 -0
  3. package/.eslintrc.json +46 -0
  4. package/.prettierignore +4 -0
  5. package/.prettierrc.json +7 -0
  6. package/README.md +1 -0
  7. package/dist/index.d.mts +90 -0
  8. package/dist/index.d.ts +90 -0
  9. package/dist/index.js +3760 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +3733 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/jest.config.js +7 -0
  14. package/package.json +45 -0
  15. package/src/SuiTradingClient.ts +158 -0
  16. package/src/apiClients/graphqlClient.ts +5 -0
  17. package/src/apiClients/kioskClient.ts +10 -0
  18. package/src/apiClients/suiClient.ts +5 -0
  19. package/src/constants.ts +74 -0
  20. package/src/graphql/createChainGQLQuery.ts +25 -0
  21. package/src/graphql/gqlChainRequest.ts +20 -0
  22. package/src/graphql/queries/fetchAccountKiosks.ts +12 -0
  23. package/src/graphql/queries/fetchBidsById.ts +28 -0
  24. package/src/graphql/queries/fetchCollectionBidById.ts +20 -0
  25. package/src/graphql/queries/fetchCollectionBidsAtSamePrice.ts +28 -0
  26. package/src/graphql/queries/fetchCollectionsById.ts +30 -0
  27. package/src/graphql/queries/fetchCommissionByListingId.ts +13 -0
  28. package/src/graphql/queries/fetchCryptoToUsdRate.ts +13 -0
  29. package/src/graphql/queries/fetchKiosksByOwner.ts +13 -0
  30. package/src/graphql/queries/fetchListingsById.ts +24 -0
  31. package/src/graphql/queries/fetchListingsByNftId.ts +23 -0
  32. package/src/graphql/queries/fetchNftsById.ts +61 -0
  33. package/src/graphql/queries/fetchOwnerCapByKiosk.ts +10 -0
  34. package/src/graphql/queries/fetchPersonalCapByKiosk.ts +10 -0
  35. package/src/graphql/queries/fetchSharedObjectsByType.ts +12 -0
  36. package/src/graphql/queries/fetchTransferPoliciesByType.ts +12 -0
  37. package/src/graphql/queries/getCommissionByListingId.ts +15 -0
  38. package/src/helpers/addOneDollarFee.ts +17 -0
  39. package/src/helpers/addThirdPartyTxFee.ts +17 -0
  40. package/src/helpers/destroyZeroCoin.ts +14 -0
  41. package/src/helpers/getMarketFeePrice.ts +78 -0
  42. package/src/helpers/getNftTypeFromNft.ts +8 -0
  43. package/src/helpers/getSharedObjects.ts +113 -0
  44. package/src/helpers/getSuiToUsdRate.ts +17 -0
  45. package/src/helpers/getTradeportBiddingContractParsedBidAmount.ts +32 -0
  46. package/src/helpers/hasRoyaltyRule.ts +14 -0
  47. package/src/helpers/hasTransferPolicyRules.ts +21 -0
  48. package/src/helpers/isNonKioskListing.ts +7 -0
  49. package/src/helpers/kiosk/getRulePackageId.ts +26 -0
  50. package/src/helpers/kiosk/isBluemoveKioskBid.ts +1 -0
  51. package/src/helpers/kiosk/isTradePortKioskBid.ts +4 -0
  52. package/src/helpers/kiosk/kioskTxWrapper.ts +102 -0
  53. package/src/helpers/kiosk/resolveFloorPriceRule.ts +25 -0
  54. package/src/helpers/kiosk/resolveKioskLockRule.ts +49 -0
  55. package/src/helpers/kiosk/resolvePersonalKioskRule.ts +26 -0
  56. package/src/helpers/kiosk/resolveRoyaltyRule.ts +41 -0
  57. package/src/helpers/kiosk/resolveTransferPolicies.ts +150 -0
  58. package/src/helpers/originByte/confirmOBTranfer.ts +33 -0
  59. package/src/helpers/originByte/createOBKiosk.ts +14 -0
  60. package/src/helpers/originByte/depositNftIntoOBKiosk.ts +14 -0
  61. package/src/helpers/originByte/getOBBidderKiosk.ts +9 -0
  62. package/src/helpers/originByte/getOBKiosk.ts +24 -0
  63. package/src/helpers/originByte/getOrCreateOBKiosk.ts +37 -0
  64. package/src/helpers/originByte/isOBKiosk.ts +13 -0
  65. package/src/helpers/originByte/isOriginByteBid.ts +6 -0
  66. package/src/helpers/originByte/isOriginByteTx.ts +2 -0
  67. package/src/helpers/originByte/shareOriginByteKiosk.ts +14 -0
  68. package/src/helpers/rpc/getAcountBalance.ts +17 -0
  69. package/src/helpers/rpc/getObjectType.ts +10 -0
  70. package/src/helpers/splitCoins.ts +12 -0
  71. package/src/index.ts +3 -0
  72. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +119 -0
  73. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +359 -0
  74. package/src/methods/acceptNftBids/acceptNftBids.ts +100 -0
  75. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +214 -0
  76. package/src/methods/buyListings/addBuyListingTxs.ts +503 -0
  77. package/src/methods/buyListings/buyListings.ts +143 -0
  78. package/src/methods/claimNfts/addClaimNftsTxs.ts +104 -0
  79. package/src/methods/claimNfts/claimNfts.ts +139 -0
  80. package/src/methods/listNfts/addListTxs.ts +186 -0
  81. package/src/methods/listNfts/addRelistTxs.ts +79 -0
  82. package/src/methods/listNfts/listNfts.ts +80 -0
  83. package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +146 -0
  84. package/src/methods/placeCollectionBids/placeCollectionBids.ts +120 -0
  85. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +146 -0
  86. package/src/methods/placeNftBids/placeNftBids.ts +69 -0
  87. package/src/methods/relistNft/relistNft.ts +104 -0
  88. package/src/methods/removeCollectionBid/addRemoveCollectionBidTxs.ts +119 -0
  89. package/src/methods/removeCollectionBid/removeCollectionBid.ts +97 -0
  90. package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +84 -0
  91. package/src/methods/removeNftBids/removeNftBids.ts +80 -0
  92. package/src/methods/transferNfts/addTransferNftTx.ts +78 -0
  93. package/src/methods/transferNfts/transferNfts.ts +107 -0
  94. package/src/methods/unlistListings/addUnlistListingTxs.ts +258 -0
  95. package/src/methods/unlistListings/unlistListings.ts +108 -0
  96. package/src/methods/withdrawKioskProfits/withdrawKioskProfits.ts +25 -0
  97. package/src/tests/SuiWallet.ts +49 -0
  98. package/src/utils/addHexPrefix.ts +7 -0
  99. package/src/utils/addLeadingZerosAfter0x.ts +2 -0
  100. package/src/utils/parseSUI.ts +1 -0
  101. package/src/utils/printTxBlockTxs.ts +5 -0
  102. package/src/utils/toUint8Array.ts +12 -0
  103. package/tsconfig.json +14 -0
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
3
+ };
package/.env.demo ADDED
@@ -0,0 +1,4 @@
1
+ GRAPHQL_API_USER=
2
+ GRAPHQL_API_KEY=
3
+ SUI_WALLET_SECRET_KEY=
4
+ SUI_WALLET_PUBLIC_KEY=
package/.eslintrc.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2022": true,
5
+ "commonjs": true,
6
+ "node": true
7
+ },
8
+ "extends": ["xo", "prettier"],
9
+ "overrides": [
10
+ {
11
+ "extends": ["xo-typescript"],
12
+ "files": ["*.ts"],
13
+ "rules": {
14
+ "@typescript-eslint/naming-convention": "off",
15
+ "@typescript-eslint/prefer-nullish-coalescing": "off",
16
+ "@typescript-eslint/no-unsafe-return": "off",
17
+ "@typescript-eslint/no-unsafe-call": "off",
18
+ "@typescript-eslint/no-unsafe-assignment": "off",
19
+ "@typescript-eslint/no-unsafe-argument": "off",
20
+ "@typescript-eslint/no-empty-function": "off",
21
+ "@typescript-eslint/no-throw-literal": "off",
22
+ "@typescript-eslint/object-curly-spacing": "off",
23
+ "@typescript-eslint/consistent-type-definitions": "off",
24
+ "@typescript-eslint/no-negated-condition": "off",
25
+ "@typescript-eslint/prefer-ts-expect-error": "off",
26
+ "@typescript-eslint/indent": "off",
27
+ "@typescript-eslint/ban-ts-comment": "off",
28
+ "complexity": "off",
29
+ "@typescript-eslint/quotes": [
30
+ "error",
31
+ "single",
32
+ {
33
+ "allowTemplateLiterals": true
34
+ }
35
+ ],
36
+ "capitalized-comments": "off",
37
+ "no-await-in-loop": "off",
38
+ "no-warning-comments": "off",
39
+ "max-nested-callbacks": ["error", 6]
40
+ }
41
+ }
42
+ ],
43
+ "parserOptions": {
44
+ "ecmaVersion": "latest"
45
+ }
46
+ }
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ dist
3
+ /src/utils/getSharedObjects.ts
4
+ /src/constants.ts
@@ -0,0 +1,7 @@
1
+ {
2
+ "semi": true,
3
+ "tabWidth": 2,
4
+ "useTabs": true,
5
+ "singleQuote": true,
6
+ "printWidth": 100
7
+ }
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # sui-trading-sdk
@@ -0,0 +1,90 @@
1
+ import { TransactionBlock } from '@mysten/sui.js/transactions';
2
+
3
+ type AcceptCollectionBid = {
4
+ bidId: string;
5
+ nftId: string;
6
+ walletAddress: string;
7
+ };
8
+
9
+ type AcceptNftBids = {
10
+ bidIds: string[];
11
+ };
12
+
13
+ type BuyListings = {
14
+ listingIds: string[];
15
+ walletAddress: string;
16
+ };
17
+
18
+ type ClaimNfts = {
19
+ nftIds: string[];
20
+ walletAddress: string;
21
+ };
22
+
23
+ type ListNfts = {
24
+ nfts: Array<{
25
+ id: string;
26
+ listPrice: number;
27
+ }>;
28
+ walletAddress: string;
29
+ };
30
+
31
+ type PlaceCollectionBid = {
32
+ collectionId: string;
33
+ bidAmount: number;
34
+ numOfBids: number;
35
+ walletAddress: string;
36
+ };
37
+
38
+ type PlaceNftBids = {
39
+ nfts: Array<{
40
+ id: string;
41
+ bidAmount: number;
42
+ }>;
43
+ walletAddress: string;
44
+ };
45
+
46
+ type RemoveCollectionBid = {
47
+ bidId: string;
48
+ };
49
+
50
+ type RemoveNftBids = {
51
+ bidIds: string[];
52
+ };
53
+
54
+ type TransferNfts = {
55
+ nftIds: string[];
56
+ recipientAddress: string;
57
+ walletAddress: string;
58
+ };
59
+
60
+ type UnlistListings = {
61
+ listingIds: string[];
62
+ walletAddress: string;
63
+ };
64
+
65
+ type WithdrawKioskProfits = {
66
+ amount?: number;
67
+ walletAddress: string;
68
+ };
69
+
70
+ type ApiConfig = {
71
+ apiUser: string;
72
+ apiKey: string;
73
+ };
74
+ declare class SuiTradingClient {
75
+ constructor({ apiUser, apiKey }: ApiConfig);
76
+ buyListings({ listingIds, walletAddress }: BuyListings): Promise<TransactionBlock>;
77
+ listNfts({ nfts, walletAddress }: ListNfts): Promise<TransactionBlock>;
78
+ unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<TransactionBlock>;
79
+ placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<TransactionBlock>;
80
+ removeNftBids({ bidIds }: RemoveNftBids): Promise<TransactionBlock>;
81
+ acceptNftBids({ bidIds }: AcceptNftBids): Promise<TransactionBlock>;
82
+ placeCollectionBid({ collectionId, bidAmount, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<TransactionBlock>;
83
+ acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<TransactionBlock>;
84
+ removeCollectionBid({ bidId }: RemoveCollectionBid): Promise<TransactionBlock>;
85
+ transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<TransactionBlock>;
86
+ claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<TransactionBlock>;
87
+ withdrawKioskProfits({ amount, walletAddress }: WithdrawKioskProfits): Promise<TransactionBlock>;
88
+ }
89
+
90
+ export { SuiTradingClient };
@@ -0,0 +1,90 @@
1
+ import { TransactionBlock } from '@mysten/sui.js/transactions';
2
+
3
+ type AcceptCollectionBid = {
4
+ bidId: string;
5
+ nftId: string;
6
+ walletAddress: string;
7
+ };
8
+
9
+ type AcceptNftBids = {
10
+ bidIds: string[];
11
+ };
12
+
13
+ type BuyListings = {
14
+ listingIds: string[];
15
+ walletAddress: string;
16
+ };
17
+
18
+ type ClaimNfts = {
19
+ nftIds: string[];
20
+ walletAddress: string;
21
+ };
22
+
23
+ type ListNfts = {
24
+ nfts: Array<{
25
+ id: string;
26
+ listPrice: number;
27
+ }>;
28
+ walletAddress: string;
29
+ };
30
+
31
+ type PlaceCollectionBid = {
32
+ collectionId: string;
33
+ bidAmount: number;
34
+ numOfBids: number;
35
+ walletAddress: string;
36
+ };
37
+
38
+ type PlaceNftBids = {
39
+ nfts: Array<{
40
+ id: string;
41
+ bidAmount: number;
42
+ }>;
43
+ walletAddress: string;
44
+ };
45
+
46
+ type RemoveCollectionBid = {
47
+ bidId: string;
48
+ };
49
+
50
+ type RemoveNftBids = {
51
+ bidIds: string[];
52
+ };
53
+
54
+ type TransferNfts = {
55
+ nftIds: string[];
56
+ recipientAddress: string;
57
+ walletAddress: string;
58
+ };
59
+
60
+ type UnlistListings = {
61
+ listingIds: string[];
62
+ walletAddress: string;
63
+ };
64
+
65
+ type WithdrawKioskProfits = {
66
+ amount?: number;
67
+ walletAddress: string;
68
+ };
69
+
70
+ type ApiConfig = {
71
+ apiUser: string;
72
+ apiKey: string;
73
+ };
74
+ declare class SuiTradingClient {
75
+ constructor({ apiUser, apiKey }: ApiConfig);
76
+ buyListings({ listingIds, walletAddress }: BuyListings): Promise<TransactionBlock>;
77
+ listNfts({ nfts, walletAddress }: ListNfts): Promise<TransactionBlock>;
78
+ unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<TransactionBlock>;
79
+ placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<TransactionBlock>;
80
+ removeNftBids({ bidIds }: RemoveNftBids): Promise<TransactionBlock>;
81
+ acceptNftBids({ bidIds }: AcceptNftBids): Promise<TransactionBlock>;
82
+ placeCollectionBid({ collectionId, bidAmount, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<TransactionBlock>;
83
+ acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<TransactionBlock>;
84
+ removeCollectionBid({ bidId }: RemoveCollectionBid): Promise<TransactionBlock>;
85
+ transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<TransactionBlock>;
86
+ claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<TransactionBlock>;
87
+ withdrawKioskProfits({ amount, walletAddress }: WithdrawKioskProfits): Promise<TransactionBlock>;
88
+ }
89
+
90
+ export { SuiTradingClient };