@mysten/kiosk 0.8.10 → 0.9.1

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 (95) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/bcs.d.ts +40 -2
  3. package/dist/cjs/bcs.js +22 -19
  4. package/dist/cjs/bcs.js.map +2 -2
  5. package/dist/cjs/client/kiosk-client.d.ts +1 -1
  6. package/dist/cjs/client/kiosk-client.js.map +1 -1
  7. package/dist/cjs/client/kiosk-transaction.d.ts +8 -6
  8. package/dist/cjs/client/kiosk-transaction.js +41 -54
  9. package/dist/cjs/client/kiosk-transaction.js.map +2 -2
  10. package/dist/cjs/client/tp-transaction.d.ts +6 -4
  11. package/dist/cjs/client/tp-transaction.js +24 -19
  12. package/dist/cjs/client/tp-transaction.js.map +2 -2
  13. package/dist/cjs/query/kiosk.d.ts +1 -1
  14. package/dist/cjs/query/kiosk.js +1 -1
  15. package/dist/cjs/query/kiosk.js.map +1 -1
  16. package/dist/cjs/query/transfer-policy.d.ts +2 -1
  17. package/dist/cjs/query/transfer-policy.js +3 -2
  18. package/dist/cjs/query/transfer-policy.js.map +3 -3
  19. package/dist/cjs/tx/kiosk.d.ts +14 -14
  20. package/dist/cjs/tx/kiosk.js +1 -1
  21. package/dist/cjs/tx/kiosk.js.map +2 -2
  22. package/dist/cjs/tx/personal-kiosk.d.ts +3 -3
  23. package/dist/cjs/tx/personal-kiosk.js.map +1 -1
  24. package/dist/cjs/tx/rules/attach.d.ts +5 -5
  25. package/dist/cjs/tx/rules/attach.js.map +1 -1
  26. package/dist/cjs/tx/rules/resolve.js +16 -16
  27. package/dist/cjs/tx/rules/resolve.js.map +2 -2
  28. package/dist/cjs/tx/transfer-policy.d.ts +7 -7
  29. package/dist/cjs/tx/transfer-policy.js +1 -1
  30. package/dist/cjs/tx/transfer-policy.js.map +1 -1
  31. package/dist/cjs/types/index.d.ts +2 -2
  32. package/dist/cjs/types/index.js.map +1 -1
  33. package/dist/cjs/types/kiosk.d.ts +2 -2
  34. package/dist/cjs/types/kiosk.js.map +1 -1
  35. package/dist/cjs/types/transfer-policy.d.ts +5 -3
  36. package/dist/cjs/types/transfer-policy.js.map +1 -1
  37. package/dist/cjs/utils.d.ts +1 -1
  38. package/dist/cjs/utils.js +2 -2
  39. package/dist/cjs/utils.js.map +2 -2
  40. package/dist/esm/bcs.d.ts +40 -2
  41. package/dist/esm/bcs.js +22 -19
  42. package/dist/esm/bcs.js.map +2 -2
  43. package/dist/esm/client/kiosk-client.d.ts +1 -1
  44. package/dist/esm/client/kiosk-client.js.map +1 -1
  45. package/dist/esm/client/kiosk-transaction.d.ts +8 -6
  46. package/dist/esm/client/kiosk-transaction.js +41 -54
  47. package/dist/esm/client/kiosk-transaction.js.map +2 -2
  48. package/dist/esm/client/tp-transaction.d.ts +6 -4
  49. package/dist/esm/client/tp-transaction.js +24 -19
  50. package/dist/esm/client/tp-transaction.js.map +2 -2
  51. package/dist/esm/query/kiosk.d.ts +1 -1
  52. package/dist/esm/query/kiosk.js +1 -1
  53. package/dist/esm/query/kiosk.js.map +1 -1
  54. package/dist/esm/query/transfer-policy.d.ts +2 -1
  55. package/dist/esm/query/transfer-policy.js +4 -3
  56. package/dist/esm/query/transfer-policy.js.map +2 -2
  57. package/dist/esm/tx/kiosk.d.ts +14 -14
  58. package/dist/esm/tx/kiosk.js +1 -1
  59. package/dist/esm/tx/kiosk.js.map +2 -2
  60. package/dist/esm/tx/personal-kiosk.d.ts +3 -3
  61. package/dist/esm/tx/personal-kiosk.js.map +1 -1
  62. package/dist/esm/tx/rules/attach.d.ts +5 -5
  63. package/dist/esm/tx/rules/attach.js.map +1 -1
  64. package/dist/esm/tx/rules/resolve.js +16 -16
  65. package/dist/esm/tx/rules/resolve.js.map +2 -2
  66. package/dist/esm/tx/transfer-policy.d.ts +7 -7
  67. package/dist/esm/tx/transfer-policy.js +1 -1
  68. package/dist/esm/tx/transfer-policy.js.map +1 -1
  69. package/dist/esm/types/index.d.ts +2 -2
  70. package/dist/esm/types/index.js.map +1 -1
  71. package/dist/esm/types/kiosk.d.ts +2 -2
  72. package/dist/esm/types/kiosk.js.map +1 -1
  73. package/dist/esm/types/transfer-policy.d.ts +5 -3
  74. package/dist/esm/types/transfer-policy.js.map +1 -1
  75. package/dist/esm/utils.d.ts +1 -1
  76. package/dist/esm/utils.js +9 -4
  77. package/dist/esm/utils.js.map +2 -2
  78. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  79. package/dist/tsconfig.tsbuildinfo +1 -1
  80. package/package.json +4 -4
  81. package/src/bcs.ts +18 -20
  82. package/src/client/kiosk-client.ts +1 -1
  83. package/src/client/kiosk-transaction.ts +50 -60
  84. package/src/client/tp-transaction.ts +29 -22
  85. package/src/query/kiosk.ts +2 -2
  86. package/src/query/transfer-policy.ts +6 -4
  87. package/src/tx/kiosk.ts +16 -16
  88. package/src/tx/personal-kiosk.ts +3 -3
  89. package/src/tx/rules/attach.ts +5 -5
  90. package/src/tx/rules/resolve.ts +16 -16
  91. package/src/tx/transfer-policy.ts +9 -9
  92. package/src/types/index.ts +2 -2
  93. package/src/types/kiosk.ts +2 -2
  94. package/src/types/transfer-policy.ts +5 -3
  95. package/src/utils.ts +11 -6
