@tradeport/sui-trading-sdk 0.4.66 → 0.5.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 (56) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/jest.config.js +6 -2
  3. package/package.json +66 -65
  4. package/src/SuiTradingClient.ts +24 -14
  5. package/src/apiClients/createKioskClient.ts +5 -6
  6. package/src/apiClients/createSuiClient.ts +2 -2
  7. package/src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts +9 -21
  8. package/src/helpers/isNonKioskListing.ts +2 -2
  9. package/src/helpers/kiosk/getKioskCollectionRoyaltyFeeAmount.ts +10 -10
  10. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +15 -7
  11. package/src/helpers/kiosk/getKioskPlaceBidCoin.ts +2 -2
  12. package/src/helpers/kiosk/getRulePackageId.ts +2 -2
  13. package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +2 -2
  14. package/src/helpers/kiosk/kioskListingBcs.ts +19 -0
  15. package/src/helpers/kiosk/kioskTxWrapper.ts +3 -3
  16. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +9 -9
  17. package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +33 -21
  18. package/src/helpers/kiosk/resolveRoyaltyRule.ts +2 -2
  19. package/src/helpers/kiosk/resolveTransferPolicies.ts +2 -2
  20. package/src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts +2 -2
  21. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +5 -9
  22. package/src/helpers/originByte/getOBBidderKiosk.ts +4 -7
  23. package/src/helpers/rpc/getAcountBalance.ts +3 -3
  24. package/src/helpers/rpc/getObjectType.ts +8 -4
  25. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +2 -2
  26. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +3 -3
  27. package/src/methods/acceptNftBids/acceptNftBids.ts +2 -2
  28. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +4 -4
  29. package/src/methods/buyListings/addBuyListingTxs.ts +16 -18
  30. package/src/methods/buyListings/buyListings.ts +2 -2
  31. package/src/methods/cancelNftTransfers/addCancelNftTransfersTx.ts +1 -1
  32. package/src/methods/claimNfts/addClaimNftsTxs.ts +8 -8
  33. package/src/methods/claimNfts/claimNfts.ts +3 -3
  34. package/src/methods/listNfts/addListTxs.ts +2 -2
  35. package/src/methods/listNfts/addRelistTxs.ts +4 -4
  36. package/src/methods/listNfts/listNfts.ts +2 -2
  37. package/src/methods/placeCollectionBids/placeCollectionBids.ts +2 -2
  38. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +5 -10
  39. package/src/methods/placeNftBids/placeNftBids.ts +2 -2
  40. package/src/methods/relistNft/relistNft.ts +2 -2
  41. package/src/methods/removeCollectionBids/removeCollectionBids.ts +2 -2
  42. package/src/methods/removeNftBids/removeNftBids.ts +2 -2
  43. package/src/methods/transferNfts/addTransferNftTx.ts +16 -7
  44. package/src/methods/transferNfts/transferNfts.ts +2 -2
  45. package/src/methods/unlistListings/addUnlistListingTxs.ts +6 -10
  46. package/src/methods/unlistListings/unlistListings.ts +2 -2
  47. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +2 -2
  48. package/src/tests/SuiWallet.ts +19 -15
  49. package/tsconfig.json +2 -1
  50. package/.claude/settings.local.json +0 -5
  51. package/dist/index.d.mts +0 -193
  52. package/dist/index.d.ts +0 -193
  53. package/dist/index.js +0 -7400
  54. package/dist/index.js.map +0 -1
  55. package/dist/index.mjs +0 -7375
  56. package/dist/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.4.67
4
+
5
+ ### Patch Changes
6
+
7
+ - e26b647: transferNfts: don't split the gas coin when no royalty is due in the direct-transfer path. Use `0x2::coin::zero` instead, so the transaction contains no GasCoin argument and can be sponsored (Enoki rejects PTBs that reference GasCoin with "Cannot use GasCoin as a transaction argument").
8
+
3
9
  ## 0.4.17
4
10
 
5
11
  ### Patch Changes
