@iota/kiosk 0.1.2 → 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 +12 -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
@@ -1,54 +1,37 @@
1
- var __accessCheck = (obj, member, msg) => {
2
- if (!member.has(obj))
3
- throw TypeError("Cannot " + msg);
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
4
3
  };
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
- var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _borrowFromPersonalCap, borrowFromPersonalCap_fn, _setPendingStatuses, setPendingStatuses_fn, _validateKioskIsSet, validateKioskIsSet_fn, _validateFinalizedStatus, validateFinalizedStatus_fn;
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ 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);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+ var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _KioskTransaction_instances, borrowFromPersonalCap_fn, setPendingStatuses_fn, validateKioskIsSet_fn, validateFinalizedStatus_fn;
24
10
  import * as kioskTx from "../tx/kiosk.js";
25
11
  import { convertToPersonalTx, transferPersonalCapTx } from "../tx/personal-kiosk.js";
26
12
  import { confirmRequest } from "../tx/transfer-policy.js";
27
13
  import { getNormalizedRuleType } from "../utils.js";
28
14
  class KioskTransaction {
29
- constructor({ transactionBlock, kioskClient, cap }) {
30
- /**
31
- * A function to borrow from `personalCap`.
32
- */
33
- __privateAdd(this, _borrowFromPersonalCap);
34
- __privateAdd(this, _setPendingStatuses);
35
- __privateAdd(this, _validateKioskIsSet);
36
- // Validates that `finalize`
37
- __privateAdd(this, _validateFinalizedStatus);
15
+ constructor({
16
+ transactionBlock,
17
+ transaction = transactionBlock,
18
+ kioskClient,
19
+ cap
20
+ }) {
21
+ __privateAdd(this, _KioskTransaction_instances);
38
22
  // If we're pending `share` of a new kiosk, `finalize()` will share it.
39
- __privateAdd(this, _pendingShare, void 0);
23
+ __privateAdd(this, _pendingShare);
40
24
  // If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.
41
- __privateAdd(this, _pendingTransfer, void 0);
25
+ __privateAdd(this, _pendingTransfer);
42
26
  // The promise that the personalCap will be returned on `finalize()`.
43
- __privateAdd(this, _promise, void 0);
27
+ __privateAdd(this, _promise);
44
28
  // The personal kiosk argument.
45
- __privateAdd(this, _personalCap, void 0);
29
+ __privateAdd(this, _personalCap);
46
30
  // A flag that checks whether kiosk TX is finalized.
47
31
  __privateAdd(this, _finalized, false);
48
- this.transactionBlock = transactionBlock;
32
+ this.transaction = transaction;
49
33
  this.kioskClient = kioskClient;
50
- if (cap)
51
- this.setCap(cap);
34
+ if (cap) this.setCap(cap);
52
35
  }
53
36
  /**
54
37
  * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
@@ -56,12 +39,12 @@ class KioskTransaction {
56
39
  * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
57
40
  */
58
41
  create() {
59
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
60
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, {
42
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
43
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, {
61
44
  share: true,
62
45
  transfer: true
63
46
  });
64
- const [kiosk, cap] = kioskTx.createKiosk(this.transactionBlock);
47
+ const [kiosk, cap] = kioskTx.createKiosk(this.transaction);
65
48
  this.kiosk = kiosk;
66
49
  this.kioskCap = cap;
67
50
  return this;
@@ -80,35 +63,33 @@ class KioskTransaction {
80
63
  * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
81
64
  */
82
65
  convertToPersonal(borrow) {
83
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
66
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
84
67
  const cap = convertToPersonalTx(
85
- this.transactionBlock,
68
+ this.transaction,
86
69
  this.kiosk,
87
70
  this.kioskCap,
88
71
  this.kioskClient.getRulePackageId("personalKioskRulePackageId")
89
72
  );
90
- if (borrow)
91
- __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap);
92
- else
93
- __privateSet(this, _personalCap, cap);
94
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: true });
73
+ if (borrow) __privateMethod(this, _KioskTransaction_instances, borrowFromPersonalCap_fn).call(this, cap);
74
+ else __privateSet(this, _personalCap, cap);
75
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { transfer: true });
95
76
  return this;
96
77
  }
