@mysten/kiosk 0.5.3 → 0.7.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 (44) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -287
  3. package/dist/client/kiosk-client.d.ts +64 -0
  4. package/dist/client/kiosk-transaction.d.ts +207 -0
  5. package/dist/client/tp-transaction.d.ts +112 -0
  6. package/dist/constants.d.ts +30 -4
  7. package/dist/index.d.ts +3 -6
  8. package/dist/index.js +1247 -257
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +1230 -223
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/query/kiosk.d.ts +2 -1
  13. package/dist/query/transfer-policy.d.ts +17 -1
  14. package/dist/tx/kiosk.d.ts +7 -23
  15. package/dist/tx/personal-kiosk.d.ts +7 -0
  16. package/dist/tx/rules/attach.d.ts +7 -0
  17. package/dist/tx/rules/resolve.d.ts +15 -0
  18. package/dist/tx/transfer-policy.d.ts +13 -16
  19. package/dist/types/index.d.ts +22 -4
  20. package/dist/types/kiosk.d.ts +30 -1
  21. package/dist/types/transfer-policy.d.ts +27 -1
  22. package/dist/utils.d.ts +32 -18
  23. package/package.json +12 -4
  24. package/src/bcs.ts +1 -0
  25. package/src/client/kiosk-client.ts +156 -0
  26. package/src/client/kiosk-transaction.ts +512 -0
  27. package/src/client/tp-transaction.ts +350 -0
  28. package/src/constants.ts +113 -6
  29. package/src/index.ts +3 -6
  30. package/src/query/kiosk.ts +51 -18
  31. package/src/query/transfer-policy.ts +82 -2
  32. package/src/tx/kiosk.ts +18 -146
  33. package/src/tx/personal-kiosk.ts +35 -0
  34. package/src/tx/rules/attach.ts +74 -0
  35. package/src/tx/rules/resolve.ts +87 -0
  36. package/src/tx/transfer-policy.ts +40 -78
  37. package/src/types/index.ts +25 -4
  38. package/src/types/kiosk.ts +26 -1
  39. package/src/types/transfer-policy.ts +35 -1
  40. package/src/utils.ts +141 -33
  41. package/dist/tx/rules.d.ts +0 -19
  42. package/dist/types/env.d.ts +0 -12
  43. package/src/tx/rules.ts +0 -58
  44. package/src/types/env.ts +0 -20
