@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
@@ -3,8 +3,8 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
5
  import type {
6
+ Transaction,
6
7
  TransactionArgument,
7
- TransactionBlock,
8
8
  TransactionObjectArgument,
9
9
  } from '@iota/iota-sdk/transactions';
10
10
 
@@ -24,8 +24,11 @@ import { getNormalizedRuleType } from '../utils.js';
24
24
  import type { KioskClient } from './kiosk-client.js';
25
25
 
26
26
  export type KioskTransactionParams = {
27
- /** The TransactionBlock for this run */
28
- transactionBlock: TransactionBlock;
27
+ /** The Transaction for this run */
28
+ transaction: Transaction;
29
+
30
+ /** @deprecated use transaction instead */
31
+ transactionBlock?: Transaction;
29
32
  /**
30
33
  * You can create a new KioskClient by calling `new KioskClient()`
31
34
  */
@@ -42,7 +45,7 @@ export type KioskTransactionParams = {
42
45
  * A helper for building transactions that involve kiosk.
43
46
  */
44
47
  export class KioskTransaction {
45
- transactionBlock: TransactionBlock;
48
+ transaction: Transaction;
46
49
  kioskClient: KioskClient;
47
50
  kiosk?: TransactionObjectArgument;
48
51
  kioskCap?: TransactionObjectArgument;
@@ -57,8 +60,13 @@ export class KioskTransaction {
57
60
  // A flag that checks whether kiosk TX is finalized.
58
61
  #finalized: boolean = false;
59
62
 
60
- constructor({ transactionBlock, kioskClient, cap }: KioskTransactionParams) {
61
- this.transactionBlock = transactionBlock;
63
+ constructor({
64
+ transactionBlock,
65
+ transaction = transactionBlock!,
66
+ kioskClient,
67
+ cap,
68
+ }: KioskTransactionParams) {
69
+ this.transaction = transaction;
62
70
  this.kioskClient = kioskClient;
63
71
 
64
72
  if (cap) this.setCap(cap);
@@ -75,7 +83,7 @@ export class KioskTransaction {
75
83
  share: true,
76
84
  transfer: true,
77
85
  });
78
- const [kiosk, cap] = kioskTx.createKiosk(this.transactionBlock);
86
+ const [kiosk, cap] = kioskTx.createKiosk(this.transaction);
79
87
  this.kiosk = kiosk;
80
88
  this.kioskCap = cap;
81
89
  return this;
@@ -99,7 +107,7 @@ export class KioskTransaction {
99
107
  this.#validateKioskIsSet();
100
108
 
101
109
  const cap = convertToPersonalTx(
102
- this.transactionBlock,
110
+ this.transaction,
103
111
  this.kiosk!,
104
112
  this.kioskCap!,
105
113
  this.kioskClient.getRulePackageId('personalKioskRulePackageId'),
@@ -118,8 +126,8 @@ export class KioskTransaction {
118
126
  */
119
127
  createAndShare(address: string) {
120
128
  this.#validateFinalizedStatus();
121
- const cap = kioskTx.createKioskAndShare(this.transactionBlock);
122
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
129
+ const cap = kioskTx.createKioskAndShare(this.transaction);
130
+ this.transaction.transferObjects([cap], this.transaction.pure.address(address));
123
131
  }
124
132
 
125
133
  /**
@@ -128,7 +136,7 @@ export class KioskTransaction {
128
136
  share() {
129
137
  this.#validateKioskIsSet();
130
138
  this.#setPendingStatuses({ share: false });
131
- kioskTx.shareKiosk(this.transactionBlock, this.kiosk!);
139
+ kioskTx.shareKiosk(this.transaction, this.kiosk!);
132
140
  }
133
141
 
134
142
  /**
@@ -140,20 +148,16 @@ export class KioskTransaction {
140
148
  throw new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');
141
149
  this.#setPendingStatuses({ transfer: false });
142
150
  this.share();
143
- this.transactionBlock.transferObjects(
144
- [this.kioskCap!],
145
- this.transactionBlock.pure.address(address),
146
- );
151
+ this.transaction.transferObjects([this.kioskCap!], this.transaction.pure.address(address));
147
152
  }
148
153
 
149
154
  /**
150
155
  * A function to borrow an item from a kiosk & execute any function with it.
151
- * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
152
156
  */
153
157
  borrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {
154
158
  this.#validateKioskIsSet();
155
159
  const [itemObj, promise] = kioskTx.borrowValue(
156
- this.transactionBlock,
160
+ this.transaction,
157
161
  itemType,
158
162
  this.kiosk!,
159
163
  this.kioskCap!,
@@ -174,7 +178,7 @@ export class KioskTransaction {
174
178
  borrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {
175
179
  this.#validateKioskIsSet();
176
180
  const [itemObj, promise] = kioskTx.borrowValue(
177
- this.transactionBlock,
181
+ this.transaction,
178
182
  itemType,
179
183
  this.kiosk!,
180
184
  this.kioskCap!,
@@ -190,7 +194,7 @@ export class KioskTransaction {
190
194
  */
191
195
  return({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {
192
196
  this.#validateKioskIsSet();
193
- kioskTx.returnValue(this.transactionBlock, itemType, this.kiosk!, item, promise);
197
+ kioskTx.returnValue(this.transaction, itemType, this.kiosk!, item, promise);
194
198
  return this;
195
199
  }
196
200
 
@@ -202,12 +206,12 @@ export class KioskTransaction {
202
206
  withdraw(address: string, amount?: string | bigint | number) {
203
207
  this.#validateKioskIsSet();
204
208
  const coin = kioskTx.withdrawFromKiosk(
205
- this.transactionBlock,
209
+ this.transaction,
206
210
  this.kiosk!,
207
211
  this.kioskCap!,
208
212
  amount,
209
213
  );
210
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
214
+ this.transaction.transferObjects([coin], this.transaction.pure.address(address));
211
215
  return this;
212
216
  }
213
217
 
@@ -218,7 +222,7 @@ export class KioskTransaction {
218
222
  */
219
223
  place({ itemType, item }: ItemReference) {
220
224
  this.#validateKioskIsSet();
221
- kioskTx.place(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, item);
225
+ kioskTx.place(this.transaction, itemType, this.kiosk!, this.kioskCap!, item);
222
226
  return this;
223
227
  }
224
228
 
@@ -226,18 +230,11 @@ export class KioskTransaction {
226
230
  * A function to place an item in the kiosk and list it for sale in one transaction.
227
231
  * @param itemType The type `T` of the item
228
232
  * @param item The ID or Transaction Argument of the item
229
- * @param price The price in nano
233
+ * @param price The price in NANOS
230
234
  */
231
235
  placeAndList({ itemType, item, price }: ItemReference & Price) {
232
236
  this.#validateKioskIsSet();
233
- kioskTx.placeAndList(
234
- this.transactionBlock,
235
- itemType,
236
- this.kiosk!,
237
- this.kioskCap!,
238
- item,
239
- price,
240
- );
237
+ kioskTx.placeAndList(this.transaction, itemType, this.kiosk!, this.kioskCap!, item, price);
241
238
  return this;
242
239
  }
243
240
 
@@ -245,11 +242,11 @@ export class KioskTransaction {
245
242
  * A function to list an item in the kiosk.
246
243
  * @param itemType The type `T` of the item
247
244
  * @param itemId The ID of the item
248
- * @param price The price in nano
245
+ * @param price The price in NANOS
249
246
  */
250
247
  list({ itemType, itemId, price }: ItemId & { price: string | bigint }) {
251
248
  this.#validateKioskIsSet();
252
- kioskTx.list(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId, price);
249
+ kioskTx.list(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId, price);
253
250
  return this;
254
251
  }
255
252
 
@@ -260,7 +257,7 @@ export class KioskTransaction {
260
257
  */
261
258
  delist({ itemType, itemId }: ItemId) {
262
259
  this.#validateKioskIsSet();
263
- kioskTx.delist(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);
260
+ kioskTx.delist(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);
264
261
  return this;
265
262
  }
266
263
 
@@ -272,7 +269,7 @@ export class KioskTransaction {
272
269
  */
273
270
  take({ itemType, itemId }: ItemId): TransactionObjectArgument {
274
271
  this.#validateKioskIsSet();
275
- return kioskTx.take(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);
272
+ return kioskTx.take(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);
276
273
  }
277
274
 
278
275
  /**
@@ -285,7 +282,7 @@ export class KioskTransaction {
285
282
  transfer({ itemType, itemId, address }: ItemId & { address: string }) {
286
283
  this.#validateKioskIsSet();
287
284
  const item = this.take({ itemType, itemId });
288
- this.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));
285
+ this.transaction.transferObjects([item], this.transaction.pure.address(address));
289
286
  return this;
290
287
  }
291
288
 
@@ -305,7 +302,7 @@ export class KioskTransaction {
305
302
  }: ItemReference & { policy: ObjectArgument; itemId?: string }) {
306
303
  this.#validateKioskIsSet();
307
304
  kioskTx.lock(
308
- this.transactionBlock,
305
+ this.transaction,
309
306
  itemType,
310
307
  this.kiosk!,
311
308
  this.kioskCap!,
@@ -321,7 +318,7 @@ export class KioskTransaction {
321
318
  * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
322
319
  * @param itemType The type `T` of the item
323
320
  * @param itemId The ID of the item
324
- * @param price The price in nano
321
+ * @param price The price in NANOS
325
322
  * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
326
323
  */
327
324
  purchase({
@@ -334,10 +331,10 @@ export class KioskTransaction {
334
331
  TransactionObjectArgument,
335
332
  ] {
336
333
  // Split the coin for the amount of the listing.
337
- const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [
338
- this.transactionBlock.pure.u64(price),
334
+ const coin = this.transaction.splitCoins(this.transaction.gas, [
335
+ this.transaction.pure.u64(price),
339
336
  ]);
340
- return kioskTx.purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);
337
+ return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);
341
338
  }
342
339
 
343
340
  /**
@@ -389,7 +386,8 @@ export class KioskTransaction {
389
386
 
390
387
  ruleDefinition.resolveRuleFunction({
391
388
  packageId: ruleDefinition.packageId,
392
- transactionBlock: this.transactionBlock,
389
+ transactionBlock: this.transaction,
390
+ transaction: this.transaction,
393
391
  itemType,
394
392
  itemId,
395
393
  price: price.toString(),
@@ -403,7 +401,7 @@ export class KioskTransaction {
403
401
  });
404
402
  }
405
403
 
406
- confirmRequest(this.transactionBlock, itemType, policy.id, transferRequest);
404
+ confirmRequest(this.transaction, itemType, policy.id, transferRequest);
407
405
 
408
406
  if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });
409
407
 
@@ -417,9 +415,9 @@ export class KioskTransaction {
417
415
  */
418
416
  setCap(cap: KioskOwnerCap) {
419
417
  this.#validateFinalizedStatus();
420
- this.kiosk = this.transactionBlock.object(cap.kioskId);
418
+ this.kiosk = this.transaction.object(cap.kioskId);
421
419
  if (!cap.isPersonal) {
422
- this.kioskCap = this.transactionBlock.object(cap.objectId);
420
+ this.kioskCap = this.transaction.object(cap.objectId);
423
421
  return;
424
422
  }
425
423
 
@@ -427,7 +425,7 @@ export class KioskTransaction {
427
425
  }
428
426
 
429
427
  /**
430
- * A function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the
428
+ * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
431
429
  * `PersonalKioskCap`, in case we are operating on a personal kiosk.
432
430
  * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
433
431
  */
@@ -450,11 +448,11 @@ export class KioskTransaction {
450
448
 
451
449
  // if we have a promise, return the `ownerCap` back to the personal cap.
452
450
  if (this.#promise) {
453
- this.transactionBlock.moveCall({
451
+ this.transaction.moveCall({
454
452
  target: `${packageId}::personal_kiosk::return_val`,
455
453
  arguments: [
456
454
  this.#personalCap,
457
- this.transactionBlock.object(this.kioskCap!),
455
+ this.transaction.object(this.kioskCap!),
458
456
  this.#promise!,
459
457
  ],
460
458
  });
@@ -462,9 +460,9 @@ export class KioskTransaction {
462
460
 
463
461
  // If we are pending transferring the personalCap, we do it here.
464
462
  if (this.#pendingTransfer)
465
- transferPersonalCapTx(this.transactionBlock, this.#personalCap, packageId);
463
+ transferPersonalCapTx(this.transaction, this.#personalCap, packageId);
466
464
 
467
- // Mark the transaction block as finalized, so no other functions can be called.
465
+ // Mark the transaction as finalized, so no other functions can be called.
468
466
  this.#finalized = true;
469
467
  }
470
468
 
@@ -504,15 +502,15 @@ export class KioskTransaction {
504
502
  * A function to borrow from `personalCap`.
505
503
  */
506
504
  #borrowFromPersonalCap(personalCap: ObjectArgument) {
507
- const [kioskCap, promise] = this.transactionBlock.moveCall({
505
+ const [kioskCap, promise] = this.transaction.moveCall({
508
506
  target: `${this.kioskClient.getRulePackageId(
509
507
  'personalKioskRulePackageId',
510
508
  )}::personal_kiosk::borrow_val`,
511
- arguments: [this.transactionBlock.object(personalCap)],
509
+ arguments: [this.transaction.object(personalCap)],
512
510
  });
513
511
 
514
512
  this.kioskCap = kioskCap;
515
- this.#personalCap = this.transactionBlock.object(personalCap);
513
+ this.#personalCap = this.transaction.object(personalCap);
516
514
  this.#promise = promise;
517
515
 
518
516
  return this;
@@ -535,8 +533,6 @@ export class KioskTransaction {
535
533
  // Validates that `finalize`
536
534
  #validateFinalizedStatus() {
537
535
  if (this.#finalized)
538
- throw new Error(
539
- "You can't add more transactions to a finalized kiosk transaction block.",
540
- );
536
+ throw new Error("You can't add more transactions to a finalized kiosk transaction.");
541
537
  }
542
538
  }
@@ -2,7 +2,7 @@
2
2
  // Modifications Copyright (c) 2024 IOTA Stiftung
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import type { TransactionBlock, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
5
+ import type { Transaction, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
6
6
 
7
7
  import {
8
8
  attachFloorPriceRuleTx,
@@ -28,20 +28,27 @@ export type TransferPolicyBaseParams = {
28
28
 
29
29
  export type TransferPolicyTransactionParams = {
30
30
  kioskClient: KioskClient;
31
- transactionBlock: TransactionBlock;
31
+ transaction: Transaction;
32
+ /** @deprecated use transaction instead */
33
+ transactionBlock?: Transaction;
32
34
  cap?: TransferPolicyCap;
33
35
  };
34
36
 
35
37
  export class TransferPolicyTransaction {
36
- transactionBlock: TransactionBlock;
38
+ transaction: Transaction;
37
39
  kioskClient: KioskClient;
38
40
  policy?: ObjectArgument;
39
41
  policyCap?: ObjectArgument;
40
42
  type?: string;
41
43
 
42
- constructor({ kioskClient, transactionBlock, cap }: TransferPolicyTransactionParams) {
44
+ constructor({
45
+ kioskClient,
46
+ transactionBlock,
47
+ transaction = transactionBlock!,
48
+ cap,
49
+ }: TransferPolicyTransactionParams) {
43
50
  this.kioskClient = kioskClient;
44
- this.transactionBlock = transactionBlock;
51
+ this.transaction = transaction;
45
52
  if (cap) this.setCap(cap);
46
53
  }
47
54
 
@@ -70,8 +77,8 @@ export class TransferPolicyTransaction {
70
77
  if (policies.length > 0)
71
78
  throw new Error("There's already transfer policy for this Type.");
72
79
  }
73
- const cap = createTransferPolicy(this.transactionBlock, type, publisher);
74
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
80
+ const cap = createTransferPolicy(this.transaction, type, publisher);
81
+ this.transaction.transferObjects([cap], this.transaction.pure.address(address));
75
82
  }
76
83
 
77
84
  /**
@@ -93,7 +100,7 @@ export class TransferPolicyTransaction {
93
100
  throw new Error("There's already transfer policy for this Type.");
94
101
  }
95
102
  const [policy, policyCap] = createTransferPolicyWithoutSharing(
96
- this.transactionBlock,
103
+ this.transaction,
97
104
  type,
98
105
  publisher,
99
106
  );
@@ -114,14 +121,10 @@ export class TransferPolicyTransaction {
114
121
  'This function can only be called after `transferPolicyManager.create`',
115
122
  );
116
123
 
117
- shareTransferPolicy(
118
- this.transactionBlock,
119
- this.type,
120
- this.policy as TransactionObjectArgument,
121
- );
122
- this.transactionBlock.transferObjects(
124
+ shareTransferPolicy(this.transaction, this.type, this.policy as TransactionObjectArgument);
125
+ this.transaction.transferObjects(
123
126
  [this.policyCap as TransactionObjectArgument],
124
- this.transactionBlock.pure.address(address),
127
+ this.transaction.pure.address(address),
125
128
  );
126
129
  }
127
130
 
@@ -143,14 +146,14 @@ export class TransferPolicyTransaction {
143
146
  this.#validateInputs();
144
147
  // Withdraw coin for specified amount (or none)
145
148
  const coin = withdrawFromPolicy(
146
- this.transactionBlock,
149
+ this.transaction,
147
150
  this.type!,
148
151
  this.policy!,
149
152
  this.policyCap!,
150
153
  amount,
151
154
  );
152
155
 
153
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
156
+ this.transaction.transferObjects([coin], this.transaction.pure.address(address));
154
157
 
155
158
  return this;
156
159
  }
@@ -163,7 +166,7 @@ export class TransferPolicyTransaction {
163
166
  * (but you should define at least one of them for the rule to make sense).
164
167
  *
165
168
  * @param percentageBps The royalty percentage in basis points. Use `percentageToBasisPoints` helper to convert from percentage [0,100].
166
- * @param minAmount The minimum royalty amount per request in nano.
169
+ * @param minAmount The minimum royalty amount per request in NANOS.
167
170
  */
168
171
  addRoyaltyRule(
169
172
  percentageBps: number | string, // this is in basis points.
@@ -175,7 +178,7 @@ export class TransferPolicyTransaction {
175
178
  // Also, it's hard to keep versioning as with network wipes, mainnet
176
179
  // and testnet will conflict.
177
180
  attachRoyaltyRuleTx(
178
- this.transactionBlock,
181
+ this.transaction,
179
182
  this.type!,
180
183
  this.policy!,
181
184
  this.policyCap!,
@@ -194,7 +197,7 @@ export class TransferPolicyTransaction {
194
197
  this.#validateInputs();
195
198
 
196
199
  attachKioskLockRuleTx(
197
- this.transactionBlock,
200
+ this.transaction,
198
201
  this.type!,
199
202
  this.policy!,
200
203
  this.policyCap!,
@@ -210,7 +213,7 @@ export class TransferPolicyTransaction {
210
213
  this.#validateInputs();
211
214
 
212
215
  attachPersonalKioskRuleTx(
213
- this.transactionBlock,
216
+ this.transaction,
214
217
  this.type!,
215
218
  this.policy!,
216
219
  this.policyCap!,
@@ -221,13 +224,13 @@ export class TransferPolicyTransaction {
221
224
 
222
225
  /**
223
226
  * A function to add the floor price rule to a transfer policy.
224
- * @param minPrice The minimum price in nano.
227
+ * @param minPrice The minimum price in NANOS.
225
228
  */
226
229
  addFloorPriceRule(minPrice: string | bigint) {
227
230
  this.#validateInputs();
228
231
 
229
232
  attachFloorPriceRuleTx(
230
- this.transactionBlock,
233
+ this.transaction,
231
234
  this.type!,
232
235
  this.policy!,
233
236
  this.policyCap!,
@@ -246,7 +249,7 @@ export class TransferPolicyTransaction {
246
249
  this.#validateInputs();
247
250
 
248
251
  removeTransferPolicyRule(
249
- this.transactionBlock,
252
+ this.transaction,
250
253
  this.type!,
251
254
  ruleType,
252
255
  configType,
@@ -264,7 +267,7 @@ export class TransferPolicyTransaction {
264
267
  const packageId = this.kioskClient.getRulePackageId('kioskLockRulePackageId');
265
268
 
266
269
  removeTransferPolicyRule(
267
- this.transactionBlock,
270
+ this.transaction,
268
271
  this.type!,
269
272
  `${packageId}::kiosk_lock_rule::Rule`,
270
273
  `${packageId}::kiosk_lock_rule::Config`,
@@ -283,7 +286,7 @@ export class TransferPolicyTransaction {
283
286
  const packageId = this.kioskClient.getRulePackageId('royaltyRulePackageId');
284
287
 
285
288
  removeTransferPolicyRule(
286
- this.transactionBlock,
289
+ this.transaction,
287
290
  this.type!,
288
291
  `${packageId}::royalty_rule::Rule`,
289
292
  `${packageId}::royalty_rule::Config`,
@@ -299,7 +302,7 @@ export class TransferPolicyTransaction {
299
302
  const packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');
300
303
 
301
304
  removeTransferPolicyRule(
302
- this.transactionBlock,
305
+ this.transaction,
303
306
  this.type!,
304
307
  `${packageId}::personal_kiosk_rule::Rule`,
305
308
  `bool`,
@@ -315,7 +318,7 @@ export class TransferPolicyTransaction {
315
318
  const packageId = this.kioskClient.getRulePackageId('floorPriceRulePackageId');
316
319
 
317
320
  removeTransferPolicyRule(
318
- this.transactionBlock,
321
+ this.transaction,
319
322
  this.type!,
320
323
  `${packageId}::floor_price_rule::Rule`,
321
324
  `${packageId}::floor_price_rule::Config`,
@@ -3,9 +3,11 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
5
  import type { IotaClient } from '@iota/iota-sdk/client';
6
- import { isValidIotaAddress } from '@iota/iota-sdk/utils';
6
+ import { fromB64, isValidIotaAddress } from '@iota/iota-sdk/utils';
7
7
 
8
- import { bcs } from '../bcs.js';
8
+ import '../bcs.js';
9
+
10
+ import { TransferPolicyType } from '../bcs.js';
9
11
  import type { TransferPolicy, TransferPolicyCap } from '../types/index.js';
10
12
  import {
11
13
  TRANSFER_POLICY_CAP_TYPE,
@@ -51,7 +53,7 @@ export async function queryTransferPolicy(
51
53
  );
52
54
  }
53
55
 
54
- const parsed = bcs.de(TRANSFER_POLICY_TYPE, policy.bcs.bcsBytes, 'base64');
56
+ const parsed = TransferPolicyType.parse(fromB64(policy.bcs.bcsBytes));
55
57
 
56
58
  return {
57
59
  id: policy?.objectId,
package/src/tx/kiosk.ts CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  import { bcs } from '@iota/iota-sdk/bcs';
6
6
  import type {
7
+ Transaction,
7
8
  TransactionArgument,
8
- TransactionBlock,
9
9
  TransactionObjectArgument,
10
10
  } from '@iota/iota-sdk/transactions';
11
11
 
@@ -16,7 +16,7 @@ import { KIOSK_MODULE, KIOSK_TYPE } from '../types/index.js';
16
16
  * Create a new shared Kiosk and returns the [kiosk, kioskOwnerCap] tuple.
17
17
  */
18
18
  export function createKiosk(
19
- tx: TransactionBlock,
19
+ tx: Transaction,
20
20
  ): [TransactionObjectArgument, TransactionObjectArgument] {
21
21
  const [kiosk, kioskOwnerCap] = tx.moveCall({
22
22
  target: `${KIOSK_MODULE}::new`,
@@ -29,7 +29,7 @@ export function createKiosk(
29
29
  * Calls the `kiosk::new()` function and shares the kiosk.
30
30
  * Returns the `kioskOwnerCap` object.
31
31
  */
32
- export function createKioskAndShare(tx: TransactionBlock): TransactionObjectArgument {
32
+ export function createKioskAndShare(tx: Transaction): TransactionObjectArgument {
33
33
  const [kiosk, kioskOwnerCap] = createKiosk(tx);
34
34
  shareKiosk(tx, kiosk);
35
35
  return kioskOwnerCap;
@@ -38,7 +38,7 @@ export function createKioskAndShare(tx: TransactionBlock): TransactionObjectArgu
38
38
  /**
39
39
  * Converts Transfer Policy to a shared object.
40
40
  */
41
- export function shareKiosk(tx: TransactionBlock, kiosk: TransactionArgument) {
41
+ export function shareKiosk(tx: Transaction, kiosk: TransactionArgument) {
42
42
  tx.moveCall({
43
43
  target: `0x2::transfer::public_share_object`,
44
44
  typeArguments: [KIOSK_TYPE],
@@ -51,7 +51,7 @@ export function shareKiosk(tx: TransactionBlock, kiosk: TransactionArgument) {
51
51
  * Place an item to the Kiosk.
52
52
  */
53
53
  export function place(
54
- tx: TransactionBlock,
54
+ tx: Transaction,
55
55
  itemType: string,
56
56
  kiosk: ObjectArgument,
57
57
  kioskCap: ObjectArgument,
@@ -73,7 +73,7 @@ export function place(
73
73
  * locked without an option to take it out.
74
74
  */
75
75
  export function lock(
76
- tx: TransactionBlock,
76
+ tx: Transaction,
77
77
  itemType: string,
78
78
  kiosk: ObjectArgument,
79
79
  kioskCap: ObjectArgument,
@@ -92,7 +92,7 @@ export function lock(
92
92
  * Take an item from the Kiosk.
93
93
  */
94
94
  export function take(
95
- tx: TransactionBlock,
95
+ tx: Transaction,
96
96
  itemType: string,
97
97
  kiosk: ObjectArgument,
98
98
  kioskCap: ObjectArgument,
@@ -112,7 +112,7 @@ export function take(
112
112
  * List an item for sale.
113
113
  */
114
114
  export function list(
115
- tx: TransactionBlock,
115
+ tx: Transaction,
116
116
  itemType: string,
117
117
  kiosk: ObjectArgument,
118
118
  kioskCap: ObjectArgument,
@@ -131,7 +131,7 @@ export function list(
131
131
  * List an item for sale.
132
132
  */
133
133
  export function delist(
134
- tx: TransactionBlock,
134
+ tx: Transaction,
135
135
  itemType: string,
136
136
  kiosk: ObjectArgument,
137
137
  kioskCap: ObjectArgument,
@@ -149,7 +149,7 @@ export function delist(
149
149
  * Place an item to the Kiosk and list it for sale.
150
150
  */
151
151
  export function placeAndList(
152
- tx: TransactionBlock,
152
+ tx: Transaction,
153
153
  itemType: string,
154
154
  kiosk: ObjectArgument,
155
155
  kioskCap: ObjectArgument,
@@ -168,7 +168,7 @@ export function placeAndList(
168
168
  * a TransferRequest which needs to be dealt with (via a matching TransferPolicy).
169
169
  */
170
170
  export function purchase(
171
- tx: TransactionBlock,
171
+ tx: Transaction,
172
172
  itemType: string,
173
173
  kiosk: ObjectArgument,
174
174
  itemId: string,
@@ -188,7 +188,7 @@ export function purchase(
188
188
  * If the amount is null, then the entire balance will be withdrawn.
189
189
  */
190
190
  export function withdrawFromKiosk(
191
- tx: TransactionBlock,
191
+ tx: Transaction,
192
192
  kiosk: ObjectArgument,
193
193
  kioskCap: ObjectArgument,
194
194
  amount?: string | bigint | number,
@@ -210,7 +210,7 @@ export function withdrawFromKiosk(
210
210
  * Requires calling `returnValue` to return the item.
211
211
  */
212
212
  export function borrowValue(
213
- tx: TransactionBlock,
213
+ tx: Transaction,
214
214
  itemType: string,
215
215
  kiosk: ObjectArgument,
216
216
  kioskCap: ObjectArgument,
@@ -230,7 +230,7 @@ export function borrowValue(
230
230
  * Return an item to the Kiosk after it was `borrowValue`-d.
231
231
  */
232
232
  export function returnValue(
233
- tx: TransactionBlock,
233
+ tx: Transaction,
234
234
  itemType: string,
235
235
  kiosk: ObjectArgument,
236
236
  item: TransactionArgument,
@@ -2,12 +2,12 @@
2
2
  // Modifications Copyright (c) 2024 IOTA Stiftung
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- import type { TransactionBlock, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
5
+ import type { Transaction, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
6
6
 
7
7
  import type { ObjectArgument } from '../types/index.js';
8
8
 
9
9
  export function convertToPersonalTx(
10
- tx: TransactionBlock,
10
+ tx: Transaction,
11
11
  kiosk: ObjectArgument,
12
12
  kioskOwnerCap: ObjectArgument,
13
13
  packageId: string,
@@ -24,7 +24,7 @@ export function convertToPersonalTx(
24
24
  * Transfers the personal kiosk Cap to the sender.
25
25
  */
26
26
  export function transferPersonalCapTx(
27
- tx: TransactionBlock,
27
+ tx: Transaction,
28
28
  personalKioskCap: TransactionObjectArgument,
29
29
  packageId: string,
30
30
  ) {