From c51a2db803c71a9c39dcbbde4c4e45615685a8bc Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@nic.ar> Date: Wed, 9 Oct 2019 02:42:58 -0300 Subject: [PATCH] Algunos bugs --- bin/libbfa.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/bin/libbfa.js b/bin/libbfa.js index 30e559e..c8a2903 100644 --- a/bin/libbfa.js +++ b/bin/libbfa.js @@ -97,25 +97,23 @@ module.exports = class Libbfa var w3 = new this.Web3( this.provider ); var req_url = this.req_url; var _bfa = this; + // This could just remain the same number all the time. + var unneededcounter = 1; w3.jsonify = function( opname, params ) { - var extra = params.join(','); - return JSON.parse( - '{'+ - '"jsonrpc":"2.0",' + - '"id":1,' + - '"method":"' + opname + '",' + - '"params":[' + extra + ']' + - '}' - ); + var obj = {}; + obj.id = unneededcounter++; + obj.jsonrpc = "2.0"; + obj.method = opname; + obj.params = params; + return obj; }; w3.rpcreq = function( opname, params, callback ) { - var body = w3.jsonify( opname, params ); request.post({ uri: req_url, json: true, - body: body, + body: w3.jsonify( opname, params ), callback: function RPCresponse( err, obj ) { var r; @@ -154,7 +152,7 @@ module.exports = class Libbfa // in a TCP stream . // Writes out data and closes our end of the connection. // Geth will reply and then close it's end. - s.end( w3.jsonify(opname,params) ); + socket.end( w3.jsonify(opname,params).valueOf() ); }); socket.on("data", (d) => { try { -- GitLab