@mysten/kiosk 0.7.7 → 0.7.9

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,25 @@
1
1
  # @mysten/kiosk
2
2
 
3
+ ## 0.7.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 43444c58f: Extend the `TransactionBlock#object()` API to accept the `TransactionResult` type as well, so that it can be used flexibly in SDKs.
8
+ - 3718a230b: Adds `txb.pure.id()` to pass ID pure values more intuitively
9
+ - Updated dependencies [28c2c3330]
10
+ - Updated dependencies [43444c58f]
11
+ - Updated dependencies [8d1e74e52]
12
+ - Updated dependencies [093554a0d]
13
+ - Updated dependencies [3718a230b]
14
+ - @mysten/sui.js@0.46.0
15
+
16
+ ## 0.7.8
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [30b47b758]
21
+ - @mysten/sui.js@0.45.1
22
+
3
23
  ## 0.7.7
4
24
 
5
25
  ### Patch Changes
package/dist/index.js CHANGED
@@ -74,7 +74,6 @@ __export(src_exports, {
74
74
  getKioskObject: () => getKioskObject,
75
75
  getNormalizedRuleType: () => getNormalizedRuleType,
76
76
  mainnetRules: () => mainnetRules,
77
- objArg: () => objArg,
78
77
  parseTransferPolicyCapObject: () => parseTransferPolicyCapObject,
79
78
  percentageToBasisPoints: () => percentageToBasisPoints,
80
79
  rules: () => rules,
@@ -138,21 +137,6 @@ import_bcs.bcs.registerStructType(TRANSFER_POLICY_TYPE, {
138
137
 
139
138
  // src/utils.ts
140
139
  var DEFAULT_QUERY_LIMIT = 50;
141
- function objArg(txb, arg) {
142
- if (typeof arg === "string") {
143
- return txb.object(arg);
144
- }
145
- if ("digest" in arg && "version" in arg && "objectId" in arg) {
146
- return txb.objectRef(arg);
147
- }
148
- if ("objectId" in arg && "initialSharedVersion" in arg && "mutable" in arg) {
149
- return txb.sharedObjectRef(arg);
150
- }
151
- if ("kind" in arg) {
152
- return arg;
153
- }
154
- throw new Error("Invalid argument type");
155
- }
156
140
  async function getKioskObject(client, id) {
157
141
  const queryRes = await client.getObject({ id, options: { showBcs: true } });
158
142
  if (!queryRes || queryRes.error || !queryRes.data) {
@@ -343,21 +327,21 @@ function place(tx, itemType, kiosk, kioskCap, item) {
343
327
  tx.moveCall({
344
328
  target: `${KIOSK_MODULE}::place`,
345
329
  typeArguments: [itemType],
346
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), objArg(tx, item)]
330
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item)]
347
331
  });
348
332
  }
349
333
  function lock(tx, itemType, kiosk, kioskCap, policy, item) {
350
334
  tx.moveCall({
351
335
  target: `${KIOSK_MODULE}::lock`,
352
336
  typeArguments: [itemType],
353
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), objArg(tx, policy), objArg(tx, item)]
337
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(policy), tx.object(item)]
354
338
  });
355
339
  }
356
340
  function take(tx, itemType, kiosk, kioskCap, itemId) {
357
341
  const [item] = tx.moveCall({
358
342
  target: `${KIOSK_MODULE}::take`,
359
343
  typeArguments: [itemType],
360
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure.address(itemId)]
344
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
361
345
  });
362
346
  return item;
363
347
  }
@@ -365,33 +349,28 @@ function list(tx, itemType, kiosk, kioskCap, itemId, price) {
365
349
  tx.moveCall({
366
350
  target: `${KIOSK_MODULE}::list`,
367
351
  typeArguments: [itemType],
368
- arguments: [
369
- objArg(tx, kiosk),
370
- objArg(tx, kioskCap),
371
- tx.pure.address(itemId),
372
- tx.pure.u64(price)
373
- ]
352
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId), tx.pure.u64(price)]
374
353
  });
375
354
  }
376
355
  function delist(tx, itemType, kiosk, kioskCap, itemId) {
377
356
  tx.moveCall({
378
357
  target: `${KIOSK_MODULE}::delist`,
379
358
  typeArguments: [itemType],
380
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure.address(itemId)]
359
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
381
360
  });
382
361
  }
