From 79e5c9cf3fc70885d1372eb44c6ae6b30ca45440 Mon Sep 17 00:00:00 2001 From: robal Date: Fri, 3 Mar 2023 16:14:05 +0100 Subject: [PATCH] feat: add glue code for console_error_panic_hook - this allows for enabling of this hook in rust contracts gh-309 --- .../modules/impl/wasm/rust-wasm-imports.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/core/modules/impl/wasm/rust-wasm-imports.ts b/src/core/modules/impl/wasm/rust-wasm-imports.ts index 6c239739..1c110c4b 100644 --- a/src/core/modules/impl/wasm/rust-wasm-imports.ts +++ b/src/core/modules/impl/wasm/rust-wasm-imports.ts @@ -245,7 +245,7 @@ export const rustWasmImports = (swGlobal, wbindgenImports, wasmInstance, dtorVal return addHeapObject(ret); }, arguments); }, - __wbg_new: function (arg0, arg1) { + __wbg_new_4: function (arg0, arg1) { try { var state0 = { a: arg0, b: arg1 }; var cb0 = (arg0, arg1) => { @@ -263,6 +263,27 @@ export const rustWasmImports = (swGlobal, wbindgenImports, wasmInstance, dtorVal state0.a = state0.b = 0; } }, + __wbg_new_6: function() { + var ret = new Error(); + return addHeapObject(ret); + }, + __wbg_stack: function(arg0, arg1) { + let limit = Error.stackTraceLimit; + Error.stackTraceLimit = 25; + var ret = getObject(arg1).stack; + var ptr0 = passStringToWasm0(ret, wasmInstance.exports.__wbindgen_malloc, wasmInstance.exports.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + Error.stackTraceLimit = limit; + }, + __wbg_error: function(arg0, arg1) { + try { + rawImports.console.log(getStringFromWasm0(arg0, arg1)); + } finally { + wasmInstance.exports.__wbindgen_free(arg0, arg1); + } + }, __wbg_resolve: function (arg0) { var ret = Promise.resolve(getObject(arg0)); return addHeapObject(ret);