@iota/kiosk 0.1.1 → 0.2.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 (86) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/bcs.d.ts +38 -2
  4. package/dist/cjs/bcs.js +20 -18
  5. package/dist/cjs/bcs.js.map +2 -2
  6. package/dist/cjs/client/kiosk-client.d.ts +4 -2
  7. package/dist/cjs/client/kiosk-client.js +10 -5
  8. package/dist/cjs/client/kiosk-client.js.map +2 -2
  9. package/dist/cjs/client/kiosk-transaction.d.ts +11 -10
  10. package/dist/cjs/client/kiosk-transaction.js +102 -140
  11. package/dist/cjs/client/kiosk-transaction.js.map +2 -2
  12. package/dist/cjs/client/tp-transaction.d.ts +8 -6
  13. package/dist/cjs/client/tp-transaction.js +54 -65
  14. package/dist/cjs/client/tp-transaction.js.map +2 -2
  15. package/dist/cjs/constants.js.map +1 -1
  16. package/dist/cjs/query/kiosk.js +2 -4
  17. package/dist/cjs/query/kiosk.js.map +1 -1
  18. package/dist/cjs/query/transfer-policy.d.ts +1 -0
  19. package/dist/cjs/query/transfer-policy.js +5 -7
  20. package/dist/cjs/query/transfer-policy.js.map +3 -3
  21. package/dist/cjs/tx/kiosk.d.ts +14 -14
  22. package/dist/cjs/tx/kiosk.js.map +2 -2
  23. package/dist/cjs/tx/personal-kiosk.d.ts +3 -3
  24. package/dist/cjs/tx/personal-kiosk.js.map +2 -2
  25. package/dist/cjs/tx/rules/attach.d.ts +5 -5
  26. package/dist/cjs/tx/rules/attach.js.map +2 -2
  27. package/dist/cjs/tx/rules/resolve.js +18 -20
  28. package/dist/cjs/tx/rules/resolve.js.map +2 -2
  29. package/dist/cjs/tx/transfer-policy.d.ts +7 -7
  30. package/dist/cjs/tx/transfer-policy.js.map +2 -2
  31. package/dist/cjs/types/kiosk.d.ts +0 -1
  32. package/dist/cjs/types/kiosk.js.map +2 -2
  33. package/dist/cjs/types/transfer-policy.d.ts +4 -2
  34. package/dist/cjs/types/transfer-policy.js.map +2 -2
  35. package/dist/cjs/utils.js +4 -7
  36. package/dist/cjs/utils.js.map +2 -2
  37. package/dist/esm/bcs.d.ts +38 -2
  38. package/dist/esm/bcs.js +20 -18
  39. package/dist/esm/bcs.js.map +2 -2
  40. package/dist/esm/client/kiosk-client.d.ts +4 -2
  41. package/dist/esm/client/kiosk-client.js +10 -5
  42. package/dist/esm/client/kiosk-client.js.map +2 -2
  43. package/dist/esm/client/kiosk-transaction.d.ts +11 -10
  44. package/dist/esm/client/kiosk-transaction.js +101 -139
  45. package/dist/esm/client/kiosk-transaction.js.map +2 -2
  46. package/dist/esm/client/tp-transaction.d.ts +8 -6
  47. package/dist/esm/client/tp-transaction.js +53 -64
  48. package/dist/esm/client/tp-transaction.js.map +2 -2
  49. package/dist/esm/constants.js.map +1 -1
  50. package/dist/esm/query/kiosk.js +2 -4
  51. package/dist/esm/query/kiosk.js.map +1 -1
  52. package/dist/esm/query/transfer-policy.d.ts +1 -0
  53. package/dist/esm/query/transfer-policy.js +7 -9
  54. package/dist/esm/query/transfer-policy.js.map +2 -2
  55. package/dist/esm/tx/kiosk.d.ts +14 -14
  56. package/dist/esm/tx/kiosk.js.map +2 -2
  57. package/dist/esm/tx/personal-kiosk.d.ts +3 -3
  58. package/dist/esm/tx/personal-kiosk.js.map +2 -2
  59. package/dist/esm/tx/rules/attach.d.ts +5 -5
  60. package/dist/esm/tx/rules/attach.js.map +2 -2
  61. package/dist/esm/tx/rules/resolve.js +18 -20
  62. package/dist/esm/tx/rules/resolve.js.map +2 -2
  63. package/dist/esm/tx/transfer-policy.d.ts +7 -7
  64. package/dist/esm/tx/transfer-policy.js.map +2 -2
  65. package/dist/esm/types/kiosk.d.ts +0 -1
  66. package/dist/esm/types/kiosk.js.map +2 -2
  67. package/dist/esm/types/transfer-policy.d.ts +4 -2
  68. package/dist/esm/types/transfer-policy.js.map +2 -2
  69. package/dist/esm/utils.js +12 -10
  70. package/dist/esm/utils.js.map +2 -2
  71. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +12 -11
  74. package/src/bcs.ts +16 -19
  75. package/src/client/kiosk-client.ts +15 -5
  76. package/src/client/kiosk-transaction.ts +52 -56
  77. package/src/client/tp-transaction.ts +31 -28
  78. package/src/query/transfer-policy.ts +5 -3
  79. package/src/tx/kiosk.ts +14 -14
  80. package/src/tx/personal-kiosk.ts +3 -3
  81. package/src/tx/rules/attach.ts +5 -5
  82. package/src/tx/rules/resolve.ts +16 -16
  83. package/src/tx/transfer-policy.ts +7 -7
  84. package/src/types/kiosk.ts +0 -1
  85. package/src/types/transfer-policy.ts +4 -2
  86. package/src/utils.ts +10 -5
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,28 +29,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
29
  mod
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var __accessCheck = (obj, member, msg) => {
30
- if (!member.has(obj))
31
- throw TypeError("Cannot " + msg);
32
- };
33
- var __privateGet = (obj, member, getter) => {
34
- __accessCheck(obj, member, "read from private field");
35
- return getter ? getter.call(obj) : member.get(obj);
36
- };
37
- var __privateAdd = (obj, member, value) => {
38
- if (member.has(obj))
39
- throw TypeError("Cannot add the same private member more than once");
40
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
41
- };
42
- var __privateSet = (obj, member, value, setter) => {
43
- __accessCheck(obj, member, "write to private field");
44
- setter ? setter.call(obj, value) : member.set(obj, value);
45
- return value;
46
- };
47
- var __privateMethod = (obj, member, method) => {
48
- __accessCheck(obj, member, "access private method");
49
- return method;
50
- };
32
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
51
37
  var kiosk_transaction_exports = {};
