@mysten/kiosk 0.7.0 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mysten/kiosk
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [781d073d9]
8
+ - Updated dependencies [3764c464f]
9
+ - Updated dependencies [e4484852b]
10
+ - Updated dependencies [71e0a3197]
11
+ - Updated dependencies [1bc430161]
12
+ - @mysten/sui.js@0.43.0
13
+
3
14
  ## 0.7.0
4
15
 
5
16
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { type TransactionArgument, type TransactionBlock } from '@mysten/sui.js/transactions';
1
+ import { TransactionObjectArgument, type TransactionArgument, type TransactionBlock } from '@mysten/sui.js/transactions';
2
2
  import { ItemId, ItemReference, ItemValue, KioskOwnerCap, ObjectArgument, Price, PurchaseOptions } from '../types';
3
3
  import { type KioskClient } from './kiosk-client';
4
4
  export type KioskTransactionParams = {
@@ -22,8 +22,8 @@ export declare class KioskTransaction {
22
22
  #private;
23
23
  transactionBlock: TransactionBlock;
24
24
  kioskClient: KioskClient;
25
- kiosk?: TransactionArgument;
26
- kioskCap?: TransactionArgument;
25
+ kiosk?: TransactionObjectArgument;
26
+ kioskCap?: TransactionObjectArgument;
27
27
  constructor({ transactionBlock, kioskClient, cap }: KioskTransactionParams);
28
28
  /**
29
29
  * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
@@ -114,7 +114,7 @@ export declare class KioskTransaction {
114
114
  * @param itemType The type `T` of the item
115
115
  * @param itemId The ID of the item
116
116
  */
117
- take({ itemType, itemId }: ItemId): TransactionArgument;
117
+ take({ itemType, itemId }: ItemId): TransactionObjectArgument;
118
118
  /**
119
119
  * Transfer a non-locked/non-listed item to an address.
120
120
  *
@@ -146,7 +146,10 @@ export declare class KioskTransaction {
146
146
  */
147
147
  purchase({ itemType, itemId, price, sellerKiosk, }: ItemId & Price & {
148
148
  sellerKiosk: ObjectArgument;
149
- }): [TransactionArgument, TransactionArgument];
149
+ }): [
150
+ TransactionObjectArgument,
151
+ TransactionObjectArgument
152
+ ];
150
153
  /**
151
154
  * A function to purchase and resolve a transfer policy.
152
155
  * If the transfer policy has the `lock` rule, the item is locked in the kiosk.
@@ -172,36 +175,8 @@ export declare class KioskTransaction {
172
175
  * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
173
176
  */
174
177
  finalize(): void;
175
- setKioskCap(cap: TransactionArgument): this;
176
- setKiosk(kiosk: TransactionArgument): this;
177
- getKiosk(): {
178
- kind: "Input";
179
- index: number;
180
- type?: "object" | "pure" | undefined;
181
- value?: any;
182
- } | {
183
- kind: "GasCoin";
184
- } | {
185
- kind: "Result";
186
- index: number;
187
- } | {
188
- kind: "NestedResult";
189
- index: number;
190
- resultIndex: number;
191
- };
192
- getKioskCap(): {
193
- kind: "Input";
194
- index: number;
195
- type?: "object" | "pure" | undefined;
196
- value?: any;
197
- } | {
198
- kind: "GasCoin";
199
- } | {
200
- kind: "Result";
201
- index: number;
202
- } | {
203
- kind: "NestedResult";
204
- index: number;
205
- resultIndex: number;
206
- };
178
+ setKioskCap(cap: TransactionObjectArgument): this;
179
+ setKiosk(kiosk: TransactionObjectArgument): this;
180
+ getKiosk(): TransactionObjectArgument;
181
+ getKioskCap(): TransactionObjectArgument;
207
182
  }
package/dist/index.js CHANGED
@@ -320,6 +320,7 @@ function getNormalizedRuleType(rule) {
320
320
  }
321
321
 
322
322
  // src/tx/kiosk.ts
