git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: fb80c5e51c634a7cd505d71b34160b19f451cd16

Files: fb80c5e51c634a7cd505d71b34160b19f451cd16 / precompiles / precompile.js

864 bytesRaw
1// const evm2wasm = require('evm2wasm')
2// const metering = require('wasm-metering')
3
4function 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
9module.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
17module.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
25module.exports.identity = function (call) {
26 return {
27 returnValue: call.data.slice(0)
28 }
29}
30

Built with git-ssb-web