@mysten/kiosk 0.6.0 → 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 +6 -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 +11 -3
  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
package/dist/index.mjs CHANGED
@@ -1,3 +1,29 @@
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+ var __privateMethod = (obj, member, method) => {
20
+ __accessCheck(obj, member, "access private method");
21
+ return method;
22
+ };
23
+
24
+ // src/utils.ts
25
+ import { normalizeSuiAddress } from "@mysten/sui.js/utils";
26
+
1
27
  // src/bcs.ts
2
28
  import { bcs } from "@mysten/sui.js/bcs";
3
29
 
@@ -14,16 +40,17 @@ var KIOSK_PURCHASE_CAP = `${KIOSK_MODULE}::PurchaseCap`;
14
40
  var TRANSFER_POLICY_MODULE = "0x2::transfer_policy";
15
41
  var TRANSFER_POLICY_CREATED_EVENT = `${TRANSFER_POLICY_MODULE}::TransferPolicyCreated`;
16
42
  var TRANSFER_POLICY_TYPE = `${TRANSFER_POLICY_MODULE}::TransferPolicy`;
43
+ var TRANSFER_POLICY_CAP_TYPE = `${TRANSFER_POLICY_MODULE}::TransferPolicyCap`;
17
44
  var KIOSK_LOCK_RULE = "kiosk_lock_rule::Rule";
18
45
  var ROYALTY_RULE = "royalty_rule::Rule";
19
46
 
20
- // src/types/env.ts
21
- var testnetEnvironment = { env: "testnet" };
22
- var mainnetEnvironment = { env: "mainnet" };
23
- var customEnvironment = (address) => ({
24
- env: "custom",
25
- address
26
- });
47
+ // src/types/index.ts
48
+ var Network = /* @__PURE__ */ ((Network2) => {
49
+ Network2["MAINNET"] = "mainnet";
50
+ Network2["TESTNET"] = "testnet";
51
+ Network2["CUSTOM"] = "custom";
52
+ return Network2;
53
+ })(Network || {});
27
54
 
28
55
  // src/bcs.ts
