@mysten/sui 2.31.2 → 2.31.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.
@@ -1,12 +1,12 @@
1
1
  import { EnumInputShape } from "@mysten/bcs";
2
- import * as valibot1369 from "valibot";
2
+ import * as valibot0 from "valibot";
3
3
  import { GenericSchema, InferOutput } from "valibot";
4
4
 
5
5
  //#region src/transactions/data/v2.d.ts
6
- declare const SerializedTransactionDataV2Schema: valibot1369.ObjectSchema<{
7
- readonly version: valibot1369.LiteralSchema<2, undefined>;
8
- readonly sender: valibot1369.NullishSchema<valibot1369.SchemaWithPipe<readonly [valibot1369.StringSchema<undefined>, valibot1369.TransformAction<string, string>, valibot1369.CheckAction<string, undefined>]>, undefined>;
9
- readonly expiration: valibot1369.NullishSchema<GenericSchema<EnumInputShape<{
6
+ declare const SerializedTransactionDataV2Schema: valibot0.ObjectSchema<{
7
+ readonly version: valibot0.LiteralSchema<2, undefined>;
8
+ readonly sender: valibot0.NullishSchema<valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<undefined>, valibot0.TransformAction<string, string>, valibot0.CheckAction<string, undefined>]>, undefined>;
9
+ readonly expiration: valibot0.NullishSchema<GenericSchema<EnumInputShape<{
10
10
  None: true;
11
11
  Epoch: string | number;
12
12
  ValidDuring: {
@@ -30,17 +30,17 @@ declare const SerializedTransactionDataV2Schema: valibot1369.ObjectSchema<{
30
30
  nonce: number;
31
31
  };
32
32
  }>>, undefined>;
33
- readonly gasData: valibot1369.ObjectSchema<{
34
- readonly budget: valibot1369.NullableSchema<valibot1369.SchemaWithPipe<readonly [valibot1369.UnionSchema<[valibot1369.StringSchema<undefined>, valibot1369.SchemaWithPipe<readonly [valibot1369.NumberSchema<undefined>, valibot1369.IntegerAction<number, undefined>]>], undefined>, valibot1369.CheckAction<string | number, "Invalid u64">]>, undefined>;
35
- readonly price: valibot1369.NullableSchema<valibot1369.SchemaWithPipe<readonly [valibot1369.UnionSchema<[valibot1369.StringSchema<undefined>, valibot1369.SchemaWithPipe<readonly [valibot1369.NumberSchema<undefined>, valibot1369.IntegerAction<number, undefined>]>], undefined>, valibot1369.CheckAction<string | number, "Invalid u64">]>, undefined>;
36
- readonly owner: valibot1369.NullableSchema<valibot1369.SchemaWithPipe<readonly [valibot1369.StringSchema<undefined>, valibot1369.TransformAction<string, string>, valibot1369.CheckAction<string, undefined>]>, undefined>;
37
- readonly payment: valibot1369.NullableSchema<valibot1369.ArraySchema<valibot1369.ObjectSchema<{
38
- readonly objectId: valibot1369.SchemaWithPipe<readonly [valibot1369.StringSchema<undefined>, valibot1369.TransformAction<string, string>, valibot1369.CheckAction<string, undefined>]>;
39
- readonly version: valibot1369.SchemaWithPipe<readonly [valibot1369.UnionSchema<[valibot1369.StringSchema<undefined>, valibot1369.SchemaWithPipe<readonly [valibot1369.NumberSchema<undefined>, valibot1369.IntegerAction<number, undefined>]>], undefined>, valibot1369.CheckAction<string | number, "Invalid u64">]>;
40
- readonly digest: valibot1369.StringSchema<undefined>;
33
+ readonly gasData: valibot0.ObjectSchema<{
34
+ readonly budget: valibot0.NullableSchema<valibot0.SchemaWithPipe<readonly [valibot0.UnionSchema<[valibot0.StringSchema<undefined>, valibot0.SchemaWithPipe<readonly [valibot0.NumberSchema<undefined>, valibot0.IntegerAction<number, undefined>]>], undefined>, valibot0.CheckAction<string | number, "Invalid u64">]>, undefined>;
35
+ readonly price: valibot0.NullableSchema<valibot0.SchemaWithPipe<readonly [valibot0.UnionSchema<[valibot0.StringSchema<undefined>, valibot0.SchemaWithPipe<readonly [valibot0.NumberSchema<undefined>, valibot0.IntegerAction<number, undefined>]>], undefined>, valibot0.CheckAction<string | number, "Invalid u64">]>, undefined>;
36
+ readonly owner: valibot0.NullableSchema<valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<undefined>, valibot0.TransformAction<string, string>, valibot0.CheckAction<string, undefined>]>, undefined>;
37
+ readonly payment: valibot0.NullableSchema<valibot0.ArraySchema<valibot0.ObjectSchema<{
38
+ readonly objectId: valibot0.SchemaWithPipe<readonly [valibot0.StringSchema<undefined>, valibot0.TransformAction<string, string>, valibot0.CheckAction<string, undefined>]>;
39
+ readonly version: valibot0.SchemaWithPipe<readonly [valibot0.UnionSchema<[valibot0.StringSchema<undefined>, valibot0.SchemaWithPipe<readonly [valibot0.NumberSchema<undefined>, valibot0.IntegerAction<number, undefined>]>], undefined>, valibot0.CheckAction<string | number, "Invalid u64">]>;
40
+ readonly digest: valibot0.StringSchema<undefined>;
41
41
  }, undefined>, undefined>, undefined>;
42
42
  }, undefined>;
43
- readonly inputs: valibot1369.ArraySchema<GenericSchema<EnumInputShape<{
43
+ readonly inputs: valibot0.ArraySchema<GenericSchema<EnumInputShape<{
44
44
  Object: EnumInputShape<{
45
45
  ImmOrOwnedObject: {
46
46
  objectId: string;
@@ -90,7 +90,7 @@ declare const SerializedTransactionDataV2Schema: valibot1369.ObjectSchema<{
90
90
  };
91
91
  };
92
92
  }>>, undefined>;
93
- readonly commands: valibot1369.ArraySchema<GenericSchema<EnumInputShape<{
93
+ readonly commands: valibot0.ArraySchema<GenericSchema<EnumInputShape<{
94
94
  MoveCall: {
95
95
  package: string;
96
96
  module: string;
@@ -189,7 +189,7 @@ declare const SerializedTransactionDataV2Schema: valibot1369.ObjectSchema<{
189
189
  };
190
190
  };
191
191
  }>>, undefined>;
192
- readonly digest: valibot1369.OptionalSchema<valibot1369.NullableSchema<valibot1369.StringSchema<undefined>, undefined>, undefined>;
192
+ readonly digest: valibot0.OptionalSchema<valibot0.NullableSchema<valibot0.StringSchema<undefined>, undefined>, undefined>;
193
193
  }, undefined>;
194
194
  type SerializedTransactionDataV2 = InferOutput<typeof SerializedTransactionDataV2Schema>;
195
195
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"v2.d.mts","names":[],"sources":["../../../src/transactions/data/v2.ts"],"mappings":";;;;;cAqJa,iCAAA,cAAiC,YAAA;EAAA,kBAQ5C,WAAA,CAAA,aAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEU,2BAAA,GAA8B,WAAA,QAAmB,iCAAA"}
1
+ {"version":3,"file":"v2.d.mts","names":[],"sources":["../../../src/transactions/data/v2.ts"],"mappings":";;;;;cAqJa,iCAAA,WAAiC,YAAA;EAAA,kBAQ5C,QAAA,CAAA,aAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEU,2BAAA,GAA8B,WAAA,QAAmB,iCAAA"}
package/dist/version.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.31.2";
2
+ const PACKAGE_VERSION = "2.31.3";
3
3
 
4
4
  //#endregion
5
5
  export { PACKAGE_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.31.2';\n"],"mappings":";AAKA,MAAa,kBAAkB"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.31.3';\n"],"mappings":";AAKA,MAAa,kBAAkB"}
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs1384 from "@mysten/bcs";
1
+ import * as _mysten_bcs1248 from "@mysten/bcs";
2
2
  import { InferBcsInput } from "@mysten/bcs";
3
3
 
4
4
  //#region src/zklogin/bcs.d.ts
5
- declare const zkLoginSignature: _mysten_bcs1384.BcsStruct<{
6
- inputs: _mysten_bcs1384.BcsStruct<{
7
- proofPoints: _mysten_bcs1384.BcsStruct<{
8
- a: _mysten_bcs1384.BcsType<string[], Iterable<string> & {
5
+ declare const zkLoginSignature: _mysten_bcs1248.BcsStruct<{
6
+ inputs: _mysten_bcs1248.BcsStruct<{
7
+ proofPoints: _mysten_bcs1248.BcsStruct<{
8
+ a: _mysten_bcs1248.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs1384.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs1248.BcsType<string[][], Iterable<Iterable<string> & {
12
12
  length: number;
13
13
  }> & {
14
14
  length: number;
15
15
  }, string>;
16
- c: _mysten_bcs1384.BcsType<string[], Iterable<string> & {
16
+ c: _mysten_bcs1248.BcsType<string[], Iterable<string> & {
17
17
  length: number;
18
18
  }, string>;
19
19
  }, string>;
20
- issBase64Details: _mysten_bcs1384.BcsStruct<{
21
- value: _mysten_bcs1384.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs1384.BcsType<number, number, "u8">;
20
+ issBase64Details: _mysten_bcs1248.BcsStruct<{
21
+ value: _mysten_bcs1248.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs1248.BcsType<number, number, "u8">;
23
23
  }, string>;
24
- headerBase64: _mysten_bcs1384.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs1384.BcsType<string, string, "string">;
24
+ headerBase64: _mysten_bcs1248.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs1248.BcsType<string, string, "string">;
26
26
  }, string>;
27
- maxEpoch: _mysten_bcs1384.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs1384.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
27
+ maxEpoch: _mysten_bcs1248.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs1248.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "2.31.2",
6
+ "version": "2.31.3",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -22,6 +22,7 @@ import {
22
22
  tuple,
23
23
  union,
24
24
  unknown,
25
+ variant,
25
26
  } from 'valibot';
26
27
 
27
28
  import { isValidSuiAddress, normalizeSuiAddress } from '../../utils/sui-types.js';
@@ -46,17 +47,49 @@ type EnumSchema<T extends Record<string, GenericSchema<any>>> = GenericSchema<
46
47
  >;
47
48
 
48
49
  export function safeEnum<T extends Record<string, GenericSchema<any>>>(options: T): EnumSchema<T> {
49
- return union(
50
- Object.keys(options).map(
51
- (key) =>
52
- withKind(
53
- key,
54
- object({
55
- [key]: options[key],
56
- }),
57
- ) as GenericSchema<EnumOutputShape<T>>,
50
+ const schemas = Object.keys(options).map((key) =>
51
+ object({
52
+ [key]: options[key],
53
+ $kind: literal(key),
54
+ }),
55
+ );
56
+
57
+ return pipe(
58
+ unknown(),
59
+ check(
60
+ (input) => unsupportedEnumVariantMessage(input, options) === undefined,
61
+ ({ input, message }) => unsupportedEnumVariantMessage(input, options) ?? message,
58
62
  ),
59
- ) as EnumSchema<T>;
63
+ transform(addMissingEnumKind),
64
+ variant('$kind', schemas),
65
+ ) as unknown as EnumSchema<T>;
66
+ }
67
+
68
+ function getEnumKind(input: unknown) {
69
+ if (typeof input !== 'object' || input === null) return null;
70
+ if ('$kind' in input && typeof input.$kind === 'string') return input.$kind;
71
+
72
+ return Object.keys(input).find((key) => key !== '$kind') ?? null;
73
+ }
74
+
75
+ function addMissingEnumKind(input: unknown) {
76
+ if (typeof input !== 'object' || input === null || '$kind' in input) return input;
77
+
78
+ const kind = getEnumKind(input);
79
+ return kind === null ? input : { ...input, $kind: kind };
80
+ }
81
+
82
+ function unsupportedEnumVariantMessage(
83
+ input: unknown,
84
+ options: Record<string, GenericSchema<any>>,
85
+ ) {
86
+ const kind = getEnumKind(input);
87
+ if (kind === null || Object.hasOwn(options, kind)) return undefined;
88
+
89
+ const expected = Object.keys(options)
90
+ .map((key) => `"${key}"`)
91
+ .join(', ');
92
+ return `Unsupported enum variant "${kind}". Expected one of: ${expected}.`;
60
93
  }
61
94
 
62
95
  function withKind<K extends string, TEntries extends ObjectEntries>(
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.31.2';
6
+ export const PACKAGE_VERSION = '2.31.3';