Files: 7465ee54b512e6772d88465794c551333e42ecfe / precompiles / precompile.js
864 bytesRaw
1 | // const evm2wasm = require('evm2wasm') |
2 | // const metering = require('wasm-metering') |
3 | |
4 | function craftResponse (status, msg) { |
5 | // NOTE: why does this has to be so hard? |
6 | return Uint8Array.from(Buffer.concat([ new Buffer([ status ]), new Buffer(msg) ])) |
7 | } |
8 | |
9 | module.exports.meteringInjector = function (call) { |
10 | console.log('Executing metering injector') |
11 | return { |
12 | // returnValue: metering.injectWAST(call.data, 2).slice(0) |
13 | returnValue: craftResponse(0, call.data) |
14 | } |
15 | } |
16 | |
17 | module.exports.transcompiler = function (call) { |
18 | console.log('Executing transcompiler') |
19 | return { |
20 | // returnValue: evm2wasm.compileEVM(call.data).slice(0) |
21 | returnValue: craftResponse(1, 'Code not supported: ' + Buffer.from(call.data.slice(0, 8)).toString('hex') + '...') |
22 | } |
23 | } |
24 | |
25 | module.exports.identity = function (call) { |
26 | return { |
27 | returnValue: call.data.slice(0) |
28 | } |
29 | } |
30 |
Built with git-ssb-web