@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
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
Price,
|
|
20
20
|
PurchaseOptions,
|
|
21
21
|
} from '../types';
|
|
22
|
-
import { getNormalizedRuleType
|
|
22
|
+
import { getNormalizedRuleType } from '../utils';
|
|
23
23
|
import { type KioskClient } from './kiosk-client';
|
|
24
24
|
|
|
25
25
|
export type KioskTransactionParams = {
|
|
@@ -396,9 +396,9 @@ export class KioskTransaction {
|
|
|
396
396
|
*/
|
|
397
397
|
setCap(cap: KioskOwnerCap) {
|
|
398
398
|
this.#validateFinalizedStatus();
|
|
399
|
-
this.kiosk =
|
|
399
|
+
this.kiosk = this.transactionBlock.object(cap.kioskId);
|
|
400
400
|
if (!cap.isPersonal) {
|
|
401
|
-
this.kioskCap =
|
|
401
|
+
this.kioskCap = this.transactionBlock.object(cap.objectId);
|
|
402
402
|
return;
|
|
403
403
|
}
|
|
404
404
|
|
|
@@ -433,7 +433,7 @@ export class KioskTransaction {
|
|
|
433
433
|
target: `${packageId}::personal_kiosk::return_val`,
|
|
434
434
|
arguments: [
|
|
435
435
|
this.#personalCap,
|
|
436
|
-
|
|
436
|
+
this.transactionBlock.object(this.kioskCap!),
|
|
437
437
|
this.#promise!,
|
|
438
438
|
],
|
|
439
439
|
});
|
|
@@ -487,11 +487,11 @@ export class KioskTransaction {
|
|
|
487
487
|
target: `${this.kioskClient.getRulePackageId(
|
|
488
488
|
'personalKioskRulePackageId',
|
|
489
489
|
)}::personal_kiosk::borrow_val`,
|
|
490
|
-
arguments: [
|
|
490
|
+
arguments: [this.transactionBlock.object(personalCap)],
|
|
491
491
|
});
|
|
492
492
|
|
|
493
493
|
this.kioskCap = kioskCap;
|
|
494
|
-
this.#personalCap =
|
|
494
|
+
this.#personalCap = this.transactionBlock.object(personalCap);
|
|
495
495
|
this.#promise = promise;
|
|
496
496
|
|
|
497
497
|
return this;
|
package/src/tx/kiosk.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from '@mysten/sui.js/transactions';
|
|
10
10
|
|
|
11
11
|
import { KIOSK_MODULE, KIOSK_TYPE, ObjectArgument } from '../types';
|
|
12
|
-
import { objArg } from '../utils';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Create a new shared Kiosk and returns the [kiosk, kioskOwnerCap] tuple.
|
|
@@ -59,7 +58,7 @@ export function place(
|
|
|
59
58
|
tx.moveCall({
|
|
60
59
|
target: `${KIOSK_MODULE}::place`,
|
|
61
60
|
typeArguments: [itemType],
|
|
62
|
-
arguments: [
|
|
61
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item)],
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
64
|
|
|
@@ -82,7 +81,7 @@ export function lock(
|
|
|
82
81
|
tx.moveCall({
|
|
83
82
|
target: `${KIOSK_MODULE}::lock`,
|
|
84
83
|
typeArguments: [itemType],
|
|
85
|
-
arguments: [
|
|
84
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(policy), tx.object(item)],
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
87
|
|
|
@@ -100,7 +99,7 @@ export function take(
|
|
|
100
99
|
const [item] = tx.moveCall({
|
|
101
100
|
target: `${KIOSK_MODULE}::take`,
|
|
102
101
|
typeArguments: [itemType],
|
|
103
|
-
arguments: [
|
|
102
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)],
|
|
104
103
|
});
|
|
105
104
|
|
|
106
105
|
return item;
|
|
@@ -121,12 +120,7 @@ export function list(
|
|
|
121
120
|
tx.moveCall({
|
|
122
121
|
target: `${KIOSK_MODULE}::list`,
|
|
123
122
|
typeArguments: [itemType],
|
|
124
|
-
arguments: [
|
|
125
|
-
objArg(tx, kiosk),
|
|
126
|
-
objArg(tx, kioskCap),
|
|
127
|
-
tx.pure.address(itemId),
|
|
128
|
-
tx.pure.u64(price),
|
|
129
|
-
],
|
|
123
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId), tx.pure.u64(price)],
|
|
130
124
|
});
|
|
131
125
|
}
|
|
132
126
|
|
|
@@ -144,7 +138,7 @@ export function delist(
|
|
|
144
138
|
tx.moveCall({
|
|
145
139
|
target: `${KIOSK_MODULE}::delist`,
|
|
146
140
|
typeArguments: [itemType],
|
|
147
|
-
arguments: [
|
|
141
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)],
|
|
148
142
|
});
|
|
149
143
|
}
|
|
150
144
|
|
|
@@ -163,7 +157,7 @@ export function placeAndList(
|
|
|
163
157
|
tx.moveCall({
|
|
164
158
|
target: `${KIOSK_MODULE}::place_and_list`,
|
|
165
159
|
typeArguments: [itemType],
|
|
166
|
-
arguments: [
|
|
160
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item), tx.pure.u64(price)],
|
|
167
161
|
});
|
|
168
162
|
}
|
|
169
163
|
|
|
@@ -181,7 +175,7 @@ export function purchase(
|
|
|
181
175
|
const [item, transferRequest] = tx.moveCall({
|
|
182
176
|
target: `${KIOSK_MODULE}::purchase`,
|
|
183
177
|
typeArguments: [itemType],
|
|
184
|
-
arguments: [
|
|
178
|
+
arguments: [tx.object(kiosk), tx.pure.id(itemId), tx.object(payment)],
|
|
185
179
|
});
|
|
186
180
|
|
|
187
181
|
return [item, transferRequest];
|
|
@@ -201,7 +195,7 @@ export function withdrawFromKiosk(
|
|
|
201
195
|
|
|
202
196
|
const [coin] = tx.moveCall({
|
|
203
197
|
target: `${KIOSK_MODULE}::withdraw`,
|
|
204
|
-
arguments: [
|
|
198
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), amountArg],
|
|
205
199
|
});
|
|
206
200
|
|
|
207
201
|
return coin;
|
|
@@ -223,7 +217,7 @@ export function borrowValue(
|
|
|
223
217
|
const [item, promise] = tx.moveCall({
|
|
224
218
|
target: `${KIOSK_MODULE}::borrow_val`,
|
|
225
219
|
typeArguments: [itemType],
|
|
226
|
-
arguments: [
|
|
220
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)],
|
|
227
221
|
});
|
|
228
222
|
|
|
229
223
|
return [item, promise];
|
|
@@ -243,6 +237,6 @@ export function returnValue(
|
|
|
243
237
|
tx.moveCall({
|
|
244
238
|
target: `${KIOSK_MODULE}::return_val`,
|
|
245
239
|
typeArguments: [itemType],
|
|
246
|
-
arguments: [
|
|
240
|
+
arguments: [tx.object(kiosk), item, promise],
|
|
247
241
|
});
|
|
248
242
|
}
|
package/src/tx/personal-kiosk.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { TransactionBlock, TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
5
5
|
|
|
6
6
|
import { ObjectArgument } from '../types';
|
|
7
|
-
import { objArg } from '../utils';
|
|
8
7
|
|
|
9
8
|
export function convertToPersonalTx(
|
|
10
9
|
tx: TransactionBlock,
|
|
@@ -14,7 +13,7 @@ export function convertToPersonalTx(
|
|
|
14
13
|
): TransactionObjectArgument {
|
|
15
14
|
const personalKioskCap = tx.moveCall({
|
|
16
15
|
target: `${packageId}::personal_kiosk::new`,
|
|
17
|
-
arguments: [
|
|
16
|
+
arguments: [tx.object(kiosk), tx.object(kioskOwnerCap)],
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
return personalKioskCap;
|
package/src/tx/rules/attach.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { type TransactionBlock } from '@mysten/sui.js/transactions';
|
|
5
5
|
|
|
6
6
|
import { type ObjectArgument } from '../../types';
|
|
7
|
-
import { objArg } from '../../utils';
|
|
8
7
|
|
|
9
8
|
export function attachKioskLockRuleTx(
|
|
10
9
|
tx: TransactionBlock,
|
|
@@ -16,7 +15,7 @@ export function attachKioskLockRuleTx(
|
|
|
16
15
|
tx.moveCall({
|
|
17
16
|
target: `${packageId}::kiosk_lock_rule::add`,
|
|
18
17
|
typeArguments: [type],
|
|
19
|
-
arguments: [
|
|
18
|
+
arguments: [tx.object(policy), tx.object(policyCap)],
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -36,8 +35,8 @@ export function attachRoyaltyRuleTx(
|
|
|
36
35
|
target: `${packageId}::royalty_rule::add`,
|
|
37
36
|
typeArguments: [type],
|
|
38
37
|
arguments: [
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
tx.object(policy),
|
|
39
|
+
tx.object(policyCap),
|
|
41
40
|
tx.pure.u16(Number(percentageBps)),
|
|
42
41
|
tx.pure.u64(minAmount),
|
|
43
42
|
],
|
|
@@ -54,7 +53,7 @@ export function attachPersonalKioskRuleTx(
|
|
|
54
53
|
tx.moveCall({
|
|
55
54
|
target: `${packageId}::personal_kiosk_rule::add`,
|
|
56
55
|
typeArguments: [type],
|
|
57
|
-
arguments: [
|
|
56
|
+
arguments: [tx.object(policy), tx.object(policyCap)],
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -69,6 +68,6 @@ export function attachFloorPriceRuleTx(
|
|
|
69
68
|
tx.moveCall({
|
|
70
69
|
target: `${packageId}::floor_price_rule::add`,
|
|
71
70
|
typeArguments: [type],
|
|
72
|
-
arguments: [
|
|
71
|
+
arguments: [tx.object(policy), tx.object(policyCap), tx.pure.u64(minPrice)],
|
|
73
72
|
});
|
|
74
73
|
}
|
package/src/tx/rules/resolve.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { type RuleResolvingParams } from '../../types';
|
|
5
|
-
import { objArg } from '../../utils';
|
|
6
5
|
import { lock } from '../kiosk';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -11,7 +10,7 @@ import { lock } from '../kiosk';
|
|
|
11
10
|
export function resolveRoyaltyRule(params: RuleResolvingParams) {
|
|
12
11
|
const { transactionBlock: txb, itemType, price, packageId, transferRequest, policyId } = params;
|
|
13
12
|
|
|
14
|
-
const policyObj =
|
|
13
|
+
const policyObj = txb.object(policyId);
|
|
15
14
|
|
|
16
15
|
// calculates the amount
|
|
17
16
|
const [amount] = txb.moveCall({
|
|
@@ -51,7 +50,7 @@ export function resolveKioskLockRule(params: RuleResolvingParams) {
|
|
|
51
50
|
txb.moveCall({
|
|
52
51
|
target: `${packageId}::kiosk_lock_rule::prove`,
|
|
53
52
|
typeArguments: [itemType],
|
|
54
|
-
arguments: [transferRequest,
|
|
53
|
+
arguments: [transferRequest, txb.object(kiosk)],
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -68,7 +67,7 @@ export function resolvePersonalKioskRule(params: RuleResolvingParams) {
|
|
|
68
67
|
txb.moveCall({
|
|
69
68
|
target: `${packageId}::personal_kiosk_rule::prove`,
|
|
70
69
|
typeArguments: [itemType],
|
|
71
|
-
arguments: [
|
|
70
|
+
arguments: [txb.object(kiosk), transferRequest],
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -82,6 +81,6 @@ export function resolveFloorPriceRule(params: RuleResolvingParams) {
|
|
|
82
81
|
txb.moveCall({
|
|
83
82
|
target: `${packageId}::floor_price_rule::prove`,
|
|
84
83
|
typeArguments: [itemType],
|
|
85
|
-
arguments: [
|
|
84
|
+
arguments: [txb.object(policyId), transferRequest],
|
|
86
85
|
});
|
|
87
86
|
}
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from '@mysten/sui.js/transactions';
|
|
10
10
|
|
|
11
11
|
import { ObjectArgument, TRANSFER_POLICY_MODULE, TRANSFER_POLICY_TYPE } from '../types';
|
|
12
|
-
import { objArg } from '../utils';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Call the `transfer_policy::new` function to create a new transfer policy.
|
|
@@ -43,7 +42,7 @@ export function createTransferPolicyWithoutSharing(
|
|
|
43
42
|
const [transferPolicy, transferPolicyCap] = tx.moveCall({
|
|
44
43
|
target: `${TRANSFER_POLICY_MODULE}::new`,
|
|
45
44
|
typeArguments: [itemType],
|
|
46
|
-
arguments: [
|
|
45
|
+
arguments: [tx.object(publisher)],
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
return [transferPolicy, transferPolicyCap];
|
|
@@ -78,7 +77,7 @@ export function withdrawFromPolicy(
|
|
|
78
77
|
const [profits] = tx.moveCall({
|
|
79
78
|
target: `${TRANSFER_POLICY_MODULE}::withdraw`,
|
|
80
79
|
typeArguments: [itemType],
|
|
81
|
-
arguments: [
|
|
80
|
+
arguments: [tx.object(policy), tx.object(policyCap), amountArg],
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
return profits;
|
|
@@ -97,7 +96,7 @@ export function confirmRequest(
|
|
|
97
96
|
tx.moveCall({
|
|
98
97
|
target: `${TRANSFER_POLICY_MODULE}::confirm_request`,
|
|
99
98
|
typeArguments: [itemType],
|
|
100
|
-
arguments: [
|
|
99
|
+
arguments: [tx.object(policy), request],
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
|
|
@@ -115,6 +114,6 @@ export function removeTransferPolicyRule(
|
|
|
115
114
|
tx.moveCall({
|
|
116
115
|
target: `${TRANSFER_POLICY_MODULE}::remove_rule`,
|
|
117
116
|
typeArguments: [itemType, ruleType, configType],
|
|
118
|
-
arguments: [
|
|
117
|
+
arguments: [tx.object(policy), tx.object(policyCap)],
|
|
119
118
|
});
|
|
120
119
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { type
|
|
5
|
-
import { type SuiClient, type SuiObjectRef } from '@mysten/sui.js/client';
|
|
4
|
+
import { type SuiClient } from '@mysten/sui.js/client';
|
|
6
5
|
import { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
7
6
|
|
|
8
7
|
import { BaseRulePackageIds } from '../constants';
|
|
@@ -13,7 +12,7 @@ export * from './transfer-policy';
|
|
|
13
12
|
/**
|
|
14
13
|
* A valid argument for any of the Kiosk functions.
|
|
15
14
|
*/
|
|
16
|
-
export type ObjectArgument = string | TransactionObjectArgument
|
|
15
|
+
export type ObjectArgument = string | TransactionObjectArgument;
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* A Network selector.
|
package/src/utils.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { SharedObjectRef } from '@mysten/sui.js/bcs';
|
|
5
4
|
import {
|
|
6
5
|
PaginationArguments,
|
|
7
6
|
SuiClient,
|
|
8
7
|
SuiObjectData,
|
|
9
8
|
SuiObjectDataFilter,
|
|
10
9
|
SuiObjectDataOptions,
|
|
11
|
-
SuiObjectRef,
|
|
12
10
|
SuiObjectResponse,
|
|
13
11
|
type DynamicFieldInfo,
|
|
14
12
|
} from '@mysten/sui.js/client';
|
|
15
|
-
import { TransactionBlock, TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
16
13
|
import { normalizeStructTag, normalizeSuiAddress, parseStructTag } from '@mysten/sui.js/utils';
|
|
17
14
|
|
|
18
15
|
import { bcs } from './bcs';
|
|
@@ -27,36 +24,6 @@ import {
|
|
|
27
24
|
|
|
28
25
|
const DEFAULT_QUERY_LIMIT = 50;
|
|
29
26
|
|
|
30
|
-
/**
|
|
31
|
-
* Convert any valid input into a TransactionArgument.
|
|
32
|
-
*
|
|
33
|
-
* @param txb The Transaction Block
|
|
34
|
-
* @param arg The argument to convert.
|
|
35
|
-
* @returns The converted TransactionArgument.
|
|
36
|
-
*/
|
|
37
|
-
export function objArg(
|
|
38
|
-
txb: TransactionBlock,
|
|
39
|
-
arg: string | SharedObjectRef | SuiObjectRef | TransactionObjectArgument,
|
|
40
|
-
): TransactionObjectArgument {
|
|
41
|
-
if (typeof arg === 'string') {
|
|
42
|
-
return txb.object(arg);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if ('digest' in arg && 'version' in arg && 'objectId' in arg) {
|
|
46
|
-
return txb.objectRef(arg);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if ('objectId' in arg && 'initialSharedVersion' in arg && 'mutable' in arg) {
|
|
50
|
-
return txb.sharedObjectRef(arg);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if ('kind' in arg) {
|
|
54
|
-
return arg;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
throw new Error('Invalid argument type');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
27
|
export async function getKioskObject(client: SuiClient, id: string): Promise<Kiosk> {
|
|
61
28
|
const queryRes = await client.getObject({ id, options: { showBcs: true } });
|
|
62
29
|
|