forked from sebs/etherscan-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
87 lines (75 loc) · 2.16 KB
/
log.js
File metadata and controls
87 lines (75 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const querystring = require('querystring');
module.exports = function(getRequest, apiKey) {
return {
/**
* The Event Log API was designed to provide an alternative to the native eth_getLogs.
*/
/**
* returns the status of a specific transaction hash
* @param {string} fromBlock - fromBlock
* @param {string} toBlock - toBlock
* @param {string} topic0 - topic (32 Bytes per topic)
* @param {string} topic0_1_opr - and|or between topic0 & topic1
* @param {string} topic1 - topic (32 Bytes per topic)
* @param {string} topic1_2_opr - and|or between topic1 & topic2
* @param {string} topic2 - topic (32 Bytes per topic)
* @param {string} topic2_3_opr - and|or between topic2 & topic3
* @param {string} topic3 - topic (32 Bytes per topic)
* @param {string} topic0_2_opr - and|or between topic0 & topic2
* @example https://etherscan.io/apis#logs
* @returns {Promise.<object>}
*/
getLogs(address,
fromBlock,
toBlock,
topic0,
topic0_1_opr,
topic1,
topic1_2_opr,
topic2,
topic2_3_opr,
topic3,
topic0_2_opr) {
const module = 'logs';
const action = 'getLogs';
var params = {
module, action, apiKey, address
};
if (address) {
params.address = address;
}
if (fromBlock) {
params.fromBlock = fromBlock;
}
if (toBlock) {
params.toBlock = toBlock;
}
if (topic0) {
params.topic0 = topic0;
}
if (topic0_1_opr) {
params.topic0_1_opr = topic0_1_opr;
}
if (topic1) {
params.topic1 = topic1;
}
if (topic1_2_opr) {
params.topic1_2_opr = topic1_2_opr;
}
if (topic2) {
params.topic2 = topic2;
}
if (topic2_3_opr) {
params.topic2_3_opr = topic2_3_opr;
}
if (topic0_2_opr) {
params.topic0_2_opr = topic0_2_opr;
}
if (topic3) {
params.topic3 = topic3;
}
var query = querystring.stringify(params);
return getRequest(query);
}
};
};