Socket
Socket
Sign inDemoInstall

ethereum-emissions-calculator

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-emissions-calculator - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

13

lib/utils/getTransactionEmissions.js

@@ -10,10 +10,13 @@ "use strict";

const getTransactionEmissions = (txns, emissionsFactorTable) => {
let datePointer = 0;
// start at the newest emissions factor (last entry)
let datePointer = emissionsFactorTable.length - 1;
return txns.reduce((prev, tx) => {
// if the timestamp is older, try the next entry
while (parseInt(tx.timeStamp) > emissionsFactorTable[datePointer].timestamp) {
if (datePointer === emissionsFactorTable.length - 1) {
var _a;
// if the proceeding emissionsFactor.timestamp is still older than the transaction, decrement
while (((_a = emissionsFactorTable[datePointer - 1]) === null || _a === void 0 ? void 0 : _a.timestamp) >=
parseInt(tx.timeStamp)) {
if (datePointer === 0) {
break;
}
datePointer++;
datePointer--;
}

@@ -20,0 +23,0 @@ const txnEmissions = parseInt(tx.gasUsed) *

{
"name": "ethereum-emissions-calculator",
"version": "3.0.3",
"version": "3.0.4",
"description": "TypeScript utils to calculate the CO2 emissions of an Ethereum wallet. Powered by the Etherscan.io API.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

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