@@ -52,7 +52,6 @@ for (const topics of [ topics_for_all]) {
52
52
53
53
// console.log(log_option);)
54
54
let tokenMap = { } ;
55
- let saved_token_address = [ ] ;
56
55
57
56
const log_subscription = web3 . eth . subscribe ( 'logs' , log_option , ( err , res ) => {
58
57
if ( err ) console . error ( err ) ;
@@ -69,13 +68,11 @@ for (const topics of [ topics_for_all]) {
69
68
}
70
69
71
70
// console.log(decodedLog);
72
- // const alert_msg = handle_msg(log, decodedLog);
73
- // alert_tg(alert_msg);
74
71
72
+
73
+ const token_address = log . address ;
75
74
try {
76
- const token_address = log . address ;
77
- if ( ! ( log . address in tokenMap ) ) {
78
- saved_token_address . push ( log . address ) ;
75
+ if ( ! ( token_address in tokenMap ) ) {
79
76
const token_contract = new web3 . eth . Contract ( erc20abi , token_address ) ;
80
77
tokenMap [ token_address ] = {
81
78
'decimals' : await token_contract . methods . decimals ( ) . call ( ) ,
@@ -84,23 +81,29 @@ for (const topics of [ topics_for_all]) {
84
81
}
85
82
} catch ( err ) { logDebug ( 'This is not an ERC20 transactions' ) ; }
86
83
87
- for ( const address in checksum_whaleAddress ) {
88
- const check_arr = [ decodedLog [ 'from' ] , decodedLog [ 'to' ] ]
89
- if ( check_arr . includes ( address ) ) {
90
- console . log ( decodedLog )
84
+ const tokenInfo = tokenMap [ token_address ] ;
85
+ const alert_msg = handle_msg ( log , decodedLog , tokenInfo ) ;
86
+ alert_tg ( alert_msg ) ;
87
+ console . log ( alert_msg )
88
+
89
+
90
+ // for (const address in checksum_whaleAddress){
91
+ // const check_arr = [decodedLog['from'], decodedLog['to']]
92
+ // if (check_arr.includes(address)) {
93
+ // console.log(decodedLog)
91
94
92
- // TODO list
95
+ // // TODO list
93
96
94
- // get the value decimals (ERC-20)
95
- // map back the address to whale name
96
- // format the telegram message (remove space between lines, add etherscan link, )
97
+ // // get the value decimals (ERC-20) (done )
98
+ // // map back the address to whale name
99
+ // // format the telegram message (remove space between lines, add etherscan link, )
97
100
98
- // push the telegram message into a list
99
- // remove the message when alert message is sent, sleep 0.5s to protect tg api
100
- // run a thread to check if there is item in list or not
101
+ // // push the telegram message into a list
102
+ // // remove the message when alert message is sent, sleep 0.5s to protect tg api
103
+ // // run a thread to check if there is item in list or not
101
104
102
- }
103
- }
105
+ // }
106
+ // }
104
107
105
108
} catch ( err ) { console . log ( err ) }
106
109
} )
0 commit comments