@tychosdk/disasm 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/LICENSE-APACHE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2015
2
+
3
+ Permission is hereby granted, free of charge, to any
4
+ person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the
6
+ Software without restriction, including without
7
+ limitation the rights to use, copy, modify, merge,
8
+ publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software
10
+ is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice
14
+ shall be included in all copies or substantial portions
15
+ of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
+ DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # TVM Disasm
2
+
3
+ A Tycho TVM disasm.
4
+
5
+ ## Installation
6
+
7
+ Requires node 16 or higher.
8
+
9
+ ```bash
10
+ yarn add @tychosdk/disasm
11
+ ```
12
+
13
+ or
14
+
15
+ ```bash
16
+ npm i @tychosdk/disasm
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { Cell } from "@ton/core";
23
+ import { disasmStructured } from "@tychosdk/disasm";
24
+
25
+ const code = Cell.fromBase64("te6ccgEBAgEACwABCvgAgHuIAQABYA==");
26
+ const parsed = await disasmStructured(code);
27
+ ```
28
+
29
+ ## Development
30
+
31
+ ### @tychosdk/disasm
32
+
33
+ To install dependencies:
34
+
35
+ ```bash
36
+ yarn install
37
+ ```
38
+
39
+ To build wasm:
40
+
41
+ ```bash
42
+ yarn wasm:build
43
+ ```
44
+
45
+ To run tests:
46
+
47
+ ```bash
48
+ yarn test
49
+ ```
50
+
51
+ To publish:
52
+
53
+ ```bash
54
+ yarn build
55
+ yarn publish --access public
56
+ ```
57
+
58
+ ## Contributing
59
+
60
+ We welcome contributions to the project! If you notice any issues or errors,
61
+ feel free to open an issue or submit a pull request.
62
+
63
+ ## License
64
+
65
+ Licensed under either of
66
+
67
+ * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE)
68
+ or <https://www.apache.org/licenses/LICENSE-2.0>)
69
+ * MIT license ([LICENSE-MIT](LICENSE-MIT)
70
+ or <https://opensource.org/licenses/MIT>)
71
+
72
+ at your option.
package/dist/env.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import * as browserWasm from "./wasm/tycho_disasm_node.js";
2
+ export type * from "./wasm/tycho_disasm_node.js";
3
+ export declare const wasm: typeof browserWasm;
4
+ export declare const wasmLoaded: (initInput?: any) => Promise<void>;
package/dist/env.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.wasmLoaded = exports.wasm = void 0;
37
+ const browserWasm = __importStar(require("./wasm/tycho_disasm_node.js"));
38
+ const init = require("./wasm/tycho_disasm_node.js").default;
39
+ let wasmInitializationStarted = false;
40
+ let notifyWasmInitialized;
41
+ const initializationPromise = new Promise((resolve, reject) => {
42
+ notifyWasmInitialized = { resolve, reject };
43
+ });
44
+ exports.wasm = browserWasm;
45
+ const wasmLoaded = (initInput) => {
46
+ if (typeof init === "function") {
47
+ if (!wasmInitializationStarted) {
48
+ wasmInitializationStarted = true;
49
+ init(initInput)
50
+ .then(notifyWasmInitialized.resolve)
51
+ .catch(notifyWasmInitialized.reject);
52
+ }
53
+ return initializationPromise;
54
+ }
55
+ else {
56
+ return Promise.resolve();
57
+ }
58
+ };
59
+ exports.wasmLoaded = wasmLoaded;
@@ -0,0 +1,3 @@
1
+ export type { Code, CodeBlock, CodeBlockTail, Data, DataBlock, Item, ItemId, JumpTable, Library, Link, LinkType, Opcode, } from "./env";
2
+ import type { Code } from "./env";
3
+ export declare function disasmStructured(code: string): Promise<Code>;
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.disasmStructured = disasmStructured;
4
+ const env_1 = require("./env");
5
+ async function disasmStructured(code) {
6
+ await (0, env_1.wasmLoaded)();
7
+ const res = env_1.wasm.disasm_structured(code);
8
+ return JSON.parse(res);
9
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {string} code
3
+ * @returns {string}
4
+ */
5
+ export function disasm_structured(code: string): string;
6
+ export default __wbg_init;
7
+ export function initSync(module: any): any;
8
+ declare function __wbg_init(module_or_path: any): Promise<any>;
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+ let wasm;
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
+ }
8
+ function handleError(f, args) {
9
+ try {
10
+ return f.apply(this, args);
11
+ }
12
+ catch (e) {
13
+ const idx = addToExternrefTable0(e);
14
+ wasm.__wbindgen_exn_store(idx);
15
+ }
16
+ }
17
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available'); } });
18
+ if (typeof TextDecoder !== 'undefined') {
19
+ cachedTextDecoder.decode();
20
+ }
21
+ ;
22
+ let cachedUint8ArrayMemory0 = null;
23
+ function getUint8ArrayMemory0() {
24
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
25
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
26
+ }
27
+ return cachedUint8ArrayMemory0;
28
+ }
29
+ function getStringFromWasm0(ptr, len) {
30
+ ptr = ptr >>> 0;
31
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
32
+ }
33
+ function isLikeNone(x) {
34
+ return x === undefined || x === null;
35
+ }
36
+ let WASM_VECTOR_LEN = 0;
37
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available'); } });
38
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
39
+ ? function (arg, view) {
40
+ return cachedTextEncoder.encodeInto(arg, view);
41
+ }
42
+ : function (arg, view) {
43
+ const buf = cachedTextEncoder.encode(arg);
44
+ view.set(buf);
45
+ return {
46
+ read: arg.length,
47
+ written: buf.length
48
+ };
49
+ });
50
+ function passStringToWasm0(arg, malloc, realloc) {
51
+ if (realloc === undefined) {
52
+ const buf = cachedTextEncoder.encode(arg);
53
+ const ptr = malloc(buf.length, 1) >>> 0;
54
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
55
+ WASM_VECTOR_LEN = buf.length;
56
+ return ptr;
57
+ }
58
+ let len = arg.length;
59
+ let ptr = malloc(len, 1) >>> 0;
60
+ const mem = getUint8ArrayMemory0();
61
+ let offset = 0;
62
+ for (; offset < len; offset++) {
63
+ const code = arg.charCodeAt(offset);
64
+ if (code > 0x7F)
65
+ break;
66
+ mem[ptr + offset] = code;
67
+ }
68
+ if (offset !== len) {
69
+ if (offset !== 0) {
70
+ arg = arg.slice(offset);
71
+ }
72
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
73
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
74
+ const ret = encodeString(arg, view);
75
+ offset += ret.written;
76
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
77
+ }
78
+ WASM_VECTOR_LEN = offset;
79
+ return ptr;
80
+ }
81
+ function takeFromExternrefTable0(idx) {
82
+ const value = wasm.__wbindgen_export_2.get(idx);
83
+ wasm.__externref_table_dealloc(idx);
84
+ return value;
85
+ }
86
+ /**
87
+ * @param {string} code
88
+ * @returns {string}
89
+ */
90
+ export function disasm_structured(code) {
91
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
92
+ const len0 = WASM_VECTOR_LEN;
93
+ const ret = wasm.disasm_structured(ptr0, len0);
94
+ if (ret[2]) {
95
+ throw takeFromExternrefTable0(ret[1]);
96
+ }
97
+ return takeFromExternrefTable0(ret[0]);
98
+ }
99
+ async function __wbg_load(module, imports) {
100
+ if (typeof Response === 'function' && module instanceof Response) {
101
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
102
+ try {
103
+ return await WebAssembly.instantiateStreaming(module, imports);
104
+ }
105
+ catch (e) {
106
+ if (module.headers.get('Content-Type') != 'application/wasm') {
107
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
108
+ }
109
+ else {
110
+ throw e;
111
+ }
112
+ }
113
+ }
114
+ const bytes = await module.arrayBuffer();
115
+ return await WebAssembly.instantiate(bytes, imports);
116
+ }
117
+ else {
118
+ const instance = await WebAssembly.instantiate(module, imports);
119
+ if (instance instanceof WebAssembly.Instance) {
120
+ return { instance, module };
121
+ }
122
+ else {
123
+ return instance;
124
+ }
125
+ }
126
+ }
127
+ function __wbg_get_imports() {
128
+ const imports = {};
129
+ imports.wbg = {};
130
+ imports.wbg.__wbg_buffer_609cc3eee51ed158 = function (arg0) {
131
+ const ret = arg0.buffer;
132
+ return ret;
133
+ };
134
+ imports.wbg.__wbg_call_672a4d21634d4a24 = function () {
135
+ return handleError(function (arg0, arg1) {
136
+ const ret = arg0.call(arg1);
137
+ return ret;
138
+ }, arguments);
139
+ };
140
+ imports.wbg.__wbg_call_7cccdd69e0791ae2 = function () {
141
+ return handleError(function (arg0, arg1, arg2) {
142
+ const ret = arg0.call(arg1, arg2);
143
+ return ret;
144
+ }, arguments);
145
+ };
146
+ imports.wbg.__wbg_crypto_ed58b8e10a292839 = function (arg0) {
147
+ const ret = arg0.crypto;
148
+ return ret;
149
+ };
150
+ imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function () {
151
+ return handleError(function (arg0, arg1) {
152
+ arg0.getRandomValues(arg1);
153
+ }, arguments);
154
+ };
155
+ imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function (arg0) {
156
+ const ret = arg0.msCrypto;
157
+ return ret;
158
+ };
159
+ imports.wbg.__wbg_new_a12002a7f91c75be = function (arg0) {
160
+ const ret = new Uint8Array(arg0);
161
+ return ret;
162
+ };
163
+ imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function (arg0, arg1) {
164
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
165
+ return ret;
166
+ };
167
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function (arg0, arg1, arg2) {
168
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
169
+ return ret;
170
+ };
171
+ imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function (arg0) {
172
+ const ret = new Uint8Array(arg0 >>> 0);
173
+ return ret;
174
+ };
175
+ imports.wbg.__wbg_node_02999533c4ea02e3 = function (arg0) {
176
+ const ret = arg0.node;
177
+ return ret;
178
+ };
179
+ imports.wbg.__wbg_process_5c1d670bc53614b8 = function (arg0) {
180
+ const ret = arg0.process;
181
+ return ret;
182
+ };
183
+ imports.wbg.__wbg_randomFillSync_ab2cfe79ebbf2740 = function () {
184
+ return handleError(function (arg0, arg1) {
185
+ arg0.randomFillSync(arg1);
186
+ }, arguments);
187
+ };
188
+ imports.wbg.__wbg_require_79b1e9274cde3c87 = function () {
189
+ return handleError(function () {
190
+ const ret = module.require;
191
+ return ret;
192
+ }, arguments);
193
+ };
194
+ imports.wbg.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
195
+ arg0.set(arg1, arg2 >>> 0);
196
+ };
197
+ imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function () {
198
+ const ret = typeof global === 'undefined' ? null : global;
199
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
200
+ };
201
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function () {
202
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
203
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
204
+ };
205
+ imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function () {
206
+ const ret = typeof self === 'undefined' ? null : self;
207
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
208
+ };
209
+ imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function () {
210
+ const ret = typeof window === 'undefined' ? null : window;
211
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
212
+ };
213
+ imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function (arg0, arg1, arg2) {
214
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
215
+ return ret;
216
+ };
217
+ imports.wbg.__wbg_versions_c71aa1626a93e0a1 = function (arg0) {
218
+ const ret = arg0.versions;
219
+ return ret;
220
+ };
221
+ imports.wbg.__wbindgen_init_externref_table = function () {
222
+ const table = wasm.__wbindgen_export_2;
223
+ const offset = table.grow(4);
224
+ table.set(0, undefined);
225
+ table.set(offset + 0, undefined);
226
+ table.set(offset + 1, null);
227
+ table.set(offset + 2, true);
228
+ table.set(offset + 3, false);
229
+ ;
230
+ };
231
+ imports.wbg.__wbindgen_is_function = function (arg0) {
232
+ const ret = typeof (arg0) === 'function';
233
+ return ret;
234
+ };
235
+ imports.wbg.__wbindgen_is_object = function (arg0) {
236
+ const val = arg0;
237
+ const ret = typeof (val) === 'object' && val !== null;
238
+ return ret;
239
+ };
240
+ imports.wbg.__wbindgen_is_string = function (arg0) {
241
+ const ret = typeof (arg0) === 'string';
242
+ return ret;
243
+ };
244
+ imports.wbg.__wbindgen_is_undefined = function (arg0) {
245
+ const ret = arg0 === undefined;
246
+ return ret;
247
+ };
248
+ imports.wbg.__wbindgen_memory = function () {
249
+ const ret = wasm.memory;
250
+ return ret;
251
+ };
252
+ imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
253
+ const ret = getStringFromWasm0(arg0, arg1);
254
+ return ret;
255
+ };
256
+ imports.wbg.__wbindgen_throw = function (arg0, arg1) {
257
+ throw new Error(getStringFromWasm0(arg0, arg1));
258
+ };
259
+ return imports;
260
+ }
261
+ function __wbg_init_memory(imports, memory) {
262
+ }
263
+ function __wbg_finalize_init(instance, module) {
264
+ wasm = instance.exports;
265
+ __wbg_init.__wbindgen_wasm_module = module;
266
+ cachedUint8ArrayMemory0 = null;
267
+ wasm.__wbindgen_start();
268
+ return wasm;
269
+ }
270
+ function initSync(module) {
271
+ if (wasm !== undefined)
272
+ return wasm;
273
+ if (typeof module !== 'undefined') {
274
+ if (Object.getPrototypeOf(module) === Object.prototype) {
275
+ ({ module } = module);
276
+ }
277
+ else {
278
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
279
+ }
280
+ }
281
+ const imports = __wbg_get_imports();
282
+ __wbg_init_memory(imports);
283
+ if (!(module instanceof WebAssembly.Module)) {
284
+ module = new WebAssembly.Module(module);
285
+ }
286
+ const instance = new WebAssembly.Instance(module, imports);
287
+ return __wbg_finalize_init(instance, module);
288
+ }
289
+ async function __wbg_init(module_or_path) {
290
+ if (wasm !== undefined)
291
+ return wasm;
292
+ if (typeof module_or_path !== 'undefined') {
293
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
294
+ ({ module_or_path } = module_or_path);
295
+ }
296
+ else {
297
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead');
298
+ }
299
+ }
300
+ if (typeof module_or_path === 'undefined') {
301
+ module_or_path = new URL('tycho_disasm_bg.wasm', import.meta.url);
302
+ }
303
+ const imports = __wbg_get_imports();
304
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
305
+ module_or_path = fetch(module_or_path);
306
+ }
307
+ __wbg_init_memory(imports);
308
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
309
+ return __wbg_finalize_init(instance, module);
310
+ }
311
+ export { initSync };
312
+ export default __wbg_init;
Binary file
@@ -0,0 +1,11 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const disasm_structured: (a: number, b: number) => [number, number, number];
5
+ export const __wbindgen_exn_store: (a: number) => void;
6
+ export const __externref_table_alloc: () => number;
7
+ export const __wbindgen_export_2: WebAssembly.Table;
8
+ export const __wbindgen_malloc: (a: number, b: number) => number;
9
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
10
+ export const __externref_table_dealloc: (a: number) => void;
11
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,32 @@
1
+ export function disasm_structured(code: string): string;
2
+ export function __wbg_buffer_609cc3eee51ed158(arg0: any): any;
3
+ export function __wbg_call_672a4d21634d4a24(...args: any[]): any;
4
+ export function __wbg_call_7cccdd69e0791ae2(...args: any[]): any;
5
+ export function __wbg_crypto_ed58b8e10a292839(arg0: any): any;
6
+ export function __wbg_getRandomValues_bcb4912f16000dc4(...args: any[]): any;
7
+ export function __wbg_msCrypto_0a36e2ec3a343d26(arg0: any): any;
8
+ export function __wbg_new_a12002a7f91c75be(arg0: any): Uint8Array<any>;
9
+ export function __wbg_newnoargs_105ed471475aaf50(arg0: any, arg1: any): Function;
10
+ export function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a(arg0: any, arg1: any, arg2: any): Uint8Array<any>;
11
+ export function __wbg_newwithlength_a381634e90c276d4(arg0: any): Uint8Array<ArrayBuffer>;
12
+ export function __wbg_node_02999533c4ea02e3(arg0: any): any;
13
+ export function __wbg_process_5c1d670bc53614b8(arg0: any): any;
14
+ export function __wbg_randomFillSync_ab2cfe79ebbf2740(...args: any[]): any;
15
+ export function __wbg_require_79b1e9274cde3c87(...args: any[]): any;
16
+ export function __wbg_set_65595bdd868b3009(arg0: any, arg1: any, arg2: any): void;
17
+ export function __wbg_static_accessor_GLOBAL_88a902d13a557d07(): any;
18
+ export function __wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0(): any;
19
+ export function __wbg_static_accessor_SELF_37c5d418e4bf5819(): any;
20
+ export function __wbg_static_accessor_WINDOW_5de37043a91a9c40(): any;
21
+ export function __wbg_subarray_aa9065fa9dc5df96(arg0: any, arg1: any, arg2: any): any;
22
+ export function __wbg_versions_c71aa1626a93e0a1(arg0: any): any;
23
+ export function __wbindgen_init_externref_table(): void;
24
+ export function __wbindgen_is_function(arg0: any): boolean;
25
+ export function __wbindgen_is_object(arg0: any): boolean;
26
+ export function __wbindgen_is_string(arg0: any): arg0 is string;
27
+ export function __wbindgen_is_undefined(arg0: any): boolean;
28
+ export function __wbindgen_memory(): any;
29
+ export function __wbindgen_string_new(arg0: any, arg1: any): string;
30
+ export function __wbindgen_throw(arg0: any, arg1: any): never;
31
+ export { wasm as __wasm };
32
+ declare let wasm: any;
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ let imports = {};
3
+ imports['wbg'] = module.exports;
4
+ let wasm;
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+ function addToExternrefTable0(obj) {
7
+ const idx = wasm.__externref_table_alloc();
8
+ wasm.__wbindgen_export_2.set(idx, obj);
9
+ return idx;
10
+ }
11
+ function handleError(f, args) {
12
+ try {
13
+ return f.apply(this, args);
14
+ }
15
+ catch (e) {
16
+ const idx = addToExternrefTable0(e);
17
+ wasm.__wbindgen_exn_store(idx);
18
+ }
19
+ }
20
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
21
+ cachedTextDecoder.decode();
22
+ let cachedUint8ArrayMemory0 = null;
23
+ function getUint8ArrayMemory0() {
24
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
25
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
26
+ }
27
+ return cachedUint8ArrayMemory0;
28
+ }
29
+ function getStringFromWasm0(ptr, len) {
30
+ ptr = ptr >>> 0;
31
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
32
+ }
33
+ function isLikeNone(x) {
34
+ return x === undefined || x === null;
35
+ }
36
+ let WASM_VECTOR_LEN = 0;
37
+ let cachedTextEncoder = new TextEncoder('utf-8');
38
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
39
+ ? function (arg, view) {
40
+ return cachedTextEncoder.encodeInto(arg, view);
41
+ }
42
+ : function (arg, view) {
43
+ const buf = cachedTextEncoder.encode(arg);
44
+ view.set(buf);
45
+ return {
46
+ read: arg.length,
47
+ written: buf.length
48
+ };
49
+ });
50
+ function passStringToWasm0(arg, malloc, realloc) {
51
+ if (realloc === undefined) {
52
+ const buf = cachedTextEncoder.encode(arg);
53
+ const ptr = malloc(buf.length, 1) >>> 0;
54
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
55
+ WASM_VECTOR_LEN = buf.length;
56
+ return ptr;
57
+ }
58
+ let len = arg.length;
59
+ let ptr = malloc(len, 1) >>> 0;
60
+ const mem = getUint8ArrayMemory0();
61
+ let offset = 0;
62
+ for (; offset < len; offset++) {
63
+ const code = arg.charCodeAt(offset);
64
+ if (code > 0x7F)
65
+ break;
66
+ mem[ptr + offset] = code;
67
+ }
68
+ if (offset !== len) {
69
+ if (offset !== 0) {
70
+ arg = arg.slice(offset);
71
+ }
72
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
73
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
74
+ const ret = encodeString(arg, view);
75
+ offset += ret.written;
76
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
77
+ }
78
+ WASM_VECTOR_LEN = offset;
79
+ return ptr;
80
+ }
81
+ function takeFromExternrefTable0(idx) {
82
+ const value = wasm.__wbindgen_export_2.get(idx);
83
+ wasm.__externref_table_dealloc(idx);
84
+ return value;
85
+ }
86
+ /**
87
+ * @param {string} code
88
+ * @returns {string}
89
+ */
90
+ module.exports.disasm_structured = function (code) {
91
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
92
+ const len0 = WASM_VECTOR_LEN;
93
+ const ret = wasm.disasm_structured(ptr0, len0);
94
+ if (ret[2]) {
95
+ throw takeFromExternrefTable0(ret[1]);
96
+ }
97
+ return takeFromExternrefTable0(ret[0]);
98
+ };
99
+ module.exports.__wbg_buffer_609cc3eee51ed158 = function (arg0) {
100
+ const ret = arg0.buffer;
101
+ return ret;
102
+ };
103
+ module.exports.__wbg_call_672a4d21634d4a24 = function () {
104
+ return handleError(function (arg0, arg1) {
105
+ const ret = arg0.call(arg1);
106
+ return ret;
107
+ }, arguments);
108
+ };
109
+ module.exports.__wbg_call_7cccdd69e0791ae2 = function () {
110
+ return handleError(function (arg0, arg1, arg2) {
111
+ const ret = arg0.call(arg1, arg2);
112
+ return ret;
113
+ }, arguments);
114
+ };
115
+ module.exports.__wbg_crypto_ed58b8e10a292839 = function (arg0) {
116
+ const ret = arg0.crypto;
117
+ return ret;
118
+ };
119
+ module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function () {
120
+ return handleError(function (arg0, arg1) {
121
+ arg0.getRandomValues(arg1);
122
+ }, arguments);
123
+ };
124
+ module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function (arg0) {
125
+ const ret = arg0.msCrypto;
126
+ return ret;
127
+ };
128
+ module.exports.__wbg_new_a12002a7f91c75be = function (arg0) {
129
+ const ret = new Uint8Array(arg0);
130
+ return ret;
131
+ };
132
+ module.exports.__wbg_newnoargs_105ed471475aaf50 = function (arg0, arg1) {
133
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
134
+ return ret;
135
+ };
136
+ module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function (arg0, arg1, arg2) {
137
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
138
+ return ret;
139
+ };
140
+ module.exports.__wbg_newwithlength_a381634e90c276d4 = function (arg0) {
141
+ const ret = new Uint8Array(arg0 >>> 0);
142
+ return ret;
143
+ };
144
+ module.exports.__wbg_node_02999533c4ea02e3 = function (arg0) {
145
+ const ret = arg0.node;
146
+ return ret;
147
+ };
148
+ module.exports.__wbg_process_5c1d670bc53614b8 = function (arg0) {
149
+ const ret = arg0.process;
150
+ return ret;
151
+ };
152
+ module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function () {
153
+ return handleError(function (arg0, arg1) {
154
+ arg0.randomFillSync(arg1);
155
+ }, arguments);
156
+ };
157
+ module.exports.__wbg_require_79b1e9274cde3c87 = function () {
158
+ return handleError(function () {
159
+ const ret = module.require;
160
+ return ret;
161
+ }, arguments);
162
+ };
163
+ module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
164
+ arg0.set(arg1, arg2 >>> 0);
165
+ };
166
+ module.exports.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function () {
167
+ const ret = typeof global === 'undefined' ? null : global;
168
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
169
+ };
170
+ module.exports.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function () {
171
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
172
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
173
+ };
174
+ module.exports.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function () {
175
+ const ret = typeof self === 'undefined' ? null : self;
176
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
177
+ };
178
+ module.exports.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function () {
179
+ const ret = typeof window === 'undefined' ? null : window;
180
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
181
+ };
182
+ module.exports.__wbg_subarray_aa9065fa9dc5df96 = function (arg0, arg1, arg2) {
183
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
184
+ return ret;
185
+ };
186
+ module.exports.__wbg_versions_c71aa1626a93e0a1 = function (arg0) {
187
+ const ret = arg0.versions;
188
+ return ret;
189
+ };
190
+ module.exports.__wbindgen_init_externref_table = function () {
191
+ const table = wasm.__wbindgen_export_2;
192
+ const offset = table.grow(4);
193
+ table.set(0, undefined);
194
+ table.set(offset + 0, undefined);
195
+ table.set(offset + 1, null);
196
+ table.set(offset + 2, true);
197
+ table.set(offset + 3, false);
198
+ ;
199
+ };
200
+ module.exports.__wbindgen_is_function = function (arg0) {
201
+ const ret = typeof (arg0) === 'function';
202
+ return ret;
203
+ };
204
+ module.exports.__wbindgen_is_object = function (arg0) {
205
+ const val = arg0;
206
+ const ret = typeof (val) === 'object' && val !== null;
207
+ return ret;
208
+ };
209
+ module.exports.__wbindgen_is_string = function (arg0) {
210
+ const ret = typeof (arg0) === 'string';
211
+ return ret;
212
+ };
213
+ module.exports.__wbindgen_is_undefined = function (arg0) {
214
+ const ret = arg0 === undefined;
215
+ return ret;
216
+ };
217
+ module.exports.__wbindgen_memory = function () {
218
+ const ret = wasm.memory;
219
+ return ret;
220
+ };
221
+ module.exports.__wbindgen_string_new = function (arg0, arg1) {
222
+ const ret = getStringFromWasm0(arg0, arg1);
223
+ return ret;
224
+ };
225
+ module.exports.__wbindgen_throw = function (arg0, arg1) {
226
+ throw new Error(getStringFromWasm0(arg0, arg1));
227
+ };
228
+ const path = require('path').join(__dirname, 'tycho_disasm_bg.wasm');
229
+ const bytes = require('fs').readFileSync(path);
230
+ const wasmModule = new WebAssembly.Module(bytes);
231
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
232
+ wasm = wasmInstance.exports;
233
+ module.exports.__wasm = wasm;
234
+ wasm.__wbindgen_start();
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@tychosdk/disasm",
3
+ "version": "0.1.0",
4
+ "description": "Tycho TVM disasm",
5
+ "main": "dist/index.js",
6
+ "browser": {
7
+ "./dist/wasm/tycho_disasm_node.js": "./dist/wasm/tycho_disasm.mjs"
8
+ },
9
+ "license": "MIT",
10
+ "author": "Ivan Kalinin <i.kalinin@dexpa.io>",
11
+ "files": [
12
+ "dist/**/*"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/broxus/tycho-disasm.git"
17
+ },
18
+ "devDependencies": {
19
+ "@ton/core": "^0.60.1",
20
+ "@types/jest": "^29.5.14",
21
+ "@types/node": "^18.15.11",
22
+ "jest": "^29.7.0",
23
+ "ts-jest": "^29.0.5",
24
+ "ts-node": "^10.9.2",
25
+ "typescript": "^5.8.3"
26
+ },
27
+ "peerDependencies": {
28
+ "@ton/crypto": ">=3.2.0"
29
+ },
30
+ "scripts": {
31
+ "wasm:build": "./scripts/build-wasm.sh",
32
+ "wasm:copy": "cp src/wasm/tycho_disasm_bg.wasm* ./dist/wasm/",
33
+ "test": "yarn jest src",
34
+ "build": "yarn wasm:build && rm -rf dist && yarn test && tsc && yarn wasm:copy"
35
+ }
36
+ }