@mysten/kiosk 1.2.4 → 1.2.5
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/package.json +6 -8
- package/docs/advanced-examples.md +0 -100
- package/docs/from-v1.md +0 -314
- package/docs/index.md +0 -22
- package/docs/kiosk-client/introduction.md +0 -50
- package/docs/kiosk-client/kiosk-transaction/examples.md +0 -119
- package/docs/kiosk-client/kiosk-transaction/kiosk-transaction.md +0 -103
- package/docs/kiosk-client/kiosk-transaction/managing.md +0 -235
- package/docs/kiosk-client/kiosk-transaction/purchasing.md +0 -110
- package/docs/kiosk-client/querying.md +0 -237
- package/docs/kiosk-client/transfer-policy-transaction/introduction.md +0 -79
- package/docs/kiosk-client/transfer-policy-transaction/using-the-manager.md +0 -113
- package/docs/llms-index.md +0 -13
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# TransferPolicyTransaction
|
|
2
|
-
|
|
3
|
-
> Create and manage transfer policies for kiosk items using the Kiosk SDK.
|
|
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
|
-
```
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# Using the manager
|
|
2
|
-
|
|
3
|
-
> Use the TransferPolicyTransaction manager to add rules and withdraw profits.
|
|
4
|
-
|
|
5
|
-
After following the introduction steps on how to initialize a transfer policy transaction you can
|
|
6
|
-
call any of the available functions to prepare your Programmable Transaction Block (PTB).
|
|
7
|
-
|
|
8
|
-
## Available functions
|
|
9
|
-
|
|
10
|
-
### Withdraw profits
|
|
11
|
-
|
|
12
|
-
`withdraw(address: string, amount?: string | bigint)`
|
|
13
|
-
|
|
14
|
-
After setting up the manager, you can withdraw profits from the specified transfer policy.
|
|
15
|
-
|
|
16
|
-
`amount` is optional. Leave empty to withdraw all profits.
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
// ... tp transaction is initialized and policy is set.
|
|
20
|
-
// Withdraw 10 SUI from the policy. Leave last parameter empty to withdraw all profits.
|
|
21
|
-
tpTx.withdraw('address_to_transfer_coin', 10_000_000_000n);
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Add/Remove rules
|
|
25
|
-
|
|
26
|
-
> You can chain the actions when you're calling them, to add multiple rules.
|
|
27
|
-
|
|
28
|
-
After setting up the transaction, you can add any of the supported rules to the policy.
|
|
29
|
-
|
|
30
|
-
#### Royalty rule
|
|
31
|
-
|
|
32
|
-
`addRoyaltyRule(percentageBps: number | string, minAmount: number | string)`
|
|
33
|
-
|
|
34
|
-
You can add the royalty rule like the following example.
|
|
35
|
-
|
|
36
|
-
`percentageToBasisPoints` is a helper to convert a percentage (0.00-100%) to basis points.
|
|
37
|
-
|
|
38
|
-
Use `minAmount` to set a minimum amount per transaction, so that the royalty paid is
|
|
39
|
-
**MAX(percentageBps, minAmount)**. Use 0 for no minimum amount.
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
// ... tp transaction is initialized and policy is set.
|
|
43
|
-
tpTx.addRoyaltyRule(percentageToBasisPoints(30), 1_000_000_000);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
You can remove the rule by calling:
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
tpTx.removeRoyaltyRule();
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### Kiosk lock rule
|
|
53
|
-
|
|
54
|
-
`addLockRule()`
|
|
55
|
-
|
|
56
|
-
You can add the kiosk lock rule like the following example.
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
// ... tp transaction is initialized and policy is set.
|
|
60
|
-
tpTx.addLockRule();
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
You can remove the rule by calling:
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
tpTx.removeLockRule();
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
#### Personal kiosk rule
|
|
70
|
-
|
|
71
|
-
`addPersonalKioskRule()`
|
|
72
|
-
|
|
73
|
-
You can add the kiosk lock rule like the following example.
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
// ... tp transaction is initialized and policy is set.
|
|
77
|
-
tpTx.addPersonalKioskRule();
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
You can remove the rule by calling:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
tpTx.removePersonalKioskRule();
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### Floor price rule
|
|
87
|
-
|
|
88
|
-
`addFloorPriceRule(minPrice: string | bigint)`
|
|
89
|
-
|
|
90
|
-
You can add the floor price rule like the following example:
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
// ... tp transaction is initialized and policy is set.
|
|
94
|
-
tpTx.addFloorPriceRule(10_000_000_000n); // sets 10 SUI as the floor price.
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
You can remove the rule by calling:
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
tpTx.removeFloorPriceRule();
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
#### Updating rules
|
|
104
|
-
|
|
105
|
-
If you want to update a rule, call the `remove...` function, and then call `add` again with the new
|
|
106
|
-
settings.
|
|
107
|
-
|
|
108
|
-
Example:
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
// ... tp transaction is initialized and policy is set.
|
|
112
|
-
tpTx.removeRoyaltyRule().addRoyaltyRule(percentageToBasisPoints(20), 1_000_000_000);
|
|
113
|
-
```
|
package/docs/llms-index.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Kiosk
|
|
2
|
-
|
|
3
|
-
> Interact with on-chain commerce applications
|
|
4
|
-
|
|
5
|
-
- [Kiosk SDK](..md): TypeScript SDK for interacting with Sui Kiosk onchain commerce.
|
|
6
|
-
- [Kiosk Client](./kiosk-client/introduction.md): Introduction to the KioskClient extension for
|
|
7
|
-
querying and managing kiosks on Sui.
|
|
8
|
-
- [Querying](./kiosk-client/querying.md): Query kiosk contents, owned kiosks, items, and transfer
|
|
9
|
-
policies using the Kiosk SDK.
|
|
10
|
-
- [Advanced Examples](./advanced-examples.md): Advanced Kiosk SDK usage patterns and code examples
|
|
11
|
-
for complex scenarios.
|
|
12
|
-
- [Migrating from Kiosk SDK V1](./from-v1.md): Migrate from Kiosk SDK v1 to the current version with
|
|
13
|
-
the builder-pattern API.
|