@mysten/kiosk 1.2.3 → 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 +34 -0
- package/dist/contracts/utils/index.mjs +6 -5
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/package.json +6 -8
- package/src/contracts/utils/index.ts +9 -5
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @mysten/kiosk
|
|
2
2
|
|
|
3
|
+
## 1.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e067cf: Validate the new per-package release flow end-to-end across every public @mysten package.
|
|
8
|
+
No functional changes — empty patch bump to force the orchestrator to dispatch every
|
|
9
|
+
release-<pkg>.yml workflow with `dry_run=false` so each package publishes via OIDC trusted
|
|
10
|
+
publishing.
|
|
11
|
+
- Updated dependencies [9e067cf]
|
|
12
|
+
- @mysten/bcs@2.0.4
|
|
13
|
+
- @mysten/sui@2.16.1
|
|
14
|
+
- @mysten/utils@0.3.2
|
|
15
|
+
|
|
16
|
+
## 1.2.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- bb8d26a: Fix three latent type errors in the generated `utils/index.ts` that surfaced for
|
|
21
|
+
consumers with `noUncheckedIndexedAccess: true`:
|
|
22
|
+
- `getPureBcsSchema(structTag.typeParams[0])` passed `TypeTag | undefined` to a parameter typed
|
|
23
|
+
`string | TypeTag`. Now null-checks the inner tag before passing it.
|
|
24
|
+
- `argTypes[i]` was redundantly re-indexed inside a `for…of entries()` loop, returning
|
|
25
|
+
`string | null | undefined` and being passed back to `getPureBcsSchema`. Switched to the loop
|
|
26
|
+
variable, which is `string | null`.
|
|
27
|
+
- `MoveStruct.get()` returned the destructured `[res]` from `getMany([objectId])` without
|
|
28
|
+
asserting it was defined. Now throws if no object was returned.
|
|
29
|
+
|
|
30
|
+
The codegen test suite gained a `tsc`-based check that compiles the generated `utils/index.ts`
|
|
31
|
+
under strict + `noUncheckedIndexedAccess`, so embedded-template type bugs are caught before
|
|
32
|
+
release rather than by downstream consumers.
|
|
33
|
+
|
|
34
|
+
All consumer packages (`payment-kit`, `pas`, `walrus`, `suins`, `deepbook-v3`, `kiosk`) have been
|
|
35
|
+
regenerated with the fix.
|
|
36
|
+
|
|
3
37
|
## 1.2.3
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -24,7 +24,8 @@ function getPureBcsSchema(typeTag) {
|
|
|
24
24
|
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
25
25
|
if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") return bcs.String;
|
|
26
26
|
if (structTag.module === "option" && structTag.name === "Option") {
|
|
27
|
-
const
|
|
27
|
+
const inner = structTag.typeParams[0];
|
|
28
|
+
const type = inner ? getPureBcsSchema(inner) : null;
|
|
28
29
|
return type ? bcs.option(type) : null;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -37,7 +38,7 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
37
38
|
if (parameterNames && argLen !== parameterNames.length) throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
|
|
38
39
|
const normalizedArgs = [];
|
|
39
40
|
let index = 0;
|
|
40
|
-
for (const
|
|
41
|
+
for (const argType of argTypes) {
|
|
41
42
|
if (argType === "0x2::clock::Clock") {
|
|
42
43
|
normalizedArgs.push((tx) => tx.object.clock());
|
|
43
44
|
continue;
|
|
@@ -69,8 +70,7 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
69
70
|
normalizedArgs.push(arg);
|
|
70
71
|
continue;
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
-
const bcsType = type === null ? null : getPureBcsSchema(type);
|
|
73
|
+
const bcsType = argType === null ? null : getPureBcsSchema(argType);
|
|
74
74
|
if (bcsType) {
|
|
75
75
|
const bytes = bcsType.serialize(arg);
|
|
76
76
|
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
@@ -80,7 +80,7 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
80
80
|
normalizedArgs.push((tx) => tx.object(arg));
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
|
-
throw new Error(`Invalid argument ${stringify(arg)} for type ${
|
|
83
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);
|
|
84
84
|
}
|
|
85
85
|
return normalizedArgs;
|
|
86
86
|
}
|
|
@@ -90,6 +90,7 @@ var MoveStruct = class extends BcsStruct {
|
|
|
90
90
|
...options,
|
|
91
91
|
objectIds: [objectId]
|
|
92
92
|
});
|
|
93
|
+
if (!res) throw new Error(`No object found for id ${objectId}`);
|
|
93
94
|
return res;
|
|
94
95
|
}
|
|
95
96
|
async getMany({ client, ...options }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["SUI_FRAMEWORK_ADDRESS","val"],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["SUI_FRAMEWORK_ADDRESS","val"],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":"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"}
|
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
|
+
"version": "1.2.5",
|
|
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.
|
|
36
|
-
"@mysten/utils": "^0.3.
|
|
35
|
+
"@mysten/bcs": "^2.0.4",
|
|
36
|
+
"@mysten/utils": "^0.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"cross-env": "^10.1.0",
|
|
@@ -42,16 +42,14 @@
|
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
43
|
"vite": "^8.0.5",
|
|
44
44
|
"vitest": "^4.0.17",
|
|
45
|
-
"wait-on": "^9.0.3"
|
|
46
|
-
"@mysten/codegen": "^0.10.0",
|
|
47
|
-
"@mysten/sui": "^2.16.0"
|
|
45
|
+
"wait-on": "^9.0.3"
|
|
48
46
|
},
|
|
49
47
|
"peerDependencies": {
|
|
50
|
-
"@mysten/sui": "^2.16.
|
|
48
|
+
"@mysten/sui": "^2.16.1"
|
|
51
49
|
},
|
|
52
50
|
"scripts": {
|
|
53
51
|
"build": "rm -rf dist && tsc --noEmit && tsdown",
|
|
54
|
-
"build:docs": "
|
|
52
|
+
"build:docs": "node ../docs/scripts/build-docs.ts",
|
|
55
53
|
"codegen": "sui-ts-codegen generate && pnpm lint:fix",
|
|
56
54
|
"test": "echo 'No unit tests for kiosk SDK'",
|
|
57
55
|
"pre-commit": "pnpm prettier:fix && pnpm lint && pnpm build",
|
|
@@ -57,7 +57,8 @@ export function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
60
|
-
const
|
|
60
|
+
const inner = structTag.typeParams[0];
|
|
61
|
+
const type = inner ? getPureBcsSchema(inner) : null;
|
|
61
62
|
return type ? bcs.option(type) : null;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -89,7 +90,7 @@ export function normalizeMoveArguments(
|
|
|
89
90
|
const normalizedArgs: TransactionArgument[] = [];
|
|
90
91
|
|
|
91
92
|
let index = 0;
|
|
92
|
-
for (const
|
|
93
|
+
for (const argType of argTypes) {
|
|
93
94
|
if (argType === '0x2::clock::Clock') {
|
|
94
95
|
normalizedArgs.push((tx) => tx.object.clock());
|
|
95
96
|
continue;
|
|
@@ -137,8 +138,7 @@ export function normalizeMoveArguments(
|
|
|
137
138
|
continue;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
const
|
|
141
|
-
const bcsType = type === null ? null : getPureBcsSchema(type);
|
|
141
|
+
const bcsType = argType === null ? null : getPureBcsSchema(argType);
|
|
142
142
|
|
|
143
143
|
if (bcsType) {
|
|
144
144
|
const bytes = bcsType.serialize(arg as never);
|
|
@@ -151,7 +151,7 @@ export function normalizeMoveArguments(
|
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
throw new Error(`Invalid argument ${stringify(arg)} for type ${
|
|
154
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
return normalizedArgs;
|
|
@@ -174,6 +174,10 @@ export class MoveStruct<
|
|
|
174
174
|
objectIds: [objectId],
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
+
if (!res) {
|
|
178
|
+
throw new Error(`No object found for id ${objectId}`);
|
|
179
|
+
}
|
|
180
|
+
|
|
177
181
|
return res;
|
|
178
182
|
}
|
|
179
183
|
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# Advanced Examples
|
|
2
|
-
|
|
3
|
-
> Advanced Kiosk SDK usage patterns and code examples for complex scenarios.
|
|
4
|
-
|
|
5
|
-
# Some extended examples
|
|
6
|
-
|
|
7
|
-
For these examples, assume you have the following data and functions available:
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
// a constant for bullshark's type.
|
|
11
|
-
const bullsharkType = `${packageId}::suifrens::SuiFren<${packageId}::bullshark::Bullshark>`;
|
|
12
|
-
// a constant for capy's type.
|
|
13
|
-
const capyType = `${packageId}::suifrens::SuiFren<${packageId}::capy::Capy>`;
|
|
14
|
-
|
|
15
|
-
// initialize the client with the kiosk extension.
|
|
16
|
-
const client = new SuiJsonRpcClient({
|
|
17
|
-
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
18
|
-
network: 'mainnet',
|
|
19
|
-
}).$extend(kiosk());
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Minting a SuiFren
|
|
23
|
-
|
|
24
|
-
This example demonstrates how to mint a SuiFren.
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
async function mintFren(address: string) {
|
|
28
|
-
const { kioskOwnerCaps } = await client.kiosk.getOwnedKiosks({ address });
|
|
29
|
-
|
|
30
|
-
// Choose the first kiosk for simplicity. We could have extra logic here (e.g. let the user choose, pick a personal one, etc).
|
|
31
|
-
const cap = kioskOwnerCaps[0];
|
|
32
|
-
|
|
33
|
-
const tx = new Transaction();
|
|
34
|
-
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });
|
|
35
|
-
|
|
36
|
-
// We're mixing the logic here. If the cap is undefined, we create a new kiosk.
|
|
37
|
-
if (!cap) kioskTx.create();
|
|
38
|
-
|
|
39
|
-
// Let's mint a capy here into the kiosk (either a new or an existing one).
|
|
40
|
-
tx.moveCall({
|
|
41
|
-
target: `${packageId}::suifrens::mint_app::mint`,
|
|
42
|
-
arguments: [kioskTx.getKiosk(), kioskTx.getKioskCap()],
|
|
43
|
-
typeArguments: [capyType],
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// If we don't have a cap, that means we create a new kiosk for the user in this flow.
|
|
47
|
-
if (!cap) kioskTx.shareAndTransferCap(address);
|
|
48
|
-
|
|
49
|
-
kioskTx.finalize();
|
|
50
|
-
|
|
51
|
-
// sign and execute transaction.
|
|
52
|
-
await signAndExecuteTransaction({ tx: tx });
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Mixing two Suifrens
|
|
57
|
-
|
|
58
|
-
This example demonstrates how to use the Kiosk SDK to mix two `bullsharks`.
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
// We're mixing two frens.
|
|
62
|
-
async function mixFrens(firstFrenObjectId: string, secondFrenObjectId: string, cap: KioskOwnerCap) {
|
|
63
|
-
const tx = new Transaction();
|
|
64
|
-
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });
|
|
65
|
-
|
|
66
|
-
// borrow both frens.
|
|
67
|
-
const [fren1, promise1] = kioskTx.borrow({
|
|
68
|
-
itemType: bullsharkType,
|
|
69
|
-
itemId: firstFrenObjectId,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const [fren2, promise2] = kioskTx.borrow({
|
|
73
|
-
itemType: bullsharkType,
|
|
74
|
-
itemId: secondFrenObjectId,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Let's call the mix function. We skip any payment related stuff here.
|
|
78
|
-
tx.moveCall({
|
|
79
|
-
target: `${packageId}::mix_app::mix`,
|
|
80
|
-
arguments: [fren1, fren2, kioskTx.getKiosk(), kioskTx.getKioskCap()],
|
|
81
|
-
typeArguments: [bullsharkType],
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
kioskTx
|
|
85
|
-
.return({
|
|
86
|
-
itemType: bullsharkType,
|
|
87
|
-
item: fren1,
|
|
88
|
-
promise: promise1,
|
|
89
|
-
})
|
|
90
|
-
.return({
|
|
91
|
-
itemType: bullsharkType,
|
|
92
|
-
item: fren2,
|
|
93
|
-
promise: promise2,
|
|
94
|
-
})
|
|
95
|
-
.finalize();
|
|
96
|
-
|
|
97
|
-
// sign and execute transaction.
|
|
98
|
-
await signAndExecuteTransaction({ tx: tx });
|
|
99
|
-
}
|
|
100
|
-
```
|
package/docs/from-v1.md
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
# Migrating from Kiosk SDK V1
|
|
2
|
-
|
|
3
|
-
> Migrate from Kiosk SDK v1 to the current version with the builder-pattern API.
|
|
4
|
-
|
|
5
|
-
The original version of Kiosk SDK provided basic experimentation with the Kiosk API. The new version
|
|
6
|
-
of the SDK (0.7+) provides a more robust experience for building kiosk/transfer policy transactions.
|
|
7
|
-
|
|
8
|
-
The new SDK offers a builder-pattern API, which provides better autocomplete capabilities, and also
|
|
9
|
-
makes code more readable.
|
|
10
|
-
|
|
11
|
-
While a one-to-one mapping between the old and new SDK is not possible, the following examples
|
|
12
|
-
should help you get started.
|
|
13
|
-
|
|
14
|
-
> An important benefit of the new SDK is that it works seamlessly with Personal Kiosk, which was not
|
|
15
|
-
> the case with the previous SDK (you would always have to wrap the transaction with `borrow_cap` /
|
|
16
|
-
> `return_cap` calls depending on whether the kiosk is personal or not).
|
|
17
|
-
|
|
18
|
-
## Placing an item to kiosk and listing it for sale
|
|
19
|
-
|
|
20
|
-
The following example is from the original Kiosk SDK V1 documentation.
|
|
21
|
-
|
|
22
|
-
### Before
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
const placeAndListToKiosk = async () => {
|
|
26
|
-
const kiosk = 'SomeKioskId';
|
|
27
|
-
const kioskCap = 'KioskCapObjectId';
|
|
28
|
-
const itemType = '0xItemAddr::some:ItemType';
|
|
29
|
-
const item = 'SomeItemId';
|
|
30
|
-
const price = '100000';
|
|
31
|
-
|
|
32
|
-
const tx = new Transaction();
|
|
33
|
-
|
|
34
|
-
placeAndList(tx, itemType, kiosk, kioskCap, item, price);
|
|
35
|
-
|
|
36
|
-
// ... continue to sign and execute the transaction
|
|
37
|
-
// ...
|
|
38
|
-
};
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### After
|
|
42
|
-
|
|
43
|
-
Using the new SDK, you can build the same transaction as follows:
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
// You need to do this only once and re-use it in the application.
|
|
47
|
-
const client = new SuiJsonRpcClient({
|
|
48
|
-
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
49
|
-
network: 'mainnet',
|
|
50
|
-
}).$extend(kiosk());
|
|
51
|
-
|
|
52
|
-
const placeAndListToKiosk = async () => {
|
|
53
|
-
// Assume you have saved the user's preferred kiosk Cap somewhere in your app's state.
|
|
54
|
-
const { kioskOwnerCaps } = await client.kiosk.getOwnedKiosks({ address: '0xSomeAddress' });
|
|
55
|
-
|
|
56
|
-
const tx = new Transaction();
|
|
57
|
-
|
|
58
|
-
// Assume you use the first owned kiosk.
|
|
59
|
-
new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap: kioskOwnerCaps[0] })
|
|
60
|
-
.placeAndList({
|
|
61
|
-
itemType: '0xItemAddr::some:ItemType',
|
|
62
|
-
item: 'SomeItemId',
|
|
63
|
-
price: '100000',
|
|
64
|
-
})
|
|
65
|
-
.finalize();
|
|
66
|
-
|
|
67
|
-
// ... continue to sign and execute the transaction
|
|
68
|
-
};
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Create a new kiosk
|
|
72
|
-
|
|
73
|
-
The following example is from the original Kiosk SDK V1 documentation.
|
|
74
|
-
|
|
75
|
-
### Before
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
const createKiosk = async () => {
|
|
79
|
-
const accountAddress = '0xSomeSuiAddress';
|
|
80
|
-
|
|
81
|
-
const tx = new Transaction();
|
|
82
|
-
const kiosk_cap = createKioskAndShare(tx);
|
|
83
|
-
|
|
84
|
-
tx.transferObjects([kiosk_cap], accountAddress);
|
|
85
|
-
|
|
86
|
-
// ... continue to sign and execute the transaction
|
|
87
|
-
// ...
|
|
88
|
-
};
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### After
|
|
92
|
-
|
|
93
|
-
Using the new SDK, you can build the same transaction as follows:
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
// You need to do this only once and re-use it in the application.
|
|
97
|
-
const client = new SuiJsonRpcClient({
|
|
98
|
-
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
99
|
-
network: 'mainnet',
|
|
100
|
-
}).$extend(kiosk());
|
|
101
|
-
|
|
102
|
-
const createKiosk = async () => {
|
|
103
|
-
const tx = new Transaction();
|
|
104
|
-
|
|
105
|
-
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk });
|
|
106
|
-
|
|
107
|
-
kioskTx.create().shareAndTransferCap('0xSomeSuiAddress').finalize();
|
|
108
|
-
|
|
109
|
-
// ... continue to sign and execute the transaction
|
|
110
|
-
};
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Purchasing an item and resolving rules
|
|
114
|
-
|
|
115
|
-
The following example is from the original Kiosk SDK V1 documentation.
|
|
116
|
-
|
|
117
|
-
### Before
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
|
|
121
|
-
queryTransferPolicy,
|
|
122
|
-
purchaseAndResolvePolicies,
|
|
123
|
-
place,
|
|
124
|
-
testnetEnvironment,
|
|
125
|
-
} from '@mysten/kiosk';
|
|
126
|
-
|
|
127
|
-
const client = new SuiJsonRpcClient({
|
|
128
|
-
url: 'https://fullnode.testnet.sui.io:443',
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// The kiosk we're purchasing from.
|
|
132
|
-
const kioskId = `0xSomeKioskAddress`;
|
|
133
|
-
// A sample item retrieved from `fetchKiosk` function (or hard-coded).
|
|
134
|
-
const item = {
|
|
135
|
-
isLocked: false,
|
|
136
|
-
objectId: '0xb892d61a9992a10c9453efcdbd14ca9720d7dc1000a2048224209c9e544ed223',
|
|
137
|
-
type: '0x52852c4ba80040395b259c641e70b702426a58990ff73cecf5afd31954429090::test::TestItem',
|
|
138
|
-
listing: {
|
|
139
|
-
isExclusive: false,
|
|
140
|
-
listingId: '0x368b512ff2514dbea814f26ec9a3d41198c00e8ed778099961e9ed22a9f0032b',
|
|
141
|
-
price: '20000000000', // in MIST
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
const ownedKiosk = `0xMyKioskAddress`;
|
|
145
|
-
const ownedKioskCap = `0xMyKioskOwnerCap`;
|
|
146
|
-
|
|
147
|
-
const purchaseItem = async (item, kioskId) => {
|
|
148
|
-
// Fetch the policy of the item (could be an array, if there's more than one transfer policy)
|
|
149
|
-
const policies = await queryTransferPolicy(client, item.type);
|
|
150
|
-
// Selecting the first one for simplicity.
|
|
151
|
-
const policyId = policy[0]?.id;
|
|
152
|
-
// Initialize transaction.
|
|
153
|
-
const tx = new Transaction();
|
|
154
|
-
|
|
155
|
-
// Both are required if there is a `kiosk_lock_rule`.
|
|
156
|
-
// Optional otherwise. Function throws an error if there's a kiosk_lock_rule and these are missing.
|
|
157
|
-
const extraParams = {
|
|
158
|
-
ownedKiosk,
|
|
159
|
-
ownedKioskCap,
|
|
160
|
-
};
|
|
161
|
-
// Define the environment.
|
|
162
|
-
// To use a custom package address for rules, you could call:
|
|
163
|
-
// const environment = customEnvironment('<PackageAddress>');
|
|
164
|
-
const environment = testnetEnvironment;
|
|
165
|
-
|
|
166
|
-
// Extra params. Optional, but required if the user tries to resolve a `kiosk_lock_rule`.
|
|
167
|
-
// Purchases the item. Supports `kiosk_lock_rule`, `royalty_rule` (accepts combination too).
|
|
168
|
-
const result = purchaseAndResolvePolicies(
|
|
169
|
-
tx,
|
|
170
|
-
item.type,
|
|
171
|
-
item.listing.price,
|
|
172
|
-
kioskId,
|
|
173
|
-
item.objectId,
|
|
174
|
-
policy[0],
|
|
175
|
-
environment,
|
|
176
|
-
extraParams,
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
// result = {item: <the_purchased_item>, canTransfer: true/false // depending on whether there was a kiosk lock rule }
|
|
180
|
-
// If the item didn't have a kiosk_lock_rule, you need to do something with it.
|
|
181
|
-
// For example, place it in your own kiosk. (demonstrated below)
|
|
182
|
-
if (result.canTransfer) place(tx, item.type, ownedKiosk, ownedKioskCap, result.item);
|
|
183
|
-
|
|
184
|
-
// ...finally, sign PTB & execute it.
|
|
185
|
-
};
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### After
|
|
189
|
-
|
|
190
|
-
Using the new SDK, you can build the same transaction as follows:
|
|
191
|
-
|
|
192
|
-
> This works with both personal and non-personal kiosks.
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
// You need to do this only once and re-use it in the application.
|
|
196
|
-
const client = new SuiJsonRpcClient({
|
|
197
|
-
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
198
|
-
network: 'mainnet',
|
|
199
|
-
}).$extend(kiosk());
|
|
200
|
-
|
|
201
|
-
// An Item as returned from `client.kiosk.getKiosk()` call.
|
|
202
|
-
const item = {
|
|
203
|
-
isLocked: false,
|
|
204
|
-
objectId: '0xb892d61a9992a10c9453efcdbd14ca9720d7dc1000a2048224209c9e544ed223',
|
|
205
|
-
type: '0x52852c4ba80040395b259c641e70b702426a58990ff73cecf5afd31954429090::test::TestItem',
|
|
206
|
-
kioskId: '0xSomeKioskAddress',
|
|
207
|
-
listing: {
|
|
208
|
-
isExclusive: false,
|
|
209
|
-
listingId: '0x368b512ff2514dbea814f26ec9a3d41198c00e8ed778099961e9ed22a9f0032b',
|
|
210
|
-
price: '20000000000', // in MIST
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const purchase = async () => {
|
|
215
|
-
// Assume you have saved the user's preferred kiosk Cap somewhere in your app's state.
|
|
216
|
-
// You wouldn't need to query this for every purchase.
|
|
217
|
-
const { kioskOwnerCaps } = await client.kiosk.getOwnedKiosks({ address: '0xSomeAddress' });
|
|
218
|
-
|
|
219
|
-
const tx = new Transaction();
|
|
220
|
-
|
|
221
|
-
const kioskTx = new KioskTransaction({
|
|
222
|
-
transaction: tx,
|
|
223
|
-
kioskClient: client.kiosk,
|
|
224
|
-
cap: kioskOwnerCaps[0],
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Purchase the item and resolve the rules.
|
|
228
|
-
await kioskTx.purchaseAndResolve({
|
|
229
|
-
itemType: item.type,
|
|
230
|
-
itemId: item.objectId,
|
|
231
|
-
price: item.listing.price,
|
|
232
|
-
sellerKiosk: item.kioskId,
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
kioskTx.finalize();
|
|
236
|
-
};
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
## Attach rules to transfer policy
|
|
240
|
-
|
|
241
|
-
The following example was taken from the original Kiosk SDK V1 documentation.
|
|
242
|
-
|
|
243
|
-
### Before
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
|
|
247
|
-
attachKioskLockRule,
|
|
248
|
-
attachRoyaltyRule,
|
|
249
|
-
createTransferPolicy,
|
|
250
|
-
percentageToBasisPoints,
|
|
251
|
-
testnetEnvironment,
|
|
252
|
-
} from '@mysten/kiosk';
|
|
253
|
-
|
|
254
|
-
// Attaches a royalty rule of 1% or 0.1 SUI (whichever is bigger)
|
|
255
|
-
// as well as a kiosk lock, making the objects tradeable only from/to a kiosk.
|
|
256
|
-
const attachStrongRoyalties = async () => {
|
|
257
|
-
const type = 'SomePackageId::type::MyType'; // the Type for which we're attaching rules.
|
|
258
|
-
const policyId = 'policyObjectId'; // the transfer Policy ID that was created for that Type.
|
|
259
|
-
const transferPolicyCap = 'transferPolicyCapId'; // the transferPolicyCap for that policy.
|
|
260
|
-
|
|
261
|
-
// Royalties configuration.
|
|
262
|
-
const percentage = 2.55; // 2.55%
|
|
263
|
-
const minAmount = 100_000_000; // 0.1 SUI.
|
|
264
|
-
|
|
265
|
-
// The environment on which we're referencing the rules package.
|
|
266
|
-
// Use `mainnetEnvironment` for mainnet.
|
|
267
|
-
const environment = testnetEnvironment;
|
|
268
|
-
|
|
269
|
-
const tx = new Transaction();
|
|
270
|
-
|
|
271
|
-
attachKioskLockRule(tx, type, policyId, policyCapId, environment);
|
|
272
|
-
attachRoyaltyRule(
|
|
273
|
-
tx,
|
|
274
|
-
type,
|
|
275
|
-
policyId,
|
|
276
|
-
policyCapId,
|
|
277
|
-
percentageToBasisPoints(percentage),
|
|
278
|
-
minAmount,
|
|
279
|
-
environment,
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
// ... continue to sign and execute the transaction
|
|
283
|
-
// ...
|
|
284
|
-
};
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### After
|
|
288
|
-
|
|
289
|
-
On the new SDK, the same transaction can be built as follows:
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
// You need to do this only once and re-use it in the application.
|
|
293
|
-
const client = new SuiJsonRpcClient({
|
|
294
|
-
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
295
|
-
network: 'mainnet',
|
|
296
|
-
}).$extend(kiosk());
|
|
297
|
-
|
|
298
|
-
const adjustPolicy = async () => {
|
|
299
|
-
const tx = new Transaction();
|
|
300
|
-
|
|
301
|
-
// You could have more than one cap, since you can create more than one transfer policy.
|
|
302
|
-
const policyCaps = await client.kiosk.getOwnedTransferPoliciesByType({
|
|
303
|
-
type: `SomePackageId::type::MyType`,
|
|
304
|
-
address: '0xOwnerAddress',
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
new TransferPolicyTransaction({ transaction: tx, kioskClient: client.kiosk, cap: policyCaps[0] })
|
|
308
|
-
.addRoyaltyRule(percentageToBasisPoints(2.55), 100_000_000)
|
|
309
|
-
.addLockRule();
|
|
310
|
-
|
|
311
|
-
// ... continue to sign and execute the transaction
|
|
312
|
-
// ...
|
|
313
|
-
};
|
|
314
|
-
```
|
package/docs/index.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Kiosk SDK
|
|
2
|
-
|
|
3
|
-
> TypeScript SDK for interacting with Sui Kiosk onchain commerce.
|
|
4
|
-
|
|
5
|
-
Kiosk SDK is a tool to interact with Sui and Mysten Kiosk. You can use it to query kiosk related
|
|
6
|
-
data, build transactions to interact, and extend Kiosk to support custom rules.
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
```sh npm2yarn
|
|
11
|
-
npm i @mysten/kiosk
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## About
|
|
15
|
-
|
|
16
|
-
The Kiosk SDK exports a client extension that integrates with Sui clients. Add it to your client
|
|
17
|
-
using `$extend(kiosk())` to access kiosk functionality through `client.kiosk`.
|
|
18
|
-
|
|
19
|
-
> The Kiosk SDK requires `SuiJsonRpcClient` or `SuiGraphQLClient`. It does not work with
|
|
20
|
-
> `SuiGrpcClient` because it uses event queries that are not available in gRPC.
|
|
21
|
-
|
|
22
|
-
- [Read more about setting up the Kiosk client extension](/kiosk/kiosk-client/introduction)
|