@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,118 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Get the version of the crate (useful for testing the package).
|
|
5
|
+
*/
|
|
6
|
+
export function version(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Deserialize the `Uint8Array`` bytecode into a JSON object.
|
|
9
|
+
* The JSON object contains the ABI (Application Binary Interface) of the module.
|
|
10
|
+
*
|
|
11
|
+
* ```javascript
|
|
12
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
13
|
+
*
|
|
14
|
+
* const json = template.deserialize( binary );
|
|
15
|
+
* console.log( json, json.identifiers );
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function deserialize(binary: Uint8Array): any;
|
|
19
|
+
/**
|
|
20
|
+
* Update the identifiers in the module bytecode, given a map of old -> new identifiers.
|
|
21
|
+
* Returns the updated bytecode.
|
|
22
|
+
*
|
|
23
|
+
* ```javascript
|
|
24
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
25
|
+
*
|
|
26
|
+
* const updated = template.update_identifiers( binary, {
|
|
27
|
+
* 'TEMPLATE': 'NEW_VALUE',
|
|
28
|
+
* 'template': 'new_value',
|
|
29
|
+
* 'Name': 'NewName'
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function update_identifiers(binary: Uint8Array, map: any): Uint8Array;
|
|
34
|
+
/**
|
|
35
|
+
* Updates a constant in the constant pool. Because constants don't have names,
|
|
36
|
+
* the only way to identify them is by their type and value.
|
|
37
|
+
*
|
|
38
|
+
* The value of a constant is BCS-encoded and the type is a string representation
|
|
39
|
+
* of the `SignatureToken` enum. String identifier for `SignatureToken` is a
|
|
40
|
+
* capitalized version of the type: U8, Address, Vector(Bool), Vector(U8), etc.
|
|
41
|
+
*
|
|
42
|
+
* ```javascript
|
|
43
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
44
|
+
* import { bcs } from '@haneullabs/bcs';
|
|
45
|
+
*
|
|
46
|
+
* let binary = template.update_constants(
|
|
47
|
+
* binary, // Uint8Array
|
|
48
|
+
* bcs.u64().serialize(0).toBytes(), // new value
|
|
49
|
+
* bcs.u64().serialize(100000).toBytes(), // old value
|
|
50
|
+
* 'U64' // type
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function update_constants(binary: Uint8Array, new_value: Uint8Array, expected_value: Uint8Array, expected_type: string): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* Convenience method to analyze the constant pool; returns all constants in order
|
|
57
|
+
* with their type and BCS value.
|
|
58
|
+
*
|
|
59
|
+
* ```javascript
|
|
60
|
+
* import * as template from '@haneullabs/move-binary-template';
|
|
61
|
+
*
|
|
62
|
+
* let consts = template.get_constants(binary);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function get_constants(binary: Uint8Array): any;
|
|
66
|
+
/**
|
|
67
|
+
* Serialize the JSON module into a `Uint8Array` (bytecode).
|
|
68
|
+
*/
|
|
69
|
+
export function serialize(json_module: any): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* A transformed constant from the constant pool.
|
|
72
|
+
*/
|
|
73
|
+
export class Constant {
|
|
74
|
+
private constructor();
|
|
75
|
+
free(): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
79
|
+
|
|
80
|
+
export interface InitOutput {
|
|
81
|
+
readonly memory: WebAssembly.Memory;
|
|
82
|
+
readonly version: () => [number, number];
|
|
83
|
+
readonly deserialize: (a: number, b: number) => [number, number, number];
|
|
84
|
+
readonly update_identifiers: (a: number, b: number, c: any) => [number, number, number, number];
|
|
85
|
+
readonly update_constants: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
86
|
+
readonly __wbg_constant_free: (a: number, b: number) => void;
|
|
87
|
+
readonly get_constants: (a: number, b: number) => [number, number, number];
|
|
88
|
+
readonly serialize: (a: any) => [number, number, number, number];
|
|
89
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
90
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
91
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
92
|
+
readonly __externref_table_alloc: () => number;
|
|
93
|
+
readonly __wbindgen_export_4: WebAssembly.Table;
|
|
94
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
95
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
96
|
+
readonly __wbindgen_start: () => void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
100
|
+
/**
|
|
101
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
102
|
+
* a precompiled `WebAssembly.Module`.
|
|
103
|
+
*
|
|
104
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
105
|
+
*
|
|
106
|
+
* @returns {InitOutput}
|
|
107
|
+
*/
|
|
108
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
112
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
113
|
+
*
|
|
114
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
115
|
+
*
|
|
116
|
+
* @returns {Promise<InitOutput>}
|
|
117
|
+
*/
|
|
118
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|