@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.
Files changed (113) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/client/client.d.ts +13 -12
  3. package/dist/cjs/client/client.js +189 -48
  4. package/dist/cjs/client/client.js.map +3 -3
  5. package/dist/cjs/experimental/cache.d.ts +1 -0
  6. package/dist/cjs/experimental/cache.js +9 -0
  7. package/dist/cjs/experimental/cache.js.map +2 -2
  8. package/dist/cjs/experimental/client.d.ts +2 -1
  9. package/dist/cjs/experimental/client.js +2 -1
  10. package/dist/cjs/experimental/client.js.map +2 -2
  11. package/dist/cjs/experimental/core.d.ts +6 -0
  12. package/dist/cjs/experimental/core.js +9 -2
  13. package/dist/cjs/experimental/core.js.map +2 -2
  14. package/dist/cjs/experimental/index.d.ts +2 -2
  15. package/dist/cjs/experimental/index.js.map +2 -2
  16. package/dist/cjs/experimental/mvr.d.ts +42 -0
  17. package/dist/cjs/experimental/mvr.js +355 -0
  18. package/dist/cjs/experimental/mvr.js.map +7 -0
  19. package/dist/cjs/experimental/transports/graphql.d.ts +4 -1
  20. package/dist/cjs/experimental/transports/graphql.js +5 -2
  21. package/dist/cjs/experimental/transports/graphql.js.map +2 -2
  22. package/dist/cjs/experimental/transports/json-rpc-resolver.d.ts +1 -1
  23. package/dist/cjs/experimental/transports/json-rpc-resolver.js +2 -2
  24. package/dist/cjs/experimental/transports/json-rpc-resolver.js.map +2 -2
  25. package/dist/cjs/experimental/transports/jsonRPC.d.ts +4 -1
  26. package/dist/cjs/experimental/transports/jsonRPC.js +15 -11
  27. package/dist/cjs/experimental/transports/jsonRPC.js.map +3 -3
  28. package/dist/cjs/experimental/transports/utils.js +2 -2
  29. package/dist/cjs/experimental/transports/utils.js.map +2 -2
  30. package/dist/cjs/experimental/types.d.ts +42 -0
  31. package/dist/cjs/experimental/types.js.map +1 -1
  32. package/dist/cjs/graphql/client.d.ts +2 -1
  33. package/dist/cjs/graphql/client.js +6 -2
  34. package/dist/cjs/graphql/client.js.map +2 -2
  35. package/dist/cjs/transactions/index.d.ts +4 -1
  36. package/dist/cjs/transactions/index.js +2 -2
  37. package/dist/cjs/transactions/index.js.map +3 -3
  38. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.d.ts +4 -3
  39. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +38 -90
  40. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js.map +3 -3
  41. package/dist/cjs/transactions/resolve.js +8 -4
  42. package/dist/cjs/transactions/resolve.js.map +2 -2
  43. package/dist/cjs/version.d.ts +1 -1
  44. package/dist/cjs/version.js +1 -1
  45. package/dist/cjs/version.js.map +1 -1
  46. package/dist/esm/client/client.d.ts +13 -12
  47. package/dist/esm/client/client.js +188 -47
  48. package/dist/esm/client/client.js.map +2 -2
  49. package/dist/esm/experimental/cache.d.ts +1 -0
  50. package/dist/esm/experimental/cache.js +9 -0
  51. package/dist/esm/experimental/cache.js.map +2 -2
  52. package/dist/esm/experimental/client.d.ts +2 -1
  53. package/dist/esm/experimental/client.js +2 -1
  54. package/dist/esm/experimental/client.js.map +2 -2
  55. package/dist/esm/experimental/core.d.ts +6 -0
  56. package/dist/esm/experimental/core.js +9 -2
  57. package/dist/esm/experimental/core.js.map +2 -2
  58. package/dist/esm/experimental/index.d.ts +2 -2
  59. package/dist/esm/experimental/index.js.map +2 -2
  60. package/dist/esm/experimental/mvr.d.ts +42 -0
  61. package/dist/esm/experimental/mvr.js +340 -0
  62. package/dist/esm/experimental/mvr.js.map +7 -0
  63. package/dist/esm/experimental/transports/graphql.d.ts +4 -1
  64. package/dist/esm/experimental/transports/graphql.js +5 -2
  65. package/dist/esm/experimental/transports/graphql.js.map +2 -2
  66. package/dist/esm/experimental/transports/json-rpc-resolver.d.ts +1 -1
  67. package/dist/esm/experimental/transports/json-rpc-resolver.js +2 -2
  68. package/dist/esm/experimental/transports/json-rpc-resolver.js.map +2 -2
  69. package/dist/esm/experimental/transports/jsonRPC.d.ts +4 -1
  70. package/dist/esm/experimental/transports/jsonRPC.js +13 -9
  71. package/dist/esm/experimental/transports/jsonRPC.js.map +3 -3
  72. package/dist/esm/experimental/transports/utils.js +1 -1
  73. package/dist/esm/experimental/transports/utils.js.map +1 -1
  74. package/dist/esm/experimental/types.d.ts +42 -0
  75. package/dist/esm/graphql/client.d.ts +2 -1
  76. package/dist/esm/graphql/client.js +6 -2
  77. package/dist/esm/graphql/client.js.map +2 -2
  78. package/dist/esm/transactions/index.d.ts +4 -1
  79. package/dist/esm/transactions/index.js.map +2 -2
  80. package/dist/esm/transactions/plugins/NamedPackagesPlugin.d.ts +4 -3
  81. package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +37 -95
  82. package/dist/esm/transactions/plugins/NamedPackagesPlugin.js.map +3 -3
  83. package/dist/esm/transactions/resolve.js +8 -4
  84. package/dist/esm/transactions/resolve.js.map +2 -2
  85. package/dist/esm/version.d.ts +1 -1
  86. package/dist/esm/version.js +1 -1
  87. package/dist/esm/version.js.map +1 -1
  88. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +3 -3
  91. package/src/client/client.ts +239 -60
  92. package/src/experimental/cache.ts +14 -0
  93. package/src/experimental/client.ts +3 -1
  94. package/src/experimental/core.ts +18 -0
  95. package/src/experimental/index.ts +2 -1
  96. package/src/experimental/mvr.ts +477 -0
  97. package/src/experimental/transports/graphql.ts +8 -2
  98. package/src/experimental/transports/json-rpc-resolver.ts +1 -1
  99. package/src/experimental/transports/jsonRPC.ts +13 -6
  100. package/src/experimental/transports/utils.ts +1 -1
  101. package/src/experimental/types.ts +58 -0
  102. package/src/graphql/client.ts +7 -1
  103. package/src/transactions/index.ts +5 -1
  104. package/src/transactions/plugins/NamedPackagesPlugin.ts +46 -120
  105. package/src/transactions/resolve.ts +12 -5
  106. package/src/version.ts +1 -1
  107. package/dist/cjs/transactions/plugins/utils.d.ts +0 -31
  108. package/dist/cjs/transactions/plugins/utils.js +0 -144
  109. package/dist/cjs/transactions/plugins/utils.js.map +0 -7
  110. package/dist/esm/transactions/plugins/utils.d.ts +0 -31
  111. package/dist/esm/transactions/plugins/utils.js +0 -124
  112. package/dist/esm/transactions/plugins/utils.js.map +0 -7
  113. package/src/transactions/plugins/utils.ts +0 -215
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/transactions/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { normalizedTypeToMoveTypeSignature, getPureBcsSchema } from './serializer.js';\n\nexport { Inputs } from './Inputs.js';\nexport {\n\tCommands,\n\ttype TransactionArgument,\n\ttype TransactionInput,\n\tUpgradePolicy,\n} from './Commands.js';\n\nexport {\n\tTransaction,\n\tisTransaction,\n\ttype TransactionObjectInput,\n\ttype TransactionObjectArgument,\n\ttype TransactionResult,\n} from './Transaction.js';\n\nexport { type SerializedTransactionDataV2 } from './data/v2.js';\nexport { type SerializedTransactionDataV1 } from './data/v1.js';\n\nexport type {\n\tTransactionData,\n\tArgument,\n\tObjectRef,\n\tGasData,\n\tCallArg,\n\tCommand,\n\tOpenMoveTypeSignature,\n\tOpenMoveTypeSignatureBody,\n} from './data/internal.js';\n\nexport { TransactionDataBuilder } from './TransactionData.js';\nexport { ObjectCache, AsyncCache } from './ObjectCache.js';\nexport { SerialTransactionExecutor } from './executor/serial.js';\nexport { ParallelTransactionExecutor } from './executor/parallel.js';\nexport type { ParallelTransactionExecutorOptions } from './executor/parallel.js';\nexport { coinWithBalance } from './intents/CoinWithBalance.js';\n\nexport type {\n\tBuildTransactionOptions,\n\tSerializeTransactionOptions,\n\tTransactionPlugin,\n} from './resolve.js';\n\nexport { Arguments } from './Arguments.js';\n\nexport {\n\tnamedPackagesPlugin,\n\ttype NamedPackagesPluginOptions,\n} from './plugins/NamedPackagesPlugin.js';\n\nexport { type NamedPackagesPluginCache } from './plugins/utils.js';\n\nexport { isArgument } from './utils.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAoE;AAEpE,oBAAuB;AACvB,sBAKO;AAEP,yBAMO;AAgBP,6BAAuC;AACvC,yBAAwC;AACxC,oBAA0C;AAC1C,sBAA4C;AAE5C,6BAAgC;AAQhC,uBAA0B;AAE1B,iCAGO;AAIP,IAAAA,gBAA2B;",
6
- "names": ["import_utils"]
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { NamedPackagesOverrides } from '../experimental/mvr.js';\n\nexport { normalizedTypeToMoveTypeSignature, getPureBcsSchema } from './serializer.js';\n\nexport { Inputs } from './Inputs.js';\nexport {\n\tCommands,\n\ttype TransactionArgument,\n\ttype TransactionInput,\n\tUpgradePolicy,\n} from './Commands.js';\n\nexport {\n\tTransaction,\n\tisTransaction,\n\ttype TransactionObjectInput,\n\ttype TransactionObjectArgument,\n\ttype TransactionResult,\n} from './Transaction.js';\n\nexport { type SerializedTransactionDataV2 } from './data/v2.js';\nexport { type SerializedTransactionDataV1 } from './data/v1.js';\n\nexport type {\n\tTransactionData,\n\tArgument,\n\tObjectRef,\n\tGasData,\n\tCallArg,\n\tCommand,\n\tOpenMoveTypeSignature,\n\tOpenMoveTypeSignatureBody,\n} from './data/internal.js';\n\nexport { TransactionDataBuilder } from './TransactionData.js';\nexport { ObjectCache, AsyncCache } from './ObjectCache.js';\nexport { SerialTransactionExecutor } from './executor/serial.js';\nexport { ParallelTransactionExecutor } from './executor/parallel.js';\nexport type { ParallelTransactionExecutorOptions } from './executor/parallel.js';\nexport { coinWithBalance } from './intents/CoinWithBalance.js';\n\nexport type {\n\tBuildTransactionOptions,\n\tSerializeTransactionOptions,\n\tTransactionPlugin,\n} from './resolve.js';\n\nexport { Arguments } from './Arguments.js';\n\nexport {\n\tnamedPackagesPlugin,\n\ttype NamedPackagesPluginOptions,\n} from './plugins/NamedPackagesPlugin.js';\n\nexport type { NamedPackagesOverrides };\n/** @deprecated Use NamedPackagesOverrides instead */\nexport type NamedPackagesPluginCache = NamedPackagesOverrides;\n\nexport { isArgument } from './utils.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,wBAAoE;AAEpE,oBAAuB;AACvB,sBAKO;AAEP,yBAMO;AAgBP,6BAAuC;AACvC,yBAAwC;AACxC,oBAA0C;AAC1C,sBAA4C;AAE5C,6BAAgC;AAQhC,uBAA0B;AAE1B,iCAGO;AAMP,mBAA2B;",
6
+ "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import type { BuildTransactionOptions } from '../resolve.js';
2
2
  import type { TransactionDataBuilder } from '../TransactionData.js';
