@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
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
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);
|
|
25
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
26
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
27
|
+
var mvr_exports = {};
|
|
28
|
+
__export(mvr_exports, {
|
|
29
|
+
MvrClient: () => MvrClient,
|
|
30
|
+
extractMvrTypes: () => extractMvrTypes,
|
|
31
|
+
findNamesInTransaction: () => findNamesInTransaction,
|
|
32
|
+
hasMvrName: () => hasMvrName,
|
|
33
|
+
replaceNames: () => replaceNames
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(mvr_exports);
|
|
36
|
+
var import_utils = require("@mysten/utils");
|
|
37
|
+
var import_move_registry = require("../utils/move-registry.js");
|
|
38
|
+
var import_sui_types = require("../utils/sui-types.js");
|
|
39
|
+
var import_version = require("../version.js");
|
|
40
|
+
var _cache, _url, _pageSize, _overrides, _MvrClient_instances, mvrPackageDataLoader_get, mvrTypeDataLoader_get, resolvePackages_fn, resolveTypes_fn, fetch_fn;
|
|
41
|
+
const NAME_SEPARATOR = "/";
|
|
42
|
+
const MVR_API_HEADER = {
|
|
43
|
+
"Mvr-Source": `@mysten/sui@${import_version.PACKAGE_VERSION}`
|
|
44
|
+
};
|
|
45
|
+
class MvrClient {
|
|
46
|
+
constructor({ cache, url, pageSize = 50, overrides }) {
|
|
47
|
+
__privateAdd(this, _MvrClient_instances);
|
|
48
|
+
__privateAdd(this, _cache);
|
|
49
|
+
__privateAdd(this, _url);
|
|
50
|
+
__privateAdd(this, _pageSize);
|
|
51
|
+
__privateAdd(this, _overrides);
|
|
52
|
+
__privateSet(this, _cache, cache);
|
|
53
|
+
__privateSet(this, _url, url);
|
|
54
|
+
__privateSet(this, _pageSize, pageSize);
|
|
55
|
+
__privateSet(this, _overrides, {
|
|
56
|
+
packages: overrides?.packages,
|
|
57
|
+
types: overrides?.types
|
|
58
|
+
});
|
|
59
|
+
validateOverrides(__privateGet(this, _overrides));
|
|
60
|
+
}
|
|
61
|
+
async resolvePackage({
|
|
62
|
+
package: name
|
|
63
|
+
}) {
|
|
64
|
+
const resolved = await __privateGet(this, _MvrClient_instances, mvrPackageDataLoader_get).load(name);
|
|
65
|
+
return {
|
|
66
|
+
package: resolved
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async resolveType({
|
|
70
|
+
type
|
|
71
|
+
}) {
|
|
72
|
+
const mvrTypes = [...extractMvrTypes(type)];
|
|
73
|
+
const resolvedTypes = await __privateGet(this, _MvrClient_instances, mvrTypeDataLoader_get).loadMany(mvrTypes);
|
|
74
|
+
const typeMap = {};
|
|
75
|
+
for (let i = 0; i < mvrTypes.length; i++) {
|
|
76
|
+
const resolvedType = resolvedTypes[i];
|
|
77
|
+
if (resolvedType instanceof Error) {
|
|
78
|
+
throw resolvedType;
|
|
79
|
+
}
|
|
80
|
+
typeMap[mvrTypes[i]] = resolvedType;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
type: replaceMvrNames(type, typeMap)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async resolve({
|
|
87
|
+
types = [],
|
|
88
|
+
packages = []
|
|
89
|
+
}) {
|
|
90
|
+
const mvrTypes = /* @__PURE__ */ new Set();
|
|
91
|
+
for (const type of types ?? []) {
|
|
92
|
+
extractMvrTypes(type, mvrTypes);
|
|
93
|
+
}
|
|
94
|
+
const typesArray = [...mvrTypes];
|
|
95
|
+
const [resolvedTypes, resolvedPackages] = await Promise.all([
|
|
96
|
+
typesArray.length > 0 ? __privateGet(this, _MvrClient_instances, mvrTypeDataLoader_get).loadMany(typesArray) : [],
|
|
97
|
+
packages.length > 0 ? __privateGet(this, _MvrClient_instances, mvrPackageDataLoader_get).loadMany(packages) : []
|
|
98
|
+
]);
|
|
99
|
+
const typeMap = {
|
|
100
|
+
...__privateGet(this, _overrides)?.types
|
|
101
|
+
};
|
|
102
|
+
for (const [i, type] of typesArray.entries()) {
|
|
103
|
+
const resolvedType = resolvedTypes[i];
|
|
104
|
+
if (resolvedType instanceof Error) {
|
|
105
|
+
throw resolvedType;
|
|
106
|
+
}
|
|
107
|
+
typeMap[type] = resolvedType;
|
|
108
|
+
}
|
|
109
|
+
const replacedTypes = {};
|
|
110
|
+
for (const type of types ?? []) {
|
|
111
|
+
const resolvedType = replaceMvrNames(type, typeMap);
|
|
112
|
+
replacedTypes[type] = {
|
|
113
|
+
type: resolvedType
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const replacedPackages = {};
|
|
117
|
+
for (const [i, pkg] of (packages ?? []).entries()) {
|
|
118
|
+
const resolvedPkg = __privateGet(this, _overrides)?.packages?.[pkg] ?? resolvedPackages[i];
|
|
119
|
+
if (resolvedPkg instanceof Error) {
|
|
120
|
+
throw resolvedPkg;
|
|
121
|
+
}
|
|
122
|
+
replacedPackages[pkg] = {
|
|
123
|
+
package: resolvedPkg
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
types: replacedTypes,
|
|
128
|
+
packages: replacedPackages
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
_cache = new WeakMap();
|
|
133
|
+
_url = new WeakMap();
|
|
134
|
+
_pageSize = new WeakMap();
|
|
135
|
+
_overrides = new WeakMap();
|
|
136
|
+
_MvrClient_instances = new WeakSet();
|
|
137
|
+
mvrPackageDataLoader_get = function() {
|
|
138
|
+
return __privateGet(this, _cache).readSync(["#mvrPackageDataLoader", __privateGet(this, _url) ?? ""], () => {
|
|
139
|
+
const loader = new import_utils.DataLoader(async (packages) => {
|
|
140
|
+
if (!__privateGet(this, _url)) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`MVR Api URL is not set for the current client (resolving ${packages.join(", ")})`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const resolved = await __privateMethod(this, _MvrClient_instances, resolvePackages_fn).call(this, packages);
|
|
146
|
+
return packages.map(
|
|
147
|
+
(pkg) => resolved[pkg] ?? new Error(`Failed to resolve package: ${pkg}`)
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
const overrides = __privateGet(this, _overrides)?.packages;
|
|
151
|
+
if (overrides) {
|
|
152
|
+
for (const [pkg, id] of Object.entries(overrides)) {
|
|
153
|
+
loader.prime(pkg, id);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return loader;
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
mvrTypeDataLoader_get = function() {
|
|
160
|
+
return __privateGet(this, _cache).readSync(["#mvrTypeDataLoader", __privateGet(this, _url) ?? ""], () => {
|
|
161
|
+
const loader = new import_utils.DataLoader(async (types) => {
|
|
162
|
+
if (!__privateGet(this, _url)) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`MVR Api URL is not set for the current client (resolving ${types.join(", ")})`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const resolved = await __privateMethod(this, _MvrClient_instances, resolveTypes_fn).call(this, types);
|
|
168
|
+
return types.map((type) => resolved[type] ?? new Error(`Failed to resolve type: ${type}`));
|
|
169
|
+
});
|
|
170
|
+
const overrides = __privateGet(this, _overrides)?.types;
|
|
171
|
+
if (overrides) {
|
|
172
|
+
for (const [type, id] of Object.entries(overrides)) {
|
|
173
|
+
loader.prime(type, id);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return loader;
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
resolvePackages_fn = async function(packages) {
|
|
180
|
+
if (packages.length === 0) return {};
|
|
181
|
+
const batches = (0, import_utils.chunk)(packages, __privateGet(this, _pageSize));
|
|
182
|
+
const results = {};
|
|
183
|
+
await Promise.all(
|
|
184
|
+
batches.map(async (batch) => {
|
|
185
|
+
const data = await __privateMethod(this, _MvrClient_instances, fetch_fn).call(this, "/v1/resolution/bulk", {
|
|
186
|
+
names: batch
|
|
187
|
+
});
|
|
188
|
+
if (!data?.resolution) return;
|
|
189
|
+
for (const pkg of Object.keys(data?.resolution)) {
|
|
190
|
+
const pkgData = data.resolution[pkg]?.package_id;
|
|
191
|
+
if (!pkgData) continue;
|
|
192
|
+
results[pkg] = pkgData;
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
return results;
|
|
197
|
+
};
|
|
198
|
+
resolveTypes_fn = async function(types) {
|
|
199
|
+
if (types.length === 0) return {};
|
|
200
|
+
const batches = (0, import_utils.chunk)(types, __privateGet(this, _pageSize));
|
|
201
|
+
const results = {};
|
|
202
|
+
await Promise.all(
|
|
203
|
+
batches.map(async (batch) => {
|
|
204
|
+
const data = await __privateMethod(this, _MvrClient_instances, fetch_fn).call(this, "/v1/struct-definition/bulk", {
|
|
205
|
+
types: batch
|
|
206
|
+
});
|
|
207
|
+
if (!data?.resolution) return;
|
|
208
|
+
for (const type of Object.keys(data?.resolution)) {
|
|
209
|
+
const typeData = data.resolution[type]?.type_tag;
|
|
210
|
+
if (!typeData) continue;
|
|
211
|
+
results[type] = typeData;
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
);
|
|
215
|
+
return results;
|
|
216
|
+
};
|
|
217
|
+
fetch_fn = async function(url, body) {
|
|
218
|
+
if (!__privateGet(this, _url)) {
|
|
219
|
+
throw new Error("MVR Api URL is not set for the current client");
|
|
220
|
+
}
|
|
221
|
+
const response = await fetch(`${__privateGet(this, _url)}${url}`, {
|
|
222
|
+
method: "POST",
|
|
223
|
+
headers: {
|
|
224
|
+
"Content-Type": "application/json",
|
|
225
|
+
...MVR_API_HEADER
|
|
226
|
+
},
|
|
227
|
+
body: JSON.stringify(body)
|
|
228
|
+
});
|
|
229
|
+
if (!response.ok) {
|
|
230
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
231
|
+
throw new Error(`Failed to resolve types: ${errorBody?.message}`);
|
|
232
|
+
}
|
|
233
|
+
return response.json();
|
|
234
|
+
};
|
|
235
|
+
function validateOverrides(overrides) {
|
|
236
|
+
if (overrides?.packages) {
|
|
237
|
+
for (const [pkg, id] of Object.entries(overrides.packages)) {
|
|
238
|
+
if (!(0, import_move_registry.isValidNamedPackage)(pkg)) {
|
|
239
|
+
throw new Error(`Invalid package name: ${pkg}`);
|
|
240
|
+
}
|
|
241
|
+
if (!(0, import_sui_types.isValidSuiAddress)((0, import_sui_types.normalizeSuiAddress)(id))) {
|
|
242
|
+
throw new Error(`Invalid package ID: ${id}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (overrides?.types) {
|
|
247
|
+
for (const [type, val] of Object.entries(overrides.types)) {
|
|
248
|
+
if ((0, import_sui_types.parseStructTag)(type).typeParams.length > 0) {
|
|
249
|
+
throw new Error(
|
|
250
|
+
"Type overrides must be first-level only. If you want to supply generic types, just pass each type individually."
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
const parsedValue = (0, import_sui_types.parseStructTag)(val);
|
|
254
|
+
if (!(0, import_sui_types.isValidSuiAddress)(parsedValue.address)) {
|
|
255
|
+
throw new Error(`Invalid type: ${val}`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function extractMvrTypes(type, types = /* @__PURE__ */ new Set()) {
|
|
261
|
+
if (typeof type === "string" && !hasMvrName(type)) return types;
|
|
262
|
+
const tag = isStructTag(type) ? type : (0, import_sui_types.parseStructTag)(type);
|
|
263
|
+
if (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);
|
|
264
|
+
for (const param of tag.typeParams) {
|
|
265
|
+
extractMvrTypes(param, types);
|
|
266
|
+
}
|
|
267
|
+
return types;
|
|
268
|
+
}
|
|
269
|
+
function replaceMvrNames(tag, typeCache) {
|
|
270
|
+
const type = isStructTag(tag) ? tag : (0, import_sui_types.parseStructTag)(tag);
|
|
271
|
+
const typeTag = `${type.address}::${type.module}::${type.name}`;
|
|
272
|
+
const cacheHit = typeCache[typeTag];
|
|
273
|
+
return (0, import_sui_types.normalizeStructTag)({
|
|
274
|
+
...type,
|
|
275
|
+
address: cacheHit ? cacheHit.split("::")[0] : type.address,
|
|
276
|
+
typeParams: type.typeParams.map((param) => replaceMvrNames(param, typeCache))
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function hasMvrName(nameOrType) {
|
|
280
|
+
return nameOrType.includes(NAME_SEPARATOR) || nameOrType.includes("@") || nameOrType.includes(".sui");
|
|
281
|
+
}
|
|
282
|
+
function isStructTag(type) {
|
|
283
|
+
return typeof type === "object" && "address" in type && "module" in type && "name" in type && "typeParams" in type;
|
|
284
|
+
}
|
|
285
|
+
function findNamesInTransaction(builder) {
|
|
286
|
+
const packages = /* @__PURE__ */ new Set();
|
|
287
|
+
const types = /* @__PURE__ */ new Set();
|
|
288
|
+
for (const command of builder.commands) {
|
|
289
|
+
switch (command.$kind) {
|
|
290
|
+
case "MakeMoveVec":
|
|
291
|
+
if (command.MakeMoveVec.type) {
|
|
292
|
+
getNamesFromTypeList([command.MakeMoveVec.type]).forEach((type) => {
|
|
293
|
+
types.add(type);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
case "MoveCall":
|
|
298
|
+
const moveCall = command.MoveCall;
|
|
299
|
+
const pkg = moveCall.package.split("::")[0];
|
|
300
|
+
if (hasMvrName(pkg)) {
|
|
301
|
+
if (!(0, import_move_registry.isValidNamedPackage)(pkg)) throw new Error(`Invalid package name: ${pkg}`);
|
|
302
|
+
packages.add(pkg);
|
|
303
|
+
}
|
|
304
|
+
getNamesFromTypeList(moveCall.typeArguments ?? []).forEach((type) => {
|
|
305
|
+
types.add(type);
|
|
306
|
+
});
|
|
307
|
+
break;
|
|
308
|
+
default:
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
packages: [...packages],
|
|
314
|
+
types: [...types]
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function replaceNames(builder, resolved) {
|
|
318
|
+
for (const command of builder.commands) {
|
|
319
|
+
if (command.MakeMoveVec?.type) {
|
|
320
|
+
if (!hasMvrName(command.MakeMoveVec.type)) continue;
|
|
321
|
+
if (!resolved.types[command.MakeMoveVec.type])
|
|
322
|
+
throw new Error(`No resolution found for type: ${command.MakeMoveVec.type}`);
|
|
323
|
+
command.MakeMoveVec.type = resolved.types[command.MakeMoveVec.type].type;
|
|
324
|
+
}
|
|
325
|
+
const tx = command.MoveCall;
|
|
326
|
+
if (!tx) continue;
|
|
327
|
+
const nameParts = tx.package.split("::");
|
|
328
|
+
const name = nameParts[0];
|
|
329
|
+
if (hasMvrName(name) && !resolved.packages[name])
|
|
330
|
+
throw new Error(`No address found for package: ${name}`);
|
|
331
|
+
if (hasMvrName(name)) {
|
|
332
|
+
nameParts[0] = resolved.packages[name].package;
|
|
333
|
+
tx.package = nameParts.join("::");
|
|
334
|
+
}
|
|
335
|
+
const types = tx.typeArguments;
|
|
336
|
+
if (!types) continue;
|
|
337
|
+
for (let i = 0; i < types.length; i++) {
|
|
338
|
+
if (!hasMvrName(types[i])) continue;
|
|
339
|
+
if (!resolved.types[types[i]]) throw new Error(`No resolution found for type: ${types[i]}`);
|
|
340
|
+
types[i] = resolved.types[types[i]].type;
|
|
341
|
+
}
|
|
342
|
+
tx.typeArguments = types;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function getNamesFromTypeList(types) {
|
|
346
|
+
const names = /* @__PURE__ */ new Set();
|
|
347
|
+
for (const type of types) {
|
|
348
|
+
if (hasMvrName(type)) {
|
|
349
|
+
if (!(0, import_move_registry.isValidNamedType)(type)) throw new Error(`Invalid type with names: ${type}`);
|
|
350
|
+
names.add(type);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return names;
|
|
354
|
+
}
|
|
355
|
+
//# 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAkC;AAClC,2BAAsD;AAEtD,uBAKO;AAGP,qBAAgC;AAdhC;AAiBA,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAAA,EACtB,cAAc,eAAe,8BAAe;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,UAAM,UAAkC,CAAC;AAEzC,aAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACzC,YAAM,eAAe,cAAc,CAAC;AACpC,UAAI,wBAAwB,OAAO;AAClC,cAAM;AAAA,MACP;AACA,cAAQ,SAAS,CAAC,CAAC,IAAI;AAAA,IACxB;AAEA,WAAO;AAAA,MACN,MAAM,gBA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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,KAAC,uCAAiB,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>;
|
|
@@ -38,8 +38,11 @@ var import_dynamic_fields = require("../../utils/dynamic-fields.js");
|
|
|
38
38
|
var import_utils2 = require("./utils.js");
|
|
39
39
|
var _graphqlClient, _GraphQLTransport_instances, graphqlQuery_fn;
|
|
40
40
|
class GraphQLTransport extends import_core.Experimental_CoreClient {
|
|
41
|
-
constructor(
|
|
42
|
-
|
|
41
|
+
constructor({
|
|
42
|
+
graphqlClient,
|
|
43
|
+
mvr
|
|
44
|
+
}) {
|
|
45
|
+
super({ network: graphqlClient.network, base: graphqlClient, mvr });
|
|
43
46
|
__privateAdd(this, _GraphQLTransport_instances);
|
|
44
47
|
__privateAdd(this, _graphqlClient);
|
|
45
48
|
__privateSet(this, _graphqlClient, graphqlClient);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/experimental/transports/graphql.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Experimental_CoreClient } from '../core.js';\nimport type { Experimental_SuiClientTypes } from '../types.js';\nimport type { GraphQLQueryOptions, SuiGraphQLClient } from '../../graphql/client.js';\nimport type {\n\tObject_Owner_FieldsFragment,\n\tObject_FieldsFragment,\n\tTransaction_FieldsFragment,\n} from '../../graphql/generated/queries.js';\nimport {\n\tDryRunTransactionBlockDocument,\n\tExecuteTransactionBlockDocument,\n\tGetAllBalancesDocument,\n\tGetBalanceDocument,\n\tGetCoinsDocument,\n\tGetDynamicFieldsDocument,\n\tGetOwnedObjectsDocument,\n\tGetReferenceGasPriceDocument,\n\tGetTransactionBlockDocument,\n\tMultiGetObjectsDocument,\n\tResolveNameServiceNamesDocument,\n\tVerifyZkLoginSignatureDocument,\n\tZkLoginIntentScope,\n} from '../../graphql/generated/queries.js';\nimport { ObjectError } from '../errors.js';\nimport { fromBase64, toBase64 } from '@mysten/utils';\nimport { normalizeStructTag, normalizeSuiAddress } from '../../utils/sui-types.js';\nimport { deriveDynamicFieldID } from '../../utils/dynamic-fields.js';\nimport { parseTransactionBcs, parseTransactionEffectsBcs } from './utils.js';\n\nexport class GraphQLTransport extends Experimental_CoreClient {\n\t#graphqlClient: SuiGraphQLClient;\n\n\tconstructor(graphqlClient: SuiGraphQLClient) {\n\t\tsuper({ network: graphqlClient.network });\n\t\tthis.#graphqlClient = graphqlClient;\n\t}\n\n\tasync #graphqlQuery<\n\t\tResult = Record<string, unknown>,\n\t\tVariables = Record<string, unknown>,\n\t\tData = Result,\n\t>(\n\t\toptions: GraphQLQueryOptions<Result, Variables>,\n\t\tgetData?: (result: Result) => Data,\n\t): Promise<NonNullable<Data>> {\n\t\tconst { data, errors } = await this.#graphqlClient.query(options);\n\n\t\thandleGraphQLErrors(errors);\n\n\t\tconst extractedData = data && (getData ? getData(data) : data);\n\n\t\tif (extractedData == null) {\n\t\t\tthrow new Error('Missing response data');\n\t\t}\n\n\t\treturn extractedData as NonNullable<Data>;\n\t}\n\n\tasync getObjects(\n\t\toptions: Experimental_SuiClientTypes.GetObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectsResponse> {\n\t\tconst objects: Object_FieldsFragment[] = [];\n\n\t\tlet hasNextPage = true;\n\t\tlet cursor: string | null = null;\n\n\t\twhile (hasNextPage) {\n\t\t\tconst objectsPage = await this.#graphqlQuery(\n\t\t\t\t{\n\t\t\t\t\tquery: MultiGetObjectsDocument,\n\t\t\t\t\tvariables: {\n\t\t\t\t\t\tobjectIds: options.objectIds,\n\t\t\t\t\t\tcursor,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t(result) => result.objects,\n\t\t\t);\n\n\t\t\tobjects.push(...objectsPage.nodes);\n\t\t\thasNextPage = objectsPage.pageInfo.hasNextPage;\n\t\t\tcursor = (objectsPage.pageInfo.endCursor ?? null) as string | null;\n\t\t}\n\n\t\treturn {\n\t\t\tobjects: options.objectIds\n\t\t\t\t.map((id) => normalizeSuiAddress(id))\n\t\t\t\t.map(\n\t\t\t\t\t(id) =>\n\t\t\t\t\t\tobjects.find((obj) => obj.address === id) ??\n\t\t\t\t\t\tnew ObjectError('notFound', `Object ${id} not found`),\n\t\t\t\t)\n\t\t\t\t.map((obj) => {\n\t\t\t\t\tif (obj instanceof ObjectError) {\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: obj.address,\n\t\t\t\t\t\tversion: obj.version.toString(),\n\t\t\t\t\t\tdigest: obj.digest!,\n\t\t\t\t\t\towner: mapOwner(obj.owner!),\n\t\t\t\t\t\ttype: obj.asMoveObject?.contents?.type?.repr!,\n\t\t\t\t\t\tcontent: Promise.resolve(\n\t\t\t\t\t\t\tobj.asMoveObject?.contents?.bcs\n\t\t\t\t\t\t\t\t? fromBase64(obj.asMoveObject.contents.bcs)\n\t\t\t\t\t\t\t\t: new Uint8Array(),\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t};\n\t}\n\tasync getOwnedObjects(\n\t\toptions: Experimental_SuiClientTypes.GetOwnedObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse> {\n\t\tconst objects = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetOwnedObjectsDocument,\n\t\t\t\tvariables: {\n\t\t\t\t\towner: options.address,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\tcursor: options.cursor,\n\t\t\t\t\tfilter: options.type ? { type: options.type } : undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.address?.objects,\n\t\t);\n\n\t\treturn {\n\t\t\tobjects: objects.nodes.map((obj) => ({\n\t\t\t\tid: obj.address,\n\t\t\t\tversion: obj.version.toString(),\n\t\t\t\tdigest: obj.digest!,\n\t\t\t\towner: mapOwner(obj.owner!),\n\t\t\t\ttype: obj.contents?.type?.repr!,\n\t\t\t\tcontent: Promise.resolve(\n\t\t\t\t\tobj.contents?.bcs ? fromBase64(obj.contents.bcs) : new Uint8Array(),\n\t\t\t\t),\n\t\t\t})),\n\t\t\thasNextPage: objects.pageInfo.hasNextPage,\n\t\t\tcursor: objects.pageInfo.endCursor ?? null,\n\t\t};\n\t}\n\tasync getCoins(\n\t\toptions: Experimental_SuiClientTypes.GetCoinsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetCoinsResponse> {\n\t\tconst coins = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetCoinsDocument,\n\t\t\t\tvariables: {\n\t\t\t\t\towner: options.address,\n\t\t\t\t\tcursor: options.cursor,\n\t\t\t\t\tfirst: options.limit,\n\t\t\t\t\ttype: options.coinType,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.address?.coins,\n\t\t);\n\n\t\treturn {\n\t\t\tcursor: coins.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: coins.pageInfo.hasNextPage,\n\t\t\tobjects: coins.nodes.map((coin) => ({\n\t\t\t\tid: coin.address,\n\t\t\t\tversion: coin.version.toString(),\n\t\t\t\tdigest: coin.digest!,\n\t\t\t\towner: mapOwner(coin.owner!),\n\t\t\t\ttype: coin.contents?.type?.repr!,\n\t\t\t\tbalance: coin.coinBalance,\n\t\t\t\tcontent: Promise.resolve(\n\t\t\t\t\tcoin.contents?.bcs ? fromBase64(coin.contents.bcs) : new Uint8Array(),\n\t\t\t\t),\n\t\t\t})),\n\t\t};\n\t}\n\n\tasync getBalance(\n\t\toptions: Experimental_SuiClientTypes.GetBalanceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetBalanceResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetBalanceDocument,\n\t\t\t\tvariables: { owner: options.address, type: options.coinType },\n\t\t\t},\n\t\t\t(result) => result.address?.balance,\n\t\t);\n\n\t\treturn {\n\t\t\tbalance: {\n\t\t\t\tcoinType: result.coinType.repr,\n\t\t\t\tbalance: result.totalBalance,\n\t\t\t},\n\t\t};\n\t}\n\tasync getAllBalances(\n\t\toptions: Experimental_SuiClientTypes.GetAllBalancesOptions,\n\t): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse> {\n\t\tconst balances = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetAllBalancesDocument,\n\t\t\t\tvariables: { owner: options.address },\n\t\t\t},\n\t\t\t(result) => result.address?.balances,\n\t\t);\n\n\t\treturn {\n\t\t\tcursor: balances.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: balances.pageInfo.hasNextPage,\n\t\t\tbalances: balances.nodes.map((balance) => ({\n\t\t\t\tcoinType: balance.coinType.repr,\n\t\t\t\tbalance: balance.totalBalance,\n\t\t\t})),\n\t\t};\n\t}\n\tasync getTransaction(\n\t\toptions: Experimental_SuiClientTypes.GetTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetTransactionBlockDocument,\n\t\t\t\tvariables: { digest: options.digest },\n\t\t\t},\n\t\t\t(result) => result.transactionBlock,\n\t\t);\n\n\t\treturn {\n\t\t\ttransaction: parseTransaction(result),\n\t\t};\n\t}\n\tasync executeTransaction(\n\t\toptions: Experimental_SuiClientTypes.ExecuteTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: ExecuteTransactionBlockDocument,\n\t\t\t\tvariables: { txBytes: toBase64(options.transaction), signatures: options.signatures },\n\t\t\t},\n\t\t\t(result) => result.executeTransactionBlock,\n\t\t);\n\n\t\tif (result.errors) {\n\t\t\tif (result.errors.length === 1) {\n\t\t\t\tthrow new Error(result.errors[0]);\n\t\t\t}\n\t\t\tthrow new AggregateError(result.errors.map((error) => new Error(error)));\n\t\t}\n\n\t\treturn {\n\t\t\ttransaction: parseTransaction(result.effects.transactionBlock!),\n\t\t};\n\t}\n\tasync dryRunTransaction(\n\t\toptions: Experimental_SuiClientTypes.DryRunTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: DryRunTransactionBlockDocument,\n\t\t\t\tvariables: { txBytes: toBase64(options.transaction) },\n\t\t\t},\n\t\t\t(result) => result.dryRunTransactionBlock,\n\t\t);\n\n\t\tif (result.error) {\n\t\t\tthrow new Error(result.error);\n\t\t}\n\n\t\treturn {\n\t\t\ttransaction: parseTransaction(result.transaction!),\n\t\t};\n\t}\n\tasync getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetReferenceGasPriceDocument,\n\t\t\t},\n\t\t\t(result) => result.epoch?.referenceGasPrice,\n\t\t);\n\n\t\treturn {\n\t\t\treferenceGasPrice: result.referenceGasPrice,\n\t\t};\n\t}\n\n\tasync getDynamicFields(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetDynamicFieldsDocument,\n\t\t\t\tvariables: { parentId: options.parentId },\n\t\t\t},\n\t\t\t(result) => result.owner?.dynamicFields,\n\t\t);\n\n\t\treturn {\n\t\t\tdynamicFields: result.nodes.map((dynamicField) => {\n\t\t\t\tconst valueType =\n\t\t\t\t\tdynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t? dynamicField.value.contents?.type?.repr!\n\t\t\t\t\t\t: dynamicField.value?.type.repr!;\n\t\t\t\treturn {\n\t\t\t\t\tid: deriveDynamicFieldID(\n\t\t\t\t\t\toptions.parentId,\n\t\t\t\t\t\tdynamicField.name?.type.repr!,\n\t\t\t\t\t\tdynamicField.name?.bcs!,\n\t\t\t\t\t),\n\t\t\t\t\ttype: normalizeStructTag(\n\t\t\t\t\t\tdynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type.repr}>,0x2::object::ID>`\n\t\t\t\t\t\t\t: `0x2::dynamic_field::Field<${dynamicField.name?.type.repr},${valueType}>`,\n\t\t\t\t\t),\n\t\t\t\t\tname: {\n\t\t\t\t\t\ttype: dynamicField.name?.type.repr!,\n\t\t\t\t\t\tbcs: fromBase64(dynamicField.name?.bcs!),\n\t\t\t\t\t},\n\t\t\t\t\tvalueType,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tcursor: result.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: result.pageInfo.hasNextPage,\n\t\t};\n\t}\n\n\tasync verifyZkLoginSignature(\n\t\toptions: Experimental_SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<Experimental_SuiClientTypes.ZkLoginVerifyResponse> {\n\t\tconst intentScope =\n\t\t\toptions.intentScope === 'TransactionData'\n\t\t\t\t? ZkLoginIntentScope.TransactionData\n\t\t\t\t: ZkLoginIntentScope.PersonalMessage;\n\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: VerifyZkLoginSignatureDocument,\n\t\t\t\tvariables: {\n\t\t\t\t\tbytes: options.bytes,\n\t\t\t\t\tsignature: options.signature,\n\t\t\t\t\tintentScope,\n\t\t\t\t\tauthor: options.author,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.verifyZkloginSignature,\n\t\t);\n\n\t\treturn {\n\t\t\tsuccess: result.success,\n\t\t\terrors: result.errors,\n\t\t};\n\t}\n\n\tasync resolveNameServiceNames(\n\t\toptions: Experimental_SuiClientTypes.ResolveNameServiceNamesOptions,\n\t): Promise<Experimental_SuiClientTypes.ResolveNameServiceNamesResponse> {\n\t\tconst suinsRegistrations = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: ResolveNameServiceNamesDocument,\n\t\t\t\tsignal: options.signal,\n\t\t\t\tvariables: {\n\t\t\t\t\taddress: options.address,\n\t\t\t\t\tcursor: options.cursor,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.address?.suinsRegistrations,\n\t\t);\n\n\t\treturn {\n\t\t\thasNextPage: suinsRegistrations.pageInfo.hasNextPage,\n\t\t\tnextCursor: suinsRegistrations.pageInfo.endCursor ?? null,\n\t\t\tdata: suinsRegistrations.nodes.map((node) => node.domain) ?? [],\n\t\t};\n\t}\n\n\tresolveTransactionPlugin(): never {\n\t\tthrow new Error('GraphQL client does not support transaction resolution yet');\n\t}\n}\nexport type GraphQLResponseErrors = Array<{\n\tmessage: string;\n\tlocations?: { line: number; column: number }[];\n\tpath?: (string | number)[];\n}>;\n\nfunction handleGraphQLErrors(errors: GraphQLResponseErrors | undefined): void {\n\tif (!errors || errors.length === 0) return;\n\n\tconst errorInstances = errors.map((error) => new GraphQLResponseError(error));\n\n\tif (errorInstances.length === 1) {\n\t\tthrow errorInstances[0];\n\t}\n\n\tthrow new AggregateError(errorInstances);\n}\n\nclass GraphQLResponseError extends Error {\n\tlocations?: Array<{ line: number; column: number }>;\n\n\tconstructor(error: GraphQLResponseErrors[0]) {\n\t\tsuper(error.message);\n\t\tthis.locations = error.locations;\n\t}\n}\n\nfunction mapOwner(owner: Object_Owner_FieldsFragment): Experimental_SuiClientTypes.ObjectOwner {\n\tswitch (owner.__typename) {\n\t\tcase 'AddressOwner':\n\t\t\treturn { $kind: 'AddressOwner', AddressOwner: owner.owner?.asAddress?.address };\n\t\tcase 'ConsensusV2':\n\t\t\treturn { $kind: 'ConsensusV2', ConsensusV2: owner.authenticator!.address };\n\t\tcase 'Immutable':\n\t\t\treturn { $kind: 'Immutable', Immutable: true };\n\t\tcase 'Parent':\n\t\t\treturn { $kind: 'ObjectOwner', ObjectOwner: owner.parent?.address };\n\t\tcase 'Shared':\n\t\t\treturn { $kind: 'Shared', Shared: owner.initialSharedVersion };\n\t}\n}\n\nfunction parseTransaction(\n\ttransaction: Transaction_FieldsFragment,\n): Experimental_SuiClientTypes.TransactionResponse {\n\tconst objectTypes: Record<string, string> = {};\n\n\ttransaction.effects?.unchangedSharedObjects.nodes.forEach((node) => {\n\t\tif (node.__typename === 'SharedObjectRead') {\n\t\t\tconst type = node.object?.asMoveObject?.contents?.type.repr;\n\t\t\tconst address = node.object?.asMoveObject?.address;\n\n\t\t\tif (type && address) {\n\t\t\t\tobjectTypes[address] = type;\n\t\t\t}\n\t\t}\n\t});\n\n\ttransaction.effects?.objectChanges.nodes.forEach((node) => {\n\t\tconst address = node.address;\n\t\tconst type =\n\t\t\tnode.inputState?.asMoveObject?.contents?.type.repr ??\n\t\t\tnode.outputState?.asMoveObject?.contents?.type.repr;\n\n\t\tif (address && type) {\n\t\t\tobjectTypes[address] = type;\n\t\t}\n\t});\n\n\treturn {\n\t\tdigest: transaction.digest!,\n\t\teffects: parseTransactionEffectsBcs(new Uint8Array(transaction.effects?.bcs!)),\n\t\tepoch: transaction.effects?.epoch?.epochId ?? null,\n\t\tobjectTypes: Promise.resolve(objectTypes),\n\t\ttransaction: parseTransactionBcs(transaction.bcs!),\n\t\tsignatures: transaction.signatures!,\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwC;AAQxC,qBAcO;AACP,oBAA4B;AAC5B,mBAAqC;AACrC,uBAAwD;AACxD,4BAAqC;AACrC,IAAAA,gBAAgE;AA9BhE;AAgCO,MAAM,yBAAyB,oCAAwB;AAAA,EAG7D,YAAY,
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Experimental_CoreClient } from '../core.js';\nimport type { Experimental_SuiClientTypes } from '../types.js';\nimport type { GraphQLQueryOptions, SuiGraphQLClient } from '../../graphql/client.js';\nimport type {\n\tObject_Owner_FieldsFragment,\n\tObject_FieldsFragment,\n\tTransaction_FieldsFragment,\n} from '../../graphql/generated/queries.js';\nimport {\n\tDryRunTransactionBlockDocument,\n\tExecuteTransactionBlockDocument,\n\tGetAllBalancesDocument,\n\tGetBalanceDocument,\n\tGetCoinsDocument,\n\tGetDynamicFieldsDocument,\n\tGetOwnedObjectsDocument,\n\tGetReferenceGasPriceDocument,\n\tGetTransactionBlockDocument,\n\tMultiGetObjectsDocument,\n\tResolveNameServiceNamesDocument,\n\tVerifyZkLoginSignatureDocument,\n\tZkLoginIntentScope,\n} from '../../graphql/generated/queries.js';\nimport { ObjectError } from '../errors.js';\nimport { fromBase64, toBase64 } from '@mysten/utils';\nimport { normalizeStructTag, normalizeSuiAddress } from '../../utils/sui-types.js';\nimport { deriveDynamicFieldID } from '../../utils/dynamic-fields.js';\nimport { parseTransactionBcs, parseTransactionEffectsBcs } from './utils.js';\n\nexport class GraphQLTransport extends Experimental_CoreClient {\n\t#graphqlClient: SuiGraphQLClient;\n\n\tconstructor({\n\t\tgraphqlClient,\n\t\tmvr,\n\t}: {\n\t\tgraphqlClient: SuiGraphQLClient;\n\t\tmvr?: Experimental_SuiClientTypes.MvrOptions;\n\t}) {\n\t\tsuper({ network: graphqlClient.network, base: graphqlClient, mvr });\n\t\tthis.#graphqlClient = graphqlClient;\n\t}\n\n\tasync #graphqlQuery<\n\t\tResult = Record<string, unknown>,\n\t\tVariables = Record<string, unknown>,\n\t\tData = Result,\n\t>(\n\t\toptions: GraphQLQueryOptions<Result, Variables>,\n\t\tgetData?: (result: Result) => Data,\n\t): Promise<NonNullable<Data>> {\n\t\tconst { data, errors } = await this.#graphqlClient.query(options);\n\n\t\thandleGraphQLErrors(errors);\n\n\t\tconst extractedData = data && (getData ? getData(data) : data);\n\n\t\tif (extractedData == null) {\n\t\t\tthrow new Error('Missing response data');\n\t\t}\n\n\t\treturn extractedData as NonNullable<Data>;\n\t}\n\n\tasync getObjects(\n\t\toptions: Experimental_SuiClientTypes.GetObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectsResponse> {\n\t\tconst objects: Object_FieldsFragment[] = [];\n\n\t\tlet hasNextPage = true;\n\t\tlet cursor: string | null = null;\n\n\t\twhile (hasNextPage) {\n\t\t\tconst objectsPage = await this.#graphqlQuery(\n\t\t\t\t{\n\t\t\t\t\tquery: MultiGetObjectsDocument,\n\t\t\t\t\tvariables: {\n\t\t\t\t\t\tobjectIds: options.objectIds,\n\t\t\t\t\t\tcursor,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t(result) => result.objects,\n\t\t\t);\n\n\t\t\tobjects.push(...objectsPage.nodes);\n\t\t\thasNextPage = objectsPage.pageInfo.hasNextPage;\n\t\t\tcursor = (objectsPage.pageInfo.endCursor ?? null) as string | null;\n\t\t}\n\n\t\treturn {\n\t\t\tobjects: options.objectIds\n\t\t\t\t.map((id) => normalizeSuiAddress(id))\n\t\t\t\t.map(\n\t\t\t\t\t(id) =>\n\t\t\t\t\t\tobjects.find((obj) => obj.address === id) ??\n\t\t\t\t\t\tnew ObjectError('notFound', `Object ${id} not found`),\n\t\t\t\t)\n\t\t\t\t.map((obj) => {\n\t\t\t\t\tif (obj instanceof ObjectError) {\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: obj.address,\n\t\t\t\t\t\tversion: obj.version.toString(),\n\t\t\t\t\t\tdigest: obj.digest!,\n\t\t\t\t\t\towner: mapOwner(obj.owner!),\n\t\t\t\t\t\ttype: obj.asMoveObject?.contents?.type?.repr!,\n\t\t\t\t\t\tcontent: Promise.resolve(\n\t\t\t\t\t\t\tobj.asMoveObject?.contents?.bcs\n\t\t\t\t\t\t\t\t? fromBase64(obj.asMoveObject.contents.bcs)\n\t\t\t\t\t\t\t\t: new Uint8Array(),\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t};\n\t}\n\tasync getOwnedObjects(\n\t\toptions: Experimental_SuiClientTypes.GetOwnedObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse> {\n\t\tconst objects = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetOwnedObjectsDocument,\n\t\t\t\tvariables: {\n\t\t\t\t\towner: options.address,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\tcursor: options.cursor,\n\t\t\t\t\tfilter: options.type ? { type: options.type } : undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.address?.objects,\n\t\t);\n\n\t\treturn {\n\t\t\tobjects: objects.nodes.map((obj) => ({\n\t\t\t\tid: obj.address,\n\t\t\t\tversion: obj.version.toString(),\n\t\t\t\tdigest: obj.digest!,\n\t\t\t\towner: mapOwner(obj.owner!),\n\t\t\t\ttype: obj.contents?.type?.repr!,\n\t\t\t\tcontent: Promise.resolve(\n\t\t\t\t\tobj.contents?.bcs ? fromBase64(obj.contents.bcs) : new Uint8Array(),\n\t\t\t\t),\n\t\t\t})),\n\t\t\thasNextPage: objects.pageInfo.hasNextPage,\n\t\t\tcursor: objects.pageInfo.endCursor ?? null,\n\t\t};\n\t}\n\tasync getCoins(\n\t\toptions: Experimental_SuiClientTypes.GetCoinsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetCoinsResponse> {\n\t\tconst coins = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetCoinsDocument,\n\t\t\t\tvariables: {\n\t\t\t\t\towner: options.address,\n\t\t\t\t\tcursor: options.cursor,\n\t\t\t\t\tfirst: options.limit,\n\t\t\t\t\ttype: options.coinType,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.address?.coins,\n\t\t);\n\n\t\treturn {\n\t\t\tcursor: coins.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: coins.pageInfo.hasNextPage,\n\t\t\tobjects: coins.nodes.map((coin) => ({\n\t\t\t\tid: coin.address,\n\t\t\t\tversion: coin.version.toString(),\n\t\t\t\tdigest: coin.digest!,\n\t\t\t\towner: mapOwner(coin.owner!),\n\t\t\t\ttype: coin.contents?.type?.repr!,\n\t\t\t\tbalance: coin.coinBalance,\n\t\t\t\tcontent: Promise.resolve(\n\t\t\t\t\tcoin.contents?.bcs ? fromBase64(coin.contents.bcs) : new Uint8Array(),\n\t\t\t\t),\n\t\t\t})),\n\t\t};\n\t}\n\n\tasync getBalance(\n\t\toptions: Experimental_SuiClientTypes.GetBalanceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetBalanceResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetBalanceDocument,\n\t\t\t\tvariables: { owner: options.address, type: options.coinType },\n\t\t\t},\n\t\t\t(result) => result.address?.balance,\n\t\t);\n\n\t\treturn {\n\t\t\tbalance: {\n\t\t\t\tcoinType: result.coinType.repr,\n\t\t\t\tbalance: result.totalBalance,\n\t\t\t},\n\t\t};\n\t}\n\tasync getAllBalances(\n\t\toptions: Experimental_SuiClientTypes.GetAllBalancesOptions,\n\t): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse> {\n\t\tconst balances = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetAllBalancesDocument,\n\t\t\t\tvariables: { owner: options.address },\n\t\t\t},\n\t\t\t(result) => result.address?.balances,\n\t\t);\n\n\t\treturn {\n\t\t\tcursor: balances.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: balances.pageInfo.hasNextPage,\n\t\t\tbalances: balances.nodes.map((balance) => ({\n\t\t\t\tcoinType: balance.coinType.repr,\n\t\t\t\tbalance: balance.totalBalance,\n\t\t\t})),\n\t\t};\n\t}\n\tasync getTransaction(\n\t\toptions: Experimental_SuiClientTypes.GetTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetTransactionBlockDocument,\n\t\t\t\tvariables: { digest: options.digest },\n\t\t\t},\n\t\t\t(result) => result.transactionBlock,\n\t\t);\n\n\t\treturn {\n\t\t\ttransaction: parseTransaction(result),\n\t\t};\n\t}\n\tasync executeTransaction(\n\t\toptions: Experimental_SuiClientTypes.ExecuteTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: ExecuteTransactionBlockDocument,\n\t\t\t\tvariables: { txBytes: toBase64(options.transaction), signatures: options.signatures },\n\t\t\t},\n\t\t\t(result) => result.executeTransactionBlock,\n\t\t);\n\n\t\tif (result.errors) {\n\t\t\tif (result.errors.length === 1) {\n\t\t\t\tthrow new Error(result.errors[0]);\n\t\t\t}\n\t\t\tthrow new AggregateError(result.errors.map((error) => new Error(error)));\n\t\t}\n\n\t\treturn {\n\t\t\ttransaction: parseTransaction(result.effects.transactionBlock!),\n\t\t};\n\t}\n\tasync dryRunTransaction(\n\t\toptions: Experimental_SuiClientTypes.DryRunTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: DryRunTransactionBlockDocument,\n\t\t\t\tvariables: { txBytes: toBase64(options.transaction) },\n\t\t\t},\n\t\t\t(result) => result.dryRunTransactionBlock,\n\t\t);\n\n\t\tif (result.error) {\n\t\t\tthrow new Error(result.error);\n\t\t}\n\n\t\treturn {\n\t\t\ttransaction: parseTransaction(result.transaction!),\n\t\t};\n\t}\n\tasync getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetReferenceGasPriceDocument,\n\t\t\t},\n\t\t\t(result) => result.epoch?.referenceGasPrice,\n\t\t);\n\n\t\treturn {\n\t\t\treferenceGasPrice: result.referenceGasPrice,\n\t\t};\n\t}\n\n\tasync getDynamicFields(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse> {\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: GetDynamicFieldsDocument,\n\t\t\t\tvariables: { parentId: options.parentId },\n\t\t\t},\n\t\t\t(result) => result.owner?.dynamicFields,\n\t\t);\n\n\t\treturn {\n\t\t\tdynamicFields: result.nodes.map((dynamicField) => {\n\t\t\t\tconst valueType =\n\t\t\t\t\tdynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t? dynamicField.value.contents?.type?.repr!\n\t\t\t\t\t\t: dynamicField.value?.type.repr!;\n\t\t\t\treturn {\n\t\t\t\t\tid: deriveDynamicFieldID(\n\t\t\t\t\t\toptions.parentId,\n\t\t\t\t\t\tdynamicField.name?.type.repr!,\n\t\t\t\t\t\tdynamicField.name?.bcs!,\n\t\t\t\t\t),\n\t\t\t\t\ttype: normalizeStructTag(\n\t\t\t\t\t\tdynamicField.value?.__typename === 'MoveObject'\n\t\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type.repr}>,0x2::object::ID>`\n\t\t\t\t\t\t\t: `0x2::dynamic_field::Field<${dynamicField.name?.type.repr},${valueType}>`,\n\t\t\t\t\t),\n\t\t\t\t\tname: {\n\t\t\t\t\t\ttype: dynamicField.name?.type.repr!,\n\t\t\t\t\t\tbcs: fromBase64(dynamicField.name?.bcs!),\n\t\t\t\t\t},\n\t\t\t\t\tvalueType,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tcursor: result.pageInfo.endCursor ?? null,\n\t\t\thasNextPage: result.pageInfo.hasNextPage,\n\t\t};\n\t}\n\n\tasync verifyZkLoginSignature(\n\t\toptions: Experimental_SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<Experimental_SuiClientTypes.ZkLoginVerifyResponse> {\n\t\tconst intentScope =\n\t\t\toptions.intentScope === 'TransactionData'\n\t\t\t\t? ZkLoginIntentScope.TransactionData\n\t\t\t\t: ZkLoginIntentScope.PersonalMessage;\n\n\t\tconst result = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: VerifyZkLoginSignatureDocument,\n\t\t\t\tvariables: {\n\t\t\t\t\tbytes: options.bytes,\n\t\t\t\t\tsignature: options.signature,\n\t\t\t\t\tintentScope,\n\t\t\t\t\tauthor: options.author,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.verifyZkloginSignature,\n\t\t);\n\n\t\treturn {\n\t\t\tsuccess: result.success,\n\t\t\terrors: result.errors,\n\t\t};\n\t}\n\n\tasync resolveNameServiceNames(\n\t\toptions: Experimental_SuiClientTypes.ResolveNameServiceNamesOptions,\n\t): Promise<Experimental_SuiClientTypes.ResolveNameServiceNamesResponse> {\n\t\tconst suinsRegistrations = await this.#graphqlQuery(\n\t\t\t{\n\t\t\t\tquery: ResolveNameServiceNamesDocument,\n\t\t\t\tsignal: options.signal,\n\t\t\t\tvariables: {\n\t\t\t\t\taddress: options.address,\n\t\t\t\t\tcursor: options.cursor,\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t},\n\t\t\t},\n\t\t\t(result) => result.address?.suinsRegistrations,\n\t\t);\n\n\t\treturn {\n\t\t\thasNextPage: suinsRegistrations.pageInfo.hasNextPage,\n\t\t\tnextCursor: suinsRegistrations.pageInfo.endCursor ?? null,\n\t\t\tdata: suinsRegistrations.nodes.map((node) => node.domain) ?? [],\n\t\t};\n\t}\n\n\tresolveTransactionPlugin(): never {\n\t\tthrow new Error('GraphQL client does not support transaction resolution yet');\n\t}\n}\nexport type GraphQLResponseErrors = Array<{\n\tmessage: string;\n\tlocations?: { line: number; column: number }[];\n\tpath?: (string | number)[];\n}>;\n\nfunction handleGraphQLErrors(errors: GraphQLResponseErrors | undefined): void {\n\tif (!errors || errors.length === 0) return;\n\n\tconst errorInstances = errors.map((error) => new GraphQLResponseError(error));\n\n\tif (errorInstances.length === 1) {\n\t\tthrow errorInstances[0];\n\t}\n\n\tthrow new AggregateError(errorInstances);\n}\n\nclass GraphQLResponseError extends Error {\n\tlocations?: Array<{ line: number; column: number }>;\n\n\tconstructor(error: GraphQLResponseErrors[0]) {\n\t\tsuper(error.message);\n\t\tthis.locations = error.locations;\n\t}\n}\n\nfunction mapOwner(owner: Object_Owner_FieldsFragment): Experimental_SuiClientTypes.ObjectOwner {\n\tswitch (owner.__typename) {\n\t\tcase 'AddressOwner':\n\t\t\treturn { $kind: 'AddressOwner', AddressOwner: owner.owner?.asAddress?.address };\n\t\tcase 'ConsensusV2':\n\t\t\treturn { $kind: 'ConsensusV2', ConsensusV2: owner.authenticator!.address };\n\t\tcase 'Immutable':\n\t\t\treturn { $kind: 'Immutable', Immutable: true };\n\t\tcase 'Parent':\n\t\t\treturn { $kind: 'ObjectOwner', ObjectOwner: owner.parent?.address };\n\t\tcase 'Shared':\n\t\t\treturn { $kind: 'Shared', Shared: owner.initialSharedVersion };\n\t}\n}\n\nfunction parseTransaction(\n\ttransaction: Transaction_FieldsFragment,\n): Experimental_SuiClientTypes.TransactionResponse {\n\tconst objectTypes: Record<string, string> = {};\n\n\ttransaction.effects?.unchangedSharedObjects.nodes.forEach((node) => {\n\t\tif (node.__typename === 'SharedObjectRead') {\n\t\t\tconst type = node.object?.asMoveObject?.contents?.type.repr;\n\t\t\tconst address = node.object?.asMoveObject?.address;\n\n\t\t\tif (type && address) {\n\t\t\t\tobjectTypes[address] = type;\n\t\t\t}\n\t\t}\n\t});\n\n\ttransaction.effects?.objectChanges.nodes.forEach((node) => {\n\t\tconst address = node.address;\n\t\tconst type =\n\t\t\tnode.inputState?.asMoveObject?.contents?.type.repr ??\n\t\t\tnode.outputState?.asMoveObject?.contents?.type.repr;\n\n\t\tif (address && type) {\n\t\t\tobjectTypes[address] = type;\n\t\t}\n\t});\n\n\treturn {\n\t\tdigest: transaction.digest!,\n\t\teffects: parseTransactionEffectsBcs(new Uint8Array(transaction.effects?.bcs!)),\n\t\tepoch: transaction.effects?.epoch?.epochId ?? null,\n\t\tobjectTypes: Promise.resolve(objectTypes),\n\t\ttransaction: parseTransactionBcs(transaction.bcs!),\n\t\tsignatures: transaction.signatures!,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAA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AAa,WAAW,KAAK;AAAA,IAC9C,KAAK;AACJ,aAAO,EAAE,OAAO,eAAe,aAAa,MAAM,QAAQ,QAAQ;AAAA,IACnE,KAAK;AACJ,aAAO,EAAE,OAAO,UAAU,QAAQ,MAAM,qBAAqB;AAAA,EAC/D;AACD;AAEA,SAAS,iBACR,aACkD;AAClD,QAAM,cAAsC,CAAC;AAE7C,cAAY,SAAS,uBAAuB,MAAM,QAAQ,CAAC,SAAS;AACnE,QAAI,KAAK,eAAe,oBAAoB;AAC3C,YAAM,OAAO,KAAK,QAAQ,cAAc,UAAU,KAAK;AACvD,YAAM,UAAU,KAAK,QAAQ,cAAc;AAE3C,UAAI,QAAQ,SAAS;AACpB,oBAAY,OAAO,IAAI;AAAA,MACxB;AAAA,IACD;AAAA,EACD,CAAC;AAED,cAAY,SAAS,cAAc,MAAM,QAAQ,CAAC,SAAS;AAC1D,UAAM,UAAU,KAAK;AACrB,UAAM,OACL,KAAK,YAAY,cAAc,UAAU,KAAK,QAC9C,KAAK,aAAa,cAAc,UAAU,KAAK;AAEhD,QAAI,WAAW,MAAM;AACpB,kBAAY,OAAO,IAAI;AAAA,IACxB;AAAA,EACD,CAAC;AAED,SAAO;AAAA,IACN,QAAQ,YAAY;AAAA,IACpB,aAAS,0CAA2B,IAAI,WAAW,YAAY,SAAS,GAAI,CAAC;AAAA,IAC7E,OAAO,YAAY,SAAS,OAAO,WAAW;AAAA,IAC9C,aAAa,QAAQ,QAAQ,WAAW;AAAA,IACxC,iBAAa,mCAAoB,YAAY,GAAI;AAAA,IACjD,YAAY,YAAY;AAAA,EACzB;AACD;",
|
|
6
6
|
"names": ["import_utils", "result"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TransactionDataBuilder } from '../../transactions/TransactionData.js';
|
|
2
2
|
import type { SuiClient } from '../../client/index.js';
|
|
3
3
|
import type { BuildTransactionOptions } from '../../transactions/index.js';
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function suiClientResolveTransactionPlugin(client: SuiClient): (transactionData: TransactionDataBuilder, options: BuildTransactionOptions, next: () => Promise<void>) => Promise<void>;
|
|
@@ -18,7 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var json_rpc_resolver_exports = {};
|
|
20
20
|
__export(json_rpc_resolver_exports, {
|
|
21
|
-
|
|
21
|
+
suiClientResolveTransactionPlugin: () => suiClientResolveTransactionPlugin
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(json_rpc_resolver_exports);
|
|
24
24
|
var import_valibot = require("valibot");
|
|
@@ -30,7 +30,7 @@ var import_utils2 = require("@mysten/utils");
|
|
|
30
30
|
const MAX_OBJECTS_PER_FETCH = 50;
|
|
31
31
|
const GAS_SAFE_OVERHEAD = 1000n;
|
|
32
32
|
const MAX_GAS = 5e10;
|
|
33
|
-
function
|
|
33
|
+
function suiClientResolveTransactionPlugin(client) {
|
|
34
34
|
return async function resolveTransactionData(transactionData, options, next) {
|
|
35
35
|
await normalizeInputs(transactionData, client);
|
|
36
36
|
await resolveObjectReferences(transactionData, client);
|