323
+ var import_bcs3 = require("@mysten/sui.js/bcs");
323
324
  function createKiosk(tx) {
324
325
  const [kiosk, kioskOwnerCap] = tx.moveCall({
325
326
  target: `${KIOSK_MODULE}::new`
@@ -356,7 +357,7 @@ function take(tx, itemType, kiosk, kioskCap, itemId) {
356
357
  const [item] = tx.moveCall({
357
358
  target: `${KIOSK_MODULE}::take`,
358
359
  typeArguments: [itemType],
359
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
360
+ arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure.address(itemId)]
360
361
  });
361
362
  return item;
362
363
  }
@@ -367,8 +368,8 @@ function list(tx, itemType, kiosk, kioskCap, itemId, price) {
367
368
  arguments: [
368
369
  objArg(tx, kiosk),
369
370
  objArg(tx, kioskCap),
370
- tx.pure(itemId, "address"),
371
- tx.pure(price, "u64")
371
+ tx.pure.address(itemId),
372
+ tx.pure.u64(price)
372
373
  ]
373
374
  });
374
375
  }
@@ -376,26 +377,26 @@ function delist(tx, itemType, kiosk, kioskCap, itemId) {
376
377
  tx.moveCall({
377
378
  target: `${KIOSK_MODULE}::delist`,
378
379
  typeArguments: [itemType],
379
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
380
+ arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure.address(itemId)]
380
381
  });
381
382
  }
382
383
  function placeAndList(tx, itemType, kiosk, kioskCap, item, price) {
383
384
  tx.moveCall({
384
385
  target: `${KIOSK_MODULE}::place_and_list`,
385
386
  typeArguments: [itemType],
386
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), objArg(tx, item), tx.pure(price, "u64")]
387
+ arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), objArg(tx, item), tx.pure.u64(price)]
387
388
  });
388
389
  }
389
390
  function purchase(tx, itemType, kiosk, itemId, payment) {
390
391
  const [item, transferRequest] = tx.moveCall({
391
392
  target: `${KIOSK_MODULE}::purchase`,
392
393
  typeArguments: [itemType],
393
- arguments: [objArg(tx, kiosk), tx.pure(itemId, "address"), objArg(tx, payment)]
394
+ arguments: [objArg(tx, kiosk), tx.pure.address(itemId), objArg(tx, payment)]
394
395
  });
395
396
  return [item, transferRequest];
396
397
  }
397
398
  function withdrawFromKiosk(tx, kiosk, kioskCap, amount) {
398
- const amountArg = tx.pure(amount ? { Some: amount } : { None: true }, "Option<u64>");
399
+ const amountArg = import_bcs3.bcs.option(import_bcs3.bcs.u64()).serialize(amount);
399
400
  const [coin] = tx.moveCall({
400
401
  target: `${KIOSK_MODULE}::withdraw`,
401
402
  arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), amountArg]
@@ -406,7 +407,7 @@ function borrowValue(tx, itemType, kiosk, kioskCap, itemId) {
406
407
  const [item, promise] = tx.moveCall({
407
408
  target: `${KIOSK_MODULE}::borrow_val`,
408
409
  typeArguments: [itemType],
409
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure(itemId, "address")]
410
+ arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure.address(itemId)]
410
411
  });
411
412
  return [item, promise];
412
413
  }
@@ -796,8 +797,8 @@ function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmou
796
797
  arguments: [
797
798
  objArg(tx, policy),
798
799
  objArg(tx, policyCap),
799
- tx.pure(percentageBps, "u16"),
800
- tx.pure(minAmount, "u64")
800
+ tx.pure.u16(Number(percentageBps)),
801
+ tx.pure.u64(minAmount)
801
802
  ]
802
803
  });
803
804
  }
@@ -812,11 +813,12 @@ function attachFloorPriceRuleTx(tx, type, policy, policyCap, minPrice, packageId
812
813
  tx.moveCall({
813
814
  target: `${packageId}::floor_price_rule::add`,
814
815
  typeArguments: [type],
815
- arguments: [objArg(tx, policy), objArg(tx, policyCap), tx.pure(minPrice, "u64")]
816
+ arguments: [objArg(tx, policy), objArg(tx, policyCap), tx.pure.u64(minPrice)]
816
817
  });
817
818
  }