@@ -0,0 +1,350 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { TransactionArgument, type TransactionBlock } from '@mysten/sui.js/transactions';
5
+
6
+ import {
7
+ attachFloorPriceRuleTx,
8
+ attachKioskLockRuleTx,
9
+ attachPersonalKioskRuleTx,
10
+ attachRoyaltyRuleTx,
11
+ } from '../tx/rules/attach';
12
+ import {
13
+ createTransferPolicy,
14
+ createTransferPolicyWithoutSharing,
15
+ removeTransferPolicyRule,
16
+ shareTransferPolicy,
17
+ withdrawFromPolicy,
18
+ } from '../tx/transfer-policy';
19
+ import { TransferPolicyCap, type ObjectArgument } from '../types';
20
+ import { KioskClient } from './kiosk-client';
21
+
22
+ export type TransferPolicyBaseParams = {
23
+ type: string;
24
+ publisher: ObjectArgument;
25
+ skipCheck?: boolean;
26
+ };
27
+
28
+ export type TransferPolicyTransactionParams = {
29
+ kioskClient: KioskClient;
30
+ transactionBlock: TransactionBlock;
31
+ cap?: TransferPolicyCap;
32
+ };
33
+
34
+ export class TransferPolicyTransaction {
35
+ transactionBlock: TransactionBlock;
36
+ kioskClient: KioskClient;
37
+ policy?: ObjectArgument;
38
+ policyCap?: ObjectArgument;
39
+ type?: string;
40
+
41
+ constructor({ kioskClient, transactionBlock, cap }: TransferPolicyTransactionParams) {
42
+ this.kioskClient = kioskClient;
43
+ this.transactionBlock = transactionBlock;
44
+ if (cap) this.setCap(cap);
45
+ }
46
+
47
+ /**
48
+ * A function to create a new transfer policy.
49
+ * Checks if there's already an existing transfer policy to prevent
50
+ * double transfer polciy mistakes.
51
+ * There's an optional `skipCheck` flag that will just create the policy
52
+ * without checking
53
+ *
54
+ * @param type The Type (`T`) for which we're creating the transfer policy.
55
+ * @param publisher The Publisher Object Id.
56
+ * @param address Address to save the `TransferPolicyCap` object to.
57
+ * @param skipCheck (Optional) skip checking if a transfer policy already exists
58
+ */
59
+ async createAndShare({
60
+ type,
61
+ publisher,
62
+ address,
63
+ skipCheck,
64
+ }: TransferPolicyBaseParams & {
65
+ address: string;
66
+ }) {
67
+ if (!skipCheck) {
68
+ const policies = await this.kioskClient.getTransferPolicies({ type });
69
+ if (policies.length > 0) throw new Error("There's already transfer policy for this Type.");
70
+ }
71
+ const cap = createTransferPolicy(this.transactionBlock, type, publisher);
72
+ this.transactionBlock.transferObjects([cap], this.transactionBlock.pure(address, 'address'));
73
+ }
74
+
75
+ /**
76
+ * A convenient function to create a Transfer Policy and attach some rules
77
+ * before sharing it (so you can prepare it in a single PTB)
78
+ * @param type The Type (`T`) for which we're creating the transfer policy.
79
+ * @param publisher The Publisher Object Id.
80
+ * @param address Address to save the `TransferPolicyCap` object to.
81
+ * @param skipCheck (Optional) skip checking if a transfer policy already exists
82
+ */
83
+ async create({
84
+ type,
85
+ publisher,
86
+ skipCheck,
87
+ }: TransferPolicyBaseParams): Promise<TransferPolicyTransaction> {
88
+ if (!skipCheck) {
89
+ const policies = await this.kioskClient.getTransferPolicies({ type });
90
+ if (policies.length > 0) throw new Error("There's already transfer policy for this Type.");
91
+ }
92
+ const [policy, policyCap] = createTransferPolicyWithoutSharing(
93
+ this.transactionBlock,
94
+ type,
95
+ publisher,
96
+ );
97
+
98
+ this.#setup(policy, policyCap, type); // sets the client's TP to the newly created one.
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * This can be called after calling the `create` function to share the `TransferPolicy`,
104
+ * and transfer the `TransferPolicyCap` to the specified address
105
+ *
106
+ * @param address The address to transfer the `TransferPolicyCap`
107
+ */
108
+ shareAndTransferCap(address: string) {
109
+ if (!this.type || !this.policyCap || !this.policy)
110
+ throw new Error('This function can only be called after `transferPolicyManager.create`');
111
+
112
+ shareTransferPolicy(this.transactionBlock, this.type, this.policy as TransactionArgument);
113
+ this.transactionBlock.transferObjects(
114
+ [this.policyCap as TransactionArgument],
115
+ this.transactionBlock.pure(address, 'address'),
116
+ );
117
+ }
118
+
119
+ /**
120
+ * Setup the TransferPolicy by passing a `cap` returned from `kioskClient.getOwnedTransferPolicies` or
121
+ * `kioskClient.getOwnedTransferPoliciesByType`.
122
+ * @param policyCapId The `TransferPolicyCap`
123
+ */
124
+ setCap({ policyId, policyCapId, type }: TransferPolicyCap) {
125
+ return this.#setup(policyId, policyCapId, type);
126
+ }
127
+
128
+ /**
129
+ * Withdraw from the transfer policy's profits.
130
+ * @param address Address to transfer the profits to.
131
+ * @param amount (Optional) amount parameter. Will withdraw all profits if the amount is not specified.
132
+ */
133
+ withdraw(address: string, amount?: string | bigint) {
134
+ this.#validateInputs();
135
+ // Withdraw coin for specified amount (or none)
136
+ const coin = withdrawFromPolicy(
137
+ this.transactionBlock,
138
+ this.type!,
139
+ this.policy!,
140
+ this.policyCap!,
141
+ amount,
142
+ );
143
+
144
+ this.transactionBlock.transferObjects([coin], this.transactionBlock.pure(address, 'address'));
145
+
146
+ return this;
147
+ }
148
+
149
+ /**
150
+ * Adds the Kiosk Royalty rule to the Transfer Policy.
151
+ * You can pass the percentage, as well as a minimum amount.
152
+ * The royalty that will be paid is the MAX(percentage, minAmount).
153
+ * You can pass 0 in either value if you want only percentage royalty, or a fixed amount fee.
154
+ * (but you should define at least one of them for the rule to make sense).
155
+ *
156
+ * @param percentageBps The royalty percentage in basis points. Use `percentageToBasisPoints` helper to convert from percentage [0,100].
157
+ * @param minAmount The minimum royalty amount per request in MIST.
158
+ */
159
+ addRoyaltyRule(
160
+ percentageBps: number | string, // this is in basis points.
161
+ minAmount: number | string,
162
+ ) {
163
+ this.#validateInputs();
164
+
165
+ // Hard-coding package Ids as these don't change.
166
+ // Also, it's hard to keep versioning as with network wipes, mainnet
167
+ // and testnet will conflict.
168
+ attachRoyaltyRuleTx(
169
+ this.transactionBlock,
170
+ this.type!,
171
+ this.policy!,
172
+ this.policyCap!,
173
+ percentageBps,
174
+ minAmount,
175
+ this.kioskClient.getRulePackageId('royaltyRulePackageId'),
176
+ );
177
+ return this;
178
+ }
179
+
180
+ /**
181
+ * Adds the Kiosk Lock Rule to the Transfer Policy.
182
+ * This Rule forces buyer to lock the item in the kiosk, preserving strong royalties.
183
+ */
184
+ addLockRule() {
185
+ this.#validateInputs();
186
+
187
+ attachKioskLockRuleTx(
188
+ this.transactionBlock,
189
+ this.type!,
190
+ this.policy!,
191
+ this.policyCap!,
192
+ this.kioskClient.getRulePackageId('kioskLockRulePackageId'),
193
+ );
194
+ return this;
195
+ }
196
+
197
+ /**
198
+ * Attaches the Personal Kiosk Rule, making a purchase valid only for `SoulBound` kiosks.
199
+ */
200
+ addPersonalKioskRule() {
201
+ this.#validateInputs();
202
+
203
+ attachPersonalKioskRuleTx(
204
+ this.transactionBlock,
205
+ this.type!,
206
+ this.policy!,
207
+ this.policyCap!,
208
+ this.kioskClient.getRulePackageId('personalKioskRulePackageId'),
209
+ );
210
+ return this;
211
+ }
212
+
213
+ /**
214
+ * A function to add the floor price rule to a transfer policy.
215
+ * @param minPrice The minimum price in MIST.
216
+ */
217
+ addFloorPriceRule(minPrice: string | bigint) {
218
+ this.#validateInputs();
219
+
220
+ attachFloorPriceRuleTx(
221
+ this.transactionBlock,
222
+ this.type!,
223
+ this.policy!,
224
+ this.policyCap!,
225
+ minPrice,
226
+ this.kioskClient.getRulePackageId('floorPriceRulePackageId'),
227
+ );
228
+ return this;
229
+ }
230
+
231
+ /**
232
+ * Generic helper to remove a rule, not from the SDK's base ruleset.
233
+ * @param ruleType The Rule Type
234
+ * @param configType The Config Type
235
+ */
236
+ removeRule({ ruleType, configType }: { ruleType: string; configType: string }) {
237
+ this.#validateInputs();
238
+
239
+ removeTransferPolicyRule(
240
+ this.transactionBlock,
241
+ this.type!,
242
+ ruleType,
243
+ configType,
244
+ this.policy!,
245
+ this.policyCap!,
246
+ );
247
+ }
248
+
249
+ /**
250
+ * Removes the lock rule.
251
+ */
252
+ removeLockRule() {
253
+ this.#validateInputs();
254
+
255
+ const packageId = this.kioskClient.getRulePackageId('kioskLockRulePackageId');
256
+
257
+ removeTransferPolicyRule(
258
+ this.transactionBlock,
259
+ this.type!,
260
+ `${packageId}::kiosk_lock_rule::Rule`,
261
+ `${packageId}::kiosk_lock_rule::Config`,
262
+ this.policy!,
263
+ this.policyCap!,
264
+ );
265
+ return this;
266
+ }
267
+
268
+ /**
269
+ * Removes the Royalty rule
270
+ */
271
+ removeRoyaltyRule() {
272
+ this.#validateInputs();
273
+
274
+ const packageId = this.kioskClient.getRulePackageId('royaltyRulePackageId');
275
+
276
+ removeTransferPolicyRule(
277
+ this.transactionBlock,
278
+ this.type!,
279
+ `${packageId}::royalty_rule::Rule`,
280
+ `${packageId}::royalty_rule::Config`,
281
+ this.policy!,
282
+ this.policyCap!,
283
+ );
284
+ return this;
285
+ }
286
+
287
+ removePersonalKioskRule() {
288
+ this.#validateInputs();
289
+
290
+ const packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');
291
+
292
+ removeTransferPolicyRule(
293
+ this.transactionBlock,
294
+ this.type!,
295
+ `${packageId}::personal_kiosk_rule::Rule`,
296
+ `bool`,
297
+ this.policy!,
298
+ this.policyCap!,
299
+ );
300
+ return this;
301
+ }
302
+
303
+ removeFloorPriceRule() {
304
+ this.#validateInputs();
305
+
306
+ const packageId = this.kioskClient.getRulePackageId('floorPriceRulePackageId');
307
+
308
+ removeTransferPolicyRule(
309
+ this.transactionBlock,
310
+ this.type!,
311
+ `${packageId}::floor_price_rule::Rule`,
312
+ `${packageId}::floor_price_rule::Config`,
313
+ this.policy!,
314
+ this.policyCap!,
315
+ );
316
+ return this;
317
+ }
318
+
319
+ getPolicy() {
320
+ if (!this.policy) throw new Error('Policy not set.');
321
+ return this.policy;
322
+ }
323
+
324
+ getPolicyCap() {
325
+ if (!this.policyCap) throw new Error('Transfer Policy Cap not set.');
326
+ return this.policyCap;
327
+ }
328
+
329
+ // Internal function that that the policy's Id + Cap + type have been set.
330
+ #validateInputs() {
331
+ const genericErrorMessage = `Please use 'setCap()' to setup the TransferPolicy.`;
332
+ if (!this.policy) throw new Error(`${genericErrorMessage} Missing: Transfer Policy Object.`);
333
+ if (!this.policyCap)
334
+ throw new Error(`${genericErrorMessage} Missing: TransferPolicyCap Object ID`);
335
+ if (!this.type)
336
+ throw new Error(
337
+ `${genericErrorMessage} Missing: Transfer Policy object type (e.g. {packageId}::item::Item)`,
338
+ );
339
+ }
340
+
341
+ /**
342
+ * Setup the state of the TransferPolicyTransaction.
343
+ */
344
+ #setup(policyId: ObjectArgument, policyCap: ObjectArgument, type: string) {
345
+ this.policy = policyId;
346
+ this.policyCap = policyCap;
347
+ this.type = type;
348
+ return this;
349
+ }
350
+ }
package/src/constants.ts CHANGED
@@ -1,10 +1,117 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- /** The Transer Policy Rules package address on testnet */
5
- export const TESTNET_RULES_PACKAGE_ADDRESS =
6
- 'bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585';
4
+ import {
5
+ resolveFloorPriceRule,
6
+ resolveKioskLockRule,
7
+ resolvePersonalKioskRule,
8
+ resolveRoyaltyRule,
9
+ } from './tx/rules//resolve';
10
+ import { Network, type ObjectArgument, type RuleResolvingParams } from './types';
7
11
 