package/jest.config.js CHANGED
@@ -1,7 +1,11 @@
1
1
  /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- module.exports = {
3
- preset: 'ts-jest',
2
+ export default {
3
+ preset: 'ts-jest/presets/default-esm',
4
4
  testEnvironment: 'node',
5
+ extensionsToTreatAsEsm: ['.ts'],
6
+ moduleNameMapper: {
7
+ '^(\\.{1,2}/.*)\\.js$': '$1',
8
+ },
5
9
  verbose: true,
6
10
  testTimeout: 1800000,
7
11
  setupFiles: ['dotenv/config'],
package/package.json CHANGED
@@ -1,66 +1,67 @@
1
1
  {
2
- "name": "@tradeport/sui-trading-sdk",
3
- "license": "MIT",
4
- "version": "0.4.66",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "build": "tsup src/index.ts --sourcemap --format cjs,esm --dts",
10
- "release": "pnpm run build && changeset publish",
11
- "lint": "tsc && eslint --fix src/* --ignore-path .gitignore --ext .js,.ts",
12
- "format": "prettier --write \"**/*.+(js|ts|json)\"",
13
- "test": "jest",
14
- "prepare": "husky install",
15
- "pre-commit": "lint-staged"
16
- },
17
- "devDependencies": {
18
- "@babel/core": "^7.23.3",
19
- "@babel/preset-env": "^7.23.3",
20
- "@changesets/cli": "^2.26.2",
21
- "@types/jest": "^29.5.10",
22
- "@types/ms": "^2.1.0",
23
- "@types/node": "^20.10.0",
24
- "@typescript-eslint/eslint-plugin": "^6.13.1",
25
- "@typescript-eslint/parser": "^6.13.1",
26
- "babel-jest": "^29.7.0",
27
- "dotenv": "^16.3.1",
28
- "eslint": "^8.54.0",
29
- "eslint-config-prettier": "^9.0.0",
30
- "eslint-config-xo": "^0.43.1",
31
- "eslint-config-xo-typescript": "^1.0.1",
32
- "husky": "^8.0.0",
33
- "jest": "^29.7.0",
34
- "lint-staged": "^16.2.7",
35
- "prettier": "^3.1.0",
36
- "ts-jest": "^29.1.1",
37
- "tsup": "^8.0.1",
38
- "typescript": "^5.3.2"
39
- },
40
- "dependencies": {
41
- "@mysten/kiosk": "^0.7.13",
42
- "@mysten/sui": "^1.17.0",
43
- "@types/analytics-node": "^3.1.14",
44
- "analytics-node": "^6.2.0",
45
- "bignumber.js": "^9.3.1",
46
- "graphql": "^16.12.0",
47
- "graphql-request": "^6.1.0",
48
- "ms": "^2.1.3"
49
- },
50
- "publishConfig": {
51
- "access": "public",
52
- "registry": "https://registry.npmjs.org/"
53
- },
54
- "lint-staged": {
55
- "*.ts": [
56
- "eslint --fix",
57
- "bash -c 'tsc --noEmit'",
58
- "prettier --write"
59
- ]
60
- },
61
- "pnpm": {
62
- "overrides": {
63
- "@mysten/sui": "^1.45.2"
64
- }
65
- }
66
- }
2
+ "name": "@tradeport/sui-trading-sdk",
3
+ "license": "MIT",
4
+ "version": "0.5.0",
5
+ "type": "module",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "devDependencies": {
16
+ "@babel/core": "^7.23.3",
17
+ "@babel/preset-env": "^7.23.3",
18
+ "@changesets/cli": "^2.26.2",
19
+ "@types/jest": "^29.5.10",
20
+ "@types/ms": "^2.1.0",
21
+ "@types/node": "^20.10.0",
22
+ "@typescript-eslint/eslint-plugin": "^6.13.1",
23
+ "@typescript-eslint/parser": "^6.13.1",
24
+ "babel-jest": "^29.7.0",
25
+ "dotenv": "^16.3.1",
26
+ "eslint": "^8.54.0",
27
+ "eslint-config-prettier": "^9.0.0",
28
+ "eslint-config-xo": "^0.43.1",
29
+ "eslint-config-xo-typescript": "^1.0.1",
30
+ "husky": "^8.0.0",
31
+ "jest": "^29.7.0",
32
+ "lint-staged": "^16.2.7",
33
+ "prettier": "^3.1.0",
34
+ "ts-jest": "^29.1.1",
35
+ "tsup": "^8.0.1",
36
+ "typescript": "^5.3.2"
37
+ },
38
+ "dependencies": {
39
+ "@mysten/kiosk": "^1.3.1",
40
+ "@mysten/sui": "^2.20.0",
41
+ "@types/analytics-node": "^3.1.14",
42
+ "analytics-node": "^6.2.0",
43
+ "bignumber.js": "^9.3.1",
44
+ "graphql": "^16.12.0",
45
+ "graphql-request": "^6.1.0",
46
+ "ms": "^2.1.3"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public",
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "lint-staged": {
53
+ "*.ts": [
54
+ "eslint --fix",
55
+ "bash -c 'tsc --noEmit'",
56
+ "prettier --write"
57
+ ]
58
+ },
59
+ "scripts": {
60
+ "build": "tsup src/index.ts --sourcemap --format esm --dts",
61
+ "release": "pnpm run build && changeset publish",
62
+ "lint": "tsc && eslint --fix src/* --ignore-path .gitignore --ext .js,.ts",
63
+ "format": "prettier --write \"**/*.+(js|ts|json)\"",
64
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
65
+ "pre-commit": "lint-staged"
66
+ }
67
+ }
@@ -1,4 +1,3 @@
1
- import { getFullnodeUrl } from '@mysten/sui/client';
2
1
  import { type Transaction } from '@mysten/sui/transactions';
3
2
  import { GraphQLClient } from 'graphql-request';
4
3
  import createKioskClient from './apiClients/createKioskClient';
@@ -53,6 +52,9 @@ import {
53
52
  } from './methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks';
54
53
  import { addLeadingZerosAfter0x } from './utils/addLeadingZerosAfter0x';
55
54
 
55
+ const DEFAULT_SUI_GRPC_URL = 'https://fullnode.mainnet.sui.io:443';
56
+ const DEFAULT_SUI_GRAPHQL_URL = 'https://graphql.mainnet.sui.io/';
57
+
56
58
  type ApiConfig = {
57
59
  apiUser: string;
58
60
  apiKey: string;
@@ -60,6 +62,7 @@ type ApiConfig = {
60
62
  tradeportRouterUrl?: string;
61
63
  apiVercelId?: string;
62
64
  suiNodeUrl?: string;
65
+ suiGraphqlUrl?: string;
63
66
  graphQLClient?: GraphQLClient;
64
67
  };
65
68
  export interface RequestContext {
@@ -85,13 +88,14 @@ class SuiTradingClient {
85
88
  apiUrl,
86
89
  tradeportRouterUrl,
87
90
  suiNodeUrl,
91
+ suiGraphqlUrl,
88
92
  graphQLClient,
89
93
  }: ApiConfig) {
90
94
  this.apiUser = apiUser;
91
95
  this.apiKey = apiKey;
92
96
  this.tradeportRouterUrl = tradeportRouterUrl;
93
- this.suiClient = createSuiClient(suiNodeUrl ?? getFullnodeUrl('mainnet'));
94
- this.kioskClient = createKioskClient(this.suiClient);
97
+ this.suiClient = createSuiClient(suiNodeUrl ?? DEFAULT_SUI_GRPC_URL);
98
+ this.kioskClient = createKioskClient(suiGraphqlUrl ?? DEFAULT_SUI_GRAPHQL_URL);
95
99
 
96
100
  if (graphQLClient) {
97
101
  setGraphqlClient(graphQLClient);
@@ -269,12 +273,13 @@ class SuiTradingClient {
269
273
  context,
270
274
  );
271
275
 
272
- let result = await this.suiClient.devInspectTransactionBlock({
273
- transactionBlock: tx,
274
- sender: addLeadingZerosAfter0x(walletAddress),
276
+ tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
277
+ let result = await this.suiClient.simulateTransaction({
278
+ transaction: tx,
279
+ include: { effects: true },
275
280
  });
276
281
 
277
- if (result.effects.status.status === 'success') {
282
+ if (result.$kind === 'Transaction') {
278
283
  return tx;
279
284
  }
280
285
 
@@ -291,18 +296,23 @@ class SuiTradingClient {
291
296
  context,
292
297
  );
293
298
 
294
- result = await this.suiClient.devInspectTransactionBlock({
295
- transactionBlock: tx,
296
- sender: addLeadingZerosAfter0x(walletAddress),
299
+ tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
300
+ result = await this.suiClient.simulateTransaction({
301
+ transaction: tx,
302
+ include: { effects: true },
297
303
  });
298
304
 
299
- if (result?.effects.status.status === 'success') {
305
+ if (result?.$kind === 'Transaction') {
300
306
  return tx;
301
307
  }
302
308
  }
303
309
 
304
310
  throw new Error(
305
- `Failed to validate accept bid transaction: ${result?.error ?? result?.effects?.status?.error ?? 'Unknown error'}`,
311
+ `Failed to validate accept bid transaction: ${
312
+ result?.FailedTransaction?.status?.error
313
+ ? JSON.stringify(result.FailedTransaction.status.error)
314
+ : 'Unknown error'
315
+ }`,
306
316
  );
307
317
  }
308
318
  }
@@ -364,8 +374,8 @@ class SuiTradingClient {
364
374
 
365
375
  tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
366
376
  const rawTransaction = await tx.build({ client: this.suiClient });
367
- await this.suiClient.dryRunTransactionBlock({
368
- transactionBlock: rawTransaction,
377
+ await this.suiClient.simulateTransaction({
378
+ transaction: rawTransaction,
369
379
  });
370
380
  return tx;
371
381
  } catch (err) {
@@ -1,11 +1,10 @@
1
- import { KioskClient, Network } from '@mysten/kiosk';
2
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { KioskClient } from '@mysten/kiosk';
2
+ import { SuiGraphQLClient } from '@mysten/sui/graphql';
3
3
 
4
- const createKioskClient = (suiClient: SuiClient) =>
4
+ const createKioskClient = (graphqlUrl: string) =>
5
5
  new KioskClient({
6
- // @ts-ignore
7
- client: suiClient,
8
- network: Network.MAINNET,
6
+ client: new SuiGraphQLClient({ url: graphqlUrl, network: 'mainnet' }),
7
+ network: 'mainnet',
9
8
  });
10
9
 
11
10
  export default createKioskClient;
@@ -1,5 +1,5 @@
1
- import { SuiClient } from '@mysten/sui/client';
1
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
2
2
 
3
- const createSuiClient = (url: string) => new SuiClient({ url });
3
+ const createSuiClient = (baseUrl: string) => new SuiGrpcClient({ network: 'mainnet', baseUrl });
4
4
 
5
5
  export default createSuiClient;
@@ -1,36 +1,24 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { normalizeStructTag, normalizeSuiObjectId } from '@mysten/sui/utils';
3
3
 
4
4
  export const getTransferPolicyRuleNamesFromSuiObject = async ({
5
5
  suiClient,
6
6
  transferPolicyId,
7
7
  }: {
8
- suiClient: SuiClient;
8
+ suiClient: SuiGrpcClient;
9
9
  transferPolicyId: string;
10
10
  }) => {
11
- const { data, error } = await suiClient.getObject({
12
- id: normalizeSuiObjectId(transferPolicyId),
13
- options: {
14
- showContent: true,
15
- },
11
+ const { object } = await suiClient.getObject({
12
+ objectId: normalizeSuiObjectId(transferPolicyId),
13
+ include: { json: true },
16
14
  });
17
15
 
18
- if (error) {
19
- throw new Error(`Error on getting SUI object ${transferPolicyId}: ${error.code}`);
20
- }
21
-
22
- const content = data.content as unknown as {
23
- fields: {
24
- rules: {
25
- fields: {
26
- contents: Array<{ fields: { name: string } }>;
27
- };
28
- };
16
+ const content = object.json as unknown as {
17
+ rules: {
18
+ contents: string[];
29
19
  };
30
20
  };
31
- const ruleNames = content.fields.rules.fields.contents.map((rule) =>
32
- normalizeStructTag(rule.fields.name),
33
- );
21
+ const ruleNames = content.rules.contents.map((rule) => normalizeStructTag(rule));
34
22
 
35
23
  return ruleNames;
36
24
  };
@@ -1,4 +1,4 @@
1
- import { type SuiClient } from '@mysten/sui/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { NON_KIOSK_LISTING_NONCE_TYPE } from '../constants';
3
3
  import { getObjectType } from './rpc/getObjectType';
4
4
 
@@ -6,7 +6,7 @@ export const isNonKioskListing = async ({
6
6
  suiClient,
7
7
  listingNonce,
8
8
  }: {
9
- suiClient: SuiClient;
9
+ suiClient: SuiGrpcClient;
10
10
  listingNonce: string;
11
11
  }): Promise<boolean> => {
12
12
  const listingType = await getObjectType({ suiClient, objectId: listingNonce });
@@ -1,5 +1,5 @@
1
1
  import { bcs } from '@mysten/sui/bcs';
2
- import { type SuiClient } from '@mysten/sui/client';
2
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import {
4
4
  Transaction,
5
5
  type TransactionArgument,
@@ -9,7 +9,7 @@ import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
9
9
 
10
10
  interface Args {
11
11
  tx: Transaction;
12
- suiClient: SuiClient;
12
+ suiClient: SuiGrpcClient;
13
13
  walletAddress: string;
14
14
  royaltyRulePackageId: string;
15
15
  royaltyRuleModule: string;
@@ -45,17 +45,17 @@ export async function getKioskCollectionRoyaltyFeeAmount({
45
45
  typeArguments: [nftType],
46
46
  });
47
47
 
48
- const res = await suiClient.devInspectTransactionBlock({
49
- sender: addLeadingZerosAfter0x(walletAddress),
50
- transactionBlock: feeTx,
48
+ feeTx.setSender(addLeadingZerosAfter0x(walletAddress));
49
+ const res = await suiClient.simulateTransaction({
50
+ transaction: feeTx,
51
+ include: { commandResults: true },
52
+ checksEnabled: false,
51
53
  });
52
54
 
53
55
  let feeAmount: TransactionArgument | bigint | undefined;
54
- if (res?.results?.[0]?.returnValues?.[0]?.[0]) {
55
- const returnedAmount = res?.results?.[0]?.returnValues?.[0]?.[0];
56
- if (returnedAmount) {
57
- feeAmount = BigInt(bcs.U64.parse(new Uint8Array(returnedAmount)));
58
- }
56
+ const returnedAmount = res?.commandResults?.[0]?.returnValues?.[0]?.bcs;
57
+ if (returnedAmount) {
58
+ feeAmount = BigInt(bcs.U64.parse(returnedAmount));
59
59
  }
60
60
 
61
61
  // We were not able to calculate the amount outside of the transaction, so fall back to resolving it within the PTB
@@ -8,14 +8,22 @@ export const getKioskIdFromKioskTx = ({
8
8
  kioskTx: KioskTransaction;
9
9
  tx: Transaction;
10
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];
11
18
  const kioskId =
12
- 'value' in kioskTx.kiosk
13
- ? kioskTx.kiosk.value
14
- : 'Input' in kioskTx.kiosk
15
- ? tx.blockData.inputs[(kioskTx.kiosk as { Input: number }).Input].value
16
- : (() => {
17
- throw new Error('Invalid kiosk transaction structure');
18
- })();
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
+ }
19
27
 
20
28
  return kioskId;
21
29
  };
@@ -1,4 +1,4 @@
1
- import { type SuiClient } from '@mysten/sui/dist/cjs/client';
1
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
2
2
  import { type Transaction } from '@mysten/sui/transactions';
3
3
  import { splitCoins } from '../splitCoins';
4
4
  import { getKioskCollectionRoyaltyFeeAmount } from './getKioskCollectionRoyaltyFeeAmount';
@@ -15,7 +15,7 @@ export async function getKioskPlaceBidCoin({
15
15
  transferPolicyId,
16
16
  }: {
17
17
  tx: Transaction;
18
- suiClient: SuiClient;
18
+ suiClient: SuiGrpcClient;
19
19
  bidder: string;
20
20
  nftType: string;
21
21
  bidAmount: number;
@@ -1,5 +1,5 @@
1
1
  import { getNormalizedRuleType, type KioskClient } from '@mysten/kiosk';
2
- import { type SuiClient } from '@mysten/sui/client';
2
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { addHexPrefix } from '../../utils/addHexPrefix';
4
4
  import { normalizedNftType } from '../../utils/normalizeNftType';
5
5
  import { getTransferPolicyRuleNamesFromSuiObject } from '../getTransferPolicyRuleNamesFromSuiObject';
@@ -16,7 +16,7 @@ export const getRulePackageId = async ({
16
16
  suiClient,
17
17
  }: {
18
18
  transferPolicies: any[];
19
- suiClient: SuiClient;
19
+ suiClient: SuiGrpcClient;
20
20
  nftType: string;
21
21
  ruleType: RuleType;
22
22
  kioskClient: KioskClient;
@@ -1,5 +1,5 @@
1
1
  import { getNormalizedRuleType, type KioskClient } from '@mysten/kiosk';
2
- import { type SuiClient } from '@mysten/sui/client';
2
+ import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { normalizedNftType } from '../../utils/normalizeNftType';
4
4
  import { getTransferPolicyRuleNamesFromSuiObject } from '../getTransferPolicyRuleNamesFromSuiObject';
5
5
  import {
@@ -23,7 +23,7 @@ export type Policy = {
23
23
 
24
24
  type Props = {
25
25
  transferPolicies: any[];
26
- suiClient: SuiClient;
26
+ suiClient: SuiGrpcClient;
27
27
  kioskClient: KioskClient;
28
28
  nftType: string;
29
29
  customTransferPolicies?: any;
@@ -0,0 +1,19 @@
1
+ import { bcs } from '@mysten/sui/bcs';
2
+
3
+ const PurchaseCap = bcs.struct('PurchaseCap', {
4
+ id: bcs.Address,
5
+ kiosk_id: bcs.Address,
6
+ item_id: bcs.Address,
7
+ min_price: bcs.u64(),
8
+ });
9
+
10
+ export const KioskListing = bcs.struct('KioskListing', {
11
+ id: bcs.Address,
12
+ seller: bcs.Address,
13
+ kiosk_id: bcs.Address,
14
+ nft_id: bcs.Address,
15
+ cap: PurchaseCap,
16
+ price: bcs.u64(),
17
+ commission: bcs.u64(),
18
+ beneficiary: bcs.Address,
19
+ });
@@ -105,7 +105,7 @@ export const kioskTxWrapper = async ({
105
105
  })
106
106
  ).personalCap.id;
107
107
  kioskTx = new KioskTransaction({
108
- transactionBlock: tx as any,
108
+ transaction: tx,
109
109
  kioskClient,
110
110
  cap: {
111
111
  isPersonal: true,
@@ -124,7 +124,7 @@ export const kioskTxWrapper = async ({
124
124
  })
125
125
  ).ownerCap?.id;
126
126
  kioskTx = new KioskTransaction({
127
- transactionBlock: tx as any,
127
+ transaction: tx,
128
128
  kioskClient,
129
129
  cap: {
130
130
  isPersonal: false,
@@ -136,7 +136,7 @@ export const kioskTxWrapper = async ({
136
136
  });
137
137
  } else {
138
138
  // creating new personal kiosk
139
- kioskTx = new KioskTransaction({ transactionBlock: tx as any, kioskClient });
139
+ kioskTx = new KioskTransaction({ transaction: tx, kioskClient });
140
140
  kioskTx.createPersonal(true);
141
141
  }
142
142
 
@@ -29,11 +29,11 @@ export const lockNftInsideKioskIfNotLocked = async ({
29
29
  let takeFromKiosk = true;
30
30
 
31
31
  if (!nftInKiosk) {
32
- const result = (await kioskClient.client.getObject({
33
- id: nftTokenId,
34
- options: { showOwner: true },
35
- })) as { data: { owner: { AddressOwner?: string } } };
36
- if (result.data.owner.AddressOwner) {
32
+ const { object } = await (kioskClient.client as any).getObject({
33
+ objectId: nftTokenId,
34
+ include: {},
35
+ });
36
+ if (object?.owner?.$kind === 'AddressOwner') {
37
37
  // NFT is owned by account
38
38
  takeFromKiosk = false;
39
39
  } else {
@@ -50,11 +50,11 @@ export const lockNftInsideKioskIfNotLocked = async ({
50
50
  itemType: nftType,
51
51
  });
52
52
 
53
- takenNftId = 'value' in takenNft ? takenNft.value : takenNft;
53
+ takenNftId = (takenNft as any).value ?? takenNft;
54
54
  }
55
55
 
56
56
  kioskTx.lock({
57
- itemId: takenNftId ?? nftTokenId,
57
+ item: takenNftId ?? nftTokenId,
58
58
  itemType: nftType,
59
59
  policy: transferPolicyId,
60
60
  });
@@ -75,7 +75,7 @@ function lockNftInsideKioskIfKioskCreatedInThisTx({
75
75
  transferPolicyId: string;
76
76
  }) {
77
77
  if (Array.isArray(kioskTx.kiosk.NestedResult)) {
78
- const transaction = tx.blockData.transactions[kioskTx.kiosk.NestedResult[0]] as {
78
+ const transaction = (tx as any).getData().commands[kioskTx.kiosk.NestedResult[0]] as {
79
79
  target: string;
80
80
  };
81
81
  if (
@@ -86,7 +86,7 @@ function lockNftInsideKioskIfKioskCreatedInThisTx({
86
86
  ) {
87
87
  // just created in this transaction block kiosk
88
88
  kioskTx.lock({
89
- itemId: nftTokenId,
89
+ item: nftTokenId,
90
90
  itemType: nftType,
91
91
  policy: transferPolicyId,
92
92
  });