52
38
  __export(kiosk_transaction_exports, {
53
39
  KioskTransaction: () => KioskTransaction
@@ -57,31 +43,28 @@ var kioskTx = __toESM(require("../tx/kiosk.js"));
57
43
  var import_personal_kiosk = require("../tx/personal-kiosk.js");
58
44
  var import_transfer_policy = require("../tx/transfer-policy.js");
59
45
  var import_utils = require("../utils.js");
60
- var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _borrowFromPersonalCap, borrowFromPersonalCap_fn, _setPendingStatuses, setPendingStatuses_fn, _validateKioskIsSet, validateKioskIsSet_fn, _validateFinalizedStatus, validateFinalizedStatus_fn;
46
+ var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _KioskTransaction_instances, borrowFromPersonalCap_fn, setPendingStatuses_fn, validateKioskIsSet_fn, validateFinalizedStatus_fn;
61
47
  class KioskTransaction {
62
- constructor({ transactionBlock, kioskClient, cap }) {
63
- /**
64
- * A function to borrow from `personalCap`.
65
- */
66
- __privateAdd(this, _borrowFromPersonalCap);
67
- __privateAdd(this, _setPendingStatuses);
68
- __privateAdd(this, _validateKioskIsSet);
69
- // Validates that `finalize`
70
- __privateAdd(this, _validateFinalizedStatus);
48
+ constructor({
49
+ transactionBlock,
50
+ transaction = transactionBlock,
51
+ kioskClient,
52
+ cap
53
+ }) {
54
+ __privateAdd(this, _KioskTransaction_instances);
71
55
  // If we're pending `share` of a new kiosk, `finalize()` will share it.
72
- __privateAdd(this, _pendingShare, void 0);
56
+ __privateAdd(this, _pendingShare);
73
57
  // If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.
74
- __privateAdd(this, _pendingTransfer, void 0);
58
+ __privateAdd(this, _pendingTransfer);
75
59
  // The promise that the personalCap will be returned on `finalize()`.
76
- __privateAdd(this, _promise, void 0);
60
+ __privateAdd(this, _promise);
77
61
  // The personal kiosk argument.
78
- __privateAdd(this, _personalCap, void 0);
62
+ __privateAdd(this, _personalCap);
79
63
  // A flag that checks whether kiosk TX is finalized.
80
64
  __privateAdd(this, _finalized, false);
81
- this.transactionBlock = transactionBlock;
65
+ this.transaction = transaction;
82
66
  this.kioskClient = kioskClient;
83
- if (cap)
84
- this.setCap(cap);
67
+ if (cap) this.setCap(cap);
85
68
  }
86
69
  /**
87
70
  * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
@@ -89,12 +72,12 @@ class KioskTransaction {
89
72
  * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
90
73
  */
91
74
  create() {
92
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
93
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, {
75
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
76
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, {
94
77
  share: true,
95
78
  transfer: true
96
79
  });
97
- const [kiosk, cap] = kioskTx.createKiosk(this.transactionBlock);
80
+ const [kiosk, cap] = kioskTx.createKiosk(this.transaction);
98
81
  this.kiosk = kiosk;
99
82
  this.kioskCap = cap;
100
83
  return this;
@@ -113,35 +96,33 @@ class KioskTransaction {
113
96
  * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
114
97
  */
115
98
  convertToPersonal(borrow) {
116
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
99
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
117
100
  const cap = (0, import_personal_kiosk.convertToPersonalTx)(
118
- this.transactionBlock,
101
+ this.transaction,
119
102
  this.kiosk,
120
103
  this.kioskCap,
121
104
  this.kioskClient.getRulePackageId("personalKioskRulePackageId")
122
105
  );
123
- if (borrow)
124
- __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap);
125
- else
126
- __privateSet(this, _personalCap, cap);
127
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: true });
106
+ if (borrow) __privateMethod(this, _KioskTransaction_instances, borrowFromPersonalCap_fn).call(this, cap);
107
+ else __privateSet(this, _personalCap, cap);
108
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { transfer: true });
128
109
  return this;
129
110
  }
130
111
  /**
131
112
  * Single function way to create a kiosk, share it and transfer the cap to the specified address.
132
113
  */
133
114
  createAndShare(address) {
134
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
135
- const cap = kioskTx.createKioskAndShare(this.transactionBlock);
136
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
115
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
116
+ const cap = kioskTx.createKioskAndShare(this.transaction);
117
+ this.transaction.transferObjects([cap], this.transaction.pure.address(address));
137
118
  }
138
119
  /**
139
120
  * Shares the kiosk.
140
121
  */
141
122
  share() {
142
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
143
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { share: false });
144
- kioskTx.shareKiosk(this.transactionBlock, this.kiosk);
123
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
124
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { share: false });
125
+ kioskTx.shareKiosk(this.transaction, this.kiosk);
145
126
  }
146
127
  /**
147
128
  * Should be called only after `create` is called.
@@ -150,21 +131,17 @@ class KioskTransaction {
150
131
  shareAndTransferCap(address) {
151
132
  if (__privateGet(this, _personalCap))
152
133
  throw new Error("You can only call `shareAndTransferCap` on a non-personal kiosk.");
153
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: false });
134
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { transfer: false });
154
135
  this.share();
155
- this.transactionBlock.transferObjects(
156
- [this.kioskCap],
157
- this.transactionBlock.pure.address(address)
158
- );
136
+ this.transaction.transferObjects([this.kioskCap], this.transaction.pure.address(address));
159
137
  }
160
138
  /**
161
139
  * A function to borrow an item from a kiosk & execute any function with it.
162
- * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
163
140
  */
