@mysten/kiosk 1.2.2 → 1.2.4

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # @mysten/kiosk
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - bb8d26a: Fix three latent type errors in the generated `utils/index.ts` that surfaced for
8
+ consumers with `noUncheckedIndexedAccess: true`:
9
+ - `getPureBcsSchema(structTag.typeParams[0])` passed `TypeTag | undefined` to a parameter typed
10
+ `string | TypeTag`. Now null-checks the inner tag before passing it.
11
+ - `argTypes[i]` was redundantly re-indexed inside a `for…of entries()` loop, returning
12
+ `string | null | undefined` and being passed back to `getPureBcsSchema`. Switched to the loop
13
+ variable, which is `string | null`.
14
+ - `MoveStruct.get()` returned the destructured `[res]` from `getMany([objectId])` without
15
+ asserting it was defined. Now throws if no object was returned.
16
+
17
+ The codegen test suite gained a `tsc`-based check that compiles the generated `utils/index.ts`
18
+ under strict + `noUncheckedIndexedAccess`, so embedded-template type bugs are caught before
19
+ release rather than by downstream consumers.
20
+
21
+ All consumer packages (`payment-kit`, `pas`, `walrus`, `suins`, `deepbook-v3`, `kiosk`) have been
22
+ regenerated with the fix.
23
+
24
+ ## 1.2.3
25
+
26
+ ### Patch Changes
27
+
28
+ - c96956e: Regenerate generated Move types against the latest contract sources. The generated
29
+ `utils/index.ts` `GetOptions` / `GetManyOptions` are now exported as type aliases (intersection)
30
+ instead of interfaces. SuiNS gains `SubnamePrunedEvent`, `pruneExpiredSubname`, and
31
+ `pruneExpiredSubnames`.
32
+
3
33
  ## 1.2.2
4
34
 
