@haneullabs/kiosk 1.1.2 → 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 +10 -0
- package/README.md +1 -1
- 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/contracts/kiosk/deps/haneul/kiosk.mjs +1 -1
- package/dist/contracts/kiosk/deps/haneul/kiosk.mjs.map +1 -1
- package/dist/query/client-utils.mjs +6 -6
- 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 +13 -27
- 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 +8 -6
- package/src/contracts/kiosk/deps/haneul/kiosk.ts +1 -1
- package/src/query/client-utils.ts +6 -6
- package/src/types/kiosk.ts +7 -4
- 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 HANEUL 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 HANEUL 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 Haneul 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": "@haneullabs/kiosk",
|
|
3
3
|
"author": "Haneul Labs <build@haneul-labs.com>",
|
|
4
4
|
"description": "Haneul 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,8 +32,8 @@
|
|
|
31
32
|
"url": "https://github.com/GeunhwaJeong/ts-sdks/issues/new"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@haneullabs/utils": "^0.3.
|
|
35
|
-
"@haneullabs/bcs": "^2.0.
|
|
35
|
+
"@haneullabs/utils": "^0.3.2",
|
|
36
|
+
"@haneullabs/bcs": "^2.0.3"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"cross-env": "^10.1.0",
|
|
@@ -42,14 +43,15 @@
|
|
|
42
43
|
"vite": "^7.3.1",
|
|
43
44
|
"vitest": "^4.0.17",
|
|
44
45
|
"wait-on": "^9.0.3",
|
|
45
|
-
"@haneullabs/haneul": "^2.
|
|
46
|
-
"@haneullabs/codegen": "^0.8.
|
|
46
|
+
"@haneullabs/haneul": "^2.13.0",
|
|
47
|
+
"@haneullabs/codegen": "^0.8.3"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
|
-
"@haneullabs/haneul": "^2.
|
|
50
|
+
"@haneullabs/haneul": "^2.13.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": "haneul-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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*
|
|
32
32
|
* - `locked` - Similar to `placed` except that `take` is disabled and the only way
|
|
33
33
|
* to move the asset out of the Kiosk is to `list` it or `list_with_purchase_cap`
|
|
34
|
-
* therefore performing a trade (
|
|
34
|
+
* therefore performing a trade (ishaneulng a `TransferRequest`). The check on the
|
|
35
35
|
* `lock` function makes sure that the `TransferPolicy` exists to not lock the
|
|
36
36
|
* item in a `Kiosk` forever.
|
|
37
37
|
*
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import type { HaneulClientTypes } from '@haneullabs/haneul/client';
|
|
5
5
|
import { graphql } from '@haneullabs/haneul/graphql/schema';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { isHaneulGraphQLClient } from '@haneullabs/haneul/graphql';
|
|
7
|
+
import { isHaneulJsonRpcClient } from '@haneullabs/haneul/jsonRpc';
|
|
8
8
|
import { normalizeStructTag } from '@haneullabs/haneul/utils';
|
|
9
9
|
import { chunk, fromBase64 } from '@haneullabs/utils';
|
|
10
10
|
|
|
@@ -72,7 +72,7 @@ export async function getAllObjects(
|
|
|
72
72
|
const chunks = chunk(ids, DEFAULT_QUERY_LIMIT);
|
|
73
73
|
const results: ObjectWithDisplay[] = [];
|
|
74
74
|
|
|
75
|
-
if (
|
|
75
|
+
if (isHaneulGraphQLClient(client)) {
|
|
76
76
|
for (const batch of chunks) {
|
|
77
77
|
const { data } = await client.query({
|
|
78
78
|
query: FetchObjectsWithDisplayQuery,
|
|
@@ -125,7 +125,7 @@ export async function getAllObjects(
|
|
|
125
125
|
return results;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
if (
|
|
128
|
+
if (isHaneulJsonRpcClient(client)) {
|
|
129
129
|
for (const batch of chunks) {
|
|
130
130
|
const responses = await client.multiGetObjects({
|
|
131
131
|
ids: batch,
|
|
@@ -261,7 +261,7 @@ export async function queryEvents(
|
|
|
261
261
|
client: KioskCompatibleClient,
|
|
262
262
|
eventType: string,
|
|
263
263
|
): Promise<{ json: unknown }[]> {
|
|
264
|
-
if (
|
|
264
|
+
if (isHaneulGraphQLClient(client)) {
|
|
265
265
|
const query = graphql(`
|
|
266
266
|
query QueryEvents($eventType: String!) {
|
|
267
267
|
events(filter: { eventType: $eventType }, first: 50) {
|
|
@@ -286,7 +286,7 @@ export async function queryEvents(
|
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
if (
|
|
289
|
+
if (isHaneulJsonRpcClient(client)) {
|
|
290
290
|
const events = await client.queryEvents({
|
|
291
291
|
query: { MoveEventType: eventType },
|
|
292
292
|
});
|
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
|
+
HaneulClientTypes.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) => {
|