@mysten/sui 2.15.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +3 -0
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/http-transport.mjs +1 -2
- package/dist/jsonRpc/http-transport.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/utils/format.d.mts +5 -1
- package/dist/utils/format.d.mts.map +1 -1
- package/dist/utils/format.mjs +19 -1
- package/dist/utils/format.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/version.mjs +2 -3
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +4 -5
- package/src/client/mvr.ts +12 -0
- package/src/jsonRpc/http-transport.ts +1 -2
- package/src/utils/format.ts +36 -0
- package/src/utils/index.ts +1 -1
- package/src/version.ts +1 -2
- package/docs/bcs.md +0 -131
- package/docs/clients/core.md +0 -616
- package/docs/clients/graphql.md +0 -99
- package/docs/clients/grpc.md +0 -205
- package/docs/clients/index.md +0 -93
- package/docs/clients/json-rpc.md +0 -235
- package/docs/cryptography/keypairs.md +0 -258
- package/docs/cryptography/multisig.md +0 -192
- package/docs/cryptography/passkey.md +0 -111
- package/docs/cryptography/webcrypto-signer.md +0 -81
- package/docs/executors.md +0 -147
- package/docs/faucet.md +0 -26
- package/docs/hello-sui.md +0 -114
- package/docs/index.md +0 -54
- package/docs/install.md +0 -61
- package/docs/llm-docs.md +0 -32
- package/docs/llms-index.md +0 -60
- package/docs/migrations/0.38.md +0 -57
- package/docs/migrations/sui-1.0.md +0 -453
- package/docs/migrations/sui-2.0/agent-prompt.md +0 -42
- package/docs/migrations/sui-2.0/dapp-kit.md +0 -350
- package/docs/migrations/sui-2.0/deepbook-v3.md +0 -33
- package/docs/migrations/sui-2.0/index.md +0 -157
- package/docs/migrations/sui-2.0/json-rpc-migration.md +0 -399
- package/docs/migrations/sui-2.0/kiosk.md +0 -120
- package/docs/migrations/sui-2.0/sdk-maintainers.md +0 -90
- package/docs/migrations/sui-2.0/seal.md +0 -14
- package/docs/migrations/sui-2.0/sui.md +0 -341
- package/docs/migrations/sui-2.0/suins.md +0 -42
- package/docs/migrations/sui-2.0/wallet-builders.md +0 -66
- package/docs/migrations/sui-2.0/walrus.md +0 -41
- package/docs/migrations/sui-2.0/zksend.md +0 -94
- package/docs/plugins.md +0 -255
- package/docs/sdk-building.md +0 -340
- package/docs/transaction-building/basics.md +0 -297
- package/docs/transaction-building/gas.md +0 -62
- package/docs/transaction-building/intents.md +0 -61
- package/docs/transaction-building/offline.md +0 -71
- package/docs/transaction-building/sponsored-transactions.md +0 -22
- package/docs/utils/derived_objects.md +0 -80
- package/docs/utils/index.md +0 -52
- package/docs/zklogin.md +0 -78
- package/src/transactions/__tests__/Transaction.test.ts +0 -184
- package/src/transactions/__tests__/bcs.test.ts +0 -205
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @mysten/sui.js
|
|
2
2
|
|
|
3
|
+
## 2.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e067cf: Validate the new per-package release flow end-to-end across every public @mysten package.
|
|
8
|
+
No functional changes — empty patch bump to force the orchestrator to dispatch every
|
|
9
|
+
release-<pkg>.yml workflow with `dry_run=false` so each package publishes via OIDC trusted
|
|
10
|
+
publishing.
|
|
11
|
+
- Updated dependencies [9e067cf]
|
|
12
|
+
- @mysten/bcs@2.0.4
|
|
13
|
+
- @mysten/utils@0.3.2
|
|
14
|
+
|
|
15
|
+
## 2.16.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 6adc085: Add `parseToUnits` and `parseToMist` balance parsing utilities using pure bigint
|
|
20
|
+
arithmetic.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- b1bf49a: Fix `extractMvrTypes` and `replaceMvrNames` to handle vector and primitive type
|
|
25
|
+
parameters. Previously, these functions passed all string type parameters directly to
|
|
26
|
+
`parseStructTag`, which produced corrupted results for vector types (e.g.,
|
|
27
|
+
`vector<@mvr/demo::baz::Qux>`) and threw on primitives (e.g., `u8`). Vector types are now
|
|
28
|
+
unwrapped and recursed into, and primitive types are passed through unchanged.
|
|
29
|
+
|
|
3
30
|
## 2.15.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
package/dist/bcs/bcs.d.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { TypeTag as TypeTag$1 } from "./types.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_bcs810 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):
|
|
8
|
-
intent:
|
|
9
|
-
scope:
|
|
7
|
+
declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs810.BcsStruct<{
|
|
8
|
+
intent: _mysten_bcs810.BcsStruct<{
|
|
9
|
+
scope: _mysten_bcs810.BcsEnum<{
|
|
10
10
|
TransactionData: null;
|
|
11
11
|
TransactionEffects: null;
|
|
12
12
|
CheckpointSummary: null;
|
|
13
13
|
PersonalMessage: null;
|
|
14
14
|
}, "IntentScope">;
|
|
15
|
-
version:
|
|
15
|
+
version: _mysten_bcs810.BcsEnum<{
|
|
16
16
|
V0: null;
|
|
17
17
|
}, "IntentVersion">;
|
|
18
|
-
appId:
|
|
18
|
+
appId: _mysten_bcs810.BcsEnum<{
|
|
19
19
|
Sui: null;
|
|
20
20
|
}, "AppId">;
|
|
21
21
|
}, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvr.d.mts","names":[],"sources":["../../src/client/mvr.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"mvr.d.mts","names":[],"sources":["../../src/client/mvr.ts"],"mappings":";;;;KAsYY,sBAAA;EACX,QAAA,EAAU,MAAA;EACV,KAAA,EAAO,MAAA;AAAA"}
|
package/dist/client/mvr.mjs
CHANGED
|
@@ -147,6 +147,7 @@ function validateOverrides(overrides) {
|
|
|
147
147
|
*/
|
|
148
148
|
function extractMvrTypes(type, types = /* @__PURE__ */ new Set()) {
|
|
149
149
|
if (typeof type === "string" && !hasMvrName(type)) return types;
|
|
150
|
+
if (typeof type === "string" && type.startsWith("vector<") && type.endsWith(">")) return extractMvrTypes(type.slice(7, -1), types);
|
|
150
151
|
const tag = isStructTag(type) ? type : parseStructTag(type);
|
|
151
152
|
if (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);
|
|
152
153
|
for (const param of tag.typeParams) extractMvrTypes(param, types);
|
|
@@ -157,6 +158,8 @@ function extractMvrTypes(type, types = /* @__PURE__ */ new Set()) {
|
|
|
157
158
|
* based on the supplied type cache.
|
|
158
159
|
*/
|
|
159
160
|
function replaceMvrNames(tag, typeCache) {
|
|
161
|
+
if (typeof tag === "string" && !tag.includes("::")) return tag;
|
|
162
|
+
if (typeof tag === "string" && tag.startsWith("vector<") && tag.endsWith(">")) return `vector<${replaceMvrNames(tag.slice(7, -1), typeCache)}>`;
|
|
160
163
|
const type = isStructTag(tag) ? tag : parseStructTag(tag);
|
|
161
164
|
const cacheHit = typeCache[`${type.address}::${type.module}::${type.name}`];
|
|
162
165
|
return normalizeStructTag({
|
package/dist/client/mvr.mjs.map
CHANGED
|
@@ -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}: SuiClientTypes.MvrResolvePackageOptions): Promise<SuiClientTypes.MvrResolvePackageResponse> {\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 this.#mvrPackageDataLoader.load(name);\n\t\treturn {\n\t\t\tpackage: resolved,\n\t\t};\n\t}\n\n\tasync resolveType({\n\t\ttype,\n\t}: SuiClientTypes.MvrResolveTypeOptions): Promise<SuiClientTypes.MvrResolveTypeResponse> {\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 this.#mvrTypeDataLoader.loadMany(mvrTypes);\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}: SuiClientTypes.MvrResolveOptions): Promise<SuiClientTypes.MvrResolveResponse> {\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 Promise.all([\n\t\t\ttypesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [],\n\t\t\tpackages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : [],\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\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\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\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,Y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AAE;AAC3C,OAAI,CAAC,SAAS,MAAM,QAAQ,YAAY,MACvC,OAAM,IAAI,MAAM,iCAAiC,QAAQ,YAAY,OAAO;AAC7E,WAAQ,YAAY,OAAO,SAAS,MAAM,QAAQ,YAAY,MAAM;;EAGrE,MAAM,KAAK,QAAQ;AACnB,MAAI,CAAC,GAAI;EAET,MAAM,YAAY,GAAG,QAAQ,MAAM,KAAK;EACxC,MAAM,OAAO,UAAU;AAEvB,MAAI,WAAW,KAAK,IAAI,CAAC,SAAS,SAAS,MAC1C,OAAM,IAAI,MAAM,iCAAiC,OAAO;AAGzD,MAAI,WAAW,KAAK,EAAE;AACrB,aAAU,KAAK,SAAS,SAAS,MAAM;AACvC,MAAG,UAAU,UAAU,KAAK,KAAK;;EAGlC,MAAM,QAAQ,GAAG;AACjB,MAAI,CAAC,MAAO;AAEZ,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,OAAI,CAAC,WAAW,MAAM,GAAG,CAAE;AAE3B,OAAI,CAAC,SAAS,MAAM,MAAM,IAAK,OAAM,IAAI,MAAM,iCAAiC,MAAM,KAAK;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"}
|
|
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}: SuiClientTypes.MvrResolvePackageOptions): Promise<SuiClientTypes.MvrResolvePackageResponse> {\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 this.#mvrPackageDataLoader.load(name);\n\t\treturn {\n\t\t\tpackage: resolved,\n\t\t};\n\t}\n\n\tasync resolveType({\n\t\ttype,\n\t}: SuiClientTypes.MvrResolveTypeOptions): Promise<SuiClientTypes.MvrResolveTypeResponse> {\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 this.#mvrTypeDataLoader.loadMany(mvrTypes);\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}: SuiClientTypes.MvrResolveOptions): Promise<SuiClientTypes.MvrResolveResponse> {\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 Promise.all([\n\t\t\ttypesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [],\n\t\t\tpackages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : [],\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\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,C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AAM;AAC9B,OAAI,CAAC,WAAW,QAAQ,YAAY,KAAK,CAAE;AAC3C,OAAI,CAAC,SAAS,MAAM,QAAQ,YAAY,MACvC,OAAM,IAAI,MAAM,iCAAiC,QAAQ,YAAY,OAAO;AAC7E,WAAQ,YAAY,OAAO,SAAS,MAAM,QAAQ,YAAY,MAAM;;EAGrE,MAAM,KAAK,QAAQ;AACnB,MAAI,CAAC,GAAI;EAET,MAAM,YAAY,GAAG,QAAQ,MAAM,KAAK;EACxC,MAAM,OAAO,UAAU;AAEvB,MAAI,WAAW,KAAK,IAAI,CAAC,SAAS,SAAS,MAC1C,OAAM,IAAI,MAAM,iCAAiC,OAAO;AAGzD,MAAI,WAAW,KAAK,EAAE;AACrB,aAAU,KAAK,SAAS,SAAS,MAAM;AACvC,MAAG,UAAU,UAAU,KAAK,KAAK;;EAGlC,MAAM,QAAQ,GAAG;AACjB,MAAI,CAAC,MAAO;AAEZ,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,OAAI,CAAC,WAAW,MAAM,GAAG,CAAE;AAE3B,OAAI,CAAC,SAAS,MAAM,MAAM,IAAK,OAAM,IAAI,MAAM,iCAAiC,MAAM,KAAK;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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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, 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:
|
|
34
|
+
methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
|
|
35
35
|
options: {
|
|
36
|
-
[extensionName: string]:
|
|
36
|
+
[extensionName: string]: _protobuf_ts_runtime1.JsonValue;
|
|
37
37
|
};
|
|
38
38
|
constructor(_transport: RpcTransport);
|
|
39
39
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LookupNameRequest, LookupNameResponse, ReverseLookupNameRequest, ReverseLookupNameResponse } from "./name_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/name_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface INameServiceClient {
|
|
|
23
23
|
declare class NameServiceClient implements INameServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime5.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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/signature_verification_service.client.d.ts
|
|
@@ -21,9 +21,9 @@ interface ISignatureVerificationServiceClient {
|
|
|
21
21
|
declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
|
|
22
22
|
private readonly _transport;
|
|
23
23
|
typeName: string;
|
|
24
|
-
methods:
|
|
24
|
+
methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
|
|
25
25
|
options: {
|
|
26
|
-
[extensionName: string]:
|
|
26
|
+
[extensionName: string]: _protobuf_ts_runtime2.JsonValue;
|
|
27
27
|
};
|
|
28
28
|
constructor(_transport: RpcTransport);
|
|
29
29
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecuteTransactionRequest, ExecuteTransactionResponse, SimulateTransactionRequest, SimulateTransactionResponse } from "./transaction_execution_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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/rpc/v2/transaction_execution_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface ITransactionExecutionServiceClient {
|
|
|
23
23
|
declare class TransactionExecutionServiceClient implements ITransactionExecutionServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime0.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PACKAGE_VERSION
|
|
1
|
+
import { PACKAGE_VERSION } from "../version.mjs";
|
|
2
2
|
import { JsonRpcError, SuiHTTPStatusError } from "./errors.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/jsonRpc/http-transport.ts
|
|
@@ -22,7 +22,6 @@ var JsonRpcHTTPTransport = class {
|
|
|
22
22
|
"Content-Type": "application/json",
|
|
23
23
|
"Client-Sdk-Type": "typescript",
|
|
24
24
|
"Client-Sdk-Version": PACKAGE_VERSION,
|
|
25
|
-
"Client-Target-Api-Version": TARGETED_RPC_VERSION,
|
|
26
25
|
"Client-Request-Method": input.method,
|
|
27
26
|
...this.#options.rpc?.headers
|
|
28
27
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-transport.mjs","names":["#options","#requestId"],"sources":["../../src/jsonRpc/http-transport.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PACKAGE_VERSION
|
|
1
|
+
{"version":3,"file":"http-transport.mjs","names":["#options","#requestId"],"sources":["../../src/jsonRpc/http-transport.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PACKAGE_VERSION } from '../version.js';\nimport { JsonRpcError, SuiHTTPStatusError } from './errors.js';\n\n/**\n * An object defining headers to be passed to the RPC server\n */\nexport type HttpHeaders = { [header: string]: string };\n\nexport interface JsonRpcHTTPTransportOptions {\n\tfetch?: typeof fetch;\n\turl: string;\n\trpc?: {\n\t\theaders?: HttpHeaders;\n\t\turl?: string;\n\t};\n}\n\nexport interface JsonRpcTransportRequestOptions {\n\tmethod: string;\n\tparams: unknown[];\n\tsignal?: AbortSignal;\n}\n\nexport interface JsonRpcTransport {\n\trequest<T = unknown>(input: JsonRpcTransportRequestOptions): Promise<T>;\n}\n\nexport class JsonRpcHTTPTransport implements JsonRpcTransport {\n\t#requestId = 0;\n\t#options: JsonRpcHTTPTransportOptions;\n\n\tconstructor(options: JsonRpcHTTPTransportOptions) {\n\t\tthis.#options = options;\n\t}\n\n\tfetch(input: RequestInfo, init?: RequestInit): Promise<Response> {\n\t\tconst fetchFn = this.#options.fetch ?? fetch;\n\n\t\tif (!fetchFn) {\n\t\t\tthrow new Error(\n\t\t\t\t'The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.',\n\t\t\t);\n\t\t}\n\n\t\treturn fetchFn(input, init);\n\t}\n\n\tasync request<T>(input: JsonRpcTransportRequestOptions): Promise<T> {\n\t\tthis.#requestId += 1;\n\n\t\tconst res = await this.fetch(this.#options.rpc?.url ?? this.#options.url, {\n\t\t\tmethod: 'POST',\n\t\t\tsignal: input.signal,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Client-Sdk-Type': 'typescript',\n\t\t\t\t'Client-Sdk-Version': PACKAGE_VERSION,\n\t\t\t\t'Client-Request-Method': input.method,\n\t\t\t\t...this.#options.rpc?.headers,\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tjsonrpc: '2.0',\n\t\t\t\tid: this.#requestId,\n\t\t\t\tmethod: input.method,\n\t\t\t\tparams: input.params,\n\t\t\t}),\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new SuiHTTPStatusError(\n\t\t\t\t`Unexpected status code: ${res.status}`,\n\t\t\t\tres.status,\n\t\t\t\tres.statusText,\n\t\t\t);\n\t\t}\n\n\t\tconst data = await res.json();\n\n\t\tif ('error' in data && data.error != null) {\n\t\t\tthrow new JsonRpcError(data.error.message, data.error.code);\n\t\t}\n\n\t\treturn data.result;\n\t}\n}\n"],"mappings":";;;;AA8BA,IAAa,uBAAb,MAA8D;CAC7D,aAAa;CACb;CAEA,YAAY,SAAsC;AACjD,QAAKA,UAAW;;CAGjB,MAAM,OAAoB,MAAuC;EAChE,MAAM,UAAU,MAAKA,QAAS,SAAS;AAEvC,MAAI,CAAC,QACJ,OAAM,IAAI,MACT,8HACA;AAGF,SAAO,QAAQ,OAAO,KAAK;;CAG5B,MAAM,QAAW,OAAmD;AACnE,QAAKC,aAAc;EAEnB,MAAM,MAAM,MAAM,KAAK,MAAM,MAAKD,QAAS,KAAK,OAAO,MAAKA,QAAS,KAAK;GACzE,QAAQ;GACR,QAAQ,MAAM;GACd,SAAS;IACR,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,yBAAyB,MAAM;IAC/B,GAAG,MAAKA,QAAS,KAAK;IACtB;GACD,MAAM,KAAK,UAAU;IACpB,SAAS;IACT,IAAI,MAAKC;IACT,QAAQ,MAAM;IACd,QAAQ,MAAM;IACd,CAAC;GACF,CAAC;AAEF,MAAI,CAAC,IAAI,GACR,OAAM,IAAI,mBACT,2BAA2B,IAAI,UAC/B,IAAI,QACJ,IAAI,WACJ;EAGF,MAAM,OAAO,MAAM,IAAI,MAAM;AAE7B,MAAI,WAAW,QAAQ,KAAK,SAAS,KACpC,OAAM,IAAI,aAAa,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK;AAG5D,SAAO,KAAK"}
|
|
@@ -8,7 +8,7 @@ import { createPure } from "./pure.mjs";
|
|
|
8
8
|
import { SignatureWithBytes, Signer } from "../cryptography/keypair.mjs";
|
|
9
9
|
import "../cryptography/index.mjs";
|
|
10
10
|
import { ClientWithCoreApi } from "../client/core.mjs";
|
|
11
|
-
import * as
|
|
11
|
+
import * as _mysten_bcs1111 from "@mysten/bcs";
|
|
12
12
|
import { SerializedBcs } from "@mysten/bcs";
|
|
13
13
|
import { InferInput } from "valibot";
|
|
14
14
|
|
|
@@ -77,7 +77,7 @@ declare class Transaction {
|
|
|
77
77
|
getData(): {
|
|
78
78
|
version: 2;
|
|
79
79
|
sender?: string | null | undefined;
|
|
80
|
-
expiration?:
|
|
80
|
+
expiration?: _mysten_bcs1111.EnumOutputShapeWithKeys<{
|
|
81
81
|
None: true;
|
|
82
82
|
Epoch: string | number;
|
|
83
83
|
ValidDuring: {
|
|
@@ -99,8 +99,8 @@ declare class Transaction {
|
|
|
99
99
|
digest: string;
|
|
100
100
|
}[] | null;
|
|
101
101
|
};
|
|
102
|
-
inputs:
|
|
103
|
-
Object:
|
|
102
|
+
inputs: _mysten_bcs1111.EnumOutputShapeWithKeys<{
|
|
103
|
+
Object: _mysten_bcs1111.EnumOutputShapeWithKeys<{
|
|
104
104
|
ImmOrOwnedObject: {
|
|
105
105
|
objectId: string;
|
|
106
106
|
version: string | number;
|
|
@@ -139,13 +139,13 @@ declare class Transaction {
|
|
|
139
139
|
Balance: string;
|
|
140
140
|
$kind: "Balance";
|
|
141
141
|
};
|
|
142
|
-
withdrawFrom:
|
|
142
|
+
withdrawFrom: _mysten_bcs1111.EnumOutputShapeWithKeys<{
|
|
143
143
|
Sender: true;
|
|
144
144
|
Sponsor: true;
|
|
145
145
|
}, "Sender" | "Sponsor">;
|
|
146
146
|
};
|
|
147
147
|
}, "Pure" | "Object" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
|
|
148
|
-
commands:
|
|
148
|
+
commands: _mysten_bcs1111.EnumOutputShapeWithKeys<{
|
|
149
149
|
MoveCall: {
|
|
150
150
|
package: string;
|
|
151
151
|
module: string;
|