5
35
  ### 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 type = getPureBcsSchema(structTag.typeParams[0]);
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 [i, argType] of argTypes.entries()) {
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 type = argTypes[i];
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 ${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 interface GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport interface GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectsOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\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 type = getPureBcsSchema(structTag.typeParams[0]);\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 [i, argType] of argTypes.entries()) {\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 type = argTypes[i];\n\t\tconst bcsType = type === null ? null : getPureBcsSchema(type);\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 ${type}`);\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\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":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAMA,0BAAwB,oBAAoB,MAAM;AAgBxD,SAAgB,iBAAiB,SAAgD;CAChF,MAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,QAAQ,GAAG;AAE1F,KAAI,QAAQ,UACX,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,aAAa,UACvB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,YAAY,WAAW;EACjC,MAAM,OAAO,iBAAiB,UAAU,OAAO;AAC/C,SAAO,OAAO,IAAI,OAAO,KAAK,GAAG;YACvB,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"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":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAMA,0BAAwB,oBAAoB,MAAM;AAUxD,SAAgB,iBAAiB,SAAgD;CAChF,MAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,QAAQ,GAAG;AAE1F,KAAI,QAAQ,UACX,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO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H,MAAM,KAAK,MAAM,IAAI,QAAQ;IAC7B;IACA;;;AAcJ,SAAS,UAAU,KAAc;AAChC,KAAI,OAAO,QAAQ,SAClB,QAAO,KAAK,UAAU,MAAM,UAAiBC,MAAI;AAElD,KAAI,OAAO,QAAQ,SAClB,QAAO,IAAI,UAAU;AAGtB,QAAO"}
@@ -1,6 +1,6 @@
1
1
  # Advanced Examples
2
2
 
3
- > Advanced Kiosk SDK usage patterns and examples
3
+ > Advanced Kiosk SDK usage patterns and code examples for complex scenarios.
4
4
 
5
5
  # Some extended examples
6
6
 
package/docs/from-v1.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Migrating from Kiosk SDK V1
2
2
 
3
- > Migrate from Kiosk SDK v1 to the current version
3
+ > Migrate from Kiosk SDK v1 to the current version with the builder-pattern API.
4
4
 
5
5
  The original version of Kiosk SDK provided basic experimentation with the Kiosk API. The new version
6
6
  of the SDK (0.7+) provides a more robust experience for building kiosk/transfer policy transactions.
package/docs/index.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Kiosk SDK
2
2
 
3
- > TypeScript SDK for interacting with Sui Kiosk on-chain commerce
3
+ > TypeScript SDK for interacting with Sui Kiosk onchain commerce.
4
4
 
5
- Kiosk SDK is a tool to interact with Sui/Mysten Kiosk. You can use it to query kiosk related data,
6
- build transactions to interact, and extend Kiosk to support custom rules.
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
7
 
8
8
  ## Installation
9
9
 
@@ -14,9 +14,9 @@ npm i @mysten/kiosk
14
14
  ## About
15
15
 
16
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 via `client.kiosk`.
17
+ using `$extend(kiosk())` to access kiosk functionality through `client.kiosk`.
18
18
 
19
- > **Note:** The Kiosk SDK requires `SuiJsonRpcClient` or `SuiGraphQLClient`. It does not work with
19
+ > The Kiosk SDK requires `SuiJsonRpcClient` or `SuiGraphQLClient`. It does not work with
20
20
  > `SuiGrpcClient` because it uses event queries that are not available in gRPC.
21
21
 
22
22
  - [Read more about setting up the Kiosk client extension](/kiosk/kiosk-client/introduction)
@@ -1,13 +1,13 @@
1
1
  # Kiosk Client
2
2
 
3
- > Introduction to the KioskClient for querying and managing kiosks
3
+ > Introduction to the KioskClient extension for querying and managing kiosks on Sui.
4
4
 
5
5
  The Kiosk SDK exports a client extension that provides all Kiosk functionality.
6
6
 
7
- > We recommend you keep only one client instance throughout your dApp or script. For example, in
7
+ > We recommend you keep only one client instance throughout your app or script. For example, in
8
8
  > React, you'd use a context to provide the client.
9
9
 
10
- > **Note:** The Kiosk SDK requires `SuiJsonRpcClient` or `SuiGraphQLClient`. It does not work with
10
+ > The Kiosk SDK requires `SuiJsonRpcClient` or `SuiGraphQLClient`. It does not work with
11
11
  > `SuiGrpcClient` because it uses event queries that are not available in gRPC.
12
12
 
13
13
  ## Setting up the kiosk extension
@@ -15,8 +15,8 @@ The Kiosk SDK exports a client extension that provides all Kiosk functionality.
15
15
  Add the kiosk extension to your Sui client using `$extend()`. The extension currently supports
16
16
  `mainnet` and `testnet`. See the next section for usage on other networks.
17
17
 
18
- _Mysten Kiosk rules and extensions are not supported in Devnet due to network wipes (that would
19
- require constantly changing the package IDs)._
18
+ Mysten Kiosk rules and extensions are not supported in Devnet due to network wipes (that would
19
+ require constantly changing the package IDs).
20
20
 
21
21
  ```typescript
22
22
  const client = new SuiJsonRpcClient({
@@ -28,7 +28,7 @@ const client = new SuiJsonRpcClient({
28
28
  const { kioskOwnerCaps } = await client.kiosk.getOwnedKiosks({ address: '0x...' });
29
29
  ```
30
30
 
31
- ### Using the kiosk extension on devnet or localnet
31
+ ### Using the kiosk extension on Devnet or Localnet
32
32
 
33
33
  To use all the functionality of Kiosk SDK outside of `mainnet` and `testnet`, pass the `packageIds`
34
34
  for the rules and extensions you want to use.
@@ -1,12 +1,12 @@
1
1
  # Examples
2
2
 
3
- > Kiosk transaction code examples
3
+ > Practical code examples for kiosk transactions including minting, listing, and purchasing.
4
4
 
5
- The following dApp-focused examples demonstrate how to use the SDK to interact with Kiosk.
5
+ The following app-focused examples demonstrate how to use the SDK to interact with Kiosk.
6
6
 
7
7
  ## Minting into Kiosk example
8
8
 
9
- For every scenario using Kiosk in dApps, the user who has connected their wallet either has at least
9
+ For every scenario using Kiosk in apps, the user who has connected their wallet either has at least
10
10
  one kiosk already or you must create it for them.
11
11
 
12
12
  The SDK supports the scenario of `silently` creating the kiosk, as part of our Programmable
@@ -1,6 +1,6 @@
1
1
  # KioskTransaction
2
2
 
3
- > Build kiosk transactions for listing, purchasing, and managing items
3
+ > Build kiosk transactions for listing, purchasing, and managing items on Sui.
4
4
 
5
5
  `KioskTransaction` is the client to build transactions that involve Kiosk. It's used similar to
6
6
  `Transaction`, and helps in building a transaction.
@@ -1,6 +1,6 @@
1
1
  # Managing Owned Kiosk
2
2
 
3
- > Manage kiosk items: place, list, delist, and withdraw
3
+ > Manage kiosk items by placing, listing, delisting, and withdrawing using the Kiosk SDK.
4
4
 
5
5
  The kiosk extension (`client.kiosk`) helps in managing a kiosk.
6
6
 
@@ -9,7 +9,7 @@ create a `KioskTransaction`.
9
9
 
10
10
  ## Available functions
11
11
 
12
- ### take
12
+ ### `take`
13
13
 
14
14
  Removes an item from the Kiosk and returns a `TransactionArgument` to use it in a different
15
15
  Programmable Transaction Block (PTB) call.
@@ -37,7 +37,7 @@ kioskTx.finalize();
37
37
  await signAndExecuteTransaction({ tx: tx });
38
38
  ```
39
39
 
40
- ### transfer
40
+ ### `transfer`
41
41
 
42
42
  Similar to `take`, but transfers the item to an address internally.
43
43
 
@@ -61,7 +61,7 @@ kioskTx
61
61
  await signAndExecuteTransaction({ tx: tx });
62
62
  ```
63
63
 
64
- ### place
64
+ ### `place`
65
65
 
66
66
  Places an item in the kiosk.
67
67
 
@@ -83,7 +83,7 @@ kioskTx
83
83
  await signAndExecuteTransaction({ tx: tx });
84
84
  ```
85
85
 
86
- ### list
86
+ ### `list`
87
87
 
88
88
  Lists an item for sale (the item must be in the kiosk).
89
89
 
@@ -106,7 +106,7 @@ kioskTx
106
106
  await signAndExecuteTransaction({ tx: tx });
107
107
  ```
108
108
 
109
- ### placeAndList
109
+ ### `placeAndList`
110
110
 
111
111
  List an item for sale by first placing it in the kiosk (places the item and lists it for sale). It's
112
112
  a short hand for `place()` and `list()`.
@@ -130,7 +130,7 @@ kioskTx
130
130
  await signAndExecuteTransaction({ tx: tx });
131
131
  ```
132
132
 
133
- ### delist
133
+ ### `delist`
134
134
 
135
135
  Removes the listing, keeping the item placed in the kiosk.
136
136
 
@@ -152,7 +152,7 @@ kioskTx
152
152
  await signAndExecuteTransaction({ tx: tx });
153
153
  ```
154
154
 
155
- ### withdraw
155
+ ### `withdraw`
156
156
 
157
157
  Withdraw (all or specific amount) from a kiosk.
158
158
 
@@ -168,7 +168,7 @@ kioskTx.withdraw('address_to_transfer_funds', 100000n).finalize();
168
168
  await signAndExecuteTransaction({ tx: tx });
169
169
  ```
170
170
 
171
- ### borrowTx (callback)
171
+ ### `borrowTx` (callback)
172
172
 
173
173
  Borrows an item from a kiosk. This function follows the `callback` approach, similar to the
174
174
  ownerCap. The return of the item happens automatically after the execution of the callback.
@@ -199,10 +199,10 @@ kioskTx
199
199
  await signAndExecuteTransaction({ tx: tx });
200
200
  ```
201
201
 
202
- ### borrow / return
202
+ ### `borrow` / `return`
203
203
 
204
204
  Similar to `borrowTx`, borrows an item from the kiosk, but returns two transaction arguments: `item`
205
- & `promise`. You can use the `item` in your PTBs, but you must always call the `return()` function
205
+ and `promise`. You can use the `item` in your PTBs, but you must always call the `return()` function
206
206
  with the `item` and the `Promise`.
207
207
 
208
208
  ```typescript
@@ -1,6 +1,6 @@
1
1
  # Purchasing from a kiosk
2
2
 
3
- > Purchase items from kiosks with transfer policy resolution
3
+ > Purchase items from kiosks with automatic transfer policy rule resolution.
4
4
 
5
5
  One of the base functionalities of the SDK is a seamless purchasing flow, allowing for ease of rules
6
6
  resolving (hiding away the calls). The SDK supports all four rules by default, and works for
@@ -1,6 +1,6 @@
1
1
  # Querying
2
2
 
3
- > Query kiosk contents, items, and transfer policies
3
+ > Query kiosk contents, owned kiosks, items, and transfer policies using the Kiosk SDK.
4
4
 
5
5
  You can use `client.kiosk` to query kiosk data. It helps you get owned kiosks for an address, as
6
6
  well as fetching all the contents of a specified kiosk.
@@ -1,6 +1,6 @@
1
1
  # TransferPolicyTransaction
2
2
 
3
- > Create and manage transfer policies for kiosk items
3
+ > Create and manage transfer policies for kiosk items using the Kiosk SDK.
4
4
 
5
5
  `TransferPolicyTransaction` is the client to build transactions that involve transfer policy
6
6
  management. It's used similar to `KioskTransaction`, and helps in crafting transactions to manage a
@@ -1,8 +1,6 @@
1
1
  # Using the manager
2
2
 
3
- > Use the TransferPolicyTransaction manager for policy rules
4
-
5
- # How to use
3
+ > Use the TransferPolicyTransaction manager to add rules and withdraw profits.
6
4
 
7
5
  After following the introduction steps on how to initialize a transfer policy transaction you can
8
6
  call any of the available functions to prepare your Programmable Transaction Block (PTB).
@@ -2,9 +2,12 @@
2
2
 
3
3
  > Interact with on-chain commerce applications
4
4
 
5
- - [Kiosk SDK](..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
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.
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.2",
5
+ "version": "1.2.4",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
8
  "main": "./dist/index.mjs",
@@ -43,7 +43,7 @@
43
43
  "vite": "^8.0.5",
44
44
  "vitest": "^4.0.17",
45
45
  "wait-on": "^9.0.3",
46
- "@mysten/codegen": "^0.9.0",
46
+ "@mysten/codegen": "^0.10.3",
47
47
  "@mysten/sui": "^2.16.0"
48
48
  },
49
49
  "peerDependencies": {
@@ -16,17 +16,11 @@ const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');
16
16
 
17
17
  export type RawTransactionArgument<T> = T | TransactionArgument;
18
18
 
19
- export interface GetOptions<
20
- Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},
21
- > extends SuiClientTypes.GetObjectOptions<Include> {
22
- client: ClientWithCoreApi;
23
- }
19
+ export type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =
20
+ SuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };
24
21
 
25
- export interface GetManyOptions<
26
- Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},
27
- > extends SuiClientTypes.GetObjectsOptions<Include> {
28
- client: ClientWithCoreApi;
29
- }
22
+ export type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =
23
+ SuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };
30
24
 
31
25
  export function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {
32
26
  const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
@@ -63,7 +57,8 @@ export function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null
63
57
  }
64
58
 
65
59
  if (structTag.module === 'option' && structTag.name === 'Option') {
66
- const type = getPureBcsSchema(structTag.typeParams[0]);
60
+ const inner = structTag.typeParams[0];
61
+ const type = inner ? getPureBcsSchema(inner) : null;
67
62
  return type ? bcs.option(type) : null;
68
63
  }
69
64
  }
@@ -95,7 +90,7 @@ export function normalizeMoveArguments(
95
90
  const normalizedArgs: TransactionArgument[] = [];
96
91
 
97
92
  let index = 0;
98
- for (const [i, argType] of argTypes.entries()) {
93
+ for (const argType of argTypes) {
99
94
  if (argType === '0x2::clock::Clock') {
100
95
  normalizedArgs.push((tx) => tx.object.clock());
101
96
  continue;
@@ -143,8 +138,7 @@ export function normalizeMoveArguments(
143
138
  continue;
144
139
  }
145
140
 
146
- const type = argTypes[i];
147
- const bcsType = type === null ? null : getPureBcsSchema(type);
141
+ const bcsType = argType === null ? null : getPureBcsSchema(argType);
148
142
 
149
143
  if (bcsType) {
150
144
  const bytes = bcsType.serialize(arg as never);
@@ -157,7 +151,7 @@ export function normalizeMoveArguments(
157
151
  continue;
158
152
  }
159
153
 
160
- throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
154
+ throw new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);
161
155
  }
162
156
 
163
157
  return normalizedArgs;
@@ -180,6 +174,10 @@ export class MoveStruct<
180
174
  objectIds: [objectId],
181
175
  });
182
176
 
177
+ if (!res) {
178
+ throw new Error(`No object found for id ${objectId}`);
179
+ }
180
+
183
181
  return res;
184
182
  }
185
183