383
362
  function placeAndList(tx, itemType, kiosk, kioskCap, item, price) {
384
363
  tx.moveCall({
385
364
  target: `${KIOSK_MODULE}::place_and_list`,
386
365
  typeArguments: [itemType],
387
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), objArg(tx, item), tx.pure.u64(price)]
366
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item), tx.pure.u64(price)]
388
367
  });
389
368
  }
390
369
  function purchase(tx, itemType, kiosk, itemId, payment) {
391
370
  const [item, transferRequest] = tx.moveCall({
392
371
  target: `${KIOSK_MODULE}::purchase`,
393
372
  typeArguments: [itemType],
394
- arguments: [objArg(tx, kiosk), tx.pure.address(itemId), objArg(tx, payment)]
373
+ arguments: [tx.object(kiosk), tx.pure.id(itemId), tx.object(payment)]
395
374
  });
396
375
  return [item, transferRequest];
397
376
  }
@@ -399,7 +378,7 @@ function withdrawFromKiosk(tx, kiosk, kioskCap, amount) {
399
378
  const amountArg = import_bcs3.bcs.option(import_bcs3.bcs.u64()).serialize(amount);
400
379
  const [coin] = tx.moveCall({
401
380
  target: `${KIOSK_MODULE}::withdraw`,
402
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), amountArg]
381
+ arguments: [tx.object(kiosk), tx.object(kioskCap), amountArg]
403
382
  });
404
383
  return coin;
405
384
  }
@@ -407,7 +386,7 @@ function borrowValue(tx, itemType, kiosk, kioskCap, itemId) {
407
386
  const [item, promise] = tx.moveCall({
408
387
  target: `${KIOSK_MODULE}::borrow_val`,
409
388
  typeArguments: [itemType],
410
- arguments: [objArg(tx, kiosk), objArg(tx, kioskCap), tx.pure.address(itemId)]
389
+ arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
411
390
  });
412
391
  return [item, promise];
413
392
  }
@@ -415,14 +394,14 @@ function returnValue(tx, itemType, kiosk, item, promise) {
415
394
  tx.moveCall({
416
395
  target: `${KIOSK_MODULE}::return_val`,
417
396
  typeArguments: [itemType],
418
- arguments: [objArg(tx, kiosk), item, promise]
397
+ arguments: [tx.object(kiosk), item, promise]
419
398
  });
420
399
  }
421
400
 
422
401
  // src/tx/rules/resolve.ts
