Skip to content

Commit

Permalink
progress with total emissions calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
SimasG committed Jan 8, 2023
1 parent fa3b088 commit 6d8be55
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dist/getTransactions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/getTransactions.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,14 @@ console.log("obj:", obj);
// console.log(jsonObject["Date(UTC)"]);
// console.log(jsonObject[i][objkey]);
}

tx.timeStamp: 1640520321 -> '1640476800'
tx.timeStamp: 1640867555 -> '1640822400'
tx.timeStamp: 1640867650 -> '1640822400'
tx.timeStamp: 1641282784 -> '1641254400'
tx.timeStamp: 1641282964 -> '1641254400'
tx.timeStamp: 1641283056 -> '1641254400'
tx.timeStamp: 1655280173 -> '1655251200'
tx.timeStamp: 1655281487 -> '1655251200'
tx.timeStamp: 1655282242 -> '1655251200'
tx.timeStamp: 1666426847 -> post-merge
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"run-index": "tsc && node ./dist/index",
"generateData": "tsc && node ./dist/scripts/generateData",
"run-tx": "tsc && node ./dist/getTransactions",
"generateEmissionsFactorTable": "tsc && node ./dist/scripts/generateEmissionsFactorTable"
"generateEmissionsFactorTable": "tsc && node ./dist/scripts/generateEmissionsFactorTable",
"calculateEmissions": "tsc && node ./dist/calculateEmissions"
}
}
4 changes: 2 additions & 2 deletions src/getTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import "dotenv/config";
/*
Fetching array of historical transactions of a given address
**/
export const getTransactions = async () => {
export const getTransactions = async (addr: string) => {
const response = await fetch(
`https://api.etherscan.io/api?module=account&action=txlist&address=0x619353127678b95C023530df08BCB638870cFDdA&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=${process.env.IAQEQUWUR1GGPD1RAFIDPUDNVDNCWUMPBI}`
`https://api.etherscan.io/api?module=account&action=txlist&address=${addr}&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=${process.env.IAQEQUWUR1GGPD1RAFIDPUDNVDNCWUMPBI}`
);
const data = await response.json();
return data;
Expand Down
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
import { calculateEmissionsFactor } from "./calculateEmissionsFactor.js";
import { getTransactions } from "./getTransactions.js";

// const txHistory = await getTransactions();
// console.log(txHistory.result[0]);

calculateEmissionsFactor(98031701993, 1126674.2703);
29 changes: 29 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,32 @@ export type emissionsFactorItem = {
UnixTimeStamp: string;
emissionsFactor: string;
};

export type tx = {
status: string;
message: string;
result: txResult[];
};

export type txResult = {
blockNumber: string;
timeStamp: string;
hash: string;
nonce: string;
blockHash: string;
transactionIndex: string;
from: string;
to: string;
value: string;
gas: string;
gasPrice: string;
isError: string;
txreceipt_status: string;
input: string;
contractAddress: string;
cumulativeGasUsed: string;
gasUsed: string;
confirmations: string;
methodId: string;
functionName: string;
};

0 comments on commit 6d8be55

Please sign in to comment.