97
78
  /**
98
79
  * Single function way to create a kiosk, share it and transfer the cap to the specified address.
99
80
  */
100
81
  createAndShare(address) {
101
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
102
- const cap = kioskTx.createKioskAndShare(this.transactionBlock);
103
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
82
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
83
+ const cap = kioskTx.createKioskAndShare(this.transaction);
84
+ this.transaction.transferObjects([cap], this.transaction.pure.address(address));
104
85
  }
105
86
  /**
106
87
  * Shares the kiosk.
107
88
  */
108
89
  share() {
109
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
110
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { share: false });
111
- kioskTx.shareKiosk(this.transactionBlock, this.kiosk);
90
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
91
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { share: false });
92
+ kioskTx.shareKiosk(this.transaction, this.kiosk);
112
93
  }
113
94
  /**
114
95
  * Should be called only after `create` is called.
@@ -117,21 +98,17 @@ class KioskTransaction {
117
98
  shareAndTransferCap(address) {
118
99
  if (__privateGet(this, _personalCap))
119
100
  throw new Error("You can only call `shareAndTransferCap` on a non-personal kiosk.");
120
- __privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: false });
101
+ __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { transfer: false });
121
102
  this.share();
122
- this.transactionBlock.transferObjects(
123
- [this.kioskCap],
124
- this.transactionBlock.pure.address(address)
125
- );
103
+ this.transaction.transferObjects([this.kioskCap], this.transaction.pure.address(address));
126
104
  }
127
105
  /**
128
106
  * A function to borrow an item from a kiosk & execute any function with it.
129
- * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
130
107
  */