164
141
  borrowTx({ itemType, itemId }, callback) {
165
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
142
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
166
143
  const [itemObj, promise] = kioskTx.borrowValue(
167
- this.transactionBlock,
144
+ this.transaction,
168
145
  itemType,
169
146
  this.kiosk,
170
147
  this.kioskCap,
@@ -180,9 +157,9 @@ class KioskTransaction {
180
157
  * Requires calling `return`.
181
158
  */
182
159
  borrow({ itemType, itemId }) {
183
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
160
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
184
161
  const [itemObj, promise] = kioskTx.borrowValue(
185
- this.transactionBlock,
162
+ this.transaction,
186
163
  itemType,
187
164
  this.kiosk,
188
165
  this.kioskCap,
@@ -195,8 +172,8 @@ class KioskTransaction {
195
172
  * Accepts the parameters returned from the `borrow` function.
196
173
  */
197
174
  return({ itemType, item, promise }) {
198
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
199
- kioskTx.returnValue(this.transactionBlock, itemType, this.kiosk, item, promise);
175
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
176
+ kioskTx.returnValue(this.transaction, itemType, this.kiosk, item, promise);
200
177
  return this;
201
178
  }
202
179
  /**
@@ -205,14 +182,14 @@ class KioskTransaction {
205
182
  * @param amount The amount we aim to withdraw.
206
183
  */
207
184
  withdraw(address, amount) {
208
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
185
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
209
186
  const coin = kioskTx.withdrawFromKiosk(
210
- this.transactionBlock,
187
+ this.transaction,
211
188
  this.kiosk,
212
189
  this.kioskCap,
213
190
  amount
214
191
  );
215
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
192
+ this.transaction.transferObjects([coin], this.transaction.pure.address(address));
216
193
  return this;
217
194
  }
218
195
  /**
@@ -221,37 +198,30 @@ class KioskTransaction {
221
198
  * @param item The ID or Transaction Argument of the item
222
199
  */
223
200
  place({ itemType, item }) {
224
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
225
- kioskTx.place(this.transactionBlock, itemType, this.kiosk, this.kioskCap, item);
201
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
202
+ kioskTx.place(this.transaction, itemType, this.kiosk, this.kioskCap, item);
226
203
  return this;
227
204
  }
228
205
  /**
229
206
  * A function to place an item in the kiosk and list it for sale in one transaction.
230
207
  * @param itemType The type `T` of the item
231
208
  * @param item The ID or Transaction Argument of the item
232
- * @param price The price in nano
209
+ * @param price The price in NANOS
233
210
  */
234
211
  placeAndList({ itemType, item, price }) {
235
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
236
- kioskTx.placeAndList(
237
- this.transactionBlock,
238
- itemType,
239
- this.kiosk,
240
- this.kioskCap,
241
- item,
242
- price
243
- );
212
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
213
+ kioskTx.placeAndList(this.transaction, itemType, this.kiosk, this.kioskCap, item, price);
244
214
  return this;
245
215
  }
246
216
  /**
247
217
  * A function to list an item in the kiosk.
248
218
  * @param itemType The type `T` of the item
249
219
  * @param itemId The ID of the item
250
- * @param price The price in nano
220
+ * @param price The price in NANOS
251
221
  */
252
222
  list({ itemType, itemId, price }) {
253
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
254
- kioskTx.list(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId, price);
223
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
224
+ kioskTx.list(this.transaction, itemType, this.kiosk, this.kioskCap, itemId, price);
255
225
  return this;
256
226
  }
257
227
  /**
@@ -260,8 +230,8 @@ class KioskTransaction {
260
230
  * @param itemId The ID of the item
261
231
  */
262
232
  delist({ itemType, itemId }) {
263
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
264
- kioskTx.delist(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId);
233
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
234
+ kioskTx.delist(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
265
235
  return this;
266
236
  }
267
237
  /**
@@ -271,8 +241,8 @@ class KioskTransaction {
271
241
  * @param itemId The ID of the item
272
242
  */
273
243
  take({ itemType, itemId }) {
274
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
275
- return kioskTx.take(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId);
244
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
245
+ return kioskTx.take(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
276
246
  }
277
247
  /**
278
248
  * Transfer a non-locked/non-listed item to an address.
@@ -282,9 +252,9 @@ class KioskTransaction {
282
252
  * @param address The destination address
283
253
  */
284
254
  transfer({ itemType, itemId, address }) {
285
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
255
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
286
256
  const item = this.take({ itemType, itemId });
287
- this.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));
257
+ this.transaction.transferObjects([item], this.transaction.pure.address(address));
288
258
  return this;
289
259
  }
290
260
  /**
@@ -301,9 +271,9 @@ class KioskTransaction {
301
271
  itemId,
302
272
  policy
303
273
  }) {
304
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
274
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
305
275
  kioskTx.lock(
306
- this.transactionBlock,
276
+ this.transaction,
307
277
  itemType,
308
278
  this.kiosk,
309
279
  this.kioskCap,
@@ -318,7 +288,7 @@ class KioskTransaction {
318
288
  * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
319
289
  * @param itemType The type `T` of the item
320
290
  * @param itemId The ID of the item
321
- * @param price The price in nano
291
+ * @param price The price in NANOS
322
292
  * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
323
293
  */
324
294
  purchase({
@@ -327,10 +297,10 @@ class KioskTransaction {
327
297
  price,
328
298
  sellerKiosk
329
299
  }) {
330
- const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [
331
- this.transactionBlock.pure.u64(price)
300
+ const coin = this.transaction.splitCoins(this.transaction.gas, [
301
+ this.transaction.pure.u64(price)
332
302
  ]);
333
- return kioskTx.purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);
303
+ return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);
334
304
  }
335
305
  /**
336
306
  * A function to purchase and resolve a transfer policy.
@@ -349,7 +319,7 @@ class KioskTransaction {
349
319
  sellerKiosk,
350
320
  extraArgs
351
321
  }) {
352
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
322
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
353
323
  const policies = await this.kioskClient.getTransferPolicies({ type: itemType });
354
324
  if (policies.length === 0) {
355
325
  throw new Error(
@@ -368,13 +338,12 @@ class KioskTransaction {
368
338
  const ruleDefinition = this.kioskClient.rules.find(
369
339
  (x) => (0, import_utils.getNormalizedRuleType)(x.rule) === (0, import_utils.getNormalizedRuleType)(rule)
370
340
  );
371
- if (!ruleDefinition)
372
- throw new Error(`No resolver for the following rule: ${rule}.`);
373
- if (ruleDefinition.hasLockingRule)
374
- canTransferOutsideKiosk = false;
341
+ if (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);
342
+ if (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;
375
343
  ruleDefinition.resolveRuleFunction({
376
344
  packageId: ruleDefinition.packageId,
377
- transactionBlock: this.transactionBlock,
345
+ transactionBlock: this.transaction,
346
+ transaction: this.transaction,
378
347
  itemType,
379
348
  itemId,
380
349
  price: price.toString(),
@@ -387,9 +356,8 @@ class KioskTransaction {
387
356
  extraArgs: extraArgs || {}
388
357
  });
389
358
  }
390
- (0, import_transfer_policy.confirmRequest)(this.transactionBlock, itemType, policy.id, transferRequest);
391
- if (canTransferOutsideKiosk)
392
- this.place({ itemType, item: purchasedItem });
359
+ (0, import_transfer_policy.confirmRequest)(this.transaction, itemType, policy.id, transferRequest);
360
+ if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });
393
361
  return this;
394
362
  }
395
363
  /**
@@ -398,23 +366,22 @@ class KioskTransaction {
398
366
  * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
399
367
  */
400
368
  setCap(cap) {
401
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
402
- this.kiosk = this.transactionBlock.object(cap.kioskId);
369
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
370
+ this.kiosk = this.transaction.object(cap.kioskId);
403
371
  if (!cap.isPersonal) {
404
- this.kioskCap = this.transactionBlock.object(cap.objectId);
372
+ this.kioskCap = this.transaction.object(cap.objectId);
405
373
  return;
406
374
  }
407
- return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
375
+ return __privateMethod(this, _KioskTransaction_instances, borrowFromPersonalCap_fn).call(this, cap.objectId);
408
376
  }
409
377
  /**
410
- * A function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the
378
+ * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
411
379
  * `PersonalKioskCap`, in case we are operating on a personal kiosk.
412
380
  * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
413
381
  */
414
382
  finalize() {
415
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
416
- if (__privateGet(this, _pendingShare))
417
- this.share();
383
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
384
+ if (__privateGet(this, _pendingShare)) this.share();
418
385
  if (!__privateGet(this, _personalCap)) {
419
386
  if (__privateGet(this, _pendingTransfer))
420
387
  throw new Error(
@@ -424,27 +391,27 @@ class KioskTransaction {
424
391
  }
425
392
  const packageId = this.kioskClient.getRulePackageId("personalKioskRulePackageId");
426
393
  if (__privateGet(this, _promise)) {
427
- this.transactionBlock.moveCall({
394
+ this.transaction.moveCall({
428
395
  target: `${packageId}::personal_kiosk::return_val`,
429
396
  arguments: [
430
397
  __privateGet(this, _personalCap),
431
- this.transactionBlock.object(this.kioskCap),
398
+ this.transaction.object(this.kioskCap),
432
399
  __privateGet(this, _promise)
433
400
  ]
434
401
  });
435
402
  }
436
403
  if (__privateGet(this, _pendingTransfer))
437
- (0, import_personal_kiosk.transferPersonalCapTx)(this.transactionBlock, __privateGet(this, _personalCap), packageId);
404
+ (0, import_personal_kiosk.transferPersonalCapTx)(this.transaction, __privateGet(this, _personalCap), packageId);
438
405
  __privateSet(this, _finalized, true);
439
406
  }
440
407
  // Some setters in case we want custom behavior.
441
408
  setKioskCap(cap) {
442
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
409
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
443
410
  this.kioskCap = cap;
444
411
  return this;
445
412
  }
446
413
  setKiosk(kiosk) {
447
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
414
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
448
415
  this.kiosk = kiosk;
449
416
  return this;
450
417
  }
@@ -453,18 +420,16 @@ class KioskTransaction {
453
420
  * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.
454
421
  */
455
422
  getKiosk() {
456
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
457
- if (!this.kiosk)
458
- throw new Error("Kiosk is not set.");
423
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
424
+ if (!this.kiosk) throw new Error("Kiosk is not set.");
459
425
  return this.kiosk;
460
426
  }
461
427
  /*
462
428
  * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.
463
429
  */
464
430
  getKioskCap() {
465
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
466
- if (!this.kioskCap)
467
- throw new Error("Kiosk cap is not set");
431
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
432
+ if (!this.kioskCap) throw new Error("Kiosk cap is not set");
468
433
  return this.kioskCap;
469
434
  }
470
435
  }
@@ -473,39 +438,36 @@ _pendingTransfer = new WeakMap();
473
438
  _promise = new WeakMap();
474
439
  _personalCap = new WeakMap();
475
440
  _finalized = new WeakMap();
476
- _borrowFromPersonalCap = new WeakSet();
441
+ _KioskTransaction_instances = new WeakSet();
442
+ /**
443
+ * A function to borrow from `personalCap`.
444
+ */
477
445
  borrowFromPersonalCap_fn = function(personalCap) {
478
- const [kioskCap, promise] = this.transactionBlock.moveCall({
446
+ const [kioskCap, promise] = this.transaction.moveCall({
479
447
  target: `${this.kioskClient.getRulePackageId(
480
448
  "personalKioskRulePackageId"
481
449
  )}::personal_kiosk::borrow_val`,
482
- arguments: [this.transactionBlock.object(personalCap)]
450
+ arguments: [this.transaction.object(personalCap)]
483
451
  });
484
452
  this.kioskCap = kioskCap;
485
- __privateSet(this, _personalCap, this.transactionBlock.object(personalCap));
453
+ __privateSet(this, _personalCap, this.transaction.object(personalCap));
486
454
  __privateSet(this, _promise, promise);
487
455
  return this;
488
456
  };
489
- _setPendingStatuses = new WeakSet();
490
457
  setPendingStatuses_fn = function({ share, transfer }) {
491
- if (transfer !== void 0)
492
- __privateSet(this, _pendingTransfer, transfer);
493
- if (share !== void 0)
494
- __privateSet(this, _pendingShare, share);
458
+ if (transfer !== void 0) __privateSet(this, _pendingTransfer, transfer);
459
+ if (share !== void 0) __privateSet(this, _pendingShare, share);
495
460
  };
496
- _validateKioskIsSet = new WeakSet();
497
461
  validateKioskIsSet_fn = function() {
498
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
462
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
499
463
  if (!this.kiosk || !this.kioskCap)
500
464
  throw new Error(
501
465
  "You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`"
502
466
  );
503
467
  };
504
- _validateFinalizedStatus = new WeakSet();
468
+ // Validates that `finalize`
505
469
  validateFinalizedStatus_fn = function() {
506
470
  if (__privateGet(this, _finalized))
507
- throw new Error(
508
- "You can't add more transactions to a finalized kiosk transaction block."
509
- );
471
+ throw new Error("You can't add more transactions to a finalized kiosk transaction.");
510
472
  };
511
473
  //# sourceMappingURL=kiosk-transaction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/client/kiosk-transaction.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n TransactionArgument,\n TransactionBlock,\n TransactionObjectArgument,\n} from '@iota/iota-sdk/transactions';\n\nimport * as kioskTx from '../tx/kiosk.js';\nimport { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';\nimport { confirmRequest } from '../tx/transfer-policy.js';\nimport type {\n ItemId,\n ItemReference,\n ItemValue,\n KioskOwnerCap,\n ObjectArgument,\n Price,\n PurchaseOptions,\n} from '../types/index.js';\nimport { getNormalizedRuleType } from '../utils.js';\nimport type { KioskClient } from './kiosk-client.js';\n\nexport type KioskTransactionParams = {\n /** The TransactionBlock for this run */\n transactionBlock: TransactionBlock;\n /**\n * You can create a new KioskClient by calling `new KioskClient()`\n */\n kioskClient: KioskClient;\n /**\n * You can optionally pass in the `cap` as returned\n * from `kioskClient.getOwnedKiosks` when initializing the client\n * Otherwise, you can set it by calling `kioskTransaction.setCap()`\n */\n cap?: KioskOwnerCap;\n};\n\n/**\n * A helper for building transactions that involve kiosk.\n */\nexport class KioskTransaction {\n transactionBlock: TransactionBlock;\n kioskClient: KioskClient;\n kiosk?: TransactionObjectArgument;\n kioskCap?: TransactionObjectArgument;\n // If we're pending `share` of a new kiosk, `finalize()` will share it.\n #pendingShare?: boolean;\n // If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.\n #pendingTransfer?: boolean;\n // The promise that the personalCap will be returned on `finalize()`.\n #promise?: TransactionArgument | undefined;\n // The personal kiosk argument.\n #personalCap?: TransactionObjectArgument;\n // A flag that checks whether kiosk TX is finalized.\n #finalized: boolean = false;\n\n constructor({ transactionBlock, kioskClient, cap }: KioskTransactionParams) {\n this.transactionBlock = transactionBlock;\n this.kioskClient = kioskClient;\n\n if (cap) this.setCap(cap);\n }\n\n /**\n * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.\n * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.\n * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n */\n create() {\n this.#validateFinalizedStatus();\n this.#setPendingStatuses({\n share: true,\n transfer: true,\n });\n const [kiosk, cap] = kioskTx.createKiosk(this.transactionBlock);\n this.kiosk = kiosk;\n this.kioskCap = cap;\n return this;\n }\n\n /**\n * Creates a personal kiosk & shares it.\n * The `PersonalKioskCap` is transferred to the signer.\n * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n */\n createPersonal(borrow?: boolean) {\n this.#pendingShare = true;\n return this.create().convertToPersonal(borrow);\n }\n\n /**\n * Converts a kiosk to a Personal (Soulbound) Kiosk.\n * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.\n */\n convertToPersonal(borrow?: boolean) {\n this.#validateKioskIsSet();\n\n const cap = convertToPersonalTx(\n this.transactionBlock,\n this.kiosk!,\n this.kioskCap!,\n this.kioskClient.getRulePackageId('personalKioskRulePackageId'),\n );\n\n // if we enable `borrow`, we borrow the kioskCap from the cap.\n if (borrow) this.#borrowFromPersonalCap(cap);\n else this.#personalCap = cap;\n\n this.#setPendingStatuses({ transfer: true });\n return this;\n }\n\n /**\n * Single function way to create a kiosk, share it and transfer the cap to the specified address.\n */\n createAndShare(address: string) {\n this.#validateFinalizedStatus();\n const cap = kioskTx.createKioskAndShare(this.transactionBlock);\n this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));\n }\n\n /**\n * Shares the kiosk.\n */\n share() {\n this.#validateKioskIsSet();\n this.#setPendingStatuses({ share: false });\n kioskTx.shareKiosk(this.transactionBlock, this.kiosk!);\n }\n\n /**\n * Should be called only after `create` is called.\n * It shares the kiosk & transfers the cap to the specified address.\n */\n shareAndTransferCap(address: string) {\n if (this.#personalCap)\n throw new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');\n this.#setPendingStatuses({ transfer: false });\n this.share();\n this.transactionBlock.transferObjects(\n [this.kioskCap!],\n this.transactionBlock.pure.address(address),\n );\n }\n\n /**\n * A function to borrow an item from a kiosk & execute any function with it.\n * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.\n */\n borrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {\n this.#validateKioskIsSet();\n const [itemObj, promise] = kioskTx.borrowValue(\n this.transactionBlock,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n itemId,\n );\n\n callback(itemObj);\n\n this.return({ itemType, item: itemObj, promise });\n }\n\n /**\n * Borrows an item from the kiosk.\n * This will fail if the item is listed for sale.\n *\n * Requires calling `return`.\n */\n borrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {\n this.#validateKioskIsSet();\n const [itemObj, promise] = kioskTx.borrowValue(\n this.transactionBlock,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n itemId,\n );\n\n return [itemObj, promise];\n }\n\n /**\n * Returns the item back to the kiosk.\n * Accepts the parameters returned from the `borrow` function.\n */\n return({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {\n this.#validateKioskIsSet();\n kioskTx.returnValue(this.transactionBlock, itemType, this.kiosk!, item, promise);\n return this;\n }\n\n /**\n * A function to withdraw from kiosk\n * @param address Where to transfer the coin.\n * @param amount The amount we aim to withdraw.\n */\n withdraw(address: string, amount?: string | bigint | number) {\n this.#validateKioskIsSet();\n const coin = kioskTx.withdrawFromKiosk(\n this.transactionBlock,\n this.kiosk!,\n this.kioskCap!,\n amount,\n );\n this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));\n return this;\n }\n\n /**\n * A function to place an item in the kiosk.\n * @param itemType The type `T` of the item\n * @param item The ID or Transaction Argument of the item\n */\n place({ itemType, item }: ItemReference) {\n this.#validateKioskIsSet();\n kioskTx.place(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, item);\n return this;\n }\n\n /**\n * A function to place an item in the kiosk and list it for sale in one transaction.\n * @param itemType The type `T` of the item\n * @param item The ID or Transaction Argument of the item\n * @param price The price in nano\n */\n placeAndList({ itemType, item, price }: ItemReference & Price) {\n this.#validateKioskIsSet();\n kioskTx.placeAndList(\n this.transactionBlock,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n item,\n price,\n );\n return this;\n }\n\n /**\n * A function to list an item in the kiosk.\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n * @param price The price in nano\n */\n list({ itemType, itemId, price }: ItemId & { price: string | bigint }) {\n this.#validateKioskIsSet();\n kioskTx.list(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId, price);\n return this;\n }\n\n /**\n * A function to delist an item from the kiosk.\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n */\n delist({ itemType, itemId }: ItemId) {\n this.#validateKioskIsSet();\n kioskTx.delist(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);\n return this;\n }\n\n /**\n\t * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.\n\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n take({ itemType, itemId }: ItemId): TransactionObjectArgument {\n this.#validateKioskIsSet();\n return kioskTx.take(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);\n }\n\n /**\n * Transfer a non-locked/non-listed item to an address.\n *\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n * @param address The destination address\n */\n transfer({ itemType, itemId, address }: ItemId & { address: string }) {\n this.#validateKioskIsSet();\n const item = this.take({ itemType, itemId });\n this.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));\n return this;\n }\n\n /**\n\t * A function to take lock an item in the kiosk.\n\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param itemId The ID of the item - Deprecated: Use `item` instead.\n\t * @param policy The Policy ID or Transaction Argument for item T\n\t */\n lock({\n itemType,\n item,\n itemId,\n policy,\n }: ItemReference & { policy: ObjectArgument; itemId?: string }) {\n this.#validateKioskIsSet();\n kioskTx.lock(\n this.transactionBlock,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n policy,\n itemId ?? item,\n );\n return this;\n }\n\n /**\n * Purchase an item from a seller's kiosk.\n * Returns [item, transferRequest]\n * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n * @param price The price in nano\n * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n */\n purchase({\n itemType,\n itemId,\n price,\n sellerKiosk,\n }: ItemId & Price & { sellerKiosk: ObjectArgument }): [\n TransactionObjectArgument,\n TransactionObjectArgument,\n ] {\n // Split the coin for the amount of the listing.\n const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [\n this.transactionBlock.pure.u64(price),\n ]);\n return kioskTx.purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);\n }\n\n /**\n * A function to purchase and resolve a transfer policy.\n * If the transfer policy has the `lock` rule, the item is locked in the kiosk.\n * Otherwise, the item is placed in the kiosk.\n * @param itemType The type of the item\n * @param itemId The id of the item\n * @param price The price of the specified item\n * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n * @param extraArgs Used to pass arguments for custom rule resolvers.\n */\n async purchaseAndResolve({\n itemType,\n itemId,\n price,\n sellerKiosk,\n extraArgs,\n }: ItemId & Price & { sellerKiosk: ObjectArgument } & PurchaseOptions) {\n this.#validateKioskIsSet();\n // Get a list of the transfer policies.\n const policies = await this.kioskClient.getTransferPolicies({ type: itemType });\n\n if (policies.length === 0) {\n throw new Error(\n `The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`,\n );\n }\n\n const policy = policies[0]; // we now pick the first one. We need to add an option to define which one.\n\n // initialize the purchase `kiosk::purchase`\n const [purchasedItem, transferRequest] = this.purchase({\n itemType,\n itemId,\n price,\n sellerKiosk,\n });\n\n let canTransferOutsideKiosk = true;\n\n for (const rule of policy.rules) {\n const ruleDefinition = this.kioskClient.rules.find(\n (x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule),\n );\n if (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);\n\n if (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;\n\n ruleDefinition.resolveRuleFunction({\n packageId: ruleDefinition.packageId,\n transactionBlock: this.transactionBlock,\n itemType,\n itemId,\n price: price.toString(),\n sellerKiosk,\n policyId: policy.id,\n transferRequest,\n purchasedItem,\n kiosk: this.kiosk!,\n kioskCap: this.kioskCap!,\n extraArgs: extraArgs || {},\n });\n }\n\n confirmRequest(this.transactionBlock, itemType, policy.id, transferRequest);\n\n if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });\n\n return this;\n }\n\n /**\n * A function to setup the client using an existing `ownerCap`,\n * as return from the `kioskClient.getOwnedKiosks` function.\n * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.\n */\n setCap(cap: KioskOwnerCap) {\n this.#validateFinalizedStatus();\n this.kiosk = this.transactionBlock.object(cap.kioskId);\n if (!cap.isPersonal) {\n this.kioskCap = this.transactionBlock.object(cap.objectId);\n return;\n }\n\n return this.#borrowFromPersonalCap(cap.objectId);\n }\n\n /**\n *\tA function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the\n * `PersonalKioskCap`, in case we are operating on a personal kiosk.\n * \tIt will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.\n */\n finalize() {\n this.#validateKioskIsSet();\n // If we're pending the sharing of the new kiosk, share it.\n if (this.#pendingShare) this.share();\n\n // If we're operating on a non-personal kiosk, we don't need to do anything else.\n if (!this.#personalCap) {\n // If we're pending transfer though, we inform user to call `shareAndTransferCap()`.\n if (this.#pendingTransfer)\n throw new Error(\n 'You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap',\n );\n return;\n }\n\n const packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n // if we have a promise, return the `ownerCap` back to the personal cap.\n if (this.#promise) {\n this.transactionBlock.moveCall({\n target: `${packageId}::personal_kiosk::return_val`,\n arguments: [\n this.#personalCap,\n this.transactionBlock.object(this.kioskCap!),\n this.#promise!,\n ],\n });\n }\n\n // If we are pending transferring the personalCap, we do it here.\n if (this.#pendingTransfer)\n transferPersonalCapTx(this.transactionBlock, this.#personalCap, packageId);\n\n // Mark the transaction block as finalized, so no other functions can be called.\n this.#finalized = true;\n }\n\n // Some setters in case we want custom behavior.\n setKioskCap(cap: TransactionObjectArgument) {\n this.#validateFinalizedStatus();\n this.kioskCap = cap;\n return this;\n }\n\n setKiosk(kiosk: TransactionObjectArgument) {\n this.#validateFinalizedStatus();\n this.kiosk = kiosk;\n return this;\n }\n\n // Some getters\n /*\n * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.\n */\n getKiosk() {\n this.#validateFinalizedStatus();\n if (!this.kiosk) throw new Error('Kiosk is not set.');\n return this.kiosk;\n }\n\n /*\n * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.\n */\n getKioskCap() {\n this.#validateFinalizedStatus();\n if (!this.kioskCap) throw new Error('Kiosk cap is not set');\n return this.kioskCap;\n }\n\n /**\n * A function to borrow from `personalCap`.\n */\n #borrowFromPersonalCap(personalCap: ObjectArgument) {\n const [kioskCap, promise] = this.transactionBlock.moveCall({\n target: `${this.kioskClient.getRulePackageId(\n 'personalKioskRulePackageId',\n )}::personal_kiosk::borrow_val`,\n arguments: [this.transactionBlock.object(personalCap)],\n });\n\n this.kioskCap = kioskCap;\n this.#personalCap = this.transactionBlock.object(personalCap);\n this.#promise = promise;\n\n return this;\n }\n\n #setPendingStatuses({ share, transfer }: { share?: boolean; transfer?: boolean }) {\n if (transfer !== undefined) this.#pendingTransfer = transfer;\n if (share !== undefined) this.#pendingShare = share;\n }\n\n #validateKioskIsSet() {\n this.#validateFinalizedStatus();\n\n if (!this.kiosk || !this.kioskCap)\n throw new Error(\n 'You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`',\n );\n }\n\n // Validates that `finalize`\n #validateFinalizedStatus() {\n if (this.#finalized)\n throw new Error(\n \"You can't add more transactions to a finalized kiosk transaction block.\",\n );\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,cAAyB;AACzB,4BAA2D;AAC3D,6BAA+B;AAU/B,mBAAsC;AAtBtC;AA2CO,MAAM,iBAAiB;AAAA,EAgB1B,YAAY,EAAE,kBAAkB,aAAa,IAAI,GAA2B;AA8b5E;AAAA;AAAA;AAAA;AAeA;AAKA;AAUA;AAAA;AAteA;AAAA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA,mCAAsB;AAGlB,SAAK,mBAAmB;AACxB,SAAK,cAAc;AAEnB,QAAI;AAAK,WAAK,OAAO,GAAG;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS;AACL,0BAAK,sDAAL;AACA,0BAAK,4CAAL,WAAyB;AAAA,MACrB,OAAO;AAAA,MACP,UAAU;AAAA,IACd;AACA,UAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,YAAY,KAAK,gBAAgB;AAC9D,SAAK,QAAQ;AACb,SAAK,WAAW;AAChB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,eAAe,QAAkB;AAC7B,uBAAK,eAAgB;AACrB,WAAO,KAAK,OAAO,EAAE,kBAAkB,MAAM;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,kBAAkB,QAAkB;AAChC,0BAAK,4CAAL;AAEA,UAAM,UAAM;AAAA,MACR,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,YAAY,iBAAiB,4BAA4B;AAAA,IAClE;AAGA,QAAI;AAAQ,4BAAK,kDAAL,WAA4B;AAAA;AACnC,yBAAK,cAAe;AAEzB,0BAAK,4CAAL,WAAyB,EAAE,UAAU,KA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AEA;AAEA;AAEA;AAgcA;AAAA,2BAAsB,SAAC,aAA6B;AAChD,QAAM,CAAC,UAAU,OAAO,IAAI,KAAK,iBAAiB,SAAS;AAAA,IACvD,QAAQ,GAAG,KAAK,YAAY;AAAA,MACxB;AAAA,IACJ;AAAA,IACA,WAAW,CAAC,KAAK,iBAAiB,OAAO,WAAW,CAAC;AAAA,EACzD,CAAC;AAED,OAAK,WAAW;AAChB,qBAAK,cAAe,KAAK,iBAAiB,OAAO,WAAW;AAC5D,qBAAK,UAAW;AAEhB,SAAO;AACX;AAEA;AAAA,wBAAmB,SAAC,EAAE,OAAO,SAAS,GAA4C;AAC9E,MAAI,aAAa;AAAW,uBAAK,kBAAmB;AACpD,MAAI,UAAU;AAAW,uBAAK,eAAgB;AAClD;AAEA;AAAA,wBAAmB,WAAG;AAClB,wBAAK,sDAAL;AAEA,MAAI,CAAC,KAAK,SAAS,CAAC,KAAK;AACrB,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AACR;AAGA;AAAA,6BAAwB,WAAG;AACvB,MAAI,mBAAK;AACL,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AACR;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n Transaction,\n TransactionArgument,\n TransactionObjectArgument,\n} from '@iota/iota-sdk/transactions';\n\nimport * as kioskTx from '../tx/kiosk.js';\nimport { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';\nimport { confirmRequest } from '../tx/transfer-policy.js';\nimport type {\n ItemId,\n ItemReference,\n ItemValue,\n KioskOwnerCap,\n ObjectArgument,\n Price,\n PurchaseOptions,\n} from '../types/index.js';\nimport { getNormalizedRuleType } from '../utils.js';\nimport type { KioskClient } from './kiosk-client.js';\n\nexport type KioskTransactionParams = {\n /** The Transaction for this run */\n transaction: Transaction;\n\n /** @deprecated use transaction instead */\n transactionBlock?: Transaction;\n /**\n * You can create a new KioskClient by calling `new KioskClient()`\n */\n kioskClient: KioskClient;\n /**\n * You can optionally pass in the `cap` as returned\n * from `kioskClient.getOwnedKiosks` when initializing the client\n * Otherwise, you can set it by calling `kioskTransaction.setCap()`\n */\n cap?: KioskOwnerCap;\n};\n\n/**\n * A helper for building transactions that involve kiosk.\n */\nexport class KioskTransaction {\n transaction: Transaction;\n kioskClient: KioskClient;\n kiosk?: TransactionObjectArgument;\n kioskCap?: TransactionObjectArgument;\n // If we're pending `share` of a new kiosk, `finalize()` will share it.\n #pendingShare?: boolean;\n // If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.\n #pendingTransfer?: boolean;\n // The promise that the personalCap will be returned on `finalize()`.\n #promise?: TransactionArgument | undefined;\n // The personal kiosk argument.\n #personalCap?: TransactionObjectArgument;\n // A flag that checks whether kiosk TX is finalized.\n #finalized: boolean = false;\n\n constructor({\n transactionBlock,\n transaction = transactionBlock!,\n kioskClient,\n cap,\n }: KioskTransactionParams) {\n this.transaction = transaction;\n this.kioskClient = kioskClient;\n\n if (cap) this.setCap(cap);\n }\n\n /**\n * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.\n * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.\n * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n */\n create() {\n this.#validateFinalizedStatus();\n this.#setPendingStatuses({\n share: true,\n transfer: true,\n });\n const [kiosk, cap] = kioskTx.createKiosk(this.transaction);\n this.kiosk = kiosk;\n this.kioskCap = cap;\n return this;\n }\n\n /**\n * Creates a personal kiosk & shares it.\n * The `PersonalKioskCap` is transferred to the signer.\n * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n */\n createPersonal(borrow?: boolean) {\n this.#pendingShare = true;\n return this.create().convertToPersonal(borrow);\n }\n\n /**\n * Converts a kiosk to a Personal (Soulbound) Kiosk.\n * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.\n */\n convertToPersonal(borrow?: boolean) {\n this.#validateKioskIsSet();\n\n const cap = convertToPersonalTx(\n this.transaction,\n this.kiosk!,\n this.kioskCap!,\n this.kioskClient.getRulePackageId('personalKioskRulePackageId'),\n );\n\n // if we enable `borrow`, we borrow the kioskCap from the cap.\n if (borrow) this.#borrowFromPersonalCap(cap);\n else this.#personalCap = cap;\n\n this.#setPendingStatuses({ transfer: true });\n return this;\n }\n\n /**\n * Single function way to create a kiosk, share it and transfer the cap to the specified address.\n */\n createAndShare(address: string) {\n this.#validateFinalizedStatus();\n const cap = kioskTx.createKioskAndShare(this.transaction);\n this.transaction.transferObjects([cap], this.transaction.pure.address(address));\n }\n\n /**\n * Shares the kiosk.\n */\n share() {\n this.#validateKioskIsSet();\n this.#setPendingStatuses({ share: false });\n kioskTx.shareKiosk(this.transaction, this.kiosk!);\n }\n\n /**\n * Should be called only after `create` is called.\n * It shares the kiosk & transfers the cap to the specified address.\n */\n shareAndTransferCap(address: string) {\n if (this.#personalCap)\n throw new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');\n this.#setPendingStatuses({ transfer: false });\n this.share();\n this.transaction.transferObjects([this.kioskCap!], this.transaction.pure.address(address));\n }\n\n /**\n * A function to borrow an item from a kiosk & execute any function with it.\n */\n borrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {\n this.#validateKioskIsSet();\n const [itemObj, promise] = kioskTx.borrowValue(\n this.transaction,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n itemId,\n );\n\n callback(itemObj);\n\n this.return({ itemType, item: itemObj, promise });\n }\n\n /**\n * Borrows an item from the kiosk.\n * This will fail if the item is listed for sale.\n *\n * Requires calling `return`.\n */\n borrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {\n this.#validateKioskIsSet();\n const [itemObj, promise] = kioskTx.borrowValue(\n this.transaction,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n itemId,\n );\n\n return [itemObj, promise];\n }\n\n /**\n * Returns the item back to the kiosk.\n * Accepts the parameters returned from the `borrow` function.\n */\n return({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {\n this.#validateKioskIsSet();\n kioskTx.returnValue(this.transaction, itemType, this.kiosk!, item, promise);\n return this;\n }\n\n /**\n * A function to withdraw from kiosk\n * @param address Where to transfer the coin.\n * @param amount The amount we aim to withdraw.\n */\n withdraw(address: string, amount?: string | bigint | number) {\n this.#validateKioskIsSet();\n const coin = kioskTx.withdrawFromKiosk(\n this.transaction,\n this.kiosk!,\n this.kioskCap!,\n amount,\n );\n this.transaction.transferObjects([coin], this.transaction.pure.address(address));\n return this;\n }\n\n /**\n * A function to place an item in the kiosk.\n * @param itemType The type `T` of the item\n * @param item The ID or Transaction Argument of the item\n */\n place({ itemType, item }: ItemReference) {\n this.#validateKioskIsSet();\n kioskTx.place(this.transaction, itemType, this.kiosk!, this.kioskCap!, item);\n return this;\n }\n\n /**\n * A function to place an item in the kiosk and list it for sale in one transaction.\n * @param itemType The type `T` of the item\n * @param item The ID or Transaction Argument of the item\n * @param price The price in NANOS\n */\n placeAndList({ itemType, item, price }: ItemReference & Price) {\n this.#validateKioskIsSet();\n kioskTx.placeAndList(this.transaction, itemType, this.kiosk!, this.kioskCap!, item, price);\n return this;\n }\n\n /**\n * A function to list an item in the kiosk.\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n * @param price The price in NANOS\n */\n list({ itemType, itemId, price }: ItemId & { price: string | bigint }) {\n this.#validateKioskIsSet();\n kioskTx.list(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId, price);\n return this;\n }\n\n /**\n * A function to delist an item from the kiosk.\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n */\n delist({ itemType, itemId }: ItemId) {\n this.#validateKioskIsSet();\n kioskTx.delist(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);\n return this;\n }\n\n /**\n\t * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.\n\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n take({ itemType, itemId }: ItemId): TransactionObjectArgument {\n this.#validateKioskIsSet();\n return kioskTx.take(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);\n }\n\n /**\n * Transfer a non-locked/non-listed item to an address.\n *\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n * @param address The destination address\n */\n transfer({ itemType, itemId, address }: ItemId & { address: string }) {\n this.#validateKioskIsSet();\n const item = this.take({ itemType, itemId });\n this.transaction.transferObjects([item], this.transaction.pure.address(address));\n return this;\n }\n\n /**\n\t * A function to take lock an item in the kiosk.\n\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param itemId The ID of the item - Deprecated: Use `item` instead.\n\t * @param policy The Policy ID or Transaction Argument for item T\n\t */\n lock({\n itemType,\n item,\n itemId,\n policy,\n }: ItemReference & { policy: ObjectArgument; itemId?: string }) {\n this.#validateKioskIsSet();\n kioskTx.lock(\n this.transaction,\n itemType,\n this.kiosk!,\n this.kioskCap!,\n policy,\n itemId ?? item,\n );\n return this;\n }\n\n /**\n * Purchase an item from a seller's kiosk.\n * Returns [item, transferRequest]\n * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`\n * @param itemType The type `T` of the item\n * @param itemId The ID of the item\n * @param price The price in NANOS\n * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n */\n purchase({\n itemType,\n itemId,\n price,\n sellerKiosk,\n }: ItemId & Price & { sellerKiosk: ObjectArgument }): [\n TransactionObjectArgument,\n TransactionObjectArgument,\n ] {\n // Split the coin for the amount of the listing.\n const coin = this.transaction.splitCoins(this.transaction.gas, [\n this.transaction.pure.u64(price),\n ]);\n return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);\n }\n\n /**\n * A function to purchase and resolve a transfer policy.\n * If the transfer policy has the `lock` rule, the item is locked in the kiosk.\n * Otherwise, the item is placed in the kiosk.\n * @param itemType The type of the item\n * @param itemId The id of the item\n * @param price The price of the specified item\n * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n * @param extraArgs Used to pass arguments for custom rule resolvers.\n */\n async purchaseAndResolve({\n itemType,\n itemId,\n price,\n sellerKiosk,\n extraArgs,\n }: ItemId & Price & { sellerKiosk: ObjectArgument } & PurchaseOptions) {\n this.#validateKioskIsSet();\n // Get a list of the transfer policies.\n const policies = await this.kioskClient.getTransferPolicies({ type: itemType });\n\n if (policies.length === 0) {\n throw new Error(\n `The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`,\n );\n }\n\n const policy = policies[0]; // we now pick the first one. We need to add an option to define which one.\n\n // initialize the purchase `kiosk::purchase`\n const [purchasedItem, transferRequest] = this.purchase({\n itemType,\n itemId,\n price,\n sellerKiosk,\n });\n\n let canTransferOutsideKiosk = true;\n\n for (const rule of policy.rules) {\n const ruleDefinition = this.kioskClient.rules.find(\n (x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule),\n );\n if (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);\n\n if (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;\n\n ruleDefinition.resolveRuleFunction({\n packageId: ruleDefinition.packageId,\n transactionBlock: this.transaction,\n transaction: this.transaction,\n itemType,\n itemId,\n price: price.toString(),\n sellerKiosk,\n policyId: policy.id,\n transferRequest,\n purchasedItem,\n kiosk: this.kiosk!,\n kioskCap: this.kioskCap!,\n extraArgs: extraArgs || {},\n });\n }\n\n confirmRequest(this.transaction, itemType, policy.id, transferRequest);\n\n if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });\n\n return this;\n }\n\n /**\n * A function to setup the client using an existing `ownerCap`,\n * as return from the `kioskClient.getOwnedKiosks` function.\n * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.\n */\n setCap(cap: KioskOwnerCap) {\n this.#validateFinalizedStatus();\n this.kiosk = this.transaction.object(cap.kioskId);\n if (!cap.isPersonal) {\n this.kioskCap = this.transaction.object(cap.objectId);\n return;\n }\n\n return this.#borrowFromPersonalCap(cap.objectId);\n }\n\n /**\n *\tA function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the\n * `PersonalKioskCap`, in case we are operating on a personal kiosk.\n * \tIt will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.\n */\n finalize() {\n this.#validateKioskIsSet();\n // If we're pending the sharing of the new kiosk, share it.\n if (this.#pendingShare) this.share();\n\n // If we're operating on a non-personal kiosk, we don't need to do anything else.\n if (!this.#personalCap) {\n // If we're pending transfer though, we inform user to call `shareAndTransferCap()`.\n if (this.#pendingTransfer)\n throw new Error(\n 'You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap',\n );\n return;\n }\n\n const packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n // if we have a promise, return the `ownerCap` back to the personal cap.\n if (this.#promise) {\n this.transaction.moveCall({\n target: `${packageId}::personal_kiosk::return_val`,\n arguments: [\n this.#personalCap,\n this.transaction.object(this.kioskCap!),\n this.#promise!,\n ],\n });\n }\n\n // If we are pending transferring the personalCap, we do it here.\n if (this.#pendingTransfer)\n transferPersonalCapTx(this.transaction, this.#personalCap, packageId);\n\n // Mark the transaction as finalized, so no other functions can be called.\n this.#finalized = true;\n }\n\n // Some setters in case we want custom behavior.\n setKioskCap(cap: TransactionObjectArgument) {\n this.#validateFinalizedStatus();\n this.kioskCap = cap;\n return this;\n }\n\n setKiosk(kiosk: TransactionObjectArgument) {\n this.#validateFinalizedStatus();\n this.kiosk = kiosk;\n return this;\n }\n\n // Some getters\n /*\n * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.\n */\n getKiosk() {\n this.#validateFinalizedStatus();\n if (!this.kiosk) throw new Error('Kiosk is not set.');\n return this.kiosk;\n }\n\n /*\n * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.\n */\n getKioskCap() {\n this.#validateFinalizedStatus();\n if (!this.kioskCap) throw new Error('Kiosk cap is not set');\n return this.kioskCap;\n }\n\n /**\n * A function to borrow from `personalCap`.\n */\n #borrowFromPersonalCap(personalCap: ObjectArgument) {\n const [kioskCap, promise] = this.transaction.moveCall({\n target: `${this.kioskClient.getRulePackageId(\n 'personalKioskRulePackageId',\n )}::personal_kiosk::borrow_val`,\n arguments: [this.transaction.object(personalCap)],\n });\n\n this.kioskCap = kioskCap;\n this.#personalCap = this.transaction.object(personalCap);\n this.#promise = promise;\n\n return this;\n }\n\n #setPendingStatuses({ share, transfer }: { share?: boolean; transfer?: boolean }) {\n if (transfer !== undefined) this.#pendingTransfer = transfer;\n if (share !== undefined) this.#pendingShare = share;\n }\n\n #validateKioskIsSet() {\n this.#validateFinalizedStatus();\n\n if (!this.kiosk || !this.kioskCap)\n throw new Error(\n 'You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`',\n );\n }\n\n // Validates that `finalize`\n #validateFinalizedStatus() {\n if (this.#finalized)\n throw new Error(\"You can't add more transactions to a finalized kiosk transaction.\");\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,cAAyB;AACzB,4BAA2D;AAC3D,6BAA+B;AAU/B,mBAAsC;AAtBtC;AA8CO,MAAM,iBAAiB;AAAA,EAgB1B,YAAY;AAAA,IACR;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACJ,GAA2B;AArBxB;AAMH;AAAA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA,mCAAsB;AAQlB,SAAK,cAAc;AACnB,SAAK,cAAc;AAEnB,QAAI,IAAK,MAAK,OAAO,GAAG;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS;AACL,0BAAK,yDAAL;AACA,0BAAK,oDAAL,WAAyB;AAAA,MACrB,OAAO;AAAA,MACP,UAAU;AAAA,IACd;AACA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