@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
@@ -1,4 +1,4 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import {
3
3
  type Transaction,
4
4
  type TransactionArgument,
@@ -8,7 +8,7 @@ import { getKioskCollectionRoyaltyFeeAmount } from './getKioskCollectionRoyaltyF
8
8
 
9
9
  type Args = {
10
10
  tx: Transaction;
11
- suiClient: SuiClient;
11
+ suiClient: SuiGrpcClient;
12
12
  walletAddress: string;
13
13
  policyId: TransactionObjectInput;
14
14
  moduleName: string;
@@ -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 {
4
4
  type Transaction,
5
5
  type TransactionArgument,
@@ -22,7 +22,7 @@ export type Policy = {
22
22
  type Props = {
23
23
  tx: Transaction;
24
24
  transferPolicies: any[];
25
- suiClient: SuiClient;
25
+ suiClient: SuiGrpcClient;
26
26
  walletAddress: string;
27
27
  kioskClient: KioskClient;
28
28
  kioskTx: any;
@@ -1,5 +1,5 @@
1
1
  import { type KioskClient, type KioskTransaction, type TransferPolicy } from '@mysten/kiosk';
2
- import { type SuiClient } from '@mysten/sui/client';
2
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { type Transaction } from '@mysten/sui/transactions';
4
4
  import { getKioskIdFromKioskTx } from './getKioskIdFromKioskTx';
5
5
  import { takeLockedNftFromKiosk } from './takeLockedNftFromKiosk';
@@ -20,7 +20,7 @@ export const takeAndBorrowNftFromKiosk = async ({
20
20
  kioskClient: KioskClient;
21
21
  nftTokenId: string;
22
22
  nftType: string;
23
- suiClient: SuiClient;
23
+ suiClient: SuiGrpcClient;
24
24
  kioskOwner: string;
25
25
  }) => {
26
26
  const kioskId = getKioskIdFromKioskTx({ kioskTx, tx });
@@ -1,5 +1,5 @@
1
1
  import { type KioskClient, type KioskTransaction, type TransferPolicy } from '@mysten/kiosk';
2
- import { type SuiClient } from '@mysten/sui/client';
2
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { type Transaction } from '@mysten/sui/transactions';
4
4
  import { getNativeKioskTransferPolicies } from './getNativeKioskTransferPolicies';
5
5
  import { resolveTransferPolicies } from './resolveTransferPolicies';
@@ -7,7 +7,7 @@ import { resolveTransferPolicies } from './resolveTransferPolicies';
7
7
  interface TakeLockedNftFromKioskProps {
8
8
  tx: Transaction;
9
9
  transferPolicies: TransferPolicy[];
10
- suiClient: SuiClient;
10
+ suiClient: SuiGrpcClient;
11
11
  kioskTx: KioskTransaction;
12
12
  kioskClient: KioskClient;
13
13
  nftTokenId: string;
@@ -36,8 +36,8 @@ export const takeLockedNftFromKiosk = async ({
36
36
  const [purchase_cap] = tx.moveCall({
37
37
  target: '0x2::kiosk::list_with_purchase_cap',
38
38
  arguments: [
39
- tx.object('value' in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
40
- tx.object('value' in kioskTx.kioskCap ? kioskTx.kioskCap.value : kioskTx.kioskCap),
39
+ tx.object(kioskTx.kiosk),
40
+ tx.object(kioskTx.kioskCap),
41
41
  tx.pure.address(nftTokenId),
42
42
  tx.pure.u64(0),
43
43
  ],
@@ -52,11 +52,7 @@ export const takeLockedNftFromKiosk = async ({
52
52
 
53
53
  const [nft, transferRequest] = tx.moveCall({
54
54
  target: '0x2::kiosk::purchase_with_cap',
55
- arguments: [
56
- tx.object('value' in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
57
- purchase_cap,
58
- zeroCoin,
59
- ],
55
+ arguments: [tx.object(kioskTx.kiosk), purchase_cap, zeroCoin],
60
56
  typeArguments: [nftType],
61
57
  });
62
58
 
@@ -1,15 +1,12 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
 
3
3
  export const getOBBidderKiosk = async ({
4
4
  suiClient,
5
5
  bidNonce,
6
6
  }: {
7
- suiClient: SuiClient;
7
+ suiClient: SuiGrpcClient;
8
8
  bidNonce: string;
9
9
  }) => {
10
- const bidObject = (await suiClient.call('sui_getObject', [
11
- bidNonce,
12
- { showContent: true },
13
- ])) as any;
14
- return bidObject.data?.content?.fields?.kiosk;
10
+ const bidObject = await suiClient.getObject({ objectId: bidNonce, include: { json: true } });
11
+ return (bidObject.object?.json as any)?.kiosk;
15
12
  };
@@ -1,8 +1,8 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
3
3
 
4
4
  type Args = {
5
- suiClient: SuiClient;
5
+ suiClient: SuiGrpcClient;
6
6
  owner: string;
7
7
  };
8
8
 
@@ -11,7 +11,7 @@ export const getAccountBalance = async ({ suiClient, owner }: Args): Promise<num
11
11
  const res = await suiClient.getBalance({
12
12
  owner: addLeadingZerosAfter0x(owner),
13
13
  });
14
- return Number(res?.totalBalance);
14
+ return Number(res?.balance?.balance);
15
15
  } catch (err) {
16
16
  return 0;
17
17
  }
@@ -1,4 +1,4 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { isValidSuiObjectId } from '@mysten/sui/utils';
3
3
  import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
4
4
 
@@ -6,15 +6,19 @@ export const getObjectType = async ({
6
6
  suiClient,
7
7
  objectId,
8
8
  }: {
9
- suiClient: SuiClient;
9
+ suiClient: SuiGrpcClient;
10
10
  objectId: string;
11
11
  }): Promise<string> => {
12
12
  const normalizedObjectId = objectId.startsWith('0x')
13
13
  ? addLeadingZerosAfter0x(objectId)
14
14
  : objectId;
15
15
  if (isValidSuiObjectId(normalizedObjectId)) {
16
- const res = await suiClient.getObject({ id: normalizedObjectId, options: { showType: true } });
17
- return res.data.type;
16
+ try {
17
+ const res = await suiClient.getObject({ objectId: normalizedObjectId, include: {} });
18
+ return res.object?.type ?? '';
19
+ } catch {
20
+ return '';
21
+ }
18
22
  }
19
23
 
20
24
  return '';
@@ -1,5 +1,5 @@
1
1
  import type { KioskClient, KioskTransaction } 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 {
@@ -20,7 +20,7 @@ import {
20
20
 
21
21
  export type AcceptCollectionBidTx = {
22
22
  tx: Transaction;
23
- suiClient: SuiClient;
23
+ suiClient: SuiGrpcClient;
24
24
  kioskClient: KioskClient;
25
25
  kioskTx?: any;
26
26
  sharedObjects?: any;
@@ -1,4 +1,4 @@
1
- import { type TransactionObjectInput } from '@mysten/sui/dist/cjs/transactions';
1
+ import { type TransactionObjectInput } from '@mysten/sui/transactions';
2
2
  import { normalizeSuiObjectId } from '@mysten/sui/utils';
3
3
  import {
4
4
  BLUEMOVE_CREATOR_CONFIG_OBJECT,
@@ -205,8 +205,8 @@ export async function addBluemoveKioskAcceptCollectionBidTx({
205
205
  tx.object(BLUEMOVE_KIOSK_OFFER_COLLECTION_DATA_OBJECT),
206
206
  tx.object(BLUEMOVE_KIOSK_OFFER_COLLECTION_BIDDER_BAG),
207
207
  tx.pure.u64(bidNonce),
208
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
209
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
208
+ tx.object(kioskTx.kiosk),
209
+ tx.object(kioskTx.kioskCap),
210
210
  tx.pure.address(nftTokenId),
211
211
  ],
212
212
  typeArguments: [nftType],
@@ -1,5 +1,5 @@
1
1
  import { type KioskClient, type KioskTransaction } 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 {
@@ -22,7 +22,7 @@ export type AcceptNftBidTx = {
22
22
  tx: Transaction;
23
23
  sharedObjects?: any;
24
24
  transferPolicies: any;
25
- suiClient: SuiClient;
25
+ suiClient: SuiGrpcClient;
26
26
  kioskClient: KioskClient;
27
27
  kioskTx?: any;
28
28
  sharedKioskState?: SharedKioskState;
@@ -110,8 +110,8 @@ export async function addTradeportKioskAcceptNftBidTx({
110
110
  arguments: [
111
111
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
112
112
  tx.pure.address(bidNonce),
113
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
114
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
113
+ tx.object(kioskTx.kiosk),
114
+ tx.object(kioskTx.kioskCap),
115
115
  tx.pure.address(nftTokenId),
116
116
  ],
117
117
  typeArguments: [nftType],
@@ -141,8 +141,8 @@ export async function addTradeportKioskAcceptNftBidTx({
141
141
  arguments: [
142
142
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
143
143
  tx.pure.address(bidNonce),
144
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
145
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
144
+ tx.object(kioskTx.kiosk),
145
+ tx.object(kioskTx.kioskCap),
146
146
  tx.pure.address(nftTokenId),
147
147
  ],
148
148
  typeArguments: [nftType],
@@ -1,4 +1,5 @@
1
1
  import { bcs } from '@mysten/sui/bcs';
2
+ import { KioskListing } from '../../helpers/kiosk/kioskListingBcs';
2
3
  import {
3
4
  BLUEMOVE_CREATOR_CONFIG_OBJECT,
4
5
  BLUEMOVE_KIOSK_MARKETPLACE_KIOSK_OBJECT,
@@ -106,16 +107,16 @@ export const addLegacyTradeportKioskBuyTx = async ({
106
107
  sharedBulkBuyingDataByNftType?.[nftType]?.commissionFeeAmountsByListingId?.[listingId] ?? 0;
107
108
 
108
109
  if (!commissionFeeAmount) {
109
- const response = await suiClient.getDynamicFieldObject({
110
- parentId: TRADEPORT_KIOSK_LISTING_STORE,
111
- name: { type: '0x2::object::ID', value: nftTokenId },
112
- });
113
-
114
- if (response.error?.code === 'dynamicFieldNotFound') {
110
+ try {
111
+ const { object } = await suiClient.core.getDynamicObjectField({
112
+ parentId: TRADEPORT_KIOSK_LISTING_STORE,
113
+ name: { type: '0x2::object::ID', bcs: bcs.Address.serialize(nftTokenId).toBytes() },
114
+ include: { content: true },
115
+ });
116
+ commissionFeeAmount = Number(KioskListing.parse(object.content).commission);
117
+ } catch {
115
118
  throw new Error(`Not found kiosk listing object of token ${nftTokenId}`);
116
119
  }
117
-
118
- commissionFeeAmount = Number((response.data?.content as any)?.fields?.commission);
119
120
  }
120
121
 
121
122
  if (commissionFeeAmount === 0) {
@@ -135,7 +136,7 @@ export const addLegacyTradeportKioskBuyTx = async ({
135
136
  arguments: [
136
137
  tx.object(TRADEPORT_KIOSK_LISTING_STORE),
137
138
  tx.object(sellerKiosk),
138
- tx.object('value' in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
139
+ tx.object(kioskTx.kiosk),
139
140
  tx.pure.address(nftTokenId),
140
141
  tx.object(coin),
141
142
  ],
@@ -225,8 +226,8 @@ export async function addKioskTradePortBuyTx({
225
226
  tx.object(TRADEPORT_LISTINGS_STORE),
226
227
  tx.object(TRADEPORT_ORDERBOOK_STORE),
227
228
  tx.object(sellerKiosk),
228
- tx.object('value' in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
229
- tx.object('value' in kioskTx.kioskCap ? kioskTx.kioskCap.value : kioskTx.kioskCap),
229
+ tx.object(kioskTx.kiosk),
230
+ tx.object(kioskTx.kioskCap),
230
231
  tx.pure.address(buyer),
231
232
  tx.pure.id(nftTokenId),
232
233
  tx.object(coin),
@@ -420,7 +421,7 @@ export async function addBluemoveKioskBuyTx({
420
421
  tx.object(BLUEMOVE_KIOSK_MARKETPLACE_KIOSK_OBJECT),
421
422
  tx.object(sellerKiosk),
422
423
  tx.object(transferPolicyId),
423
- tx.object('value' in kioskTx.kiosk ? kioskTx.kiosk.value : kioskTx.kiosk),
424
+ tx.object(kioskTx.kiosk),
424
425
  tx.pure.address(nftTokenId),
425
426
  tx.pure.u64(price),
426
427
  tx.object(coin1),
@@ -676,14 +677,11 @@ export async function addTradePortBuyTxHandler(txData: BuyTx) {
676
677
  // Legacy contract logic below
677
678
  if (txData.listingNonce?.startsWith('0x')) {
678
679
  const response = await txData?.suiClient.getObject({
679
- id: txData.listingNonce,
680
- options: { showType: true },
680
+ objectId: txData.listingNonce,
681
+ include: {},
681
682
  });
682
- if (response.error) {
683
- throw new Error(response.error.code);
684
- }
685
683
 
686
- if (response.data.type === NON_KIOSK_LISTING_NONCE_TYPE) {
684
+ if (response.object.type === NON_KIOSK_LISTING_NONCE_TYPE) {
687
685
  const sharedObjects =
688
686
  txData?.sharedBulkBuyingDataByNftType?.[txData?.nftType]?.sharedObjects ??
689
687
  (await getSharedObjects(txData?.nftType));
@@ -1,5 +1,5 @@
1
1
  import type { KioskClient, KioskTransaction } 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 {
@@ -30,7 +30,7 @@ type BuyTxBase = {
30
30
  tx: Transaction;
31
31
  sharedObjects?: any;
32
32
  transferPolicies: any;
33
- suiClient: SuiClient;
33
+ suiClient: SuiGrpcClient;
34
34
  kioskClient: KioskClient;
35
35
  kioskTx?: any;
36
36
  sharedKioskState?: SharedKioskState;
@@ -12,7 +12,7 @@ export async function addTradeportKioskCancelNftTransferTx({
12
12
  '0x49642273ca7db3d942f9fd810c93467974c40e73ea7f03e8e7a632f1222aca73::kiosk_transfers::cancel_with_purchase_cap',
13
13
  arguments: [
14
14
  tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
15
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
15
+ tx.object(kioskTx.kiosk),
16
16
  tx.pure.address(nftTokenId),
17
17
  ],
18
18
  typeArguments: [nftType],
@@ -59,8 +59,8 @@ export const addClaimAcceptedBidNftTx = async ({
59
59
  arguments: [
60
60
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
61
61
  tx.object(TRADEPORT_KIOSK_BIDDING_ESCROW_KIOSK),
62
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
63
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
62
+ tx.object(kioskTx.kiosk),
63
+ tx.object(kioskTx.kioskCap),
64
64
  tx.pure.address(nftTokenId),
65
65
  tx.object(transferPolicyId),
66
66
  ],
@@ -100,8 +100,8 @@ export const addClaimAcceptedBidNftWithPurchaseCapTx = async ({
100
100
  arguments: [
101
101
  tx.object(TRADEPORT_KIOSK_BIDDING_STORE),
102
102
  tx.object(sellerKiosk),
103
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
104
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
103
+ tx.object(kioskTx.kiosk),
104
+ tx.object(kioskTx.kioskCap),
105
105
  tx.pure.address(nftTokenId),
106
106
  tx.object(transferPolicyId),
107
107
  ],
@@ -140,8 +140,8 @@ export const addClaimTransferredNftTx = async ({
140
140
  arguments: [
141
141
  tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
142
142
  tx.object(TRADEPORT_KIOSK_TRANSFERS_ESCROW_KIOSK),
143
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
144
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
143
+ tx.object(kioskTx.kiosk),
144
+ tx.object(kioskTx.kioskCap),
145
145
  tx.pure.address(nftTokenId),
146
146
  tx.object(transferPolicyId),
147
147
  ],
@@ -237,8 +237,8 @@ export const addBluemoveClaimAcceptedBidNft = async ({
237
237
  tx.object(BLUEMOVE_KIOSK_OFFER_COLLECTION_BIDDER_BAG),
238
238
  tx.object(transferPolicyId),
239
239
  tx.object(sellerKiosk),
240
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
241
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
240
+ tx.object(kioskTx.kiosk),
241
+ tx.object(kioskTx.kioskCap),
242
242
  tx.pure.address(nftTokenId),
243
243
  tx.object(coin),
244
244
  ],
@@ -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 {
@@ -36,7 +36,7 @@ export type ClaimTradeHoldTx = {
36
36
 
37
37
  export type ClaimTransferredNftTx = {
38
38
  tx: Transaction;
39
- suiClient?: SuiClient;
39
+ suiClient?: SuiGrpcClient;
40
40
  kioskTx?: any;
41
41
  kioskClient: KioskClient;
42
42
  sharedKioskState?: SharedKioskState;
@@ -52,7 +52,7 @@ export type ClaimTransferredNftTx = {
52
52
 
53
53
  export type ClaimAcceptedBidNftTx = {
54
54
  tx: Transaction;
55
- suiClient: SuiClient;
55
+ suiClient: SuiGrpcClient;
56
56
  kioskTx?: any;
57
57
  kioskClient: KioskClient;
58
58
  sharedKioskState?: SharedKioskState;
@@ -110,8 +110,8 @@ export async function addKioskTradePortListTx({
110
110
  arguments: [
111
111
  tx.object(TRADEPORT_LISTINGS_STORE),
112
112
  tx.object(TRADEPORT_ORDERBOOK_STORE),
113
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
114
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
113
+ tx.object(kioskTx.kiosk),
114
+ tx.object(kioskTx.kioskCap),
115
115
  tx.pure.address(seller),
116
116
  tx.pure.id(nftTokenId),
117
117
  tx.pure.u64(listPrice),
@@ -8,11 +8,11 @@ import {
8
8
  TRADEPORT_ORDERBOOK_STORE,
9
9
  } from '../../constants';
10
10
  import { addTradePortListTx } from './addListTxs';
11
- import { type SuiClient } from '@mysten/sui/client';
11
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
12
12
 
13
13
  export type RelistNftTx = {
14
14
  tx: Transaction;
15
- suiClient: SuiClient;
15
+ suiClient: SuiGrpcClient;
16
16
  kioskTx?: any;
17
17
  kioskClient: KioskClient;
18
18
  transferPolicies: any;
@@ -51,8 +51,8 @@ export async function addKioskTradePortRelistTx({
51
51
  arguments: [
52
52
  tx.object(TRADEPORT_LISTINGS_STORE),
53
53
  tx.object(TRADEPORT_ORDERBOOK_STORE),
54
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
55
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
54
+ tx.object(kioskTx.kiosk),
55
+ tx.object(kioskTx.kioskCap),
56
56
  tx.pure.id(nftTokenId),
57
57
  tx.pure.u64(listPrice),
58
58
  ],
@@ -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, type TransactionObjectInput } from '@mysten/sui/transactions';
4
4
  import { type RequestContext } from '../../SuiTradingClient';
5
5
  import {
@@ -19,7 +19,7 @@ import { addTradePortListTxHandler } from './addListTxs';
19
19
 
20
20
  export type ListNftTx = {
21
21
  tx: Transaction;
22
- suiClient: SuiClient;
22
+ suiClient: SuiGrpcClient;
23
23
  kioskClient: KioskClient;
24
24
  kioskTx?: any;
25
25
  sharedObjects?: any;
@@ -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 { ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK } from '../../constants';
@@ -16,7 +16,7 @@ import { addOriginByteCollectionBidTx } from './addPlaceCollectionBidTxs';
16
16
 
17
17
  export type PlaceCollectionBidTx = {
18
18
  tx: Transaction;
19
- suiClient: SuiClient;
19
+ suiClient: SuiGrpcClient;
20
20
  kioskClient: KioskClient;
21
21
  sharedObjects?: any;
22
22
  transferPolicies: any;
@@ -1,4 +1,4 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { fromHex, normalizeSuiObjectId } from '@mysten/sui/utils';
3
3
  import {
4
4
  DYNAMIC_COLLECTION_IDS,
@@ -134,22 +134,17 @@ export async function addTradePortPlaceNftBidTxHandler(txData: PlaceNftBidTx) {
134
134
 
135
135
  let bidFeeBps: bigint | undefined;
136
136
 
137
- export async function getBidFeeBps(suiClient: SuiClient) {
137
+ export async function getBidFeeBps(suiClient: SuiGrpcClient) {
138
138
  if (bidFeeBps !== undefined) {
139
139
  return bidFeeBps;
140
140
  }
141
141
 
142
142
  const res = await suiClient.getObject({
143
- id: TRADEPORT_MULTI_BID_STORE,
144
- options: { showContent: true },
143
+ objectId: TRADEPORT_MULTI_BID_STORE,
144
+ include: { json: true },
145
145
  });
146
- if (res.error) {
147
- throw new Error(`Error on getting SUI object ${TRADEPORT_MULTI_BID_STORE}: ${res.error.code}`);
148
- }
149
146
 
150
- bidFeeBps = BigInt(
151
- (res?.data?.content as unknown as { fields: { fee_bps: string } })?.fields?.fee_bps ?? 0,
152
- );
147
+ bidFeeBps = BigInt((res?.object?.json as unknown as { fee_bps: string })?.fee_bps ?? 0);
153
148
 
154
149
  return bidFeeBps;
155
150
  }
@@ -1,4 +1,4 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { Transaction } from '@mysten/sui/transactions';
3
3
  import { type RequestContext } from '../../SuiTradingClient';
4
4
  import {
@@ -12,7 +12,7 @@ import { addTradePortPlaceNftBidTxHandler } from './addPlaceNftBidTxs';
12
12
 
13
13
  export type PlaceNftBidTx = {
14
14
  tx: Transaction;
15
- suiClient: SuiClient;
15
+ suiClient: SuiGrpcClient;
16
16
  bidder: string;
17
17
  collectionId: string;
18
18
  nftTokenId?: string;
@@ -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 { type Transaction } from '@mysten/sui/transactions';
4
4
  import { ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK } from '../../constants';
5
5
  import { getNftType } from '../../helpers/getNftType';
@@ -24,7 +24,7 @@ import { type SharedKioskState } from '../../helpers/kiosk/sharedKioskState.type
24
24
 
25
25
  interface Args {
26
26
  tx: Transaction;
27
- suiClient: SuiClient;
27
+ suiClient: SuiGrpcClient;
28
28
  kioskClient: KioskClient;
29
29
  sharedKioskState: SharedKioskState;
30
30
  transferPolicies: any;
@@ -1,4 +1,4 @@
1
- import type { SuiClient } from '@mysten/sui/client';
1
+ import type { SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { Transaction } from '@mysten/sui/transactions';
3
3
  import { type RequestContext } from '../../SuiTradingClient';
4
4
  import {
@@ -17,7 +17,7 @@ import {
17
17
 
18
18
  export type RemoveCollectionBidTx = {
19
19
  tx: Transaction;
20
- suiClient: SuiClient;
20
+ suiClient: SuiGrpcClient;
21
21
  sharedObjects?: any;
22
22
  bidNonce: string;
23
23
  bidder: string;
@@ -1,4 +1,4 @@
1
- import type { SuiClient } from '@mysten/sui/client';
1
+ import type { SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { Transaction } from '@mysten/sui/transactions';
3
3
  import { type RequestContext } from '../../SuiTradingClient';
4
4
  import {
@@ -17,7 +17,7 @@ import {
17
17
 
18
18
  export type RemoveNftBidTx = {
19
19
  tx: Transaction;
20
- suiClient: SuiClient;
20
+ suiClient: SuiGrpcClient;
21
21
  sharedObjects?: any;
22
22
  bidNonce: string;
23
23
  nftType: string;
@@ -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 { type Transaction } from '@mysten/sui/transactions';
4
4
  import {
5
5
  MYSTEN_TRANSFER_POLICY_RULES_PACKAGE_ID,
@@ -88,8 +88,8 @@ export async function addTradeportKioskTransferTx({
88
88
  '0x49642273ca7db3d942f9fd810c93467974c40e73ea7f03e8e7a632f1222aca73::kiosk_transfers::transfer_with_purchase_capability',
89
89
  arguments: [
90
90
  tx.object(TRADEPORT_KIOSK_TRANSFERS_STORE),
91
- tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
92
- tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
91
+ tx.object(kioskTx.kiosk),
92
+ tx.object(kioskTx.kioskCap),
93
93
  tx.pure.address(nftTokenId),
94
94
  tx.pure.address(addLeadingZerosAfter0x(recipientAddress)),
95
95
  ],
@@ -106,7 +106,7 @@ export async function addTradeportKioskDirectTransferTx(
106
106
  sharedKioskState?: SharedKioskState;
107
107
  },
108
108
  nfts: any[],
109
- suiClient: SuiClient,
109
+ suiClient: SuiGrpcClient,
110
110
  ) {
111
111
  const { tx, recipientAddress, kioskClient, sharedKioskState, senderAddress } = txData;
112
112
  if (nfts.length === 0) {
@@ -128,7 +128,16 @@ export async function addTradeportKioskDirectTransferTx(
128
128
  );
129
129
 
130
130
  const totalRoyaltyAmount = royaltyAmounts.reduce((sum: bigint, amount) => sum + amount, 0n);
131
- const [royaltyCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(totalRoyaltyAmount)]);
131
+ // When no royalty is due, avoid touching the gas coin: sponsored transactions
132
+ // (e.g. Enoki) reject any PTB that uses GasCoin as an argument.
133
+ const [royaltyCoin] =
134
+ totalRoyaltyAmount === 0n
135
+ ? tx.moveCall({
136
+ target: '0x2::coin::zero',
137
+ arguments: [],
138
+ typeArguments: ['0x2::sui::SUI'],
139
+ })
140
+ : tx.splitCoins(tx.gas, [tx.pure.u64(totalRoyaltyAmount)]);
132
141
  for (const nft of nfts) {
133
142
  const nftType = getNftType({
134
143
  collectionId: nft?.collection?.id,
@@ -165,7 +174,7 @@ export async function addTradeportKioskDirectTransferTx(
165
174
  }
166
175
 
167
176
  export async function canBeTransferedDirectly(
168
- suiClient: SuiClient,
177
+ suiClient: SuiGrpcClient,
169
178
  collectionChainState?: CollectionChainState,
170
179
  ) {
171
180
  return (
@@ -174,7 +183,7 @@ export async function canBeTransferedDirectly(
174
183
  }
175
184
 
176
185
  export async function getTransferPolicyForDirectTransfer(
177
- suiClient: SuiClient,
186
+ suiClient: SuiGrpcClient,
178
187
  collectionChainState?: CollectionChainState,
179
188
  validateRules = false,
180
189
  ): Promise<TransferPolicy | undefined> {
@@ -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 {
@@ -35,7 +35,7 @@ export type TransferNftTx = {
35
35
  transferPolicies: any;
36
36
  kioskTx?: any;
37
37
  transferPolicy?: any;
38
- suiClient: SuiClient;
38
+ suiClient: SuiGrpcClient;
39
39
  };
40
40
 
41
41
  export type TransferNfts = {