8
- /** The transfer policy rules package address on mainnet */
9
- export const MAINNET_RULES_PACKAGE_ADDRESS =
10
- '0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879';
12
+ /**
13
+ * The base rule package ids that can be extended
14
+ */
15
+ export type BaseRulePackageIds = {
16
+ royaltyRulePackageId?: string;
17
+ kioskLockRulePackageId?: string;
18
+ personalKioskRulePackageId?: string;
19
+ floorPriceRulePackageId?: string;
20
+ };
21
+
22
+ /**
23
+ * The Transfer Policy rule.
24
+ */
25
+ export type TransferPolicyRule = {
26
+ rule: string;
27
+ packageId: string;
28
+ resolveRuleFunction: (rule: RuleResolvingParams) => ObjectArgument | void;
29
+ hasLockingRule?: boolean;
30
+ };
31
+
32
+ export const ROYALTY_RULE_ADDRESS: Record<Network, string> = {
33
+ [Network.TESTNET]: 'bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585',
34
+ [Network.MAINNET]: '0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879',
35
+ [Network.CUSTOM]: '',
36
+ };
37
+
38
+ export const KIOSK_LOCK_RULE_ADDRESS: Record<Network, string> = {
39
+ [Network.TESTNET]: 'bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585',
40
+ [Network.MAINNET]: '0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879',
41
+ [Network.CUSTOM]: '',
42
+ };
43
+
44
+ export const FLOOR_PRICE_RULE_ADDRESS: Record<Network, string> = {
45
+ [Network.TESTNET]: '0x06f6bdd3f2e2e759d8a4b9c252f379f7a05e72dfe4c0b9311cdac27b8eb791b1',
46
+ [Network.MAINNET]: '0x34cc6762780f4f6f153c924c0680cfe2a1fb4601e7d33cc28a92297b62de1e0e',
47
+ [Network.CUSTOM]: '',
48
+ };
49
+
50
+ export const PERSONAL_KIOSK_RULE_ADDRESS: Record<Network, string> = {
51
+ [Network.TESTNET]: '0x06f6bdd3f2e2e759d8a4b9c252f379f7a05e72dfe4c0b9311cdac27b8eb791b1',
52
+ [Network.MAINNET]: '0x0cb4bcc0560340eb1a1b929cabe56b33fc6449820ec8c1980d69bb98b649b802',
53
+ [Network.CUSTOM]: '',
54
+ };
55
+
56
+ /**
57
+ * Constructs a list of rule resolvers based on the params.
58
+ */
59
+ export function getBaseRules({
60
+ royaltyRulePackageId,
61
+ kioskLockRulePackageId,
62
+ personalKioskRulePackageId,
63
+ floorPriceRulePackageId,
64
+ }: BaseRulePackageIds): TransferPolicyRule[] {
65
+ const rules = [];
66
+
67
+ if (royaltyRulePackageId) {
68
+ rules.push({
69
+ rule: `${royaltyRulePackageId}::royalty_rule::Rule`,
70
+ packageId: royaltyRulePackageId,
71
+ resolveRuleFunction: resolveRoyaltyRule,
72
+ });
73
+ }
74
+
75
+ if (kioskLockRulePackageId) {
76
+ rules.push({
77
+ rule: `${kioskLockRulePackageId}::kiosk_lock_rule::Rule`,
78
+ packageId: kioskLockRulePackageId,
79
+ resolveRuleFunction: resolveKioskLockRule,
80
+ hasLockingRule: true,
81
+ });
82
+ }
83
+
84
+ if (personalKioskRulePackageId) {
85
+ rules.push({
86
+ rule: `${personalKioskRulePackageId}::personal_kiosk_rule::Rule`,
87
+ packageId: personalKioskRulePackageId,
88
+ resolveRuleFunction: resolvePersonalKioskRule,
89
+ });
90
+ }
91
+
92
+ if (floorPriceRulePackageId) {
93
+ rules.push({
94
+ rule: `${floorPriceRulePackageId}::floor_price_rule::Rule`,
95
+ packageId: floorPriceRulePackageId,
96
+ resolveRuleFunction: resolveFloorPriceRule,
97
+ });
98
+ }
99
+
100
+ return rules;
101
+ }
102
+
103
+ // A list of testnet's base rules.
104
+ export const testnetRules: TransferPolicyRule[] = getBaseRules({
105
+ royaltyRulePackageId: ROYALTY_RULE_ADDRESS[Network.TESTNET],
106
+ kioskLockRulePackageId: KIOSK_LOCK_RULE_ADDRESS[Network.TESTNET],
107
+ personalKioskRulePackageId: PERSONAL_KIOSK_RULE_ADDRESS[Network.TESTNET],
108
+ floorPriceRulePackageId: FLOOR_PRICE_RULE_ADDRESS[Network.TESTNET],
109
+ });
110
+
111
+ // A list of mainnet's base rules.
112
+ export const mainnetRules: TransferPolicyRule[] = getBaseRules({
113
+ royaltyRulePackageId: ROYALTY_RULE_ADDRESS[Network.MAINNET],
114
+ kioskLockRulePackageId: KIOSK_LOCK_RULE_ADDRESS[Network.MAINNET],
115
+ });
116
+
117
+ export const rules: TransferPolicyRule[] = [...testnetRules, ...mainnetRules];
package/src/index.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- export * from './tx/kiosk';
5
- export * from './tx/transfer-policy';
6
- export * from './tx/rules';
7
- export * from './query/kiosk';
8
- export * from './bcs';
9
4
  export * from './utils';
