@tradeport/sui-trading-sdk 0.4.66 → 0.5.1

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 (55) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.js +330 -329
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +16 -5
  6. package/dist/index.mjs.map +1 -1
  7. package/jest.config.js +6 -2
  8. package/package.json +66 -65
  9. package/src/SuiTradingClient.ts +24 -14
  10. package/src/apiClients/createKioskClient.ts +5 -6
  11. package/src/apiClients/createSuiClient.ts +2 -2
  12. package/src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts +9 -21
  13. package/src/helpers/isNonKioskListing.ts +2 -2
  14. package/src/helpers/kiosk/getKioskCollectionRoyaltyFeeAmount.ts +10 -10
  15. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +15 -7
  16. package/src/helpers/kiosk/getKioskPlaceBidCoin.ts +2 -2
  17. package/src/helpers/kiosk/getRulePackageId.ts +2 -2
  18. package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +2 -2
  19. package/src/helpers/kiosk/kioskListingBcs.ts +19 -0
  20. package/src/helpers/kiosk/kioskTxWrapper.ts +3 -3
  21. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +9 -9
  22. package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +33 -21
  23. package/src/helpers/kiosk/resolveRoyaltyRule.ts +2 -2
  24. package/src/helpers/kiosk/resolveTransferPolicies.ts +2 -2
  25. package/src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts +2 -2
  26. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +5 -9
  27. package/src/helpers/originByte/getOBBidderKiosk.ts +4 -7
  28. package/src/helpers/rpc/getAcountBalance.ts +3 -3
  29. package/src/helpers/rpc/getObjectType.ts +8 -4
  30. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +2 -2
  31. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +3 -3
  32. package/src/methods/acceptNftBids/acceptNftBids.ts +2 -2
  33. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +4 -4
  34. package/src/methods/buyListings/addBuyListingTxs.ts +16 -18
  35. package/src/methods/buyListings/buyListings.ts +2 -2
  36. package/src/methods/cancelNftTransfers/addCancelNftTransfersTx.ts +1 -1
  37. package/src/methods/claimNfts/addClaimNftsTxs.ts +8 -8
  38. package/src/methods/claimNfts/claimNfts.ts +3 -3
  39. package/src/methods/listNfts/addListTxs.ts +2 -2
  40. package/src/methods/listNfts/addRelistTxs.ts +4 -4
  41. package/src/methods/listNfts/listNfts.ts +2 -2
  42. package/src/methods/placeCollectionBids/placeCollectionBids.ts +2 -2
  43. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +5 -10
  44. package/src/methods/placeNftBids/placeNftBids.ts +2 -2
  45. package/src/methods/relistNft/relistNft.ts +2 -2
  46. package/src/methods/removeCollectionBids/removeCollectionBids.ts +2 -2
  47. package/src/methods/removeNftBids/removeNftBids.ts +2 -2
  48. package/src/methods/transferNfts/addTransferNftTx.ts +16 -7
  49. package/src/methods/transferNfts/transferNfts.ts +2 -2
  50. package/src/methods/unlistListings/addUnlistListingTxs.ts +6 -10
  51. package/src/methods/unlistListings/unlistListings.ts +2 -2
  52. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +2 -2
  53. package/src/tests/SuiWallet.ts +19 -15
  54. package/tsconfig.json +2 -1
  55. package/.claude/settings.local.json +0 -5