3
- import type { NamedPackagesPluginCache } from './utils.js';
3
+ import type { NamedPackagesOverrides } from '../../experimental/mvr.js';
4
4
  export type NamedPackagesPluginOptions = {
5
5
  /**
6
6
  * The URL of the MVR API to use for resolving names.
@@ -28,7 +28,7 @@ export type NamedPackagesPluginOptions = {
28
28
  * }
29
29
  *
30
30
  */
31
- overrides?: NamedPackagesPluginCache;
31
+ overrides?: NamedPackagesOverrides;
32
32
  };
33
33
  /**
34
34
  * @experimental This plugin is in experimental phase and there might be breaking changes in the future
@@ -44,4 +44,5 @@ export type NamedPackagesPluginOptions = {
44
44
  *
45
45
  * You can also define `overrides` to pre-populate name resolutions locally (removes the GraphQL request).
46
46
  */
47
- export declare const namedPackagesPlugin: ({ url, pageSize, overrides, }: NamedPackagesPluginOptions) => (transactionData: TransactionDataBuilder, _buildOptions: BuildTransactionOptions, next: () => Promise<void>) => Promise<void>;
47
+ export declare const namedPackagesPlugin: (options?: NamedPackagesPluginOptions) => (transactionData: TransactionDataBuilder, buildOptions: BuildTransactionOptions, next: () => Promise<void>) => Promise<void>;
48
+ export declare function getClient(options: BuildTransactionOptions): import("../../experimental/core.js").ClientWithCoreApi;
@@ -18,102 +18,50 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var NamedPackagesPlugin_exports = {};
20
20
  __export(NamedPackagesPlugin_exports, {
21
+ getClient: () => getClient,
21
22
  namedPackagesPlugin: () => namedPackagesPlugin
22
23
  });
