@mysten/sui 1.32.0 → 1.34.0
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 +19 -0
- package/dist/cjs/client/client.d.ts +13 -12
- package/dist/cjs/client/client.js +189 -48
- package/dist/cjs/client/client.js.map +3 -3
- package/dist/cjs/experimental/cache.d.ts +1 -0
- package/dist/cjs/experimental/cache.js +9 -0
- package/dist/cjs/experimental/cache.js.map +2 -2
- package/dist/cjs/experimental/client.d.ts +2 -1
- package/dist/cjs/experimental/client.js +2 -1
- package/dist/cjs/experimental/client.js.map +2 -2
- package/dist/cjs/experimental/core.d.ts +6 -0
- package/dist/cjs/experimental/core.js +9 -2
- package/dist/cjs/experimental/core.js.map +2 -2
- package/dist/cjs/experimental/index.d.ts +2 -2
- package/dist/cjs/experimental/index.js.map +2 -2
- package/dist/cjs/experimental/mvr.d.ts +42 -0
- package/dist/cjs/experimental/mvr.js +355 -0
- package/dist/cjs/experimental/mvr.js.map +7 -0
- package/dist/cjs/experimental/transports/graphql.d.ts +4 -1
- package/dist/cjs/experimental/transports/graphql.js +5 -2
- package/dist/cjs/experimental/transports/graphql.js.map +2 -2
- package/dist/cjs/experimental/transports/json-rpc-resolver.d.ts +1 -1
- package/dist/cjs/experimental/transports/json-rpc-resolver.js +2 -2
- package/dist/cjs/experimental/transports/json-rpc-resolver.js.map +2 -2
- package/dist/cjs/experimental/transports/jsonRPC.d.ts +4 -1
- package/dist/cjs/experimental/transports/jsonRPC.js +15 -11
- package/dist/cjs/experimental/transports/jsonRPC.js.map +3 -3
- package/dist/cjs/experimental/transports/utils.js +2 -2
- package/dist/cjs/experimental/transports/utils.js.map +2 -2
- package/dist/cjs/experimental/types.d.ts +42 -0
- package/dist/cjs/experimental/types.js.map +1 -1
- package/dist/cjs/graphql/client.d.ts +2 -1
- package/dist/cjs/graphql/client.js +6 -2
- package/dist/cjs/graphql/client.js.map +2 -2
- package/dist/cjs/transactions/index.d.ts +4 -1
- package/dist/cjs/transactions/index.js +2 -2
- package/dist/cjs/transactions/index.js.map +3 -3
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.d.ts +4 -3
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +38 -90
- package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js.map +3 -3
- package/dist/cjs/transactions/resolve.js +8 -4
- package/dist/cjs/transactions/resolve.js.map +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/client/client.d.ts +13 -12
- package/dist/esm/client/client.js +188 -47
- package/dist/esm/client/client.js.map +2 -2
- package/dist/esm/experimental/cache.d.ts +1 -0
- package/dist/esm/experimental/cache.js +9 -0
- package/dist/esm/experimental/cache.js.map +2 -2
- package/dist/esm/experimental/client.d.ts +2 -1
- package/dist/esm/experimental/client.js +2 -1
- package/dist/esm/experimental/client.js.map +2 -2
- package/dist/esm/experimental/core.d.ts +6 -0
- package/dist/esm/experimental/core.js +9 -2
- package/dist/esm/experimental/core.js.map +2 -2
- package/dist/esm/experimental/index.d.ts +2 -2
- package/dist/esm/experimental/index.js.map +2 -2
- package/dist/esm/experimental/mvr.d.ts +42 -0
- package/dist/esm/experimental/mvr.js +340 -0
- package/dist/esm/experimental/mvr.js.map +7 -0
- package/dist/esm/experimental/transports/graphql.d.ts +4 -1
- package/dist/esm/experimental/transports/graphql.js +5 -2
- package/dist/esm/experimental/transports/graphql.js.map +2 -2
- package/dist/esm/experimental/transports/json-rpc-resolver.d.ts +1 -1
- package/dist/esm/experimental/transports/json-rpc-resolver.js +2 -2
- package/dist/esm/experimental/transports/json-rpc-resolver.js.map +2 -2
- package/dist/esm/experimental/transports/jsonRPC.d.ts +4 -1
- package/dist/esm/experimental/transports/jsonRPC.js +13 -9
- package/dist/esm/experimental/transports/jsonRPC.js.map +3 -3
- package/dist/esm/experimental/transports/utils.js +1 -1
- package/dist/esm/experimental/transports/utils.js.map +1 -1
- package/dist/esm/experimental/types.d.ts +42 -0
- package/dist/esm/graphql/client.d.ts +2 -1
- package/dist/esm/graphql/client.js +6 -2
- package/dist/esm/graphql/client.js.map +2 -2
- package/dist/esm/transactions/index.d.ts +4 -1
- package/dist/esm/transactions/index.js.map +2 -2
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.d.ts +4 -3
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +37 -95
- package/dist/esm/transactions/plugins/NamedPackagesPlugin.js.map +3 -3
- package/dist/esm/transactions/resolve.js +8 -4
- package/dist/esm/transactions/resolve.js.map +2 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/client/client.ts +239 -60
- package/src/experimental/cache.ts +14 -0
- package/src/experimental/client.ts +3 -1
- package/src/experimental/core.ts +18 -0
- package/src/experimental/index.ts +2 -1
- package/src/experimental/mvr.ts +477 -0
- package/src/experimental/transports/graphql.ts +8 -2
- package/src/experimental/transports/json-rpc-resolver.ts +1 -1
- package/src/experimental/transports/jsonRPC.ts +13 -6
- package/src/experimental/transports/utils.ts +1 -1
- package/src/experimental/types.ts +58 -0
- package/src/graphql/client.ts +7 -1
- package/src/transactions/index.ts +5 -1
- package/src/transactions/plugins/NamedPackagesPlugin.ts +46 -120
- package/src/transactions/resolve.ts +12 -5
- package/src/version.ts +1 -1
- package/dist/cjs/transactions/plugins/utils.d.ts +0 -31
- package/dist/cjs/transactions/plugins/utils.js +0 -144
- package/dist/cjs/transactions/plugins/utils.js.map +0 -7
- package/dist/esm/transactions/plugins/utils.d.ts +0 -31
- package/dist/esm/transactions/plugins/utils.js +0 -124
- package/dist/esm/transactions/plugins/utils.js.map +0 -7
- package/src/transactions/plugins/utils.ts +0 -215
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ClientCache } from "./cache.js";
|
|
2
2
|
class Experimental_BaseClient {
|
|
3
|
-
constructor({ network }) {
|
|
3
|
+
constructor({ network, base }) {
|
|
4
4
|
this.cache = new ClientCache();
|
|
5
5
|
this.network = network;
|
|
6
|
+
this.base = base ?? this;
|
|
6
7
|
}
|
|
7
8
|
$extend(...registrations) {
|
|
8
9
|
return Object.create(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/experimental/client.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n/* eslint-disable @typescript-eslint/ban-types */\n\nimport type { Simplify, UnionToIntersection } from '@mysten/utils';\nimport { ClientCache } from './cache.js';\nimport type { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSuiClientRegistration,\n} from './types.js';\n\nexport abstract class Experimental_BaseClient {\n\tnetwork: Experimental_SuiClientTypes.Network;\n\tcache = new ClientCache();\n\n\tconstructor({ network }: Experimental_SuiClientTypes.SuiClientOptions) {\n\t\tthis.network = network;\n\t}\n\n\tabstract core: Experimental_CoreClient;\n\n\t$extend<const Registrations extends SuiClientRegistration<this>[]>(\n\t\t...registrations: Registrations\n\t) {\n\t\treturn Object.create(\n\t\t\tthis,\n\t\t\tObject.fromEntries(\n\t\t\t\tregistrations.map((registration) => {\n\t\t\t\t\tif ('experimental_asClientExtension' in registration) {\n\t\t\t\t\t\tconst { name, register } = registration.experimental_asClientExtension();\n\t\t\t\t\t\treturn [name, { value: register(this) }];\n\t\t\t\t\t}\n\t\t\t\t\treturn [registration.name, { value: registration.register(this) }];\n\t\t\t\t}),\n\t\t\t),\n\t\t) as ClientWithExtensions<\n\t\t\tSimplify<\n\t\t\t\tUnionToIntersection<\n\t\t\t\t\t{\n\t\t\t\t\t\t[K in keyof Registrations]: Registrations[K] extends SuiClientRegistration<\n\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\tinfer Name extends string,\n\t\t\t\t\t\t\tinfer Extension\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t[K2 in Name]: Extension;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: never;\n\t\t\t\t\t}[number]\n\t\t\t\t>\n\t\t\t>,\n\t\t\tthis\n\t\t>;\n\t}\n}\n"],
|
|
5
|
-
"mappings": "AAKA,SAAS,mBAAmB;AAQrB,MAAe,wBAAwB;AAAA,
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n/* eslint-disable @typescript-eslint/ban-types */\n\nimport type { Simplify, UnionToIntersection } from '@mysten/utils';\nimport { ClientCache } from './cache.js';\nimport type { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSuiClientRegistration,\n} from './types.js';\n\nexport abstract class Experimental_BaseClient {\n\tnetwork: Experimental_SuiClientTypes.Network;\n\tcache = new ClientCache();\n\tbase: Experimental_BaseClient;\n\n\tconstructor({ network, base }: Experimental_SuiClientTypes.SuiClientOptions) {\n\t\tthis.network = network;\n\t\tthis.base = base ?? this;\n\t}\n\n\tabstract core: Experimental_CoreClient;\n\n\t$extend<const Registrations extends SuiClientRegistration<this>[]>(\n\t\t...registrations: Registrations\n\t) {\n\t\treturn Object.create(\n\t\t\tthis,\n\t\t\tObject.fromEntries(\n\t\t\t\tregistrations.map((registration) => {\n\t\t\t\t\tif ('experimental_asClientExtension' in registration) {\n\t\t\t\t\t\tconst { name, register } = registration.experimental_asClientExtension();\n\t\t\t\t\t\treturn [name, { value: register(this) }];\n\t\t\t\t\t}\n\t\t\t\t\treturn [registration.name, { value: registration.register(this) }];\n\t\t\t\t}),\n\t\t\t),\n\t\t) as ClientWithExtensions<\n\t\t\tSimplify<\n\t\t\t\tUnionToIntersection<\n\t\t\t\t\t{\n\t\t\t\t\t\t[K in keyof Registrations]: Registrations[K] extends SuiClientRegistration<\n\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\tinfer Name extends string,\n\t\t\t\t\t\t\tinfer Extension\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t[K2 in Name]: Extension;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: never;\n\t\t\t\t\t}[number]\n\t\t\t\t>\n\t\t\t>,\n\t\t\tthis\n\t\t>;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,mBAAmB;AAQrB,MAAe,wBAAwB;AAAA,EAK7C,YAAY,EAAE,SAAS,KAAK,GAAiD;AAH7E,iBAAQ,IAAI,YAAY;AAIvB,SAAK,UAAU;AACf,SAAK,OAAO,QAAQ;AAAA,EACrB;AAAA,EAIA,WACI,eACF;AACD,WAAO,OAAO;AAAA,MACb;AAAA,MACA,OAAO;AAAA,QACN,cAAc,IAAI,CAAC,iBAAiB;AACnC,cAAI,oCAAoC,cAAc;AACrD,kBAAM,EAAE,MAAM,SAAS,IAAI,aAAa,+BAA+B;AACvE,mBAAO,CAAC,MAAM,EAAE,OAAO,SAAS,IAAI,EAAE,CAAC;AAAA,UACxC;AACA,iBAAO,CAAC,aAAa,MAAM,EAAE,OAAO,aAAa,SAAS,IAAI,EAAE,CAAC;AAAA,QAClE,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EAkBD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,8 +4,14 @@ import type { ClientWithExtensions, Experimental_SuiClientTypes } from './types.
|
|
|
4
4
|
export type ClientWithCoreApi = ClientWithExtensions<{
|
|
5
5
|
core: Experimental_CoreClient;
|
|
6
6
|
}>;
|
|
7
|
+
export interface Experimental_CoreClientOptions extends Experimental_SuiClientTypes.SuiClientOptions {
|
|
8
|
+
base: Experimental_BaseClient;
|
|
9
|
+
mvr?: Experimental_SuiClientTypes.MvrOptions;
|
|
10
|
+
}
|
|
7
11
|
export declare abstract class Experimental_CoreClient extends Experimental_BaseClient implements Experimental_SuiClientTypes.TransportMethods {
|
|
8
12
|
core: this;
|
|
13
|
+
mvr: Experimental_SuiClientTypes.MvrMethods;
|
|
14
|
+
constructor(options: Experimental_CoreClientOptions);
|
|
9
15
|
abstract getObjects(options: Experimental_SuiClientTypes.GetObjectsOptions): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;
|
|
10
16
|
getObject(options: Experimental_SuiClientTypes.GetObjectOptions): Promise<Experimental_SuiClientTypes.GetObjectResponse>;
|
|
11
17
|
abstract getCoins(options: Experimental_SuiClientTypes.GetCoinsOptions): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;
|
|
@@ -2,10 +2,17 @@ import { TypeTagSerializer } from "../bcs/type-tag-serializer.js";
|
|
|
2
2
|
import { deriveDynamicFieldID } from "../utils/dynamic-fields.js";
|
|
3
3
|
import { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from "../utils/sui-types.js";
|
|
4
4
|
import { Experimental_BaseClient } from "./client.js";
|
|
5
|
+
import { MvrClient } from "./mvr.js";
|
|
5
6
|
class Experimental_CoreClient extends Experimental_BaseClient {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
8
9
|
this.core = this;
|
|
10
|
+
this.mvr = new MvrClient({
|
|
11
|
+
cache: this.base.cache.scope("core"),
|
|
12
|
+
url: options.mvr?.url,
|
|
13
|
+
pageSize: options.mvr?.pageSize,
|
|
14
|
+
overrides: options.mvr?.overrides
|
|
15
|
+
});
|
|
9
16
|
}
|
|
10
17
|
async getObject(options) {
|
|
11
18
|
const { objectId } = options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/experimental/core.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeTagSerializer } from '../bcs/type-tag-serializer.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\nimport { deriveDynamicFieldID } from '../utils/dynamic-fields.js';\nimport { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport { Experimental_BaseClient } from './client.js';\nimport type { ClientWithExtensions, Experimental_SuiClientTypes } from './types.js';\n\nexport type ClientWithCoreApi = ClientWithExtensions<{\n\tcore: Experimental_CoreClient;\n}>;\n\nexport abstract class Experimental_CoreClient\n\textends Experimental_BaseClient\n\timplements Experimental_SuiClientTypes.TransportMethods\n{\n\tcore = this;\n\n\tabstract getObjects(\n\t\toptions: Experimental_SuiClientTypes.GetObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;\n\n\tasync getObject(\n\t\toptions: Experimental_SuiClientTypes.GetObjectOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectResponse> {\n\t\tconst { objectId } = options;\n\t\tconst {\n\t\t\tobjects: [result],\n\t\t} = await this.getObjects({ objectIds: [objectId], signal: options.signal });\n\t\tif (result instanceof Error) {\n\t\t\tthrow result;\n\t\t}\n\t\treturn { object: result };\n\t}\n\n\tabstract getCoins(\n\t\toptions: Experimental_SuiClientTypes.GetCoinsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;\n\n\tabstract getOwnedObjects(\n\t\toptions: Experimental_SuiClientTypes.GetOwnedObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse>;\n\n\tabstract getBalance(\n\t\toptions: Experimental_SuiClientTypes.GetBalanceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetBalanceResponse>;\n\n\tabstract getAllBalances(\n\t\toptions: Experimental_SuiClientTypes.GetAllBalancesOptions,\n\t): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse>;\n\n\tabstract getTransaction(\n\t\toptions: Experimental_SuiClientTypes.GetTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.GetTransactionResponse>;\n\n\tabstract executeTransaction(\n\t\toptions: Experimental_SuiClientTypes.ExecuteTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse>;\n\n\tabstract dryRunTransaction(\n\t\toptions: Experimental_SuiClientTypes.DryRunTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;\n\n\tabstract getReferenceGasPrice(\n\t\toptions?: Experimental_SuiClientTypes.GetReferenceGasPriceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;\n\n\tabstract getDynamicFields(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse>;\n\n\tabstract resolveTransactionPlugin(): TransactionPlugin;\n\n\tasync getDynamicField(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldResponse> {\n\t\tconst fieldId = deriveDynamicFieldID(\n\t\t\toptions.parentId,\n\t\t\tTypeTagSerializer.parseFromStr(options.name.type),\n\t\t\toptions.name.bcs,\n\t\t);\n\t\tconst {\n\t\t\tobjects: [fieldObject],\n\t\t} = await this.getObjects({\n\t\t\tobjectIds: [fieldId],\n\t\t\tsignal: options.signal,\n\t\t});\n\n\t\tif (fieldObject instanceof Error) {\n\t\t\tthrow fieldObject;\n\t\t}\n\n\t\tconst fieldType = parseStructTag(fieldObject.type);\n\t\tconst content = await fieldObject.content;\n\n\t\treturn {\n\t\t\tdynamicField: {\n\t\t\t\tid: fieldObject.id,\n\t\t\t\tdigest: fieldObject.digest,\n\t\t\t\tversion: fieldObject.version,\n\t\t\t\ttype: fieldObject.type,\n\t\t\t\tname: {\n\t\t\t\t\ttype:\n\t\t\t\t\t\ttypeof fieldType.typeParams[0] === 'string'\n\t\t\t\t\t\t\t? fieldType.typeParams[0]\n\t\t\t\t\t\t\t: normalizeStructTag(fieldType.typeParams[0]),\n\t\t\t\t\tbcs: options.name.bcs,\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype:\n\t\t\t\t\t\ttypeof fieldType.typeParams[1] === 'string'\n\t\t\t\t\t\t\t? fieldType.typeParams[1]\n\t\t\t\t\t\t\t: normalizeStructTag(fieldType.typeParams[1]),\n\t\t\t\t\tbcs: content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync waitForTransaction({\n\t\tsignal,\n\t\ttimeout = 60 * 1000,\n\t\t...input\n\t}: {\n\t\t/** An optional abort signal that can be used to cancel the wait. */\n\t\tsignal?: AbortSignal;\n\t\t/** The amount of time to wait for transaction. Defaults to one minute. */\n\t\ttimeout?: number;\n\t} & Experimental_SuiClientTypes.GetTransactionOptions): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {\n\t\tconst abortSignal = signal\n\t\t\t? AbortSignal.any([AbortSignal.timeout(timeout), signal])\n\t\t\t: AbortSignal.timeout(timeout);\n\n\t\tconst abortPromise = new Promise((_, reject) => {\n\t\t\tabortSignal.addEventListener('abort', () => reject(abortSignal.reason));\n\t\t});\n\n\t\tabortPromise.catch(() => {\n\t\t\t// Swallow unhandled rejections that might be thrown after early return\n\t\t});\n\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\tabortSignal.throwIfAborted();\n\t\t\ttry {\n\t\t\t\treturn await this.getTransaction({\n\t\t\t\t\t...input,\n\t\t\t\t\tsignal: abortSignal,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tawait Promise.race([new Promise((resolve) => setTimeout(resolve, 2_000)), abortPromise]);\n\t\t\t}\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,yBAAyB;AAElC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,gBAAgB,0BAA0B;AACvE,SAAS,+BAA+B;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeTagSerializer } from '../bcs/type-tag-serializer.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\nimport { deriveDynamicFieldID } from '../utils/dynamic-fields.js';\nimport { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport { Experimental_BaseClient } from './client.js';\nimport type { ClientWithExtensions, Experimental_SuiClientTypes } from './types.js';\nimport { MvrClient } from './mvr.js';\n\nexport type ClientWithCoreApi = ClientWithExtensions<{\n\tcore: Experimental_CoreClient;\n}>;\n\nexport interface Experimental_CoreClientOptions\n\textends Experimental_SuiClientTypes.SuiClientOptions {\n\tbase: Experimental_BaseClient;\n\tmvr?: Experimental_SuiClientTypes.MvrOptions;\n}\n\nexport abstract class Experimental_CoreClient\n\textends Experimental_BaseClient\n\timplements Experimental_SuiClientTypes.TransportMethods\n{\n\tcore = this;\n\tmvr: Experimental_SuiClientTypes.MvrMethods;\n\n\tconstructor(options: Experimental_CoreClientOptions) {\n\t\tsuper(options);\n\t\tthis.mvr = new MvrClient({\n\t\t\tcache: this.base.cache.scope('core'),\n\t\t\turl: options.mvr?.url,\n\t\t\tpageSize: options.mvr?.pageSize,\n\t\t\toverrides: options.mvr?.overrides,\n\t\t});\n\t}\n\n\tabstract getObjects(\n\t\toptions: Experimental_SuiClientTypes.GetObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;\n\n\tasync getObject(\n\t\toptions: Experimental_SuiClientTypes.GetObjectOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectResponse> {\n\t\tconst { objectId } = options;\n\t\tconst {\n\t\t\tobjects: [result],\n\t\t} = await this.getObjects({ objectIds: [objectId], signal: options.signal });\n\t\tif (result instanceof Error) {\n\t\t\tthrow result;\n\t\t}\n\t\treturn { object: result };\n\t}\n\n\tabstract getCoins(\n\t\toptions: Experimental_SuiClientTypes.GetCoinsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;\n\n\tabstract getOwnedObjects(\n\t\toptions: Experimental_SuiClientTypes.GetOwnedObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse>;\n\n\tabstract getBalance(\n\t\toptions: Experimental_SuiClientTypes.GetBalanceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetBalanceResponse>;\n\n\tabstract getAllBalances(\n\t\toptions: Experimental_SuiClientTypes.GetAllBalancesOptions,\n\t): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse>;\n\n\tabstract getTransaction(\n\t\toptions: Experimental_SuiClientTypes.GetTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.GetTransactionResponse>;\n\n\tabstract executeTransaction(\n\t\toptions: Experimental_SuiClientTypes.ExecuteTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse>;\n\n\tabstract dryRunTransaction(\n\t\toptions: Experimental_SuiClientTypes.DryRunTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;\n\n\tabstract getReferenceGasPrice(\n\t\toptions?: Experimental_SuiClientTypes.GetReferenceGasPriceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;\n\n\tabstract getDynamicFields(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse>;\n\n\tabstract resolveTransactionPlugin(): TransactionPlugin;\n\n\tasync getDynamicField(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldResponse> {\n\t\tconst fieldId = deriveDynamicFieldID(\n\t\t\toptions.parentId,\n\t\t\tTypeTagSerializer.parseFromStr(options.name.type),\n\t\t\toptions.name.bcs,\n\t\t);\n\t\tconst {\n\t\t\tobjects: [fieldObject],\n\t\t} = await this.getObjects({\n\t\t\tobjectIds: [fieldId],\n\t\t\tsignal: options.signal,\n\t\t});\n\n\t\tif (fieldObject instanceof Error) {\n\t\t\tthrow fieldObject;\n\t\t}\n\n\t\tconst fieldType = parseStructTag(fieldObject.type);\n\t\tconst content = await fieldObject.content;\n\n\t\treturn {\n\t\t\tdynamicField: {\n\t\t\t\tid: fieldObject.id,\n\t\t\t\tdigest: fieldObject.digest,\n\t\t\t\tversion: fieldObject.version,\n\t\t\t\ttype: fieldObject.type,\n\t\t\t\tname: {\n\t\t\t\t\ttype:\n\t\t\t\t\t\ttypeof fieldType.typeParams[0] === 'string'\n\t\t\t\t\t\t\t? fieldType.typeParams[0]\n\t\t\t\t\t\t\t: normalizeStructTag(fieldType.typeParams[0]),\n\t\t\t\t\tbcs: options.name.bcs,\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype:\n\t\t\t\t\t\ttypeof fieldType.typeParams[1] === 'string'\n\t\t\t\t\t\t\t? fieldType.typeParams[1]\n\t\t\t\t\t\t\t: normalizeStructTag(fieldType.typeParams[1]),\n\t\t\t\t\tbcs: content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync waitForTransaction({\n\t\tsignal,\n\t\ttimeout = 60 * 1000,\n\t\t...input\n\t}: {\n\t\t/** An optional abort signal that can be used to cancel the wait. */\n\t\tsignal?: AbortSignal;\n\t\t/** The amount of time to wait for transaction. Defaults to one minute. */\n\t\ttimeout?: number;\n\t} & Experimental_SuiClientTypes.GetTransactionOptions): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {\n\t\tconst abortSignal = signal\n\t\t\t? AbortSignal.any([AbortSignal.timeout(timeout), signal])\n\t\t\t: AbortSignal.timeout(timeout);\n\n\t\tconst abortPromise = new Promise((_, reject) => {\n\t\t\tabortSignal.addEventListener('abort', () => reject(abortSignal.reason));\n\t\t});\n\n\t\tabortPromise.catch(() => {\n\t\t\t// Swallow unhandled rejections that might be thrown after early return\n\t\t});\n\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\tabortSignal.throwIfAborted();\n\t\t\ttry {\n\t\t\t\treturn await this.getTransaction({\n\t\t\t\t\t...input,\n\t\t\t\t\tsignal: abortSignal,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tawait Promise.race([new Promise((resolve) => setTimeout(resolve, 2_000)), abortPromise]);\n\t\t\t}\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,yBAAyB;AAElC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,gBAAgB,0BAA0B;AACvE,SAAS,+BAA+B;AAExC,SAAS,iBAAiB;AAYnB,MAAe,gCACb,wBAET;AAAA,EAIC,YAAY,SAAyC;AACpD,UAAM,OAAO;AAJd,gBAAO;AAKN,SAAK,MAAM,IAAI,UAAU;AAAA,MACxB,OAAO,KAAK,KAAK,MAAM,MAAM,MAAM;AAAA,MACnC,KAAK,QAAQ,KAAK;AAAA,MAClB,UAAU,QAAQ,KAAK;AAAA,MACvB,WAAW,QAAQ,KAAK;AAAA,IACzB,CAAC;AAAA,EACF;AAAA,EAMA,MAAM,UACL,SACyD;AACzD,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM;AAAA,MACL,SAAS,CAAC,MAAM;AAAA,IACjB,IAAI,MAAM,KAAK,WAAW,EAAE,WAAW,CAAC,QAAQ,GAAG,QAAQ,QAAQ,OAAO,CAAC;AAC3E,QAAI,kBAAkB,OAAO;AAC5B,YAAM;AAAA,IACP;AACA,WAAO,EAAE,QAAQ,OAAO;AAAA,EACzB;AAAA,EAwCA,MAAM,gBACL,SAC+D;AAC/D,UAAM,UAAU;AAAA,MACf,QAAQ;AAAA,MACR,kBAAkB,aAAa,QAAQ,KAAK,IAAI;AAAA,MAChD,QAAQ,KAAK;AAAA,IACd;AACA,UAAM;AAAA,MACL,SAAS,CAAC,WAAW;AAAA,IACtB,IAAI,MAAM,KAAK,WAAW;AAAA,MACzB,WAAW,C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X,cAAM,QAAQ,KAAK,CAAC,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAK,CAAC,GAAG,YAAY,CAAC;AAAA,MACxF;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Experimental_BaseClient } from './client.js';
|
|
2
|
-
import type { ClientWithCoreApi } from './core.js';
|
|
2
|
+
import type { ClientWithCoreApi, Experimental_CoreClientOptions } from './core.js';
|
|
3
3
|
import { Experimental_CoreClient } from './core.js';
|
|
4
4
|
import type { ClientWithExtensions, Experimental_SuiClientTypes, SuiClientRegistration } from './types.js';
|
|
5
5
|
export { parseTransactionBcs, parseTransactionEffectsBcs } from './transports/utils.js';
|
|
6
|
-
export { Experimental_BaseClient, Experimental_CoreClient, type ClientWithExtensions, type Experimental_SuiClientTypes, type SuiClientRegistration, type ClientWithCoreApi, };
|
|
6
|
+
export { Experimental_BaseClient, Experimental_CoreClient, type Experimental_CoreClientOptions, type ClientWithExtensions, type Experimental_SuiClientTypes, type SuiClientRegistration, type ClientWithCoreApi, };
|
|
7
7
|
export { ClientCache, type ClientCacheOptions } from './cache.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/experimental/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Experimental_BaseClient } from './client.js';\nimport type { ClientWithCoreApi } from './core.js';\nimport { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSuiClientRegistration,\n} from './types.js';\nexport { parseTransactionBcs, parseTransactionEffectsBcs } from './transports/utils.js';\n\nexport {\n\tExperimental_BaseClient,\n\tExperimental_CoreClient,\n\ttype ClientWithExtensions,\n\ttype Experimental_SuiClientTypes,\n\ttype SuiClientRegistration,\n\ttype ClientWithCoreApi,\n};\n\nexport { ClientCache, type ClientCacheOptions } from './cache.js';\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,+BAA+B;AAExC,SAAS,+BAA+B;AAMxC,SAAS,qBAAqB,kCAAkC;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Experimental_BaseClient } from './client.js';\nimport type { ClientWithCoreApi, Experimental_CoreClientOptions } from './core.js';\nimport { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSuiClientRegistration,\n} from './types.js';\nexport { parseTransactionBcs, parseTransactionEffectsBcs } from './transports/utils.js';\n\nexport {\n\tExperimental_BaseClient,\n\tExperimental_CoreClient,\n\ttype Experimental_CoreClientOptions,\n\ttype ClientWithExtensions,\n\ttype Experimental_SuiClientTypes,\n\ttype SuiClientRegistration,\n\ttype ClientWithCoreApi,\n};\n\nexport { ClientCache, type ClientCacheOptions } from './cache.js';\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,+BAA+B;AAExC,SAAS,+BAA+B;AAMxC,SAAS,qBAAqB,kCAAkC;AAYhE,SAAS,mBAA4C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { StructTag } from '../utils/sui-types.js';
|
|
2
|
+
import type { ClientCache } from './cache.js';
|
|
3
|
+
import type { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
4
|
+
import type { Experimental_SuiClientTypes } from './types.js';
|
|
5
|
+
export interface MvrClientOptions {
|
|
6
|
+
cache: ClientCache;
|
|
7
|
+
url?: string;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
overrides?: {
|
|
10
|
+
packages?: Record<string, string>;
|
|
11
|
+
types?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare class MvrClient implements Experimental_SuiClientTypes.MvrMethods {
|
|
15
|
+
#private;
|
|
16
|
+
constructor({ cache, url, pageSize, overrides }: MvrClientOptions);
|
|
17
|
+
resolvePackage({ package: name, }: Experimental_SuiClientTypes.MvrResolvePackageOptions): Promise<Experimental_SuiClientTypes.MvrResolvePackageResponse>;
|
|
18
|
+
resolveType({ type, }: Experimental_SuiClientTypes.MvrResolveTypeOptions): Promise<Experimental_SuiClientTypes.MvrResolveTypeResponse>;
|
|
19
|
+
resolve({ types, packages, }: Experimental_SuiClientTypes.MvrResolveOptions): Promise<Experimental_SuiClientTypes.MvrResolveResponse>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extracts all named types from a given type.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractMvrTypes(type: string | StructTag, types?: Set<string>): Set<string>;
|
|
25
|
+
export declare function hasMvrName(nameOrType: string): boolean;
|
|
26
|
+
export type NamedPackagesOverrides = {
|
|
27
|
+
packages: Record<string, string>;
|
|
28
|
+
types: Record<string, string>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Looks up all `.move` names in a transaction block.
|
|
32
|
+
* Returns a list of all the names found.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findNamesInTransaction(builder: TransactionDataBuilder): {
|
|
35
|
+
packages: string[];
|
|
36
|
+
types: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Replace all names & types in a transaction block
|
|
40
|
+
* with their resolved names/types.
|
|
41
|
+
*/
|
|
42
|
+
export declare function replaceNames(builder: TransactionDataBuilder, resolved: Experimental_SuiClientTypes.MvrResolveResponse): void;
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
+
var _cache, _url, _pageSize, _overrides, _MvrClient_instances, mvrPackageDataLoader_get, mvrTypeDataLoader_get, resolvePackages_fn, resolveTypes_fn, fetch_fn;
|
|
10
|
+
import { chunk, DataLoader } from "@mysten/utils";
|
|
11
|
+
import { isValidNamedPackage, isValidNamedType } from "../utils/move-registry.js";
|
|
12
|
+
import {
|
|
13
|
+
isValidSuiAddress,
|
|
14
|
+
normalizeStructTag,
|
|
15
|
+
normalizeSuiAddress,
|
|
16
|
+
parseStructTag
|
|
17
|
+
} from "../utils/sui-types.js";
|
|
18
|
+
import { PACKAGE_VERSION } from "../version.js";
|
|
19
|
+
const NAME_SEPARATOR = "/";
|
|
20
|
+
const MVR_API_HEADER = {
|
|
21
|
+
"Mvr-Source": `@mysten/sui@${PACKAGE_VERSION}`
|
|
22
|
+
};
|
|
23
|
+
class MvrClient {
|
|
24
|
+
constructor({ cache, url, pageSize = 50, overrides }) {
|
|
25
|
+
__privateAdd(this, _MvrClient_instances);
|
|
26
|
+
__privateAdd(this, _cache);
|
|
27
|
+
__privateAdd(this, _url);
|
|
28
|
+
__privateAdd(this, _pageSize);
|
|
29
|
+
__privateAdd(this, _overrides);
|
|
30
|
+
__privateSet(this, _cache, cache);
|
|
31
|
+
__privateSet(this, _url, url);
|
|
32
|
+
__privateSet(this, _pageSize, pageSize);
|
|
33
|
+
__privateSet(this, _overrides, {
|
|
34
|
+
packages: overrides?.packages,
|
|
35
|
+
types: overrides?.types
|
|
36
|
+
});
|
|
37
|
+
validateOverrides(__privateGet(this, _overrides));
|
|
38
|
+
}
|
|
39
|
+
async resolvePackage({
|
|
40
|
+
package: name
|
|
41
|
+
}) {
|
|
42
|
+
const resolved = await __privateGet(this, _MvrClient_instances, mvrPackageDataLoader_get).load(name);
|
|
43
|
+
return {
|
|
44
|
+
package: resolved
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async resolveType({
|
|
48
|
+
type
|
|
49
|
+
}) {
|
|
50
|
+
const mvrTypes = [...extractMvrTypes(type)];
|
|
51
|
+
const resolvedTypes = await __privateGet(this, _MvrClient_instances, mvrTypeDataLoader_get).loadMany(mvrTypes);
|
|
52
|
+
const typeMap = {};
|
|
53
|
+
for (let i = 0; i < mvrTypes.length; i++) {
|
|
54
|
+
const resolvedType = resolvedTypes[i];
|
|
55
|
+
if (resolvedType instanceof Error) {
|
|
56
|
+
throw resolvedType;
|
|
57
|
+
}
|
|
58
|
+
typeMap[mvrTypes[i]] = resolvedType;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
type: replaceMvrNames(type, typeMap)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async resolve({
|
|
65
|
+
types = [],
|
|
66
|
+
packages = []
|
|
67
|
+
}) {
|
|
68
|
+
const mvrTypes = /* @__PURE__ */ new Set();
|
|
69
|
+
for (const type of types ?? []) {
|
|
70
|
+
extractMvrTypes(type, mvrTypes);
|
|
71
|
+
}
|
|
72
|
+
const typesArray = [...mvrTypes];
|
|
73
|
+
const [resolvedTypes, resolvedPackages] = await Promise.all([
|
|
74
|
+
typesArray.length > 0 ? __privateGet(this, _MvrClient_instances, mvrTypeDataLoader_get).loadMany(typesArray) : [],
|
|
75
|
+
packages.length > 0 ? __privateGet(this, _MvrClient_instances, mvrPackageDataLoader_get).loadMany(packages) : []
|
|
76
|
+
]);
|
|
77
|
+
const typeMap = {
|
|
78
|
+
...__privateGet(this, _overrides)?.types
|
|
79
|
+
};
|
|
80
|
+
for (const [i, type] of typesArray.entries()) {
|
|
81
|
+
const resolvedType = resolvedTypes[i];
|
|
82
|
+
if (resolvedType instanceof Error) {
|
|
83
|
+
throw resolvedType;
|
|
84
|
+
}
|
|
85
|
+
typeMap[type] = resolvedType;
|
|
86
|
+
}
|
|
87
|
+
const replacedTypes = {};
|
|
88
|
+
for (const type of types ?? []) {
|
|
89
|
+
const resolvedType = replaceMvrNames(type, typeMap);
|
|
90
|
+
replacedTypes[type] = {
|
|
91
|
+
type: resolvedType
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const replacedPackages = {};
|
|
95
|
+
for (const [i, pkg] of (packages ?? []).entries()) {
|
|
96
|
+
const resolvedPkg = __privateGet(this, _overrides)?.packages?.[pkg] ?? resolvedPackages[i];
|
|
97
|
+
if (resolvedPkg instanceof Error) {
|
|
98
|
+
throw resolvedPkg;
|
|
99
|
+
}
|
|
100
|
+
replacedPackages[pkg] = {
|
|
101
|
+
package: resolvedPkg
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
types: replacedTypes,
|
|
106
|
+
packages: replacedPackages
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
_cache = new WeakMap();
|
|
111
|
+
_url = new WeakMap();
|
|
112
|
+
_pageSize = new WeakMap();
|
|
113
|
+
_overrides = new WeakMap();
|
|
114
|
+
_MvrClient_instances = new WeakSet();
|
|
115
|
+
mvrPackageDataLoader_get = function() {
|
|
116
|
+
return __privateGet(this, _cache).readSync(["#mvrPackageDataLoader", __privateGet(this, _url) ?? ""], () => {
|
|
117
|
+
const loader = new DataLoader(async (packages) => {
|
|
118
|
+
if (!__privateGet(this, _url)) {
|
|
119
|
+
throw new Error(
|
|
120
|
+
`MVR Api URL is not set for the current client (resolving ${packages.join(", ")})`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const resolved = await __privateMethod(this, _MvrClient_instances, resolvePackages_fn).call(this, packages);
|
|
124
|
+
return packages.map(
|
|
125
|
+
(pkg) => resolved[pkg] ?? new Error(`Failed to resolve package: ${pkg}`)
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
const overrides = __privateGet(this, _overrides)?.packages;
|
|
129
|
+
if (overrides) {
|
|
130
|
+
for (const [pkg, id] of Object.entries(overrides)) {
|
|
131
|
+
loader.prime(pkg, id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return loader;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
mvrTypeDataLoader_get = function() {
|
|
138
|
+
return __privateGet(this, _cache).readSync(["#mvrTypeDataLoader", __privateGet(this, _url) ?? ""], () => {
|
|
139
|
+
const loader = new DataLoader(async (types) => {
|
|
140
|
+
if (!__privateGet(this, _url)) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`MVR Api URL is not set for the current client (resolving ${types.join(", ")})`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const resolved = await __privateMethod(this, _MvrClient_instances, resolveTypes_fn).call(this, types);
|
|
146
|
+
return types.map((type) => resolved[type] ?? new Error(`Failed to resolve type: ${type}`));
|
|
147
|
+
});
|
|
148
|
+
const overrides = __privateGet(this, _overrides)?.types;
|
|
149
|
+
if (overrides) {
|
|
150
|
+
for (const [type, id] of Object.entries(overrides)) {
|
|
151
|
+
loader.prime(type, id);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return loader;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
resolvePackages_fn = async function(packages) {
|
|
158
|
+
if (packages.length === 0) return {};
|
|
159
|
+
const batches = chunk(packages, __privateGet(this, _pageSize));
|
|
160
|
+
const results = {};
|
|
161
|
+
await Promise.all(
|
|
162
|
+
batches.map(async (batch) => {
|
|
163
|
+
const data = await __privateMethod(this, _MvrClient_instances, fetch_fn).call(this, "/v1/resolution/bulk", {
|
|
164
|
+
names: batch
|
|
165
|
+
});
|
|
166
|
+
if (!data?.resolution) return;
|
|
167
|
+
for (const pkg of Object.keys(data?.resolution)) {
|
|
168
|
+
const pkgData = data.resolution[pkg]?.package_id;
|
|
169
|
+
if (!pkgData) continue;
|
|
170
|
+
results[pkg] = pkgData;
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
return results;
|
|
175
|
+
};
|
|
176
|
+
resolveTypes_fn = async function(types) {
|
|
177
|
+
if (types.length === 0) return {};
|
|
178
|
+
const batches = chunk(types, __privateGet(this, _pageSize));
|
|
179
|
+
const results = {};
|
|
180
|
+
await Promise.all(
|
|
181
|
+
batches.map(async (batch) => {
|
|
182
|
+
const data = await __privateMethod(this, _MvrClient_instances, fetch_fn).call(this, "/v1/struct-definition/bulk", {
|
|
183
|
+
types: batch
|
|
184
|
+
});
|
|
185
|
+
if (!data?.resolution) return;
|
|
186
|
+
for (const type of Object.keys(data?.resolution)) {
|
|
187
|
+
const typeData = data.resolution[type]?.type_tag;
|
|
188
|
+
if (!typeData) continue;
|
|
189
|
+
results[type] = typeData;
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
return results;
|
|
194
|
+
};
|
|
195
|
+
fetch_fn = async function(url, body) {
|
|
196
|
+
if (!__privateGet(this, _url)) {
|
|
197
|
+
throw new Error("MVR Api URL is not set for the current client");
|
|
198
|
+
}
|
|
199
|
+
const response = await fetch(`${__privateGet(this, _url)}${url}`, {
|
|
200
|
+
method: "POST",
|
|
201
|
+
headers: {
|
|
202
|
+
"Content-Type": "application/json",
|
|
203
|
+
...MVR_API_HEADER
|
|
204
|
+
},
|
|
205
|
+
body: JSON.stringify(body)
|
|
206
|
+
});
|
|
207
|
+
if (!response.ok) {
|
|
208
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
209
|
+
throw new Error(`Failed to resolve types: ${errorBody?.message}`);
|
|
210
|
+
}
|
|
211
|
+
return response.json();
|
|
212
|
+
};
|
|
213
|
+
function validateOverrides(overrides) {
|
|
214
|
+
if (overrides?.packages) {
|
|
215
|
+
for (const [pkg, id] of Object.entries(overrides.packages)) {
|
|
216
|
+
if (!isValidNamedPackage(pkg)) {
|
|
217
|
+
throw new Error(`Invalid package name: ${pkg}`);
|
|
218
|
+
}
|
|
219
|
+
if (!isValidSuiAddress(normalizeSuiAddress(id))) {
|
|
220
|
+
throw new Error(`Invalid package ID: ${id}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (overrides?.types) {
|
|
225
|
+
for (const [type, val] of Object.entries(overrides.types)) {
|
|
226
|
+
if (parseStructTag(type).typeParams.length > 0) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
"Type overrides must be first-level only. If you want to supply generic types, just pass each type individually."
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
const parsedValue = parseStructTag(val);
|
|
232
|
+
if (!isValidSuiAddress(parsedValue.address)) {
|
|
233
|
+
throw new Error(`Invalid type: ${val}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function extractMvrTypes(type, types = /* @__PURE__ */ new Set()) {
|
|
239
|
+
if (typeof type === "string" && !hasMvrName(type)) return types;
|
|
240
|
+
const tag = isStructTag(type) ? type : parseStructTag(type);
|
|
241
|
+
if (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);
|
|
242
|
+
for (const param of tag.typeParams) {
|
|
243
|
+
extractMvrTypes(param, types);
|
|
244
|
+
}
|
|
245
|
+
return types;
|
|
246
|
+
}
|
|
247
|
+
function replaceMvrNames(tag, typeCache) {
|
|
248
|
+
const type = isStructTag(tag) ? tag : parseStructTag(tag);
|
|
249
|
+
const typeTag = `${type.address}::${type.module}::${type.name}`;
|
|
250
|
+
const cacheHit = typeCache[typeTag];
|
|
251
|
+
return normalizeStructTag({
|
|
252
|
+
...type,
|
|
253
|
+
address: cacheHit ? cacheHit.split("::")[0] : type.address,
|
|
254
|
+
typeParams: type.typeParams.map((param) => replaceMvrNames(param, typeCache))
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function hasMvrName(nameOrType) {
|
|
258
|
+
return nameOrType.includes(NAME_SEPARATOR) || nameOrType.includes("@") || nameOrType.includes(".sui");
|
|
259
|
+
}
|
|
260
|
+
function isStructTag(type) {
|
|
261
|
+
return typeof type === "object" && "address" in type && "module" in type && "name" in type && "typeParams" in type;
|
|
262
|
+
}
|
|
263
|
+
function findNamesInTransaction(builder) {
|
|
264
|
+
const packages = /* @__PURE__ */ new Set();
|
|
265
|
+
const types = /* @__PURE__ */ new Set();
|
|
266
|
+
for (const command of builder.commands) {
|
|
267
|
+
switch (command.$kind) {
|
|
268
|
+
case "MakeMoveVec":
|
|
269
|
+
if (command.MakeMoveVec.type) {
|
|
270
|
+
getNamesFromTypeList([command.MakeMoveVec.type]).forEach((type) => {
|
|
271
|
+
types.add(type);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
case "MoveCall":
|
|
276
|
+
const moveCall = command.MoveCall;
|
|
277
|
+
const pkg = moveCall.package.split("::")[0];
|
|
278
|
+
if (hasMvrName(pkg)) {
|
|
279
|
+
if (!isValidNamedPackage(pkg)) throw new Error(`Invalid package name: ${pkg}`);
|
|
280
|
+
packages.add(pkg);
|
|
281
|
+
}
|
|
282
|
+
getNamesFromTypeList(moveCall.typeArguments ?? []).forEach((type) => {
|
|
283
|
+
types.add(type);
|
|
284
|
+
});
|
|
285
|
+
break;
|
|
286
|
+
default:
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
packages: [...packages],
|
|
292
|
+
types: [...types]
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function replaceNames(builder, resolved) {
|
|
296
|
+
for (const command of builder.commands) {
|
|
297
|
+
if (command.MakeMoveVec?.type) {
|
|
298
|
+
if (!hasMvrName(command.MakeMoveVec.type)) continue;
|
|
299
|
+
if (!resolved.types[command.MakeMoveVec.type])
|
|
300
|
+
throw new Error(`No resolution found for type: ${command.MakeMoveVec.type}`);
|
|
301
|
+
command.MakeMoveVec.type = resolved.types[command.MakeMoveVec.type].type;
|
|
302
|
+
}
|
|
303
|
+
const tx = command.MoveCall;
|
|
304
|
+
if (!tx) continue;
|
|
305
|
+
const nameParts = tx.package.split("::");
|
|
306
|
+
const name = nameParts[0];
|
|
307
|
+
if (hasMvrName(name) && !resolved.packages[name])
|
|
308
|
+
throw new Error(`No address found for package: ${name}`);
|
|
309
|
+
if (hasMvrName(name)) {
|
|
310
|
+
nameParts[0] = resolved.packages[name].package;
|
|
311
|
+
tx.package = nameParts.join("::");
|
|
312
|
+
}
|
|
313
|
+
const types = tx.typeArguments;
|
|
314
|
+
if (!types) continue;
|
|
315
|
+
for (let i = 0; i < types.length; i++) {
|
|
316
|
+
if (!hasMvrName(types[i])) continue;
|
|
317
|
+
if (!resolved.types[types[i]]) throw new Error(`No resolution found for type: ${types[i]}`);
|
|
318
|
+
types[i] = resolved.types[types[i]].type;
|
|
319
|
+
}
|
|
320
|
+
tx.typeArguments = types;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function getNamesFromTypeList(types) {
|
|
324
|
+
const names = /* @__PURE__ */ new Set();
|
|
325
|
+
for (const type of types) {
|
|
326
|
+
if (hasMvrName(type)) {
|
|
327
|
+
if (!isValidNamedType(type)) throw new Error(`Invalid type with names: ${type}`);
|
|
328
|
+
names.add(type);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return names;
|
|
332
|
+
}
|
|
333
|
+
export {
|
|
334
|
+
MvrClient,
|
|
335
|
+
extractMvrTypes,
|
|
336
|
+
findNamesInTransaction,
|
|
337
|
+
hasMvrName,
|
|
338
|
+
replaceNames
|
|
339
|
+
};
|
|
340
|
+
//# sourceMappingURL=mvr.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/experimental/mvr.ts"],
|
|
4
|
+
"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 { Experimental_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 Experimental_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}: Experimental_SuiClientTypes.MvrResolvePackageOptions): Promise<Experimental_SuiClientTypes.MvrResolvePackageResponse> {\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}: Experimental_SuiClientTypes.MvrResolveTypeOptions): Promise<Experimental_SuiClientTypes.MvrResolveTypeResponse> {\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}: Experimental_SuiClientTypes.MvrResolveOptions): Promise<Experimental_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: Experimental_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"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;AAGA,SAAS,OAAO,kBAAkB;AAClC,SAAS,qBAAqB,wBAAwB;AAEtD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAGP,SAAS,uBAAuB;AAGhC,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAAA,EACtB,cAAc,eAAe,eAAe;AAC7C;AAYO,MAAM,UAA4D;AAAA,EASxE,YAAY,EAAE,OAAO,KAAK,WAAW,IAAI,UAAU,GAAqB;AATlE;AACN;AACA;AACA;AACA;AAMC,uBAAK,QAAS;AACd,uBAAK,MAAO;AACZ,uBAAK,WAAY;AACjB,uBAAK,YAAa;AAAA,MACjB,UAAU,WAAW;AAAA,MACrB,OAAO,WAAW;AAAA,IACnB;AAEA,sBAAkB,mBAAK,WAAU;AAAA,EAClC;AAAA,EAsIA,MAAM,eAAe;AAAA,IACpB,SAAS;AAAA,EACV,GAAyH;AACxH,UAAM,WAAW,MAAM,mBAAK,gDAAsB,KAAK,IAAI;AAC3D,WAAO;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EAEA,MAAM,YAAY;AAAA,IACjB;AAAA,EACD,GAAmH;AAClH,UAAM,WAAW,CAAC,GAAG,gBAAgB,IAAI,CAAC;AAC1C,UAAM,gBAAgB,MAAM,mBAAK,6CAAmB,SAAS,QAAQ;AAErE,UAA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SAAG,UAAU,UAAU,KAAK,IAAI;AAAA,IACjC;AAEA,UAAM,QAAQ,GAAG;AACjB,QAAI,CAAC,MAAO;AAEZ,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,UAAI,CAAC,WAAW,MAAM,CAAC,CAAC,EAAG;AAE3B,UAAI,CAAC,SAAS,MAAM,MAAM,CAAC,CAAC,EAAG,OAAM,IAAI,MAAM,iCAAiC,MAAM,CAAC,CAAC,EAAE;AAC1F,YAAM,CAAC,IAAI,SAAS,MAAM,MAAM,CAAC,CAAC,EAAE;AAAA,IACrC;AAEA,OAAG,gBAAgB;AAAA,EACpB;AACD;AAMA,SAAS,qBAAqB,OAAiB;AAC9C,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,QAAQ,OAAO;AACzB,QAAI,WAAW,IAAI,GAAG;AACrB,UAAI,CAAC,iBAAiB,IAAI,EAAG,OAAM,IAAI,MAAM,4BAA4B,IAAI,EAAE;AAC/E,YAAM,IAAI,IAAI;AAAA,IACf;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,7 +3,10 @@ import type { Experimental_SuiClientTypes } from '../types.js';
|
|
|
3
3
|
import type { SuiGraphQLClient } from '../../graphql/client.js';
|
|
4
4
|
export declare class GraphQLTransport extends Experimental_CoreClient {
|
|
5
5
|
#private;
|
|
6
|
-
constructor(graphqlClient:
|
|
6
|
+
constructor({ graphqlClient, mvr, }: {
|
|
7
|
+
graphqlClient: SuiGraphQLClient;
|
|
8
|
+
mvr?: Experimental_SuiClientTypes.MvrOptions;
|
|
9
|
+
});
|
|
7
10
|
getObjects(options: Experimental_SuiClientTypes.GetObjectsOptions): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;
|
|
8
11
|
getOwnedObjects(options: Experimental_SuiClientTypes.GetOwnedObjectsOptions): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse>;
|
|
9
12
|
getCoins(options: Experimental_SuiClientTypes.GetCoinsOptions): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;
|
|
@@ -29,8 +29,11 @@ import { normalizeStructTag, normalizeSuiAddress } from "../../utils/sui-types.j
|
|
|
29
29
|
import { deriveDynamicFieldID } from "../../utils/dynamic-fields.js";
|
|
30
30
|
import { parseTransactionBcs, parseTransactionEffectsBcs } from "./utils.js";
|
|
31
31
|
class GraphQLTransport extends Experimental_CoreClient {
|
|
32
|
-
constructor(
|
|
33
|
-
|
|
32
|
+
constructor({
|
|
33
|
+
graphqlClient,
|
|
34
|
+
mvr
|
|
35
|
+
}) {
|
|
36
|
+
super({ network: graphqlClient.network, base: graphqlClient, mvr });
|
|
34
37
|
__privateAdd(this, _GraphQLTransport_instances);
|
|
35
38
|
__privateAdd(this, _graphqlClient);
|
|
36
39
|
__privateSet(this, _graphqlClient, graphqlClient);
|