@ton/sandbox 0.42.0 → 0.43.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.
Files changed (35) hide show
  1. package/dist/blockchain/Blockchain.d.ts +1 -6
  2. package/dist/blockchain/Blockchain.js +0 -15
  3. package/dist/blockchain/SmartContract.d.ts +0 -3
  4. package/dist/blockchain/SmartContract.js +1 -39
  5. package/dist/config/config.tlb-gen.d.ts +69 -18
  6. package/dist/config/config.tlb-gen.js +273 -53
  7. package/dist/config/defaultConfig.d.ts +2 -2
  8. package/dist/config/defaultConfig.js +2 -2
  9. package/dist/config/slimConfig.d.ts +2 -2
  10. package/dist/config/slimConfig.js +2 -2
  11. package/dist/executor/Executor.d.ts +1 -37
  12. package/dist/executor/Executor.js +3 -160
  13. package/dist/executor/emulator-emscripten.js +1 -1
  14. package/dist/executor/emulator-emscripten.wasm.js +1 -1
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.js +1 -3
  17. package/package.json +3 -5
  18. package/dist/debugger/DebugContext.d.ts +0 -14
  19. package/dist/debugger/DebugContext.js +0 -29
  20. package/dist/debugger/DebugInfoCache.d.ts +0 -9
  21. package/dist/debugger/DebugInfoCache.js +0 -87
  22. package/dist/debugger/Debuggee.d.ts +0 -147
  23. package/dist/debugger/Debuggee.js +0 -451
  24. package/dist/debugger/TVMDebugSession.d.ts +0 -26
  25. package/dist/debugger/TVMDebugSession.js +0 -272
  26. package/dist/debugger/debug.d.ts +0 -4
  27. package/dist/debugger/debug.js +0 -76
  28. package/dist/debugger/index.d.ts +0 -1
  29. package/dist/debugger/index.js +0 -5
  30. package/dist/debugger/marks.d.ts +0 -2
  31. package/dist/debugger/marks.js +0 -127
  32. package/dist/executor/emulator-emscripten.debugger.bpatch.gzip.js +0 -1
  33. package/dist/executor/emulator-emscripten.debugger.js +0 -20
  34. package/dist/utils/bpatch.d.ts +0 -9
  35. package/dist/utils/bpatch.js +0 -52
