@mysten/kiosk 0.7.8 → 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 +13 -0
- package/dist/index.js +34 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -50
- 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 -16
- 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/dist/index.mjs
CHANGED
|
@@ -77,21 +77,6 @@ bcs.registerStructType(TRANSFER_POLICY_TYPE, {
|
|
|
77
77
|
|
|
78
78
|
// src/utils.ts
|
|
79
79
|
var DEFAULT_QUERY_LIMIT = 50;
|
|
80
|
-
function objArg(txb, arg) {
|
|
81
|
-
if (typeof arg === "string") {
|
|
82
|
-
return txb.object(arg);
|
|
83
|
-
}
|
|
84
|
-
if ("digest" in arg && "version" in arg && "objectId" in arg) {
|
|
85
|
-
return txb.objectRef(arg);
|
|
86
|
-
}
|
|
87
|
-
if ("objectId" in arg && "initialSharedVersion" in arg && "mutable" in arg) {
|
|
88
|
-
return txb.sharedObjectRef(arg);
|
|
89
|
-
}
|
|
90
|
-
if ("kind" in arg) {
|
|
91
|
-
return arg;
|
|
92
|
-
}
|
|
93
|
-
throw new Error("Invalid argument type");
|
|
94
|
-
}
|
|
95
80
|
async function getKioskObject(client, id) {
|
|
96
81
|
const queryRes = await client.getObject({ id, options: { showBcs: true } });
|
|
97
82
|
if (!queryRes || queryRes.error || !queryRes.data) {
|
|
@@ -282,21 +267,21 @@ function place(tx, itemType, kiosk, kioskCap, item) {
|
|
|
282
267
|
tx.moveCall({
|
|
283
268
|
target: `${KIOSK_MODULE}::place`,
|
|
284
269
|
typeArguments: [itemType],
|
|
285
|
-
arguments: [
|
|
270
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item)]
|
|
286
271
|
});
|
|
287
272
|
}
|
|
288
273
|
function lock(tx, itemType, kiosk, kioskCap, policy, item) {
|
|
289
274
|
tx.moveCall({
|
|
290
275
|
target: `${KIOSK_MODULE}::lock`,
|
|
291
276
|
typeArguments: [itemType],
|
|
292
|
-
arguments: [
|
|
277
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(policy), tx.object(item)]
|
|
293
278
|
});
|
|
294
279
|
}
|
|
295
280
|
function take(tx, itemType, kiosk, kioskCap, itemId) {
|
|
296
281
|
const [item] = tx.moveCall({
|
|
297
282
|
target: `${KIOSK_MODULE}::take`,
|
|
298
283
|
typeArguments: [itemType],
|
|
299
|
-
arguments: [
|
|
284
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
300
285
|
});
|
|
301
286
|
return item;
|
|
302
287
|
}
|
|
@@ -304,33 +289,28 @@ function list(tx, itemType, kiosk, kioskCap, itemId, price) {
|
|
|
304
289
|
tx.moveCall({
|
|
305
290
|
target: `${KIOSK_MODULE}::list`,
|
|
306
291
|
typeArguments: [itemType],
|
|
307
|
-
arguments: [
|
|
308
|
-
objArg(tx, kiosk),
|
|
309
|
-
objArg(tx, kioskCap),
|
|
310
|
-
tx.pure.address(itemId),
|
|
311
|
-
tx.pure.u64(price)
|
|
312
|
-
]
|
|
292
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId), tx.pure.u64(price)]
|
|
313
293
|
});
|
|
314
294
|
}
|
|
315
295
|
function delist(tx, itemType, kiosk, kioskCap, itemId) {
|
|
316
296
|
tx.moveCall({
|
|
317
297
|
target: `${KIOSK_MODULE}::delist`,
|
|
318
298
|
typeArguments: [itemType],
|
|
319
|
-
arguments: [
|
|
299
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
320
300
|
});
|
|
321
301
|
}
|
|
322
302
|
function placeAndList(tx, itemType, kiosk, kioskCap, item, price) {
|
|
323
303
|
tx.moveCall({
|
|
324
304
|
target: `${KIOSK_MODULE}::place_and_list`,
|
|
325
305
|
typeArguments: [itemType],
|
|
326
|
-
arguments: [
|
|
306
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item), tx.pure.u64(price)]
|
|
327
307
|
});
|
|
328
308
|
}
|
|
329
309
|
function purchase(tx, itemType, kiosk, itemId, payment) {
|
|
330
310
|
const [item, transferRequest] = tx.moveCall({
|
|
331
311
|
target: `${KIOSK_MODULE}::purchase`,
|
|
332
312
|
typeArguments: [itemType],
|
|
333
|
-
arguments: [
|
|
313
|
+
arguments: [tx.object(kiosk), tx.pure.id(itemId), tx.object(payment)]
|
|
334
314
|
});
|
|
335
315
|
return [item, transferRequest];
|
|
336
316
|
}
|
|
@@ -338,7 +318,7 @@ function withdrawFromKiosk(tx, kiosk, kioskCap, amount) {
|
|
|
338
318
|
const amountArg = bcs2.option(bcs2.u64()).serialize(amount);
|
|
339
319
|
const [coin] = tx.moveCall({
|
|
340
320
|
target: `${KIOSK_MODULE}::withdraw`,
|
|
341
|
-
arguments: [
|
|
321
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), amountArg]
|
|
342
322
|
});
|
|
343
323
|
return coin;
|
|
344
324
|
}
|
|
@@ -346,7 +326,7 @@ function borrowValue(tx, itemType, kiosk, kioskCap, itemId) {
|
|
|
346
326
|
const [item, promise] = tx.moveCall({
|
|
347
327
|
target: `${KIOSK_MODULE}::borrow_val`,
|
|
348
328
|
typeArguments: [itemType],
|
|
349
|
-
arguments: [
|
|
329
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
350
330
|
});
|
|
351
331
|
return [item, promise];
|
|
352
332
|
}
|
|
@@ -354,14 +334,14 @@ function returnValue(tx, itemType, kiosk, item, promise) {
|
|
|
354
334
|
tx.moveCall({
|
|
355
335
|
target: `${KIOSK_MODULE}::return_val`,
|
|
356
336
|
typeArguments: [itemType],
|
|
357
|
-
arguments: [
|
|
337
|
+
arguments: [tx.object(kiosk), item, promise]
|
|
358
338
|
});
|
|
359
339
|
}
|
|
360
340
|
|
|
361
341
|
// src/tx/rules/resolve.ts
|
|
362
342
|
function resolveRoyaltyRule(params) {
|
|
363
343
|
const { transactionBlock: txb, itemType, price, packageId, transferRequest, policyId } = params;
|
|
364
|
-
const policyObj =
|
|
344
|
+
const policyObj = txb.object(policyId);
|
|
365
345
|
const [amount] = txb.moveCall({
|
|
366
346
|
target: `${packageId}::royalty_rule::fee_amount`,
|
|
367
347
|
typeArguments: [itemType],
|
|
@@ -391,7 +371,7 @@ function resolveKioskLockRule(params) {
|
|
|
391
371
|
txb.moveCall({
|
|
392
372
|
target: `${packageId}::kiosk_lock_rule::prove`,
|
|
393
373
|
typeArguments: [itemType],
|
|
394
|
-
arguments: [transferRequest,
|
|
374
|
+
arguments: [transferRequest, txb.object(kiosk)]
|
|
395
375
|
});
|
|
396
376
|
}
|
|
397
377
|
function resolvePersonalKioskRule(params) {
|
|
@@ -401,7 +381,7 @@ function resolvePersonalKioskRule(params) {
|
|
|
401
381
|
txb.moveCall({
|
|
402
382
|
target: `${packageId}::personal_kiosk_rule::prove`,
|
|
403
383
|
typeArguments: [itemType],
|
|
404
|
-
arguments: [
|
|
384
|
+
arguments: [txb.object(kiosk), transferRequest]
|
|
405
385
|
});
|
|
406
386
|
}
|
|
407
387
|
function resolveFloorPriceRule(params) {
|
|
@@ -409,7 +389,7 @@ function resolveFloorPriceRule(params) {
|
|
|
409
389
|
txb.moveCall({
|
|
410
390
|
target: `${packageId}::floor_price_rule::prove`,
|
|
411
391
|
typeArguments: [itemType],
|
|
412
|
-
arguments: [
|
|
392
|
+
arguments: [txb.object(policyId), transferRequest]
|
|
413
393
|
});
|
|
414
394
|
}
|
|
415
395
|
|
|
@@ -754,7 +734,7 @@ function attachKioskLockRuleTx(tx, type, policy, policyCap, packageId) {
|
|
|
754
734
|
tx.moveCall({
|
|
755
735
|
target: `${packageId}::kiosk_lock_rule::add`,
|
|
756
736
|
typeArguments: [type],
|
|
757
|
-
arguments: [
|
|
737
|
+
arguments: [tx.object(policy), tx.object(policyCap)]
|
|
758
738
|
});
|
|
759
739
|
}
|
|
760
740
|
function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmount, packageId) {
|
|
@@ -764,8 +744,8 @@ function attachRoyaltyRuleTx(tx, type, policy, policyCap, percentageBps, minAmou
|
|
|
764
744
|
target: `${packageId}::royalty_rule::add`,
|
|
765
745
|
typeArguments: [type],
|
|
766
746
|
arguments: [
|
|
767
|
-
|
|
768
|
-
|
|
747
|
+
tx.object(policy),
|
|
748
|
+
tx.object(policyCap),
|
|
769
749
|
tx.pure.u16(Number(percentageBps)),
|
|
770
750
|
tx.pure.u64(minAmount)
|
|
771
751
|
]
|
|
@@ -775,14 +755,14 @@ function attachPersonalKioskRuleTx(tx, type, policy, policyCap, packageId) {
|
|
|
775
755
|
tx.moveCall({
|
|
776
756
|
target: `${packageId}::personal_kiosk_rule::add`,
|
|
777
757
|
typeArguments: [type],
|
|
778
|
-
arguments: [
|
|
758
|
+
arguments: [tx.object(policy), tx.object(policyCap)]
|
|
779
759
|
});
|
|
780
760
|
}
|
|
781
761
|
function attachFloorPriceRuleTx(tx, type, policy, policyCap, minPrice, packageId) {
|
|
782
762
|
tx.moveCall({
|
|
783
763
|
target: `${packageId}::floor_price_rule::add`,
|
|
784
764
|
typeArguments: [type],
|
|
785
|
-
arguments: [
|
|
765
|
+
arguments: [tx.object(policy), tx.object(policyCap), tx.pure.u64(minPrice)]
|
|
786
766
|
});
|
|
787
767
|
}
|
|
788
768
|
|
|
@@ -801,7 +781,7 @@ function createTransferPolicyWithoutSharing(tx, itemType, publisher) {
|
|
|
801
781
|
const [transferPolicy, transferPolicyCap] = tx.moveCall({
|
|
802
782
|
target: `${TRANSFER_POLICY_MODULE}::new`,
|
|
803
783
|
typeArguments: [itemType],
|
|
804
|
-
arguments: [
|
|
784
|
+
arguments: [tx.object(publisher)]
|
|
805
785
|
});
|
|
806
786
|
return [transferPolicy, transferPolicyCap];
|
|
807
787
|
}
|
|
@@ -817,7 +797,7 @@ function withdrawFromPolicy(tx, itemType, policy, policyCap, amount) {
|
|
|
817
797
|
const [profits] = tx.moveCall({
|
|
818
798
|
target: `${TRANSFER_POLICY_MODULE}::withdraw`,
|
|
819
799
|
typeArguments: [itemType],
|
|
820
|
-
arguments: [
|
|
800
|
+
arguments: [tx.object(policy), tx.object(policyCap), amountArg]
|
|
821
801
|
});
|
|
822
802
|
return profits;
|
|
823
803
|
}
|
|
@@ -825,14 +805,14 @@ function confirmRequest(tx, itemType, policy, request) {
|
|
|
825
805
|
tx.moveCall({
|
|
826
806
|
target: `${TRANSFER_POLICY_MODULE}::confirm_request`,
|
|
827
807
|
typeArguments: [itemType],
|
|
828
|
-
arguments: [
|
|
808
|
+
arguments: [tx.object(policy), request]
|
|
829
809
|
});
|
|
830
810
|
}
|
|
831
811
|
function removeTransferPolicyRule(tx, itemType, ruleType, configType, policy, policyCap) {
|
|
832
812
|
tx.moveCall({
|
|
833
813
|
target: `${TRANSFER_POLICY_MODULE}::remove_rule`,
|
|
834
814
|
typeArguments: [itemType, ruleType, configType],
|
|
835
|
-
arguments: [
|
|
815
|
+
arguments: [tx.object(policy), tx.object(policyCap)]
|
|
836
816
|
});
|
|
837
817
|
}
|
|
838
818
|
|
|
@@ -1120,7 +1100,7 @@ setup_fn = function(policyId, policyCap, type) {
|
|
|
1120
1100
|
function convertToPersonalTx(tx, kiosk, kioskOwnerCap, packageId) {
|
|
1121
1101
|
const personalKioskCap = tx.moveCall({
|
|
1122
1102
|
target: `${packageId}::personal_kiosk::new`,
|
|
1123
|
-
arguments: [
|
|
1103
|
+
arguments: [tx.object(kiosk), tx.object(kioskOwnerCap)]
|
|
1124
1104
|
});
|
|
1125
1105
|
return personalKioskCap;
|
|
1126
1106
|
}
|
|
@@ -1454,9 +1434,9 @@ var KioskTransaction = class {
|
|
|
1454
1434
|
*/
|
|
1455
1435
|
setCap(cap) {
|
|
1456
1436
|
__privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
|
|
1457
|
-
this.kiosk =
|
|
1437
|
+
this.kiosk = this.transactionBlock.object(cap.kioskId);
|
|
1458
1438
|
if (!cap.isPersonal) {
|
|
1459
|
-
this.kioskCap =
|
|
1439
|
+
this.kioskCap = this.transactionBlock.object(cap.objectId);
|
|
1460
1440
|
return;
|
|
1461
1441
|
}
|
|
1462
1442
|
return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
|
|
@@ -1483,7 +1463,7 @@ var KioskTransaction = class {
|
|
|
1483
1463
|
target: `${packageId}::personal_kiosk::return_val`,
|
|
1484
1464
|
arguments: [
|
|
1485
1465
|
__privateGet(this, _personalCap),
|
|
1486
|
-
|
|
1466
|
+
this.transactionBlock.object(this.kioskCap),
|
|
1487
1467
|
__privateGet(this, _promise)
|
|
1488
1468
|
]
|
|
1489
1469
|
});
|
|
@@ -1534,10 +1514,10 @@ borrowFromPersonalCap_fn = function(personalCap) {
|
|
|
1534
1514
|
target: `${this.kioskClient.getRulePackageId(
|
|
1535
1515
|
"personalKioskRulePackageId"
|
|
1536
1516
|
)}::personal_kiosk::borrow_val`,
|
|
1537
|
-
arguments: [
|
|
1517
|
+
arguments: [this.transactionBlock.object(personalCap)]
|
|
1538
1518
|
});
|
|
1539
1519
|
this.kioskCap = kioskCap;
|
|
1540
|
-
__privateSet(this, _personalCap,
|
|
1520
|
+
__privateSet(this, _personalCap, this.transactionBlock.object(personalCap));
|
|
1541
1521
|
__privateSet(this, _promise, promise);
|
|
1542
1522
|
return this;
|
|
1543
1523
|
};
|
|
@@ -1594,7 +1574,6 @@ export {
|
|
|
1594
1574
|
getKioskObject,
|
|
1595
1575
|
getNormalizedRuleType,
|
|
1596
1576
|
mainnetRules,
|
|
1597
|
-
objArg,
|
|
1598
1577
|
parseTransferPolicyCapObject,
|
|
1599
1578
|
percentageToBasisPoints,
|
|
1600
1579
|
rules,
|