@@ -43,8 +43,8 @@ export async function addLegacyTradePortKioskUnlistTx({
43
43
  '0x475e98e9c436ec118909f3b9e241d86bcbbc2cf9fba05e99a934823fefb375b7::kiosk_listings::unlist',
44
44
  arguments: [
45
45
  tx.object(TRADEPORT_KIOSK_LISTING_STORE),
46
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
47
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
46
+ tx.object(kioskTx.kiosk),
47
+ tx.object(kioskTx.kioskCap),
48
48
  tx.pure.address(nftTokenId),
49
49
  ],
50
50
  typeArguments: [nftType],
@@ -74,8 +74,8 @@ export async function addKioskTradePortUnlistTx({
74
74
  arguments: [
75
75
  tx.object(TRADEPORT_LISTINGS_STORE),
76
76
  tx.object(TRADEPORT_ORDERBOOK_STORE),
77
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
78
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
77
+ tx.object(kioskTx.kiosk),
78
+ tx.object(kioskTx.kioskCap),
79
79
  tx.pure.id(nftTokenId),
80
80
  ],
81
81
  typeArguments: [nftType],
@@ -134,7 +134,7 @@ export async function addBluemoveKioskUnlistTx({
134
134
  '0xcc97b74ed95c8e8a3ed88050a898727dee37896da579fc400d482b64db6149ff::kiosk_trade::kiosk_delist',
135
135
  arguments: [
136
136
  tx.object(BLUEMOVE_KIOSK_MARKETPLACE_KIOSK_OBJECT),
137
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
137
+ tx.object(kioskTx.kiosk),
138
138
  tx.pure.address(nftTokenId),
139
139
  ],
140
140
  typeArguments: [nftType],
@@ -163,11 +163,7 @@ export async function addHyperspaceKioskUnlistTx({
163
163
  tx.moveCall({
164
164
  target:
165
165
  '0x6ea97b03c441edd54ae89224bf9560e583ee66c37e6c246f5db35258e580ba94::hyperspace::delist',
166
- arguments: [
167
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
168
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
169
- tx.pure.address(nftTokenId),
170
- ],
166
+ arguments: [tx.object(kioskTx.kiosk), tx.object(kioskTx.kioskCap), tx.pure.address(nftTokenId)],
171
167
  typeArguments: [nftType, HYPERSPACE_MP_TRANSFER_POLICY_TYPE],
172
168
  });
173
169
  }
@@ -1,5 +1,5 @@
1
1
  import type { KioskClient } from '@mysten/kiosk';
2
- import type { SuiClient } from '@mysten/sui/client';
2
+ import type { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Transaction } from '@mysten/sui/transactions';
4
4
  import { type RequestContext } from '../../SuiTradingClient';
5
5
  import {
@@ -24,7 +24,7 @@ import { normalizeSuiAddress } from '@mysten/sui/utils';
24
24
 
25
25
  export type UnlistListingTx = {
26
26
  tx: Transaction;
27
- suiClient: SuiClient;
27
+ suiClient: SuiGrpcClient;
28
28
  kioskClient: KioskClient;
29
29
  sharedKioskState?: SharedKioskState;
30
30
  kioskTx?: any;
@@ -55,7 +55,7 @@ export async function withdrawProfitsFromKiosks(
55
55
  ).personalCap?.id;
56
56
 
57
57
  kioskTx = new KioskTransaction({
58
- transactionBlock: tx as any,
58
+ transaction: tx,
59
59
  kioskClient: context.kioskClient,
60
60
  cap: {
61
61
  isPersonal: true,
@@ -75,7 +75,7 @@ export async function withdrawProfitsFromKiosks(
75
75
  ).ownerCap?.id;
76
76
 
77
77
  kioskTx = new KioskTransaction({
78
- transactionBlock: tx as any,
78
+ transaction: tx,
79
79
  kioskClient: context.kioskClient,
80
80
  cap: {
81
81
  isPersonal: false,
@@ -18,7 +18,7 @@ export class SuiWallet {
18
18
 
19
19
  async refreshBalance(): Promise<void> {
20
20
  this.balanceAmount = BigInt(
21
- (await this.suiClient.getBalance({ owner: this.keypair.toSuiAddress() })).totalBalance,
21
+ (await this.suiClient.getBalance({ owner: this.keypair.toSuiAddress() })).balance.balance,
22
22
  );
23
23
  }
24
24
 
@@ -31,19 +31,16 @@ export class SuiWallet {
31
31
  }
32
32
 
33
33
  async simulateCall(tx: Transaction, sender?: string): Promise<any> {
34
- const result = await this.suiClient.devInspectTransactionBlock({
35
- transactionBlock: tx,
36
- sender: sender ?? this.keypair.toSuiAddress(),
34
+ tx.setSenderIfNotSet(sender ?? this.keypair.toSuiAddress());
35
+ const result = await this.suiClient.simulateTransaction({
36
+ transaction: tx,
37
+ include: { effects: true },
37
38
  });
38
39
 
39
- if (result?.effects?.status?.status === 'failure') {
40
+ if (result.$kind === 'FailedTransaction') {
40
41
  throw new Error(
41
- `Error on transaction simulation (from effect): ${result.effects.status.error}`,
42
- ); // result.effects.status.error
43
- }
44
-
45
- if (result?.error) {
46
- throw new Error(`Error on transaction simulation: ${result.error}`); // result.error
42
+ `Error on transaction simulation: ${JSON.stringify(result.FailedTransaction.status.error)}`,
43
+ );
47
44
  }
48
45
 
49
46
  return result;
@@ -51,17 +48,24 @@ export class SuiWallet {
51
48
 
52
49
  async executeTransaction(tx: Transaction): Promise<string> {
53
50
  tx.setSenderIfNotSet(this.keypair.toSuiAddress());
54
- const { digest } = await this.suiClient.signAndExecuteTransaction({
51
+ const executed = await this.suiClient.signAndExecuteTransaction({
55
52
  transaction: tx,
56
53
  signer: this.keypair,
57
54
  });
55
+ const digest = executed.Transaction?.digest ?? executed.FailedTransaction?.digest ?? '';
58
56
  console.log(digest);
59
57
  const response = await this.suiClient.waitForTransaction({
60
58
  digest,
61
- options: { showEffects: true },
59
+ include: { effects: true },
62
60
  });
63
- if (response.effects?.status?.status !== 'success') {
64
- throw new Error(`Error on transaction execution: ${response.effects?.status?.error ?? ''}`);
61
+ if (response.$kind !== 'Transaction') {
62
+ throw new Error(
63
+ `Error on transaction execution: ${
64
+ response.FailedTransaction?.status?.error
65
+ ? JSON.stringify(response.FailedTransaction.status.error)
66
+ : ''
67
+ }`,
68
+ );
65
69
  }
66
70
 
67
71
  return digest;
package/tsconfig.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "es2020",
4
- "module": "commonjs",
4
+ "module": "esnext",
5
+ "moduleResolution": "Bundler",
5
6
  "lib": ["es2020"],
6
7
  "allowJs": false,
7
8
  "skipLibCheck": true,
@@ -1,5 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": ["Bash(xxd:*)", "Bash(pnpm tsc:*)", "Bash(npx tsc:*)"]
4
- }
5
- }