Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eth-gas-reporter

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-gas-reporter - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

mock/contracts/MultiContractFile.sol

2

CHANGELOG.md
## Changelog: eth-gas-reporter
0.1.3 / 2018-05-14
0.1.4 / 2018-05-14
==================

@@ -4,0 +4,0 @@ * Try to work around web3 websocket provider by attempting connection over http://.

@@ -8,2 +8,3 @@ /**

const path = require('path')
const fs = require('fs')
const request = require('request-promise-native')

@@ -14,3 +15,3 @@ const shell = require('shelljs')

const abiDecoder = require('abi-decoder')
const fs = require('fs');
const parser = require('solidity-parser-antlr');
const sync = require('./sync');

@@ -295,2 +296,21 @@

/**
* Parses files for contract names
* @param {String} filePath path to file
* @return {Array} array of contract names
*/
function getContractNames(filePath){
const names = [];
const code = fs.readFileSync(filePath, 'utf-8');
const ast = parser.parse(code, {tolerant: true});
parser.visit(ast, {
ContractDefinition: function(node) {
names.push(node.name);
}
});
return names;
}
/**
* Generates a complete mapping of method data ids to their contract and method names.

@@ -329,42 +349,47 @@ * Map also initialised w/ an empty `gasData` array that the gas value of each matched transaction

const names = shell.ls('./contracts/**/*.sol')
names.forEach(name => {
name = path.basename(name)
const files = shell.ls('./contracts/**/*.sol')
if (name === 'Migrations.sol') return
// For each file
files.forEach(file => {
names = getContractNames(file);
// Create Deploy Map:
let contract
try { contract = truffleArtifacts.require(name) } catch (error) { return }
// For each contract in file
names.forEach(name => {
if (name === 'Migrations') return
const contractInfo = {
name: name.split('.sol')[0],
binary: contract.unlinked_binary,
gasData: []
}
deployMap.push(contractInfo)
abis.push(contract._json.abi)
// Create Deploy Map:
let contract
try { contract = truffleArtifacts.require(name) } catch (error) { return }
// Decode, getMethodIDs
abiDecoder.addABI(contract._json.abi)
const methodIDs = abiDecoder.getMethodIDs()
const contractInfo = {
name: name,
binary: contract.unlinked_binary,
gasData: []
}
deployMap.push(contractInfo)
abis.push(contract._json.abi)
// Create Method Map;
Object.keys(methodIDs).forEach(key => {
const isInterface = contract.unlinked_binary === '0x';
const isConstant = methodIDs[key].constant
const isEvent = methodIDs[key].type === 'event'
const hasName = methodIDs[key].name
// Decode, getMethodIDs
abiDecoder.addABI(contract._json.abi)
const methodIDs = abiDecoder.getMethodIDs()
if (hasName && !isConstant && !isEvent && !isInterface) {
methodMap[key] = {
contract: name.split('.sol')[0],
method: methodIDs[key].name,
gasData: [],
numberOfCalls: 0
// Create Method Map;
Object.keys(methodIDs).forEach(key => {
const isInterface = contract.unlinked_binary === '0x';
const isConstant = methodIDs[key].constant
const isEvent = methodIDs[key].type === 'event'
const hasName = methodIDs[key].name
if (hasName && !isConstant && !isEvent && !isInterface) {
methodMap[key] = {
contract: name,
method: methodIDs[key].name,
gasData: [],
numberOfCalls: 0
}
}
}
})
abiDecoder.removeABI(contract._json.abi)
})
abiDecoder.removeABI(contract._json.abi)
})
});

@@ -371,0 +396,0 @@ abis.forEach(abi => abiDecoder.addABI(abi))

{
"name": "eth-gas-reporter",
"version": "0.1.3",
"version": "0.1.4",
"description": "Mocha reporter which shows gas used per unit test.",

@@ -37,2 +37,3 @@ "main": "index.js",

"shelljs": "^0.7.8",
"solidity-parser-antlr": "^0.2.10",
"sync-request": "^6.0.0"

@@ -39,0 +40,0 @@ },

{
"name": "eth-gas-reporter",
"version": "0.1.4",
"version": "0.1.5",
"description": "Mocha reporter which shows gas used per unit test.",

@@ -37,2 +37,3 @@ "main": "index.js",

"shelljs": "^0.7.8",
"solidity-parser-antlr": "^0.2.10",
"sync-request": "^6.0.0"

@@ -39,0 +40,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc