@typemove/sui 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/builtin/0x1.d.ts +1030 -0
- package/dist/esm/builtin/0x1.d.ts.map +1 -0
- package/dist/esm/builtin/0x1.js +7799 -0
- package/dist/esm/builtin/0x1.js.map +1 -0
- package/dist/esm/builtin/0x2.d.ts +4766 -0
- package/dist/esm/builtin/0x2.d.ts.map +1 -0
- package/dist/esm/builtin/0x2.js +23180 -0
- package/dist/esm/builtin/0x2.js.map +1 -0
- package/dist/esm/builtin/0x3.d.ts +1964 -0
- package/dist/esm/builtin/0x3.d.ts.map +1 -0
- package/dist/esm/builtin/0x3.js +7606 -0
- package/dist/esm/builtin/0x3.js.map +1 -0
- package/dist/esm/builtin/index.d.ts +4 -0
- package/dist/esm/builtin/index.d.ts.map +1 -0
- package/dist/esm/builtin/index.js +7 -0
- package/dist/esm/builtin/index.js.map +1 -0
- package/dist/esm/codegen/codegen.d.ts +20 -0
- package/dist/esm/codegen/codegen.d.ts.map +1 -0
- package/dist/esm/codegen/codegen.js +247 -0
- package/dist/esm/codegen/codegen.js.map +1 -0
- package/dist/esm/codegen/index.d.ts +2 -0
- package/dist/esm/codegen/index.d.ts.map +1 -0
- package/dist/esm/codegen/index.js +2 -0
- package/dist/esm/codegen/index.js.map +1 -0
- package/dist/esm/codegen/run.d.ts +3 -0
- package/dist/esm/codegen/run.d.ts.map +1 -0
- package/dist/esm/codegen/run.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/models.d.ts +21 -0
- package/dist/esm/models.d.ts.map +1 -0
- package/dist/esm/models.js +2 -0
- package/dist/esm/models.js.map +1 -0
- package/dist/esm/move-coder.d.ts +28 -0
- package/dist/esm/move-coder.d.ts.map +1 -0
- package/dist/esm/move-coder.js +311 -0
- package/dist/esm/move-coder.js.map +1 -0
- package/dist/esm/sui-chain-adapter.d.ts +28 -0
- package/dist/esm/sui-chain-adapter.d.ts.map +1 -0
- package/dist/esm/sui-chain-adapter.js +109 -0
- package/dist/esm/sui-chain-adapter.js.map +1 -0
- package/dist/esm/to-internal.d.ts +6 -0
- package/dist/esm/to-internal.d.ts.map +1 -0
- package/dist/esm/to-internal.js +170 -0
- package/dist/esm/to-internal.js.map +1 -0
- package/dist/esm/transaction.d.ts +15 -0
- package/dist/esm/transaction.d.ts.map +1 -0
- package/dist/esm/transaction.js +83 -0
- package/dist/esm/transaction.js.map +1 -0
- package/package.json +6 -6
- package/src/abis/0x1.json +9096 -0
- package/src/abis/0x2.json +38512 -0
- package/src/abis/0x3.json +14755 -0
- package/src/builtin/0x1.ts +10657 -0
- package/src/builtin/0x2.ts +33567 -0
- package/src/builtin/0x3.ts +11437 -0
- package/src/builtin/index.ts +6 -0
- package/src/codegen/codegen.ts +292 -0
- package/src/codegen/index.ts +1 -0
- package/src/codegen/run.ts +57 -0
- package/src/index.ts +13 -0
- package/src/models.ts +32 -0
- package/src/move-coder.ts +364 -0
- package/src/sui-chain-adapter.ts +142 -0
- package/src/to-internal.ts +201 -0
- package/src/transaction.ts +127 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { AbstractMoveCoder, ANY_TYPE, accountTypeString, parseMoveType, SPLITTER, TypeDescriptor } from '@typemove/move';
|
|
2
|
+
import { SuiChainAdapter, getGrpcClient, getGrpcFullnodeUrl } from './sui-chain-adapter.js';
|
|
3
|
+
import { toInternalModule } from './to-internal.js';
|
|
4
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
+
import { normalizeSuiObjectId, normalizeSuiAddress } from '@mysten/sui/utils';
|
|
6
|
+
export class MoveCoder extends AbstractMoveCoder {
|
|
7
|
+
constructor(client) {
|
|
8
|
+
super(new SuiChainAdapter(client));
|
|
9
|
+
}
|
|
10
|
+
load(entry, address) {
|
|
11
|
+
address = accountTypeString(address);
|
|
12
|
+
const { address: moduleAddress, module } = entry;
|
|
13
|
+
let m = this.moduleMapping.get(moduleAddress + '::' + module.name);
|
|
14
|
+
const mDeclared = this.moduleMapping.get(address + '::' + module.name);
|
|
15
|
+
if (m && mDeclared) {
|
|
16
|
+
return m;
|
|
17
|
+
}
|
|
18
|
+
this.accounts.add(moduleAddress);
|
|
19
|
+
m = toInternalModule(module, moduleAddress);
|
|
20
|
+
this.loadInternal(m, address);
|
|
21
|
+
return m;
|
|
22
|
+
}
|
|
23
|
+
async decode(data, type) {
|
|
24
|
+
// UID handled before the switch to avoid the existing fall-through chain
|
|
25
|
+
// (case '0x2::url::Url' / '0x2::coin::Coin' bodies fire on non-string
|
|
26
|
+
// inputs and corrupt UID output). gRPC's unified Object.json flattens UID
|
|
27
|
+
// to a bare address string — re-wrap to `{ id: '0x<32-byte>' }` so
|
|
28
|
+
// downstream `.id.id`-style accessors keep working. The BCS-shaped path
|
|
29
|
+
// (`{ id: { bytes: Uint8Array(32) } }`) is delegated to super.decode,
|
|
30
|
+
// which then hits the inner ID case.
|
|
31
|
+
if (type.qname === '0x2::object::UID') {
|
|
32
|
+
if (typeof data === 'string') {
|
|
33
|
+
return { id: normalizeSuiObjectId(data) };
|
|
34
|
+
}
|
|
35
|
+
return super.decode(data, type);
|
|
36
|
+
}
|
|
37
|
+
switch (type.qname) {
|
|
38
|
+
case '0x1::ascii::Char':
|
|
39
|
+
if (data !== undefined && typeof data !== 'string') {
|
|
40
|
+
// bcs
|
|
41
|
+
const byte = (await super.decode(data, type)).byte;
|
|
42
|
+
return String.fromCharCode(byte);
|
|
43
|
+
}
|
|
44
|
+
case '0x1::ascii::String':
|
|
45
|
+
if (data !== undefined && typeof data !== 'string') {
|
|
46
|
+
// bcs verified
|
|
47
|
+
const bytes = (await super.decode(data, type)).bytes;
|
|
48
|
+
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
49
|
+
}
|
|
50
|
+
case '0x2::object::ID':
|
|
51
|
+
if (data !== undefined && typeof data !== 'string') {
|
|
52
|
+
// bcs verified
|
|
53
|
+
const bytes = (await super.decode(data, type)).bytes;
|
|
54
|
+
return normalizeSuiObjectId(bytes);
|
|
55
|
+
}
|
|
56
|
+
case '0x2::url::Url':
|
|
57
|
+
if (data !== undefined && typeof data !== 'string') {
|
|
58
|
+
// bcs
|
|
59
|
+
return (await super.decode(data, type)).url;
|
|
60
|
+
}
|
|
61
|
+
case '0x2::coin::Coin':
|
|
62
|
+
if (data !== undefined && typeof data !== 'string') {
|
|
63
|
+
// bcs
|
|
64
|
+
const bytes = (await super.decode(data, type)).id.id.bytes;
|
|
65
|
+
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
case '0x2::balance::Balance':
|
|
69
|
+
if (data.value) {
|
|
70
|
+
// bcs verfied
|
|
71
|
+
const balance = await super.decode(data, type);
|
|
72
|
+
return balance.value;
|
|
73
|
+
}
|
|
74
|
+
return BigInt(data);
|
|
75
|
+
case '0x1::option::Option':
|
|
76
|
+
if (data === null) {
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
79
|
+
if (data.vec) {
|
|
80
|
+
// bcs verifed
|
|
81
|
+
let vec = await super.decode(data, type);
|
|
82
|
+
vec = vec.vec;
|
|
83
|
+
if (vec.length === 0) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return vec[0];
|
|
87
|
+
}
|
|
88
|
+
return this.decode(data, type.typeArgs[0]);
|
|
89
|
+
case 'Address':
|
|
90
|
+
const str = data;
|
|
91
|
+
return normalizeSuiAddress(str);
|
|
92
|
+
case '0x1::string::String':
|
|
93
|
+
if (typeof data !== 'string') {
|
|
94
|
+
// bcs
|
|
95
|
+
return new TextDecoder().decode(new Uint8Array(data.bytes));
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
return super.decode(data, type);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
decodeEvent(event) {
|
|
102
|
+
return this.decodedStruct(event);
|
|
103
|
+
}
|
|
104
|
+
filterAndDecodeEvents(type, resources) {
|
|
105
|
+
if (typeof type === 'string') {
|
|
106
|
+
type = parseMoveType(type);
|
|
107
|
+
}
|
|
108
|
+
return this.filterAndDecodeStruct(type, resources);
|
|
109
|
+
}
|
|
110
|
+
async getDynamicFields(objects, keyType = ANY_TYPE, valueType = ANY_TYPE) {
|
|
111
|
+
const type = new TypeDescriptor('0x2::dynamic_field::Field');
|
|
112
|
+
type.typeArgs = [keyType, valueType];
|
|
113
|
+
const res = await this.filterAndDecodeObjects(type, objects);
|
|
114
|
+
return res.map((o) => o.data_decoded);
|
|
115
|
+
}
|
|
116
|
+
filterAndDecodeObjects(type, objects) {
|
|
117
|
+
return this.filterAndDecodeStruct(type, objects);
|
|
118
|
+
}
|
|
119
|
+
// Decodes a parsed Move call payload against the loaded module ABI.
|
|
120
|
+
// Inputs are gRPC `Input[]`: kind=PURE carries a Uint8Array of BCS bytes
|
|
121
|
+
// that we decode using the corresponding parameter's Move type;
|
|
122
|
+
// object inputs (IMMUTABLE_OR_OWNED / SHARED / receiving) are surfaced as
|
|
123
|
+
// undefined since their on-chain values aren't part of the payload.
|
|
124
|
+
async decodeFunctionPayload(payload, inputs) {
|
|
125
|
+
const functionType = [payload.package, payload.module, payload.function].join(SPLITTER);
|
|
126
|
+
const func = await this.getMoveFunction(functionType);
|
|
127
|
+
const params = this.adapter.getMeaningfulFunctionParams(func.params);
|
|
128
|
+
const args = [];
|
|
129
|
+
for (const value of payload.arguments ?? []) {
|
|
130
|
+
const av = value;
|
|
131
|
+
const idx = av?.input;
|
|
132
|
+
if (idx == null || idx < 0 || idx >= inputs.length) {
|
|
133
|
+
args.push(undefined);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const arg = inputs[idx];
|
|
137
|
+
if (arg?.pure) {
|
|
138
|
+
const paramType = params[args.length];
|
|
139
|
+
try {
|
|
140
|
+
const bytes = arg.pure instanceof Uint8Array ? arg.pure : new Uint8Array(arg.pure);
|
|
141
|
+
const decoded = paramType ? await this.decodeBCS(paramType, bytes) : bytes;
|
|
142
|
+
args.push(decoded);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
args.push(undefined);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Object inputs (and unknown kinds) — value isn't carried in the payload.
|
|
150
|
+
args.push(undefined);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const argumentsTyped = await this.decodeArray(args, params, false);
|
|
154
|
+
return {
|
|
155
|
+
...payload,
|
|
156
|
+
arguments_decoded: argumentsTyped
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
bcsRegistered = new Set();
|
|
160
|
+
bcsRegistry = new Map();
|
|
161
|
+
async getBCSTypeWithArgs(type, args = []) {
|
|
162
|
+
const qname = type.qname;
|
|
163
|
+
const sig = type.getNormalizedSignature();
|
|
164
|
+
const cached = this.bcsRegistry.get(sig);
|
|
165
|
+
if (cached) {
|
|
166
|
+
return cached;
|
|
167
|
+
}
|
|
168
|
+
const lowerQname = qname.toLowerCase();
|
|
169
|
+
switch (lowerQname) {
|
|
170
|
+
case 'u8':
|
|
171
|
+
case 'u16':
|
|
172
|
+
case 'u32':
|
|
173
|
+
case 'u64':
|
|
174
|
+
case 'u128':
|
|
175
|
+
case 'u256':
|
|
176
|
+
case 'bool':
|
|
177
|
+
return bcs[lowerQname]();
|
|
178
|
+
case 'address':
|
|
179
|
+
return bcs.Address;
|
|
180
|
+
case 'vector':
|
|
181
|
+
return bcs.vector(args[0]);
|
|
182
|
+
default:
|
|
183
|
+
if (!qname.includes('::')) {
|
|
184
|
+
throw `Unimplemented builtin type ${qname}`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
let moveStruct;
|
|
188
|
+
try {
|
|
189
|
+
moveStruct = await this.getMoveStruct(qname);
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
console.error('Invalid move address', qname);
|
|
193
|
+
throw e;
|
|
194
|
+
}
|
|
195
|
+
const structDef = {};
|
|
196
|
+
for (const field of moveStruct.fields) {
|
|
197
|
+
if (field.type.qname.startsWith('T') && args.length) {
|
|
198
|
+
const index = +field.type.qname.slice(1);
|
|
199
|
+
structDef[field.name] = args[index];
|
|
200
|
+
}
|
|
201
|
+
else if (field.type.typeArgs.length && args.length) {
|
|
202
|
+
structDef[field.name] = await this.getBCSTypeWithArgs(field.type, args);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
structDef[field.name] = await this.getBCSType(field.type);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return bcs.struct(qname, structDef);
|
|
209
|
+
}
|
|
210
|
+
async getBCSType(type) {
|
|
211
|
+
const args = await Promise.all(type.typeArgs.map((x) => this.getBCSType(x)));
|
|
212
|
+
const bcsType = await this.getBCSTypeWithArgs(type, args);
|
|
213
|
+
this.bcsRegistry.set(type.getNormalizedSignature(), bcsType);
|
|
214
|
+
return bcsType;
|
|
215
|
+
}
|
|
216
|
+
async registerBCSTypes(type) {
|
|
217
|
+
const sig = type.getNormalizedSignature();
|
|
218
|
+
if (this.bcsRegistered.has(sig)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this.bcsRegistered.add(sig);
|
|
222
|
+
const bcsType = await this.getBCSType(type);
|
|
223
|
+
this.bcsRegistry.set(type.getNormalizedSignature(), bcsType);
|
|
224
|
+
}
|
|
225
|
+
async decodeBCS(type, data, encoding) {
|
|
226
|
+
await this.registerBCSTypes(type);
|
|
227
|
+
if (typeof data == 'string') {
|
|
228
|
+
const buf = Buffer.from(data, encoding);
|
|
229
|
+
data = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
230
|
+
}
|
|
231
|
+
const bcsType = this.bcsRegistry.get(type.getNormalizedSignature());
|
|
232
|
+
return bcsType?.parse(data);
|
|
233
|
+
}
|
|
234
|
+
// Replaces decodeDevInspectResult. gRPC simulateTransaction returns
|
|
235
|
+
// `commandResults: CommandResult[]` where each CommandResult.returnValues is
|
|
236
|
+
// `CommandOutput[]` of raw `{ bcs: Uint8Array }` — there is no per-return
|
|
237
|
+
// type string the way devInspect carried one. The caller must therefore pass
|
|
238
|
+
// the Move return-type signatures explicitly (codegen emits them next to
|
|
239
|
+
// each generated view helper).
|
|
240
|
+
async decodeSimulateResult(simulateRes, returnTypeSignatures, typeArguments) {
|
|
241
|
+
// Generic view helpers embed return signatures like "T0" / "vector<T1>"
|
|
242
|
+
// at codegen time, but the caller supplies concrete type arguments only
|
|
243
|
+
// at runtime. Substitute them in before BCS decoding — otherwise the BCS
|
|
244
|
+
// type registry sees the bare type-parameter qname and rejects it as an
|
|
245
|
+
// unimplemented builtin.
|
|
246
|
+
const ctx = new Map();
|
|
247
|
+
if (typeArguments && typeArguments.length > 0) {
|
|
248
|
+
typeArguments.forEach((t, i) => {
|
|
249
|
+
ctx.set('T' + i, typeof t === 'string' ? parseMoveType(t) : t);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const returnValues = [];
|
|
253
|
+
const commandResults = simulateRes?.commandResults;
|
|
254
|
+
if (Array.isArray(commandResults)) {
|
|
255
|
+
let typeIdx = 0;
|
|
256
|
+
for (const r of commandResults) {
|
|
257
|
+
const rvs = r?.returnValues;
|
|
258
|
+
if (Array.isArray(rvs) && rvs.length > 0) {
|
|
259
|
+
for (const rv of rvs) {
|
|
260
|
+
const sig = returnTypeSignatures[typeIdx++];
|
|
261
|
+
if (!sig) {
|
|
262
|
+
returnValues.push(null);
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
let type = parseMoveType(sig);
|
|
266
|
+
if (ctx.size > 0) {
|
|
267
|
+
type = type.applyTypeArgs(ctx);
|
|
268
|
+
}
|
|
269
|
+
const bcsBytes = rv?.bcs instanceof Uint8Array ? rv.bcs : new Uint8Array(rv?.bcs ?? []);
|
|
270
|
+
const bcsDecoded = await this.decodeBCS(type, bcsBytes);
|
|
271
|
+
const decoded = await this.decodeType(bcsDecoded, type);
|
|
272
|
+
returnValues.push(decoded);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
returnValues.push(null);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return { ...simulateRes, results_decoded: returnValues };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const DEFAULT_ENDPOINT = getGrpcFullnodeUrl('mainnet');
|
|
284
|
+
const CODER_MAP = new Map();
|
|
285
|
+
export function defaultMoveCoder(endpoint = DEFAULT_ENDPOINT) {
|
|
286
|
+
let coder = CODER_MAP.get(endpoint);
|
|
287
|
+
if (!coder) {
|
|
288
|
+
coder = new MoveCoder(getGrpcClient(endpoint));
|
|
289
|
+
CODER_MAP.set(endpoint, coder);
|
|
290
|
+
}
|
|
291
|
+
return coder;
|
|
292
|
+
}
|
|
293
|
+
const PROVIDER_CODER_MAP = new Map();
|
|
294
|
+
let DEFAULT_CHAIN_ID;
|
|
295
|
+
export async function getMoveCoder(client) {
|
|
296
|
+
let coder = PROVIDER_CODER_MAP.get(client);
|
|
297
|
+
if (!coder) {
|
|
298
|
+
coder = new MoveCoder(client);
|
|
299
|
+
const { chainIdentifier } = await client.core.getChainIdentifier();
|
|
300
|
+
const defaultCoder = defaultMoveCoder();
|
|
301
|
+
if (!DEFAULT_CHAIN_ID) {
|
|
302
|
+
DEFAULT_CHAIN_ID = await defaultCoder.adapter.getChainId();
|
|
303
|
+
}
|
|
304
|
+
if (chainIdentifier === DEFAULT_CHAIN_ID) {
|
|
305
|
+
coder = defaultCoder;
|
|
306
|
+
}
|
|
307
|
+
PROVIDER_CODER_MAP.set(client, coder);
|
|
308
|
+
}
|
|
309
|
+
return coder;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=move-coder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-coder.js","sourceRoot":"","sources":["../../src/move-co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MoveStruct, ChainAdapter, TypeDescriptor } from '@typemove/move';
|
|
2
|
+
import type { GrpcTypes } from '@mysten/sui/grpc';
|
|
3
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
4
|
+
import type { SuiClientTypes } from '@mysten/sui/client';
|
|
5
|
+
export type SuiEventInput = SuiClientTypes.Event;
|
|
6
|
+
export type SuiMoveObjectInput = SuiClientTypes.Object<{
|
|
7
|
+
json: true;
|
|
8
|
+
}>;
|
|
9
|
+
export interface ModuleWithAddress {
|
|
10
|
+
address: string;
|
|
11
|
+
module: GrpcTypes.Module;
|
|
12
|
+
}
|
|
13
|
+
export declare class SuiChainAdapter extends ChainAdapter<ModuleWithAddress, SuiEventInput | SuiMoveObjectInput> {
|
|
14
|
+
client: SuiGrpcClient;
|
|
15
|
+
constructor(client: SuiGrpcClient);
|
|
16
|
+
getChainId(): Promise<string>;
|
|
17
|
+
fetchModule(account: string, module: string): Promise<ModuleWithAddress>;
|
|
18
|
+
fetchModules(account: string): Promise<ModuleWithAddress[]>;
|
|
19
|
+
getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[];
|
|
20
|
+
toInternalModules(modules: ModuleWithAddress[]): InternalMoveModule[];
|
|
21
|
+
getAllEventStructs(modules: InternalMoveModule[]): Map<string, InternalMoveStruct>;
|
|
22
|
+
getType(base: SuiEventInput | SuiMoveObjectInput): string;
|
|
23
|
+
getData(val: SuiEventInput | SuiMoveObjectInput): any;
|
|
24
|
+
}
|
|
25
|
+
export declare function inferNetworkFromUrl(url: string): string;
|
|
26
|
+
export declare function getGrpcFullnodeUrl(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'): string;
|
|
27
|
+
export declare function getGrpcClient(endpoint: string): SuiGrpcClient;
|
|
28
|
+
//# sourceMappingURL=sui-chain-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui-chain-adapter.d.ts","sourceRoot":"","sources":["../../src/sui-chain-adapter.ts"],"names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B,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMvD;AAMD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAWjG;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAG7D"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { toInternalModule } from './to-internal.js';
|
|
2
|
+
import { ChainAdapter, moduleQname, SPLITTER } from '@typemove/move';
|
|
3
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
4
|
+
export class SuiChainAdapter extends ChainAdapter {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
super();
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
async getChainId() {
|
|
11
|
+
const { chainIdentifier } = await this.client.core.getChainIdentifier();
|
|
12
|
+
return chainIdentifier ?? '';
|
|
13
|
+
}
|
|
14
|
+
async fetchModule(account, module) {
|
|
15
|
+
// gRPC has no single-module-fetch RPC; pull the whole package and filter.
|
|
16
|
+
const modules = await this.fetchModules(account);
|
|
17
|
+
const m = modules.find((x) => x.module.name === module);
|
|
18
|
+
if (!m) {
|
|
19
|
+
throw Error(`Module ${module} not found in package ${account}`);
|
|
20
|
+
}
|
|
21
|
+
return m;
|
|
22
|
+
}
|
|
23
|
+
async fetchModules(account) {
|
|
24
|
+
const { response } = await this.client.movePackageService.getPackage({ packageId: account });
|
|
25
|
+
const pkg = response.package;
|
|
26
|
+
if (!pkg) {
|
|
27
|
+
throw Error(`No package returned for ${account}`);
|
|
28
|
+
}
|
|
29
|
+
// gRPC returns the canonical long-form storage id (0x0000...0002); the rest
|
|
30
|
+
// of typemove keys system packages by their short form (0x2). Preserve the
|
|
31
|
+
// caller-supplied address so framework lookups and short-form import paths
|
|
32
|
+
// (`@typemove/sui/builtin/0x2`) keep working.
|
|
33
|
+
return (pkg.modules ?? []).map((module) => ({ address: account, module }));
|
|
34
|
+
}
|
|
35
|
+
getMeaningfulFunctionParams(params) {
|
|
36
|
+
return params;
|
|
37
|
+
}
|
|
38
|
+
toInternalModules(modules) {
|
|
39
|
+
return modules.map(({ address, module }) => toInternalModule(module, address));
|
|
40
|
+
}
|
|
41
|
+
getAllEventStructs(modules) {
|
|
42
|
+
const eventMap = new Map();
|
|
43
|
+
for (const module of modules) {
|
|
44
|
+
const qname = moduleQname(module);
|
|
45
|
+
for (const struct of module.structs) {
|
|
46
|
+
const abilities = new Set(struct.abilities);
|
|
47
|
+
if (abilities.has('Drop') && abilities.has('Copy')) {
|
|
48
|
+
eventMap.set(qname + SPLITTER + struct.name, struct);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return eventMap;
|
|
53
|
+
}
|
|
54
|
+
getType(base) {
|
|
55
|
+
// Unified SuiClientTypes: Event has `eventType`, Object has `type`.
|
|
56
|
+
const v = base;
|
|
57
|
+
return v.eventType ?? v.type ?? '';
|
|
58
|
+
}
|
|
59
|
+
getData(val) {
|
|
60
|
+
if (val === undefined) {
|
|
61
|
+
throw Error('val is undefined');
|
|
62
|
+
}
|
|
63
|
+
// Pass through primitives (e.g. a UID flattened to a bare string) — the
|
|
64
|
+
// decoder's per-type case handlers know how to interpret them.
|
|
65
|
+
if (val === null || typeof val !== 'object') {
|
|
66
|
+
return val;
|
|
67
|
+
}
|
|
68
|
+
const v = val;
|
|
69
|
+
// Unified SuiClientTypes shapes: Event.json / Object<{json:true}>.json
|
|
70
|
+
// carries the decoded Move struct content. Anything else (a nested
|
|
71
|
+
// already-flat struct value passed in during recursion) is its own data.
|
|
72
|
+
if (v.json != null) {
|
|
73
|
+
return v.json;
|
|
74
|
+
}
|
|
75
|
+
return val;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function inferNetworkFromUrl(url) {
|
|
79
|
+
if (url.includes('mainnet'))
|
|
80
|
+
return 'mainnet';
|
|
81
|
+
if (url.includes('testnet'))
|
|
82
|
+
return 'testnet';
|
|
83
|
+
if (url.includes('devnet'))
|
|
84
|
+
return 'devnet';
|
|
85
|
+
if (url.includes('localnet') || url.includes('127.0.0.1') || url.includes('localhost'))
|
|
86
|
+
return 'localnet';
|
|
87
|
+
return 'custom';
|
|
88
|
+
}
|
|
89
|
+
// gRPC counterpart of @mysten/sui/jsonRpc's `getJsonRpcFullnodeUrl`. The SDK
|
|
90
|
+
// doesn't ship one under /grpc — Sui's gRPC-Web endpoint is exposed on the
|
|
91
|
+
// same host as JSON-RPC over standard HTTPS, so we mirror the JSON-RPC list
|
|
92
|
+
// (sans the explicit :443 since the transport speaks HTTPS by default).
|
|
93
|
+
export function getGrpcFullnodeUrl(network) {
|
|
94
|
+
switch (network) {
|
|
95
|
+
case 'mainnet':
|
|
96
|
+
return 'https://fullnode.mainnet.sui.io';
|
|
97
|
+
case 'testnet':
|
|
98
|
+
return 'https://fullnode.testnet.sui.io';
|
|
99
|
+
case 'devnet':
|
|
100
|
+
return 'https://fullnode.devnet.sui.io';
|
|
101
|
+
case 'localnet':
|
|
102
|
+
return 'http://127.0.0.1:9000';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function getGrpcClient(endpoint) {
|
|
106
|
+
const network = inferNetworkFromUrl(endpoint);
|
|
107
|
+
return new SuiGrpcClient({ network, baseUrl: endpoint });
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=sui-chain-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui-chain-adapter.js","sourceRoot":"","sources":["../../src/sui-chain-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAGL,YAAY,EACZ,WAAW,EACX,QAAQ,EAET,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAkBhD,MAAM,OAAO,eAAgB,SAA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E,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;AAC1D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GrpcTypes } from '@mysten/sui/grpc';
|
|
2
|
+
import { InternalMoveModule } from '@typemove/move';
|
|
3
|
+
type Module = GrpcTypes.Module;
|
|
4
|
+
export declare function toInternalModule(module: Module, packageAddress: string): InternalMoveModule;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=to-internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-internal.d.ts","sourceRoot":"","sources":["../../src/to-internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAKL,kBAAkB,EAKnB,MAAM,gBAAgB,CAAA;AAIvB,KAAK,MAAM,GAAG,SAAS,CAAC,MAAM,CAAA;AAwC9B,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,kBAAkB,CAgB3F"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { accountTypeString, InternalMoveFunctionVisibility, SPLITTER, TypeDescriptor } from '@typemove/move';
|
|
2
|
+
// Proto enum constants kept as literals so we can compare against
|
|
3
|
+
// the ordinals returned in the wire-decoded shape without importing
|
|
4
|
+
// the namespaced enum at runtime.
|
|
5
|
+
const DATATYPE_KIND_STRUCT = 1;
|
|
6
|
+
const DATATYPE_KIND_ENUM = 2;
|
|
7
|
+
const VISIBILITY_PRIVATE = 1;
|
|
8
|
+
const VISIBILITY_PUBLIC = 2;
|
|
9
|
+
const VISIBILITY_FRIEND = 3;
|
|
10
|
+
// OpenSignatureBody.Type
|
|
11
|
+
const TYPE_ADDRESS = 1;
|
|
12
|
+
const TYPE_BOOL = 2;
|
|
13
|
+
const TYPE_U8 = 3;
|
|
14
|
+
const TYPE_U16 = 4;
|
|
15
|
+
const TYPE_U32 = 5;
|
|
16
|
+
const TYPE_U64 = 6;
|
|
17
|
+
const TYPE_U128 = 7;
|
|
18
|
+
const TYPE_U256 = 8;
|
|
19
|
+
const TYPE_VECTOR = 9;
|
|
20
|
+
const TYPE_DATATYPE = 10;
|
|
21
|
+
const TYPE_TYPE_PARAMETER = 11;
|
|
22
|
+
const ABILITY_NAMES = {
|
|
23
|
+
1: 'Copy',
|
|
24
|
+
2: 'Drop',
|
|
25
|
+
3: 'Store',
|
|
26
|
+
4: 'Key'
|
|
27
|
+
};
|
|
28
|
+
// Convert a proto Module (from movePackageService.getPackage().package.modules[i])
|
|
29
|
+
// into typemove's InternalMoveModule. `packageAddress` is needed because the
|
|
30
|
+
// proto Module doesn't repeat the package id on every module entry.
|
|
31
|
+
export function toInternalModule(module, packageAddress) {
|
|
32
|
+
packageAddress = accountTypeString(packageAddress);
|
|
33
|
+
const datatypes = module.datatypes ?? [];
|
|
34
|
+
const functions = module.functions ?? [];
|
|
35
|
+
const structs = datatypes.filter((d) => d.kind === DATATYPE_KIND_STRUCT).map(toInternalStruct);
|
|
36
|
+
const enums = datatypes.filter((d) => d.kind === DATATYPE_KIND_ENUM).map(toInternalEnum);
|
|
37
|
+
return {
|
|
38
|
+
address: packageAddress,
|
|
39
|
+
name: module.name ?? '',
|
|
40
|
+
exposedFunctions: functions.map(toInternalFunction),
|
|
41
|
+
structs,
|
|
42
|
+
enums
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function toInternalFunction(func) {
|
|
46
|
+
let visibility;
|
|
47
|
+
switch (func.visibility) {
|
|
48
|
+
case VISIBILITY_PRIVATE:
|
|
49
|
+
visibility = InternalMoveFunctionVisibility.PRIVATE;
|
|
50
|
+
break;
|
|
51
|
+
case VISIBILITY_PUBLIC:
|
|
52
|
+
visibility = InternalMoveFunctionVisibility.PUBLIC;
|
|
53
|
+
break;
|
|
54
|
+
case VISIBILITY_FRIEND:
|
|
55
|
+
visibility = InternalMoveFunctionVisibility.FRIEND;
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
throw Error(`No visibility for function ${func.name}`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
typeParams: (func.typeParameters ?? []).map((p) => ({
|
|
62
|
+
constraints: (p.constraints ?? []).map(abilityName)
|
|
63
|
+
})),
|
|
64
|
+
isEntry: func.isEntry ?? false,
|
|
65
|
+
name: func.name ?? '',
|
|
66
|
+
params: (func.parameters ?? []).map(toTypeDescriptorFromSignature),
|
|
67
|
+
return: (func.returns ?? []).map(toTypeDescriptorFromSignature),
|
|
68
|
+
visibility
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function toInternalStruct(d) {
|
|
72
|
+
return {
|
|
73
|
+
abilities: (d.abilities ?? []).map(abilityName),
|
|
74
|
+
fields: (d.fields ?? []).map(toInternalField),
|
|
75
|
+
typeParams: (d.typeParameters ?? []).map((p) => ({
|
|
76
|
+
constraints: (p.constraints ?? []).map(abilityName)
|
|
77
|
+
})),
|
|
78
|
+
isNative: false,
|
|
79
|
+
isEvent: false,
|
|
80
|
+
name: d.name ?? ''
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function toInternalEnum(d) {
|
|
84
|
+
const variants = {};
|
|
85
|
+
for (const v of d.variants ?? []) {
|
|
86
|
+
variants[v.name ?? ''] = (v.fields ?? []).map(toInternalField);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
name: d.name ?? '',
|
|
90
|
+
abilities: (d.abilities ?? []).map(abilityName),
|
|
91
|
+
typeParams: (d.typeParameters ?? []).map((p) => ({
|
|
92
|
+
constraints: (p.constraints ?? []).map(abilityName)
|
|
93
|
+
})),
|
|
94
|
+
variants
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function toInternalField(f) {
|
|
98
|
+
if (!f.type) {
|
|
99
|
+
throw Error(`Field ${f.name} has no type`);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
name: f.name ?? '',
|
|
103
|
+
type: toTypeDescriptorFromBody(f.type)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// OpenSignature wraps an OpenSignatureBody with an optional reference marker.
|
|
107
|
+
// Used for function params and returns.
|
|
108
|
+
function toTypeDescriptorFromSignature(sig) {
|
|
109
|
+
if (!sig.body) {
|
|
110
|
+
throw Error('OpenSignature has no body');
|
|
111
|
+
}
|
|
112
|
+
const desc = toTypeDescriptorFromBody(sig.body);
|
|
113
|
+
// Reference.IMMUTABLE=1, MUTABLE=2
|
|
114
|
+
if (sig.reference === 1) {
|
|
115
|
+
desc.reference = true;
|
|
116
|
+
}
|
|
117
|
+
else if (sig.reference === 2) {
|
|
118
|
+
desc.reference = true;
|
|
119
|
+
desc.mutable = true;
|
|
120
|
+
}
|
|
121
|
+
return desc;
|
|
122
|
+
}
|
|
123
|
+
function toTypeDescriptorFromBody(body) {
|
|
124
|
+
switch (body.type) {
|
|
125
|
+
case TYPE_ADDRESS:
|
|
126
|
+
return new TypeDescriptor('Address');
|
|
127
|
+
case TYPE_BOOL:
|
|
128
|
+
return new TypeDescriptor('Bool');
|
|
129
|
+
case TYPE_U8:
|
|
130
|
+
return new TypeDescriptor('U8');
|
|
131
|
+
case TYPE_U16:
|
|
132
|
+
return new TypeDescriptor('U16');
|
|
133
|
+
case TYPE_U32:
|
|
134
|
+
return new TypeDescriptor('U32');
|
|
135
|
+
case TYPE_U64:
|
|
136
|
+
return new TypeDescriptor('U64');
|
|
137
|
+
case TYPE_U128:
|
|
138
|
+
return new TypeDescriptor('U128');
|
|
139
|
+
case TYPE_U256:
|
|
140
|
+
return new TypeDescriptor('U256');
|
|
141
|
+
case TYPE_VECTOR: {
|
|
142
|
+
const inner = body.typeParameterInstantiation?.[0];
|
|
143
|
+
if (!inner)
|
|
144
|
+
throw Error('Vector OpenSignatureBody missing type parameter');
|
|
145
|
+
return new TypeDescriptor('Vector', [toTypeDescriptorFromBody(inner)]);
|
|
146
|
+
}
|
|
147
|
+
case TYPE_DATATYPE: {
|
|
148
|
+
// gRPC emits typeName as `<defining_id>::<module>::<name>` with the
|
|
149
|
+
// address in canonical long form (0x0000...0002). Normalize to the
|
|
150
|
+
// short form (0x2) so module-lookup keys match what's loaded into
|
|
151
|
+
// MoveCoder by short-form aware code paths.
|
|
152
|
+
const raw = body.typeName ?? '';
|
|
153
|
+
const parts = raw.split(SPLITTER);
|
|
154
|
+
const qname = parts.length === 3 ? [accountTypeString(parts[0]), parts[1], parts[2]].join(SPLITTER) : raw;
|
|
155
|
+
const args = (body.typeParameterInstantiation ?? []).map(toTypeDescriptorFromBody);
|
|
156
|
+
return new TypeDescriptor(qname, args);
|
|
157
|
+
}
|
|
158
|
+
case TYPE_TYPE_PARAMETER:
|
|
159
|
+
return new TypeDescriptor('T' + (body.typeParameter ?? 0));
|
|
160
|
+
default:
|
|
161
|
+
throw new Error(`Unexpected OpenSignatureBody type: ${body.type}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function abilityName(a) {
|
|
165
|
+
const n = ABILITY_NAMES[a];
|
|
166
|
+
if (!n)
|
|
167
|
+
throw Error(`Unknown Ability value: ${a}`);
|
|
168
|
+
return n;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=to-internal.js.map
|