@mysten/sui 2.31.1 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/client/mvr.mjs +2 -1
  4. package/dist/client/mvr.mjs.map +1 -1
  5. package/dist/cryptography/signature.d.mts +6 -6
  6. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  7. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  8. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  9. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  10. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  11. package/dist/jsonRpc/client.mjs +1 -1
  12. package/dist/transactions/Transaction.d.mts +6 -6
  13. package/dist/transactions/data/internal.d.mts.map +1 -1
  14. package/dist/transactions/data/internal.mjs +24 -2
  15. package/dist/transactions/data/internal.mjs.map +1 -1
  16. package/dist/utils/index.d.mts +2 -1
  17. package/dist/utils/index.mjs +2 -1
  18. package/dist/utils/move-registry.d.mts +3 -2
  19. package/dist/utils/move-registry.d.mts.map +1 -1
  20. package/dist/utils/move-registry.mjs +2 -18
  21. package/dist/utils/move-registry.mjs.map +1 -1
  22. package/dist/utils/named-packages.d.mts +5 -0
  23. package/dist/utils/named-packages.d.mts.map +1 -0
  24. package/dist/utils/named-packages.mjs +23 -0
  25. package/dist/utils/named-packages.mjs.map +1 -0
  26. package/dist/utils/sui-types.mjs +1 -1
  27. package/dist/utils/sui-types.mjs.map +1 -1
  28. package/dist/version.mjs +1 -1
  29. package/dist/version.mjs.map +1 -1
  30. package/dist/zklogin/bcs.d.mts +14 -14
  31. package/package.json +1 -1
  32. package/src/transactions/data/internal.ts +43 -10
  33. package/src/utils/move-registry.ts +2 -25
  34. package/src/utils/named-packages.ts +29 -0
  35. package/src/utils/sui-types.ts +1 -1
  36. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mysten/sui.js
2
2
 
3
+ ## 2.31.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 59dedfe: Report unsupported enum variants and their expected values when parsing transaction data.
8
+
9
+ ## 2.31.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 8508156: Break the circular dependency between struct-tag and named-package utilities to prevent
14
+ initialization errors in Next.js Turbopack production builds.
15
+
3
16
  ## 2.31.1
4
17
 
5
18
  ### Patch Changes
@@ -1,21 +1,21 @@
1
1
  import { TypeTag as TypeTag$1 } from "./types.mjs";
2
- import * as _mysten_bcs1254 from "@mysten/bcs";
2
+ import * as _mysten_bcs1261 from "@mysten/bcs";
3
3
  import { BcsType } from "@mysten/bcs";
4
4
 
5
5
  //#region src/bcs/bcs.d.ts
6
6
  declare const TypeTag: BcsType<string, string | TypeTag$1, string>;
