Skip to content

Commit

Permalink
chore(bridge): comply w/ eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed May 18, 2021
1 parent 0f90d90 commit 8c2cbdc
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
28 changes: 14 additions & 14 deletions utils/generateDeployTx.js
Original file line number Diff line number Diff line change
@@ -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;
}
rawTx: "0x" + tx.serialize().toString("hex"),
sender: ethUtils.toChecksumAddress("0x" + tx.getSenderAddress().toString("hex")),
}
return res
}
6 changes: 3 additions & 3 deletions utils/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
generateDeployTx: require('./generateDeployTx'),
traceEvents: require('./traceEvents.js'),
}
generateDeployTx: require("./generateDeployTx"),
traceEvents: require("./traceEvents.js"),
}
4 changes: 2 additions & 2 deletions utils/rawTransaction.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -8,4 +8,4 @@ module.exports = function(json, r, s, gasprice, gaslimit) {
r: r,
s: s,
}
}
}
6 changes: 3 additions & 3 deletions utils/shortenAddr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = function(addr) {
return addr.substring(0, 6) + ".." + addr.slice(-4);
}
module.exports = function (addr) {
return addr.substring(0, 6) + ".." + addr.slice(-4)
}
22 changes: 15 additions & 7 deletions utils/traceEvents.js
Original file line number Diff line number Diff line change
@@ -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})`)
}
}
}

0 comments on commit 8c2cbdc

Please sign in to comment.