From 5062be5d72b01aaaacbe2300338a48b68de2928e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20D=C3=ADaz?= Date: Tue, 18 May 2021 14:22:15 +0200 Subject: [PATCH] chore(bridge): comply w/ eslint rules --- utils/generateDeployTx.js | 28 ++++++++++++++-------------- utils/index.js | 6 +++--- utils/rawTransaction.js | 4 ++-- utils/shortenAddr.js | 6 +++--- utils/traceEvents.js | 22 +++++++++++++++------- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/utils/generateDeployTx.js b/utils/generateDeployTx.js index 4276a9638..929196fe3 100644 --- a/utils/generateDeployTx.js +++ b/utils/generateDeployTx.js @@ -1,23 +1,23 @@ -const ethTx = require('ethereumjs-tx').Transaction -const ethUtils = require('ethereumjs-util') -const rawTransaction = require('./rawTransaction') +const EthTx = require("ethereumjs-tx").Transaction +const ethUtils = require("ethereumjs-util") +const rawTransaction = require("./rawTransaction") module.exports = function (json, r, s, gasprice, gaslimit) { const rawTx = rawTransaction(json, r, s, gasprice, gaslimit) - const tx = new ethTx(rawTx) + const tx = new EthTx(rawTx) const res = { bytecode: rawTx.data, contractAddr: ethUtils.toChecksumAddress( - '0x' + ethUtils.generateAddress( - tx.getSenderAddress(), - ethUtils.toBuffer(0) - ).toString('hex') - ), + "0x" + ethUtils.generateAddress( + tx.getSenderAddress(), + ethUtils.toBuffer(0) + ).toString("hex") + ), gasLimit: rawTx.gasLimit.toString(), gasPrice: rawTx.gasPrice.toString(), - rawTx: '0x' + tx.serialize().toString('hex'), - sender: ethUtils.toChecksumAddress('0x' + tx.getSenderAddress().toString('hex')), - }; - return res; -} \ No newline at end of file + rawTx: "0x" + tx.serialize().toString("hex"), + sender: ethUtils.toChecksumAddress("0x" + tx.getSenderAddress().toString("hex")), + } + return res +} diff --git a/utils/index.js b/utils/index.js index e203777f2..cda548b68 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,4 +1,4 @@ module.exports = { - generateDeployTx: require('./generateDeployTx'), - traceEvents: require('./traceEvents.js'), -} \ No newline at end of file + generateDeployTx: require("./generateDeployTx"), + traceEvents: require("./traceEvents.js"), +} diff --git a/utils/rawTransaction.js b/utils/rawTransaction.js index 7f5f5b436..35b3acc2e 100644 --- a/utils/rawTransaction.js +++ b/utils/rawTransaction.js @@ -1,4 +1,4 @@ -module.exports = function(json, r, s, gasprice, gaslimit) { +module.exports = function (json, r, s, gasprice, gaslimit) { return { gasPrice: gasprice, value: 0, @@ -8,4 +8,4 @@ module.exports = function(json, r, s, gasprice, gaslimit) { r: r, s: s, } -} \ No newline at end of file +} diff --git a/utils/shortenAddr.js b/utils/shortenAddr.js index 2b3f7d83c..622a674b0 100644 --- a/utils/shortenAddr.js +++ b/utils/shortenAddr.js @@ -1,3 +1,3 @@ -module.exports = function(addr) { - return addr.substring(0, 6) + ".." + addr.slice(-4); -} \ No newline at end of file +module.exports = function (addr) { + return addr.substring(0, 6) + ".." + addr.slice(-4) +} diff --git a/utils/traceEvents.js b/utils/traceEvents.js index 29b417118..4e4748263 100644 --- a/utils/traceEvents.js +++ b/utils/traceEvents.js @@ -1,14 +1,22 @@ -const shortenAddr = require('./shortenAddr') +const shortenAddr = require("./shortenAddr") module.exports = async function (logs, web3) { - for (var i = 0; i < logs.length; i++) { - var event = logs[i].event; - var args = logs[i].args; - var params = "" + for (let i = 0; i < logs.length; i++) { + const event = logs[i].event + const args = logs[i].args + let params = "" switch (event) { + case "PostedRequest": + case "PostedResult": + params = `from: ${shortenAddr(args[0])}, id: ${args[1].toString(16)}` + break + default: - continue; + continue } + let tabs = "\t" + if (event.length < 13) tabs = "\t\t" + console.log(" ", `>> ${event}${tabs}(${params})`) } -} \ No newline at end of file +}