7
- declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs1254.BcsStruct<{
8
- intent: _mysten_bcs1254.BcsStruct<{
9
- scope: _mysten_bcs1254.BcsEnum<{
7
+ declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs1261.BcsStruct<{
8
+ intent: _mysten_bcs1261.BcsStruct<{
9
+ scope: _mysten_bcs1261.BcsEnum<{
10
10
  TransactionData: null;
11
11
  TransactionEffects: null;
12
12
  CheckpointSummary: null;
13
13
  PersonalMessage: null;
14
14
  }, "IntentScope">;
15
- version: _mysten_bcs1254.BcsEnum<{
15
+ version: _mysten_bcs1261.BcsEnum<{
16
16
  V0: null;
17
17
  }, "IntentVersion">;
18
- appId: _mysten_bcs1254.BcsEnum<{
18
+ appId: _mysten_bcs1261.BcsEnum<{
19
19
  Sui: null;
20
20
  }, "AppId">;
21
21
  }, string>;
@@ -1,5 +1,6 @@
1
- import { isValidNamedPackage, isValidNamedType } from "../utils/move-registry.mjs";
1
+ import { isValidNamedPackage } from "../utils/named-packages.mjs";
2
2
  import { isValidSuiAddress, normalizeStructTag, normalizeSuiAddress, parseStructTag } from "../utils/sui-types.mjs";
3
+ import { isValidNamedType } from "../utils/move-registry.mjs";
3
4
  import { PACKAGE_VERSION } from "../version.mjs";
4
5
  import { DataLoader, chunk } from "@mysten/utils";
5
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"mvr.mjs","names":["#cache","#url","#pageSize","#overrides","#mvrPackageDataLoader","#resolvePackages","#mvrTypeDataLoader","#resolveTypes","#fetch"],"sources":["../../src/client/mvr.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { chunk, DataLoader } from '@mysten/utils';\nimport { isValidNamedPackage, isValidNamedType } from '../utils/move-registry.js';\nimport type { StructTag } from '../utils/sui-types.js';\nimport {\n\tisValidSuiAddress,\n\tnormalizeStructTag,\n\tnormalizeSuiAddress,\n\tparseStructTag,\n} from '../utils/sui-types.js';\nimport type { ClientCache } from './cache.js';\nimport type { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport { PACKAGE_VERSION } from '../version.js';\nimport type { SuiClientTypes } from './types.js';\n\nconst NAME_SEPARATOR = '/';\nconst MVR_API_HEADER = {\n\t'Mvr-Source': `@mysten/sui@${PACKAGE_VERSION}`,\n};\n\nexport interface MvrClientOptions {\n\tcache: ClientCache;\n\turl?: string;\n\tpageSize?: number;\n\toverrides?: {\n\t\tpackages?: Record<string, string>;\n\t\ttypes?: Record<string, string>;\n\t};\n}\n\nexport class MvrClient implements SuiClientTypes.MvrMethods {\n\t#cache: ClientCache;\n\t#url?: string;\n\t#pageSize: number;\n\t#overrides: {\n\t\tpackages?: Record<string, string>;\n\t\ttypes?: Record<string, string>;\n\t};\n\n\tconstructor({ cache, url, pageSize = 50, overrides }: MvrClientOptions) {\n\t\tthis.#cache = cache;\n\t\tthis.#url = url;\n\t\tthis.#pageSize = pageSize;\n\t\tthis.#overrides = {\n\t\t\tpackages: overrides?.packages,\n\t\t\ttypes: overrides?.types,\n\t\t};\n\n\t\tvalidateOverrides(this.#overrides);\n\t}\n\n\tget #mvrPackageDataLoader() {\n\t\treturn this.#cache.readSync(['#mvrPackageDataLoader', this.#url ?? ''], () => {\n\t\t\tconst loader = new DataLoader<string, string>(async (packages) => {\n\t\t\t\tif (!this.#url) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`MVR Api URL is not set for the current client (resolving ${packages.join(', ')})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst resolved = await this.#resolvePackages(packages);\n\n\t\t\t\treturn packages.map(\n\t\t\t\t\t(pkg) => resolved[pkg] ?? new Error(`Failed to resolve package: ${pkg}`),\n\t\t\t\t);\n\t\t\t});\n\t\t\tconst overrides = this.#overrides?.packages;\n\n\t\t\tif (overrides) {\n\t\t\t\tfor (const [pkg, id] of Object.entries(overrides)) {\n\t\t\t\t\tloader.prime(pkg, id);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn loader;\n\t\t});\n\t}\n\n\tget #mvrTypeDataLoader() {\n\t\treturn this.#cache.readSync(['#mvrTypeDataLoader', this.#url ?? ''], () => {\n\t\t\tconst loader = new DataLoader<string, string>(async (types) => {\n\t\t\t\tif (!this.#url) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`MVR Api URL is not set for the current client (resolving ${types.join(', ')})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst resolved = await this.#resolveTypes(types);\n\n\t\t\t\treturn types.map((type) => resolved[type] ?? new Error(`Failed to resolve type: ${type}`));\n\t\t\t});\n\n\t\t\tconst overrides = this.#overrides?.types;\n\n\t\t\tif (overrides) {\n\t\t\t\tfor (const [type, id] of Object.entries(overrides)) {\n\t\t\t\t\tloader.prime(type, id);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn loader;\n\t\t});\n\t}\n\n\tasync #resolvePackages(packages: readonly string[]) {\n\t\tif (packages.length === 0) return {};\n\n\t\tconst batches = chunk(packages, this.#pageSize);\n\t\tconst results: Record<string, string> = {};\n\n\t\tawait Promise.all(\n\t\t\tbatches.map(async (batch) => {\n\t\t\t\tconst data = await this.#fetch<{ resolution: Record<string, { package_id: string }> }>(\n\t\t\t\t\t'/v1/resolution/bulk',\n\t\t\t\t\t{\n\t\t\t\t\t\tnames: batch,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (!data?.resolution) return;\n\n\t\t\t\tfor (const pkg of Object.keys(data?.resolution)) {\n\t\t\t\t\tconst pkgData = data.resolution[pkg]?.package_id;\n\n\t\t\t\t\tif (!pkgData) continue;\n\n\t\t\t\t\tresults[pkg] = pkgData;\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\treturn results;\n\t}\n\n\tasync #resolveTypes(types: readonly string[]) {\n\t\tif (types.length === 0) return {};\n\n\t\tconst batches = chunk(types, this.#pageSize);\n\t\tconst results: Record<string, string> = {};\n\n\t\tawait Promise.all(\n\t\t\tbatches.map(async (batch) => {\n\t\t\t\tconst data = await this.#fetch<{ resolution: Record<string, { type_tag: string }> }>(\n\t\t\t\t\t'/v1/struct-definition/bulk',\n\t\t\t\t\t{\n\t\t\t\t\t\ttypes: batch,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (!data?.resolution) return;\n\n\t\t\t\tfor (const type of Object.keys(data?.resolution)) {\n\t\t\t\t\tconst typeData = data.resolution[type]?.type_tag;\n\t\t\t\t\tif (!typeData) continue;\n\n\t\t\t\t\tresults[type] = typeData;\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\treturn results;\n\t}\n\n\tasync #fetch<T>(url: string, body: Record<string, unknown>): Promise<T> {\n\t\tif (!this.#url) {\n\t\t\tthrow new Error('MVR Api URL is not set for the current client');\n\t\t}\n\n\t\tconst response = await fetch(`${this.#url}${url}`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t...MVR_API_HEADER,\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst errorBody = await response.json().catch(() => ({}));\n\t\t\tthrow new Error(`Failed to resolve types: ${errorBody?.message}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync resolvePackage({\n\t\tpackage: name,\n\t\tsignal,\n\t}: SuiClientTypes.MvrResolvePackageOptions): Promise<SuiClientTypes.MvrResolvePackageResponse> {\n\t\tsignal?.throwIfAborted();\n\t\tif (!hasMvrName(name)) {\n\t\t\treturn {\n\t\t\t\tpackage: name,\n\t\t\t};\n\t\t}\n\t\tconst resolved = await raceSignal(this.#mvrPackageDataLoader.load(name), signal);\n\t\treturn {\n\t\t\tpackage: resolved,\n\t\t};\n\t}\n\n\tasync resolveType({\n\t\ttype,\n\t\tsignal,\n\t}: SuiClientTypes.MvrResolveTypeOptions): Promise<SuiClientTypes.MvrResolveTypeResponse> {\n\t\tsignal?.throwIfAborted();\n\t\tif (!hasMvrName(type)) {\n\t\t\treturn {\n\t\t\t\ttype,\n\t\t\t};\n\t\t}\n\n\t\tconst mvrTypes = [...extractMvrTypes(type)];\n\t\tconst resolvedTypes = await raceSignal(this.#mvrTypeDataLoader.loadMany(mvrTypes), signal);\n\n\t\tconst typeMap: Record<string, string> = {};\n\n\t\tfor (let i = 0; i < mvrTypes.length; i++) {\n\t\t\tconst resolvedType = resolvedTypes[i];\n\t\t\tif (resolvedType instanceof Error) {\n\t\t\t\tthrow resolvedType;\n\t\t\t}\n\t\t\ttypeMap[mvrTypes[i]] = resolvedType;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: replaceMvrNames(type, typeMap),\n\t\t};\n\t}\n\n\tasync resolve({\n\t\ttypes = [],\n\t\tpackages = [],\n\t\tsignal,\n\t}: SuiClientTypes.MvrResolveOptions): Promise<SuiClientTypes.MvrResolveResponse> {\n\t\tsignal?.throwIfAborted();\n\t\tconst mvrTypes = new Set<string>();\n\n\t\tfor (const type of types ?? []) {\n\t\t\textractMvrTypes(type, mvrTypes);\n\t\t}\n\n\t\tconst typesArray = [...mvrTypes];\n\t\tconst [resolvedTypes, resolvedPackages] = await raceSignal(\n\t\t\tPromise.all([\n\t\t\t\ttypesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [],\n\t\t\t\tpackages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : [],\n\t\t\t]),\n\t\t\tsignal,\n\t\t);\n\n\t\tconst typeMap: Record<string, string> = {\n\t\t\t...this.#overrides?.types,\n\t\t};\n\n\t\tfor (const [i, type] of typesArray.entries()) {\n\t\t\tconst resolvedType = resolvedTypes[i];\n\t\t\tif (resolvedType instanceof Error) {\n\t\t\t\tthrow resolvedType;\n\t\t\t}\n\t\t\ttypeMap[type] = resolvedType;\n\t\t}\n\n\t\tconst replacedTypes: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\ttype: string;\n\t\t\t}\n\t\t> = {};\n\n\t\tfor (const type of types ?? []) {\n\t\t\tconst resolvedType = replaceMvrNames(type, typeMap);\n\n\t\t\treplacedTypes[type] = {\n\t\t\t\ttype: resolvedType,\n\t\t\t};\n\t\t}\n\n\t\tconst replacedPackages: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tpackage: string;\n\t\t\t}\n\t\t> = {};\n\n\t\tfor (const [i, pkg] of (packages ?? []).entries()) {\n\t\t\tconst resolvedPkg = this.#overrides?.packages?.[pkg] ?? resolvedPackages[i];\n\n\t\t\tif (resolvedPkg instanceof Error) {\n\t\t\t\tthrow resolvedPkg;\n\t\t\t}\n\n\t\t\treplacedPackages[pkg] = {\n\t\t\t\tpackage: resolvedPkg,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\ttypes: replacedTypes,\n\t\t\tpackages: replacedPackages,\n\t\t};\n\t}\n}\n\nfunction validateOverrides(overrides?: {\n\tpackages?: Record<string, string>;\n\ttypes?: Record<string, string>;\n}) {\n\tif (overrides?.packages) {\n\t\tfor (const [pkg, id] of Object.entries(overrides.packages)) {\n\t\t\tif (!isValidNamedPackage(pkg)) {\n\t\t\t\tthrow new Error(`Invalid package name: ${pkg}`);\n\t\t\t}\n\t\t\tif (!isValidSuiAddress(normalizeSuiAddress(id))) {\n\t\t\t\tthrow new Error(`Invalid package ID: ${id}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (overrides?.types) {\n\t\tfor (const [type, val] of Object.entries(overrides.types)) {\n\t\t\t// validate that types are first-level only.\n\t\t\tif (parseStructTag(type).typeParams.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Type overrides must be first-level only. If you want to supply generic types, just pass each type individually.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst parsedValue = parseStructTag(val);\n\n\t\t\tif (!isValidSuiAddress(parsedValue.address)) {\n\t\t\t\tthrow new Error(`Invalid type: ${val}`);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Extracts all named types from a given type.\n */\nexport function extractMvrTypes(type: string | StructTag, types = new Set<string>()) {\n\tif (typeof type === 'string' && !hasMvrName(type)) return types;\n\n\tif (typeof type === 'string' && type.startsWith('vector<') && type.endsWith('>')) {\n\t\treturn extractMvrTypes(type.slice(7, -1), types);\n\t}\n\n\tconst tag = isStructTag(type) ? type : parseStructTag(type);\n\n\tif (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);\n\n\tfor (const param of tag.typeParams) {\n\t\textractMvrTypes(param, types);\n\t}\n\n\treturn types;\n}\n\n/**\n * Traverses a type, and replaces any found names with their resolved equivalents,\n * based on the supplied type cache.\n */\nfunction replaceMvrNames(tag: string | StructTag, typeCache: Record<string, string>): string {\n\tif (typeof tag === 'string' && !tag.includes('::')) {\n\t\treturn tag;\n\t}\n\n\tif (typeof tag === 'string' && tag.startsWith('vector<') && tag.endsWith('>')) {\n\t\treturn `vector<${replaceMvrNames(tag.slice(7, -1), typeCache)}>`;\n\t}\n\n\tconst type = isStructTag(tag) ? tag : parseStructTag(tag);\n\n\tconst typeTag = `${type.address}::${type.module}::${type.name}`;\n\tconst cacheHit = typeCache[typeTag];\n\n\treturn normalizeStructTag({\n\t\t...type,\n\t\taddress: cacheHit ? cacheHit.split('::')[0] : type.address,\n\t\ttypeParams: type.typeParams.map((param) => replaceMvrNames(param, typeCache)),\n\t});\n}\n\nexport function hasMvrName(nameOrType: string) {\n\treturn (\n\t\tnameOrType.includes(NAME_SEPARATOR) || nameOrType.includes('@') || nameOrType.includes('.sui')\n\t);\n}\n\n/**\n * Races a promise against an optional AbortSignal. MVR resolution batches lookups\n * from independent callers into a single request via a shared DataLoader, so a\n * caller's signal cannot cancel the shared network request without affecting other\n * callers. Instead, this rejects the awaiting caller as soon as its signal aborts\n * (the underlying request continues in the background).\n *\n * The same isolation applies to any shared/cached request (e.g. `cache.read`).\n */\nexport function raceSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T> {\n\tif (!signal) {\n\t\treturn promise;\n\t}\n\n\t// An `abort` event is not replayed for listeners added after the fact, so a signal that was\n\t// already aborted would otherwise resolve normally.\n\tif (signal.aborted) {\n\t\treturn Promise.reject(signal.reason);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst onAbort = () => reject(signal.reason);\n\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\n\t\tpromise.then(resolve, reject).finally(() => {\n\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t});\n\t});\n}\n\nfunction isStructTag(type: string | StructTag): type is StructTag {\n\treturn (\n\t\ttypeof type === 'object' &&\n\t\t'address' in type &&\n\t\t'module' in type &&\n\t\t'name' in type &&\n\t\t'typeParams' in type\n\t);\n}\n\nexport type NamedPackagesOverrides = {\n\tpackages: Record<string, string>;\n\ttypes: Record<string, string>;\n};\n\n/**\n * Looks up all `.move` names in a transaction block.\n * Returns a list of all the names found.\n */\nexport function findNamesInTransaction(builder: TransactionDataBuilder): {\n\tpackages: string[];\n\ttypes: string[];\n} {\n\tconst packages: Set<string> = new Set();\n\tconst types: Set<string> = new Set();\n\n\tfor (const command of builder.commands) {\n\t\tswitch (command.$kind) {\n\t\t\tcase 'MakeMoveVec':\n\t\t\t\tif (command.MakeMoveVec.type) {\n\t\t\t\t\tgetNamesFromTypeList([command.MakeMoveVec.type]).forEach((type) => {\n\t\t\t\t\t\ttypes.add(type);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'MoveCall':\n\t\t\t\tconst moveCall = command.MoveCall;\n\n\t\t\t\tconst pkg = moveCall.package.split('::')[0];\n\t\t\t\tif (hasMvrName(pkg)) {\n\t\t\t\t\tif (!isValidNamedPackage(pkg)) throw new Error(`Invalid package name: ${pkg}`);\n\t\t\t\t\tpackages.add(pkg);\n\t\t\t\t}\n\n\t\t\t\tgetNamesFromTypeList(moveCall.typeArguments ?? []).forEach((type) => {\n\t\t\t\t\ttypes.add(type);\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn {\n\t\tpackages: [...packages],\n\t\ttypes: [...types],\n\t};\n}\n\n/**\n * Replace all names & types in a transaction block\n * with their resolved names/types.\n */\nexport function replaceNames(\n\tbuilder: TransactionDataBuilder,\n\tresolved: SuiClientTypes.MvrResolveResponse,\n) {\n\tfor (const command of builder.commands) {\n\t\t// Replacements for `MakeMoveVec` commands (that can include types)\n\t\tif (command.MakeMoveVec?.type) {\n\t\t\tif (!hasMvrName(command.MakeMoveVec.type)) continue;\n\t\t\tif (!resolved.types[command.MakeMoveVec.type])\n\t\t\t\tthrow new Error(`No resolution found for type: ${command.MakeMoveVec.type}`);\n\t\t\tcommand.MakeMoveVec.type = resolved.types[command.MakeMoveVec.type].type;\n\t\t}\n\t\t// Replacements for `MoveCall` commands (that can include packages & types)\n\t\tconst tx = command.MoveCall;\n\t\tif (!tx) continue;\n\n\t\tconst nameParts = tx.package.split('::');\n\t\tconst name = nameParts[0];\n\n\t\tif (hasMvrName(name) && !resolved.packages[name])\n\t\t\tthrow new Error(`No address found for package: ${name}`);\n\n\t\t// Replace package name with address.\n\t\tif (hasMvrName(name)) {\n\t\t\tnameParts[0] = resolved.packages[name].package;\n\t\t\ttx.package = nameParts.join('::');\n\t\t}\n\n\t\tconst types = tx.typeArguments;\n\t\tif (!types) continue;\n\n\t\tfor (let i = 0; i < types.length; i++) {\n\t\t\tif (!hasMvrName(types[i])) continue;\n\n\t\t\tif (!resolved.types[types[i]]) throw new Error(`No resolution found for type: ${types[i]}`);\n\t\t\ttypes[i] = resolved.types[types[i]].type;\n\t\t}\n\n\t\ttx.typeArguments = types;\n\t}\n}\n\n/**\n * Returns a list of unique types that include a name\n * from the given list. This list is retrieved from the Transaction Data.\n */\nfunction getNamesFromTypeList(types: string[]) {\n\tconst names = new Set<string>();\n\tfor (const type of types) {\n\t\tif (hasMvrName(type)) {\n\t\t\tif (!isValidNamedType(type)) throw new Error(`Invalid type with names: ${type}`);\n\t\t\tnames.add(type);\n\t\t}\n\t}\n\treturn names;\n}\n"],"mappings":";;;;;;AAiBA,MAAM,iBAAiB;AACvB,MAAM,iBAAiB,EACtB,cAAc,eAAe,mBAC7B;AAYD,IAAa,YAAb,MAA4D;CAC3D;CACA;CACA;CACA;CAKA,YAAY,EAAE,OAAO,KAAK,WAAW,IAAI,aAA+B;AACvE,QAAKA,QAAS;AACd,QAAKC,MAAO;AACZ,QAAKC,WAAY;AACjB,QAAKC,YAAa;GACjB,UAAU,WAAW;GACrB,OAAO,WAAW;GAClB;AAED,oBAAkB,MAAKA,UAAW;;CAGnC,KAAIC,uBAAwB;AAC3B,SAAO,MAAKJ,MAAO,SAAS,CAAC,yBAAyB,MAAKC,OAAQ,GAAG,QAAQ;GAC7E,MAAM,SAAS,IAAI,WAA2B,OAAO,aAAa;AACjE,QAAI,CAAC,MAAKA,IACT,OAAM,IAAI,MACT,4DAA4D,SAAS,KAAK,KAAK,CAAC,GAChF;IAEF,MAAM,WAAW,MAAM,MAAKI,gB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AI;;AAGrC,KAAG,gBAAgB;;;;;;;AAQrB,SAAS,qBAAqB,OAAiB;CAC9C,MAAM,wBAAQ,IAAI,KAAa;AAC/B,MAAK,MAAM,QAAQ,MAClB,KAAI,WAAW,KAAK,EAAE;AACrB,MAAI,CAAC,iBAAiB,KAAK,CAAE,OAAM,IAAI,MAAM,4BAA4B,OAAO;AAChF,QAAM,IAAI,KAAK;;AAGjB,QAAO"}
1
+ {"version":3,"file":"mvr.mjs","names":["#cache","#url","#pageSize","#overrides","#mvrPackageDataLoader","#resolvePackages","#mvrTypeDataLoader","#resolveTypes","#fetch"],"sources":["../../src/client/mvr.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { chunk, DataLoader } from '@mysten/utils';\nimport { isValidNamedPackage, isValidNamedType } from '../utils/move-registry.js';\nimport type { StructTag } from '../utils/sui-types.js';\nimport {\n\tisValidSuiAddress,\n\tnormalizeStructTag,\n\tnormalizeSuiAddress,\n\tparseStructTag,\n} from '../utils/sui-types.js';\nimport type { ClientCache } from './cache.js';\nimport type { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport { PACKAGE_VERSION } from '../version.js';\nimport type { SuiClientTypes } from './types.js';\n\nconst NAME_SEPARATOR = '/';\nconst MVR_API_HEADER = {\n\t'Mvr-Source': `@mysten/sui@${PACKAGE_VERSION}`,\n};\n\nexport interface MvrClientOptions {\n\tcache: ClientCache;\n\turl?: string;\n\tpageSize?: number;\n\toverrides?: {\n\t\tpackages?: Record<string, string>;\n\t\ttypes?: Record<string, string>;\n\t};\n}\n\nexport class MvrClient implements SuiClientTypes.MvrMethods {\n\t#cache: ClientCache;\n\t#url?: string;\n\t#pageSize: number;\n\t#overrides: {\n\t\tpackages?: Record<string, string>;\n\t\ttypes?: Record<string, string>;\n\t};\n\n\tconstructor({ cache, url, pageSize = 50, overrides }: MvrClientOptions) {\n\t\tthis.#cache = cache;\n\t\tthis.#url = url;\n\t\tthis.#pageSize = pageSize;\n\t\tthis.#overrides = {\n\t\t\tpackages: overrides?.packages,\n\t\t\ttypes: overrides?.types,\n\t\t};\n\n\t\tvalidateOverrides(this.#overrides);\n\t}\n\n\tget #mvrPackageDataLoader() {\n\t\treturn this.#cache.readSync(['#mvrPackageDataLoader', this.#url ?? ''], () => {\n\t\t\tconst loader = new DataLoader<string, string>(async (packages) => {\n\t\t\t\tif (!this.#url) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`MVR Api URL is not set for the current client (resolving ${packages.join(', ')})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst resolved = await this.#resolvePackages(packages);\n\n\t\t\t\treturn packages.map(\n\t\t\t\t\t(pkg) => resolved[pkg] ?? new Error(`Failed to resolve package: ${pkg}`),\n\t\t\t\t);\n\t\t\t});\n\t\t\tconst overrides = this.#overrides?.packages;\n\n\t\t\tif (overrides) {\n\t\t\t\tfor (const [pkg, id] of Object.entries(overrides)) {\n\t\t\t\t\tloader.prime(pkg, id);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn loader;\n\t\t});\n\t}\n\n\tget #mvrTypeDataLoader() {\n\t\treturn this.#cache.readSync(['#mvrTypeDataLoader', this.#url ?? ''], () => {\n\t\t\tconst loader = new DataLoader<string, string>(async (types) => {\n\t\t\t\tif (!this.#url) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`MVR Api URL is not set for the current client (resolving ${types.join(', ')})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst resolved = await this.#resolveTypes(types);\n\n\t\t\t\treturn types.map((type) => resolved[type] ?? new Error(`Failed to resolve type: ${type}`));\n\t\t\t});\n\n\t\t\tconst overrides = this.#overrides?.types;\n\n\t\t\tif (overrides) {\n\t\t\t\tfor (const [type, id] of Object.entries(overrides)) {\n\t\t\t\t\tloader.prime(type, id);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn loader;\n\t\t});\n\t}\n\n\tasync #resolvePackages(packages: readonly string[]) {\n\t\tif (packages.length === 0) return {};\n\n\t\tconst batches = chunk(packages, this.#pageSize);\n\t\tconst results: Record<string, string> = {};\n\n\t\tawait Promise.all(\n\t\t\tbatches.map(async (batch) => {\n\t\t\t\tconst data = await this.#fetch<{ resolution: Record<string, { package_id: string }> }>(\n\t\t\t\t\t'/v1/resolution/bulk',\n\t\t\t\t\t{\n\t\t\t\t\t\tnames: batch,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (!data?.resolution) return;\n\n\t\t\t\tfor (const pkg of Object.keys(data?.resolution)) {\n\t\t\t\t\tconst pkgData = data.resolution[pkg]?.package_id;\n\n\t\t\t\t\tif (!pkgData) continue;\n\n\t\t\t\t\tresults[pkg] = pkgData;\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\treturn results;\n\t}\n\n\tasync #resolveTypes(types: readonly string[]) {\n\t\tif (types.length === 0) return {};\n\n\t\tconst batches = chunk(types, this.#pageSize);\n\t\tconst results: Record<string, string> = {};\n\n\t\tawait Promise.all(\n\t\t\tbatches.map(async (batch) => {\n\t\t\t\tconst data = await this.#fetch<{ resolution: Record<string, { type_tag: string }> }>(\n\t\t\t\t\t'/v1/struct-definition/bulk',\n\t\t\t\t\t{\n\t\t\t\t\t\ttypes: batch,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (!data?.resolution) return;\n\n\t\t\t\tfor (const type of Object.keys(data?.resolution)) {\n\t\t\t\t\tconst typeData = data.resolution[type]?.type_tag;\n\t\t\t\t\tif (!typeData) continue;\n\n\t\t\t\t\tresults[type] = typeData;\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\treturn results;\n\t}\n\n\tasync #fetch<T>(url: string, body: Record<string, unknown>): Promise<T> {\n\t\tif (!this.#url) {\n\t\t\tthrow new Error('MVR Api URL is not set for the current client');\n\t\t}\n\n\t\tconst response = await fetch(`${this.#url}${url}`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t...MVR_API_HEADER,\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst errorBody = await response.json().catch(() => ({}));\n\t\t\tthrow new Error(`Failed to resolve types: ${errorBody?.message}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync resolvePackage({\n\t\tpackage: name,\n\t\tsignal,\n\t}: SuiClientTypes.MvrResolvePackageOptions): Promise<SuiClientTypes.MvrResolvePackageResponse> {\n\t\tsignal?.throwIfAborted();\n\t\tif (!hasMvrName(name)) {\n\t\t\treturn {\n\t\t\t\tpackage: name,\n\t\t\t};\n\t\t}\n\t\tconst resolved = await raceSignal(this.#mvrPackageDataLoader.load(name), signal);\n\t\treturn {\n\t\t\tpackage: resolved,\n\t\t};\n\t}\n\n\tasync resolveType({\n\t\ttype,\n\t\tsignal,\n\t}: SuiClientTypes.MvrResolveTypeOptions): Promise<SuiClientTypes.MvrResolveTypeResponse> {\n\t\tsignal?.throwIfAborted();\n\t\tif (!hasMvrName(type)) {\n\t\t\treturn {\n\t\t\t\ttype,\n\t\t\t};\n\t\t}\n\n\t\tconst mvrTypes = [...extractMvrTypes(type)];\n\t\tconst resolvedTypes = await raceSignal(this.#mvrTypeDataLoader.loadMany(mvrTypes), signal);\n\n\t\tconst typeMap: Record<string, string> = {};\n\n\t\tfor (let i = 0; i < mvrTypes.length; i++) {\n\t\t\tconst resolvedType = resolvedTypes[i];\n\t\t\tif (resolvedType instanceof Error) {\n\t\t\t\tthrow resolvedType;\n\t\t\t}\n\t\t\ttypeMap[mvrTypes[i]] = resolvedType;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: replaceMvrNames(type, typeMap),\n\t\t};\n\t}\n\n\tasync resolve({\n\t\ttypes = [],\n\t\tpackages = [],\n\t\tsignal,\n\t}: SuiClientTypes.MvrResolveOptions): Promise<SuiClientTypes.MvrResolveResponse> {\n\t\tsignal?.throwIfAborted();\n\t\tconst mvrTypes = new Set<string>();\n\n\t\tfor (const type of types ?? []) {\n\t\t\textractMvrTypes(type, mvrTypes);\n\t\t}\n\n\t\tconst typesArray = [...mvrTypes];\n\t\tconst [resolvedTypes, resolvedPackages] = await raceSignal(\n\t\t\tPromise.all([\n\t\t\t\ttypesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [],\n\t\t\t\tpackages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : [],\n\t\t\t]),\n\t\t\tsignal,\n\t\t);\n\n\t\tconst typeMap: Record<string, string> = {\n\t\t\t...this.#overrides?.types,\n\t\t};\n\n\t\tfor (const [i, type] of typesArray.entries()) {\n\t\t\tconst resolvedType = resolvedTypes[i];\n\t\t\tif (resolvedType instanceof Error) {\n\t\t\t\tthrow resolvedType;\n\t\t\t}\n\t\t\ttypeMap[type] = resolvedType;\n\t\t}\n\n\t\tconst replacedTypes: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\ttype: string;\n\t\t\t}\n\t\t> = {};\n\n\t\tfor (const type of types ?? []) {\n\t\t\tconst resolvedType = replaceMvrNames(type, typeMap);\n\n\t\t\treplacedTypes[type] = {\n\t\t\t\ttype: resolvedType,\n\t\t\t};\n\t\t}\n\n\t\tconst replacedPackages: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tpackage: string;\n\t\t\t}\n\t\t> = {};\n\n\t\tfor (const [i, pkg] of (packages ?? []).entries()) {\n\t\t\tconst resolvedPkg = this.#overrides?.packages?.[pkg] ?? resolvedPackages[i];\n\n\t\t\tif (resolvedPkg instanceof Error) {\n\t\t\t\tthrow resolvedPkg;\n\t\t\t}\n\n\t\t\treplacedPackages[pkg] = {\n\t\t\t\tpackage: resolvedPkg,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\ttypes: replacedTypes,\n\t\t\tpackages: replacedPackages,\n\t\t};\n\t}\n}\n\nfunction validateOverrides(overrides?: {\n\tpackages?: Record<string, string>;\n\ttypes?: Record<string, string>;\n}) {\n\tif (overrides?.packages) {\n\t\tfor (const [pkg, id] of Object.entries(overrides.packages)) {\n\t\t\tif (!isValidNamedPackage(pkg)) {\n\t\t\t\tthrow new Error(`Invalid package name: ${pkg}`);\n\t\t\t}\n\t\t\tif (!isValidSuiAddress(normalizeSuiAddress(id))) {\n\t\t\t\tthrow new Error(`Invalid package ID: ${id}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (overrides?.types) {\n\t\tfor (const [type, val] of Object.entries(overrides.types)) {\n\t\t\t// validate that types are first-level only.\n\t\t\tif (parseStructTag(type).typeParams.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Type overrides must be first-level only. If you want to supply generic types, just pass each type individually.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst parsedValue = parseStructTag(val);\n\n\t\t\tif (!isValidSuiAddress(parsedValue.address)) {\n\t\t\t\tthrow new Error(`Invalid type: ${val}`);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Extracts all named types from a given type.\n */\nexport function extractMvrTypes(type: string | StructTag, types = new Set<string>()) {\n\tif (typeof type === 'string' && !hasMvrName(type)) return types;\n\n\tif (typeof type === 'string' && type.startsWith('vector<') && type.endsWith('>')) {\n\t\treturn extractMvrTypes(type.slice(7, -1), types);\n\t}\n\n\tconst tag = isStructTag(type) ? type : parseStructTag(type);\n\n\tif (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);\n\n\tfor (const param of tag.typeParams) {\n\t\textractMvrTypes(param, types);\n\t}\n\n\treturn types;\n}\n\n/**\n * Traverses a type, and replaces any found names with their resolved equivalents,\n * based on the supplied type cache.\n */\nfunction replaceMvrNames(tag: string | StructTag, typeCache: Record<string, string>): string {\n\tif (typeof tag === 'string' && !tag.includes('::')) {\n\t\treturn tag;\n\t}\n\n\tif (typeof tag === 'string' && tag.startsWith('vector<') && tag.endsWith('>')) {\n\t\treturn `vector<${replaceMvrNames(tag.slice(7, -1), typeCache)}>`;\n\t}\n\n\tconst type = isStructTag(tag) ? tag : parseStructTag(tag);\n\n\tconst typeTag = `${type.address}::${type.module}::${type.name}`;\n\tconst cacheHit = typeCache[typeTag];\n\n\treturn normalizeStructTag({\n\t\t...type,\n\t\taddress: cacheHit ? cacheHit.split('::')[0] : type.address,\n\t\ttypeParams: type.typeParams.map((param) => replaceMvrNames(param, typeCache)),\n\t});\n}\n\nexport function hasMvrName(nameOrType: string) {\n\treturn (\n\t\tnameOrType.includes(NAME_SEPARATOR) || nameOrType.includes('@') || nameOrType.includes('.sui')\n\t);\n}\n\n/**\n * Races a promise against an optional AbortSignal. MVR resolution batches lookups\n * from independent callers into a single request via a shared DataLoader, so a\n * caller's signal cannot cancel the shared network request without affecting other\n * callers. Instead, this rejects the awaiting caller as soon as its signal aborts\n * (the underlying request continues in the background).\n *\n * The same isolation applies to any shared/cached request (e.g. `cache.read`).\n */\nexport function raceSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T> {\n\tif (!signal) {\n\t\treturn promise;\n\t}\n\n\t// An `abort` event is not replayed for listeners added after the fact, so a signal that was\n\t// already aborted would otherwise resolve normally.\n\tif (signal.aborted) {\n\t\treturn Promise.reject(signal.reason);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst onAbort = () => reject(signal.reason);\n\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\n\t\tpromise.then(resolve, reject).finally(() => {\n\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t});\n\t});\n}\n\nfunction isStructTag(type: string | StructTag): type is StructTag {\n\treturn (\n\t\ttypeof type === 'object' &&\n\t\t'address' in type &&\n\t\t'module' in type &&\n\t\t'name' in type &&\n\t\t'typeParams' in type\n\t);\n}\n\nexport type NamedPackagesOverrides = {\n\tpackages: Record<string, string>;\n\ttypes: Record<string, string>;\n};\n\n/**\n * Looks up all `.move` names in a transaction block.\n * Returns a list of all the names found.\n */\nexport function findNamesInTransaction(builder: TransactionDataBuilder): {\n\tpackages: string[];\n\ttypes: string[];\n} {\n\tconst packages: Set<string> = new Set();\n\tconst types: Set<string> = new Set();\n\n\tfor (const command of builder.commands) {\n\t\tswitch (command.$kind) {\n\t\t\tcase 'MakeMoveVec':\n\t\t\t\tif (command.MakeMoveVec.type) {\n\t\t\t\t\tgetNamesFromTypeList([command.MakeMoveVec.type]).forEach((type) => {\n\t\t\t\t\t\ttypes.add(type);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'MoveCall':\n\t\t\t\tconst moveCall = command.MoveCall;\n\n\t\t\t\tconst pkg = moveCall.package.split('::')[0];\n\t\t\t\tif (hasMvrName(pkg)) {\n\t\t\t\t\tif (!isValidNamedPackage(pkg)) throw new Error(`Invalid package name: ${pkg}`);\n\t\t\t\t\tpackages.add(pkg);\n\t\t\t\t}\n\n\t\t\t\tgetNamesFromTypeList(moveCall.typeArguments ?? []).forEach((type) => {\n\t\t\t\t\ttypes.add(type);\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn {\n\t\tpackages: [...packages],\n\t\ttypes: [...types],\n\t};\n}\n\n/**\n * Replace all names & types in a transaction block\n * with their resolved names/types.\n */\nexport function replaceNames(\n\tbuilder: TransactionDataBuilder,\n\tresolved: SuiClientTypes.MvrResolveResponse,\n) {\n\tfor (const command of builder.commands) {\n\t\t// Replacements for `MakeMoveVec` commands (that can include types)\n\t\tif (command.MakeMoveVec?.type) {\n\t\t\tif (!hasMvrName(command.MakeMoveVec.type)) continue;\n\t\t\tif (!resolved.types[command.MakeMoveVec.type])\n\t\t\t\tthrow new Error(`No resolution found for type: ${command.MakeMoveVec.type}`);\n\t\t\tcommand.MakeMoveVec.type = resolved.types[command.MakeMoveVec.type].type;\n\t\t}\n\t\t// Replacements for `MoveCall` commands (that can include packages & types)\n\t\tconst tx = command.MoveCall;\n\t\tif (!tx) continue;\n\n\t\tconst nameParts = tx.package.split('::');\n\t\tconst name = nameParts[0];\n\n\t\tif (hasMvrName(name) && !resolved.packages[name])\n\t\t\tthrow new Error(`No address found for package: ${name}`);\n\n\t\t// Replace package name with address.\n\t\tif (hasMvrName(name)) {\n\t\t\tnameParts[0] = resolved.packages[name].package;\n\t\t\ttx.package = nameParts.join('::');\n\t\t}\n\n\t\tconst types = tx.typeArguments;\n\t\tif (!types) continue;\n\n\t\tfor (let i = 0; i < types.length; i++) {\n\t\t\tif (!hasMvrName(types[i])) continue;\n\n\t\t\tif (!resolved.types[types[i]]) throw new Error(`No resolution found for type: ${types[i]}`);\n\t\t\ttypes[i] = resolved.types[types[i]].type;\n\t\t}\n\n\t\ttx.typeArguments = types;\n\t}\n}\n\n/**\n * Returns a list of unique types that include a name\n * from the given list. This list is retrieved from the Transaction Data.\n */\nfunction getNamesFromTypeList(types: string[]) {\n\tconst names = new Set<string>();\n\tfor (const type of types) {\n\t\tif (hasMvrName(type)) {\n\t\t\tif (!isValidNamedType(type)) throw new Error(`Invalid type with names: ${type}`);\n\t\t\tnames.add(type);\n\t\t}\n\t}\n\treturn names;\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,iBAAiB;AACvB,MAAM,iBAAiB,EACtB,cAAc,eAAe,mBAC7B;AAYD,IAAa,YAAb,MAA4D;CAC3D;CACA;CACA;CACA;CAKA,YAAY,EAAE,OAAO,KAAK,WAAW,IAAI,aAA+B;AACvE,QAAKA,QAAS;AACd,QAAKC,MAAO;AACZ,QAAKC,WAAY;AACjB,QAAKC,YAAa;GACjB,UAAU,WAAW;GACrB,OAAO,WAAW;GAClB;AAED,oBAAkB,MAAKA,UAAW;;CAGnC,KAAIC,uBAAwB;AAC3B,SAAO,MAAKJ,MAAO,SAAS,CAAC,yBAAyB,MAAKC,OAAQ,GAAG,QAAQ;GAC7E,MAAM,SAAS,IAAI,WAA2B,OAAO,aAAa;AACjE,QAAI,CAAC,MAAKA,IACT,OAAM,IAAI,MACT,4DAA4D,SAAS,KAAK,KAAK,CA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AK;AAC3F,SAAM,KAAK,SAAS,MAAM,MAAM,IAAI;;AAGrC,KAAG,gBAAgB;;;;;;;AAQrB,SAAS,qBAAqB,OAAiB;CAC9C,MAAM,wBAAQ,IAAI,KAAa;AAC/B,MAAK,MAAM,QAAQ,MAClB,KAAI,WAAW,KAAK,EAAE;AACrB,MAAI,CAAC,iBAAiB,KAAK,CAAE,OAAM,IAAI,MAAM,4BAA4B,OAAO;AAChF,QAAM,IAAI,KAAK;;AAGjB,QAAO"}
@@ -30,12 +30,6 @@ declare function parseSerializedSignature(serializedSignature: string): {
30
30
  clientDataJson: string;
31
31
  userSignature: Uint8Array<ArrayBuffer>;
32
32
  publicKey: Uint8Array<ArrayBuffer>;
33
- } | {
34
- serializedSignature: string;
35
- signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
36
- signature: Uint8Array<ArrayBuffer>;
37
- publicKey: Uint8Array<ArrayBuffer>;
38
- bytes: Uint8Array<ArrayBuffer>;
39
33
  } | {
40
34
  serializedSignature: string;
41
35
  signatureScheme: "ZkLogin";
@@ -60,6 +54,12 @@ declare function parseSerializedSignature(serializedSignature: string): {
60
54
  };
61
55
  signature: Uint8Array<ArrayBufferLike>;
62
56
  publicKey: Uint8Array<ArrayBuffer>;
57
+ } | {
58
+ serializedSignature: string;
59
+ signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
60
+ signature: Uint8Array<ArrayBuffer>;
61
+ publicKey: Uint8Array<ArrayBuffer>;
62
+ bytes: Uint8Array<ArrayBuffer>;
63
63
  } | {
64
64
  serializedSignature: string;
65
65
  signatureScheme: "MultiSig";
@@ -1,6 +1,6 @@
1
1
  import { AdvanceCheckpointRequest, AdvanceCheckpointResponse, AdvanceClockRequest, AdvanceClockResponse, GetStatusRequest, GetStatusResponse } from "./forking_service.mjs";
2
- import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/forking/v1alpha/forking_service.client.d.ts
@@ -37,9 +37,9 @@ interface IForkingServiceClient {
37
37
  declare class ForkingServiceClient implements IForkingServiceClient, ServiceInfo {
38
38
  private readonly _transport;
39
39
  typeName: string;
40
- methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
40
+ methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
41
41
  options: {
42
- [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
42
+ [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
43
43
  };
44
44
  constructor(_transport: RpcTransport);
45
45
  /**
@@ -1,6 +1,6 @@
1
1
  import { BatchGetObjectsRequest, BatchGetObjectsResponse, BatchGetTransactionsRequest, BatchGetTransactionsResponse, GetCheckpointRequest, GetCheckpointResponse, GetEpochRequest, GetEpochResponse, GetObjectRequest, GetObjectResponse, GetServiceInfoRequest, GetServiceInfoResponse, GetTransactionRequest, GetTransactionResponse, ListCheckpointsRequest, ListCheckpointsResponse, ListEventsRequest, ListEventsResponse, ListTransactionsRequest, ListTransactionsResponse } from "./ledger_service.mjs";
2
- import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts
@@ -73,9 +73,9 @@ interface ILedgerServiceClient {
73
73
  declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
74
74
  private readonly _transport;
75
75
  typeName: string;
76
- methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
76
+ methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
77
77
  options: {
78
- [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
78
+ [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
79
79
  };
80
80
  constructor(_transport: RpcTransport);
81
81
  /**
@@ -1,6 +1,6 @@
1
1
  import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
2
- import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts
@@ -31,9 +31,9 @@ interface IMovePackageServiceClient {
31
31
  declare class MovePackageServiceClient implements IMovePackageServiceClient, ServiceInfo {
32
32
  private readonly _transport;
33
33
  typeName: string;
34
- methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
34
+ methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
35
35
  options: {
36
- [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
36
+ [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
37
37
  };
38
38
  constructor(_transport: RpcTransport);
39
39
  /**
@@ -1,6 +1,6 @@
1
1
  import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
2
- import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
@@ -35,9 +35,9 @@ interface IStateServiceClient {
35
35
  declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
36
36
  private readonly _transport;
37
37
  typeName: string;
38
- methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
38
+ methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
39
39
  options: {
40
- [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
40
+ [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
41
41
  };
42
42
  constructor(_transport: RpcTransport);
43
43
  /**
@@ -1,6 +1,6 @@
1
1
  import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse, SubscribeEventsRequest, SubscribeEventsResponse, SubscribeTransactionsRequest, SubscribeTransactionsResponse } from "./subscription_service.mjs";
2
- import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
@@ -100,9 +100,9 @@ interface ISubscriptionServiceClient {
100
100
  declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
101
101
  private readonly _transport;
102
102
  typeName: string;
103
- methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
103
+ methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
104
104
  options: {
105
- [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
105
+ [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
106
106
  };
107
107
  constructor(_transport: RpcTransport);
108
108
  /**
@@ -1,5 +1,5 @@
1
1
  import { normalizeSuiNSName } from "../utils/suins.mjs";
2
- import { isValidNamedPackage } from "../utils/move-registry.mjs";
2
+ import { isValidNamedPackage } from "../utils/named-packages.mjs";
3
3
  import { isValidSuiAddress, isValidSuiObjectId, isValidTransactionDigest, normalizeSuiAddress, normalizeSuiObjectId } from "../utils/sui-types.mjs";
4
4
  import { BaseClient } from "../client/client.mjs";
5
5
  import { hasMvrName } from "../client/mvr.mjs";
@@ -8,7 +8,7 @@ import { createPure } from "./pure.mjs";
8
8
  import { BalanceOptions } from "./intents/BalanceOptions.mjs";
9
9
  import { SignatureWithBytes, Signer } from "../cryptography/keypair.mjs";
10
10
  import "../cryptography/index.mjs";
11
- import * as _mysten_bcs1397 from "@mysten/bcs";
11
+ import * as _mysten_bcs1241 from "@mysten/bcs";
12
12
  import { SerializedBcs } from "@mysten/bcs";
13
13
  import { InferInput } from "valibot";
14
14
 
@@ -107,7 +107,7 @@ declare class Transaction {
107
107
  getData(): {
108
108
  version: 2;
109
109
  sender?: string | null | undefined;
110
- expiration?: _mysten_bcs1397.EnumOutputShapeWithKeys<{
110
+ expiration?: _mysten_bcs1241.EnumOutputShapeWithKeys<{
111
111
  None: true;
112
112
  Epoch: string | number;
113
113
  ValidDuring: {
@@ -141,8 +141,8 @@ declare class Transaction {
141
141
  digest: string;
142
142
  }[] | null;
143
143
  };
144
- inputs: _mysten_bcs1397.EnumOutputShapeWithKeys<{
145
- Object: _mysten_bcs1397.EnumOutputShapeWithKeys<{
144
+ inputs: _mysten_bcs1241.EnumOutputShapeWithKeys<{
145
+ Object: _mysten_bcs1241.EnumOutputShapeWithKeys<{
146
146
  ImmOrOwnedObject: {
147
147
  objectId: string;
148
148
  version: string | number;
@@ -181,7 +181,7 @@ declare class Transaction {
181
181
  Balance: string;
182
182
  $kind: "Balance";
183
183
  };
184
- withdrawFrom: _mysten_bcs1397.EnumOutputShapeWithKeys<{
184
+ withdrawFrom: _mysten_bcs1241.EnumOutputShapeWithKeys<{
185
185
  Sender: true;
186
186
  Sponsor: true;
187
187
  SenderAllowance: {
@@ -191,7 +191,7 @@ declare class Transaction {
191
191
  }, "Sender" | "Sponsor" | "SenderAllowance">;
192
192
  };
193
193
  }, "Pure" | "Object" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
194
- commands: _mysten_bcs1397.EnumOutputShapeWithKeys<{
194
+ commands: _mysten_bcs1241.EnumOutputShapeWithKeys<{
195
195
  MoveCall: {
196
196
  package: string;
197
197
  module: string;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.mts","names":[],"sources":["../../../src/transactions/data/internal.ts"],"mappings":";;;;;;;KA8BK,eAAA,WAA0B,MAAA,SAAe,aAAA,UAAuB,cAAA,CACpE,QAAA,eACa,CAAA,GAAI,UAAA,CAAW,CAAA,CAAE,CAAA;AAAA,KAI1B,gBAAA,WAA2B,MAAA,SAAe,aAAA,UAAuB,eAAA,CACrE,QAAA,eACa,CAAA,GAAI,WAAA,CAAY,CAAA,CAAE,CAAA;AAAA,KAI3B,UAAA,WAAqB,MAAA,SAAe,aAAA,UAAuB,aAAA,CAC/D,eAAA,CAAgB,CAAA,GAChB,gBAAA,CAAiB,CAAA;AAAA,cA6DL,eAAA,EAAe,YAAA;EAAA,uDAI1B,UAAA,CAAA,YAAA;;;;KACU,SAAA,GAAY,WAAA,QAAmB,eAAA;AAAA,cAG9B,cAAA,aAAc,WAAA,EAAA,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBf,QAAA,GAAW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A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KACU,OAAA,GAAU,WAAA,QAAmB,aAAA;AAAA,cAsC5B,qBAAA,EAAqB,UAAA;QAKhC,UAAA,CAAA,aAAA;;;;;;;;;;;;;;;;;;;;;;;KAEU,qBAAA,GAAwB,WAAA,QAAmB,qBAAA;AAAA,cAE1C,qBAAA,EAAqB,YAAA;EAAA,kBAOhC,UAAA,CAAA,aAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEU,eAAA,GAAkB,WAAA,QAAmB,qBAAA"}
@@ -1,9 +1,31 @@
1
1
  import { isValidSuiAddress, normalizeSuiAddress } from "../../utils/sui-types.mjs";
2
- import { array, boolean, check, integer, lazy, literal, nullable, nullish, number, object, optional, pipe, record, string, transform, tuple, union, unknown } from "valibot";
2
+ import { array, boolean, check, integer, lazy, literal, nullable, nullish, number, object, optional, pipe, record, string, transform, tuple, union, unknown, variant } from "valibot";
3
3
 
4
4
  //#region src/transactions/data/internal.ts
5
5
  function safeEnum(options) {
6
- return union(Object.keys(options).map((key) => withKind(key, object({ [key]: options[key] }))));
6
+ const schemas = Object.keys(options).map((key) => object({
7
+ [key]: options[key],
8
+ $kind: literal(key)
9
+ }));
10
+ return pipe(unknown(), check((input) => unsupportedEnumVariantMessage(input, options) === void 0, ({ input, message }) => unsupportedEnumVariantMessage(input, options) ?? message), transform(addMissingEnumKind), variant("$kind", schemas));
11
+ }
12
+ function getEnumKind(input) {
13
+ if (typeof input !== "object" || input === null) return null;
14
+ if ("$kind" in input && typeof input.$kind === "string") return input.$kind;
15
+ return Object.keys(input).find((key) => key !== "$kind") ?? null;
16
+ }
17
+ function addMissingEnumKind(input) {
18
+ if (typeof input !== "object" || input === null || "$kind" in input) return input;
19
+ const kind = getEnumKind(input);
20
+ return kind === null ? input : {
21
+ ...input,
22
+ $kind: kind
23
+ };
24
+ }
25
+ function unsupportedEnumVariantMessage(input, options) {
26
+ const kind = getEnumKind(input);
27
+ if (kind === null || Object.hasOwn(options, kind)) return void 0;
28
+ return `Unsupported enum variant "${kind}". Expected one of: ${Object.keys(options).map((key) => `"${key}"`).join(", ")}.`;
7
29
  }
8
30
  function withKind(key, schema) {
9
31
  return pipe(object({
@@ -1 +1 @@
1
- {"version":3,"file":"internal.mjs","names":[],"sources":["../../../src/transactions/data/internal.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { EnumInputShape, EnumOutputShape } from '@mysten/bcs';\nimport type { GenericSchema, InferInput, InferOutput, ObjectEntries, ObjectSchema } from 'valibot';\nimport {\n\tarray,\n\tboolean,\n\tcheck,\n\tinteger,\n\tlazy,\n\tliteral,\n\tnullable,\n\tnullish,\n\tnumber,\n\tobject,\n\toptional,\n\tpipe,\n\trecord,\n\tstring,\n\ttransform,\n\ttuple,\n\tunion,\n\tunknown,\n} from 'valibot';\n\nimport { isValidSuiAddress, normalizeSuiAddress } from '../../utils/sui-types.js';\nimport type { Simplify } from '@mysten/utils';\nimport type { SuiClientTypes } from '../../client/types.js';\n\ntype EnumSchemaInput<T extends Record<string, GenericSchema<any>>> = EnumInputShape<\n\tSimplify<{\n\t\t[K in keyof T]: InferInput<T[K]>;\n\t}>\n>;\n\ntype EnumSchemaOutput<T extends Record<string, GenericSchema<any>>> = EnumOutputShape<\n\tSimplify<{\n\t\t[K in keyof T]: InferOutput<T[K]>;\n\t}>\n>;\n\ntype EnumSchema<T extends Record<string, GenericSchema<any>>> = GenericSchema<\n\tEnumSchemaInput<T>,\n\tEnumSchemaOutput<T>\n>;\n\nexport function safeEnum<T extends Record<string, GenericSchema<any>>>(options: T): EnumSchema<T> {\n\treturn union(\n\t\tObject.keys(options).map(\n\t\t\t(key) =>\n\t\t\t\twithKind(\n\t\t\t\t\tkey,\n\t\t\t\t\tobject({\n\t\t\t\t\t\t[key]: options[key],\n\t\t\t\t\t}),\n\t\t\t\t) as GenericSchema<EnumOutputShape<T>>,\n\t\t),\n\t) as EnumSchema<T>;\n}\n\nfunction withKind<K extends string, TEntries extends ObjectEntries>(\n\tkey: K,\n\tschema: ObjectSchema<TEntries, undefined>,\n) {\n\treturn pipe(\n\t\tobject({\n\t\t\t...schema.entries,\n\t\t\t$kind: optional(literal(key)),\n\t\t}),\n\t\ttransform((value) => ({ ...value, $kind: key })),\n\t) as GenericSchema<\n\t\tSimplify<InferInput<ObjectSchema<TEntries, undefined>> & { $kind?: K }>,\n\t\tSimplify<InferOutput<ObjectSchema<TEntries, undefined>> & { $kind: K }>\n\t>;\n}\n\nexport const SuiAddress = pipe(\n\tstring(),\n\ttransform((value) => normalizeSuiAddress(value)),\n\tcheck(isValidSuiAddress),\n);\nexport const ObjectID = SuiAddress;\nexport const BCSBytes = string();\nexport const JsonU64 = pipe(\n\tunion([string(), pipe(number(), integer())]),\n\n\tcheck((val) => {\n\t\ttry {\n\t\t\tBigInt(val);\n\t\t\treturn BigInt(val) >= 0 && BigInt(val) <= 18446744073709551615n;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, 'Invalid u64'),\n);\n\nexport const U32 = pipe(\n\tnumber(),\n\tinteger(),\n\tcheck((val) => val >= 0 && val < 2 ** 32, 'Invalid u32'),\n);\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/base_types.rs#L138\n// Implemented as a tuple in rust\nexport const ObjectRefSchema = object({\n\tobjectId: SuiAddress,\n\tversion: JsonU64,\n\tdigest: string(),\n});\nexport type ObjectRef = InferOutput<typeof ObjectRefSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L690-L702\nexport const ArgumentSchema = union([\n\twithKind('GasCoin', object({ GasCoin: literal(true) })),\n\twithKind(\n\t\t'Input',\n\t\tobject({\n\t\t\tInput: pipe(number(), integer()),\n\t\t\ttype: optional(union([literal('pure'), literal('object'), literal('withdrawal')])),\n\t\t}),\n\t),\n\twithKind('Result', object({ Result: pipe(number(), integer()) })),\n\twithKind(\n\t\t'NestedResult',\n\t\tobject({ NestedResult: tuple([pipe(number(), integer()), pipe(number(), integer())]) }),\n\t),\n]);\n\nexport type Argument = InferOutput<typeof ArgumentSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L1387-L1392\nexport const GasDataSchema = object({\n\tbudget: nullable(JsonU64),\n\tprice: nullable(JsonU64),\n\towner: nullable(SuiAddress),\n\tpayment: nullable(array(ObjectRefSchema)),\n});\nexport type GasData = InferOutput<typeof GasDataSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/external-crates/move/crates/move-core-types/src/language_storage.rs#L140-L147\nexport const StructTagSchema = object({\n\taddress: string(),\n\tmodule: string(),\n\tname: string(),\n\t// type_params in rust, should be updated to use camelCase\n\ttypeParams: array(string()),\n});\nexport type StructTag = InferOutput<typeof StructTagSchema>;\n\nexport const OpenSignatureBodySchema: GenericSchema<SuiClientTypes.OpenSignatureBody> = union([\n\tobject({ $kind: literal('address') }),\n\tobject({ $kind: literal('bool') }),\n\tobject({ $kind: literal('u8') }),\n\tobject({ $kind: literal('u16') }),\n\tobject({ $kind: literal('u32') }),\n\tobject({ $kind: literal('u64') }),\n\tobject({ $kind: literal('u128') }),\n\tobject({ $kind: literal('u256') }),\n\tobject({ $kind: literal('unknown') }),\n\tobject({ $kind: literal('vector'), vector: lazy(() => OpenSignatureBodySchema) }),\n\tobject({\n\t\t$kind: literal('datatype'),\n\t\tdatatype: object({\n\t\t\ttypeName: string(),\n\t\t\ttypeParameters: array(lazy(() => OpenSignatureBodySchema)),\n\t\t}),\n\t}),\n\tobject({ $kind: literal('typeParameter'), index: pipe(number(), integer()) }),\n]);\n\nexport const OpenSignatureSchema = object({\n\treference: nullable(union([literal('mutable'), literal('immutable'), literal('unknown')])),\n\tbody: OpenSignatureBodySchema,\n});\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L707-L718\nconst ProgrammableMoveCallSchema = object({\n\tpackage: ObjectID,\n\tmodule: string(),\n\tfunction: string(),\n\t// snake case in rust\n\ttypeArguments: array(string()),\n\targuments: array(ArgumentSchema),\n\t_argumentTypes: optional(nullable(array(OpenSignatureSchema))),\n});\nexport type ProgrammableMoveCall = InferOutput<typeof ProgrammableMoveCallSchema>;\n\nexport const $Intent = object({\n\tname: string(),\n\tinputs: record(string(), union([ArgumentSchema, array(ArgumentSchema)])),\n\tdata: record(string(), unknown()),\n});\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L657-L685\nexport const CommandSchema = safeEnum({\n\tMoveCall: ProgrammableMoveCallSchema,\n\tTransferObjects: object({\n\t\tobjects: array(ArgumentSchema),\n\t\taddress: ArgumentSchema,\n\t}),\n\tSplitCoins: object({\n\t\tcoin: ArgumentSchema,\n\t\tamounts: array(ArgumentSchema),\n\t}),\n\tMergeCoins: object({\n\t\tdestination: ArgumentSchema,\n\t\tsources: array(ArgumentSchema),\n\t}),\n\tPublish: object({\n\t\tmodules: array(BCSBytes),\n\t\tdependencies: array(ObjectID),\n\t}),\n\tMakeMoveVec: object({\n\t\ttype: nullable(string()),\n\t\telements: array(ArgumentSchema),\n\t}),\n\tUpgrade: object({\n\t\tmodules: array(BCSBytes),\n\t\tdependencies: array(ObjectID),\n\t\tpackage: ObjectID,\n\t\tticket: ArgumentSchema,\n\t}),\n\t$Intent,\n});\n\nexport type Command<Arg = Argument> = EnumOutputShape<{\n\tMoveCall: {\n\t\tpackage: string;\n\t\tmodule: string;\n\t\tfunction: string;\n\t\ttypeArguments: string[];\n\t\targuments: Arg[];\n\t\t_argumentTypes?: SuiClientTypes.OpenSignature[] | null;\n\t};\n\tTransferObjects: {\n\t\tobjects: Arg[];\n\t\taddress: Arg;\n\t};\n\tSplitCoins: {\n\t\tcoin: Arg;\n\t\tamounts: Arg[];\n\t};\n\tMergeCoins: {\n\t\tdestination: Arg;\n\t\tsources: Arg[];\n\t};\n\tPublish: {\n\t\tmodules: string[];\n\t\tdependencies: string[];\n\t};\n\tMakeMoveVec: {\n\t\ttype: string | null;\n\t\telements: Arg[];\n\t};\n\tUpgrade: {\n\t\tmodules: string[];\n\t\tdependencies: string[];\n\t\tpackage: string;\n\t\tticket: Arg;\n\t};\n\t$Intent: {\n\t\tname: string;\n\t\tinputs: Record<string, Argument | Argument[]>;\n\t\tdata: Record<string, unknown>;\n\t};\n}>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L102-L114\nexport const ObjectArgSchema = safeEnum({\n\tImmOrOwnedObject: ObjectRefSchema,\n\tSharedObject: object({\n\t\tobjectId: ObjectID,\n\t\t// snake case in rust\n\t\tinitialSharedVersion: JsonU64,\n\t\tmutable: boolean(),\n\t}),\n\tReceiving: ObjectRefSchema,\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ReservationSchema = safeEnum({\n\tMaxAmountU64: JsonU64,\n});\nexport type Reservation = InferOutput<typeof ReservationSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawalTypeArgSchema = safeEnum({\n\tBalance: string(),\n});\nexport type WithdrawalTypeArg = InferOutput<typeof WithdrawalTypeArgSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawFromSchema = safeEnum({\n\tSender: literal(true),\n\tSponsor: literal(true),\n\tSenderAllowance: object({\n\t\tfunder: SuiAddress,\n\t\tallowance: ObjectID,\n\t}),\n});\nexport type WithdrawFrom = InferOutput<typeof WithdrawFromSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const FundsWithdrawalArgSchema = object({\n\treservation: ReservationSchema,\n\ttypeArg: WithdrawalTypeArgSchema,\n\twithdrawFrom: WithdrawFromSchema,\n});\nexport type FundsWithdrawalArg = InferOutput<typeof FundsWithdrawalArgSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L75-L80\nconst CallArgSchema = safeEnum({\n\tObject: ObjectArgSchema,\n\tPure: object({\n\t\tbytes: BCSBytes,\n\t}),\n\tUnresolvedPure: object({\n\t\tvalue: unknown(),\n\t}),\n\tUnresolvedObject: object({\n\t\tobjectId: ObjectID,\n\t\tversion: optional(nullable(JsonU64)),\n\t\tdigest: optional(nullable(string())),\n\t\tinitialSharedVersion: optional(nullable(JsonU64)),\n\t\tmutable: optional(nullable(boolean())),\n\t}),\n\tFundsWithdrawal: FundsWithdrawalArgSchema,\n});\nexport type CallArg = InferOutput<typeof CallArgSchema>;\n\nexport const NormalizedCallArg = safeEnum({\n\tObject: ObjectArgSchema,\n\tPure: object({\n\t\tbytes: BCSBytes,\n\t}),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ValidDuringSchema = object({\n\tminEpoch: nullable(JsonU64),\n\tmaxEpoch: nullable(JsonU64),\n\tminTimestamp: nullable(JsonU64),\n\tmaxTimestamp: nullable(JsonU64),\n\tchain: string(),\n\tnonce: U32,\n});\nexport type ValidDuring = InferOutput<typeof ValidDuringSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const AllowedProposersSchema = object({\n\tepoch: JsonU64,\n\t// Shared by `setExpiration` and `restore`, so this can only carry the invariant true on both.\n\tproposers: pipe(\n\t\tarray(U32),\n\t\tcheck((proposers) => proposers.length > 0, 'Allowed proposers must not be empty'),\n\t),\n});\nexport type AllowedProposers = InferOutput<typeof AllowedProposersSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ValiditySchema = object({\n\t...ValidDuringSchema.entries,\n\tallowedProposers: nullable(AllowedProposersSchema),\n});\nexport type Validity = InferOutput<typeof ValiditySchema>;\n\nexport const TransactionExpiration = safeEnum({\n\tNone: literal(true),\n\tEpoch: JsonU64,\n\tValidDuring: ValidDuringSchema,\n\tValidity: ValiditySchema,\n});\n\nexport type TransactionExpiration = InferOutput<typeof TransactionExpiration>;\n\nexport const TransactionDataSchema = object({\n\tversion: literal(2),\n\tsender: nullish(SuiAddress),\n\texpiration: nullish(TransactionExpiration),\n\tgasData: GasDataSchema,\n\tinputs: array(CallArgSchema),\n\tcommands: array(CommandSchema),\n});\n\nexport type TransactionData = InferOutput<typeof TransactionDataSchema>;\n"],"mappings":";;;;AA+CA,SAAgB,SAAuD,SAA2B;AACjG,QAAO,MACN,OAAO,KAAK,QAAQ,CAAC,KACnB,QACA,SACC,KACA,OAAO,GACL,MAAM,QAAQ,MACf,CAAC,CACF,CACF,CACD;;AAGF,SAAS,SACR,KACA,QACC;AACD,QAAO,KACN,OAAO;EACN,GAAG,OAAO;EACV,OAAO,SAAS,QAAQ,IAAI,CAAC;EAC7B,CAAC,EACF,WAAW,WAAW;EAAE,GAAG;EAAO,OAAO;EAAK,EAAE,CAChD;;AAMF,MAAa,aAAa,KACzB,QAAQ,EACR,WAAW,UAAU,oBAAoB,MAAM,CAAC,EAChD,MAAM,kBAAkB,CACxB;AACD,MAAa,WAAW;AACxB,MAAa,WAAW,QAAQ;AAChC,MAAa,UAAU,KACtB,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AAQ,SAAS,SAAS,QAAQ,CAAC,CAAC;EACpC,sBAAsB,SAAS,SAAS,QAAQ,CAAC;EACjD,SAAS,SAAS,SAAS,SAAS,CAAC,CAAC;EACtC,CAAC;CACF,iBAAiB;CACjB,CAAC;AAGF,MAAa,oBAAoB,SAAS;CACzC,QAAQ;CACR,MAAM,OAAO,EACZ,OAAO,UACP,CAAC;CACF,CAAC;AAGF,MAAa,oBAAoB,OAAO;CACvC,UAAU,SAAS,QAAQ;CAC3B,UAAU,SAAS,QAAQ;CAC3B,cAAc,SAAS,QAAQ;CAC/B,cAAc,SAAS,QAAQ;CAC/B,OAAO,QAAQ;CACf,OAAO;CACP,CAAC;AAIF,MAAa,yBAAyB,OAAO;CAC5C,OAAO;CAEP,WAAW,KACV,MAAM,IAAI,EACV,OAAO,cAAc,UAAU,SAAS,GAAG,sCAAsC,CACjF;CACD,CAAC;AAIF,MAAa,iBAAiB,OAAO;CACpC,GAAG,kBAAkB;CACrB,kBAAkB,SAAS,uBAAuB;CAClD,CAAC;AAGF,MAAa,wBAAwB,SAAS;CAC7C,MAAM,QAAQ,KAAK;CACnB,OAAO;CACP,aAAa;CACb,UAAU;CACV,CAAC;AAIF,MAAa,wBAAwB,OAAO;CAC3C,SAAS,QAAQ,EAAE;CACnB,QAAQ,QAAQ,WAAW;CAC3B,YAAY,QAAQ,sBAAsB;CAC1C,SAAS;CACT,QAAQ,MAAM,cAAc;CAC5B,UAAU,MAAM,cAAc;CAC9B,CAAC"}
1
+ {"version":3,"file":"internal.mjs","names":[],"sources":["../../../src/transactions/data/internal.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { EnumInputShape, EnumOutputShape } from '@mysten/bcs';\nimport type { GenericSchema, InferInput, InferOutput, ObjectEntries, ObjectSchema } from 'valibot';\nimport {\n\tarray,\n\tboolean,\n\tcheck,\n\tinteger,\n\tlazy,\n\tliteral,\n\tnullable,\n\tnullish,\n\tnumber,\n\tobject,\n\toptional,\n\tpipe,\n\trecord,\n\tstring,\n\ttransform,\n\ttuple,\n\tunion,\n\tunknown,\n\tvariant,\n} from 'valibot';\n\nimport { isValidSuiAddress, normalizeSuiAddress } from '../../utils/sui-types.js';\nimport type { Simplify } from '@mysten/utils';\nimport type { SuiClientTypes } from '../../client/types.js';\n\ntype EnumSchemaInput<T extends Record<string, GenericSchema<any>>> = EnumInputShape<\n\tSimplify<{\n\t\t[K in keyof T]: InferInput<T[K]>;\n\t}>\n>;\n\ntype EnumSchemaOutput<T extends Record<string, GenericSchema<any>>> = EnumOutputShape<\n\tSimplify<{\n\t\t[K in keyof T]: InferOutput<T[K]>;\n\t}>\n>;\n\ntype EnumSchema<T extends Record<string, GenericSchema<any>>> = GenericSchema<\n\tEnumSchemaInput<T>,\n\tEnumSchemaOutput<T>\n>;\n\nexport function safeEnum<T extends Record<string, GenericSchema<any>>>(options: T): EnumSchema<T> {\n\tconst schemas = Object.keys(options).map((key) =>\n\t\tobject({\n\t\t\t[key]: options[key],\n\t\t\t$kind: literal(key),\n\t\t}),\n\t);\n\n\treturn pipe(\n\t\tunknown(),\n\t\tcheck(\n\t\t\t(input) => unsupportedEnumVariantMessage(input, options) === undefined,\n\t\t\t({ input, message }) => unsupportedEnumVariantMessage(input, options) ?? message,\n\t\t),\n\t\ttransform(addMissingEnumKind),\n\t\tvariant('$kind', schemas),\n\t) as unknown as EnumSchema<T>;\n}\n\nfunction getEnumKind(input: unknown) {\n\tif (typeof input !== 'object' || input === null) return null;\n\tif ('$kind' in input && typeof input.$kind === 'string') return input.$kind;\n\n\treturn Object.keys(input).find((key) => key !== '$kind') ?? null;\n}\n\nfunction addMissingEnumKind(input: unknown) {\n\tif (typeof input !== 'object' || input === null || '$kind' in input) return input;\n\n\tconst kind = getEnumKind(input);\n\treturn kind === null ? input : { ...input, $kind: kind };\n}\n\nfunction unsupportedEnumVariantMessage(\n\tinput: unknown,\n\toptions: Record<string, GenericSchema<any>>,\n) {\n\tconst kind = getEnumKind(input);\n\tif (kind === null || Object.hasOwn(options, kind)) return undefined;\n\n\tconst expected = Object.keys(options)\n\t\t.map((key) => `\"${key}\"`)\n\t\t.join(', ');\n\treturn `Unsupported enum variant \"${kind}\". Expected one of: ${expected}.`;\n}\n\nfunction withKind<K extends string, TEntries extends ObjectEntries>(\n\tkey: K,\n\tschema: ObjectSchema<TEntries, undefined>,\n) {\n\treturn pipe(\n\t\tobject({\n\t\t\t...schema.entries,\n\t\t\t$kind: optional(literal(key)),\n\t\t}),\n\t\ttransform((value) => ({ ...value, $kind: key })),\n\t) as GenericSchema<\n\t\tSimplify<InferInput<ObjectSchema<TEntries, undefined>> & { $kind?: K }>,\n\t\tSimplify<InferOutput<ObjectSchema<TEntries, undefined>> & { $kind: K }>\n\t>;\n}\n\nexport const SuiAddress = pipe(\n\tstring(),\n\ttransform((value) => normalizeSuiAddress(value)),\n\tcheck(isValidSuiAddress),\n);\nexport const ObjectID = SuiAddress;\nexport const BCSBytes = string();\nexport const JsonU64 = pipe(\n\tunion([string(), pipe(number(), integer())]),\n\n\tcheck((val) => {\n\t\ttry {\n\t\t\tBigInt(val);\n\t\t\treturn BigInt(val) >= 0 && BigInt(val) <= 18446744073709551615n;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, 'Invalid u64'),\n);\n\nexport const U32 = pipe(\n\tnumber(),\n\tinteger(),\n\tcheck((val) => val >= 0 && val < 2 ** 32, 'Invalid u32'),\n);\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/base_types.rs#L138\n// Implemented as a tuple in rust\nexport const ObjectRefSchema = object({\n\tobjectId: SuiAddress,\n\tversion: JsonU64,\n\tdigest: string(),\n});\nexport type ObjectRef = InferOutput<typeof ObjectRefSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L690-L702\nexport const ArgumentSchema = union([\n\twithKind('GasCoin', object({ GasCoin: literal(true) })),\n\twithKind(\n\t\t'Input',\n\t\tobject({\n\t\t\tInput: pipe(number(), integer()),\n\t\t\ttype: optional(union([literal('pure'), literal('object'), literal('withdrawal')])),\n\t\t}),\n\t),\n\twithKind('Result', object({ Result: pipe(number(), integer()) })),\n\twithKind(\n\t\t'NestedResult',\n\t\tobject({ NestedResult: tuple([pipe(number(), integer()), pipe(number(), integer())]) }),\n\t),\n]);\n\nexport type Argument = InferOutput<typeof ArgumentSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L1387-L1392\nexport const GasDataSchema = object({\n\tbudget: nullable(JsonU64),\n\tprice: nullable(JsonU64),\n\towner: nullable(SuiAddress),\n\tpayment: nullable(array(ObjectRefSchema)),\n});\nexport type GasData = InferOutput<typeof GasDataSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/external-crates/move/crates/move-core-types/src/language_storage.rs#L140-L147\nexport const StructTagSchema = object({\n\taddress: string(),\n\tmodule: string(),\n\tname: string(),\n\t// type_params in rust, should be updated to use camelCase\n\ttypeParams: array(string()),\n});\nexport type StructTag = InferOutput<typeof StructTagSchema>;\n\nexport const OpenSignatureBodySchema: GenericSchema<SuiClientTypes.OpenSignatureBody> = union([\n\tobject({ $kind: literal('address') }),\n\tobject({ $kind: literal('bool') }),\n\tobject({ $kind: literal('u8') }),\n\tobject({ $kind: literal('u16') }),\n\tobject({ $kind: literal('u32') }),\n\tobject({ $kind: literal('u64') }),\n\tobject({ $kind: literal('u128') }),\n\tobject({ $kind: literal('u256') }),\n\tobject({ $kind: literal('unknown') }),\n\tobject({ $kind: literal('vector'), vector: lazy(() => OpenSignatureBodySchema) }),\n\tobject({\n\t\t$kind: literal('datatype'),\n\t\tdatatype: object({\n\t\t\ttypeName: string(),\n\t\t\ttypeParameters: array(lazy(() => OpenSignatureBodySchema)),\n\t\t}),\n\t}),\n\tobject({ $kind: literal('typeParameter'), index: pipe(number(), integer()) }),\n]);\n\nexport const OpenSignatureSchema = object({\n\treference: nullable(union([literal('mutable'), literal('immutable'), literal('unknown')])),\n\tbody: OpenSignatureBodySchema,\n});\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L707-L718\nconst ProgrammableMoveCallSchema = object({\n\tpackage: ObjectID,\n\tmodule: string(),\n\tfunction: string(),\n\t// snake case in rust\n\ttypeArguments: array(string()),\n\targuments: array(ArgumentSchema),\n\t_argumentTypes: optional(nullable(array(OpenSignatureSchema))),\n});\nexport type ProgrammableMoveCall = InferOutput<typeof ProgrammableMoveCallSchema>;\n\nexport const $Intent = object({\n\tname: string(),\n\tinputs: record(string(), union([ArgumentSchema, array(ArgumentSchema)])),\n\tdata: record(string(), unknown()),\n});\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L657-L685\nexport const CommandSchema = safeEnum({\n\tMoveCall: ProgrammableMoveCallSchema,\n\tTransferObjects: object({\n\t\tobjects: array(ArgumentSchema),\n\t\taddress: ArgumentSchema,\n\t}),\n\tSplitCoins: object({\n\t\tcoin: ArgumentSchema,\n\t\tamounts: array(ArgumentSchema),\n\t}),\n\tMergeCoins: object({\n\t\tdestination: ArgumentSchema,\n\t\tsources: array(ArgumentSchema),\n\t}),\n\tPublish: object({\n\t\tmodules: array(BCSBytes),\n\t\tdependencies: array(ObjectID),\n\t}),\n\tMakeMoveVec: object({\n\t\ttype: nullable(string()),\n\t\telements: array(ArgumentSchema),\n\t}),\n\tUpgrade: object({\n\t\tmodules: array(BCSBytes),\n\t\tdependencies: array(ObjectID),\n\t\tpackage: ObjectID,\n\t\tticket: ArgumentSchema,\n\t}),\n\t$Intent,\n});\n\nexport type Command<Arg = Argument> = EnumOutputShape<{\n\tMoveCall: {\n\t\tpackage: string;\n\t\tmodule: string;\n\t\tfunction: string;\n\t\ttypeArguments: string[];\n\t\targuments: Arg[];\n\t\t_argumentTypes?: SuiClientTypes.OpenSignature[] | null;\n\t};\n\tTransferObjects: {\n\t\tobjects: Arg[];\n\t\taddress: Arg;\n\t};\n\tSplitCoins: {\n\t\tcoin: Arg;\n\t\tamounts: Arg[];\n\t};\n\tMergeCoins: {\n\t\tdestination: Arg;\n\t\tsources: Arg[];\n\t};\n\tPublish: {\n\t\tmodules: string[];\n\t\tdependencies: string[];\n\t};\n\tMakeMoveVec: {\n\t\ttype: string | null;\n\t\telements: Arg[];\n\t};\n\tUpgrade: {\n\t\tmodules: string[];\n\t\tdependencies: string[];\n\t\tpackage: string;\n\t\tticket: Arg;\n\t};\n\t$Intent: {\n\t\tname: string;\n\t\tinputs: Record<string, Argument | Argument[]>;\n\t\tdata: Record<string, unknown>;\n\t};\n}>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L102-L114\nexport const ObjectArgSchema = safeEnum({\n\tImmOrOwnedObject: ObjectRefSchema,\n\tSharedObject: object({\n\t\tobjectId: ObjectID,\n\t\t// snake case in rust\n\t\tinitialSharedVersion: JsonU64,\n\t\tmutable: boolean(),\n\t}),\n\tReceiving: ObjectRefSchema,\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ReservationSchema = safeEnum({\n\tMaxAmountU64: JsonU64,\n});\nexport type Reservation = InferOutput<typeof ReservationSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawalTypeArgSchema = safeEnum({\n\tBalance: string(),\n});\nexport type WithdrawalTypeArg = InferOutput<typeof WithdrawalTypeArgSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawFromSchema = safeEnum({\n\tSender: literal(true),\n\tSponsor: literal(true),\n\tSenderAllowance: object({\n\t\tfunder: SuiAddress,\n\t\tallowance: ObjectID,\n\t}),\n});\nexport type WithdrawFrom = InferOutput<typeof WithdrawFromSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const FundsWithdrawalArgSchema = object({\n\treservation: ReservationSchema,\n\ttypeArg: WithdrawalTypeArgSchema,\n\twithdrawFrom: WithdrawFromSchema,\n});\nexport type FundsWithdrawalArg = InferOutput<typeof FundsWithdrawalArgSchema>;\n\n// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L75-L80\nconst CallArgSchema = safeEnum({\n\tObject: ObjectArgSchema,\n\tPure: object({\n\t\tbytes: BCSBytes,\n\t}),\n\tUnresolvedPure: object({\n\t\tvalue: unknown(),\n\t}),\n\tUnresolvedObject: object({\n\t\tobjectId: ObjectID,\n\t\tversion: optional(nullable(JsonU64)),\n\t\tdigest: optional(nullable(string())),\n\t\tinitialSharedVersion: optional(nullable(JsonU64)),\n\t\tmutable: optional(nullable(boolean())),\n\t}),\n\tFundsWithdrawal: FundsWithdrawalArgSchema,\n});\nexport type CallArg = InferOutput<typeof CallArgSchema>;\n\nexport const NormalizedCallArg = safeEnum({\n\tObject: ObjectArgSchema,\n\tPure: object({\n\t\tbytes: BCSBytes,\n\t}),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ValidDuringSchema = object({\n\tminEpoch: nullable(JsonU64),\n\tmaxEpoch: nullable(JsonU64),\n\tminTimestamp: nullable(JsonU64),\n\tmaxTimestamp: nullable(JsonU64),\n\tchain: string(),\n\tnonce: U32,\n});\nexport type ValidDuring = InferOutput<typeof ValidDuringSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const AllowedProposersSchema = object({\n\tepoch: JsonU64,\n\t// Shared by `setExpiration` and `restore`, so this can only carry the invariant true on both.\n\tproposers: pipe(\n\t\tarray(U32),\n\t\tcheck((proposers) => proposers.length > 0, 'Allowed proposers must not be empty'),\n\t),\n});\nexport type AllowedProposers = InferOutput<typeof AllowedProposersSchema>;\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ValiditySchema = object({\n\t...ValidDuringSchema.entries,\n\tallowedProposers: nullable(AllowedProposersSchema),\n});\nexport type Validity = InferOutput<typeof ValiditySchema>;\n\nexport const TransactionExpiration = safeEnum({\n\tNone: literal(true),\n\tEpoch: JsonU64,\n\tValidDuring: ValidDuringSchema,\n\tValidity: ValiditySchema,\n});\n\nexport type TransactionExpiration = InferOutput<typeof TransactionExpiration>;\n\nexport const TransactionDataSchema = object({\n\tversion: literal(2),\n\tsender: nullish(SuiAddress),\n\texpiration: nullish(TransactionExpiration),\n\tgasData: GasDataSchema,\n\tinputs: array(CallArgSchema),\n\tcommands: array(CommandSchema),\n});\n\nexport type TransactionData = InferOutput<typeof TransactionDataSchema>;\n"],"mappings":";;;;AAgDA,SAAgB,SAAuD,SAA2B;CACjG,MAAM,UAAU,OAAO,KAAK,QAAQ,CAAC,KAAK,QACzC,OAAO;GACL,MAAM,QAAQ;EACf,OAAO,QAAQ,IAAI;EACnB,CAAC,CACF;AAED,QAAO,KACN,SAAS,EACT,OACE,UAAU,8BAA8B,OAAO,QAAQ,KAAK,SAC5D,EAAE,OAAO,cAAc,8BAA8B,OAAO,QAAQ,IAAI,QACzE,EACD,UAAU,mBAAmB,EAC7B,QAAQ,SAAS,QAAQ,CACzB;;AAGF,SAAS,YAAY,OAAgB;AACpC,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,KAAI,WAAW,SAAS,OAAO,MAAM,UAAU,SAAU,QAAO,MAAM;AAEtE,QAAO,OAAO,KAAK,MAAM,CAAC,MAAM,QAAQ,QAAQ,QAAQ,IAAI;;AAG7D,SAAS,mBAAmB,OAAgB;AAC3C,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,MAAO,QAAO;CAE5E,MAAM,OAAO,YAAY,MAAM;AAC/B,QAAO,SAAS,OAAO,QAAQ;EAAE,GAAG;EAAO,OAAO;EAAM;;AAGzD,SAAS,8BACR,OACA,SACC;CACD,MAAM,OAAO,YAAY,MAAM;AAC/B,KAAI,SAAS,QAAQ,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MAAa,wBAAwB,OAAO;CAC3C,SAAS,QAAQ,EAAE;CACnB,QAAQ,QAAQ,WAAW;CAC3B,YAAY,QAAQ,sBAAsB;CAC1C,SAAS;CACT,QAAQ,MAAM,cAAc;CAC5B,UAAU,MAAM,cAAc;CAC9B,CAAC"}
@@ -3,7 +3,8 @@ import { SUI_ADDRESS_LENGTH, isValidStructTag, isValidSuiAddress, isValidSuiObje
3
3
  import { formatAddress, formatDigest, parseToMist, parseToUnits } from "./format.mjs";
4
4
  import { isValidSuiNSName, normalizeSuiNSName } from "./suins.mjs";
5
5
  import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
6
- import { isValidNamedPackage, isValidNamedType } from "./move-registry.mjs";
6
+ import { isValidNamedPackage } from "./named-packages.mjs";
7
+ import { isValidNamedType } from "./move-registry.mjs";
7
8
  import { deriveDynamicFieldID } from "./dynamic-fields.mjs";
8
9
  import { deriveObjectID } from "./derived-objects.mjs";
9
10
  import { fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from "@mysten/bcs";
@@ -1,8 +1,9 @@
1
1
  import { isValidSuiNSName, normalizeSuiNSName } from "./suins.mjs";
2
- import { isValidNamedPackage, isValidNamedType } from "./move-registry.mjs";
2
+ import { isValidNamedPackage } from "./named-packages.mjs";
3
3
  import { SUI_ADDRESS_LENGTH, isValidStructTag, isValidSuiAddress, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiObjectId, parseStructTag } from "./sui-types.mjs";
4
4
  import { normalizeTypeTag } from "../bcs/type-tag-serializer.mjs";
5
5
  import { deriveDynamicFieldID } from "./dynamic-fields.mjs";
6
+ import { isValidNamedType } from "./move-registry.mjs";
6
7
  import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
7
8
  import { formatAddress, formatDigest, parseToMist, parseToUnits } from "./format.mjs";
8
9
  import { deriveObjectID } from "./derived-objects.mjs";
@@ -1,9 +1,10 @@
1
+ import { isValidNamedPackage } from "./named-packages.mjs";
2
+
1
3
  //#region src/utils/move-registry.d.ts
2
- declare const isValidNamedPackage: (name: string) => boolean;
3
4
  /**
4
5
  * Checks if a type contains valid named packages and is a valid Move struct tag.
5
6
  */
6
7
  declare const isValidNamedType: (type: string) => boolean;
7
8
  //#endregion
8
- export { isValidNamedPackage, isValidNamedType };
9
+ export { isValidNamedType };
9
10
  //# sourceMappingURL=move-registry.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"move-registry.d.mts","names":[],"sources":["../../src/utils/move-registry.ts"],"mappings":";cAea,mBAAA,GAAuB,IAAA;AAApC;;;AAAA,cAmBa,gBAAA,GAAoB,IAAA"}
1
+ {"version":3,"file":"move-registry.d.mts","names":[],"sources":["../../src/utils/move-registry.ts"],"mappings":";;;;;AAWA;cAAa,gBAAA,GAAoB,IAAA"}
@@ -1,23 +1,7 @@
1
- import { isValidSuiNSName } from "./suins.mjs";
1
+ import { NAME_SEPARATOR, isValidNamedPackage } from "./named-packages.mjs";
2
2
  import { isValidStructTag } from "./sui-types.mjs";
3
3
 
4
4
  //#region src/utils/move-registry.ts
5
- /** The pattern to find an optionally versioned name */
6
- const NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;
7
- /** The pattern for a valid version number */
8
- const VERSION_REGEX = /^\d+$/;
9
- /** The maximum size for an app */
10
- const MAX_APP_SIZE = 64;
11
- /** The separator for the name */
12
- const NAME_SEPARATOR = "/";
13
- const isValidNamedPackage = (name) => {
14
- const parts = name.split(NAME_SEPARATOR);
15
- if (parts.length < 2 || parts.length > 3) return false;
16
- const [org, app, version] = parts;
17
- if (version !== void 0 && !VERSION_REGEX.test(version)) return false;
18
- if (!isValidSuiNSName(org)) return false;
19
- return NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;
20
- };
21
5
  /**
22
6
  * Checks if a type contains valid named packages and is a valid Move struct tag.
23
7
  */
@@ -28,5 +12,5 @@ const isValidNamedType = (type) => {
28
12
  };
29
13
 
30
14
  //#endregion
31
- export { isValidNamedPackage, isValidNamedType };
15
+ export { isValidNamedType };
32
16
  //# sourceMappingURL=move-registry.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"move-registry.mjs","names":[],"sources":["../../src/utils/move-registry.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isValidSuiNSName } from './suins.js';\nimport { isValidStructTag } from './sui-types.js';\n\n/** The pattern to find an optionally versioned name */\nconst NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;\n/** The pattern for a valid version number */\nconst VERSION_REGEX = /^\\d+$/;\n/** The maximum size for an app */\nconst MAX_APP_SIZE = 64;\n/** The separator for the name */\nconst NAME_SEPARATOR = '/';\n\nexport const isValidNamedPackage = (name: string): boolean => {\n\tconst parts = name.split(NAME_SEPARATOR);\n\t// The name has to have 2 parts (without-version), or 3 parts (with version).\n\tif (parts.length < 2 || parts.length > 3) return false;\n\n\tconst [org, app, version] = parts; // split by {org} {app} {optional version}\n\n\t// If the version exists, it must be a number.\n\tif (version !== undefined && !VERSION_REGEX.test(version)) return false;\n\t// Check if the org is a valid SuiNS name.\n\tif (!isValidSuiNSName(org)) return false;\n\n\t// Check if the app is a valid name.\n\treturn NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;\n};\n\n/**\n * Checks if a type contains valid named packages and is a valid Move struct tag.\n */\nexport const isValidNamedType = (type: string): boolean => {\n\t// split our type by all possible type delimeters.\n\tconst splitType = type.split(/::|<|>|,/);\n\tfor (const t of splitType) {\n\t\tif (t.includes(NAME_SEPARATOR) && !isValidNamedPackage(t)) return false;\n\t}\n\treturn isValidStructTag(type);\n};\n"],"mappings":";;;;;AAOA,MAAM,eAAe;;AAErB,MAAM,gBAAgB;;AAEtB,MAAM,eAAe;;AAErB,MAAM,iBAAiB;AAEvB,MAAa,uBAAuB,SAA0B;CAC7D,MAAM,QAAQ,KAAK,MAAM,eAAe;AAExC,KAAI,MAAM,SAAS,KAAK,MAAM,SAAS,EAAG,QAAO;CAEjD,MAAM,CAAC,KAAK,KAAK,WAAW;AAG5B,KAAI,YAAY,UAAa,CAAC,cAAc,KAAK,QAAQ,CAAE,QAAO;AAElE,KAAI,CAAC,iBAAiB,IAAI,CAAE,QAAO;AAGnC,QAAO,aAAa,KAAK,IAAI,IAAI,IAAI,SAAS;;;;;AAM/C,MAAa,oBAAoB,SAA0B;CAE1D,MAAM,YAAY,KAAK,MAAM,WAAW;AACxC,MAAK,MAAM,KAAK,UACf,KAAI,EAAE,SAAS,eAAe,IAAI,CAAC,oBAAoB,EAAE,CAAE,QAAO;AAEnE,QAAO,iBAAiB,KAAK"}
1
+ {"version":3,"file":"move-registry.mjs","names":[],"sources":["../../src/utils/move-registry.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isValidNamedPackage, NAME_SEPARATOR } from './named-packages.js';\nimport { isValidStructTag } from './sui-types.js';\n\nexport { isValidNamedPackage } from './named-packages.js';\n\n/**\n * Checks if a type contains valid named packages and is a valid Move struct tag.\n */\nexport const isValidNamedType = (type: string): boolean => {\n\t// split our type by all possible type delimeters.\n\tconst splitType = type.split(/::|<|>|,/);\n\tfor (const t of splitType) {\n\t\tif (t.includes(NAME_SEPARATOR) && !isValidNamedPackage(t)) return false;\n\t}\n\treturn isValidStructTag(type);\n};\n"],"mappings":";;;;;;;AAWA,MAAa,oBAAoB,SAA0B;CAE1D,MAAM,YAAY,KAAK,MAAM,WAAW;AACxC,MAAK,MAAM,KAAK,UACf,KAAI,EAAE,SAAS,eAAe,IAAI,CAAC,oBAAoB,EAAE,CAAE,QAAO;AAEnE,QAAO,iBAAiB,KAAK"}
@@ -0,0 +1,5 @@
1
+ //#region src/utils/named-packages.d.ts
2
+ declare const isValidNamedPackage: (name: string) => boolean;
3
+ //#endregion
4
+ export { isValidNamedPackage };
5
+ //# sourceMappingURL=named-packages.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named-packages.d.mts","names":[],"sources":["../../src/utils/named-packages.ts"],"mappings":";cAca,mBAAA,GAAuB,IAAA"}
@@ -0,0 +1,23 @@
1
+ import { isValidSuiNSName } from "./suins.mjs";
2
+
3
+ //#region src/utils/named-packages.ts
4
+ /** The pattern to find an optionally versioned name */
5
+ const NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;
6
+ /** The pattern for a valid version number */
7
+ const VERSION_REGEX = /^\d+$/;
8
+ /** The maximum size for an app */
9
+ const MAX_APP_SIZE = 64;
10
+ /** The separator for the name */
11
+ const NAME_SEPARATOR = "/";
12
+ const isValidNamedPackage = (name) => {
13
+ const parts = name.split(NAME_SEPARATOR);
14
+ if (parts.length < 2 || parts.length > 3) return false;
15
+ const [org, app, version] = parts;
16
+ if (version !== void 0 && !VERSION_REGEX.test(version)) return false;
17
+ if (!isValidSuiNSName(org)) return false;
18
+ return NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;
19
+ };
20
+
21
+ //#endregion
22
+ export { NAME_SEPARATOR, isValidNamedPackage };
23
+ //# sourceMappingURL=named-packages.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named-packages.mjs","names":[],"sources":["../../src/utils/named-packages.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isValidSuiNSName } from './suins.js';\n\n/** The pattern to find an optionally versioned name */\nconst NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;\n/** The pattern for a valid version number */\nconst VERSION_REGEX = /^\\d+$/;\n/** The maximum size for an app */\nconst MAX_APP_SIZE = 64;\n/** The separator for the name */\nexport const NAME_SEPARATOR = '/';\n\nexport const isValidNamedPackage = (name: string): boolean => {\n\tconst parts = name.split(NAME_SEPARATOR);\n\t// The name has to have 2 parts (without-version), or 3 parts (with version).\n\tif (parts.length < 2 || parts.length > 3) return false;\n\n\tconst [org, app, version] = parts; // split by {org} {app} {optional version}\n\n\t// If the version exists, it must be a number.\n\tif (version !== undefined && !VERSION_REGEX.test(version)) return false;\n\t// Check if the org is a valid SuiNS name.\n\tif (!isValidSuiNSName(org)) return false;\n\n\t// Check if the app is a valid name.\n\treturn NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;\n};\n"],"mappings":";;;;AAMA,MAAM,eAAe;;AAErB,MAAM,gBAAgB;;AAEtB,MAAM,eAAe;;AAErB,MAAa,iBAAiB;AAE9B,MAAa,uBAAuB,SAA0B;CAC7D,MAAM,QAAQ,KAAK,MAAM,eAAe;AAExC,KAAI,MAAM,SAAS,KAAK,MAAM,SAAS,EAAG,QAAO;CAEjD,MAAM,CAAC,KAAK,KAAK,WAAW;AAG5B,KAAI,YAAY,UAAa,CAAC,cAAc,KAAK,QAAQ,CAAE,QAAO;AAElE,KAAI,CAAC,iBAAiB,IAAI,CAAE,QAAO;AAGnC,QAAO,aAAa,KAAK,IAAI,IAAI,IAAI,SAAS"}
@@ -1,4 +1,4 @@
1
- import { isValidNamedPackage } from "./move-registry.mjs";
1
+ import { isValidNamedPackage } from "./named-packages.mjs";
2
2
  import { fromBase58, splitGenericParameters } from "@mysten/bcs";
3
3
 
4
4
  //#region src/utils/sui-types.ts
@@ -1 +1 @@
1
- {"version":3,"file":"sui-types.mjs","names":[],"sources":["../../src/utils/sui-types.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase58, splitGenericParameters } from '@mysten/bcs';\n\nimport { isValidNamedPackage } from './move-registry.js';\n\nconst TX_DIGEST_LENGTH = 32;\n\n/** Returns whether the tx digest is valid based on the serialization format */\nexport function isValidTransactionDigest(value: string): value is string {\n\ttry {\n\t\tconst buffer = fromBase58(value);\n\t\treturn buffer.length === TX_DIGEST_LENGTH;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// TODO - can we automatically sync this with rust length definition?\n// Source of truth is\n// https://github.com/MystenLabs/sui/blob/acb2b97ae21f47600e05b0d28127d88d0725561d/crates/sui-types/src/base_types.rs#L67\n// which uses the Move account address length\n// https://github.com/move-language/move/blob/67ec40dc50c66c34fd73512fcc412f3b68d67235/language/move-core/types/src/account_address.rs#L23 .\n\nexport const SUI_ADDRESS_LENGTH = 32;\nexport function isValidSuiAddress(value: string): value is string {\n\treturn isHex(value) && getHexByteLength(value) === SUI_ADDRESS_LENGTH;\n}\n\nexport function isValidSuiObjectId(value: string): boolean {\n\treturn isValidSuiAddress(value);\n}\n\nconst MOVE_IDENTIFIER_REGEX = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nexport function isValidMoveIdentifier(name: string): boolean {\n\treturn MOVE_IDENTIFIER_REGEX.test(name);\n}\n\nconst PRIMITIVE_TYPE_TAGS = [\n\t'bool',\n\t'u8',\n\t'u16',\n\t'u32',\n\t'u64',\n\t'u128',\n\t'u256',\n\t'address',\n\t'signer',\n];\n\nconst VECTOR_TYPE_REGEX = /^vector<(.+)>$/;\n\nfunction isValidTypeTag(type: string): boolean {\n\tif (PRIMITIVE_TYPE_TAGS.includes(type)) return true;\n\n\tconst vectorMatch = type.match(VECTOR_TYPE_REGEX);\n\tif (vectorMatch) return isValidTypeTag(vectorMatch[1]);\n\n\tif (type.includes('::')) return isValidStructTag(type);\n\n\treturn false;\n}\n\nfunction isValidParsedStructTag(tag: StructTag): boolean {\n\tif (!isValidSuiAddress(tag.address) && !isValidNamedPackage(tag.address)) {\n\t\treturn false;\n\t}\n\n\tif (!isValidMoveIdentifier(tag.module) || !isValidMoveIdentifier(tag.name)) {\n\t\treturn false;\n\t}\n\n\treturn tag.typeParams.every((param) => {\n\t\tif (typeof param === 'string') {\n\t\t\treturn isValidTypeTag(param);\n\t\t}\n\t\treturn isValidParsedStructTag(param);\n\t});\n}\n\nexport function isValidStructTag(type: string): boolean {\n\ttry {\n\t\tconst tag = parseStructTag(type);\n\t\treturn isValidParsedStructTag(tag);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport type StructTag = {\n\taddress: string;\n\tmodule: string;\n\tname: string;\n\ttypeParams: (string | StructTag)[];\n};\n\nfunction parseTypeTag(type: string): string | StructTag {\n\tif (type.startsWith('vector<')) {\n\t\tif (!type.endsWith('>')) {\n\t\t\tthrow new Error(`Invalid type tag: ${type}`);\n\t\t}\n\t\tconst inner = type.slice(7, -1);\n\t\tif (!inner) {\n\t\t\tthrow new Error(`Invalid type tag: ${type}`);\n\t\t}\n\t\tconst parsed = parseTypeTag(inner);\n\t\tif (typeof parsed === 'string') {\n\t\t\treturn `vector<${parsed}>`;\n\t\t}\n\t\treturn `vector<${normalizeStructTag(parsed)}>`;\n\t}\n\n\tif (!type.includes('::')) return type;\n\n\treturn parseStructTag(type);\n}\n\nexport function parseStructTag(type: string): StructTag {\n\tconst parts = type.split('::');\n\n\tif (parts.length < 3) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst [address, module] = parts;\n\n\tif (!address || !module) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst isMvrPackage = isValidNamedPackage(address);\n\n\tconst rest = type.slice(address.length + module.length + 4);\n\tconst name = rest.includes('<') ? rest.slice(0, rest.indexOf('<')) : rest;\n\n\tif (!name || (rest.includes('<') && !rest.endsWith('>'))) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst typeParams = rest.includes('<')\n\t\t? splitGenericParameters(rest.slice(rest.indexOf('<') + 1, rest.lastIndexOf('>'))).map(\n\t\t\t\t(typeParam) => parseTypeTag(typeParam.trim()),\n\t\t\t)\n\t\t: [];\n\n\treturn {\n\t\taddress: isMvrPackage ? address : normalizeSuiAddress(address),\n\t\tmodule,\n\t\tname,\n\t\ttypeParams,\n\t};\n}\n\nexport function normalizeStructTag(type: string | StructTag): string {\n\tif (typeof type === 'string' && type.startsWith('vector<')) {\n\t\tthrow new Error(\n\t\t\t'normalizeStructTag does not support vector types. Use normalizeTypeTag instead.',\n\t\t);\n\t}\n\n\tconst { address, module, name, typeParams } =\n\t\ttypeof type === 'string' ? parseStructTag(type) : type;\n\n\tconst formattedTypeParams =\n\t\ttypeParams?.length > 0\n\t\t\t? `<${typeParams\n\t\t\t\t\t.map((typeParam) =>\n\t\t\t\t\t\ttypeof typeParam === 'string' ? typeParam : normalizeStructTag(typeParam),\n\t\t\t\t\t)\n\t\t\t\t\t.join(',')}>`\n\t\t\t: '';\n\n\treturn `${address}::${module}::${name}${formattedTypeParams}`;\n}\n\n/**\n * Perform the following operations:\n * 1. Make the address lower case\n * 2. Prepend `0x` if the string does not start with `0x`.\n * 3. Add more zeros if the length of the address(excluding `0x`) is less than `SUI_ADDRESS_LENGTH`\n *\n * WARNING: if the address value itself starts with `0x`, e.g., `0x0x`, the default behavior\n * is to treat the first `0x` not as part of the address. The default behavior can be overridden by\n * setting `forceAdd0x` to true\n *\n */\nexport function normalizeSuiAddress(value: string, forceAdd0x: boolean = false): string {\n\tlet address = value.toLowerCase();\n\tif (!forceAdd0x && address.startsWith('0x')) {\n\t\taddress = address.slice(2);\n\t}\n\treturn `0x${address.padStart(SUI_ADDRESS_LENGTH * 2, '0')}`;\n}\n\nexport function normalizeSuiObjectId(value: string, forceAdd0x: boolean = false): string {\n\treturn normalizeSuiAddress(value, forceAdd0x);\n}\n\nfunction isHex(value: string): boolean {\n\treturn /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;\n}\n\nfunction getHexByteLength(value: string): number {\n\treturn /^(0x|0X)/.test(value) ? (value.length - 2) / 2 : value.length / 2;\n}\n"],"mappings":";;;;AAOA,MAAM,mBAAmB;;AAGzB,SAAgB,yBAAyB,OAAgC;AACxE,KAAI;AAEH,SADe,WAAW,MAAM,CAClB,WAAW;SAClB;AACP,SAAO;;;AAUT,MAAa,qBAAqB;AAClC,SAAgB,kBAAkB,OAAgC;AACjE,QAAO,MAAM,MAAM,IAAI,iBAAiB,MAAM,KAAK;;AAGpD,SAAgB,mBAAmB,OAAwB;AAC1D,QAAO,kBAAkB,MAAM;;AAGhC,MAAM,wBAAwB;AAE9B,SAAgB,sBAAsB,MAAuB;AAC5D,QAAO,sBAAsB,KAAK,KAAK;;AAGxC,MAAM,sBAAsB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAM,oBAAoB;AAE1B,SAAS,eAAe,MAAuB;AAC9C,KAAI,oBAAoB,SAAS,KAAK,CAAE,QAAO;CAE/C,MAAM,cAAc,KAAK,MAAM,kBAAkB;AACjD,KAAI,YAAa,QAAO,eAAe,YAAY,GAAG;AAEtD,KAAI,KAAK,SAAS,KAAK,CAAE,QAAO,iBAAiB,KAAK;AAEtD,QAAO;;AAGR,SAAS,uBAAuB,KAAyB;AACxD,KAAI,CAAC,kBAAkB,IAAI,QAAQ,IAAI,CAAC,oBAAoB,IAAI,QAAQ,CACvE,QAAO;AAGR,KAAI,CAAC,sBAAsB,IAAI,OAAO,IAAI,CAAC,sBAAsB,IAAI,KAAK,CACzE,QAAO;AAGR,QAAO,IAAI,WAAW,OAAO,UAAU;AACtC,MAAI,OAAO,UAAU,SACpB,QAAO,eAAe,MAAM;AAE7B,SAAO,uBAAuB,MAAM;GACnC;;AAGH,SAAgB,iBAAiB,MAAuB;AAC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,SAAS,eAAe,UAAU,oBAAoB,QAAQ;EAC9D;EACA;EACA;EACA;;AAGF,SAAgB,mBAAmB,MAAkC;AACpE,KAAI,OAAO,SAAS,YAAY,KAAK,WAAW,UAAU,CACzD,OAAM,IAAI,MACT,kFACA;CAGF,MAAM,EAAE,SAAS,QAAQ,MAAM,eAC9B,OAAO,SAAS,WAAW,eAAe,KAAK,GAAG;AAWnD,QAAO,GAAG,QAAQ,IAAI,OAAO,IAAI,OARhC,YAAY,SAAS,IAClB,IAAI,WACH,KAAK,cACL,OAAO,cAAc,WAAW,YAAY,mBAAmB,UAAU,CACzE,CACA,KAAK,IAAI,CAAC,KACX;;;;;;;;;;;;;AAgBL,SAAgB,oBAAoB,OAAe,aAAsB,OAAe;CACvF,IAAI,UAAU,MAAM,aAAa;AACjC,KAAI,CAAC,cAAc,QAAQ,WAAW,KAAK,CAC1C,WAAU,QAAQ,MAAM,EAAE;AAE3B,QAAO,KAAK,QAAQ,SAAS,qBAAqB,GAAG,IAAI;;AAG1D,SAAgB,qBAAqB,OAAe,aAAsB,OAAe;AACxF,QAAO,oBAAoB,OAAO,WAAW;;AAG9C,SAAS,MAAM,OAAwB;AACtC,QAAO,yBAAyB,KAAK,MAAM,IAAI,MAAM,SAAS,MAAM;;AAGrE,SAAS,iBAAiB,OAAuB;AAChD,QAAO,WAAW,KAAK,MAAM,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,SAAS"}
1
+ {"version":3,"file":"sui-types.mjs","names":[],"sources":["../../src/utils/sui-types.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase58, splitGenericParameters } from '@mysten/bcs';\n\nimport { isValidNamedPackage } from './named-packages.js';\n\nconst TX_DIGEST_LENGTH = 32;\n\n/** Returns whether the tx digest is valid based on the serialization format */\nexport function isValidTransactionDigest(value: string): value is string {\n\ttry {\n\t\tconst buffer = fromBase58(value);\n\t\treturn buffer.length === TX_DIGEST_LENGTH;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// TODO - can we automatically sync this with rust length definition?\n// Source of truth is\n// https://github.com/MystenLabs/sui/blob/acb2b97ae21f47600e05b0d28127d88d0725561d/crates/sui-types/src/base_types.rs#L67\n// which uses the Move account address length\n// https://github.com/move-language/move/blob/67ec40dc50c66c34fd73512fcc412f3b68d67235/language/move-core/types/src/account_address.rs#L23 .\n\nexport const SUI_ADDRESS_LENGTH = 32;\nexport function isValidSuiAddress(value: string): value is string {\n\treturn isHex(value) && getHexByteLength(value) === SUI_ADDRESS_LENGTH;\n}\n\nexport function isValidSuiObjectId(value: string): boolean {\n\treturn isValidSuiAddress(value);\n}\n\nconst MOVE_IDENTIFIER_REGEX = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nexport function isValidMoveIdentifier(name: string): boolean {\n\treturn MOVE_IDENTIFIER_REGEX.test(name);\n}\n\nconst PRIMITIVE_TYPE_TAGS = [\n\t'bool',\n\t'u8',\n\t'u16',\n\t'u32',\n\t'u64',\n\t'u128',\n\t'u256',\n\t'address',\n\t'signer',\n];\n\nconst VECTOR_TYPE_REGEX = /^vector<(.+)>$/;\n\nfunction isValidTypeTag(type: string): boolean {\n\tif (PRIMITIVE_TYPE_TAGS.includes(type)) return true;\n\n\tconst vectorMatch = type.match(VECTOR_TYPE_REGEX);\n\tif (vectorMatch) return isValidTypeTag(vectorMatch[1]);\n\n\tif (type.includes('::')) return isValidStructTag(type);\n\n\treturn false;\n}\n\nfunction isValidParsedStructTag(tag: StructTag): boolean {\n\tif (!isValidSuiAddress(tag.address) && !isValidNamedPackage(tag.address)) {\n\t\treturn false;\n\t}\n\n\tif (!isValidMoveIdentifier(tag.module) || !isValidMoveIdentifier(tag.name)) {\n\t\treturn false;\n\t}\n\n\treturn tag.typeParams.every((param) => {\n\t\tif (typeof param === 'string') {\n\t\t\treturn isValidTypeTag(param);\n\t\t}\n\t\treturn isValidParsedStructTag(param);\n\t});\n}\n\nexport function isValidStructTag(type: string): boolean {\n\ttry {\n\t\tconst tag = parseStructTag(type);\n\t\treturn isValidParsedStructTag(tag);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport type StructTag = {\n\taddress: string;\n\tmodule: string;\n\tname: string;\n\ttypeParams: (string | StructTag)[];\n};\n\nfunction parseTypeTag(type: string): string | StructTag {\n\tif (type.startsWith('vector<')) {\n\t\tif (!type.endsWith('>')) {\n\t\t\tthrow new Error(`Invalid type tag: ${type}`);\n\t\t}\n\t\tconst inner = type.slice(7, -1);\n\t\tif (!inner) {\n\t\t\tthrow new Error(`Invalid type tag: ${type}`);\n\t\t}\n\t\tconst parsed = parseTypeTag(inner);\n\t\tif (typeof parsed === 'string') {\n\t\t\treturn `vector<${parsed}>`;\n\t\t}\n\t\treturn `vector<${normalizeStructTag(parsed)}>`;\n\t}\n\n\tif (!type.includes('::')) return type;\n\n\treturn parseStructTag(type);\n}\n\nexport function parseStructTag(type: string): StructTag {\n\tconst parts = type.split('::');\n\n\tif (parts.length < 3) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst [address, module] = parts;\n\n\tif (!address || !module) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst isMvrPackage = isValidNamedPackage(address);\n\n\tconst rest = type.slice(address.length + module.length + 4);\n\tconst name = rest.includes('<') ? rest.slice(0, rest.indexOf('<')) : rest;\n\n\tif (!name || (rest.includes('<') && !rest.endsWith('>'))) {\n\t\tthrow new Error(`Invalid struct tag: ${type}`);\n\t}\n\n\tconst typeParams = rest.includes('<')\n\t\t? splitGenericParameters(rest.slice(rest.indexOf('<') + 1, rest.lastIndexOf('>'))).map(\n\t\t\t\t(typeParam) => parseTypeTag(typeParam.trim()),\n\t\t\t)\n\t\t: [];\n\n\treturn {\n\t\taddress: isMvrPackage ? address : normalizeSuiAddress(address),\n\t\tmodule,\n\t\tname,\n\t\ttypeParams,\n\t};\n}\n\nexport function normalizeStructTag(type: string | StructTag): string {\n\tif (typeof type === 'string' && type.startsWith('vector<')) {\n\t\tthrow new Error(\n\t\t\t'normalizeStructTag does not support vector types. Use normalizeTypeTag instead.',\n\t\t);\n\t}\n\n\tconst { address, module, name, typeParams } =\n\t\ttypeof type === 'string' ? parseStructTag(type) : type;\n\n\tconst formattedTypeParams =\n\t\ttypeParams?.length > 0\n\t\t\t? `<${typeParams\n\t\t\t\t\t.map((typeParam) =>\n\t\t\t\t\t\ttypeof typeParam === 'string' ? typeParam : normalizeStructTag(typeParam),\n\t\t\t\t\t)\n\t\t\t\t\t.join(',')}>`\n\t\t\t: '';\n\n\treturn `${address}::${module}::${name}${formattedTypeParams}`;\n}\n\n/**\n * Perform the following operations:\n * 1. Make the address lower case\n * 2. Prepend `0x` if the string does not start with `0x`.\n * 3. Add more zeros if the length of the address(excluding `0x`) is less than `SUI_ADDRESS_LENGTH`\n *\n * WARNING: if the address value itself starts with `0x`, e.g., `0x0x`, the default behavior\n * is to treat the first `0x` not as part of the address. The default behavior can be overridden by\n * setting `forceAdd0x` to true\n *\n */\nexport function normalizeSuiAddress(value: string, forceAdd0x: boolean = false): string {\n\tlet address = value.toLowerCase();\n\tif (!forceAdd0x && address.startsWith('0x')) {\n\t\taddress = address.slice(2);\n\t}\n\treturn `0x${address.padStart(SUI_ADDRESS_LENGTH * 2, '0')}`;\n}\n\nexport function normalizeSuiObjectId(value: string, forceAdd0x: boolean = false): string {\n\treturn normalizeSuiAddress(value, forceAdd0x);\n}\n\nfunction isHex(value: string): boolean {\n\treturn /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;\n}\n\nfunction getHexByteLength(value: string): number {\n\treturn /^(0x|0X)/.test(value) ? (value.length - 2) / 2 : value.length / 2;\n}\n"],"mappings":";;;;AAOA,MAAM,mBAAmB;;AAGzB,SAAgB,yBAAyB,OAAgC;AACxE,KAAI;AAEH,SADe,WAAW,MAAM,CAClB,WAAW;SAClB;AACP,SAAO;;;AAUT,MAAa,qBAAqB;AAClC,SAAgB,kBA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mBAAmB,UAAU,CACzE,CACA,KAAK,IAAI,CAAC,KACX;;;;;;;;;;;;;AAgBL,SAAgB,oBAAoB,OAAe,aAAsB,OAAe;CACvF,IAAI,UAAU,MAAM,aAAa;AACjC,KAAI,CAAC,cAAc,QAAQ,WAAW,KAAK,CAC1C,WAAU,QAAQ,MAAM,EAAE;AAE3B,QAAO,KAAK,QAAQ,SAAS,qBAAqB,GAAG,IAAI;;AAG1D,SAAgB,qBAAqB,OAAe,aAAsB,OAAe;AACxF,QAAO,oBAAoB,OAAO,WAAW;;AAG9C,SAAS,MAAM,OAAwB;AACtC,QAAO,yBAAyB,KAAK,MAAM,IAAI,MAAM,SAAS,MAAM;;AAGrE,SAAS,iBAAiB,OAAuB;AAChD,QAAO,WAAW,KAAK,MAAM,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,SAAS"}
package/dist/version.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.31.1";
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.1';\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_bcs1241 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_bcs1241.BcsStruct<{
6
- inputs: _mysten_bcs1241.BcsStruct<{
7
- proofPoints: _mysten_bcs1241.BcsStruct<{
8
- a: _mysten_bcs1241.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_bcs1241.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_bcs1241.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_bcs1241.BcsStruct<{
21
- value: _mysten_bcs1241.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs1241.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_bcs1241.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs1241.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_bcs1241.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs1241.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.1",
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>(
@@ -1,33 +1,10 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { isValidSuiNSName } from './suins.js';
4
+ import { isValidNamedPackage, NAME_SEPARATOR } from './named-packages.js';
5
5
  import { isValidStructTag } from './sui-types.js';
6
6
 
7
- /** The pattern to find an optionally versioned name */
8
- const NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;
9
- /** The pattern for a valid version number */
10
- const VERSION_REGEX = /^\d+$/;
11
- /** The maximum size for an app */
12
- const MAX_APP_SIZE = 64;
13
- /** The separator for the name */
14
- const NAME_SEPARATOR = '/';
15
-
16
- export const isValidNamedPackage = (name: string): boolean => {
17
- const parts = name.split(NAME_SEPARATOR);
18
- // The name has to have 2 parts (without-version), or 3 parts (with version).
19
- if (parts.length < 2 || parts.length > 3) return false;
20
-
21
- const [org, app, version] = parts; // split by {org} {app} {optional version}
22
-
23
- // If the version exists, it must be a number.
24
- if (version !== undefined && !VERSION_REGEX.test(version)) return false;
25
- // Check if the org is a valid SuiNS name.
26
- if (!isValidSuiNSName(org)) return false;
27
-
28
- // Check if the app is a valid name.
29
- return NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;
30
- };
7
+ export { isValidNamedPackage } from './named-packages.js';
31
8
 
32
9
  /**
33
10
  * Checks if a type contains valid named packages and is a valid Move struct tag.
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { isValidSuiNSName } from './suins.js';
5
+
6
+ /** The pattern to find an optionally versioned name */
7
+ const NAME_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/;
8
+ /** The pattern for a valid version number */
9
+ const VERSION_REGEX = /^\d+$/;
10
+ /** The maximum size for an app */
11
+ const MAX_APP_SIZE = 64;
12
+ /** The separator for the name */
13
+ export const NAME_SEPARATOR = '/';
14
+
15
+ export const isValidNamedPackage = (name: string): boolean => {
16
+ const parts = name.split(NAME_SEPARATOR);
17
+ // The name has to have 2 parts (without-version), or 3 parts (with version).
18
+ if (parts.length < 2 || parts.length > 3) return false;
19
+
20
+ const [org, app, version] = parts; // split by {org} {app} {optional version}
21
+
22
+ // If the version exists, it must be a number.
23
+ if (version !== undefined && !VERSION_REGEX.test(version)) return false;
24
+ // Check if the org is a valid SuiNS name.
25
+ if (!isValidSuiNSName(org)) return false;
26
+
27
+ // Check if the app is a valid name.
28
+ return NAME_PATTERN.test(app) && app.length < MAX_APP_SIZE;
29
+ };
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { fromBase58, splitGenericParameters } from '@mysten/bcs';
5
5
 
6
- import { isValidNamedPackage } from './move-registry.js';
6
+ import { isValidNamedPackage } from './named-packages.js';
7
7
 
8
8
  const TX_DIGEST_LENGTH = 32;
9
9
 
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.1';
6
+ export const PACKAGE_VERSION = '2.31.3';