@@ -96,11 +96,8 @@ export declare class Executor implements IExecutor {
96
96
  private module;
97
97
  private heap;
98
98
  private emulator?;
99
- debugLogFunc: (s: string) => void;
100
99
  private constructor();
101
- static create(opts?: {
102
- debug?: boolean;
103
- }): Promise<Executor>;
100
+ static create(): Promise<Executor>;
104
101
  runGetMethod(args: GetMethodArgs): Promise<GetMethodResult>;
105
102
  private runCommon;
106
103
  runTickTock(args: RunTickTockArgs): Promise<EmulationResult>;
@@ -108,39 +105,6 @@ export declare class Executor implements IExecutor {
108
105
  private createEmulator;
109
106
  private getEmulatorPointer;
110
107
  invoke(method: string, args: (number | string)[]): number;
111
- sbsGetMethodSetup(args: GetMethodArgs): number;
112
- destroyTvmEmulator(ptr: number): void;
113
- sbsGetMethodStep(ptr: number): boolean;
114
- sbsGetMethodStack(ptr: number): TupleItem[];
115
- sbsGetMethodC7(ptr: number): TupleItem;
116
- sbsGetMethodGetContDistinguisher(ptr: number): number;
117
- sbsGetMethodSetContDistinguishers(ptr: number, distinguisher: number, trueDistinguisher: number, falseDistinguisher: number): void;
118
- sbsGetMethodGetContDistinguisherTriggered(ptr: number): boolean;
119
- sbsGetMethodSetTryParams(ptr: number, primed: number, triggered: number): void;
120
- sbsGetMethodGetTriggeredTryParam(ptr: number): number;
121
- sbsGetMethodCodePos(ptr: number): {
122
- hash: string;
123
- offset: number;
124
- };
125
- sbsGetMethodResult(ptr: number): GetMethodResult;
126
- sbsTransactionSetup(args: RunTransactionArgs): {
127
- res: number;
128
- emptr: number;
129
- };
130
- destroyEmulator(ptr: number): void;
131
- sbsTransactionStep(ptr: number): boolean;
132
- sbsTransactionCodePos(ptr: number): {
133
- hash: string;
134
- offset: number;
135
- };
136
- sbsTransactionStack(ptr: number): TupleItem[];
137
- sbsTransactionC7(ptr: number): TupleItem;
138
- sbsTransactionGetContDistinguisher(ptr: number): number;
139
- sbsTransactionSetContDistinguishers(ptr: number, distinguisher: number, trueDistinguisher: number, falseDistinguisher: number): void;
140
- sbsTransactionGetContDistinguisherTriggered(ptr: number): boolean;
141
- sbsTransactionSetTryParams(ptr: number, primed: number, triggered: number): void;
142
- sbsTransactionGetTriggeredTryParam(ptr: number): number;
143
- sbsTransactionResult(ptr: number): EmulationResult;
144
108
  private extractString;
145
109
  getVersion(): {
146
110
  commitHash: string;
@@ -2,13 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Executor = void 0;
4
4
  const core_1 = require("@ton/core");
5
- const fflate_1 = require("fflate");
6
5
  const base64_1 = require("../utils/base64");
7
- const bpatch_1 = require("../utils/bpatch");
8
6
  // eslint-disable-next-line @typescript-eslint/no-require-imports
9
7
  const EmulatorModule = require('./emulator-emscripten.js');
10
- // eslint-disable-next-line @typescript-eslint/no-require-imports
11
- const DebuggerEmulatorModule = require('./emulator-emscripten.debugger.js');
12
8
  function blockIdToTuple(blockId) {
13
9
  return [
14
10
  { type: 'int', value: BigInt(blockId.workchain) },
@@ -153,17 +149,6 @@ function getWasmBinary() {
153
149
  wasmBinary = new Uint8Array((0, base64_1.base64Decode)(require('./emulator-emscripten.wasm.js').EmulatorEmscriptenWasm));
154
150
  return wasmBinary;
155
151
  }
156
- let debuggerWasmBinary = undefined;
157
- function getDebuggerWasmBinary() {
158
- if (debuggerWasmBinary !== undefined) {
159
- return debuggerWasmBinary;
160
- }
161
- // eslint-disable-next-line @typescript-eslint/no-require-imports
162
- const patch = (0, base64_1.base64Decode)(require('./emulator-emscripten.debugger.bpatch.gzip.js').DebuggerPatchGzip);
163
- const unzipped = (0, fflate_1.gunzipSync)(patch);
164
- debuggerWasmBinary = (0, bpatch_1.decodePatch)(getWasmBinary(), unzipped);
165
- return debuggerWasmBinary;
166
- }
167
152
  function splitVmLog(log) {
168
153
  const vm = [];
169
154
  const debug = [];
@@ -182,19 +167,15 @@ class Executor {
182
167
  module;
183
168
  heap;
184
169
  emulator;
185
- // TODO: this is not used anymore - debug logs are now included in the VM log, and so we cannot emit them during execution
186
- debugLogFunc = () => { };
187
170
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
188
171
  constructor(module) {
189
172
  this.module = module;
190
173
  this.heap = new Heap(module);
191
174
  }
192
- static async create(opts) {
193
- const binary = opts?.debug ? getDebuggerWasmBinary() : getWasmBinary();
194
- const module = opts?.debug ? DebuggerEmulatorModule : EmulatorModule;
175
+ static async create() {
195
176
  let ex = undefined;
196
- ex = new Executor(await module({
197
- wasmBinary: binary,
177
+ ex = new Executor(await EmulatorModule({
178
+ wasmBinary: getWasmBinary(),
198
179
  }));
199
180
  return ex;
200
181
  }
@@ -311,144 +292,6 @@ class Executor {
311
292
  }
312
293
  return this.module[method](...invocationArgs);
313
294
  }
314
- sbsGetMethodSetup(args) {
315
- const params = getMethodArgsToInternalParams(args);
316
- let stack = (0, core_1.serializeTuple)(args.stack);
317
- const res = this.invoke('_setup_sbs_get_method', [
318
- JSON.stringify(params),
319
- stack.toBoc().toString('base64'),
320
- args.config,
321
- ]);
322
- return res;
323
- }
324
- destroyTvmEmulator(ptr) {
325
- this.invoke('_destroy_tvm_emulator', [ptr]);
326
- }
327
- sbsGetMethodStep(ptr) {
328
- const res = this.invoke('_sbs_step', [ptr]);
329
- return res !== 0;
330
- }
331
- sbsGetMethodStack(ptr) {
332
- const resp = this.extractString(this.invoke('_sbs_get_stack', [ptr]));
333
- return (0, core_1.parseTuple)(core_1.Cell.fromBase64(resp));
334
- }
335
- sbsGetMethodC7(ptr) {
336
- const resp = this.extractString(this.invoke('_sbs_get_c7', [ptr]));
337
- return (0, core_1.parseTuple)((0, core_1.beginCell)().storeUint(1, 24).storeRef(core_1.Cell.EMPTY).storeSlice(core_1.Cell.fromBase64(resp).beginParse()).endCell())[0];
338
- }
339
- sbsGetMethodGetContDistinguisher(ptr) {
340
- return this.invoke('_sbs_get_cont_distinguisher', [ptr]);
341
- }
342
- sbsGetMethodSetContDistinguishers(ptr, distinguisher, trueDistinguisher, falseDistinguisher) {
343
- this.invoke('_sbs_set_cont_distinguishers', [ptr, distinguisher, trueDistinguisher, falseDistinguisher]);
344
- }
345
- sbsGetMethodGetContDistinguisherTriggered(ptr) {
346
- return this.invoke('_sbs_get_cont_distinguisher_triggered', [ptr]) !== 0;
347
- }
348
- sbsGetMethodSetTryParams(ptr, primed, triggered) {
349
- this.invoke('_sbs_set_try_params', [ptr, primed, triggered]);
350
- }
351
- sbsGetMethodGetTriggeredTryParam(ptr) {
352
- return this.invoke('_sbs_get_triggered_try_param', [ptr]);
353
- }
354
- sbsGetMethodCodePos(ptr) {
355
- const resp = this.extractString(this.invoke('_sbs_get_code_pos', [ptr]));
356
- const parts = resp.split(':');
357
- return {
358
- hash: parts[0],
359
- offset: parseInt(parts[1]),
360
- };
361
- }
362
- sbsGetMethodResult(ptr) {
363
- const resp = JSON.parse(this.extractString(this.invoke('_sbs_get_method_result', [ptr])));
364
- const { vmLog, debugLog } = splitVmLog('vm_log' in resp ? resp.vm_log : '');
365
- return {
366
- output: 'vm_log' in resp
367
- ? {
368
- ...resp,
369
- vm_log: vmLog,
370
- }
371
- : resp,
372
- logs: 'BLOCKCHAIN LOGS ARE NOT AVAILABLE IN DEBUGGER BETA',
373
- debugLogs: debugLog,
374
- };
375
- }
376
- sbsTransactionSetup(args) {
377
- const emptr = this.invoke('_create_emulator', [args.config, verbosityToNum[args.verbosity]]);
378
- const params = runCommonArgsToInternalParams(args);
379
- const res = this.invoke('_emulate_sbs', [
380
- emptr,
381
- args.libs?.toBoc().toString('base64') ?? 0,
382
- args.shardAccount,
383
- args.message.toBoc().toString('base64'),
384
- JSON.stringify(params),
385
- ]);
386
- return { res, emptr };
387
- }
388
- destroyEmulator(ptr) {
389
- this.invoke('_destroy_emulator', [ptr]);
390
- }
391
- sbsTransactionStep(ptr) {
392
- const res = this.invoke('_em_sbs_step', [ptr]);
393
- return res !== 0;
394
- }
395
- sbsTransactionCodePos(ptr) {
396
- const resp = this.extractString(this.invoke('_em_sbs_code_pos', [ptr]));
397
- const parts = resp.split(':');
398
- return {
399
- hash: parts[0],
400
- offset: parseInt(parts[1]),
401
- };
402
- }
403
- sbsTransactionStack(ptr) {
404
- const resp = this.extractString(this.invoke('_em_sbs_stack', [ptr]));
405
- return (0, core_1.parseTuple)(core_1.Cell.fromBase64(resp));
406
- }
407
- sbsTransactionC7(ptr) {
408
- const resp = this.extractString(this.invoke('_em_sbs_c7', [ptr]));
409
- return (0, core_1.parseTuple)((0, core_1.beginCell)().storeUint(1, 24).storeRef(core_1.Cell.EMPTY).storeSlice(core_1.Cell.fromBase64(resp).beginParse()).endCell())[0];
410
- }
411
- sbsTransactionGetContDistinguisher(ptr) {
412
- return this.invoke('_em_sbs_get_cont_distinguisher', [ptr]);
413
- }
414
- sbsTransactionSetContDistinguishers(ptr, distinguisher, trueDistinguisher, falseDistinguisher) {
415
- this.invoke('_em_sbs_set_cont_distinguishers', [ptr, distinguisher, trueDistinguisher, falseDistinguisher]);
416
- }
417
- sbsTransactionGetContDistinguisherTriggered(ptr) {
418
- return this.invoke('_em_sbs_get_cont_distinguisher_triggered', [ptr]) !== 0;
419
- }
420
- sbsTransactionSetTryParams(ptr, primed, triggered) {
421
- this.invoke('_em_sbs_set_try_params', [ptr, primed, triggered]);
422
- }
423
- sbsTransactionGetTriggeredTryParam(ptr) {
424
- return this.invoke('_em_sbs_get_triggered_try_param', [ptr]);
425
- }
426
- sbsTransactionResult(ptr) {
427
- const result = JSON.parse(this.extractString(this.invoke('_em_sbs_result', [ptr])));
428
- const { vmLog, debugLog } = splitVmLog('vm_log' in result ? result.vm_log : '');
429
- return {
430
- result: result.success
431
- ? {
432
- success: true,
433
- transaction: result.transaction,
434
- shardAccount: result.shard_account,
435
- vmLog: vmLog,
436
- actions: result.actions,
437
- }
438
- : {
439
- success: false,
440
- error: result.error,
441
- vmResults: 'vm_log' in result
442
- ? {
443
- vmLog: vmLog,
444
- vmExitCode: result.vm_exit_code,
445
- }
446
- : undefined,
447
- },
448
- logs: 'BLOCKCHAIN LOGS ARE NOT AVAILABLE IN DEBUGGER BETA',
449
- debugLogs: debugLog,
450
- };
451
- }
452
295
  extractString(ptr) {
453
296
  const str = this.module.UTF8ToString(ptr);
454
297
  this.module._free(ptr);