818
819
 
819
820
  // src/tx/transfer-policy.ts
821
+ var import_bcs5 = require("@mysten/sui.js/bcs");
820
822
  function createTransferPolicy(tx, itemType, publisher) {
821
823
  const [transferPolicy, transferPolicyCap] = createTransferPolicyWithoutSharing(
822
824
  tx,
@@ -842,7 +844,7 @@ function shareTransferPolicy(tx, itemType, transferPolicy) {
842
844
  });
843
845
  }
844
846
  function withdrawFromPolicy(tx, itemType, policy, policyCap, amount) {
845
- const amountArg = tx.pure(amount ? { Some: amount } : { None: true }, "Option<u64>");
847
+ const amountArg = import_bcs5.bcs.option(import_bcs5.bcs.u64()).serialize(amount);
846
848
  const [profits] = tx.moveCall({
847
849
  target: `${TRANSFER_POLICY_MODULE}::withdraw`,
848
850
  typeArguments: [itemType],
@@ -904,7 +906,7 @@ var TransferPolicyTransaction = class {
904
906
  throw new Error("There's already transfer policy for this Type.");
905
907
  }
906
908
  const cap = createTransferPolicy(this.transactionBlock, type, publisher);
907
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure(address, "address"));
909
+ this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
908
910
  }
909
911
  /**
910
912
  * A convenient function to create a Transfer Policy and attach some rules
@@ -944,7 +946,7 @@ var TransferPolicyTransaction = class {
944
946
  shareTransferPolicy(this.transactionBlock, this.type, this.policy);
945
947
  this.transactionBlock.transferObjects(
946
948
  [this.policyCap],
947
- this.transactionBlock.pure(address, "address")
949
+ this.transactionBlock.pure.address(address)
948
950
  );
949
951
  }
950
952
  /**
@@ -969,7 +971,7 @@ var TransferPolicyTransaction = class {
969
971
  this.policyCap,
970
972
  amount
971
973
  );
972
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure(address, "address"));
974
+ this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
973
975
  return this;
974
976
  }
975
977
  /**
@@ -1237,7 +1239,7 @@ var KioskTransaction = class {
1237
1239
  createAndShare(address) {
1238
1240
  __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1239
1241
  const cap = createKioskAndShare(this.transactionBlock);
1240
- this.transactionBlock.transferObjects([cap], this.transactionBlock.pure(address, "address"));
1242
+ this.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));
1241
1243
  }
1242
1244
  /**
1243
1245
  * Shares the kiosk.
@@ -1258,7 +1260,7 @@ var KioskTransaction = class {
1258
1260
  this.share();
1259
1261
  this.transactionBlock.transferObjects(
1260
1262
  [this.kioskCap],
1261
- this.transactionBlock.pure(address, "address")
1263
+ this.transactionBlock.pure.address(address)
1262
1264
  );
1263
1265
  }
1264
1266
  /**
@@ -1316,7 +1318,7 @@ var KioskTransaction = class {
1316
1318
  this.kioskCap,
1317
1319
  amount
1318
1320
  );
1319
- this.transactionBlock.transferObjects([coin], this.transactionBlock.pure(address, "address"));
1321
+ this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
1320
1322
  return this;
1321
1323
  }
1322
1324
  /**
@@ -1381,7 +1383,7 @@ var KioskTransaction = class {
1381
1383
  transfer({ itemType, itemId, address }) {
1382
1384
  __privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
1383
1385
  const item = this.take({ itemType, itemId });
1384
- this.transactionBlock.transferObjects([item], this.transactionBlock.pure(address, "address"));
1386
+ this.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));
1385
1387
  return this;
1386
1388
  }
1387
1389
  /**
@@ -1412,7 +1414,7 @@ var KioskTransaction = class {
1412
1414
  sellerKiosk
1413
1415
  }) {
1414
1416
  const coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [
1415
- this.transactionBlock.pure(price, "u64")
1417
+ this.transactionBlock.pure.u64(price)
1416
1418
  ]);
1417
1419
  return purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);
1418
1420
  }