29
56
  bcs.registerStructType(KIOSK_TYPE, {
@@ -48,26 +75,17 @@ bcs.registerStructType(TRANSFER_POLICY_TYPE, {
48
75
  rules: ["vector", "string"]
49
76
  });
50
77
 
51
- // src/constants.ts
52
- var TESTNET_RULES_PACKAGE_ADDRESS = "bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585";
53
- var MAINNET_RULES_PACKAGE_ADDRESS = "0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879";
54
-
55
78
  // src/utils.ts
56
- var rulesPackageAddresses = {
57
- mainnet: MAINNET_RULES_PACKAGE_ADDRESS,
58
- testnet: TESTNET_RULES_PACKAGE_ADDRESS,
59
- devnet: "",
60
- custom: null
61
- };
62
- function objArg(tx, arg) {
79
+ var DEFAULT_QUERY_LIMIT = 50;
80
+ function objArg(txb, arg) {
63
81
  if (typeof arg === "string") {
64
- return tx.object(arg);
82
+ return txb.object(arg);
65
83
  }
66
84
  if ("digest" in arg && "version" in arg && "objectId" in arg) {
67
- return tx.objectRef(arg);
85
+ return txb.objectRef(arg);
68
86
  }
69
87
  if ("objectId" in arg && "initialSharedVersion" in arg && "mutable" in arg) {
70
- return tx.sharedObjectRef(arg);
88
+ return txb.sharedObjectRef(arg);
71
89
  }
72
90
  if ("kind" in arg) {
73
91
  return arg;
@@ -84,7 +102,7 @@ async function getKioskObject(client, id) {
84
102
  }
85
103
  return bcs.de(KIOSK_TYPE, queryRes.data.bcs.bcsBytes, "base64");
86
104
  }
87
- function extractKioskData(data, listings, lockedItemIds) {
105
+ function extractKioskData(data, listings, lockedItemIds, kioskId) {
88
106
  return data.reduce(
89
107
  (acc, val) => {
90
108
  const type = getTypeWithoutPackageAddress(val.name.type);
@@ -94,7 +112,8 @@ function extractKioskData(data, listings, lockedItemIds) {
94
112
  acc.items.push({
95
113
  objectId: val.objectId,
96
114
  type: val.objectType,
97
- isLocked: false
115
+ isLocked: false,
116
+ kioskId
98
117
  });
99
118
  break;
100
119
  case "kiosk::Listing":
@@ -136,6 +155,18 @@ function attachListingsAndPrices(kioskData, listings, listingObjects) {
136
155
  item.listing = itemListings[item.objectId] || void 0;
137
156
  });
138
157
  }
158
+ function attachObjects(kioskData, objects) {
159
+ const mapping = objects.reduce(
160
+ (acc, obj) => {
161
+ acc[obj.objectId] = obj;
162
+ return acc;
163
+ },
164
+ {}
165
+ );
166
+ kioskData.items.forEach((item) => {
167
+ item.data = mapping[item.objectId] || void 0;
168
+ });
169
+ }
139
170
  function attachLockedItems(kioskData, lockedItemIds) {
140
171
  const lockedStatuses = lockedItemIds.reduce(
141
172
  (acc, item) => {
@@ -148,14 +179,6 @@ function attachLockedItems(kioskData, lockedItemIds) {
148
179
  item.isLocked = lockedStatuses[item.objectId] || false;
149
180
  });
150
181
  }
151
- function getRulePackageAddress(environment) {
152
- if (environment.env === "custom") {
153
- if (!environment.address)
154
- throw new Error("Please supply the custom package address for rules.");
155
- return environment.address;
156
- }
157
- return rulesPackageAddresses[environment.env];
158
- }
159
182
  async function getAllDynamicFields(client, parentId, pagination) {
160
183
  let hasNextPage = true;
161
184
  let cursor = void 0;
@@ -172,89 +195,86 @@ async function getAllDynamicFields(client, parentId, pagination) {
172
195
  }
173
196
  return data;
174
197
  }
198
+ async function getAllObjects(client, ids, options, limit = DEFAULT_QUERY_LIMIT) {
199
+ const chunks = Array.from(
200
+ { length: Math.ceil(ids.length / limit) },
201
+ (_, index) => ids.slice(index * limit, index * limit + limit)
202
+ );
203
+ const results = await Promise.all(
204
+ chunks.map((chunk) => {
205
+ return client.multiGetObjects({
206
+ ids: chunk,
207
+ options
208
+ });
209
+ })
210
+ );
211
+ return results.flat();
212
+ }
213
+ async function getAllOwnedObjects({
214
+ client,
215
+ owner,
216
+ filter,
217
+ limit = DEFAULT_QUERY_LIMIT,
218
+ options = { showType: true, showContent: true }
219
+ }) {
220
+ let hasNextPage = true;
221
+ let cursor = void 0;
222
+ const data = [];
223
+ while (hasNextPage) {
224
+ const result = await client.getOwnedObjects({
225
+ owner,
226
+ filter,
227
+ limit,
228
+ cursor,
229
+ options
230
+ });
231
+ data.push(...result.data);
232
+ hasNextPage = result.hasNextPage;
233
+ cursor = result.nextCursor;
234
+ }
235
+ return data;
236
+ }
175
237
  function percentageToBasisPoints(percentage) {
176
238
  if (percentage < 0 || percentage > 100)
177
239
  throw new Error("Percentage needs to be in the [0,100] range.");
178
240
  return Math.ceil(percentage * 100);
179
241
  }
180
-
181
- // src/tx/transfer-policy.ts
182
- function createTransferPolicy(tx, itemType, publisher) {
183
- let [transferPolicy, transferPolicyCap] = tx.moveCall({
184
- target: `${TRANSFER_POLICY_MODULE}::new`,
185
- typeArguments: [itemType],
186
- arguments: [objArg(tx, publisher)]
187
- });
188
- tx.moveCall({
189
- target: `0x2::transfer::public_share_object`,
190
- typeArguments: [`${TRANSFER_POLICY_TYPE}<${itemType}>`],
191
- arguments: [transferPolicy]
192
- });
193
- return transferPolicyCap;
194
- }
195
- function withdrawFromPolicy(tx, itemType, policy, policyCap, amount) {
196
- let amountArg = amount !== null ? tx.pure({ Some: amount }, "Option<u64>") : tx.pure({ None: true }, "Option<u64>");
197
- let [profits] = tx.moveCall({
198
- target: `${TRANSFER_POLICY_MODULE}::withdraw`,
199
- typeArguments: [itemType],
200
- arguments: [objArg(tx, policy), objArg(tx, policyCap), amountArg]
201
- });
202
- return profits;
203
- }
204
- function confirmRequest(tx, itemType, policy, request) {
205
- tx.moveCall({
206
- target: `${TRANSFER_POLICY_MODULE}::confirm_request`,
207
- typeArguments: [itemType],
208
- arguments: [objArg(tx, policy), request]
209
- });
210
- }
211
- function removeTransferPolicyRule(tx, itemType, ruleType, configType, policy, policyCap) {
212
- tx.moveCall({
213
- target: `${TRANSFER_POLICY_MODULE}::remove_rule`,
214
- typeArguments: [itemType, ruleType, configType],
215
- arguments: [objArg(tx, policy), policyCap]
216
- });
242
+ function parseTransferPolicyCapObject(item) {
243
+ const type = item?.data?.content?.type;
244
+ const policy = item?.data?.content?.fields?.policy_id;
245
+ if (!type.includes(TRANSFER_POLICY_CAP_TYPE))
246
+ return void 0;
247
+ const objectType = type.replace(TRANSFER_POLICY_CAP_TYPE + "<", "").slice(0, -1);
248
+ return {
249
+ policyId: policy,
250
+ policyCapId: item.data?.objectId,
251
+ type: objectType
252
+ };
217
253
  }
218
- function resolveRoyaltyRule(tx, itemType, price, policyId, transferRequest, environment) {
219
- const policyObj = objArg(tx, policyId);
220
- const [amount] = tx.moveCall({
221
- target: `${getRulePackageAddress(environment)}::royalty_rule::fee_amount`,
222
- typeArguments: [itemType],
223
- arguments: [policyObj, objArg(tx, price)]
224
- });
225
- const feeCoin = tx.splitCoins(tx.gas, [amount]);
226
- tx.moveCall({
227
- target: `${getRulePackageAddress(environment)}::royalty_rule::pay`,
228
- typeArguments: [itemType],
229
- arguments: [policyObj, transferRequest, feeCoin]
230
- });
231
- }
232
- function resolveKioskLockRule(tx, itemType, item, kiosk, kioskCap, policyId, transferRequest, environment) {
233
- lock(tx, itemType, kiosk, kioskCap, policyId, item);
234
- tx.moveCall({
235
- target: `${getRulePackageAddress(environment)}::kiosk_lock_rule::prove`,
236
- typeArguments: [itemType],
237
- arguments: [transferRequest, objArg(tx, kiosk)]
238
- });
254
+ function getNormalizedRuleType(rule) {
255
+ const normalizedRuleAddress = rule.split("::");
256
+ normalizedRuleAddress[0] = normalizeSuiAddress(normalizedRuleAddress[0]);
257
+ return normalizedRuleAddress.join("::");
239
258
  }
240
259
 
241
260
  // src/tx/kiosk.ts
242
261
  function createKiosk(tx) {
243
- let [kiosk, kioskOwnerCap] = tx.moveCall({
262
+ const [kiosk, kioskOwnerCap] = tx.moveCall({
244
263
  target: `${KIOSK_MODULE}::new`
245
264
  });
246
265
  return [kiosk, kioskOwnerCap];
247
266
  }
248
267
  function createKioskAndShare(tx) {
249
- let [kiosk, kioskOwnerCap] = tx.moveCall({
250
- target: `${KIOSK_MODULE}::new`
251
- });
268
+ const [kiosk, kioskOwnerCap] = createKiosk(tx);
269
+ shareKiosk(tx, kiosk);
270
+ return kioskOwnerCap;
271
+ }
272
+ function shareKiosk(tx, kiosk) {
252
273
  tx.moveCall({
253
274
  target: `0x2::transfer::public_share_object`,
254
275
  typeArguments: [KIOSK_TYPE],
255
276
  arguments: [kiosk]
256
277
  });
257
- return kioskOwnerCap;
258
278
  }
259
279
  function place(tx, itemType, kiosk, kioskCap, item) {
260
280
  tx.moveCall({
@@ -271,7 +291,7 @@ function lock(tx, itemType, kiosk, kioskCap, policy, item) {
271
291
  });
272
292
  }
273
293
  function take(tx, itemType, kiosk, kioskCap, itemId) {
274
- let [item] = tx.moveCall({
294
+ const [item] = tx.moveCall({
275
295
  target: `${KIOSK_MODULE}::take`,
276
296
  typeArguments: [itemType],
277
297
  arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
@@ -305,7 +325,7 @@ function placeAndList(tx, itemType, kiosk, kioskCap, item, price) {
305
325
  });
306
326
  }
307
327
  function purchase(tx, itemType, kiosk, itemId, payment) {
308
- let [item, transferRequest] = tx.moveCall({
328
+ const [item, transferRequest] = tx.moveCall({
309
329
  target: `${KIOSK_MODULE}::purchase`,
310
330
  typeArguments: [itemType],
311
331
  arguments: [objArg(tx, kiosk), tx.pure(itemId, "address"), objArg(tx, payment)]
@@ -313,36 +333,15 @@ function purchase(tx, itemType, kiosk, itemId, payment) {
313
333
  return [item, transferRequest];
314
334
  }
315
335
  function withdrawFromKiosk(tx, kiosk, kioskCap, amount) {
316
- let amountArg = amount !== null ? tx.pure(
317
- {
318
- Some: amount
319
- },
320
- "Option<u64>"
321
- ) : tx.pure({ None: true }, "Option<u64>");
322
- let [coin] = tx.moveCall({
336
+ const amountArg = tx.pure(amount ? { Some: amount } : { None: true }, "Option<u64>");
337
+ const [coin] = tx.moveCall({
323
338
  target: `${KIOSK_MODULE}::withdraw`,
324
339
  arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), amountArg]
325
340
  });
326
341
  return coin;
327
342
  }
328
- function borrow(tx, itemType, kiosk, kioskCap, itemId) {
329
- let [item] = tx.moveCall({
330
- target: `${KIOSK_MODULE}::borrow`,
331
- typeArguments: [itemType],
332
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
333
- });
334
- return item;
335
- }
336
- function borrowMut(tx, itemType, kiosk, kioskCap, itemId) {
337
- let [item] = tx.moveCall({
338
- target: `${KIOSK_MODULE}::borrow_mut`,
339
- typeArguments: [itemType],
340
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
341
- });
342
- return item;
343
- }
344
343
  function borrowValue(tx, itemType, kiosk, kioskCap, itemId) {
345
- let [item, promise] = tx.moveCall({
344
+ const [item, promise] = tx.moveCall({
346
345
  target: `${KIOSK_MODULE}::borrow_val`,
347
346
  typeArguments: [itemType],
348
347
  arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
@@ -356,68 +355,132 @@ function returnValue(tx, itemType, kiosk, item, promise) {
356
355
  arguments: [objArg(tx, kiosk), item, promise]
357
356
  });
358
357
  }
359
- function purchaseAndResolvePolicies(tx, itemType, price, kiosk, itemId, policy, environment, extraParams) {
360
- if (price === void 0 || typeof price !== "string")
361
- throw new Error(`Price of the listing is not supplied.`);
362
- const coin = tx.splitCoins(tx.gas, [tx.pure(price, "u64")]);
363
- const [purchasedItem, transferRequest] = purchase(tx, itemType, kiosk, itemId, coin);
364
- let hasKioskLockRule = false;
365
- for (let rule of policy.rules) {
366
- const ruleWithoutAddr = getTypeWithoutPackageAddress(rule);
367
- switch (ruleWithoutAddr) {
368
- case ROYALTY_RULE:
369
- resolveRoyaltyRule(tx, itemType, price, policy.id, transferRequest, environment);
370
- break;
371
- case KIOSK_LOCK_RULE:
372
- if (!extraParams?.ownedKiosk || !extraParams?.ownedKioskCap)
373
- throw new Error(
374
- `This item type ${itemType} has a 'kiosk_lock_rule', but function call is missing user's kiosk and kioskCap params`
375
- );
376
- hasKioskLockRule = true;
377
- resolveKioskLockRule(
378
- tx,
379
- itemType,
380
- purchasedItem,
381
- extraParams.ownedKiosk,
382
- extraParams.ownedKioskCap,
383
- policy.id,
384
- transferRequest,
385
- environment
386
- );
387
- break;
388
- default:
389
- break;
390
- }
391
- }
392
- confirmRequest(tx, itemType, policy.id, transferRequest);
393
- return {
394
- item: purchasedItem,
395
- canTransfer: !hasKioskLockRule
396
- };
397
- }
398
358
 
399
- // src/tx/rules.ts
400
- function attachRoyaltyRule(tx, type, policy, policyCap, percentageBps, minAmount, environment) {
401
- if (Number(percentageBps) < 0 || Number(percentageBps) > 1e4)
402
- throw new Error("Invalid basis point percentage. Use a value between [0,10000].");
403
- tx.moveCall({
404
- target: `${getRulePackageAddress(environment)}::royalty_rule::add`,
405
- typeArguments: [type],
406
- arguments: [
407
- objArg(tx, policy),
408
- objArg(tx, policyCap),
409
- tx.pure(percentageBps, "u16"),
410
- tx.pure(minAmount, "u64")
411
- ]
359
+ // src/tx/rules/resolve.ts
360
+ function resolveRoyaltyRule(params) {
361
+ const { transactionBlock: txb, itemType, price, packageId, transferRequest, policyId } = params;
362
+ const policyObj = objArg(txb, policyId);
363
+ const [amount] = txb.moveCall({
364
+ target: `${packageId}::royalty_rule::fee_amount`,
365
+ typeArguments: [itemType],
366
+ arguments: [policyObj, objArg(txb, price ?? "")]
367
+ });
368
+ const feeCoin = txb.splitCoins(txb.gas, [amount]);
369
+ txb.moveCall({
370
+ target: `${packageId}::royalty_rule::pay`,
371
+ typeArguments: [itemType],
372
+ arguments: [policyObj, transferRequest, feeCoin]
412
373
  });
413
374
  }
414
- function attachKioskLockRule(tx, type, policy, policyCap, environment) {
415
- tx.moveCall({
416
- target: `${getRulePackageAddress(environment)}::kiosk_lock_rule::add`,
417
- typeArguments: [type],
418
- arguments: [objArg(tx, policy), objArg(tx, policyCap)]
375
+ function resolveKioskLockRule(params) {
376
+ const {
377
+ transactionBlock: txb,
378
+ packageId,
379
+ itemType,
380
+ kiosk,
381
+ kioskCap,
382
+ policyId,
383
+ purchasedItem,
384
+ transferRequest
385
+ } = params;
386
+ if (!kiosk || !kioskCap)
387
+ throw new Error("Missing Owned Kiosk or Owned Kiosk Cap");
388
+ lock(txb, itemType, kiosk, kioskCap, policyId, purchasedItem);
389
+ txb.moveCall({
390
+ target: `${packageId}::kiosk_lock_rule::prove`,
391
+ typeArguments: [itemType],
392
+ arguments: [transferRequest, objArg(txb, kiosk)]
393
+ });
394
+ }
395
+ function resolvePersonalKioskRule(params) {
396
+ const { transactionBlock: txb, packageId, itemType, kiosk, transferRequest } = params;
397
+ if (!kiosk)
398
+ throw new Error("Missing owned Kiosk.");
399
+ txb.moveCall({
400
+ target: `${packageId}::personal_kiosk_rule::prove`,
401
+ typeArguments: [itemType],
402
+ arguments: [objArg(txb, kiosk), transferRequest]
419
403
  });
420
404
  }
405
+ function resolveFloorPriceRule(params) {
406
+ const { transactionBlock: txb, packageId, itemType, policyId, transferRequest } = params;
407
+ txb.moveCall({
408
+ target: `${packageId}::floor_price_rule::prove`,
409
+ typeArguments: [itemType],
410
+ arguments: [objArg(txb, policyId), transferRequest]
411
+ });
412
+ }
413
+
414
+ // src/constants.ts
415
+ var ROYALTY_RULE_ADDRESS = {
416
+ ["testnet" /* TESTNET */]: "bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585",
417
+ ["mainnet" /* MAINNET */]: "0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879",
418
+ ["custom" /* CUSTOM */]: ""
419
+ };
420
+ var KIOSK_LOCK_RULE_ADDRESS = {
421
+ ["testnet" /* TESTNET */]: "bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585",
422
+ ["mainnet" /* MAINNET */]: "0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879",
423
+ ["custom" /* CUSTOM */]: ""
424
+ };
425
+ var FLOOR_PRICE_RULE_ADDRESS = {
426
+ ["testnet" /* TESTNET */]: "0x06f6bdd3f2e2e759d8a4b9c252f379f7a05e72dfe4c0b9311cdac27b8eb791b1",
427
+ ["mainnet" /* MAINNET */]: "0x34cc6762780f4f6f153c924c0680cfe2a1fb4601e7d33cc28a92297b62de1e0e",
428
+ ["custom" /* CUSTOM */]: ""
429
+ };
430
+ var PERSONAL_KIOSK_RULE_ADDRESS = {
431
+ ["testnet" /* TESTNET */]: "0x06f6bdd3f2e2e759d8a4b9c252f379f7a05e72dfe4c0b9311cdac27b8eb791b1",
432
+ ["mainnet" /* MAINNET */]: "0x0cb4bcc0560340eb1a1b929cabe56b33fc6449820ec8c1980d69bb98b649b802",
433
+ ["custom" /* CUSTOM */]: ""
434
+ };
435
+ function getBaseRules({
436
+ royaltyRulePackageId,
437
+ kioskLockRulePackageId,
438
+ personalKioskRulePackageId,
439
+ floorPriceRulePackageId
440
+ }) {
441
+ const rules2 = [];
442
+ if (royaltyRulePackageId) {
443
+ rules2.push({
444
+ rule: `${royaltyRulePackageId}::royalty_rule::Rule`,
445
+ packageId: royaltyRulePackageId,
446
+ resolveRuleFunction: resolveRoyaltyRule
447
+ });
448
+ }
449
+ if (kioskLockRulePackageId) {
450
+ rules2.push({
451
+ rule: `${kioskLockRulePackageId}::kiosk_lock_rule::Rule`,
452
+ packageId: kioskLockRulePackageId,
453
+ resolveRuleFunction: resolveKioskLockRule,
454
+ hasLockingRule: true
455
+ });
456
+ }
457
+ if (personalKioskRulePackageId) {
458
+ rules2.push({
459
+ rule: `${personalKioskRulePackageId}::personal_kiosk_rule::Rule`,
460
+ packageId: personalKioskRulePackageId,
461
+ resolveRuleFunction: resolvePersonalKioskRule
462
+ });
463
+ }
464
+ if (floorPriceRulePackageId) {
465
+ rules2.push({
466
+ rule: `${floorPriceRulePackageId}::floor_price_rule::Rule`,
467
+ packageId: floorPriceRulePackageId,
468
+ resolveRuleFunction: resolveFloorPriceRule
469
+ });
470
+ }
471
+ return rules2;
472
+ }
473
+ var testnetRules = getBaseRules({
474
+ royaltyRulePackageId: ROYALTY_RULE_ADDRESS["testnet" /* TESTNET */],
475
+ kioskLockRulePackageId: KIOSK_LOCK_RULE_ADDRESS["testnet" /* TESTNET */],
476
+ personalKioskRulePackageId: PERSONAL_KIOSK_RULE_ADDRESS["testnet" /* TESTNET */],
477
+ floorPriceRulePackageId: FLOOR_PRICE_RULE_ADDRESS["testnet" /* TESTNET */]
478
+ });
479
+ var mainnetRules = getBaseRules({
480
+ royaltyRulePackageId: ROYALTY_RULE_ADDRESS["mainnet" /* MAINNET */],
481
+ kioskLockRulePackageId: KIOSK_LOCK_RULE_ADDRESS["mainnet" /* MAINNET */]
482
+ });
483
+ var rules = [...testnetRules, ...mainnetRules];
421
484
 
422
485
  // src/query/kiosk.ts
423
486
  import { isValidSuiAddress } from "@mysten/sui.js/utils";
@@ -425,20 +488,22 @@ async function fetchKiosk(client, kioskId, pagination, options) {
425
488
  const data = await getAllDynamicFields(client, kioskId, pagination);
426
489
  const listings = [];
427
490
  const lockedItemIds = [];
428
- const kioskData = extractKioskData(data, listings, lockedItemIds);
429
- const [kiosk, listingObjects] = await Promise.all([
491
+ const kioskData = extractKioskData(data, listings, lockedItemIds, kioskId);
492
+ const [kiosk, listingObjects, items] = await Promise.all([
430
493
  options.withKioskFields ? getKioskObject(client, kioskId) : Promise.resolve(void 0),
431
- options.withListingPrices ? client.multiGetObjects({
432
- ids: kioskData.listingIds,
433
- options: {
434
- showContent: true
435
- }
436
- }) : Promise.resolve([])
494
+ options.withListingPrices ? getAllObjects(client, kioskData.listingIds, {
495
+ showContent: true
496
+ }) : Promise.resolve([]),
497
+ options.withObjects ? getAllObjects(client, kioskData.itemIds, options.objectOptions || { showDisplay: true }) : Promise.resolve([])
437
498
  ]);
438
499
  if (options.withKioskFields)
439
500
  kioskData.kiosk = kiosk;
440
501
  attachListingsAndPrices(kioskData, listings, listingObjects);
441
502
  attachLockedItems(kioskData, lockedItemIds);
503
+ attachObjects(
504
+ kioskData,
505
+ items.filter((x) => !!x.data).map((x) => x.data)
506
+ );
442
507
  return {
443
508
  data: kioskData,
444
509
  nextCursor: null,
@@ -453,23 +518,37 @@ async function getOwnedKiosks(client, address, options) {
453
518
  kioskOwnerCaps: [],
454
519
  kioskIds: []
455
520
  };
521
+ const filter = {
522
+ MatchAny: [
523
+ {
524
+ StructType: KIOSK_OWNER_CAP
525
+ }
526
+ ]
527
+ };
528
+ if (options?.personalKioskType) {
529
+ filter.MatchAny.push({
530
+ StructType: options.personalKioskType
531
+ });
532
+ }
456
533
  const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({
457
534
  owner: address,
458
- filter: { StructType: KIOSK_OWNER_CAP },
535
+ filter,
459
536
  options: {
460
- showContent: true
537
+ showContent: true,
538
+ showType: true
461
539
  },
462
540
  ...options?.pagination || {}
463
541
  });
464
542
  const kioskIdList = data?.map((x) => {
465
543
  const fields = x.data?.content?.dataType === "moveObject" ? x.data.content.fields : null;
466
- return fields?.for;
544
+ return fields?.cap ? fields?.cap?.fields?.for : fields?.for;
467
545
  });
468
546
  const filteredData = data.filter((x) => "data" in x).map((x) => x.data);
469
547
  return {
470
548
  nextCursor,
471
549
  hasNextPage,
472
550
  kioskOwnerCaps: filteredData.map((x, idx) => ({
551
+ isPersonal: x.type !== KIOSK_OWNER_CAP,
473
552
  digest: x.digest,
474
553
  version: x.version,
475
554
  objectId: x.objectId,
@@ -480,6 +559,7 @@ async function getOwnedKiosks(client, address, options) {
480
559
  }
481
560
 
482
561
  // src/query/transfer-policy.ts
562
+ import { isValidSuiAddress as isValidSuiAddress2 } from "@mysten/sui.js/utils";
483
563
  async function queryTransferPolicy(client, type) {
484
564
  const { data } = await client.queryEvents({
485
565
  query: {
@@ -495,7 +575,7 @@ async function queryTransferPolicy(client, type) {
495
575
  if (!policy || !policy.bcs || !("bcsBytes" in policy.bcs)) {
496
576
  throw new Error(`Invalid policy: ${policy?.objectId}, expected object, got package`);
497
577
  }
498
- let parsed = bcs.de(TRANSFER_POLICY_TYPE, policy.bcs.bcsBytes, "base64");
578
+ const parsed = bcs.de(TRANSFER_POLICY_TYPE, policy.bcs.bcsBytes, "base64");
499
579
  return {
500
580
  id: policy?.objectId,
501
581
  type: `${TRANSFER_POLICY_TYPE}<${type}>`,
@@ -505,60 +585,987 @@ async function queryTransferPolicy(client, type) {
505
585
  };
506
586
  });
507
587
  }
588
+ async function queryTransferPolicyCapsByType(client, address, type) {
589
+ if (!isValidSuiAddress2(address))
590
+ return [];
591
+ const filter = {
592
+ MatchAll: [
593
+ {
594
+ StructType: `${TRANSFER_POLICY_CAP_TYPE}<${type}>`
595
+ }
596
+ ]
597
+ };
598
+ const data = await getAllOwnedObjects({
599
+ client,
600
+ filter,
601
+ owner: address
602
+ });
603
+ return data.map((item) => parseTransferPolicyCapObject(item)).filter((item) => !!item);
604
+ }
605
+ async function queryOwnedTransferPolicies(client, address) {
606
+ if (!isValidSuiAddress2(address))
607
+ return;
608
+ const filter = {
609
+ MatchAll: [
610
+ {
611
+ MoveModule: {
612
+ module: "transfer_policy",
613
+ package: "0x2"
614
+ }
615
+ }
616
+ ]
617
+ };
618
+ const data = await getAllOwnedObjects({ client, owner: address, filter });
619
+ const policies = [];
620
+ for (const item of data) {
621
+ const data2 = parseTransferPolicyCapObject(item);
622
+ if (data2)
623
+ policies.push(data2);
624
+ }
625
+ return policies;
626
+ }
627
+
628
+ // src/client/kiosk-client.ts
629
+ var KioskClient = class {
630
+ constructor(options) {
631
+ this.client = options.client;
632
+ this.network = options.network;
633
+ this.rules = rules;
634
+ this.packageIds = options.packageIds;
635
+ if (options.packageIds)
636
+ this.rules.push(...getBaseRules(options.packageIds));
637
+ }
638
+ /// Querying
639
+ /**
640
+ * Get an addresses's owned kiosks.
641
+ * @param address The address for which we want to retrieve the kiosks.
642
+ * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.
643
+ */
644
+ async getOwnedKiosks({ address }) {
645
+ const personalPackageId = this.packageIds?.personalKioskRulePackageId || PERSONAL_KIOSK_RULE_ADDRESS[this.network];
646
+ return getOwnedKiosks(this.client, address, {
647
+ personalKioskType: personalPackageId ? `${personalPackageId}::personal_kiosk::PersonalKioskCap` : ""
648
+ });
649
+ }
650
+ /**
651
+ * Fetches the kiosk contents.
652
+ * @param kioskId The ID of the kiosk to fetch.
653
+ * @param options Optioal
654
+ * @returns
655
+ */
656
+ async getKiosk({ id, options }) {
657
+ return (await fetchKiosk(
658
+ this.client,
659
+ id,
660
+ {
661
+ limit: 1e3
662
+ },
663
+ options || {}
664
+ )).data;
665
+ }
666
+ /**
667
+ * Query the Transfer Policy(ies) for type `T`.
668
+ * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)
669
+ */
670
+ async getTransferPolicies({ type }) {
671
+ return queryTransferPolicy(this.client, type);
672
+ }
673
+ /**
674
+ * Query all the owned transfer policies for an address.
675
+ * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.
676
+ * @param address The address we're searching the owned transfer policies for.
677
+ */
678
+ async getOwnedTransferPolicies({ address }) {
679
+ return queryOwnedTransferPolicies(this.client, address);
680
+ }
681
+ /**
682
+ * Query the Transfer Policy Cap for type `T`, owned by `address`
683
+ * @param type The Type `T` for the object
684
+ * @param address The address that owns the cap.
685
+ */
686
+ async getOwnedTransferPoliciesByType({ type, address }) {
687
+ return queryTransferPolicyCapsByType(this.client, address, type);
688
+ }
689
+ // Someone would just have to create a `kiosk-client.ts` file in their project, initialize a KioskClient
690
+ // and call the `addRuleResolver` function. Each rule has a `resolve` function.
691
+ // The resolve function is automatically called on `purchaseAndResolve` function call.
692
+ addRuleResolver(rule) {
693
+ if (this.rules.find((x) => x.rule === rule.rule))
694
+ throw new Error(`Rule ${rule.rule} resolver already exists.`);
695
+ this.rules.push(rule);
696
+ }
697
+ /**
698
+ * A convenient helper to get the packageIds for our supported ruleset,
699
+ * based on `kioskClient` configuration.
700
+ */
701
+ getRulePackageId(rule) {
702
+ const rules2 = this.packageIds || {};
703
+ const network = this.network;
704
+ if (!rules2[rule] && network !== "mainnet" /* MAINNET */ && network !== "testnet" /* TESTNET */) {
705
+ throw new Error(`Missing packageId for rule ${rule}`);
706
+ }
707
+ switch (rule) {
708
+ case "kioskLockRulePackageId":
709
+ return rules2[rule] || KIOSK_LOCK_RULE_ADDRESS[network];
710
+ case "royaltyRulePackageId":
711
+ return rules2[rule] || ROYALTY_RULE_ADDRESS[network];
712
+ case "personalKioskRulePackageId":
713
+ return rules2[rule] || PERSONAL_KIOSK_RULE_ADDRESS[network];
714
+ case "floorPriceRulePackageId":
715
+ return rules2[rule] || FLOOR_PRICE_RULE_ADDRESS[network];
716
+ }
717
+ }
718
+ };
719
+
720
+ // src/tx/rules/attach.ts
721
+ function attachKioskLockRuleTx(tx, type, policy, policyCap, packageId) {
722
+ tx.moveCall({
723
+ target: `${packageId}::kiosk_lock_rule::add`,
724
+ typeArguments: [type],
725
+ arguments: [objArg(tx, policy), objArg(tx, policyCap)]
726
+ });
727
+ }
728
+ function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmount, packageId) {
729
+ if (Number(percentageBps) < 0 || Number(percentageBps) > 1e4)
730
+ throw new Error("Invalid basis point percentage. Use a value between [0,10000].");
731
+ tx.moveCall({
732
+ target: `${packageId}::royalty_rule::add`,
733
+ typeArguments: [type],
734
+ arguments: [
735
+ objArg(tx, policy),
736
+ objArg(tx, policyCap),
737
+ tx.pure(percentageBps, "u16"),
738
+ tx.pure(minAmount, "u64")
739
+ ]
740
+ });
741
+ }
742
+ function attachPersonalKioskRuleTx(tx, type, policy, policyCap, packageId) {
743
+ tx.moveCall({
744
+ target: `${packageId}::personal_kiosk_rule::add`,
745
+ typeArguments: [type],
746
+ arguments: [objArg(tx, policy), objArg(tx, policyCap)]
747
+ });
748
+ }
749
+ function attachFloorPriceRuleTx(tx, type, policy, policyCap, minPrice, packageId) {
750
+ tx.moveCall({
751
+ target: `${packageId}::floor_price_rule::add`,
752
+ typeArguments: [type],
753
+ arguments: [objArg(tx, policy), objArg(tx, policyCap), tx.pure(minPrice, "u64")]
754
+ });
755
+ }
756
+
757
+ // src/tx/transfer-policy.ts
758
+ function createTransferPolicy(tx, itemType, publisher) {
759
+ const [transferPolicy, transferPolicyCap] = createTransferPolicyWithoutSharing(
760
+ tx,
761
+ itemType,
762
+ publisher
763
+ );
764
+ shareTransferPolicy(tx, itemType, transferPolicy);
765
+ return transferPolicyCap;
766
+ }
767
+ function createTransferPolicyWithoutSharing(tx, itemType, publisher) {
768
+ const [transferPolicy, transferPolicyCap] = tx.moveCall({
769
+ target: `${TRANSFER_POLICY_MODULE}::new`,
770
+ typeArguments: [itemType],
771
+ arguments: [objArg(tx, publisher)]
772
+ });
773
+ return [transferPolicy, transferPolicyCap];
774
+ }
775
+ function shareTransferPolicy(tx, itemType, transferPolicy) {
776
+ tx.moveCall({
777
+ target: `0x2::transfer::public_share_object`,
778
+ typeArguments: [`${TRANSFER_POLICY_TYPE}<${itemType}>`],
779
+ arguments: [transferPolicy]
780
+ });
781
+ }
782
+ function withdrawFromPolicy(tx, itemType, policy, policyCap, amount) {
783
+ const amountArg = tx.pure(amount ? { Some: amount } : { None: true }, "Option<u64>");
784
+ const [profits] = tx.moveCall({
785
+ target: `${TRANSFER_POLICY_MODULE}::withdraw`,
786
+ typeArguments: [itemType],
787
+ arguments: [objArg(tx, policy), objArg(tx, policyCap), amountArg]
788
+ });
789
+ return profits;
790
+ }
791
+ function confirmRequest(tx, itemType, policy, request) {
792
+ tx.moveCall({
793
+ target: `${TRANSFER_POLICY_MODULE}::confirm_request`,
794
+ typeArguments: [itemType],
795
+ arguments: [objArg(tx, policy), request]
796
+ });
797
+ }
798
+ function removeTransferPolicyRule(tx, itemType, ruleType, configType, policy, policyCap) {
799
+ tx.moveCall({
800
+ target: `${TRANSFER_POLICY_MODULE}::remove_rule`,
801
+ typeArguments: [itemType, ruleType, configType],
802
+ arguments: [objArg(tx, policy), objArg(tx, policyCap)]
803
+ });
804
+ }
805
+
806
+ // src/client/tp-transaction.ts
807
+ var _validateInputs, validateInputs_fn, _setup, setup_fn;
808
+ var TransferPolicyTransaction = class {
809
+ constructor({ kioskClient, transactionBlock, cap }) {
810
+ // Internal function that that the policy's Id + Cap + type have been set.
811
+ __privateAdd(this, _validateInputs);
812
+ /**
813
+ * Setup the state of the TransferPolicyTransaction.
814
+ */
815
+ __privateAdd(this, _setup);
816
+ this.kioskClient = kioskClient;
817
+ this.transactionBlock = transactionBlock;
818
+ if (cap)
819
+ this.setCap(cap);
820
+ }
821
+ /**
822
+ * A function to create a new transfer policy.
823
+ * Checks if there's already an existing transfer policy to prevent
824
+ * double transfer polciy mistakes.
825
+ * There's an optional `skipCheck` flag that will just create the policy
826
+ * without checking
827
+ *
828
+ * @param type The Type (`T`) for which we're creating the transfer policy.
829
+ * @param publisher The Publisher Object Id.
830
+ * @param address Address to save the `TransferPolicyCap` object to.
831
+ * @param skipCheck (Optional) skip checking if a transfer policy already exists
832
+ */
833
+ async createAndShare({
834
+ type,
835
+ publisher,
836
+ address,
837
+ skipCheck
838
+ }) {
839
+ if (!skipCheck) {
840
+ const policies = await this.kioskClient.getTransferPolicies({ type });
841
+ if (policies.length > 0)
842
+ throw new Error("There's already transfer policy for this Type.");
843
+ }
844
+ const cap = createTransferPolicy(this.transactionBlock, type, publisher);
845
+ this.transactionBlock.transferObjects([cap], this.transactionBlock.pure(address, "address"));
846
+ }
847
+ /**
848
+ * A convenient function to create a Transfer Policy and attach some rules
849
+ * before sharing it (so you can prepare it in a single PTB)
850
+ * @param type The Type (`T`) for which we're creating the transfer policy.
851
+ * @param publisher The Publisher Object Id.
852
+ * @param address Address to save the `TransferPolicyCap` object to.
853
+ * @param skipCheck (Optional) skip checking if a transfer policy already exists
854
+ */
855
+ async create({
856
+ type,
857
+ publisher,
858
+ skipCheck
859
+ }) {
860
+ if (!skipCheck) {
861
+ const policies = await this.kioskClient.getTransferPolicies({ type });
862
+ if (policies.length > 0)
863
+ throw new Error("There's already transfer policy for this Type.");
864
+ }
865
+ const [policy, policyCap] = createTransferPolicyWithoutSharing(
866
+ this.transactionBlock,
867
+ type,
868
+ publisher
869
+ );
870
+ __privateMethod(this, _setup, setup_fn).call(this, policy, policyCap, type);
871
+ return this;
872
+ }
873
+ /**
874
+ * This can be called after calling the `create` function to share the `TransferPolicy`,
875
+ * and transfer the `TransferPolicyCap` to the specified address
876
+ *
877
+ * @param address The address to transfer the `TransferPolicyCap`
878
+ */
879
+ shareAndTransferCap(address) {
880
+ if (!this.type || !this.policyCap || !this.policy)
881
+ throw new Error("This function can only be called after `transferPolicyManager.create`");
882
+ shareTransferPolicy(this.transactionBlock, this.type, this.policy);
883
+ this.transactionBlock.transferObjects(
884
+ [this.policyCap],
885
+ this.transactionBlock.pure(address, "address")
886
+ );
887
+ }
888
+ /**
889
+ * Setup the TransferPolicy by passing a `cap` returned from `kioskClient.getOwnedTransferPolicies` or
890
+ * `kioskClient.getOwnedTransferPoliciesByType`.
891
+ * @param policyCapId The `TransferPolicyCap`
892
+ */
893
+ setCap({ policyId, policyCapId, type }) {
894
+ return __privateMethod(this, _setup, setup_fn).call(this, policyId, policyCapId, type);
895
+ }
896
+ /**
897
+ * Withdraw from the transfer policy's profits.
898
+ * @param address Address to transfer the profits to.
899
+ * @param amount (Optional) amount parameter. Will withdraw all profits if the amount is not specified.
900
+ */
901
+ withdraw(address, amount) {
902
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
903
+ const coin = withdrawFromPolicy(
904
+ this.transactionBlock,
905
+ this.type,
906
+ this.policy,
907
+ this.policyCap,
908
+ amount
909
+ );
910
+ this.transactionBlock.transferObjects([coin], this.transactionBlock.pure(address, "address"));
911
+ return this;
912
+ }
913
+ /**
914
+ * Adds the Kiosk Royalty rule to the Transfer Policy.
915
+ * You can pass the percentage, as well as a minimum amount.
916
+ * The royalty that will be paid is the MAX(percentage, minAmount).
917
+ * You can pass 0 in either value if you want only percentage royalty, or a fixed amount fee.
918
+ * (but you should define at least one of them for the rule to make sense).
919
+ *
920
+ * @param percentageBps The royalty percentage in basis points. Use `percentageToBasisPoints` helper to convert from percentage [0,100].
921
+ * @param minAmount The minimum royalty amount per request in MIST.
922
+ */
923
+ addRoyaltyRule(percentageBps, minAmount) {
924
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
925
+ attachRoyaltyRuleTx(
926
+ this.transactionBlock,
927
+ this.type,
928
+ this.policy,
929
+ this.policyCap,
930
+ percentageBps,
931
+ minAmount,
932
+ this.kioskClient.getRulePackageId("royaltyRulePackageId")
933
+ );
934
+ return this;
935
+ }
936
+ /**
937
+ * Adds the Kiosk Lock Rule to the Transfer Policy.
938
+ * This Rule forces buyer to lock the item in the kiosk, preserving strong royalties.
939
+ */
940
+ addLockRule() {
941
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
942
+ attachKioskLockRuleTx(
943
+ this.transactionBlock,
944
+ this.type,
945
+ this.policy,
946
+ this.policyCap,
947
+ this.kioskClient.getRulePackageId("kioskLockRulePackageId")
948
+ );
949
+ return this;
950
+ }
951
+ /**
952
+ * Attaches the Personal Kiosk Rule, making a purchase valid only for `SoulBound` kiosks.
953
+ */
954
+ addPersonalKioskRule() {
955
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
956
+ attachPersonalKioskRuleTx(
957
+ this.transactionBlock,
958
+ this.type,
959
+ this.policy,
960
+ this.policyCap,
961
+ this.kioskClient.getRulePackageId("personalKioskRulePackageId")
962
+ );
963
+ return this;
964
+ }
965
+ /**
966
+ * A function to add the floor price rule to a transfer policy.
967
+ * @param minPrice The minimum price in MIST.
968
+ */
969
+ addFloorPriceRule(minPrice) {
970
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
971
+ attachFloorPriceRuleTx(
972
+ this.transactionBlock,
973
+ this.type,
974
+ this.policy,
975
+ this.policyCap,
976
+ minPrice,
977
+ this.kioskClient.getRulePackageId("floorPriceRulePackageId")
978
+ );
979
+ return this;
980
+ }
981
+ /**
982
+ * Generic helper to remove a rule, not from the SDK's base ruleset.
983
+ * @param ruleType The Rule Type
984
+ * @param configType The Config Type
985
+ */
986
+ removeRule({ ruleType, configType }) {
987
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
988
+ removeTransferPolicyRule(
989
+ this.transactionBlock,
990
+ this.type,
991
+ ruleType,
992
+ configType,
993
+ this.policy,
994
+ this.policyCap
995
+ );
996
+ }
997
+ /**
998
+ * Removes the lock rule.
999
+ */
1000
+ removeLockRule() {
1001
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
1002
+ const packageId = this.kioskClient.getRulePackageId("kioskLockRulePackageId");
1003
+ removeTransferPolicyRule(
1004
+ this.transactionBlock,
1005
+ this.type,
1006
+ `${packageId}::kiosk_lock_rule::Rule`,
1007
+ `${packageId}::kiosk_lock_rule::Config`,
1008
+ this.policy,
1009
+ this.policyCap
1010
+ );
1011
+ return this;
1012
+ }
1013
+ /**
1014
+ * Removes the Royalty rule
1015
+ */
1016
+ removeRoyaltyRule() {
1017
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
1018
+ const packageId = this.kioskClient.getRulePackageId("royaltyRulePackageId");
1019
+ removeTransferPolicyRule(
1020
+ this.transactionBlock,
1021
+ this.type,
1022
+ `${packageId}::royalty_rule::Rule`,
1023
+ `${packageId}::royalty_rule::Config`,
1024
+ this.policy,
1025
+ this.policyCap
1026
+ );
1027
+ return this;
1028
+ }
1029
+ removePersonalKioskRule() {
1030
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
1031
+ const packageId = this.kioskClient.getRulePackageId("personalKioskRulePackageId");
1032
+ removeTransferPolicyRule(
1033
+ this.transactionBlock,
1034
+ this.type,
1035
+ `${packageId}::personal_kiosk_rule::Rule`,
1036
+ `bool`,
1037
+ this.policy,
1038
+ this.policyCap
1039
+ );
1040
+ return this;
1041
+ }
1042
+ removeFloorPriceRule() {
1043
+ __privateMethod(this, _validateInputs, validateInputs_fn).call(this);
1044
+ const packageId = this.kioskClient.getRulePackageId("floorPriceRulePackageId");
1045
+ removeTransferPolicyRule(
1046
+ this.transactionBlock,
1047
+ this.type,
1048
+ `${packageId}::floor_price_rule::Rule`,
1049
+ `${packageId}::floor_price_rule::Config`,
1050
+ this.policy,
1051
+ this.policyCap
1052
+ );
1053
+ return this;
1054
+ }
1055
+ getPolicy() {
1056
+ if (!this.policy)
1057
+ throw new Error("Policy not set.");
1058
+ return this.policy;
1059
+ }
1060
+ getPolicyCap() {
1061
+ if (!this.policyCap)
1062
+ throw new Error("Transfer Policy Cap not set.");
1063
+ return this.policyCap;
1064
+ }
1065
+ };
1066
+ _validateInputs = new WeakSet();
1067
+ validateInputs_fn = function() {
1068
+ const genericErrorMessage = `Please use 'setCap()' to setup the TransferPolicy.`;
1069
+ if (!this.policy)
1070
+ throw new Error(`${genericErrorMessage} Missing: Transfer Policy Object.`);
1071
+ if (!this.policyCap)
1072
+ throw new Error(`${genericErrorMessage} Missing: TransferPolicyCap Object ID`);
1073
+ if (!this.type)
1074
+ throw new Error(
1075
+ `${genericErrorMessage} Missing: Transfer Policy object type (e.g. {packageId}::item::Item)`
1076
+ );
1077
+ };
1078
+ _setup = new WeakSet();
1079
+ setup_fn = function(policyId, policyCap, type) {
1080
+ this.policy = policyId;
1081
+ this.policyCap = policyCap;
1082
+ this.type = type;
1083
+ return this;
1084
+ };
1085
+
1086
+ // src/tx/personal-kiosk.ts
1087
+ function convertToPersonalTx(tx, kiosk, kioskOwnerCap, packageId) {
1088
+ const personalKioskCap = tx.moveCall({
1089
+ target: `${packageId}::personal_kiosk::new`,
1090
+ arguments: [objArg(tx, kiosk), objArg(tx, kioskOwnerCap)]
1091
+ });
1092
+ return personalKioskCap;
1093
+ }
1094
+ function transferPersonalCapTx(tx, personalKioskCap, packageId) {
1095
+ tx.moveCall({
1096
+ target: `${packageId}::personal_kiosk::transfer_to_sender`,
1097
+ arguments: [personalKioskCap]
1098
+ });
1099
+ }
1100
+
1101
+ // src/client/kiosk-transaction.ts
1102
+ var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _borrowFromPersonalCap, borrowFromPersonalCap_fn, _setPendingStatuses, setPendingStatuses_fn, _validateKioskIsSet, validateKioskIsSet_fn, _validateFinalizedStatus, validateFinalizedStatus_fn;
1103
+ var KioskTransaction = class {
1104
+ constructor({ transactionBlock, kioskClient, cap }) {
1105
+ /**
1106
+ * A function to borrow from `personalCap`.
1107
+ */
1108
+ __privateAdd(this, _borrowFromPersonalCap);
1109
+ __privateAdd(this, _setPendingStatuses);
1110
+ __privateAdd(this, _validateKioskIsSet);
1111
+ // Validates that `finalize`
1112
+ __privateAdd(this, _validateFinalizedStatus);
1113
+ // If we're pending `share` of a new kiosk, `finalize()` will share it.
1114
+ __privateAdd(this, _pendingShare, void 0);
1115
+ // If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.
1116
+ __privateAdd(this, _pendingTransfer, void 0);
1117
+ // The promise that the personalCap will be returned on `finalize()`.
1118
+ __privateAdd(this, _promise, void 0);
1119
+ // The personal kiosk argument.
1120
+ __privateAdd(this, _personalCap, void 0);
1121
+ // A flag that checks whether kiosk TX is finalized.
1122
+ __privateAdd(this, _finalized, false);
1123
+ this.transactionBlock = transactionBlock;
1124
+ this.kioskClient = kioskClient;
1125
+ if (cap)
1126
+ this.setCap(cap);
1127
+ }
1128
+ /**
1129
+ * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
1130
+ * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.
1131
+ * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
1132
+ */
1133
+ create() {
1134
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1135
+ __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, {
1136
+ share: true,
1137
+ transfer: true
1138
+ });
1139
+ const [kiosk, cap] = createKiosk(this.transactionBlock);
1140
+ this.kiosk = kiosk;
1141
+ this.kioskCap = cap;
1142
+ return this;
1143
+ }
1144
+ /**
1145
+ * Creates a personal kiosk & shares it.
1146
+ * The `PersonalKioskCap` is transferred to the signer.
1147
+ * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
1148
+ */
1149
+ createPersonal(borrow) {
1150
+ __privateSet(this, _pendingShare, true);
1151
+ return this.create().convertToPersonal(borrow);
1152
+ }
1153
+ /**
1154
+ * Converts a kiosk to a Personal (Soulbound) Kiosk.
1155
+ * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
1156
+ */
1157
+ convertToPersonal(borrow) {
1158
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1159
+ const cap = convertToPersonalTx(
1160
+ this.transactionBlock,
1161
+ this.kiosk,
1162
+ this.kioskCap,
1163
+ this.kioskClient.getRulePackageId("personalKioskRulePackageId")
1164
+ );
1165
+ if (borrow)
1166
+ __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap);
1167
+ else
1168
+ __privateSet(this, _personalCap, cap);
1169
+ __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: true });
1170
+ return this;
1171
+ }
1172
+ /**
1173
+ * Single function way to create a kiosk, share it and transfer the cap to the specified address.
1174
+ */
1175
+ createAndShare(address) {
1176
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1177
+ const cap = createKioskAndShare(this.transactionBlock);
1178
+ this.transactionBlock.transferObjects([cap], this.transactionBlock.pure(address, "address"));
1179
+ }
1180
+ /**
1181
+ * Shares the kiosk.
1182
+ */
1183
+ share() {
1184
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1185
+ __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { share: false });
1186
+ shareKiosk(this.transactionBlock, this.kiosk);
1187
+ }
1188
+ /**
1189
+ * Should be called only after `create` is called.
1190
+ * It shares the kiosk & transfers the cap to the specified address.
1191
+ */
1192
+ shareAndTransferCap(address) {
1193
+ if (__privateGet(this, _personalCap))
1194
+ throw new Error("You can only call `shareAndTransferCap` on a non-personal kiosk.");
1195
+ __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: false });
1196
+ this.share();
1197
+ this.transactionBlock.transferObjects(
1198
+ [this.kioskCap],
1199
+ this.transactionBlock.pure(address, "address")
1200
+ );
1201
+ }
1202
+ /**
1203
+ * A function to borrow an item from a kiosk & execute any function with it.
1204
+ * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
1205
+ */
1206
+ borrowTx({ itemType, itemId }, callback) {
1207
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1208
+ const [itemObj, promise] = borrowValue(
1209
+ this.transactionBlock,
1210
+ itemType,
1211
+ this.kiosk,
1212
+ this.kioskCap,
1213
+ itemId
1214
+ );
1215
+ callback(itemObj);
1216
+ this.return({ itemType, item: itemObj, promise });
1217
+ }
1218
+ /**
1219
+ * Borrows an item from the kiosk.
1220
+ * This will fail if the item is listed for sale.
1221
+ *
1222
+ * Requires calling `return`.
1223
+ */
1224
+ borrow({ itemType, itemId }) {
1225
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1226
+ const [itemObj, promise] = borrowValue(
1227
+ this.transactionBlock,
1228
+ itemType,
1229
+ this.kiosk,
1230
+ this.kioskCap,
1231
+ itemId
1232
+ );
1233
+ return [itemObj, promise];
1234
+ }
1235
+ /**
1236
+ * Returns the item back to the kiosk.
1237
+ * Accepts the parameters returned from the `borrow` function.
1238
+ */
1239
+ return({ itemType, item, promise }) {
1240
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1241
+ returnValue(this.transactionBlock, itemType, this.kiosk, item, promise);
1242
+ return this;
1243
+ }
1244
+ /**
1245
+ * A function to withdraw from kiosk
1246
+ * @param address Where to trasnfer the coin.
1247
+ * @param amount The amount we aim to withdraw.
1248
+ */
1249
+ withdraw(address, amount) {
1250
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1251
+ const coin = withdrawFromKiosk(
1252
+ this.transactionBlock,
1253
+ this.kiosk,
1254
+ this.kioskCap,
1255
+ amount
1256
+ );
1257
+ this.transactionBlock.transferObjects([coin], this.transactionBlock.pure(address, "address"));
1258
+ return this;
1259
+ }
1260
+ /**
1261
+ * A function to place an item in the kiosk.
1262
+ * @param itemType The type `T` of the item
1263
+ * @param item The ID or Transaction Argument of the item
1264
+ */
1265
+ place({ itemType, item }) {
1266
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1267
+ place(this.transactionBlock, itemType, this.kiosk, this.kioskCap, item);
1268
+ return this;
1269
+ }
1270
+ /**
1271
+ * A function to place an item in the kiosk and list it for sale in one transaction.
1272
+ * @param itemType The type `T` of the item
1273
+ * @param item The ID or Transaction Argument of the item
1274
+ * @param price The price in MIST
1275
+ */
1276
+ placeAndList({ itemType, item, price }) {
1277
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1278
+ placeAndList(this.transactionBlock, itemType, this.kiosk, this.kioskCap, item, price);
1279
+ return this;
1280
+ }
1281
+ /**
1282
+ * A function to list an item in the kiosk.
1283
+ * @param itemType The type `T` of the item
1284
+ * @param itemId The ID of the item
1285
+ * @param price The price in MIST
1286
+ */
1287
+ list({ itemType, itemId, price }) {
1288
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1289
+ list(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId, price);
1290
+ return this;
1291
+ }
1292
+ /**
1293
+ * A function to delist an item from the kiosk.
1294
+ * @param itemType The type `T` of the item
1295
+ * @param itemId The ID of the item
1296
+ */
1297
+ delist({ itemType, itemId }) {
1298
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1299
+ delist(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId);
1300
+ return this;
1301
+ }
1302
+ /**
1303
+ * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.
1304
+
1305
+ * @param itemType The type `T` of the item
1306
+ * @param itemId The ID of the item
1307
+ */
1308
+ take({ itemType, itemId }) {
1309
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1310
+ return take(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId);
1311
+ }
1312
+ /**
1313
+ * Transfer a non-locked/non-listed item to an address.
1314
+ *
1315
+ * @param itemType The type `T` of the item
1316
+ * @param itemId The ID of the item
1317
+ * @param address The destination address
1318
+ */
1319
+ transfer({ itemType, itemId, address }) {
1320
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1321
+ const item = this.take({ itemType, itemId });
1322
+ this.transactionBlock.transferObjects([item], this.transactionBlock.pure(address, "address"));
1323
+ return this;
1324
+ }
1325
+ /**
1326
+ * A function to take lock an item in the kiosk.
1327
+
1328
+ * @param itemType The type `T` of the item
1329
+ * @param itemId The ID of the item
1330
+ * @param policy The Policy ID or Transaction Argument for item T
1331
+ */
1332
+ lock({ itemType, itemId, policy }) {
1333
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1334
+ lock(this.transactionBlock, itemType, this.kiosk, this.kioskCap, policy, itemId);
1335
+ return this;
1336
+ }
1337
+ /**
1338
+ * Purchase an item from a seller's kiosk.
1339
+ * Returns [item, transferRequest]
1340
+ * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
1341
+ * @param itemType The type `T` of the item
1342
+ * @param itemId The ID of the item
1343
+ * @param price The price in MIST
1344
+ * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
1345
+ */
1346
+ purchase({
1347
+ itemType,
1348
+ itemId,
1349
+ price,
1350
+ sellerKiosk
1351
+ }) {
1352
+ const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [
1353
+ this.transactionBlock.pure(price, "u64")
1354
+ ]);
1355
+ return purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);
1356
+ }
1357
+ /**
1358
+ * A function to purchase and resolve a transfer policy.
1359
+ * If the transfer policy has the `lock` rule, the item is locked in the kiosk.
1360
+ * Otherwise, the item is placed in the kiosk.
1361
+ * @param itemType The type of the item
1362
+ * @param itemId The id of the item
1363
+ * @param price The price of the specified item
1364
+ * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
1365
+ * @param extraArgs Used to pass arguments for custom rule resolvers.
1366
+ */
1367
+ async purchaseAndResolve({
1368
+ itemType,
1369
+ itemId,
1370
+ price,
1371
+ sellerKiosk,
1372
+ extraArgs
1373
+ }) {
1374
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1375
+ const policies = await this.kioskClient.getTransferPolicies({ type: itemType });
1376
+ if (policies.length === 0) {
1377
+ throw new Error(
1378
+ `The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`
1379
+ );
1380
+ }
1381
+ const policy = policies[0];
1382
+ const [purchasedItem, transferRequest] = this.purchase({
1383
+ itemType,
1384
+ itemId,
1385
+ price,
1386
+ sellerKiosk
1387
+ });
1388
+ let canTransferOutsideKiosk = true;
1389
+ for (const rule of policy.rules) {
1390
+ const ruleDefinition = this.kioskClient.rules.find(
1391
+ (x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule)
1392
+ );
1393
+ if (!ruleDefinition)
1394
+ throw new Error(`No resolver for the following rule: ${rule}.`);
1395
+ if (ruleDefinition.hasLockingRule)
1396
+ canTransferOutsideKiosk = false;
1397
+ ruleDefinition.resolveRuleFunction({
1398
+ packageId: ruleDefinition.packageId,
1399
+ transactionBlock: this.transactionBlock,
1400
+ itemType,
1401
+ itemId,
1402
+ price: price.toString(),
1403
+ sellerKiosk,
1404
+ policyId: policy.id,
1405
+ transferRequest,
1406
+ purchasedItem,
1407
+ kiosk: this.kiosk,
1408
+ kioskCap: this.kioskCap,
1409
+ extraArgs: extraArgs || {}
1410
+ });
1411
+ }
1412
+ confirmRequest(this.transactionBlock, itemType, policy.id, transferRequest);
1413
+ if (canTransferOutsideKiosk)
1414
+ this.place({ itemType, item: purchasedItem });
1415
+ return this;
1416
+ }
1417
+ /**
1418
+ * A function to setup the client using an existing `ownerCap`,
1419
+ * as return from the `kioskClient.getOwnedKiosks` function.
1420
+ * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
1421
+ */
1422
+ setCap(cap) {
1423
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1424
+ this.kiosk = objArg(this.transactionBlock, cap.kioskId);
1425
+ if (!cap.isPersonal) {
1426
+ this.kioskCap = objArg(this.transactionBlock, cap.objectId);
1427
+ return;
1428
+ }
1429
+ return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
1430
+ }
1431
+ /**
1432
+ * A function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the
1433
+ * `PersonalKioskCap`, in case we are operating on a personal kiosk.
1434
+ * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
1435
+ */
1436
+ finalize() {
1437
+ __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1438
+ if (__privateGet(this, _pendingShare))
1439
+ this.share();
1440
+ if (!__privateGet(this, _personalCap)) {
1441
+ if (__privateGet(this, _pendingTransfer))
1442
+ throw new Error(
1443
+ "You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap"
1444
+ );
1445
+ return;
1446
+ }
1447
+ const packageId = this.kioskClient.getRulePackageId("personalKioskRulePackageId");
1448
+ if (__privateGet(this, _promise)) {
1449
+ this.transactionBlock.moveCall({
1450
+ target: `${packageId}::personal_kiosk::return_val`,
1451
+ arguments: [
1452
+ __privateGet(this, _personalCap),
1453
+ objArg(this.transactionBlock, this.kioskCap),
1454
+ __privateGet(this, _promise)
1455
+ ]
1456
+ });
1457
+ }
1458
+ if (__privateGet(this, _pendingTransfer))
1459
+ transferPersonalCapTx(this.transactionBlock, __privateGet(this, _personalCap), packageId);
1460
+ __privateSet(this, _finalized, true);
1461
+ }
1462
+ // Some setters in case we want custom behavior.
1463
+ setKioskCap(cap) {
1464
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1465
+ this.kioskCap = cap;
1466
+ return this;
1467
+ }
1468
+ setKiosk(kiosk) {
1469
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1470
+ this.kiosk = kiosk;
1471
+ return this;
1472
+ }
1473
+ // Some getters
1474
+ /*
1475
+ * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.
1476
+ */
1477
+ getKiosk() {
1478
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1479
+ if (!this.kiosk)
1480
+ throw new Error("Kiosk is not set.");
1481
+ return this.kiosk;
1482
+ }
1483
+ /*
1484
+ * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.
1485
+ */
1486
+ getKioskCap() {
1487
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1488
+ if (!this.kioskCap)
1489
+ throw new Error("Kiosk cap is not set");
1490
+ return this.kioskCap;
1491
+ }
1492
+ };
1493
+ _pendingShare = new WeakMap();
1494
+ _pendingTransfer = new WeakMap();
1495
+ _promise = new WeakMap();
1496
+ _personalCap = new WeakMap();
1497
+ _finalized = new WeakMap();
1498
+ _borrowFromPersonalCap = new WeakSet();
1499
+ borrowFromPersonalCap_fn = function(personalCap) {
1500
+ const [kioskCap, promise] = this.transactionBlock.moveCall({
1501
+ target: `${this.kioskClient.getRulePackageId(
1502
+ "personalKioskRulePackageId"
1503
+ )}::personal_kiosk::borrow_val`,
1504
+ arguments: [objArg(this.transactionBlock, personalCap)]
1505
+ });
1506
+ this.kioskCap = kioskCap;
1507
+ __privateSet(this, _personalCap, objArg(this.transactionBlock, personalCap));
1508
+ __privateSet(this, _promise, promise);
1509
+ return this;
1510
+ };
1511
+ _setPendingStatuses = new WeakSet();
1512
+ setPendingStatuses_fn = function({ share, transfer }) {
1513
+ if (transfer !== void 0)
1514
+ __privateSet(this, _pendingTransfer, transfer);
1515
+ if (share !== void 0)
1516
+ __privateSet(this, _pendingShare, share);
1517
+ };
1518
+ _validateKioskIsSet = new WeakSet();
1519
+ validateKioskIsSet_fn = function() {
1520
+ __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1521
+ if (!this.kiosk || !this.kioskCap)
1522
+ throw new Error(
1523
+ "You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`"
1524
+ );
1525
+ };
1526
+ _validateFinalizedStatus = new WeakSet();
1527
+ validateFinalizedStatus_fn = function() {
1528
+ if (__privateGet(this, _finalized))
1529
+ throw new Error("You can't add more transactions to a finalized kiosk transaction block.");
1530
+ };
508
1531
  export {
1532
+ FLOOR_PRICE_RULE_ADDRESS,
509
1533
  KIOSK_ITEM,
510
1534
  KIOSK_LISTING,
511
1535
  KIOSK_LOCK,
512
1536
  KIOSK_LOCK_RULE,
1537
+ KIOSK_LOCK_RULE_ADDRESS,
513
1538
  KIOSK_MODULE,
514
1539
  KIOSK_OWNER_CAP,
515
1540
  KIOSK_PURCHASE_CAP,
516
1541
  KIOSK_TYPE,
517
- MAINNET_RULES_PACKAGE_ADDRESS,
1542
+ KioskClient,
1543
+ KioskTransaction,
1544
+ Network,
1545
+ PERSONAL_KIOSK_RULE_ADDRESS,
518
1546
  ROYALTY_RULE,
519
- TESTNET_RULES_PACKAGE_ADDRESS,
1547
+ ROYALTY_RULE_ADDRESS,
1548
+ TRANSFER_POLICY_CAP_TYPE,
520
1549
  TRANSFER_POLICY_CREATED_EVENT,
521
1550
  TRANSFER_POLICY_MODULE,
522
1551
  TRANSFER_POLICY_TYPE,
523
- attachKioskLockRule,
1552
+ TransferPolicyTransaction,
524
1553
  attachListingsAndPrices,
525
1554
  attachLockedItems,
526
- attachRoyaltyRule,
527
- bcs,
528
- borrow,
529
- borrowMut,
530
- borrowValue,
531
- confirmRequest,
532
- createKiosk,
533
- createKioskAndShare,
534
- createTransferPolicy,
535
- customEnvironment,
536
- delist,
1555
+ attachObjects,
537
1556
  extractKioskData,
538
- fetchKiosk,
539
1557
  getAllDynamicFields,
1558
+ getAllObjects,
1559
+ getAllOwnedObjects,
1560
+ getBaseRules,
540
1561
  getKioskObject,
541
- getOwnedKiosks,
542
- getRulePackageAddress,
1562
+ getNormalizedRuleType,
543
1563
  getTypeWithoutPackageAddress,
544
- list,
545
- lock,
546
- mainnetEnvironment,
1564
+ mainnetRules,
547
1565
  objArg,
1566
+ parseTransferPolicyCapObject,
548
1567
  percentageToBasisPoints,
549
- place,
550
- placeAndList,
551
- purchase,
552
- purchaseAndResolvePolicies,
553
- queryTransferPolicy,
554
- removeTransferPolicyRule,
555
- resolveKioskLockRule,
556
- resolveRoyaltyRule,
557
- returnValue,
558
- rulesPackageAddresses,
559
- take,
560
- testnetEnvironment,
561
- withdrawFromKiosk,
562
- withdrawFromPolicy
1568
+ rules,
1569
+ testnetRules
563
1570
  };
564
1571
  //# sourceMappingURL=index.mjs.map