23
24
  module.exports = __toCommonJS(NamedPackagesPlugin_exports);
24
- var import_sui_types = require("../../utils/sui-types.js");
25
- var import_utils = require("./utils.js");
26
- const namedPackagesPlugin = ({
27
- url,
28
- pageSize = 50,
29
- overrides = { packages: {}, types: {} }
30
- }) => {
31
- Object.keys(overrides.types).forEach((type) => {
32
- if ((0, import_sui_types.parseStructTag)(type).typeParams.length > 0)
33
- throw new Error(
34
- "Type overrides must be first-level only. If you want to supply generic types, just pass each type individually."
35
- );
36
- });
37
- const cache = overrides;
38
- return async (transactionData, _buildOptions, next) => {
39
- const names = (0, import_utils.findNamesInTransaction)(transactionData);
40
- const [packages, types] = await Promise.all([
41
- resolvePackages(
42
- names.packages.filter((x) => !cache.packages[x]),
43
- url,
44
- pageSize
45
- ),
46
- resolveTypes(
47
- [...(0, import_utils.getFirstLevelNamedTypes)(names.types)].filter((x) => !cache.types[x]),
48
- url,
49
- pageSize
50
- )
51
- ]);
52
- Object.assign(cache.packages, packages);
53
- Object.assign(cache.types, types);
54
- const composedTypes = (0, import_utils.populateNamedTypesFromCache)(names.types, cache.types);
55
- (0, import_utils.replaceNames)(transactionData, {
56
- packages: { ...cache.packages },
57
- // we include the "composed" type cache too.
58
- types: composedTypes
25
+ var import_cache = require("../../experimental/cache.js");
26
+ var import_mvr = require("../../experimental/mvr.js");
27
+ var import_mvr2 = require("../../experimental/mvr.js");
28
+ const cacheMap = /* @__PURE__ */ new WeakMap();
29
+ const namedPackagesPlugin = (options) => {
30
+ let mvrClient;
31
+ if (options) {
32
+ const overrides = options.overrides ?? {
33
+ packages: {},
34
+ types: {}
35
+ };
36
+ if (!cacheMap.has(overrides)) {
37
+ cacheMap.set(overrides, new import_cache.ClientCache());
38
+ }
39
+ mvrClient = new import_mvr.MvrClient({
40
+ cache: cacheMap.get(overrides),
41
+ url: options.url,
42
+ pageSize: options.pageSize,
43
+ overrides
59
44
  });
45
+ }
46
+ return async (transactionData, buildOptions, next) => {
47
+ const names = (0, import_mvr2.findNamesInTransaction)(transactionData);
48
+ if (names.types.length === 0 && names.packages.length === 0) {
49
+ return next();
50
+ }
51
+ const resolved = await (mvrClient || getClient(buildOptions).core.mvr).resolve({
52
+ types: names.types,
53
+ packages: names.packages
54
+ });
55
+ (0, import_mvr2.replaceNames)(transactionData, resolved);
60
56
  await next();
61
57
  };
62
- async function resolvePackages(packages, apiUrl, pageSize2) {
63
- if (packages.length === 0) return {};
64
- const batches = (0, import_utils.batch)(packages, pageSize2);
65
- const results = {};
66
- await Promise.all(
67
- batches.map(async (batch2) => {
68
- const response = await fetch(`${apiUrl}/v1/resolution/bulk`, {
69
- method: "POST",
70
- headers: { "Content-Type": "application/json" },
71
- body: JSON.stringify({
72
- names: batch2
73
- })
74
- });
75
- if (!response.ok) {
76
- const errorBody = await response.json().catch(() => ({}));
77
- throw new Error(`Failed to resolve packages: ${errorBody?.message}`);
78
- }
79
- const data = await response.json();
80
- if (!data?.resolution) return;
81
- for (const pkg of Object.keys(data?.resolution)) {
82
- const pkgData = data.resolution[pkg]?.package_id;
83
- if (!pkgData) continue;
84
- results[pkg] = pkgData;
85
- }
86
- })
87
- );
88
- return results;
89
- }
90
- async function resolveTypes(types, apiUrl, pageSize2) {
91
- if (types.length === 0) return {};
92
- const batches = (0, import_utils.batch)(types, pageSize2);
93
- const results = {};
94
- await Promise.all(
95
- batches.map(async (batch2) => {
96
- const response = await fetch(`${apiUrl}/v1/struct-definition/bulk`, {
97
- method: "POST",
98
- headers: { "Content-Type": "application/json" },
99
- body: JSON.stringify({
100
- types: batch2
101
- })
102
- });
103
- if (!response.ok) {
104
- const errorBody = await response.json().catch(() => ({}));
105
- throw new Error(`Failed to resolve types: ${errorBody?.message}`);
106
- }
107
- const data = await response.json();
108
- if (!data?.resolution) return;
109
- for (const type of Object.keys(data?.resolution)) {
110
- const typeData = data.resolution[type]?.type_tag;
111
- if (!typeData) continue;
112
- results[type] = typeData;
113
- }
114
- })
58
+ };
59
+ function getClient(options) {
60
+ if (!options.client) {
61
+ throw new Error(
62
+ `No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`
115
63
  );
116
- return results;
117
64
  }
118
- };
65
+ return options.client;
66
+ }
119
67
  //# sourceMappingURL=NamedPackagesPlugin.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/transactions/plugins/NamedPackagesPlugin.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { parseStructTag } from '../../utils/sui-types.js';\nimport type { BuildTransactionOptions } from '../resolve.js';\nimport type { TransactionDataBuilder } from '../TransactionData.js';\nimport type { NamedPackagesPluginCache } from './utils.js';\nimport {\n\tbatch,\n\tfindNamesInTransaction,\n\tgetFirstLevelNamedTypes,\n\tpopulateNamedTypesFromCache,\n\treplaceNames,\n} from './utils.js';\n\nexport type NamedPackagesPluginOptions = {\n\t/**\n\t * The URL of the MVR API to use for resolving names.\n\t */\n\turl: string;\n\t/**\n\t * The number of names to resolve in each batch request.\n\t * Needs to be calculated based on the GraphQL query limits.\n\t */\n\tpageSize?: number;\n\t/**\n\t * Local overrides for the resolution plugin. Pass this to pre-populate\n\t * the cache with known packages / types (especially useful for local or CI testing).\n\t *\n\t * The type cache expects ONLY first-level types to ensure the cache is more composable.\n\t *\n\t * \tExpected format example:\n\t * {\n\t * \t\tpackages: {\n\t * \t\t\t'@framework/std': '0x1234',\n\t * \t\t},\n\t * \t\ttypes: {\n\t * \t\t\t'@framework/std::string::String': '0x1234::string::String',\n\t * \t\t},\n\t * \t}\n\t *\n\t */\n\toverrides?: NamedPackagesPluginCache;\n};\n\n/**\n * @experimental This plugin is in experimental phase and there might be breaking changes in the future\n *\n * Adds named resolution so that you can use .move names in your transactions.\n * e.g. `@org/app::type::Type` will be resolved to `0x1234::type::Type`.\n * This plugin will resolve all names & types in the transaction block.\n *\n * To install this plugin globally in your app, use:\n * ```\n * Transaction.registerGlobalSerializationPlugin(\"namedPackagesPlugin\", namedPackagesPlugin({ suiGraphQLClient }));\n * ```\n *\n * You can also define `overrides` to pre-populate name resolutions locally (removes the GraphQL request).\n */\nexport const namedPackagesPlugin = ({\n\turl,\n\tpageSize = 50,\n\toverrides = { packages: {}, types: {} },\n}: NamedPackagesPluginOptions) => {\n\t// validate that types are first-level only.\n\tObject.keys(overrides.types).forEach((type) => {\n\t\tif (parseStructTag(type).typeParams.length > 0)\n\t\t\tthrow new Error(\n\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);\n\t});\n\n\tconst cache = overrides;\n\n\treturn async (\n\t\ttransactionData: TransactionDataBuilder,\n\t\t_buildOptions: BuildTransactionOptions,\n\t\tnext: () => Promise<void>,\n\t) => {\n\t\tconst names = findNamesInTransaction(transactionData);\n\n\t\tconst [packages, types] = await Promise.all([\n\t\t\tresolvePackages(\n\t\t\t\tnames.packages.filter((x) => !cache.packages[x]),\n\t\t\t\turl,\n\t\t\t\tpageSize,\n\t\t\t),\n\t\t\tresolveTypes(\n\t\t\t\t[...getFirstLevelNamedTypes(names.types)].filter((x) => !cache.types[x]),\n\t\t\t\turl,\n\t\t\t\tpageSize,\n\t\t\t),\n\t\t]);\n\n\t\t// save first-level mappings to cache.\n\t\tObject.assign(cache.packages, packages);\n\t\tObject.assign(cache.types, types);\n\n\t\tconst composedTypes = populateNamedTypesFromCache(names.types, cache.types);\n\n\t\t// when replacing names, we also need to replace the \"composed\" types collected above.\n\t\treplaceNames(transactionData, {\n\t\t\tpackages: { ...cache.packages },\n\t\t\t// we include the \"composed\" type cache too.\n\t\t\ttypes: composedTypes,\n\t\t});\n\n\t\tawait next();\n\t};\n\n\tasync function resolvePackages(packages: string[], apiUrl: string, pageSize: number) {\n\t\tif (packages.length === 0) return {};\n\n\t\tconst batches = batch(packages, 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 response = await fetch(`${apiUrl}/v1/resolution/bulk`, {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t\t\tbody: JSON.stringify({\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 (!response.ok) {\n\t\t\t\t\tconst errorBody = await response.json().catch(() => ({}));\n\t\t\t\t\tthrow new Error(`Failed to resolve packages: ${errorBody?.message}`);\n\t\t\t\t}\n\n\t\t\t\tconst data = await response.json();\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 function resolveTypes(types: string[], apiUrl: string, pageSize: number) {\n\t\tif (types.length === 0) return {};\n\n\t\tconst batches = batch(types, 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 response = await fetch(`${apiUrl}/v1/struct-definition/bulk`, {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t\t\tbody: JSON.stringify({\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 (!response.ok) {\n\t\t\t\t\tconst errorBody = await response.json().catch(() => ({}));\n\t\t\t\t\tthrow new Error(`Failed to resolve types: ${errorBody?.message}`);\n\t\t\t\t}\n\n\t\t\t\tconst data = await response.json();\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"],
5
- "mappings": "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",
6
- "names": ["pageSize", "batch"]
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ClientCache } from '../../experimental/cache.js';\nimport { MvrClient } from '../../experimental/mvr.js';\nimport type { BuildTransactionOptions } from '../resolve.js';\nimport type { TransactionDataBuilder } from '../TransactionData.js';\nimport { findNamesInTransaction, replaceNames } from '../../experimental/mvr.js';\nimport type { NamedPackagesOverrides } from '../../experimental/mvr.js';\n\nexport type NamedPackagesPluginOptions = {\n\t/**\n\t * The URL of the MVR API to use for resolving names.\n\t */\n\turl: string;\n\t/**\n\t * The number of names to resolve in each batch request.\n\t * Needs to be calculated based on the GraphQL query limits.\n\t */\n\tpageSize?: number;\n\t/**\n\t * Local overrides for the resolution plugin. Pass this to pre-populate\n\t * the cache with known packages / types (especially useful for local or CI testing).\n\t *\n\t * The type cache expects ONLY first-level types to ensure the cache is more composable.\n\t *\n\t * \tExpected format example:\n\t * {\n\t * \t\tpackages: {\n\t * \t\t\t'@framework/std': '0x1234',\n\t * \t\t},\n\t * \t\ttypes: {\n\t * \t\t\t'@framework/std::string::String': '0x1234::string::String',\n\t * \t\t},\n\t * \t}\n\t *\n\t */\n\toverrides?: NamedPackagesOverrides;\n};\n\n// The original versions of the mvr plugin cached lookups by mutating overrides.\n// We don't want to mutate the options, but we can link our cache to the provided overrides object\n// This preserves the caching across transactions while removing the mutation side effects\nconst cacheMap = new WeakMap<object, ClientCache>();\n\n/**\n * @experimental This plugin is in experimental phase and there might be breaking changes in the future\n *\n * Adds named resolution so that you can use .move names in your transactions.\n * e.g. `@org/app::type::Type` will be resolved to `0x1234::type::Type`.\n * This plugin will resolve all names & types in the transaction block.\n *\n * To install this plugin globally in your app, use:\n * ```\n * Transaction.registerGlobalSerializationPlugin(\"namedPackagesPlugin\", namedPackagesPlugin({ suiGraphQLClient }));\n * ```\n *\n * You can also define `overrides` to pre-populate name resolutions locally (removes the GraphQL request).\n */\nexport const namedPackagesPlugin = (options?: NamedPackagesPluginOptions) => {\n\tlet mvrClient: MvrClient | undefined;\n\n\tif (options) {\n\t\tconst overrides = options.overrides ?? {\n\t\t\tpackages: {},\n\t\t\ttypes: {},\n\t\t};\n\n\t\tif (!cacheMap.has(overrides)) {\n\t\t\tcacheMap.set(overrides, new ClientCache());\n\t\t}\n\n\t\tmvrClient = new MvrClient({\n\t\t\tcache: cacheMap.get(overrides)!,\n\t\t\turl: options.url,\n\t\t\tpageSize: options.pageSize,\n\t\t\toverrides: overrides,\n\t\t});\n\t}\n\n\treturn async (\n\t\ttransactionData: TransactionDataBuilder,\n\t\tbuildOptions: BuildTransactionOptions,\n\t\tnext: () => Promise<void>,\n\t) => {\n\t\tconst names = findNamesInTransaction(transactionData);\n\n\t\tif (names.types.length === 0 && names.packages.length === 0) {\n\t\t\treturn next();\n\t\t}\n\n\t\tconst resolved = await (mvrClient || getClient(buildOptions).core.mvr).resolve({\n\t\t\ttypes: names.types,\n\t\t\tpackages: names.packages,\n\t\t});\n\n\t\treplaceNames(transactionData, resolved);\n\n\t\tawait next();\n\t};\n};\n\nexport function getClient(options: BuildTransactionOptions) {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\n\treturn options.client;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA4B;AAC5B,iBAA0B;AAG1B,IAAAA,cAAqD;AAoCrD,MAAM,WAAW,oBAAI,QAA6B;AAgB3C,MAAM,sBAAsB,CAAC,YAAyC;AAC5E,MAAI;AAEJ,MAAI,SAAS;AACZ,UAAM,YAAY,QAAQ,aAAa;AAAA,MACtC,UAAU,CAAC;AAAA,MACX,OAAO,CAAC;AAAA,IACT;AAEA,QAAI,CAAC,SAAS,IAAI,SAAS,GAAG;AAC7B,eAAS,IAAI,WAAW,IAAI,yBAAY,CAAC;AAAA,IAC1C;AAEA,gBAAY,IAAI,qBAAU;AAAA,MACzB,OAAO,SAAS,IAAI,SAAS;AAAA,MAC7B,KAAK,QAAQ;AAAA,MACb,UAAU,QAAQ;AAAA,MAClB;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO,OACN,iBACA,cACA,SACI;AACJ,UAAM,YAAQ,oCAAuB,eAAe;AAEpD,QAAI,MAAM,MAAM,WAAW,KAAK,MAAM,SAAS,WAAW,GAAG;AAC5D,aAAO,KAAK;AAAA,IACb;AAEA,UAAM,WAAW,OAAO,aAAa,UAAU,YAAY,EAAE,KAAK,KAAK,QAAQ;AAAA,MAC9E,OAAO,MAAM;AAAA,MACb,UAAU,MAAM;AAAA,IACjB,CAAC;AAED,kCAAa,iBAAiB,QAAQ;AAEtC,UAAM,KAAK;AAAA,EACZ;AACD;AAEO,SAAS,UAAU,SAAkC;AAC3D,MAAI,CAAC,QAAQ,QAAQ;AACpB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,QAAQ;AAChB;",
6
+ "names": ["import_mvr"]
7
7
  }
@@ -25,6 +25,8 @@ __export(resolve_exports, {
25
25
  module.exports = __toCommonJS(resolve_exports);
26
26
  var import_Inputs = require("./Inputs.js");
27
27
  var import_bcs = require("../bcs/index.js");
28
+ var import_NamedPackagesPlugin = require("./plugins/NamedPackagesPlugin.js");
29
+ var import_json_rpc_resolver = require("../experimental/transports/json-rpc-resolver.js");
28
30
  function needsTransactionResolution(data, options) {
29
31
  if (data.inputs.some((input) => {
30
32
  return input.UnresolvedObject || input.UnresolvedPure;
@@ -45,10 +47,12 @@ async function resolveTransactionPlugin(transactionData, options, next) {
45
47
  return next();
46
48
  }
47
49
  const client = getClient(options);
48
- const plugin = client.core.resolveTransactionPlugin();
49
- return plugin(transactionData, options, async () => {
50
- await validate(transactionData);
51
- await next();
50
+ const plugin = client.core?.resolveTransactionPlugin() ?? (0, import_json_rpc_resolver.suiClientResolveTransactionPlugin)(client);
51
+ return (0, import_NamedPackagesPlugin.namedPackagesPlugin)()(transactionData, options, async () => {
52
+ await plugin(transactionData, options, async () => {
53
+ await validate(transactionData);
54
+ await next();
55
+ });
52
56
  });
53
57
  }
54
58
  function validate(transactionData) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/transactions/resolve.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Argument } from './data/internal.js';\n\nimport type { ClientWithCoreApi } from '../experimental/index.js';\nimport type { TransactionDataBuilder } from './TransactionData.js';\nimport type { BcsType } from '@mysten/bcs';\nimport { Inputs } from './Inputs.js';\nimport { bcs } from '../bcs/index.js';\n\nexport interface BuildTransactionOptions {\n\tclient?: ClientWithCoreApi;\n\tonlyTransactionKind?: boolean;\n}\n\nexport interface SerializeTransactionOptions extends BuildTransactionOptions {\n\tsupportedIntents?: string[];\n}\n\nexport type TransactionPlugin = (\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) => Promise<void>;\n\nexport function needsTransactionResolution(\n\tdata: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n): boolean {\n\tif (\n\t\tdata.inputs.some((input) => {\n\t\t\treturn input.UnresolvedObject || input.UnresolvedPure;\n\t\t})\n\t) {\n\t\treturn true;\n\t}\n\n\tif (!options.onlyTransactionKind) {\n\t\tif (!data.gasConfig.price || !data.gasConfig.budget || !data.gasConfig.payment) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport async function resolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tnormalizeRawArguments(transactionData);\n\tif (!needsTransactionResolution(transactionData, options)) {\n\t\tawait validate(transactionData);\n\t\treturn next();\n\t}\n\n\tconst client = getClient(options);\n\tconst plugin = client.core.resolveTransactionPlugin();\n\n\treturn plugin(transactionData, options, async () => {\n\t\tawait validate(transactionData);\n\t\tawait next();\n\t});\n}\n\nfunction validate(transactionData: TransactionDataBuilder) {\n\ttransactionData.inputs.forEach((input, index) => {\n\t\tif (input.$kind !== 'Object' && input.$kind !== 'Pure') {\n\t\t\tthrow new Error(\n\t\t\t\t`Input at index ${index} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(\n\t\t\t\t\tinput,\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t});\n}\n\nexport function getClient(options: BuildTransactionOptions) {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\n\treturn options.client;\n}\n\nfunction normalizeRawArguments(transactionData: TransactionDataBuilder) {\n\tfor (const command of transactionData.commands) {\n\t\tswitch (command.$kind) {\n\t\t\tcase 'SplitCoins':\n\t\t\t\tcommand.SplitCoins.amounts.forEach((amount) => {\n\t\t\t\t\tnormalizeRawArgument(amount, bcs.U64, transactionData);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'TransferObjects':\n\t\t\t\tnormalizeRawArgument(command.TransferObjects.address, bcs.Address, transactionData);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction normalizeRawArgument(\n\targ: Argument,\n\tschema: BcsType<any>,\n\ttransactionData: TransactionDataBuilder,\n) {\n\tif (arg.$kind !== 'Input') {\n\t\treturn;\n\t}\n\tconst input = transactionData.inputs[arg.Input];\n\n\tif (input.$kind !== 'UnresolvedPure') {\n\t\treturn;\n\t}\n\n\ttransactionData.inputs[arg.Input] = Inputs.Pure(schema.serialize(input.UnresolvedPure.value));\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,oBAAuB;AACvB,iBAAoB;AAiBb,SAAS,2BACf,MACA,SACU;AACV,MACC,KAAK,OAAO,KAAK,CAAC,UAAU;AAC3B,WAAO,MAAM,oBAAoB,MAAM;AAAA,EACxC,CAAC,GACA;AACD,WAAO;AAAA,EACR;AAEA,MAAI,CAAC,QAAQ,qBAAqB;AACjC,QAAI,CAAC,KAAK,UAAU,SAAS,CAAC,KAAK,UAAU,UAAU,CAAC,KAAK,UAAU,SAAS;AAC/E,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,yBACrB,iBACA,SACA,MACC;AACD,wBAAsB,eAAe;AACrC,MAAI,CAAC,2BAA2B,iBAAiB,OAAO,GAAG;AAC1D,UAAM,SAAS,eAAe;AAC9B,WAAO,KAAK;AAAA,EACb;AAEA,QAAM,SAAS,UAAU,OAAO;AAChC,QAAM,SAAS,OAAO,KAAK,yBAAyB;AAEpD,SAAO,OAAO,iBAAiB,SAAS,YAAY;AACnD,UAAM,SAAS,eAAe;AAC9B,UAAM,KAAK;AAAA,EACZ,CAAC;AACF;AAEA,SAAS,SAAS,iBAAyC;AAC1D,kBAAgB,OAAO,QAAQ,CAAC,OAAO,UAAU;AAChD,QAAI,MAAM,UAAU,YAAY,MAAM,UAAU,QAAQ;AACvD,YAAM,IAAI;AAAA,QACT,kBAAkB,KAAK,uEAAuE,KAAK;AAAA,UAClG;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,SAAS,UAAU,SAAkC;AAC3D,MAAI,CAAC,QAAQ,QAAQ;AACpB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,QAAQ;AAChB;AAEA,SAAS,sBAAsB,iBAAyC;AACvE,aAAW,WAAW,gBAAgB,UAAU;AAC/C,YAAQ,QAAQ,OAAO;AAAA,MACtB,KAAK;AACJ,gBAAQ,WAAW,QAAQ,QAAQ,CAAC,WAAW;AAC9C,+BAAqB,QAAQ,eAAI,KAAK,eAAe;AAAA,QACtD,CAAC;AACD;AAAA,MACD,KAAK;AACJ,6BAAqB,QAAQ,gBAAgB,SAAS,eAAI,SAAS,eAAe;AAClF;AAAA,IACF;AAAA,EACD;AACD;AAEA,SAAS,qBACR,KACA,QACA,iBACC;AACD,MAAI,IAAI,UAAU,SAAS;AAC1B;AAAA,EACD;AACA,QAAM,QAAQ,gBAAgB,OAAO,IAAI,KAAK;AAE9C,MAAI,MAAM,UAAU,kBAAkB;AACrC;AAAA,EACD;AAEA,kBAAgB,OAAO,IAAI,KAAK,IAAI,qBAAO,KAAK,OAAO,UAAU,MAAM,eAAe,KAAK,CAAC;AAC7F;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Argument } from './data/internal.js';\n\nimport type { ClientWithCoreApi } from '../experimental/index.js';\nimport type { TransactionDataBuilder } from './TransactionData.js';\nimport type { BcsType } from '@mysten/bcs';\nimport { Inputs } from './Inputs.js';\nimport { bcs } from '../bcs/index.js';\nimport { namedPackagesPlugin } from './plugins/NamedPackagesPlugin.js';\nimport { suiClientResolveTransactionPlugin } from '../experimental/transports/json-rpc-resolver.js';\nimport type { SuiClient } from '../client/index.js';\n\nexport interface BuildTransactionOptions {\n\tclient?: ClientWithCoreApi;\n\tonlyTransactionKind?: boolean;\n}\n\nexport interface SerializeTransactionOptions extends BuildTransactionOptions {\n\tsupportedIntents?: string[];\n}\n\nexport type TransactionPlugin = (\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) => Promise<void>;\n\nexport function needsTransactionResolution(\n\tdata: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n): boolean {\n\tif (\n\t\tdata.inputs.some((input) => {\n\t\t\treturn input.UnresolvedObject || input.UnresolvedPure;\n\t\t})\n\t) {\n\t\treturn true;\n\t}\n\n\tif (!options.onlyTransactionKind) {\n\t\tif (!data.gasConfig.price || !data.gasConfig.budget || !data.gasConfig.payment) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport async function resolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tnormalizeRawArguments(transactionData);\n\tif (!needsTransactionResolution(transactionData, options)) {\n\t\tawait validate(transactionData);\n\t\treturn next();\n\t}\n\n\tconst client = getClient(options);\n\tconst plugin =\n\t\tclient.core?.resolveTransactionPlugin() ??\n\t\tsuiClientResolveTransactionPlugin(client as SuiClient);\n\n\treturn namedPackagesPlugin()(transactionData, options, async () => {\n\t\tawait plugin(transactionData, options, async () => {\n\t\t\tawait validate(transactionData);\n\t\t\tawait next();\n\t\t});\n\t});\n}\n\nfunction validate(transactionData: TransactionDataBuilder) {\n\ttransactionData.inputs.forEach((input, index) => {\n\t\tif (input.$kind !== 'Object' && input.$kind !== 'Pure') {\n\t\t\tthrow new Error(\n\t\t\t\t`Input at index ${index} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(\n\t\t\t\t\tinput,\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t});\n}\n\nexport function getClient(options: BuildTransactionOptions) {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\n\treturn options.client;\n}\n\nfunction normalizeRawArguments(transactionData: TransactionDataBuilder) {\n\tfor (const command of transactionData.commands) {\n\t\tswitch (command.$kind) {\n\t\t\tcase 'SplitCoins':\n\t\t\t\tcommand.SplitCoins.amounts.forEach((amount) => {\n\t\t\t\t\tnormalizeRawArgument(amount, bcs.U64, transactionData);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'TransferObjects':\n\t\t\t\tnormalizeRawArgument(command.TransferObjects.address, bcs.Address, transactionData);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction normalizeRawArgument(\n\targ: Argument,\n\tschema: BcsType<any>,\n\ttransactionData: TransactionDataBuilder,\n) {\n\tif (arg.$kind !== 'Input') {\n\t\treturn;\n\t}\n\tconst input = transactionData.inputs[arg.Input];\n\n\tif (input.$kind !== 'UnresolvedPure') {\n\t\treturn;\n\t}\n\n\ttransactionData.inputs[arg.Input] = Inputs.Pure(schema.serialize(input.UnresolvedPure.value));\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,oBAAuB;AACvB,iBAAoB;AACpB,iCAAoC;AACpC,+BAAkD;AAkB3C,SAAS,2BACf,MACA,SACU;AACV,MACC,KAAK,OAAO,KAAK,CAAC,UAAU;AAC3B,WAAO,MAAM,oBAAoB,MAAM;AAAA,EACxC,CAAC,GACA;AACD,WAAO;AAAA,EACR;AAEA,MAAI,CAAC,QAAQ,qBAAqB;AACjC,QAAI,CAAC,KAAK,UAAU,SAAS,CAAC,KAAK,UAAU,UAAU,CAAC,KAAK,UAAU,SAAS;AAC/E,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,yBACrB,iBACA,SACA,MACC;AACD,wBAAsB,eAAe;AACrC,MAAI,CAAC,2BAA2B,iBAAiB,OAAO,GAAG;AAC1D,UAAM,SAAS,eAAe;AAC9B,WAAO,KAAK;AAAA,EACb;AAEA,QAAM,SAAS,UAAU,OAAO;AAChC,QAAM,SACL,OAAO,MAAM,yBAAyB,SACtC,4DAAkC,MAAmB;AAEtD,aAAO,gDAAoB,EAAE,iBAAiB,SAAS,YAAY;AAClE,UAAM,OAAO,iBAAiB,SAAS,YAAY;AAClD,YAAM,SAAS,eAAe;AAC9B,YAAM,KAAK;AAAA,IACZ,CAAC;AAAA,EACF,CAAC;AACF;AAEA,SAAS,SAAS,iBAAyC;AAC1D,kBAAgB,OAAO,QAAQ,CAAC,OAAO,UAAU;AAChD,QAAI,MAAM,UAAU,YAAY,MAAM,UAAU,QAAQ;AACvD,YAAM,IAAI;AAAA,QACT,kBAAkB,KAAK,uEAAuE,KAAK;AAAA,UAClG;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,SAAS,UAAU,SAAkC;AAC3D,MAAI,CAAC,QAAQ,QAAQ;AACpB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,QAAQ;AAChB;AAEA,SAAS,sBAAsB,iBAAyC;AACvE,aAAW,WAAW,gBAAgB,UAAU;AAC/C,YAAQ,QAAQ,OAAO;AAAA,MACtB,KAAK;AACJ,gBAAQ,WAAW,QAAQ,QAAQ,CAAC,WAAW;AAC9C,+BAAqB,QAAQ,eAAI,KAAK,eAAe;AAAA,QACtD,CAAC;AACD;AAAA,MACD,KAAK;AACJ,6BAAqB,QAAQ,gBAAgB,SAAS,eAAI,SAAS,eAAe;AAClF;AAAA,IACF;AAAA,EACD;AACD;AAEA,SAAS,qBACR,KACA,QACA,iBACC;AACD,MAAI,IAAI,UAAU,SAAS;AAC1B;AAAA,EACD;AACA,QAAM,QAAQ,gBAAgB,OAAO,IAAI,KAAK;AAE9C,MAAI,MAAM,UAAU,kBAAkB;AACrC;AAAA,EACD;AAEA,kBAAgB,OAAO,IAAI,KAAK,IAAI,qBAAO,KAAK,OAAO,UAAU,MAAM,eAAe,KAAK,CAAC;AAC7F;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- export declare const PACKAGE_VERSION = "1.32.0";
1
+ export declare const PACKAGE_VERSION = "1.34.0";
2
2
  export declare const TARGETED_RPC_VERSION = "1.51.0";
@@ -22,6 +22,6 @@ __export(version_exports, {
22
22
  TARGETED_RPC_VERSION: () => TARGETED_RPC_VERSION
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const PACKAGE_VERSION = "1.32.0";
25
+ const PACKAGE_VERSION = "1.34.0";
26
26
  const TARGETED_RPC_VERSION = "1.51.0";
27
27
  //# sourceMappingURL=version.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/version.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '1.32.0';\nexport const TARGETED_RPC_VERSION = '1.51.0';\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '1.34.0';\nexport const TARGETED_RPC_VERSION = '1.51.0';\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;",
6
6
  "names": []
7
7
  }
@@ -2,7 +2,7 @@ import type { Signer } from '../cryptography/index.js';
2
2
  import { Experimental_BaseClient } from '../experimental/client.js';
3
3
  import { JSONRpcTransport } from '../experimental/transports/jsonRPC.js';
4
4
  import type { Experimental_SuiClientTypes, SelfRegisteringClientExtension } from '../experimental/types.js';
5
- import type { Transaction } from '../transactions/index.js';
5
+ import type { Transaction } from '../transactions/Transaction.js';
6
6
  import type { SuiTransport } from './http-transport.js';
7
7
  import type { AddressMetrics, AllEpochsAddressMetrics, Checkpoint, CheckpointPage, CoinBalance, CoinMetadata, CoinSupply, CommitteeInfo, DelegatedStake, DevInspectResults, DevInspectTransactionBlockParams, DryRunTransactionBlockParams, DryRunTransactionBlockResponse, DynamicFieldPage, EpochInfo, EpochMetricsPage, EpochPage, ExecuteTransactionBlockParams, GetAllBalancesParams, GetAllCoinsParams, GetBalanceParams, GetCheckpointParams, GetCheckpointsParams, GetCoinMetadataParams, GetCoinsParams, GetCommitteeInfoParams, GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetLatestCheckpointSequenceNumberParams, GetLatestSuiSystemStateParams, GetMoveFunctionArgTypesParams, GetNormalizedMoveFunctionParams, GetNormalizedMoveModuleParams, GetNormalizedMoveModulesByPackageParams, GetNormalizedMoveStructParams, GetObjectParams, GetOwnedObjectsParams, GetProtocolConfigParams, GetReferenceGasPriceParams, GetStakesByIdsParams, GetStakesParams, GetTotalSupplyParams, GetTransactionBlockParams, MoveCallMetrics, MultiGetObjectsParams, MultiGetTransactionBlocksParams, NetworkMetrics, ObjectRead, Order, PaginatedCoins, PaginatedEvents, PaginatedObjectsResponse, PaginatedTransactionResponse, ProtocolConfig, QueryEventsParams, QueryTransactionBlocksParams, ResolvedNameServiceNames, ResolveNameServiceAddressParams, ResolveNameServiceNamesParams, SubscribeEventParams, SubscribeTransactionParams, SuiEvent, SuiMoveFunctionArgType, SuiMoveNormalizedFunction, SuiMoveNormalizedModule, SuiMoveNormalizedModules, SuiMoveNormalizedStruct, SuiObjectResponse, SuiSystemStateSummary, SuiTransactionBlockResponse, TransactionEffects, TryGetPastObjectParams, Unsubscribe, ValidatorsApy, VerifyZkLoginSignatureParams, ZkLoginVerifyResult } from './types/index.js';
8
8
  export interface PaginationArguments<Cursor> {
@@ -20,6 +20,7 @@ export interface OrderArguments {
20
20
  */
21
21
  export type SuiClientOptions = NetworkOrTransport & {
22
22
  network?: Experimental_SuiClientTypes.Network;
23
+ mvr?: Experimental_SuiClientTypes.MvrOptions;
23
24
  };
24
25
  type NetworkOrTransport = {
25
26
  url: string;
@@ -47,7 +48,7 @@ export declare class SuiClient extends Experimental_BaseClient implements SelfRe
47
48
  /**
48
49
  * Get all Coin<`coin_type`> objects owned by an address.
49
50
  */
50
- getCoins(input: GetCoinsParams): Promise<PaginatedCoins>;
51
+ getCoins({ coinType, owner, cursor, limit, signal, }: GetCoinsParams): Promise<PaginatedCoins>;
51
52
  /**
52
53
  * Get all Coin objects owned by an address.
53
54
  */
@@ -55,7 +56,7 @@ export declare class SuiClient extends Experimental_BaseClient implements SelfRe
55
56
  /**
56
57
  * Get the total coin balance for one coin type, owned by the address owner.
57
58
  */
58
- getBalance(input: GetBalanceParams): Promise<CoinBalance>;
59
+ getBalance({ owner, coinType, signal }: GetBalanceParams): Promise<CoinBalance>;
59
60
  /**
60
61
  * Get the total coin balance for all coin types, owned by the address owner.
61
62
  */
@@ -63,11 +64,11 @@ export declare class SuiClient extends Experimental_BaseClient implements SelfRe
63
64
  /**
64
65
  * Fetch CoinMetadata for a given coin type
65
66
  */
66
- getCoinMetadata(input: GetCoinMetadataParams): Promise<CoinMetadata | null>;
67
+ getCoinMetadata({ coinType, signal }: GetCoinMetadataParams): Promise<CoinMetadata | null>;
67
68
  /**
68
69
  * Fetch total supply for a coin
69
70
  */
70
- getTotalSupply(input: GetTotalSupplyParams): Promise<CoinSupply>;
71
+ getTotalSupply({ coinType, signal }: GetTotalSupplyParams): Promise<CoinSupply>;
71
72
  /**
72
73
  * Invoke any RPC method
73
74
  * @param method the method to be invoked
@@ -79,24 +80,24 @@ export declare class SuiClient extends Experimental_BaseClient implements SelfRe
79
80
  /**
80
81
  * Get Move function argument types like read, write and full access
81
82
  */
82
- getMoveFunctionArgTypes(input: GetMoveFunctionArgTypesParams): Promise<SuiMoveFunctionArgType[]>;
83
+ getMoveFunctionArgTypes({ package: pkg, module, function: fn, signal, }: GetMoveFunctionArgTypesParams): Promise<SuiMoveFunctionArgType[]>;
83
84
  /**
84
85
  * Get a map from module name to
85
86
  * structured representations of Move modules
86
87
  */
87
- getNormalizedMoveModulesByPackage(input: GetNormalizedMoveModulesByPackageParams): Promise<SuiMoveNormalizedModules>;
88
+ getNormalizedMoveModulesByPackage({ package: pkg, signal, }: GetNormalizedMoveModulesByPackageParams): Promise<SuiMoveNormalizedModules>;
88
89
  /**
89
90
  * Get a structured representation of Move module
90
91
  */
91
- getNormalizedMoveModule(input: GetNormalizedMoveModuleParams): Promise<SuiMoveNormalizedModule>;
92
+ getNormalizedMoveModule({ package: pkg, module, signal, }: GetNormalizedMoveModuleParams): Promise<SuiMoveNormalizedModule>;
92
93
  /**
93
94
  * Get a structured representation of Move function
94
95
  */
95
- getNormalizedMoveFunction(input: GetNormalizedMoveFunctionParams): Promise<SuiMoveNormalizedFunction>;
96
+ getNormalizedMoveFunction({ package: pkg, module, function: fn, signal, }: GetNormalizedMoveFunctionParams): Promise<SuiMoveNormalizedFunction>;
96
97
  /**
97
98
  * Get a structured representation of Move struct
98
99
  */
99
- getNormalizedMoveStruct(input: GetNormalizedMoveStructParams): Promise<SuiMoveNormalizedStruct>;
100
+ getNormalizedMoveStruct({ package: pkg, module, struct, signal, }: GetNormalizedMoveStructParams): Promise<SuiMoveNormalizedStruct>;
100
101
  /**
101
102
  * Get all objects owned by an address
102
103
  */
@@ -113,7 +114,7 @@ export declare class SuiClient extends Experimental_BaseClient implements SelfRe
113
114
  /**
114
115
  * Get transaction blocks for a given query criteria
115
116
  */
116
- queryTransactionBlocks(input: QueryTransactionBlocksParams): Promise<PaginatedTransactionResponse>;
117
+ queryTransactionBlocks({ filter, options, cursor, limit, order, signal, }: QueryTransactionBlocksParams): Promise<PaginatedTransactionResponse>;
117
118
  getTransactionBlock(input: GetTransactionBlockParams): Promise<SuiTransactionBlockResponse>;
118
119
  multiGetTransactionBlocks(input: MultiGetTransactionBlocksParams): Promise<SuiTransactionBlockResponse[]>;
119
120
  executeTransactionBlock({ transactionBlock, signature, options, requestType, signal, }: ExecuteTransactionBlockParams): Promise<SuiTransactionBlockResponse>;
@@ -146,7 +147,7 @@ export declare class SuiClient extends Experimental_BaseClient implements SelfRe
146
147
  /**
147
148
  * Get events for a given query criteria
148
149
  */
149
- queryEvents(input: QueryEventsParams): Promise<PaginatedEvents>;
150
+ queryEvents({ query, cursor, limit, order, signal, }: QueryEventsParams): Promise<PaginatedEvents>;
150
151
  /**
151
152
  * Subscribe to get notifications whenever an event matching the filter occurs
152
153
  *