10
- export * from './query/transfer-policy';
11
5
  export * from './types';
12
6
  export * from './constants';
7
+ export * from './client/kiosk-client';
8
+ export * from './client/tp-transaction';
9
+ export * from './client/kiosk-transaction';
@@ -1,15 +1,15 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { SuiObjectData, SuiObjectResponse } from '@mysten/sui.js/client';
5
- import { isValidSuiAddress } from '@mysten/sui.js/utils';
6
4
  import {
7
- attachListingsAndPrices,
8
- attachLockedItems,
9
- extractKioskData,
10
- getAllDynamicFields,
11
- getKioskObject,
12
- } from '../utils';
5
+ PaginationArguments,
6
+ SuiClient,
7
+ SuiObjectData,
8
+ SuiObjectDataFilter,
9
+ SuiObjectResponse,
10
+ } from '@mysten/sui.js/client';
11
+ import { isValidSuiAddress } from '@mysten/sui.js/utils';
12
+
13
13
  import {
14
14
  FetchKioskOptions,
15
15
  KIOSK_OWNER_CAP,
@@ -17,7 +17,15 @@ import {
17
17
  OwnedKiosks,
18
18
  PagedKioskData,
19
19
  } from '../types';
20
- import { SuiClient, PaginationArguments } from '@mysten/sui.js/client';
20
+ import {
21
+ attachListingsAndPrices,
22
+ attachLockedItems,
23
+ attachObjects,
24
+ extractKioskData,
25
+ getAllDynamicFields,
26
+ getAllObjects,
27
+ getKioskObject,
28
+ } from '../utils';
21
29
 
22
30
  export async function fetchKiosk(
23
31
  client: SuiClient,
@@ -35,21 +43,21 @@ export async function fetchKiosk(
35
43
  const lockedItemIds: string[] = [];
36
44
 
37
45
  // extracted kiosk data.
38
- const kioskData = extractKioskData(data, listings, lockedItemIds);
46
+ const kioskData = extractKioskData(data, listings, lockedItemIds, kioskId);
39
47
 
40
48
  // split the fetching in two queries as we are most likely passing different options for each kind.
41
49
  // For items, we usually seek the Display.
42
50
  // For listings we usually seek the DF value (price) / exclusivity.
43
- const [kiosk, listingObjects] = await Promise.all([
51
+ const [kiosk, listingObjects, items] = await Promise.all([
44
52
  options.withKioskFields ? getKioskObject(client, kioskId) : Promise.resolve(undefined),
45
53
  options.withListingPrices
46
- ? client.multiGetObjects({
47
- ids: kioskData.listingIds,
48
- options: {
49
- showContent: true,
50
- },
54
+ ? getAllObjects(client, kioskData.listingIds, {
55
+ showContent: true,
51
56
  })
52
57
  : Promise.resolve([]),
58
+ options.withObjects
59
+ ? getAllObjects(client, kioskData.itemIds, options.objectOptions || { showDisplay: true })
60
+ : Promise.resolve([]),
53
61
  ]);
54
62
 
55
63
  if (options.withKioskFields) kioskData.kiosk = kiosk;
@@ -58,6 +66,12 @@ export async function fetchKiosk(
58
66
  // add `locked` status to items that are locked.
59
67
  attachLockedItems(kioskData, lockedItemIds);
60
68
 
69
+ // Attach the objects for the queried items.
70
+ attachObjects(
71
+ kioskData,
72
+ items.filter((x) => !!x.data).map((x) => x.data!),
73
+ );
74
+
61
75
  return {
62
76
  data: kioskData,
63
77
  nextCursor: null,
@@ -76,6 +90,7 @@ export async function getOwnedKiosks(
76
90
  address: string,
77
91
  options?: {
78
92
  pagination?: PaginationArguments<string>;
93
+ personalKioskType: string;
79
94
  },
80
95
  ): Promise<OwnedKiosks> {
81
96
  if (!isValidSuiAddress(address))
@@ -86,12 +101,27 @@ export async function getOwnedKiosks(
86
101
  kioskIds: [],
87
102
  };
88
103
 
104
+ const filter: SuiObjectDataFilter = {
105
+ MatchAny: [
106
+ {
107
+ StructType: KIOSK_OWNER_CAP,
108
+ },
109
+ ],
110
+ };
111
+
112
+ if (options?.personalKioskType) {
113
+ filter.MatchAny.push({
114
+ StructType: options.personalKioskType,
115
+ });
116
+ }
117
+
89
118
  // fetch owned kiosk caps, paginated.
90
119
  const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({
91
120
  owner: address,
92
- filter: { StructType: KIOSK_OWNER_CAP },
121
+ filter,
93
122
  options: {
94
123
  showContent: true,
124
+ showType: true,
95
125
  },
96
126
  ...(options?.pagination || {}),
97
127
  });
@@ -99,7 +129,9 @@ export async function getOwnedKiosks(
99
129
  // get kioskIds from the OwnerCaps.
100
130
  const kioskIdList = data?.map((x: SuiObjectResponse) => {
101
131
  const fields = x.data?.content?.dataType === 'moveObject' ? x.data.content.fields : null;
102
- return (fields as { for: string })?.for;
132
+ // @ts-ignore-next-line TODO: should i remove ts ignore here?
133
+ return (fields?.cap ? fields?.cap?.fields?.for : fields?.for) as string;
134
+ // return (fields as { for: string })?.for;
103
135
  });
104
136
 
105
137
  // clean up data that might have an error in them.
@@ -110,6 +142,7 @@ export async function getOwnedKiosks(
110
142
  nextCursor,
111
143
  hasNextPage,
112
144
  kioskOwnerCaps: filteredData.map((x, idx) => ({
145
+ isPersonal: x.type !== KIOSK_OWNER_CAP,
113
146
  digest: x.digest,
114
147
  version: x.version,
115
148
  objectId: x.objectId,