@mysten/kiosk 0.0.0-experimental-20231108214021 → 0.0.0-experimental-20231113213638
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 +5 -2
- package/dist/index.js +34 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -45
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/utils.d.ts +1 -11
- package/package.json +2 -2
- package/src/client/kiosk-transaction.ts +6 -6
- package/src/tx/kiosk.ts +10 -11
- package/src/tx/personal-kiosk.ts +1 -2
- package/src/tx/rules/attach.ts +5 -6
- package/src/tx/rules/resolve.ts +4 -5
- package/src/tx/transfer-policy.ts +4 -5
- package/src/types/index.ts +2 -3
- package/src/utils.ts +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# @mysten/kiosk
|
|
2
2
|
|
|
3
|
-
## 0.0.0-experimental-
|
|
3
|
+
## 0.0.0-experimental-20231113213638
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 43444c58f: Extend the `TransactionBlock#object()` API to accept the `TransactionResult` type as well, so that it can be used flexibly in SDKs.
|
|
7
8
|
- 3718a230b: Adds `txb.pure.id()` to pass ID pure values more intuitively
|
|
8
9
|
- Updated dependencies [28c2c3330]
|
|
10
|
+
- Updated dependencies [43444c58f]
|
|
11
|
+
- Updated dependencies [8d1e74e52]
|
|
9
12
|
- Updated dependencies [093554a0d]
|
|
10
13
|
- Updated dependencies [3718a230b]
|
|
11
|
-
- @mysten/sui.js@0.0.0-experimental-
|
|
14
|
+
- @mysten/sui.js@0.0.0-experimental-20231113213638
|
|
12
15
|
|
|
13
16
|
## 0.7.8
|
|
14
17
|
|
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: [
|
|
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: [
|
|
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: [
|
|
344
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
361
345
|
});
|
|
362
346
|
return item;
|
|
363
347
|
}
|
|
@@ -365,28 +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: [
|
|
352
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId), tx.pure.u64(price)]
|
|
369
353
|
});
|
|
370
354
|
}
|
|
371
355
|
function delist(tx, itemType, kiosk, kioskCap, itemId) {
|
|
372
356
|
tx.moveCall({
|
|
373
357
|
target: `${KIOSK_MODULE}::delist`,
|
|
374
358
|
typeArguments: [itemType],
|
|
375
|
-
arguments: [
|
|
359
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
376
360
|
});
|
|
377
361
|
}
|
|
378
362
|
function placeAndList(tx, itemType, kiosk, kioskCap, item, price) {
|
|
379
363
|
tx.moveCall({
|
|
380
364
|
target: `${KIOSK_MODULE}::place_and_list`,
|
|
381
365
|
typeArguments: [itemType],
|
|
382
|
-
arguments: [
|
|
366
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item), tx.pure.u64(price)]
|
|
383
367
|
});
|
|
384
368
|
}
|
|
385
369
|
function purchase(tx, itemType, kiosk, itemId, payment) {
|
|
386
370
|
const [item, transferRequest] = tx.moveCall({
|
|
387
371
|
target: `${KIOSK_MODULE}::purchase`,
|
|
388
372
|
typeArguments: [itemType],
|
|
389
|
-
arguments: [
|
|
373
|
+
arguments: [tx.object(kiosk), tx.pure.id(itemId), tx.object(payment)]
|
|
390
374
|
});
|
|
391
375
|
return [item, transferRequest];
|
|
392
376
|
}
|
|
@@ -394,7 +378,7 @@ function withdrawFromKiosk(tx, kiosk, kioskCap, amount) {
|
|
|
394
378
|
const amountArg = import_bcs3.bcs.option(import_bcs3.bcs.u64()).serialize(amount);
|
|
395
379
|
const [coin] = tx.moveCall({
|
|
396
380
|
target: `${KIOSK_MODULE}::withdraw`,
|
|
397
|
-
arguments: [
|
|
381
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), amountArg]
|
|
398
382
|
});
|
|
399
383
|
return coin;
|
|
400
384
|
}
|
|
@@ -402,7 +386,7 @@ function borrowValue(tx, itemType, kiosk, kioskCap, itemId) {
|
|
|
402
386
|
const [item, promise] = tx.moveCall({
|
|
403
387
|
target: `${KIOSK_MODULE}::borrow_val`,
|
|
404
388
|
typeArguments: [itemType],
|
|
405
|
-
arguments: [
|
|
389
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
406
390
|
});
|
|
407
391
|
return [item, promise];
|
|
408
392
|
}
|
|
@@ -410,14 +394,14 @@ function returnValue(tx, itemType, kiosk, item, promise) {
|
|
|
410
394
|
tx.moveCall({
|
|
411
395
|
target: `${KIOSK_MODULE}::return_val`,
|
|
412
396
|
typeArguments: [itemType],
|
|
413
|
-
arguments: [
|
|
397
|
+
arguments: [tx.object(kiosk), item, promise]
|
|
414
398
|
});
|
|
415
399
|
}
|
|
416
400
|
|
|
417
401
|
// src/tx/rules/resolve.ts
|
|
418
402
|
function resolveRoyaltyRule(params) {
|
|
419
403
|
const { transactionBlock: txb, itemType, price, packageId, transferRequest, policyId } = params;
|
|
420
|
-
const policyObj =
|
|
404
|
+
const policyObj = txb.object(policyId);
|
|
421
405
|
const [amount] = txb.moveCall({
|
|
422
406
|
target: `${packageId}::royalty_rule::fee_amount`,
|
|
423
407
|
typeArguments: [itemType],
|
|
@@ -447,7 +431,7 @@ function resolveKioskLockRule(params) {
|
|
|
447
431
|
txb.moveCall({
|
|
448
432
|
target: `${packageId}::kiosk_lock_rule::prove`,
|
|
449
433
|
typeArguments: [itemType],
|
|
450
|
-
arguments: [transferRequest,
|
|
434
|
+
arguments: [transferRequest, txb.object(kiosk)]
|
|
451
435
|
});
|
|
452
436
|
}
|
|
453
437
|
function resolvePersonalKioskRule(params) {
|
|
@@ -457,7 +441,7 @@ function resolvePersonalKioskRule(params) {
|
|
|
457
441
|
txb.moveCall({
|
|
458
442
|
target: `${packageId}::personal_kiosk_rule::prove`,
|
|
459
443
|
typeArguments: [itemType],
|
|
460
|
-
arguments: [
|
|
444
|
+
arguments: [txb.object(kiosk), transferRequest]
|
|
461
445
|
});
|
|
462
446
|
}
|
|
463
447
|
function resolveFloorPriceRule(params) {
|
|
@@ -465,7 +449,7 @@ function resolveFloorPriceRule(params) {
|
|
|
465
449
|
txb.moveCall({
|
|
466
450
|
target: `${packageId}::floor_price_rule::prove`,
|
|
467
451
|
typeArguments: [itemType],
|
|
468
|
-
arguments: [
|
|
452
|
+
arguments: [txb.object(policyId), transferRequest]
|
|
469
453
|
});
|
|
470
454
|
}
|
|
471
455
|
|
|
@@ -541,7 +525,7 @@ var mainnetRules = getBaseRules({
|
|
|
541
525
|
var rules = [...testnetRules, ...mainnetRules];
|
|
542
526
|
|
|
543
527
|
// src/query/kiosk.ts
|
|
544
|
-
var
|
|
528
|
+
var import_utils2 = require("@mysten/sui.js/utils");
|
|
545
529
|
async function fetchKiosk(client, kioskId, pagination, options) {
|
|
546
530
|
const data = await getAllDynamicFields(client, kioskId, pagination);
|
|
547
531
|
const listings = [];
|
|
@@ -569,7 +553,7 @@ async function fetchKiosk(client, kioskId, pagination, options) {
|
|
|
569
553
|
};
|
|
570
554
|
}
|
|
571
555
|
async function getOwnedKiosks(client, address, options) {
|
|
572
|
-
if (!(0,
|
|
556
|
+
if (!(0, import_utils2.isValidSuiAddress)(address))
|
|
573
557
|
return {
|
|
574
558
|
nextCursor: null,
|
|
575
559
|
hasNextPage: false,
|
|
@@ -639,7 +623,7 @@ async function fetchKioskExtension(client, kioskId, extensionType) {
|
|
|
639
623
|
}
|
|
640
624
|
|
|
641
625
|
// src/query/transfer-policy.ts
|
|
642
|
-
var
|
|
626
|
+
var import_utils4 = require("@mysten/sui.js/utils");
|
|
643
627
|
async function queryTransferPolicy(client, type) {
|
|
644
628
|
const { data } = await client.queryEvents({
|
|
645
629
|
query: {
|
|
@@ -666,7 +650,7 @@ async function queryTransferPolicy(client, type) {
|
|
|
666
650
|
});
|
|
667
651
|
}
|
|
668
652
|
async function queryTransferPolicyCapsByType(client, address, type) {
|
|
669
|
-
if (!(0,
|
|
653
|
+
if (!(0, import_utils4.isValidSuiAddress)(address))
|
|
670
654
|
return [];
|
|
671
655
|
const filter = {
|
|
672
656
|
MatchAll: [
|
|
@@ -683,7 +667,7 @@ async function queryTransferPolicyCapsByType(client, address, type) {
|
|
|
683
667
|
return data.map((item) => parseTransferPolicyCapObject(item)).filter((item) => !!item);
|
|
684
668
|
}
|
|
685
669
|
async function queryOwnedTransferPolicies(client, address) {
|
|
686
|
-
if (!(0,
|
|
670
|
+
if (!(0, import_utils4.isValidSuiAddress)(address))
|
|
687
671
|
return;
|
|
688
672
|
const filter = {
|
|
689
673
|
MatchAll: [
|
|
@@ -810,7 +794,7 @@ function attachKioskLockRuleTx(tx, type, policy, policyCap, packageId) {
|
|
|
810
794
|
tx.moveCall({
|
|
811
795
|
target: `${packageId}::kiosk_lock_rule::add`,
|
|
812
796
|
typeArguments: [type],
|
|
813
|
-
arguments: [
|
|
797
|
+
arguments: [tx.object(policy), tx.object(policyCap)]
|
|
814
798
|
});
|
|
815
799
|
}
|
|
816
800
|
function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmount, packageId) {
|
|
@@ -820,8 +804,8 @@ function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmou
|
|
|
820
804
|
target: `${packageId}::royalty_rule::add`,
|
|
821
805
|
typeArguments: [type],
|
|
822
806
|
arguments: [
|
|
823
|
-
|
|
824
|
-
|
|
807
|
+
tx.object(policy),
|
|
808
|
+
tx.object(policyCap),
|
|
825
809
|
tx.pure.u16(Number(percentageBps)),
|
|
826
810
|
tx.pure.u64(minAmount)
|
|
827
811
|
]
|
|
@@ -831,14 +815,14 @@ function attachPersonalKioskRuleTx(tx, type, policy, policyCap, packageId) {
|
|
|
831
815
|
tx.moveCall({
|
|
832
816
|
target: `${packageId}::personal_kiosk_rule::add`,
|
|
833
817
|
typeArguments: [type],
|
|
834
|
-
arguments: [
|
|
818
|
+
arguments: [tx.object(policy), tx.object(policyCap)]
|
|
835
819
|
});
|
|
836
820
|
}
|
|
837
821
|
function attachFloorPriceRuleTx(tx, type, policy, policyCap, minPrice, packageId) {
|
|
838
822
|
tx.moveCall({
|
|
839
823
|
target: `${packageId}::floor_price_rule::add`,
|
|
840
824
|
typeArguments: [type],
|
|
841
|
-
arguments: [
|
|
825
|
+
arguments: [tx.object(policy), tx.object(policyCap), tx.pure.u64(minPrice)]
|
|
842
826
|
});
|
|
843
827
|
}
|
|
844
828
|
|
|
@@ -857,7 +841,7 @@ function createTransferPolicyWithoutSharing(tx, itemType, publisher) {
|
|
|
857
841
|
const [transferPolicy, transferPolicyCap] = tx.moveCall({
|
|
858
842
|
target: `${TRANSFER_POLICY_MODULE}::new`,
|
|
859
843
|
typeArguments: [itemType],
|
|
860
|
-
arguments: [
|
|
844
|
+
arguments: [tx.object(publisher)]
|
|
861
845
|
});
|
|
862
846
|
return [transferPolicy, transferPolicyCap];
|
|
863
847
|
}
|
|
@@ -873,7 +857,7 @@ function withdrawFromPolicy(tx, itemType, policy, policyCap, amount) {
|
|
|
873
857
|
const [profits] = tx.moveCall({
|
|
874
858
|
target: `${TRANSFER_POLICY_MODULE}::withdraw`,
|
|
875
859
|
typeArguments: [itemType],
|
|
876
|
-
arguments: [
|
|
860
|
+
arguments: [tx.object(policy), tx.object(policyCap), amountArg]
|
|
877
861
|
});
|
|
878
862
|
return profits;
|
|
879
863
|
}
|
|
@@ -881,14 +865,14 @@ function confirmRequest(tx, itemType, policy, request) {
|
|
|
881
865
|
tx.moveCall({
|
|
882
866
|
target: `${TRANSFER_POLICY_MODULE}::confirm_request`,
|
|
883
867
|
typeArguments: [itemType],
|
|
884
|
-
arguments: [
|
|
868
|
+
arguments: [tx.object(policy), request]
|
|
885
869
|
});
|
|
886
870
|
}
|
|
887
871
|
function removeTransferPolicyRule(tx, itemType, ruleType, configType, policy, policyCap) {
|
|
888
872
|
tx.moveCall({
|
|
889
873
|
target: `${TRANSFER_POLICY_MODULE}::remove_rule`,
|
|
890
874
|
typeArguments: [itemType, ruleType, configType],
|
|
891
|
-
arguments: [
|
|
875
|
+
arguments: [tx.object(policy), tx.object(policyCap)]
|
|
892
876
|
});
|
|
893
877
|
}
|
|
894
878
|
|
|
@@ -1176,7 +1160,7 @@ setup_fn = function(policyId, policyCap, type) {
|
|
|
1176
1160
|
function convertToPersonalTx(tx, kiosk, kioskOwnerCap, packageId) {
|
|
1177
1161
|
const personalKioskCap = tx.moveCall({
|
|
1178
1162
|
target: `${packageId}::personal_kiosk::new`,
|
|
1179
|
-
arguments: [
|
|
1163
|
+
arguments: [tx.object(kiosk), tx.object(kioskOwnerCap)]
|
|
1180
1164
|
});
|
|
1181
1165
|
return personalKioskCap;
|
|
1182
1166
|
}
|
|
@@ -1510,9 +1494,9 @@ var KioskTransaction = class {
|
|
|
1510
1494
|
*/
|
|
1511
1495
|
setCap(cap) {
|
|
1512
1496
|
__privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
|
|
1513
|
-
this.kiosk =
|
|
1497
|
+
this.kiosk = this.transactionBlock.object(cap.kioskId);
|
|
1514
1498
|
if (!cap.isPersonal) {
|
|
1515
|
-
this.kioskCap =
|
|
1499
|
+
this.kioskCap = this.transactionBlock.object(cap.objectId);
|
|
1516
1500
|
return;
|
|
1517
1501
|
}
|
|
1518
1502
|
return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
|
|
@@ -1539,7 +1523,7 @@ var KioskTransaction = class {
|
|
|
1539
1523
|
target: `${packageId}::personal_kiosk::return_val`,
|
|
1540
1524
|
arguments: [
|
|
1541
1525
|
__privateGet(this, _personalCap),
|
|
1542
|
-
|
|
1526
|
+
this.transactionBlock.object(this.kioskCap),
|
|
1543
1527
|
__privateGet(this, _promise)
|
|
1544
1528
|
]
|
|
1545
1529
|
});
|
|
@@ -1590,10 +1574,10 @@ borrowFromPersonalCap_fn = function(personalCap) {
|
|
|
1590
1574
|
target: `${this.kioskClient.getRulePackageId(
|
|
1591
1575
|
"personalKioskRulePackageId"
|
|
1592
1576
|
)}::personal_kiosk::borrow_val`,
|
|
1593
|
-
arguments: [
|
|
1577
|
+
arguments: [this.transactionBlock.object(personalCap)]
|
|
1594
1578
|
});
|
|
1595
1579
|
this.kioskCap = kioskCap;
|
|
1596
|
-
__privateSet(this, _personalCap,
|
|
1580
|
+
__privateSet(this, _personalCap, this.transactionBlock.object(personalCap));
|
|
1597
1581
|
__privateSet(this, _promise, promise);
|
|
1598
1582
|
return this;
|
|
1599
1583
|
};
|
|
@@ -1651,7 +1635,6 @@ validateFinalizedStatus_fn = function() {
|
|
|
1651
1635
|
getKioskObject,
|
|
1652
1636
|
getNormalizedRuleType,
|
|
1653
1637
|
mainnetRules,
|
|
1654
|
-
objArg,
|
|
1655
1638
|
parseTransferPolicyCapObject,
|
|
1656
1639
|
percentageToBasisPoints,
|
|
1657
1640
|
rules,
|