@mysten/kiosk 1.1.1 → 1.1.3
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 +16 -0
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/types/kiosk.d.mts +2 -2
- package/dist/types/kiosk.d.mts.map +1 -1
- package/dist/types/kiosk.mjs.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/contracts/utils/index.ts +1 -1
- package/src/types/kiosk.ts +7 -4
- package/src/utils.ts +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Querying
|
|
2
|
+
|
|
3
|
+
> Query kiosk contents, items, and transfer policies
|
|
4
|
+
|
|
5
|
+
You can use `client.kiosk` to query kiosk data. It helps you get owned kiosks for an address, as
|
|
6
|
+
well as fetching all the contents of a specified kiosk.
|
|
7
|
+
|
|
8
|
+
## Querying owned kiosks
|
|
9
|
+
|
|
10
|
+
Querying owned kiosks returns a list of `kioskOwnerCaps`, as well as a list of the `kioskIds`.
|
|
11
|
+
|
|
12
|
+
`KioskOwnerCap` is important in this case, as it is used for managing an owned kiosk, as well as
|
|
13
|
+
purchasing.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const address = '0xAddress';
|
|
17
|
+
// You can perform actions, like querying the owned kiosks for an address.
|
|
18
|
+
const { kioskOwnerCaps, kioskIds } = await client.kiosk.getOwnedKiosks({ address });
|
|
19
|
+
console.log(kioskOwnerCaps);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* An example response for an address that owns two kiosks (one of which is personal)
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
isPersonal: true,
|
|
26
|
+
digest: '9mstxLa87E3VEewQ62EEQDKb7ZH2irrEXeMetQjQHzXz',
|
|
27
|
+
version: '18',
|
|
28
|
+
objectId: '0x5d4df1b8da5e1b6bafbb4b7dc5c73e532324d82c86e331f71bf1ea5dff18dccc',
|
|
29
|
+
kioskId: '0x8453fc71611ce8ff73efcca42ed241dcaf7dc65411b56a7be42e6a0bc3d72c13'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
isPersonal: false,
|
|
33
|
+
digest: '8fsKgCh5c2ycPKMVUqUz2H6D9WkPjRHmGP454z67afJh',
|
|
34
|
+
version: '15',
|
|
35
|
+
objectId: '0x84f5a9a1379d73eceae03d0578637936e208daa809e04ec07a8085c798a980fd',
|
|
36
|
+
kioskId: '0xf8c826aae52bc576768032ce496b7fc349f9003603ed1541c8033fc5c2dd2d2c'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
*/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Querying kiosk content
|
|
43
|
+
|
|
44
|
+
You can follow the sample to query a kiosk's contents. We recommend saving the `items` structure
|
|
45
|
+
(`KioskItem`), as it's useful when you're trying to purchase from one.
|
|
46
|
+
|
|
47
|
+
`listing` field only applies on items that are listed for sale.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const id = `0xKioskId`;
|
|
51
|
+
|
|
52
|
+
// You can perform actions, like querying a kiosk's contents.
|
|
53
|
+
const res = await client.kiosk.getKiosk({
|
|
54
|
+
id,
|
|
55
|
+
options: {
|
|
56
|
+
withKioskFields: true, // this flag also returns the `kiosk` object in the response, which includes the base setup
|
|
57
|
+
withListingPrices: true, // This flag enables / disables the fetching of the listing prices.
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
console.log(res);
|
|
61
|
+
/**
|
|
62
|
+
* An example response of an existing kiosk
|
|
63
|
+
*
|
|
64
|
+
{
|
|
65
|
+
items: [
|
|
66
|
+
{
|
|
67
|
+
objectId: '0xf65e88a33466763cabd11b7c2a57938cf4fa707c6cf767cb428894e14caf1537',
|
|
68
|
+
type: '0xd12f8e0fdae3f5d88d2fc4af2e869ea503491e2d8da5f3136320b65bdcf70ab3::hero::Hero',
|
|
69
|
+
isLocked: false,
|
|
70
|
+
kioskId: '0x6d45df1942c11048a9182e3f732262e6e3c95ddd2e5f338c565f531717c2617f',
|
|
71
|
+
listing: undefined,
|
|
72
|
+
data: {
|
|
73
|
+
objectId: '0xf65e88a33466763cabd11b7c2a57938cf4fa707c6cf767cb428894e14caf1537',
|
|
74
|
+
version: '18',
|
|
75
|
+
digest: 'As9fkLEP4QVChhYuGemB185xyyzWG4hspSa3UZ6TWR8b',
|
|
76
|
+
display: { data: null, error: null },
|
|
77
|
+
content: {
|
|
78
|
+
dataType: 'moveObject',
|
|
79
|
+
type: '0xd12f8e0fdae3f5d88d2fc4af2e869ea503491e2d8da5f3136320b65bdcf70ab3::hero::Hero',
|
|
80
|
+
hasPublicTransfer: true,
|
|
81
|
+
fields: {
|
|
82
|
+
id: {
|
|
83
|
+
id: '0xf65e88a33466763cabd11b7c2a57938cf4fa707c6cf767cb428894e14caf1537'
|
|
84
|
+
},
|
|
85
|
+
level: 3
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
objectId: '0x34def97cb8c357fcfdf22f72421d4f6f01706662acf7be1afb6e7391d5491372',
|
|
92
|
+
type: '0xd12f8e0fdae3f5d88d2fc4af2e869ea503491e2d8da5f3136320b65bdcf70ab3::hero::Hero',
|
|
93
|
+
isLocked: true,
|
|
94
|
+
kioskId: '0x6d45df1942c11048a9182e3f732262e6e3c95ddd2e5f338c565f531717c2617f',
|
|
95
|
+
listing: undefined,
|
|
96
|
+
data: {
|
|
97
|
+
objectId: '0x34def97cb8c357fcfdf22f72421d4f6f01706662acf7be1afb6e7391d5491372',
|
|
98
|
+
version: '15',
|
|
99
|
+
digest: 'J1MdmHUCXJEKd86rkmMwWASMV86wGkVS9P6SFPyRaKVV',
|
|
100
|
+
display: { data: null, error: null },
|
|
101
|
+
content: {
|
|
102
|
+
dataType: 'moveObject',
|
|
103
|
+
type: '0xd12f8e0fdae3f5d88d2fc4af2e869ea503491e2d8da5f3136320b65bdcf70ab3::hero::Hero',
|
|
104
|
+
hasPublicTransfer: true,
|
|
105
|
+
fields: {
|
|
106
|
+
id: {
|
|
107
|
+
id: '0x34def97cb8c357fcfdf22f72421d4f6f01706662acf7be1afb6e7391d5491372'
|
|
108
|
+
},
|
|
109
|
+
level: 1
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
itemIds: [
|
|
116
|
+
'0xf65e88a33466763cabd11b7c2a57938cf4fa707c6cf767cb428894e14caf1537',
|
|
117
|
+
'0x34def97cb8c357fcfdf22f72421d4f6f01706662acf7be1afb6e7391d5491372'
|
|
118
|
+
],
|
|
119
|
+
listingIds: [],
|
|
120
|
+
extensions: [],
|
|
121
|
+
kiosk: {
|
|
122
|
+
id: '6d45df1942c11048a9182e3f732262e6e3c95ddd2e5f338c565f531717c2617f',
|
|
123
|
+
profits: '100000',
|
|
124
|
+
owner: '96300f8d9064f954f99db2d7fbe2ad0c5e4344f0e22392330285d399498cfaf3',
|
|
125
|
+
itemCount: 2,
|
|
126
|
+
allowExtensions: false
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
*/
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Query kiosk extension
|
|
133
|
+
|
|
134
|
+
Queries an extension's data. Returns `null` if there's no extension with that type installed.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// The type of the custom extension.
|
|
138
|
+
const type = '0xAddress::custom_extension::ACustomExtensionType';
|
|
139
|
+
|
|
140
|
+
const extension = await client.kiosk.getKioskExtension({
|
|
141
|
+
kioskId: '0xAKioskId',
|
|
142
|
+
type,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
console.log(extension);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* An example output of the response
|
|
149
|
+
{
|
|
150
|
+
objectId: 'extensionObjectId',
|
|
151
|
+
type: '0xAddress::custom_extension::ACustomExtensionType',
|
|
152
|
+
isEnabled: true,
|
|
153
|
+
permissions: "3",
|
|
154
|
+
storageId: '0xExampleStorageId',
|
|
155
|
+
storageSize: "0",
|
|
156
|
+
}
|
|
157
|
+
*/
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Querying transfer policy for type
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const itemType = '0xAddress::hero::Hero';
|
|
164
|
+
// You can perform actions, like querying transfer policy for type.
|
|
165
|
+
const policies = await client.kiosk.getTransferPolicies({ type: itemType });
|
|
166
|
+
console.log(policies);
|
|
167
|
+
|
|
168
|
+
/* An example output of the response
|
|
169
|
+
[
|
|
170
|
+
{
|
|
171
|
+
id: '0x074847055fe4ea9a7f51eeaf095c05875509403059115af121cfea9b8de355de',
|
|
172
|
+
type: '0x2::transfer_policy::TransferPolicy<0x85926b03d56e49bedfca558fc6a2540d43bdfb5c218190d63b571f33afe255f8::hero::Hero>',
|
|
173
|
+
owner: { Shared: { initial_shared_version: 5 } },
|
|
174
|
+
rules: [
|
|
175
|
+
'a82212d931d3bc7c3401552d935abced7b7fd41d4f57a99f0f47b9196b2f57f5::kiosk_lock_rule::Rule',
|
|
176
|
+
'a82212d931d3bc7c3401552d935abced7b7fd41d4f57a99f0f47b9196b2f57f5::floor_price_rule::Rule',
|
|
177
|
+
'a82212d931d3bc7c3401552d935abced7b7fd41d4f57a99f0f47b9196b2f57f5::royalty_rule::Rule',
|
|
178
|
+
'a82212d931d3bc7c3401552d935abced7b7fd41d4f57a99f0f47b9196b2f57f5::personal_kiosk_rule::Rule'
|
|
179
|
+
],
|
|
180
|
+
balance: '20000'
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
*/
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Get owned transfer policies
|
|
187
|
+
|
|
188
|
+
Queries to find all the owned transfer policies. Useful to manage transfer policies, and can be
|
|
189
|
+
combined with `TransferPolicyTransaction` to easily add or remove rules and withdraw profits.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// The address that owns the transfer policies.
|
|
193
|
+
const address = '0xAddress';
|
|
194
|
+
// You can perform actions, like querying the owned transfer policies for an address.
|
|
195
|
+
const policies = await client.kiosk.getOwnedTransferPolicies({ address });
|
|
196
|
+
console.log(policies);
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* An example output of the response
|
|
200
|
+
[
|
|
201
|
+
{
|
|
202
|
+
policyId: '0x6b6eca8df6e70ea6447e639ef26b519039b5e9123642258eea1b3c781e94faca',
|
|
203
|
+
policyCapId: '0x34a4794d4ad6578ac345d23ca0f7a4632ca88de297daaf24a1cdbc91e1547be4',
|
|
204
|
+
type: '0xbe01d0594bedbce45c0e08c7374b03bf822e9b73cd7d555bf39c39bbf09d23a9::hero::Hero'
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
policyId: '0x87ac2dd80011ed2de9c7916a19145ff520959acd3d8c3dbd100aa74b34155a0a',
|
|
208
|
+
policyCapId: '0x858edda13c5c9086b2491eafed39e0ea58511268bb90d90464a2d7b5ed3f3880',
|
|
209
|
+
type: '0xbe01d0594bedbce45c0e08c7374b03bf822e9b73cd7d555bf39c39bbf09d23a9::hero::Villain'
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
*/
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Get owned transfer policies by type
|
|
216
|
+
|
|
217
|
+
Queries to find all the owned transfer policies for a specific type. Useful to manage transfer
|
|
218
|
+
policies, and can be combined with
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
// The address that owns the transfer policies.
|
|
222
|
+
const address = '0xAddress';
|
|
223
|
+
// The type of the transfer policy.
|
|
224
|
+
const type = '0xbe01d0594bedbce45c0e08c7374b03bf822e9b73cd7d555bf39c39bbf09d23a9::hero::Hero';
|
|
225
|
+
|
|
226
|
+
// We can query by type.
|
|
227
|
+
const policies = await client.kiosk.getOwnedTransferPoliciesByType({ address, type });
|
|
228
|
+
|
|
229
|
+
// An example output of the response
|
|
230
|
+
// [
|
|
231
|
+
// {
|
|
232
|
+
// policyId: '0x6b6eca8df6e70ea6447e639ef26b519039b5e9123642258eea1b3c781e94faca',
|
|
233
|
+
// policyCapId: '0x34a4794d4ad6578ac345d23ca0f7a4632ca88de297daaf24a1cdbc91e1547be4',
|
|
234
|
+
// type: '0xbe01d0594bedbce45c0e08c7374b03bf822e9b73cd7d555bf39c39bbf09d23a9::hero::Hero'
|
|
235
|
+
// }
|
|
236
|
+
// ]
|
|
237
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# TransferPolicyTransaction
|
|
2
|
+
|
|
3
|
+
> Create and manage transfer policies for kiosk items
|
|
4
|
+
|
|
5
|
+
`TransferPolicyTransaction` is the client to build transactions that involve transfer policy
|
|
6
|
+
management. It's used similar to `KioskTransaction`, and helps in crafting transactions to manage a
|
|
7
|
+
transfer policy.
|
|
8
|
+
|
|
9
|
+
You need to instantiate it once in every Programmable Transaction Block (PTB) that you're building.
|
|
10
|
+
|
|
11
|
+
Similar to `KioskTransaction`, you can either create a new transfer policy, or use an existing one.
|
|
12
|
+
|
|
13
|
+
## Using an existing transfer policy
|
|
14
|
+
|
|
15
|
+
If you have already retrieved a transfer policy from `client.kiosk.getOwnedTransferPolicies()`, or
|
|
16
|
+
`client.kiosk.getOwnedTransferPoliciesByType()`, you can pass a `TransferPolicyCap` result when
|
|
17
|
+
instantiating.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// You could have more than one cap, since we can create more than one transfer policy.
|
|
21
|
+
const heroPolicyCaps = await client.kiosk.getOwnedTransferPoliciesByType({
|
|
22
|
+
type: `${packageId}::hero::Hero`,
|
|
23
|
+
address: '0xConnectedAddress',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const tx = new Transaction();
|
|
27
|
+
// You can choose to use any of the caps you have. For this example, use the first one.
|
|
28
|
+
const tpTx = new TransferPolicyTransaction({
|
|
29
|
+
kioskClient: client.kiosk,
|
|
30
|
+
transaction: tx,
|
|
31
|
+
cap: heroPolicyCaps[0],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// A demonstration of using all the available rule add/remove functions.
|
|
35
|
+
// You can chain these commands.
|
|
36
|
+
tpTx
|
|
37
|
+
.addFloorPriceRule(10n)
|
|
38
|
+
.addLockRule()
|
|
39
|
+
.addRoyaltyRule(percentageToBasisPoints(10), 0)
|
|
40
|
+
.addPersonalKioskRule();
|
|
41
|
+
// .removeFloorPriceRule()
|
|
42
|
+
// .removeLockRule()
|
|
43
|
+
// .removeRoyaltyRule()
|
|
44
|
+
// .removePersonalKioskRule()
|
|
45
|
+
|
|
46
|
+
// Sign and execute transaction.
|
|
47
|
+
await signAndExecuteTransaction({ tx: tx });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Creating a new transfer policy
|
|
51
|
+
|
|
52
|
+
If you don't have an existing transfer policy, you can create a new one. You can also attach rules
|
|
53
|
+
in the same PTB.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const publisher = '0xPackagePublisherObject';
|
|
57
|
+
const tx = new Transaction();
|
|
58
|
+
|
|
59
|
+
const tpTx = new TransferPolicyTransaction({ kioskClient: client.kiosk, transaction: tx });
|
|
60
|
+
|
|
61
|
+
// This is an async call, as the SDK protects from accidentally creating
|
|
62
|
+
// a second transfer policy.
|
|
63
|
+
// You can skip this check by passing `skipCheck: true`.
|
|
64
|
+
await tpTx.create({
|
|
65
|
+
type: `${heroPackageId}::hero::Hero`,
|
|
66
|
+
publisher,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
tpTx
|
|
70
|
+
.addLockRule()
|
|
71
|
+
.addFloorPriceRule(1000n)
|
|
72
|
+
.addRoyaltyRule(percentageToBasisPoints(10), 100)
|
|
73
|
+
.addPersonalKioskRule()
|
|
74
|
+
// Transfers the `TransferPolicyCap` to the user and shares the transfer policy.
|
|
75
|
+
.shareAndTransferCap('address_to_transfer_cap_to');
|
|
76
|
+
|
|
77
|
+
// Sign and execute transaction.
|
|
78
|
+
await signAndExecuteTransaction({ tx: tx });
|
|
79
|
+
```
|
|
@@ -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.1.
|
|
5
|
+
"version": "1.1.3",
|
|
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.8.0"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
|
-
"@mysten/sui": "^2.
|
|
50
|
+
"@mysten/sui": "^2.8.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",
|
package/src/types/kiosk.ts
CHANGED
|
@@ -93,10 +93,13 @@ export type KioskDisplay = {
|
|
|
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) => {
|