423
402
  function resolveRoyaltyRule(params) {
424
403
  const { transactionBlock: txb, itemType, price, packageId, transferRequest, policyId } = params;
425
- const policyObj = objArg(txb, policyId);
404
+ const policyObj = txb.object(policyId);
426
405
  const [amount] = txb.moveCall({
427
406
  target: `${packageId}::royalty_rule::fee_amount`,
428
407
  typeArguments: [itemType],
@@ -452,7 +431,7 @@ function resolveKioskLockRule(params) {
452
431
  txb.moveCall({
453
432
  target: `${packageId}::kiosk_lock_rule::prove`,
454
433
  typeArguments: [itemType],
455
- arguments: [transferRequest, objArg(txb, kiosk)]
434
+ arguments: [transferRequest, txb.object(kiosk)]
456
435
  });
457
436
  }
458
437
  function resolvePersonalKioskRule(params) {
@@ -462,7 +441,7 @@ function resolvePersonalKioskRule(params) {
462
441
  txb.moveCall({
463
442
  target: `${packageId}::personal_kiosk_rule::prove`,
464
443
  typeArguments: [itemType],
465
- arguments: [objArg(txb, kiosk), transferRequest]
444
+ arguments: [txb.object(kiosk), transferRequest]
466
445
  });
467
446
  }
468
447
  function resolveFloorPriceRule(params) {
@@ -470,7 +449,7 @@ function resolveFloorPriceRule(params) {
470
449
  txb.moveCall({
471
450
  target: `${packageId}::floor_price_rule::prove`,
472
451
  typeArguments: [itemType],
473
- arguments: [objArg(txb, policyId), transferRequest]
452
+ arguments: [txb.object(policyId), transferRequest]
474
453
  });
475
454
  }
476
455
 
@@ -546,7 +525,7 @@ var mainnetRules = getBaseRules({
546
525
  var rules = [...testnetRules, ...mainnetRules];
547
526
 
548
527
  // src/query/kiosk.ts
549
- var import_utils4 = require("@mysten/sui.js/utils");
528
+ var import_utils2 = require("@mysten/sui.js/utils");
550
529
  async function fetchKiosk(client, kioskId, pagination, options) {
551
530
  const data = await getAllDynamicFields(client, kioskId, pagination);
552
531
  const listings = [];
@@ -574,7 +553,7 @@ async function fetchKiosk(client, kioskId, pagination, options) {
574
553
  };
575
554
  }
576
555
  async function getOwnedKiosks(client, address, options) {
577
- if (!(0, import_utils4.isValidSuiAddress)(address))
556
+ if (!(0, import_utils2.isValidSuiAddress)(address))
578
557
  return {
579
558
  nextCursor: null,
580
559
  hasNextPage: false,
@@ -644,7 +623,7 @@ async function fetchKioskExtension(client, kioskId, extensionType) {
644
623
  }
645
624
 
646
625
  // src/query/transfer-policy.ts
647
- var import_utils6 = require("@mysten/sui.js/utils");
626
+ var import_utils4 = require("@mysten/sui.js/utils");
648
627
  async function queryTransferPolicy(client, type) {
649
628
  const { data } = await client.queryEvents({
650
629
  query: {
@@ -671,7 +650,7 @@ async function queryTransferPolicy(client, type) {
671
650
  });
672
651
  }
673
652
  async function queryTransferPolicyCapsByType(client, address, type) {
674
- if (!(0, import_utils6.isValidSuiAddress)(address))
653
+ if (!(0, import_utils4.isValidSuiAddress)(address))
675
654
  return [];
676
655
  const filter = {
677
656
  MatchAll: [
@@ -688,7 +667,7 @@ async function queryTransferPolicyCapsByType(client, address, type) {
688
667
  return data.map((item) => parseTransferPolicyCapObject(item)).filter((item) => !!item);
689
668
  }
690
669
  async function queryOwnedTransferPolicies(client, address) {
691
- if (!(0, import_utils6.isValidSuiAddress)(address))
670
+ if (!(0, import_utils4.isValidSuiAddress)(address))
692
671
  return;
693
672
  const filter = {
694
673
  MatchAll: [
@@ -815,7 +794,7 @@ function attachKioskLockRuleTx(tx, type, policy, policyCap, packageId) {
815
794
  tx.moveCall({
816
795
  target: `${packageId}::kiosk_lock_rule::add`,
817
796
  typeArguments: [type],
818
- arguments: [objArg(tx, policy), objArg(tx, policyCap)]
797
+ arguments: [tx.object(policy), tx.object(policyCap)]
819
798
  });
820
799
  }
821
800
  function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmount, packageId) {
@@ -825,8 +804,8 @@ function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmou
825
804
  target: `${packageId}::royalty_rule::add`,
826
805
  typeArguments: [type],
827
806
  arguments: [
828
- objArg(tx, policy),
829
- objArg(tx, policyCap),
807
+ tx.object(policy),
808
+ tx.object(policyCap),
830
809
  tx.pure.u16(Number(percentageBps)),
831
810
  tx.pure.u64(minAmount)
832
811
  ]
@@ -836,14 +815,14 @@ function attachPersonalKioskRuleTx(tx, type, policy, policyCap, packageId) {
836
815
  tx.moveCall({
837
816
  target: `${packageId}::personal_kiosk_rule::add`,
838
817
  typeArguments: [type],
839
- arguments: [objArg(tx, policy), objArg(tx, policyCap)]
818
+ arguments: [tx.object(policy), tx.object(policyCap)]
840
819
  });
841
820
  }
842
821
  function attachFloorPriceRuleTx(tx, type, policy, policyCap, minPrice, packageId) {
843
822
  tx.moveCall({
844
823
  target: `${packageId}::floor_price_rule::add`,
845
824
  typeArguments: [type],
846
- arguments: [objArg(tx, policy), objArg(tx, policyCap), tx.pure.u64(minPrice)]
825
+ arguments: [tx.object(policy), tx.object(policyCap), tx.pure.u64(minPrice)]
847
826
  });
848
827
  }
849
828
 
@@ -862,7 +841,7 @@ function createTransferPolicyWithoutSharing(tx, itemType, publisher) {
862
841
  const [transferPolicy, transferPolicyCap] = tx.moveCall({
863
842
  target: `${TRANSFER_POLICY_MODULE}::new`,
864
843
  typeArguments: [itemType],
865
- arguments: [objArg(tx, publisher)]
844
+ arguments: [tx.object(publisher)]
866
845
  });
867
846
  return [transferPolicy, transferPolicyCap];
868
847
  }
@@ -878,7 +857,7 @@ function withdrawFromPolicy(tx, itemType, policy, policyCap, amount) {
878
857
  const [profits] = tx.moveCall({
879
858
  target: `${TRANSFER_POLICY_MODULE}::withdraw`,
880
859
  typeArguments: [itemType],
881
- arguments: [objArg(tx, policy), objArg(tx, policyCap), amountArg]
860
+ arguments: [tx.object(policy), tx.object(policyCap), amountArg]
882
861
  });
883
862
  return profits;
884
863
  }
@@ -886,14 +865,14 @@ function confirmRequest(tx, itemType, policy, request) {
886
865
  tx.moveCall({
887
866
  target: `${TRANSFER_POLICY_MODULE}::confirm_request`,
888
867
  typeArguments: [itemType],
889
- arguments: [objArg(tx, policy), request]
868
+ arguments: [tx.object(policy), request]
890
869
  });
891
870
  }
892
871
  function removeTransferPolicyRule(tx, itemType, ruleType, configType, policy, policyCap) {
893
872
  tx.moveCall({
894
873
  target: `${TRANSFER_POLICY_MODULE}::remove_rule`,
895
874
  typeArguments: [itemType, ruleType, configType],
896
- arguments: [objArg(tx, policy), objArg(tx, policyCap)]
875
+ arguments: [tx.object(policy), tx.object(policyCap)]
897
876
  });
898
877
  }
899
878
 
@@ -1181,7 +1160,7 @@ setup_fn = function(policyId, policyCap, type) {
1181
1160
  function convertToPersonalTx(tx, kiosk, kioskOwnerCap, packageId) {
1182
1161
  const personalKioskCap = tx.moveCall({
1183
1162
  target: `${packageId}::personal_kiosk::new`,
1184
- arguments: [objArg(tx, kiosk), objArg(tx, kioskOwnerCap)]
1163
+ arguments: [tx.object(kiosk), tx.object(kioskOwnerCap)]
1185
1164
  });
1186
1165
  return personalKioskCap;
1187
1166
  }
@@ -1515,9 +1494,9 @@ var KioskTransaction = class {
1515
1494
  */
1516
1495
  setCap(cap) {
1517
1496
  __privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
1518
- this.kiosk = objArg(this.transactionBlock, cap.kioskId);
1497
+ this.kiosk = this.transactionBlock.object(cap.kioskId);
1519
1498
  if (!cap.isPersonal) {
1520
- this.kioskCap = objArg(this.transactionBlock, cap.objectId);
1499
+ this.kioskCap = this.transactionBlock.object(cap.objectId);
1521
1500
  return;
1522
1501
  }
1523
1502
  return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
@@ -1544,7 +1523,7 @@ var KioskTransaction = class {
1544
1523
  target: `${packageId}::personal_kiosk::return_val`,
1545
1524
  arguments: [
1546
1525
  __privateGet(this, _personalCap),
1547
- objArg(this.transactionBlock, this.kioskCap),
1526
+ this.transactionBlock.object(this.kioskCap),
1548
1527
  __privateGet(this, _promise)
1549
1528
  ]
1550
1529
  });
@@ -1595,10 +1574,10 @@ borrowFromPersonalCap_fn = function(personalCap) {
1595
1574
  target: `${this.kioskClient.getRulePackageId(
1596
1575
  "personalKioskRulePackageId"
1597
1576
  )}::personal_kiosk::borrow_val`,
1598
- arguments: [objArg(this.transactionBlock, personalCap)]
1577
+ arguments: [this.transactionBlock.object(personalCap)]
1599
1578
  });
1600
1579
  this.kioskCap = kioskCap;
1601
- __privateSet(this, _personalCap, objArg(this.transactionBlock, personalCap));
1580
+ __privateSet(this, _personalCap, this.transactionBlock.object(personalCap));
1602
1581
  __privateSet(this, _promise, promise);
1603
1582
  return this;
1604
1583
  };
@@ -1656,7 +1635,6 @@ validateFinalizedStatus_fn = function() {
1656
1635
  getKioskObject,
1657
1636
  getNormalizedRuleType,
1658
1637
  mainnetRules,
1659
- objArg,
1660
1638
  parseTransferPolicyCapObject,
1661
1639
  percentageToBasisPoints,
1662
1640
  rules,