ethereum-emissions-calculator
Advanced tools
Comparing version 3.0.3 to 3.0.4
@@ -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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44031
1285