@mysten/kiosk 1.2.5 → 1.2.6

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.
@@ -0,0 +1,79 @@
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
+ ```
@@ -0,0 +1,113 @@
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
+ ```
@@ -0,0 +1,14 @@
1
+ # Kiosk
2
+ > Interact with on-chain commerce applications
3
+
4
+ - [Kiosk SDK](..md): TypeScript SDK for interacting with Sui Kiosk onchain commerce.
5
+ - [Kiosk Client](./kiosk-client/introduction.md): Introduction to the KioskClient extension for querying and managing kiosks on Sui.
6
+ - [Querying](./kiosk-client/querying.md): Query kiosk contents, owned kiosks, items, and transfer policies using the Kiosk SDK.
7
+ - [KioskTransaction](./kiosk-client/kiosk-transaction/kiosk-transaction.md): Build kiosk transactions for listing, purchasing, and managing items on Sui.
8
+ - [Managing Owned Kiosk](./kiosk-client/kiosk-transaction/managing.md): Manage kiosk items by placing, listing, delisting, and withdrawing using the Kiosk SDK.
9
+ - [Purchasing from a kiosk](./kiosk-client/kiosk-transaction/purchasing.md): Purchase items from kiosks with automatic transfer policy rule resolution.
10
+ - [Examples](./kiosk-client/kiosk-transaction/examples.md): Practical code examples for kiosk transactions including minting, listing, and purchasing.
11
+ - [TransferPolicyTransaction](./kiosk-client/transfer-policy-transaction/introduction.md): Create and manage transfer policies for kiosk items using the Kiosk SDK.
12
+ - [Using the manager](./kiosk-client/transfer-policy-transaction/using-the-manager.md): Use the TransferPolicyTransaction manager to add rules and withdraw profits.
13
+ - [Advanced Examples](./advanced-examples.md): Advanced Kiosk SDK usage patterns and code examples for complex scenarios.
14
+ - [Migrating from Kiosk SDK V1](./from-v1.md): Migrate from Kiosk SDK v1 to the current version with the builder-pattern API.
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.2.5",
5
+ "version": "1.2.6",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
8
  "main": "./dist/index.mjs",
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/MystenLabs/ts-sdks/issues/new"
33
33
  },
34
34
  "dependencies": {
35
- "@mysten/bcs": "^2.0.4",
36
- "@mysten/utils": "^0.3.2"
35
+ "@mysten/utils": "^0.3.3",
36
+ "@mysten/bcs": "^2.0.5"
37
37
  },
38
38
  "devDependencies": {
39
39
  "cross-env": "^10.1.0",
@@ -45,7 +45,7 @@
45
45
  "wait-on": "^9.0.3"
46
46
  },
47
47
  "peerDependencies": {
48
- "@mysten/sui": "^2.16.1"
48
+ "@mysten/sui": "^2.16.2"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rm -rf dist && tsc --noEmit && tsdown",