@@ -2,10 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type {
5
+ Transaction,
5
6
  TransactionArgument,
6
- TransactionBlock,
7
7
  TransactionObjectArgument,
8
- } from '@mysten/sui.js/transactions';
8
+ } from '@mysten/sui/transactions';
9
9
 
10
10
  import * as kioskTx from '../tx/kiosk.js';
11
11
  import { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';
@@ -23,8 +23,11 @@ import { getNormalizedRuleType } from '../utils.js';
23
23
  import type { KioskClient } from './kiosk-client.js';
24
24
 
25
25
  export type KioskTransactionParams = {
26
- /** The TransactionBlock for this run */
27
- transactionBlock: TransactionBlock;
26
+ /** The Transaction for this run */
27
+ transaction: Transaction;
28
+
29
+ /** @deprecated use transaction instead */
30
+ transactionBlock?: Transaction;
28
31
  /**
29
32
  * You can create a new KioskClient by calling `new KioskClient()`
30
33
  */
@@ -41,7 +44,7 @@ export type KioskTransactionParams = {
41
44
  * A helper for building transactions that involve kiosk.
42
45
  */
43
46
  export class KioskTransaction {
44
- transactionBlock: TransactionBlock;
47
+ transaction: Transaction;
45
48
  kioskClient: KioskClient;
46
49
  kiosk?: TransactionObjectArgument;
47
50
  kioskCap?: TransactionObjectArgument;
@@ -56,8 +59,13 @@ export class KioskTransaction {
56
59
  // A flag that checks whether kiosk TX is finalized.
57
60
  #finalized: boolean = false;
58
61
 
59
- constructor({ transactionBlock, kioskClient, cap }: KioskTransactionParams) {
60
- this.transactionBlock = transactionBlock;
62
+ constructor({
63
+ transactionBlock,
64
+ transaction = transactionBlock!,
65
+ kioskClient,
66
+ cap,
67
+ }: KioskTransactionParams) {
68
+ this.transaction = transaction;
61
69
  this.kioskClient = kioskClient;
62
70
 
63
71
  if (cap) this.setCap(cap);
@@ -74,7 +82,7 @@ export class KioskTransaction {
74
82
  share: true,
75
83
  transfer: true,
76
84
  });
77
- const [kiosk, cap] = kioskTx.createKiosk(this.transactionBlock);
85
+ const [kiosk, cap] = kioskTx.createKiosk(this.transaction);
78
86
  this.kiosk = kiosk;
79
87
  this.kioskCap = cap;
80
88
  return this;
@@ -98,7 +106,7 @@ export class KioskTransaction {
98
106
  this.#validateKioskIsSet();
99
107
 
100
108
  const cap = convertToPersonalTx(
101
- this.transactionBlock,
109
+ this.transaction,
102
110
  this.kiosk!,
103
111
  this.kioskCap!,
104
112
  this.kioskClient.getRulePackageId('personalKioskRulePackageId'),
@@ -117,8 +125,8 @@ export class KioskTransaction {
117
125
  */
118
126
  createAndShare(address: string) {
119
127
  this.#validateFinalizedStatus();
120
- const cap = kioskTx.createKioskAndShare(this.transactionBlock);
121
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
128
+ const cap = kioskTx.createKioskAndShare(this.transaction);
129
+ this.transaction.transferObjects([cap], this.transaction.pure.address(address));
122
130
  }
123
131
 
124
132
  /**
@@ -127,7 +135,7 @@ export class KioskTransaction {
127
135
  share() {
128
136
  this.#validateKioskIsSet();
129
137
  this.#setPendingStatuses({ share: false });
130
- kioskTx.shareKiosk(this.transactionBlock, this.kiosk!);
138
+ kioskTx.shareKiosk(this.transaction, this.kiosk!);
131
139
  }
132
140
 
133
141
  /**
@@ -139,10 +147,7 @@ export class KioskTransaction {
139
147
  throw new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');
140
148
  this.#setPendingStatuses({ transfer: false });
141
149
  this.share();
142
- this.transactionBlock.transferObjects(
143
- [this.kioskCap!],
144
- this.transactionBlock.pure.address(address),
145
- );
150
+ this.transaction.transferObjects([this.kioskCap!], this.transaction.pure.address(address));
146
151
  }
147
152
 
148
153
  /**
@@ -152,7 +157,7 @@ export class KioskTransaction {
152
157
  borrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {
153
158
  this.#validateKioskIsSet();
154
159
  const [itemObj, promise] = kioskTx.borrowValue(
155
- this.transactionBlock,
160
+ this.transaction,
156
161
  itemType,
157
162
  this.kiosk!,
158
163
  this.kioskCap!,
@@ -173,7 +178,7 @@ export class KioskTransaction {
173
178
  borrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {
174
179
  this.#validateKioskIsSet();
175
180
  const [itemObj, promise] = kioskTx.borrowValue(
176
- this.transactionBlock,
181
+ this.transaction,
177
182
  itemType,
178
183
  this.kiosk!,
179
184
  this.kioskCap!,
@@ -189,7 +194,7 @@ export class KioskTransaction {
189
194
  */
190
195
  return({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {
191
196
  this.#validateKioskIsSet();
192
- kioskTx.returnValue(this.transactionBlock, itemType, this.kiosk!, item, promise);
197
+ kioskTx.returnValue(this.transaction, itemType, this.kiosk!, item, promise);
193
198
  return this;
194
199
  }
195
200
 
@@ -200,13 +205,8 @@ export class KioskTransaction {
200
205
  */
201
206
  withdraw(address: string, amount?: string | bigint | number) {
202
207
  this.#validateKioskIsSet();
203
- const coin = kioskTx.withdrawFromKiosk(
204
- this.transactionBlock,
205
- this.kiosk!,
206
- this.kioskCap!,
207
- amount,
208
- );
209
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
208
+ const coin = kioskTx.withdrawFromKiosk(this.transaction, this.kiosk!, this.kioskCap!, amount);
209
+ this.transaction.transferObjects([coin], this.transaction.pure.address(address));
210
210
  return this;
211
211
  }
212
212
 
@@ -217,7 +217,7 @@ export class KioskTransaction {
217
217
  */
218
218
  place({ itemType, item }: ItemReference) {
219
219
  this.#validateKioskIsSet();
220
- kioskTx.place(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, item);
220
+ kioskTx.place(this.transaction, itemType, this.kiosk!, this.kioskCap!, item);
221
221
  return this;
222
222
  }
223
223
 
@@ -229,7 +229,7 @@ export class KioskTransaction {
229
229
  */
230
230
  placeAndList({ itemType, item, price }: ItemReference & Price) {
231
231
  this.#validateKioskIsSet();
232
- kioskTx.placeAndList(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, item, price);
232
+ kioskTx.placeAndList(this.transaction, itemType, this.kiosk!, this.kioskCap!, item, price);
233
233
  return this;
234
234
  }
235
235
 
@@ -241,7 +241,7 @@ export class KioskTransaction {
241
241
  */
242
242
  list({ itemType, itemId, price }: ItemId & { price: string | bigint }) {
243
243
  this.#validateKioskIsSet();
244
- kioskTx.list(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId, price);
244
+ kioskTx.list(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId, price);
245
245
  return this;
246
246
  }
247
247
 
@@ -252,7 +252,7 @@ export class KioskTransaction {
252
252
  */
253
253
  delist({ itemType, itemId }: ItemId) {
254
254
  this.#validateKioskIsSet();
255
- kioskTx.delist(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);
255
+ kioskTx.delist(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);
256
256
  return this;
257
257
  }
258
258
 
@@ -264,7 +264,7 @@ export class KioskTransaction {
264
264
  */
265
265
  take({ itemType, itemId }: ItemId): TransactionObjectArgument {
266
266
  this.#validateKioskIsSet();
267
- return kioskTx.take(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);
267
+ return kioskTx.take(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);
268
268
  }
269
269
 
270
270
  /**
@@ -277,7 +277,7 @@ export class KioskTransaction {
277
277
  transfer({ itemType, itemId, address }: ItemId & { address: string }) {
278
278
  this.#validateKioskIsSet();
279
279
  const item = this.take({ itemType, itemId });
280
- this.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));
280
+ this.transaction.transferObjects([item], this.transaction.pure.address(address));
281
281
  return this;
282
282
  }
283
283
 
@@ -296,14 +296,7 @@ export class KioskTransaction {
296
296
  policy,
297
297
  }: ItemReference & { policy: ObjectArgument; itemId?: string }) {
298
298
  this.#validateKioskIsSet();
299
- kioskTx.lock(
300
- this.transactionBlock,
301
- itemType,
302
- this.kiosk!,
303
- this.kioskCap!,
304
- policy,
305
- itemId ?? item,
306
- );
299
+ kioskTx.lock(this.transaction, itemType, this.kiosk!, this.kioskCap!, policy, itemId ?? item);
307
300
  return this;
308
301
  }
309
302
 
@@ -326,10 +319,10 @@ export class KioskTransaction {
326
319
  TransactionObjectArgument,
327
320
  ] {
328
321
  // Split the coin for the amount of the listing.
329
- const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [
330
- this.transactionBlock.pure.u64(price),
322
+ const coin = this.transaction.splitCoins(this.transaction.gas, [
323
+ this.transaction.pure.u64(price),
331
324
  ]);
332
- return kioskTx.purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);
325
+ return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);
333
326
  }
334
327
 
335
328
  /**
@@ -381,7 +374,8 @@ export class KioskTransaction {
381
374
 
382
375
  ruleDefinition.resolveRuleFunction({
383
376
  packageId: ruleDefinition.packageId,
384
- transactionBlock: this.transactionBlock,
377
+ transactionBlock: this.transaction,
378
+ transaction: this.transaction,
385
379
  itemType,
386
380
  itemId,
387
381
  price: price.toString(),
@@ -395,7 +389,7 @@ export class KioskTransaction {
395
389
  });
396
390
  }
397
391
 
398
- confirmRequest(this.transactionBlock, itemType, policy.id, transferRequest);
392
+ confirmRequest(this.transaction, itemType, policy.id, transferRequest);
399
393
 
400
394
  if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });
401
395
 
@@ -409,9 +403,9 @@ export class KioskTransaction {
409
403
  */
410
404
  setCap(cap: KioskOwnerCap) {
411
405
  this.#validateFinalizedStatus();
412
- this.kiosk = this.transactionBlock.object(cap.kioskId);
406
+ this.kiosk = this.transaction.object(cap.kioskId);
413
407
  if (!cap.isPersonal) {
414
- this.kioskCap = this.transactionBlock.object(cap.objectId);
408
+ this.kioskCap = this.transaction.object(cap.objectId);
415
409
  return;
416
410
  }
417
411
 
@@ -419,7 +413,7 @@ export class KioskTransaction {
419
413
  }
420
414
 
421
415
  /**
422
- * A function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the
416
+ * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
423
417
  * `PersonalKioskCap`, in case we are operating on a personal kiosk.
424
418
  * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
425
419
  */
@@ -442,21 +436,17 @@ export class KioskTransaction {
442
436
 
443
437
  // if we have a promise, return the `ownerCap` back to the personal cap.
444
438
  if (this.#promise) {
445
- this.transactionBlock.moveCall({
439
+ this.transaction.moveCall({
446
440
  target: `${packageId}::personal_kiosk::return_val`,
447
- arguments: [
448
- this.#personalCap,
449
- this.transactionBlock.object(this.kioskCap!),
450
- this.#promise!,
451
- ],
441
+ arguments: [this.#personalCap, this.transaction.object(this.kioskCap!), this.#promise!],
452
442
  });
453
443
  }
454
444
 
455
445
  // If we are pending transferring the personalCap, we do it here.
456
446
  if (this.#pendingTransfer)
457
- transferPersonalCapTx(this.transactionBlock, this.#personalCap, packageId);
447
+ transferPersonalCapTx(this.transaction, this.#personalCap, packageId);
458
448
 
459
- // Mark the transaction block as finalized, so no other functions can be called.
449
+ // Mark the transaction as finalized, so no other functions can be called.
460
450
  this.#finalized = true;
461
451
  }
462
452
 
@@ -496,15 +486,15 @@ export class KioskTransaction {
496
486
  * A function to borrow from `personalCap`.
497
487
  */
498
488
  #borrowFromPersonalCap(personalCap: ObjectArgument) {
499
- const [kioskCap, promise] = this.transactionBlock.moveCall({
489
+ const [kioskCap, promise] = this.transaction.moveCall({
500
490
  target: `${this.kioskClient.getRulePackageId(
501
491
  'personalKioskRulePackageId',
502
492
  )}::personal_kiosk::borrow_val`,
503
- arguments: [this.transactionBlock.object(personalCap)],
493
+ arguments: [this.transaction.object(personalCap)],
504
494
  });
505
495
 
506
496
  this.kioskCap = kioskCap;
507
- this.#personalCap = this.transactionBlock.object(personalCap);
497
+ this.#personalCap = this.transaction.object(personalCap);
508
498
  this.#promise = promise;
509
499
 
510
500
  return this;
@@ -527,6 +517,6 @@ export class KioskTransaction {
527
517
  // Validates that `finalize`
528
518
  #validateFinalizedStatus() {
529
519
  if (this.#finalized)
530
- throw new Error("You can't add more transactions to a finalized kiosk transaction block.");
520
+ throw new Error("You can't add more transactions to a finalized kiosk transaction.");
531
521
  }
532
522
  }
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { TransactionBlock, TransactionObjectArgument } from '@mysten/sui.js/transactions';
4
+ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
5
 
6
6
  import {
7
7
  attachFloorPriceRuleTx,
@@ -27,20 +27,27 @@ export type TransferPolicyBaseParams = {
27
27
 
28
28
  export type TransferPolicyTransactionParams = {
29
29
  kioskClient: KioskClient;
30
- transactionBlock: TransactionBlock;
30
+ transaction: Transaction;
31
+ /** @deprecated use transaction instead */
32
+ transactionBlock?: Transaction;
31
33
  cap?: TransferPolicyCap;
32
34
  };
33
35
 
34
36
  export class TransferPolicyTransaction {
35
- transactionBlock: TransactionBlock;
37
+ transaction: Transaction;
36
38
  kioskClient: KioskClient;
37
39
  policy?: ObjectArgument;
38
40
  policyCap?: ObjectArgument;
39
41
  type?: string;
40
42
 
41
- constructor({ kioskClient, transactionBlock, cap }: TransferPolicyTransactionParams) {
43
+ constructor({
44
+ kioskClient,
45
+ transactionBlock,
46
+ transaction = transactionBlock!,
47
+ cap,
48
+ }: TransferPolicyTransactionParams) {
42
49
  this.kioskClient = kioskClient;
43
- this.transactionBlock = transactionBlock;
50
+ this.transaction = transaction;
44
51
  if (cap) this.setCap(cap);
45
52
  }
46
53
 
@@ -68,8 +75,8 @@ export class TransferPolicyTransaction {
68
75
  const policies = await this.kioskClient.getTransferPolicies({ type });
69
76
  if (policies.length > 0) throw new Error("There's already transfer policy for this Type.");
70
77
  }
71
- const cap = createTransferPolicy(this.transactionBlock, type, publisher);
72
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
78
+ const cap = createTransferPolicy(this.transaction, type, publisher);
79
+ this.transaction.transferObjects([cap], this.transaction.pure.address(address));
73
80
  }
74
81
 
75
82
  /**
@@ -90,7 +97,7 @@ export class TransferPolicyTransaction {
90
97
  if (policies.length > 0) throw new Error("There's already transfer policy for this Type.");
91
98
  }
92
99
  const [policy, policyCap] = createTransferPolicyWithoutSharing(
93
- this.transactionBlock,
100
+ this.transaction,
94
101
  type,
95
102
  publisher,
96
103
  );
@@ -109,10 +116,10 @@ export class TransferPolicyTransaction {
109
116
  if (!this.type || !this.policyCap || !this.policy)
110
117
  throw new Error('This function can only be called after `transferPolicyManager.create`');
111
118
 
112
- shareTransferPolicy(this.transactionBlock, this.type, this.policy as TransactionObjectArgument);
113
- this.transactionBlock.transferObjects(
119
+ shareTransferPolicy(this.transaction, this.type, this.policy as TransactionObjectArgument);
120
+ this.transaction.transferObjects(
114
121
  [this.policyCap as TransactionObjectArgument],
115
- this.transactionBlock.pure.address(address),
122
+ this.transaction.pure.address(address),
116
123
  );
117
124
  }
118
125
 
@@ -134,14 +141,14 @@ export class TransferPolicyTransaction {
134
141
  this.#validateInputs();
135
142
  // Withdraw coin for specified amount (or none)
136
143
  const coin = withdrawFromPolicy(
137
- this.transactionBlock,
144
+ this.transaction,
138
145
  this.type!,
139
146
  this.policy!,
140
147
  this.policyCap!,
141
148
  amount,
142
149
  );
143
150
 
144
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
151
+ this.transaction.transferObjects([coin], this.transaction.pure.address(address));
145
152
 
146
153
  return this;
147
154
  }
@@ -166,7 +173,7 @@ export class TransferPolicyTransaction {
166
173
  // Also, it's hard to keep versioning as with network wipes, mainnet
167
174
  // and testnet will conflict.
168
175
  attachRoyaltyRuleTx(
169
- this.transactionBlock,
176
+ this.transaction,
170
177
  this.type!,
171
178
  this.policy!,
172
179
  this.policyCap!,
@@ -185,7 +192,7 @@ export class TransferPolicyTransaction {
185
192
  this.#validateInputs();
186
193
 
187
194
  attachKioskLockRuleTx(
188
- this.transactionBlock,
195
+ this.transaction,
189
196
  this.type!,
190
197
  this.policy!,
191
198
  this.policyCap!,
@@ -201,7 +208,7 @@ export class TransferPolicyTransaction {
201
208
  this.#validateInputs();
202
209
 
203
210
  attachPersonalKioskRuleTx(
204
- this.transactionBlock,
211
+ this.transaction,
205
212
  this.type!,
206
213
  this.policy!,
207
214
  this.policyCap!,
@@ -218,7 +225,7 @@ export class TransferPolicyTransaction {
218
225
  this.#validateInputs();
219
226
 
220
227
  attachFloorPriceRuleTx(
221
- this.transactionBlock,
228
+ this.transaction,
222
229
  this.type!,
223
230
  this.policy!,
224
231
  this.policyCap!,
@@ -237,7 +244,7 @@ export class TransferPolicyTransaction {
237
244
  this.#validateInputs();
238
245
 
239
246
  removeTransferPolicyRule(
240
- this.transactionBlock,
247
+ this.transaction,
241
248
  this.type!,
242
249
  ruleType,
243
250
  configType,
@@ -255,7 +262,7 @@ export class TransferPolicyTransaction {
255
262
  const packageId = this.kioskClient.getRulePackageId('kioskLockRulePackageId');
256
263
 
257
264
  removeTransferPolicyRule(
258
- this.transactionBlock,
265
+ this.transaction,
259
266
  this.type!,
260
267
  `${packageId}::kiosk_lock_rule::Rule`,
261
268
  `${packageId}::kiosk_lock_rule::Config`,
@@ -274,7 +281,7 @@ export class TransferPolicyTransaction {
274
281
  const packageId = this.kioskClient.getRulePackageId('royaltyRulePackageId');
275
282
 
276
283
  removeTransferPolicyRule(
277
- this.transactionBlock,
284
+ this.transaction,
278
285
  this.type!,
279
286
  `${packageId}::royalty_rule::Rule`,
280
287
  `${packageId}::royalty_rule::Config`,
@@ -290,7 +297,7 @@ export class TransferPolicyTransaction {
290
297
  const packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');
291
298
 
292
299
  removeTransferPolicyRule(
293
- this.transactionBlock,
300
+ this.transaction,
294
301
  this.type!,
295
302
  `${packageId}::personal_kiosk_rule::Rule`,
296
303
  `bool`,
@@ -306,7 +313,7 @@ export class TransferPolicyTransaction {
306
313
  const packageId = this.kioskClient.getRulePackageId('floorPriceRulePackageId');
307
314
 
308
315
  removeTransferPolicyRule(
309
- this.transactionBlock,
316
+ this.transaction,
310
317
  this.type!,
311
318
  `${packageId}::floor_price_rule::Rule`,
312
319
  `${packageId}::floor_price_rule::Config`,
@@ -7,8 +7,8 @@ import type {
7
7
  SuiObjectData,
8
8
  SuiObjectDataFilter,
9
9
  SuiObjectResponse,
10
- } from '@mysten/sui.js/client';
11
- import { isValidSuiAddress } from '@mysten/sui.js/utils';
10
+ } from '@mysten/sui/client';
11
+ import { isValidSuiAddress } from '@mysten/sui/utils';
12
12
 
13
13
  import type {
14
14
  FetchKioskOptions,
@@ -1,10 +1,12 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { SuiClient } from '@mysten/sui.js/client';
5
- import { isValidSuiAddress } from '@mysten/sui.js/utils';
4
+ import type { SuiClient } from '@mysten/sui/client';
5
+ import { fromB64, isValidSuiAddress } from '@mysten/sui/utils';
6
6
 
7
- import { bcs } from '../bcs.js';
7
+ import '../bcs.js';
8
+
9
+ import { TransferPolicyType } from '../bcs.js';
8
10
  import type { TransferPolicy, TransferPolicyCap } from '../types/index.js';
9
11
  import {
10
12
  TRANSFER_POLICY_CAP_TYPE,
@@ -48,7 +50,7 @@ export async function queryTransferPolicy(
48
50
  throw new Error(`Invalid policy: ${policy?.objectId}, expected object, got package`);
49
51
  }
50
52
 
51
- const parsed = bcs.de(TRANSFER_POLICY_TYPE, policy.bcs.bcsBytes, 'base64');
53
+ const parsed = TransferPolicyType.parse(fromB64(policy.bcs.bcsBytes));
52
54
 
53
55
  return {
54
56
  id: policy?.objectId,
package/src/tx/kiosk.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { bcs } from '@mysten/sui.js/bcs';
4
+ import { bcs } from '@mysten/sui/bcs';
5
5
  import type {
6
+ Transaction,
6
7
  TransactionArgument,
7
- TransactionBlock,
8
8
  TransactionObjectArgument,
9
- } from '@mysten/sui.js/transactions';
9
+ } from '@mysten/sui/transactions';
10
10
 
11
11
  import type { ObjectArgument } from '../types/index.js';
12
12
  import { KIOSK_MODULE, KIOSK_TYPE } from '../types/index.js';
@@ -15,7 +15,7 @@ import { KIOSK_MODULE, KIOSK_TYPE } from '../types/index.js';
15
15
  * Create a new shared Kiosk and returns the [kiosk, kioskOwnerCap] tuple.
16
16
  */
17
17
  export function createKiosk(
18
- tx: TransactionBlock,
18
+ tx: Transaction,
19
19
  ): [TransactionObjectArgument, TransactionObjectArgument] {
20
20
  const [kiosk, kioskOwnerCap] = tx.moveCall({
21
21
  target: `${KIOSK_MODULE}::new`,
@@ -28,7 +28,7 @@ export function createKiosk(
28
28
  * Calls the `kiosk::new()` function and shares the kiosk.
29
29
  * Returns the `kioskOwnerCap` object.
30
30
  */
31
- export function createKioskAndShare(tx: TransactionBlock): TransactionObjectArgument {
31
+ export function createKioskAndShare(tx: Transaction): TransactionObjectArgument {
32
32
  const [kiosk, kioskOwnerCap] = createKiosk(tx);
33
33
  shareKiosk(tx, kiosk);
34
34
  return kioskOwnerCap;
@@ -37,7 +37,7 @@ export function createKioskAndShare(tx: TransactionBlock): TransactionObjectArgu
37
37
  /**
38
38
  * Converts Transfer Policy to a shared object.
39
39
  */
40
- export function shareKiosk(tx: TransactionBlock, kiosk: TransactionArgument) {
40
+ export function shareKiosk(tx: Transaction, kiosk: TransactionArgument) {
41
41
  tx.moveCall({
42
42
  target: `0x2::transfer::public_share_object`,
43
43
  typeArguments: [KIOSK_TYPE],
@@ -50,7 +50,7 @@ export function shareKiosk(tx: TransactionBlock, kiosk: TransactionArgument) {
50
50
  * Place an item to the Kiosk.
51
51
  */
52
52
  export function place(
53
- tx: TransactionBlock,
53
+ tx: Transaction,
54
54
  itemType: string,
55
55
  kiosk: ObjectArgument,
56
56
  kioskCap: ObjectArgument,
@@ -72,7 +72,7 @@ export function place(
72
72
  * locked without an option to take it out.
73
73
  */
74
74
  export function lock(
75
- tx: TransactionBlock,
75
+ tx: Transaction,
76
76
  itemType: string,
77
77
  kiosk: ObjectArgument,
78
78
  kioskCap: ObjectArgument,
@@ -91,7 +91,7 @@ export function lock(
91
91
  * Take an item from the Kiosk.
92
92
  */
93
93
  export function take(
94
- tx: TransactionBlock,
94
+ tx: Transaction,
95
95
  itemType: string,
96
96
  kiosk: ObjectArgument,
97
97
  kioskCap: ObjectArgument,
@@ -111,7 +111,7 @@ export function take(
111
111
  * List an item for sale.
112
112
  */
113
113
  export function list(
114
- tx: TransactionBlock,
114
+ tx: Transaction,
115
115
  itemType: string,
116
116
  kiosk: ObjectArgument,
117
117
  kioskCap: ObjectArgument,
@@ -130,7 +130,7 @@ export function list(
130
130
  * List an item for sale.
131
131
  */
132
132
  export function delist(
133
- tx: TransactionBlock,
133
+ tx: Transaction,
134
134
  itemType: string,
135
135
  kiosk: ObjectArgument,
136
136
  kioskCap: ObjectArgument,
@@ -148,7 +148,7 @@ export function delist(
148
148
  * Place an item to the Kiosk and list it for sale.
149
149
  */
150
150
  export function placeAndList(
151
- tx: TransactionBlock,
151
+ tx: Transaction,
152
152
  itemType: string,
153
153
  kiosk: ObjectArgument,
154
154
  kioskCap: ObjectArgument,
@@ -167,7 +167,7 @@ export function placeAndList(
167
167
  * a TransferRequest which needs to be dealt with (via a matching TransferPolicy).
168
168
  */
169
169
  export function purchase(
170
- tx: TransactionBlock,
170
+ tx: Transaction,
171
171
  itemType: string,
172
172
  kiosk: ObjectArgument,
173
173
  itemId: string,
@@ -187,7 +187,7 @@ export function purchase(
187
187
  * If the amount is null, then the entire balance will be withdrawn.
188
188
  */
189
189
  export function withdrawFromKiosk(
190
- tx: TransactionBlock,
190
+ tx: Transaction,
191
191
  kiosk: ObjectArgument,
192
192
  kioskCap: ObjectArgument,
193
193
  amount?: string | bigint | number,
@@ -209,7 +209,7 @@ export function withdrawFromKiosk(
209
209
  * Requires calling `returnValue` to return the item.
210
210
  */
211
211
  export function borrowValue(
212
- tx: TransactionBlock,
212
+ tx: Transaction,
213
213
  itemType: string,
214
214
  kiosk: ObjectArgument,
215
215
  kioskCap: ObjectArgument,
@@ -229,7 +229,7 @@ export function borrowValue(
229
229
  * Return an item to the Kiosk after it was `borrowValue`-d.
230
230
  */
231
231
  export function returnValue(
232
- tx: TransactionBlock,
232
+ tx: Transaction,
233
233
  itemType: string,
234
234
  kiosk: ObjectArgument,
235
235
  item: TransactionArgument,
@@ -1,12 +1,12 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { TransactionBlock, TransactionObjectArgument } from '@mysten/sui.js/transactions';
4
+ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
5
 
6
6
  import type { ObjectArgument } from '../types/index.js';
7
7
 
8
8
  export function convertToPersonalTx(
9
- tx: TransactionBlock,
9
+ tx: Transaction,
10
10
  kiosk: ObjectArgument,
11
11
  kioskOwnerCap: ObjectArgument,
12
12
  packageId: string,
@@ -23,7 +23,7 @@ export function convertToPersonalTx(
23
23
  * Transfers the personal kiosk Cap to the sender.
24
24
  */
25
25
  export function transferPersonalCapTx(
26
- tx: TransactionBlock,
26
+ tx: Transaction,
27
27
  personalKioskCap: TransactionObjectArgument,
28
28
  packageId: string,
29
29
  ) {