@mysten/kiosk 1.1.2 → 1.2.0
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 +25 -0
- package/dist/client/kiosk-client.d.mts.map +1 -1
- package/dist/client/kiosk-transaction.d.mts +1 -2
- package/dist/client/kiosk-transaction.d.mts.map +1 -1
- package/dist/client/tp-transaction.d.mts +1 -2
- package/dist/client/tp-transaction.d.mts.map +1 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/query/client-utils.mjs.map +1 -1
- package/dist/types/index.d.mts +0 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/kiosk.d.mts +14 -28
- package/dist/types/kiosk.d.mts.map +1 -1
- package/dist/types/kiosk.mjs.map +1 -1
- package/dist/types/transfer-policy.d.mts.map +1 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs.map +1 -1
- package/docs/advanced-examples.md +100 -0
- package/docs/from-v1.md +314 -0
- package/docs/index.md +22 -0
- package/docs/kiosk-client/introduction.md +50 -0
- package/docs/kiosk-client/kiosk-transaction/examples.md +119 -0
- package/docs/kiosk-client/kiosk-transaction/kiosk-transaction.md +103 -0
- package/docs/kiosk-client/kiosk-transaction/managing.md +235 -0
- package/docs/kiosk-client/kiosk-transaction/purchasing.md +110 -0
- package/docs/kiosk-client/querying.md +237 -0
- package/docs/kiosk-client/transfer-policy-transaction/introduction.md +79 -0
- package/docs/kiosk-client/transfer-policy-transaction/using-the-manager.md +115 -0
- package/docs/llms-index.md +10 -0
- package/package.json +7 -5
- package/src/query/client-utils.ts +1 -1
- package/src/types/kiosk.ts +8 -5
- package/src/utils.ts +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Using the manager
|
|
2
|
+
|
|
3
|
+
> Use the TransferPolicyTransaction manager for policy rules
|
|
4
|
+
|
|
5
|
+
# How to use
|
|
6
|
+
|
|
7
|
+
After following the introduction steps on how to initialize a transfer policy transaction you can
|
|
8
|
+
call any of the available functions to prepare your Programmable Transaction Block (PTB).
|
|
9
|
+
|
|
10
|
+
## Available functions
|
|
11
|
+
|
|
12
|
+
### Withdraw profits
|
|
13
|
+
|
|
14
|
+
`withdraw(address: string, amount?: string | bigint)`
|
|
15
|
+
|
|
16
|
+
After setting up the manager, you can withdraw profits from the specified transfer policy.
|
|
17
|
+
|
|
18
|
+
`amount` is optional. Leave empty to withdraw all profits.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
// ... tp transaction is initialized and policy is set.
|
|
22
|
+
// Withdraw 10 SUI from the policy. Leave last parameter empty to withdraw all profits.
|
|
23
|
+
tpTx.withdraw('address_to_transfer_coin', 10_000_000_000n);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Add/Remove rules
|
|
27
|
+
|
|
28
|
+
> You can chain the actions when you're calling them, to add multiple rules.
|
|
29
|
+
|
|
30
|
+
After setting up the transaction, you can add any of the supported rules to the policy.
|
|
31
|
+
|
|
32
|
+
#### Royalty rule
|
|
33
|
+
|
|
34
|
+
`addRoyaltyRule(percentageBps: number | string, minAmount: number | string)`
|
|
35
|
+
|
|
36
|
+
You can add the royalty rule like the following example.
|
|
37
|
+
|
|
38
|
+
`percentageToBasisPoints` is a helper to convert a percentage (0.00-100%) to basis points.
|
|
39
|
+
|
|
40
|
+
Use `minAmount` to set a minimum amount per transaction, so that the royalty paid is
|
|
41
|
+
**MAX(percentageBps, minAmount)**. Use 0 for no minimum amount.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// ... tp transaction is initialized and policy is set.
|
|
45
|
+
tpTx.addRoyaltyRule(percentageToBasisPoints(30), 1_000_000_000);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
You can remove the rule by calling:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
tpTx.removeRoyaltyRule();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Kiosk lock rule
|
|
55
|
+
|
|
56
|
+
`addLockRule()`
|
|
57
|
+
|
|
58
|
+
You can add the kiosk lock rule like the following example.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// ... tp transaction is initialized and policy is set.
|
|
62
|
+
tpTx.addLockRule();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
You can remove the rule by calling:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
tpTx.removeLockRule();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Personal kiosk rule
|
|
72
|
+
|
|
73
|
+
`addPersonalKioskRule()`
|
|
74
|
+
|
|
75
|
+
You can add the kiosk lock rule like the following example.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// ... tp transaction is initialized and policy is set.
|
|
79
|
+
tpTx.addPersonalKioskRule();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
You can remove the rule by calling:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
tpTx.removePersonalKioskRule();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Floor price rule
|
|
89
|
+
|
|
90
|
+
`addFloorPriceRule(minPrice: string | bigint)`
|
|
91
|
+
|
|
92
|
+
You can add the floor price rule like the following example:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// ... tp transaction is initialized and policy is set.
|
|
96
|
+
tpTx.addFloorPriceRule(10_000_000_000n); // sets 10 SUI as the floor price.
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You can remove the rule by calling:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
tpTx.removeFloorPriceRule();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Updating rules
|
|
106
|
+
|
|
107
|
+
If you want to update a rule, call the `remove...` function, and then call `add` again with the new
|
|
108
|
+
settings.
|
|
109
|
+
|
|
110
|
+
Example:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// ... tp transaction is initialized and policy is set.
|
|
114
|
+
tpTx.removeRoyaltyRule().addRoyaltyRule(percentageToBasisPoints(20), 1_000_000_000);
|
|
115
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Kiosk
|
|
2
|
+
|
|
3
|
+
> Interact with on-chain commerce applications
|
|
4
|
+
|
|
5
|
+
- [Kiosk SDK](./index.md): TypeScript SDK for interacting with Sui Kiosk on-chain commerce
|
|
6
|
+
- [Kiosk Client](./kiosk-client/introduction.md): Introduction to the KioskClient for querying and
|
|
7
|
+
managing kiosks
|
|
8
|
+
- [Querying](./kiosk-client/querying.md): Query kiosk contents, items, and transfer policies
|
|
9
|
+
- [Advanced Examples](./advanced-examples.md): Advanced Kiosk SDK usage patterns and examples
|
|
10
|
+
- [Migrating from Kiosk SDK V1](./from-v1.md): Migrate from Kiosk SDK v1 to the current version
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@mysten/kiosk",
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui Kiosk library",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.mjs",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"CHANGELOG.md",
|
|
20
20
|
"dist",
|
|
21
|
+
"docs",
|
|
21
22
|
"src"
|
|
22
23
|
],
|
|
23
24
|
"engines": {
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
"url": "https://github.com/MystenLabs/ts-sdks/issues/new"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@mysten/bcs": "^2.0.
|
|
35
|
+
"@mysten/bcs": "^2.0.3",
|
|
35
36
|
"@mysten/utils": "^0.3.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
@@ -42,14 +43,15 @@
|
|
|
42
43
|
"vite": "^7.3.1",
|
|
43
44
|
"vitest": "^4.0.17",
|
|
44
45
|
"wait-on": "^9.0.3",
|
|
45
|
-
"@mysten/codegen": "^0.8.
|
|
46
|
-
"@mysten/sui": "^2.
|
|
46
|
+
"@mysten/codegen": "^0.8.3",
|
|
47
|
+
"@mysten/sui": "^2.14.0"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
|
-
"@mysten/sui": "^2.
|
|
50
|
+
"@mysten/sui": "^2.14.0"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
53
|
"build": "rm -rf dist && tsc --noEmit && tsdown",
|
|
54
|
+
"build:docs": "tsx ../docs/scripts/build-docs.ts",
|
|
53
55
|
"codegen": "sui-ts-codegen generate && pnpm lint:fix",
|
|
54
56
|
"test": "echo 'No unit tests for kiosk SDK'",
|
|
55
57
|
"pre-commit": "pnpm prettier:fix && pnpm lint && pnpm build",
|
|
@@ -101,7 +101,7 @@ export async function getAllObjects(
|
|
|
101
101
|
const displayData = obj.asMoveObject?.contents?.display;
|
|
102
102
|
const display: KioskDisplay | undefined = displayData
|
|
103
103
|
? {
|
|
104
|
-
data: (displayData.output as Record<string,
|
|
104
|
+
data: (displayData.output as Record<string, unknown> | null) ?? null,
|
|
105
105
|
error: displayData.errors ? JSON.stringify(displayData.errors) : null,
|
|
106
106
|
}
|
|
107
107
|
: undefined;
|
package/src/types/kiosk.ts
CHANGED
|
@@ -89,14 +89,17 @@ export type KioskListing = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
export type KioskDisplay = {
|
|
92
|
-
data: Record<string,
|
|
92
|
+
data: Record<string, unknown> | null;
|
|
93
93
|
error: string | null;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
export type ObjectWithDisplay =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
export type ObjectWithDisplay = Omit<
|
|
97
|
+
SuiClientTypes.Object<{
|
|
98
|
+
content: true;
|
|
99
|
+
previousTransaction: true;
|
|
100
|
+
}>,
|
|
101
|
+
'display'
|
|
102
|
+
> & {
|
|
100
103
|
display?: KioskDisplay;
|
|
101
104
|
};
|
|
102
105
|
|
package/src/utils.ts
CHANGED
|
@@ -104,7 +104,7 @@ export function extractKioskData(
|
|
|
104
104
|
export function attachListingsAndPrices(
|
|
105
105
|
kioskData: KioskData,
|
|
106
106
|
listings: KioskListing[],
|
|
107
|
-
listingObjects:
|
|
107
|
+
listingObjects: ObjectWithDisplay[],
|
|
108
108
|
) {
|
|
109
109
|
const itemListings = listings.reduce<Record<string, KioskListing>>(
|
|
110
110
|
(acc: Record<string, KioskListing>, item, idx) => {
|