@haneullabs/move-bytecode-template 0.1.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/README.md +175 -0
- package/index.js +7 -0
- package/index.mjs +5 -0
- package/nodejs/move_bytecode_template.d.ts +76 -0
- package/nodejs/move_bytecode_template.js +629 -0
- package/nodejs/move_bytecode_template_bg.wasm +0 -0
- package/nodejs/move_bytecode_template_bg.wasm.d.ts +18 -0
- package/package.json +47 -0
- package/web/move_bytecode_template.d.ts +118 -0
- package/web/move_bytecode_template.js +676 -0
- package/web/move_bytecode_template_bg.wasm +0 -0
- package/web/move_bytecode_template_bg.wasm.d.ts +18 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
let wasm;
|
|
5
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
6
|
+
|
|
7
|
+
let WASM_VECTOR_LEN = 0;
|
|
8
|
+
|
|
9
|
+
let cachedUint8ArrayMemory0 = null;
|
|
10
|
+
|
|
11
|
+
function getUint8ArrayMemory0() {
|
|
12
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
+
}
|
|
15
|
+
return cachedUint8ArrayMemory0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
19
|
+
|
|
20
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
21
|
+
? function (arg, view) {
|
|
22
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
23
|
+
}
|
|
24
|
+
: function (arg, view) {
|
|
25
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
26
|
+
view.set(buf);
|
|
27
|
+
return {
|
|
28
|
+
read: arg.length,
|
|
29
|
+
written: buf.length
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
34
|
+
|
|
35
|
+
if (realloc === undefined) {
|
|
36
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
37
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
38
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
39
|
+
WASM_VECTOR_LEN = buf.length;
|
|
40
|
+
return ptr;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let len = arg.length;
|
|
44
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
45
|
+
|
|
46
|
+
const mem = getUint8ArrayMemory0();
|
|
47
|
+
|
|
48
|
+
let offset = 0;
|
|
49
|
+
|
|
50
|
+
for (; offset < len; offset++) {
|
|
51
|
+
const code = arg.charCodeAt(offset);
|
|
52
|
+
if (code > 0x7F) break;
|
|
53
|
+
mem[ptr + offset] = code;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (offset !== len) {
|
|
57
|
+
if (offset !== 0) {
|
|
58
|
+
arg = arg.slice(offset);
|
|
59
|
+
}
|
|
60
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
61
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
62
|
+
const ret = encodeString(arg, view);
|
|
63
|
+
|
|
64
|
+
offset += ret.written;
|
|
65
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
WASM_VECTOR_LEN = offset;
|
|
69
|
+
return ptr;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let cachedDataViewMemory0 = null;
|
|
73
|
+
|
|
74
|
+
function getDataViewMemory0() {
|
|
75
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
76
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
77
|
+
}
|
|
78
|
+
return cachedDataViewMemory0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function addToExternrefTable0(obj) {
|
|
82
|
+
const idx = wasm.__externref_table_alloc();
|
|
83
|
+
wasm.__wbindgen_export_4.set(idx, obj);
|
|
84
|
+
return idx;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleError(f, args) {
|
|
88
|
+
try {
|
|
89
|
+
return f.apply(this, args);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
const idx = addToExternrefTable0(e);
|
|
92
|
+
wasm.__wbindgen_exn_store(idx);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isLikeNone(x) {
|
|
97
|
+
return x === undefined || x === null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function debugString(val) {
|
|
101
|
+
// primitive types
|
|
102
|
+
const type = typeof val;
|
|
103
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
104
|
+
return `${val}`;
|
|
105
|
+
}
|
|
106
|
+
if (type == 'string') {
|
|
107
|
+
return `"${val}"`;
|
|
108
|
+
}
|
|
109
|
+
if (type == 'symbol') {
|
|
110
|
+
const description = val.description;
|
|
111
|
+
if (description == null) {
|
|
112
|
+
return 'Symbol';
|
|
113
|
+
} else {
|
|
114
|
+
return `Symbol(${description})`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (type == 'function') {
|
|
118
|
+
const name = val.name;
|
|
119
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
120
|
+
return `Function(${name})`;
|
|
121
|
+
} else {
|
|
122
|
+
return 'Function';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// objects
|
|
126
|
+
if (Array.isArray(val)) {
|
|
127
|
+
const length = val.length;
|
|
128
|
+
let debug = '[';
|
|
129
|
+
if (length > 0) {
|
|
130
|
+
debug += debugString(val[0]);
|
|
131
|
+
}
|
|
132
|
+
for(let i = 1; i < length; i++) {
|
|
133
|
+
debug += ', ' + debugString(val[i]);
|
|
134
|
+
}
|
|
135
|
+
debug += ']';
|
|
136
|
+
return debug;
|
|
137
|
+
}
|
|
138
|
+
// Test for built-in
|
|
139
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
140
|
+
let className;
|
|
141
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
142
|
+
className = builtInMatches[1];
|
|
143
|
+
} else {
|
|
144
|
+
// Failed to match the standard '[object ClassName]'
|
|
145
|
+
return toString.call(val);
|
|
146
|
+
}
|
|
147
|
+
if (className == 'Object') {
|
|
148
|
+
// we're a user defined class or Object
|
|
149
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
150
|
+
// easier than looping through ownProperties of `val`.
|
|
151
|
+
try {
|
|
152
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
153
|
+
} catch (_) {
|
|
154
|
+
return 'Object';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// errors
|
|
158
|
+
if (val instanceof Error) {
|
|
159
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
160
|
+
}
|
|
161
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
162
|
+
return className;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
166
|
+
|
|
167
|
+
cachedTextDecoder.decode();
|
|
168
|
+
|
|
169
|
+
function getStringFromWasm0(ptr, len) {
|
|
170
|
+
ptr = ptr >>> 0;
|
|
171
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get the version of the crate (useful for testing the package).
|
|
175
|
+
* @returns {string}
|
|
176
|
+
*/
|
|
177
|
+
module.exports.version = function() {
|
|
178
|
+
let deferred1_0;
|
|
179
|
+
let deferred1_1;
|
|
180
|
+
try {
|
|
181
|
+
const ret = wasm.version();
|
|
182
|
+
deferred1_0 = ret[0];
|
|
183
|
+
deferred1_1 = ret[1];
|
|
184
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
185
|
+
} finally {
|
|
186
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
191
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
192
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
193
|
+
WASM_VECTOR_LEN = arg.length;
|
|
194
|
+
return ptr;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function takeFromExternrefTable0(idx) {
|
|
198
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
199
|
+
wasm.__externref_table_dealloc(idx);
|
|
200
|
+
return value;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Deserialize the `Uint8Array`` bytecode into a JSON object.
|
|
204
|
+
* The JSON object contains the ABI (Application Binary Interface) of the module.
|
|
205
|
+
*
|
|
206
|
+
* ```javascript
|
|
207
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
208
|
+
*
|
|
209
|
+
* const json = template.deserialize( binary );
|
|
210
|
+
* console.log( json, json.identifiers );
|
|
211
|
+
* ```
|
|
212
|
+
* @param {Uint8Array} binary
|
|
213
|
+
* @returns {any}
|
|
214
|
+
*/
|
|
215
|
+
module.exports.deserialize = function(binary) {
|
|
216
|
+
const ptr0 = passArray8ToWasm0(binary, wasm.__wbindgen_malloc);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
const ret = wasm.deserialize(ptr0, len0);
|
|
219
|
+
if (ret[2]) {
|
|
220
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
221
|
+
}
|
|
222
|
+
return takeFromExternrefTable0(ret[0]);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
226
|
+
ptr = ptr >>> 0;
|
|
227
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Update the identifiers in the module bytecode, given a map of old -> new identifiers.
|
|
231
|
+
* Returns the updated bytecode.
|
|
232
|
+
*
|
|
233
|
+
* ```javascript
|
|
234
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
235
|
+
*
|
|
236
|
+
* const updated = template.update_identifiers( binary, {
|
|
237
|
+
* 'TEMPLATE': 'NEW_VALUE',
|
|
238
|
+
* 'template': 'new_value',
|
|
239
|
+
* 'Name': 'NewName'
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
* @param {Uint8Array} binary
|
|
243
|
+
* @param {any} map
|
|
244
|
+
* @returns {Uint8Array}
|
|
245
|
+
*/
|
|
246
|
+
module.exports.update_identifiers = function(binary, map) {
|
|
247
|
+
const ptr0 = passArray8ToWasm0(binary, wasm.__wbindgen_malloc);
|
|
248
|
+
const len0 = WASM_VECTOR_LEN;
|
|
249
|
+
const ret = wasm.update_identifiers(ptr0, len0, map);
|
|
250
|
+
if (ret[3]) {
|
|
251
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
252
|
+
}
|
|
253
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
254
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
255
|
+
return v2;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Updates a constant in the constant pool. Because constants don't have names,
|
|
260
|
+
* the only way to identify them is by their type and value.
|
|
261
|
+
*
|
|
262
|
+
* The value of a constant is BCS-encoded and the type is a string representation
|
|
263
|
+
* of the `SignatureToken` enum. String identifier for `SignatureToken` is a
|
|
264
|
+
* capitalized version of the type: U8, Address, Vector(Bool), Vector(U8), etc.
|
|
265
|
+
*
|
|
266
|
+
* ```javascript
|
|
267
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
268
|
+
* import { bcs } from '@haneullabs/bcs';
|
|
269
|
+
*
|
|
270
|
+
* let binary = template.update_constants(
|
|
271
|
+
* binary, // Uint8Array
|
|
272
|
+
* bcs.u64().serialize(0).toBytes(), // new value
|
|
273
|
+
* bcs.u64().serialize(100000).toBytes(), // old value
|
|
274
|
+
* 'U64' // type
|
|
275
|
+
* );
|
|
276
|
+
* ```
|
|
277
|
+
* @param {Uint8Array} binary
|
|
278
|
+
* @param {Uint8Array} new_value
|
|
279
|
+
* @param {Uint8Array} expected_value
|
|
280
|
+
* @param {string} expected_type
|
|
281
|
+
* @returns {Uint8Array}
|
|
282
|
+
*/
|
|
283
|
+
module.exports.update_constants = function(binary, new_value, expected_value, expected_type) {
|
|
284
|
+
const ptr0 = passArray8ToWasm0(binary, wasm.__wbindgen_malloc);
|
|
285
|
+
const len0 = WASM_VECTOR_LEN;
|
|
286
|
+
const ptr1 = passArray8ToWasm0(new_value, wasm.__wbindgen_malloc);
|
|
287
|
+
const len1 = WASM_VECTOR_LEN;
|
|
288
|
+
const ptr2 = passArray8ToWasm0(expected_value, wasm.__wbindgen_malloc);
|
|
289
|
+
const len2 = WASM_VECTOR_LEN;
|
|
290
|
+
const ptr3 = passStringToWasm0(expected_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
+
const len3 = WASM_VECTOR_LEN;
|
|
292
|
+
const ret = wasm.update_constants(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
293
|
+
if (ret[3]) {
|
|
294
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
295
|
+
}
|
|
296
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
297
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
298
|
+
return v5;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Convenience method to analyze the constant pool; returns all constants in order
|
|
303
|
+
* with their type and BCS value.
|
|
304
|
+
*
|
|
305
|
+
* ```javascript
|
|
306
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
307
|
+
*
|
|
308
|
+
* let consts = template.get_constants(binary);
|
|
309
|
+
* ```
|
|
310
|
+
* @param {Uint8Array} binary
|
|
311
|
+
* @returns {any}
|
|
312
|
+
*/
|
|
313
|
+
module.exports.get_constants = function(binary) {
|
|
314
|
+
const ptr0 = passArray8ToWasm0(binary, wasm.__wbindgen_malloc);
|
|
315
|
+
const len0 = WASM_VECTOR_LEN;
|
|
316
|
+
const ret = wasm.get_constants(ptr0, len0);
|
|
317
|
+
if (ret[2]) {
|
|
318
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
319
|
+
}
|
|
320
|
+
return takeFromExternrefTable0(ret[0]);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Serialize the JSON module into a `Uint8Array` (bytecode).
|
|
325
|
+
* @param {any} json_module
|
|
326
|
+
* @returns {Uint8Array}
|
|
327
|
+
*/
|
|
328
|
+
module.exports.serialize = function(json_module) {
|
|
329
|
+
const ret = wasm.serialize(json_module);
|
|
330
|
+
if (ret[3]) {
|
|
331
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
332
|
+
}
|
|
333
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
334
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
335
|
+
return v1;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const ConstantFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
339
|
+
? { register: () => {}, unregister: () => {} }
|
|
340
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_constant_free(ptr >>> 0, 1));
|
|
341
|
+
/**
|
|
342
|
+
* A transformed constant from the constant pool.
|
|
343
|
+
*/
|
|
344
|
+
class Constant {
|
|
345
|
+
|
|
346
|
+
__destroy_into_raw() {
|
|
347
|
+
const ptr = this.__wbg_ptr;
|
|
348
|
+
this.__wbg_ptr = 0;
|
|
349
|
+
ConstantFinalization.unregister(this);
|
|
350
|
+
return ptr;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
free() {
|
|
354
|
+
const ptr = this.__destroy_into_raw();
|
|
355
|
+
wasm.__wbg_constant_free(ptr, 0);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
module.exports.Constant = Constant;
|
|
359
|
+
|
|
360
|
+
module.exports.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
|
|
361
|
+
const ret = String(arg1);
|
|
362
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
363
|
+
const len1 = WASM_VECTOR_LEN;
|
|
364
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
365
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
module.exports.__wbg_buffer_a215fd0f9dbb5414 = function(arg0) {
|
|
369
|
+
const ret = arg0.buffer;
|
|
370
|
+
return ret;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
module.exports.__wbg_call_aa20ca83b389253c = function() { return handleError(function (arg0, arg1) {
|
|
374
|
+
const ret = arg0.call(arg1);
|
|
375
|
+
return ret;
|
|
376
|
+
}, arguments) };
|
|
377
|
+
|
|
378
|
+
module.exports.__wbg_done_b00ac79b7cf688ec = function(arg0) {
|
|
379
|
+
const ret = arg0.done;
|
|
380
|
+
return ret;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
module.exports.__wbg_entries_2aaa882d15c26fd0 = function(arg0) {
|
|
384
|
+
const ret = Object.entries(arg0);
|
|
385
|
+
return ret;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
module.exports.__wbg_get_142c69a0a38ca3a9 = function(arg0, arg1) {
|
|
389
|
+
const ret = arg0[arg1 >>> 0];
|
|
390
|
+
return ret;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
module.exports.__wbg_get_9528546d1b415178 = function() { return handleError(function (arg0, arg1) {
|
|
394
|
+
const ret = Reflect.get(arg0, arg1);
|
|
395
|
+
return ret;
|
|
396
|
+
}, arguments) };
|
|
397
|
+
|
|
398
|
+
module.exports.__wbg_getwithrefkey_6550b2c093d2eb18 = function(arg0, arg1) {
|
|
399
|
+
const ret = arg0[arg1];
|
|
400
|
+
return ret;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
module.exports.__wbg_instanceof_ArrayBuffer_b19b33ccadb20395 = function(arg0) {
|
|
404
|
+
let result;
|
|
405
|
+
try {
|
|
406
|
+
result = arg0 instanceof ArrayBuffer;
|
|
407
|
+
} catch (_) {
|
|
408
|
+
result = false;
|
|
409
|
+
}
|
|
410
|
+
const ret = result;
|
|
411
|
+
return ret;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
module.exports.__wbg_instanceof_Uint8Array_ee46a70987a1d66b = function(arg0) {
|
|
415
|
+
let result;
|
|
416
|
+
try {
|
|
417
|
+
result = arg0 instanceof Uint8Array;
|
|
418
|
+
} catch (_) {
|
|
419
|
+
result = false;
|
|
420
|
+
}
|
|
421
|
+
const ret = result;
|
|
422
|
+
return ret;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
module.exports.__wbg_isArray_643b5b2b3afb0871 = function(arg0) {
|
|
426
|
+
const ret = Array.isArray(arg0);
|
|
427
|
+
return ret;
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
module.exports.__wbg_isSafeInteger_1c660d27c689f62a = function(arg0) {
|
|
431
|
+
const ret = Number.isSafeInteger(arg0);
|
|
432
|
+
return ret;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
module.exports.__wbg_iterator_c397425a538e3b86 = function() {
|
|
436
|
+
const ret = Symbol.iterator;
|
|
437
|
+
return ret;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
module.exports.__wbg_length_1799fd5bf657c257 = function(arg0) {
|
|
441
|
+
const ret = arg0.length;
|
|
442
|
+
return ret;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
module.exports.__wbg_length_621925723fc28f40 = function(arg0) {
|
|
446
|
+
const ret = arg0.length;
|
|
447
|
+
return ret;
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
module.exports.__wbg_new_9163745409122fa8 = function() {
|
|
451
|
+
const ret = new Array();
|
|
452
|
+
return ret;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
module.exports.__wbg_new_b6f51e9f591d0d1d = function(arg0) {
|
|
456
|
+
const ret = new Uint8Array(arg0);
|
|
457
|
+
return ret;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
module.exports.__wbg_new_d684b6b3189ca362 = function() {
|
|
461
|
+
const ret = new Object();
|
|
462
|
+
return ret;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
module.exports.__wbg_next_6a72514087dd23f8 = function(arg0) {
|
|
466
|
+
const ret = arg0.next;
|
|
467
|
+
return ret;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
module.exports.__wbg_next_96ab50690a8f6cca = function() { return handleError(function (arg0) {
|
|
471
|
+
const ret = arg0.next();
|
|
472
|
+
return ret;
|
|
473
|
+
}, arguments) };
|
|
474
|
+
|
|
475
|
+
module.exports.__wbg_set_3807d5f0bfc24aa7 = function(arg0, arg1, arg2) {
|
|
476
|
+
arg0[arg1] = arg2;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
module.exports.__wbg_set_61aa9ab41a0fb137 = function(arg0, arg1, arg2) {
|
|
480
|
+
arg0[arg1 >>> 0] = arg2;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
module.exports.__wbg_set_911a2f3ee8dd23b5 = function(arg0, arg1, arg2) {
|
|
484
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
module.exports.__wbg_value_5af0abb3b2b9f90b = function(arg0) {
|
|
488
|
+
const ret = arg0.value;
|
|
489
|
+
return ret;
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
module.exports.__wbindgen_bigint_from_u128 = function(arg0, arg1) {
|
|
493
|
+
const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1);
|
|
494
|
+
return ret;
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
498
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
499
|
+
return ret;
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
503
|
+
const v = arg1;
|
|
504
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
505
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
506
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
module.exports.__wbindgen_boolean_get = function(arg0) {
|
|
510
|
+
const v = arg0;
|
|
511
|
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
512
|
+
return ret;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
516
|
+
const ret = debugString(arg1);
|
|
517
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
518
|
+
const len1 = WASM_VECTOR_LEN;
|
|
519
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
520
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
524
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
525
|
+
return ret;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
module.exports.__wbindgen_in = function(arg0, arg1) {
|
|
529
|
+
const ret = arg0 in arg1;
|
|
530
|
+
return ret;
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
module.exports.__wbindgen_init_externref_table = function() {
|
|
534
|
+
const table = wasm.__wbindgen_export_4;
|
|
535
|
+
const offset = table.grow(4);
|
|
536
|
+
table.set(0, undefined);
|
|
537
|
+
table.set(offset + 0, undefined);
|
|
538
|
+
table.set(offset + 1, null);
|
|
539
|
+
table.set(offset + 2, true);
|
|
540
|
+
table.set(offset + 3, false);
|
|
541
|
+
;
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
module.exports.__wbindgen_is_bigint = function(arg0) {
|
|
545
|
+
const ret = typeof(arg0) === 'bigint';
|
|
546
|
+
return ret;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
module.exports.__wbindgen_is_function = function(arg0) {
|
|
550
|
+
const ret = typeof(arg0) === 'function';
|
|
551
|
+
return ret;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
module.exports.__wbindgen_is_object = function(arg0) {
|
|
555
|
+
const val = arg0;
|
|
556
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
557
|
+
return ret;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
module.exports.__wbindgen_is_string = function(arg0) {
|
|
561
|
+
const ret = typeof(arg0) === 'string';
|
|
562
|
+
return ret;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
566
|
+
const ret = arg0 === undefined;
|
|
567
|
+
return ret;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
module.exports.__wbindgen_jsval_eq = function(arg0, arg1) {
|
|
571
|
+
const ret = arg0 === arg1;
|
|
572
|
+
return ret;
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
576
|
+
const ret = arg0 == arg1;
|
|
577
|
+
return ret;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
module.exports.__wbindgen_memory = function() {
|
|
581
|
+
const ret = wasm.memory;
|
|
582
|
+
return ret;
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
module.exports.__wbindgen_number_get = function(arg0, arg1) {
|
|
586
|
+
const obj = arg1;
|
|
587
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
588
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
589
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
module.exports.__wbindgen_number_new = function(arg0) {
|
|
593
|
+
const ret = arg0;
|
|
594
|
+
return ret;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
module.exports.__wbindgen_shr = function(arg0, arg1) {
|
|
598
|
+
const ret = arg0 >> arg1;
|
|
599
|
+
return ret;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
603
|
+
const obj = arg1;
|
|
604
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
605
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
606
|
+
var len1 = WASM_VECTOR_LEN;
|
|
607
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
608
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
612
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
613
|
+
return ret;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
617
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
const path = require('path').join(__dirname, 'move_bytecode_template_bg.wasm');
|
|
621
|
+
const bytes = require('fs').readFileSync(path);
|
|
622
|
+
|
|
623
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
624
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
625
|
+
wasm = wasmInstance.exports;
|
|
626
|
+
module.exports.__wasm = wasm;
|
|
627
|
+
|
|
628
|
+
wasm.__wbindgen_start();
|
|
629
|
+
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const version: () => [number, number];
|
|
5
|
+
export const deserialize: (a: number, b: number) => [number, number, number];
|
|
6
|
+
export const update_identifiers: (a: number, b: number, c: any) => [number, number, number, number];
|
|
7
|
+
export const update_constants: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
8
|
+
export const __wbg_constant_free: (a: number, b: number) => void;
|
|
9
|
+
export const get_constants: (a: number, b: number) => [number, number, number];
|
|
10
|
+
export const serialize: (a: any) => [number, number, number, number];
|
|
11
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
12
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
13
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
14
|
+
export const __externref_table_alloc: () => number;
|
|
15
|
+
export const __wbindgen_export_4: WebAssembly.Table;
|
|
16
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
18
|
+
export const __wbindgen_start: () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@haneullabs/move-bytecode-template",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Move Binary Format implementation in WASM",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "./web/move_bytecode_template.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"nodejs",
|
|
9
|
+
"web",
|
|
10
|
+
"index.js",
|
|
11
|
+
"index.mjs"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"browser": "./web/move_bytecode_template.js",
|
|
16
|
+
"import": "./index.mjs",
|
|
17
|
+
"require": "./index.js",
|
|
18
|
+
"types": "./web/move_bytecode_template.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./web/move_bytecode_template_bg.wasm": {
|
|
21
|
+
"browser": "./web/move_bytecode_template_bg.wasm",
|
|
22
|
+
"import": "./web/move_bytecode_template_bg.wasm",
|
|
23
|
+
"require": "./web/move_bytecode_template_bg.wasm"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/GeunhwaJeong/haneul-ts-sdks.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/GeunhwaJeong/haneul-ts-sdks/issues/new"
|
|
32
|
+
},
|
|
33
|
+
"author": "Haneul Labs <build@haneullabs.com>",
|
|
34
|
+
"license": "Apache-2.0",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.9.3",
|
|
37
|
+
"vitest": "^4.0.15",
|
|
38
|
+
"@haneullabs/build-scripts": "0.1.0",
|
|
39
|
+
"@haneullabs/bcs": "0.1.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build:wasm": "pnpm build:nodejs && pnpm build:web",
|
|
43
|
+
"build:nodejs": "wasm-pack build --target nodejs --release --out-dir nodejs --no-pack && rm nodejs/.gitignore",
|
|
44
|
+
"build:web": "wasm-pack build --target web --release --out-dir web --no-pack && rm web/.gitignore",
|
|
45
|
+
"test": "vitest run"
|
|
46
|
+
}
|
|
47
|
+
}
|