Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function wast2wasm(str) {
const module = wabt.parseWat("hack.wat", str);
const { buffer } = module.toBinary({});
return buffer.buffer;
}
function wastToWasm(content) {
const module = wabt.parseWat("module.wast", content);
module.resolveNames();
module.validate();
const { buffer } = module.toBinary({ write_debug_names: true });
return buffer.buffer;
}
exports.evm2wasm = function (evmCode, opts = {
'stackTrace': false,
'useAsyncAPI': false,
'inlineOps': true,
'testName': 'temp',
'chargePerOp': false
}) {
const wast = exports.evm2wast(evmCode, opts)
const mod = wabt.parseWat('arbitraryModuleName', wast)
mod.resolveNames()
mod.validate()
const bin = mod.toBinary({log: false, write_debug_names: false}).buffer
mod.destroy()
return Promise.resolve(bin)
}