131
108
  borrowTx({ itemType, itemId }, callback) {
132
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
109
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
133
110
  const [itemObj, promise] = kioskTx.borrowValue(
134
- this.transactionBlock,
111
+ this.transaction,
135
112
  itemType,
136
113
  this.kiosk,
137
114
  this.kioskCap,
@@ -147,9 +124,9 @@ class KioskTransaction {
147
124
  * Requires calling `return`.
148
125
  */
149
126
  borrow({ itemType, itemId }) {
150
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
127
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
151
128
  const [itemObj, promise] = kioskTx.borrowValue(
152
- this.transactionBlock,
129
+ this.transaction,
153
130
  itemType,
154
131
  this.kiosk,
155
132
  this.kioskCap,
@@ -162,8 +139,8 @@ class KioskTransaction {
162
139
  * Accepts the parameters returned from the `borrow` function.
163
140
  */
164
141
  return({ itemType, item, promise }) {
165
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
166
- kioskTx.returnValue(this.transactionBlock, itemType, this.kiosk, item, promise);
142
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
143
+ kioskTx.returnValue(this.transaction, itemType, this.kiosk, item, promise);
167
144
  return this;
168
145
  }
169
146
  /**
@@ -172,14 +149,14 @@ class KioskTransaction {
172
149
  * @param amount The amount we aim to withdraw.
173
150
  */
174
151
  withdraw(address, amount) {
175
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
152
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
176
153
  const coin = kioskTx.withdrawFromKiosk(
177
- this.transactionBlock,
154
+ this.transaction,
178
155
  this.kiosk,
179
156
  this.kioskCap,
180
157
  amount
181
158
  );
182
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
159
+ this.transaction.transferObjects([coin], this.transaction.pure.address(address));
183
160
  return this;
184
161
  }
185
162
  /**
@@ -188,37 +165,30 @@ class KioskTransaction {
188
165
  * @param item The ID or Transaction Argument of the item
189
166
  */
190
167
  place({ itemType, item }) {
191
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
192
- kioskTx.place(this.transactionBlock, itemType, this.kiosk, this.kioskCap, item);
168
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
169
+ kioskTx.place(this.transaction, itemType, this.kiosk, this.kioskCap, item);
193
170
  return this;
194
171
  }
195
172
  /**
196
173
  * A function to place an item in the kiosk and list it for sale in one transaction.
197
174
  * @param itemType The type `T` of the item
198
175
  * @param item The ID or Transaction Argument of the item
199
- * @param price The price in nano
176
+ * @param price The price in NANOS
200
177
  */
201
178
  placeAndList({ itemType, item, price }) {
202
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
203
- kioskTx.placeAndList(
204
- this.transactionBlock,
205
- itemType,
206
- this.kiosk,
207
- this.kioskCap,
208
- item,
209
- price
210
- );
179
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
180
+ kioskTx.placeAndList(this.transaction, itemType, this.kiosk, this.kioskCap, item, price);
211
181
  return this;
212
182
  }
213
183
  /**
214
184
  * A function to list an item in the kiosk.
215
185
  * @param itemType The type `T` of the item
216
186
  * @param itemId The ID of the item
217
- * @param price The price in nano
187
+ * @param price The price in NANOS
218
188
  */
219
189
  list({ itemType, itemId, price }) {
220
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
221
- kioskTx.list(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId, price);
190
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
191
+ kioskTx.list(this.transaction, itemType, this.kiosk, this.kioskCap, itemId, price);
222
192
  return this;
223
193
  }
224
194
  /**
@@ -227,8 +197,8 @@ class KioskTransaction {
227
197
  * @param itemId The ID of the item
228
198
  */
229
199
  delist({ itemType, itemId }) {
230
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
231
- kioskTx.delist(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId);
200
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
201
+ kioskTx.delist(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
232
202
  return this;
233
203
  }
234
204
  /**
@@ -238,8 +208,8 @@ class KioskTransaction {
238
208
  * @param itemId The ID of the item
239
209
  */
240
210
  take({ itemType, itemId }) {
241
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
242
- return kioskTx.take(this.transactionBlock, itemType, this.kiosk, this.kioskCap, itemId);
211
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
212
+ return kioskTx.take(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
243
213
  }
244
214
  /**
245
215
  * Transfer a non-locked/non-listed item to an address.
@@ -249,9 +219,9 @@ class KioskTransaction {
249
219
  * @param address The destination address
250
220
  */
251
221
  transfer({ itemType, itemId, address }) {
252
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
222
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
253
223
  const item = this.take({ itemType, itemId });
254
- this.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));
224
+ this.transaction.transferObjects([item], this.transaction.pure.address(address));
255
225
  return this;
256
226
  }
257
227
  /**
@@ -268,9 +238,9 @@ class KioskTransaction {
268
238
  itemId,
269
239
  policy
270
240
  }) {
271
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
241
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
272
242
  kioskTx.lock(
273
- this.transactionBlock,
243
+ this.transaction,
274
244
  itemType,
275
245
  this.kiosk,
276
246
  this.kioskCap,
@@ -285,7 +255,7 @@ class KioskTransaction {
285
255
  * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
286
256
  * @param itemType The type `T` of the item
287
257
  * @param itemId The ID of the item
288
- * @param price The price in nano
258
+ * @param price The price in NANOS
289
259
  * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
290
260
  */
291
261
  purchase({
@@ -294,10 +264,10 @@ class KioskTransaction {
294
264
  price,
295
265
  sellerKiosk
296
266
  }) {
297
- const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [
298
- this.transactionBlock.pure.u64(price)
267
+ const coin = this.transaction.splitCoins(this.transaction.gas, [
268
+ this.transaction.pure.u64(price)
299
269
  ]);
300
- return kioskTx.purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);
270
+ return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);
301
271
  }
302
272
  /**
303
273
  * A function to purchase and resolve a transfer policy.
@@ -316,7 +286,7 @@ class KioskTransaction {
316
286
  sellerKiosk,
317
287
  extraArgs
318
288
  }) {
319
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
289
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
320
290
  const policies = await this.kioskClient.getTransferPolicies({ type: itemType });
321
291
  if (policies.length === 0) {
322
292
  throw new Error(
@@ -335,13 +305,12 @@ class KioskTransaction {
335
305
  const ruleDefinition = this.kioskClient.rules.find(
336
306
  (x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule)
337
307
  );
338
- if (!ruleDefinition)
339
- throw new Error(`No resolver for the following rule: ${rule}.`);
340
- if (ruleDefinition.hasLockingRule)
341
- canTransferOutsideKiosk = false;
308
+ if (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);
309
+ if (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;
342
310
  ruleDefinition.resolveRuleFunction({
343
311
  packageId: ruleDefinition.packageId,
344
- transactionBlock: this.transactionBlock,
312
+ transactionBlock: this.transaction,
313
+ transaction: this.transaction,
345
314
  itemType,
346
315
  itemId,
347
316
  price: price.toString(),
@@ -354,9 +323,8 @@ class KioskTransaction {
354
323
  extraArgs: extraArgs || {}
355
324
  });
356
325
  }
357
- confirmRequest(this.transactionBlock, itemType, policy.id, transferRequest);
358
- if (canTransferOutsideKiosk)
359
- this.place({ itemType, item: purchasedItem });
326
+ confirmRequest(this.transaction, itemType, policy.id, transferRequest);
327
+ if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });
360
328
  return this;
361
329
  }
362
330
  /**
@@ -365,23 +333,22 @@ class KioskTransaction {
365
333
  * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
366
334
  */
367
335
  setCap(cap) {
368
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
369
- this.kiosk = this.transactionBlock.object(cap.kioskId);
336
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
337
+ this.kiosk = this.transaction.object(cap.kioskId);
370
338
  if (!cap.isPersonal) {
371
- this.kioskCap = this.transactionBlock.object(cap.objectId);
339
+ this.kioskCap = this.transaction.object(cap.objectId);
372
340
  return;
373
341
  }
374
- return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
342
+ return __privateMethod(this, _KioskTransaction_instances, borrowFromPersonalCap_fn).call(this, cap.objectId);
375
343
  }
376
344
  /**
377
- * A function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the
345
+ * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
378
346
  * `PersonalKioskCap`, in case we are operating on a personal kiosk.
379
347
  * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
380
348
  */
381
349
  finalize() {
382
- __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
383
- if (__privateGet(this, _pendingShare))
384
- this.share();
350
+ __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
351
+ if (__privateGet(this, _pendingShare)) this.share();
385
352
  if (!__privateGet(this, _personalCap)) {
386
353
  if (__privateGet(this, _pendingTransfer))
387
354
  throw new Error(
@@ -391,27 +358,27 @@ class KioskTransaction {
391
358
  }
392
359
  const packageId = this.kioskClient.getRulePackageId("personalKioskRulePackageId");
393
360
  if (__privateGet(this, _promise)) {
394
- this.transactionBlock.moveCall({
361
+ this.transaction.moveCall({
395
362
  target: `${packageId}::personal_kiosk::return_val`,
396
363
  arguments: [
397
364
  __privateGet(this, _personalCap),
398
- this.transactionBlock.object(this.kioskCap),
365
+ this.transaction.object(this.kioskCap),
399
366
  __privateGet(this, _promise)
400
367
  ]
401
368
  });
402
369
  }
403
370
  if (__privateGet(this, _pendingTransfer))
404
- transferPersonalCapTx(this.transactionBlock, __privateGet(this, _personalCap), packageId);
371
+ transferPersonalCapTx(this.transaction, __privateGet(this, _personalCap), packageId);
405
372
  __privateSet(this, _finalized, true);
406
373
  }
407
374
  // Some setters in case we want custom behavior.
408
375
  setKioskCap(cap) {
409
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
376
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
410
377
  this.kioskCap = cap;
411
378
  return this;
412
379
  }
413
380
  setKiosk(kiosk) {
414
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
381
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
415
382
  this.kiosk = kiosk;
416
383
  return this;
417
384
  }
@@ -420,18 +387,16 @@ class KioskTransaction {
420
387
  * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.
421
388
  */
422
389
  getKiosk() {
423
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
424
- if (!this.kiosk)
425
- throw new Error("Kiosk is not set.");
390
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
391
+ if (!this.kiosk) throw new Error("Kiosk is not set.");
426
392
  return this.kiosk;
427
393
  }
428
394
  /*
429
395
  * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.
430
396
  */
431
397
  getKioskCap() {
432
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
433
- if (!this.kioskCap)
434
- throw new Error("Kiosk cap is not set");
398
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
399
+ if (!this.kioskCap) throw new Error("Kiosk cap is not set");
435
400
  return this.kioskCap;
436
401
  }
437
402
  }
@@ -440,40 +405,37 @@ _pendingTransfer = new WeakMap();
440
405
  _promise = new WeakMap();
441
406
  _personalCap = new WeakMap();
442
407
  _finalized = new WeakMap();
443
- _borrowFromPersonalCap = new WeakSet();
408
+ _KioskTransaction_instances = new WeakSet();
409
+ /**
410
+ * A function to borrow from `personalCap`.
411
+ */
444
412
  borrowFromPersonalCap_fn = function(personalCap) {
445
- const [kioskCap, promise] = this.transactionBlock.moveCall({
413
+ const [kioskCap, promise] = this.transaction.moveCall({
446
414
  target: `${this.kioskClient.getRulePackageId(
447
415
  "personalKioskRulePackageId"
448
416
  )}::personal_kiosk::borrow_val`,
449
- arguments: [this.transactionBlock.object(personalCap)]
417
+ arguments: [this.transaction.object(personalCap)]
450
418
  });
451
419
  this.kioskCap = kioskCap;
452
- __privateSet(this, _personalCap, this.transactionBlock.object(personalCap));
420
+ __privateSet(this, _personalCap, this.transaction.object(personalCap));
453
421
  __privateSet(this, _promise, promise);
454
422
  return this;
455
423
  };
456
- _setPendingStatuses = new WeakSet();
457
424
  setPendingStatuses_fn = function({ share, transfer }) {
458
- if (transfer !== void 0)
459
- __privateSet(this, _pendingTransfer, transfer);
460
- if (share !== void 0)
461
- __privateSet(this, _pendingShare, share);
425
+ if (transfer !== void 0) __privateSet(this, _pendingTransfer, transfer);
426
+ if (share !== void 0) __privateSet(this, _pendingShare, share);
462
427
  };
463
- _validateKioskIsSet = new WeakSet();
464
428
  validateKioskIsSet_fn = function() {
465
- __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
429
+ __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
466
430
  if (!this.kiosk || !this.kioskCap)
467
431
  throw new Error(
468
432
  "You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`"
469
433
  );
470
434
  };
471
- _validateFinalizedStatus = new WeakSet();
435
+ // Validates that `finalize`
472
436
  validateFinalizedStatus_fn = function() {
473
437
  if (__privateGet(this, _finalized))
474
- throw new Error(
475
- "You can't add more transactions to a finalized kiosk transaction block."
476
- );
438
+ throw new Error("You can't add more transactions to a finalized kiosk transaction.");
477
439
  };
478
440
  export {
479
441
  KioskTransaction
@@ -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;AAUA,YAAY,aAAa;AACzB,SAAS,qBAAqB,6BAA6B;AAC3D,SAAS,sBAAsB;AAU/B,SAAS,6BAA6B;AAqB/B,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;A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AAI;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;AAUA,YAAY,aAAa;AACzB,SAAS,qBAAqB,6BAA6B;AAC3D,SAAS,sBAAsB;AAU/B,SAAS,6BAA6B;AAwB/B,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,UAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,YAAY,KAAK,WAAW;AACzD,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,oDAAL;AAEA,UAAM,MAAM;AAAA,MACR,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,YAAY,iBAAiB,4BAA4B;AAAA,IAClE;AAGA,QAAI,OAAQ,uBAAK,uDAAL,WAA4B;AAAA,QACnC,oBAAK,cAAe;AAEzB,0BAAK,oDAAL,WAAyB,EAAE,UAAU,KAAK;AAC1C,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,SA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