huginn_callisto_network_agent 0.1.76 → 0.1.78

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 978696531634721dd99da0a9200ac467dab56affe953ab733388a007ddf98677
4
- data.tar.gz: be4148d9bd03535cf47b51e4277509515053a06260fb35ecfe73435740207935
3
+ metadata.gz: 62cd018bc6a5c861d87fdc1406a16373272495617c165e53c5ac9d7a3c94a3cb
4
+ data.tar.gz: d968669b2e7c2cbca3c02bf08843fc150dac47d1cf32e5d96465041b3d21855e
5
5
  SHA512:
6
- metadata.gz: e7ed37406065d75edb82432406bcc2162b5a8ce289a0ad2b7f9c78814a731265cacef5753332332c24ed8c01537f8aaf93d702a00f69475eea7ee624696568cd
7
- data.tar.gz: fff1c67747226fe34c3a762396d399c33f5a9b94996fafa16c806bd3a68c746670ac4b3f625cf50fec7aadc82afdb3659df0600d67ab0e2cf6d01d53afc763c1
6
+ metadata.gz: 67c88c8663c2908df10e805f8e3071e2223591ce8efe631b446d8cff7bccd89e366f4c610f30283e0250cbc719fe7c772a831d1ecadcb83b237b0ea8c07826af
7
+ data.tar.gz: 8a1195b638719d8c3bc5d859e72b8e3f4d1d3611d1948f42b589f4680dcbc3aa14699bdfb996544695d8a5b9f618c5226182814acbb068f275998f4e35c63660
@@ -53,7 +53,8 @@ module Agents
53
53
  'changes_only' => 'true',
54
54
  'filter_for_method_id' => '',
55
55
  'first_block' => '',
56
- 'last_block' => ''
56
+ 'last_block' => '',
57
+ 'sql_db' => ''
57
58
  }
58
59
  end
59
60
 
@@ -61,7 +62,7 @@ module Agents
61
62
  form_configurable :emit_events, type: :boolean
62
63
  form_configurable :expected_receive_period_in_days, type: :string
63
64
  form_configurable :changes_only, type: :boolean
64
- form_configurable :type, type: :array, values: ['get_balance', 'net_peerCount', 'net_version', 'eth_protocolVersion', 'eth_gasPrice', 'eth_getTransactionCount', 'stake_reward_clo', 'get_tokens_balance', 'eth_getBlockByNumber', 'soy_farming_soy_clo_pending_rewards', 'soy_farming_soy_cloe_pending_rewards', 'stake_reward_soy', 'soy_farming_soy_btt_pending_rewards', 'soy_cs_pending_rewards', 'clo_sendtx', 'get_tx_by_address_with_filter', 'start_cs_clo', 'withdraw_cs_clo', 'get_tx_stats', 'callosha_slots', '2bears_check_order_by_id']
65
+ form_configurable :type, type: :array, values: ['get_balance', 'net_peerCount', 'net_version', 'eth_protocolVersion', 'eth_gasPrice', 'eth_getTransactionCount', 'stake_reward_clo', 'get_tokens_balance', 'eth_getBlockByNumber', 'soy_farming_soy_clo_pending_rewards', 'soy_farming_soy_cloe_pending_rewards', 'stake_reward_soy', 'soy_farming_soy_btt_pending_rewards', 'soy_cs_pending_rewards', 'clo_sendtx', 'get_tx_by_address_with_filter', 'start_cs_clo', 'withdraw_cs_clo', 'get_tx_stats', 'callosha_slots', '2bears_check_order_by_id', 'get_abi_json']
65
66
  form_configurable :wallet, type: :string
66
67
  form_configurable :rpc_server, type: :string
67
68
  form_configurable :wallet_password, type: :string
@@ -71,8 +72,9 @@ module Agents
71
72
  form_configurable :filter_for_method_id, type: :string
72
73
  form_configurable :first_block, type: :string
73
74
  form_configurable :last_block, type: :string
75
+ form_configurable :sql_db, type: :string
74
76
  def validate_options
75
- errors.add(:base, "type has invalid value: should be 'get_balance' 'net_peerCount' 'net_version' 'eth_protocolVersion' 'eth_gasPrice' 'eth_getTransactionCount' 'stake_reward_clo' 'get_tokens_balance' 'eth_getBlockByNumber' 'soy_farming_soy_clo_pending_rewards' 'soy_farming_soy_cloe_pending_rewards' 'stake_reward_soy' 'soy_farming_soy_btt_pending_rewards' 'soy_cs_pending_rewards' 'clo_sendtx' 'get_tx_by_address_with_filter' 'start_cs_clo' 'withdraw_cs_clo' 'get_tx_stats' 'callosha_slots' '2bears_check_order_by_id'") if interpolated['type'].present? && !%w(get_balance net_peerCount net_version eth_protocolVersion eth_gasPrice eth_getTransactionCount stake_reward_clo get_tokens_balance eth_getBlockByNumber soy_farming_soy_clo_pending_rewards soy_farming_soy_cloe_pending_rewards stake_reward_soy soy_farming_soy_btt_pending_rewards soy_cs_pending_rewards clo_sendtx get_tx_by_address_with_filter start_cs_clo withdraw_cs_clo get_tx_stats callosha_slots 2bears_check_order_by_id).include?(interpolated['type'])
77
+ errors.add(:base, "type has invalid value: should be 'get_balance' 'net_peerCount' 'net_version' 'eth_protocolVersion' 'eth_gasPrice' 'eth_getTransactionCount' 'stake_reward_clo' 'get_tokens_balance' 'eth_getBlockByNumber' 'soy_farming_soy_clo_pending_rewards' 'soy_farming_soy_cloe_pending_rewards' 'stake_reward_soy' 'soy_farming_soy_btt_pending_rewards' 'soy_cs_pending_rewards' 'clo_sendtx' 'get_tx_by_address_with_filter' 'start_cs_clo' 'withdraw_cs_clo' 'get_tx_stats' 'callosha_slots' '2bears_check_order_by_id' 'get_abi_json'") if interpolated['type'].present? && !%w(get_balance net_peerCount net_version eth_protocolVersion eth_gasPrice eth_getTransactionCount stake_reward_clo get_tokens_balance eth_getBlockByNumber soy_farming_soy_clo_pending_rewards soy_farming_soy_cloe_pending_rewards stake_reward_soy soy_farming_soy_btt_pending_rewards soy_cs_pending_rewards clo_sendtx get_tx_by_address_with_filter start_cs_clo withdraw_cs_clo get_tx_stats callosha_slots 2bears_check_order_by_id get_abi_json).include?(interpolated['type'])
76
78
 
77
79
  unless options['wallet_password'].present? || !['clo_sendtx' 'start_cs_clo' 'withdraw_cs_clo'].include?(options['type'])
78
80
  errors.add(:base, "wallet_password is a required field")
@@ -94,7 +96,7 @@ module Agents
94
96
  errors.add(:base, "rpc_server is a required field")
95
97
  end
96
98
 
97
- unless options['wallet'].present? || !['get_balance' 'eth_getTransactionCount' 'stake_reward_clo' 'get_tokens_balance' 'eth_getBlockByNumber' 'soy_farming_soy_clo_pending_rewards' 'soy_farming_soy_cloe_pending_rewards' 'stake_reward_soy' 'soy_farming_soy_btt_pending_rewards' 'soy_cs_pending_rewards' 'clo_sendtx' 'get_tx_by_address_with_filter' 'start_cs_clo' 'callosha_slots'].include?(options['type'])
99
+ unless options['wallet'].present? || !['get_balance' 'eth_getTransactionCount' 'stake_reward_clo' 'get_tokens_balance' 'eth_getBlockByNumber' 'soy_farming_soy_clo_pending_rewards' 'soy_farming_soy_cloe_pending_rewards' 'stake_reward_soy' 'soy_farming_soy_btt_pending_rewards' 'soy_cs_pending_rewards' 'clo_sendtx' 'get_tx_by_address_with_filter' 'start_cs_clo' 'callosha_slots' 'get_abi_json'].include?(options['type'])
98
100
  errors.add(:base, "wallet is a required field")
99
101
  end
100
102
 
@@ -191,6 +193,52 @@ module Agents
191
193
  return found_symbol
192
194
  end
193
195
 
196
+ def function_finder(contract_address=interpolated['wallet'],bytes_signature)
197
+
198
+ db = SQLite3::Database.new(interpolated['sql_db'])
199
+ result = db.get_first_row('SELECT text_signature FROM signatures WHERE bytes_signature = ? AND contract_address = ?', bytes_signature, contract_address)
200
+ db.close
201
+
202
+ if result
203
+ return result[0].split('(').first
204
+ else
205
+ db = SQLite3::Database.new(interpolated['sql_db'])
206
+ result = db.get_first_row('SELECT text_signature FROM signatures WHERE bytes_signature = ?', bytes_signature)
207
+ db.close
208
+ if result
209
+ return result[0].split('(').first
210
+ else
211
+ return 'unknown'
212
+ end
213
+ end
214
+ end
215
+
216
+ def get_abi_json(contract_address,internal=false)
217
+
218
+ uri = URI.parse("https://explorer.callisto.network/api?module=contract&action=getabi&address=#{contract_address}")
219
+ request = Net::HTTP::Get.new(uri)
220
+ request["Accept"] = "application/json"
221
+
222
+ req_options = {
223
+ use_ssl: uri.scheme == "https",
224
+ }
225
+
226
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
227
+ http.request(request)
228
+ end
229
+
230
+ log_curl_output(response.code,response.body)
231
+
232
+ payload = JSON.parse(response.body)
233
+
234
+ if internal == false
235
+ create_event payload: payload
236
+ else
237
+ return payload
238
+ end
239
+
240
+ end
241
+
194
242
  def get_tx_receipt(hash)
195
243
 
196
244
  uri = URI.parse("#{interpolated['rpc_server']}")
@@ -378,6 +426,9 @@ module Agents
378
426
  def get_tx_stats()
379
427
  all_miners = ['0xf34eaf6e2cf4744b5e29734295135c4213d59149', '0xed15b7b7b5dc81daae277a081b47a04c3a8bea1b' ,'0xd125b3b146d21d058edac7a5b5f7481a571e4c46', '0xe683de43ccfbef16424ecb577f288cf343dfbc5a', '0x0073cf1b9230cf3ee8cab1971b8dbef21ea7b595', '0x40b67778d97a7d15a519d907ed991948e8ea486c', '0x8845ee5cae61b807678415bb8a68773df9d48f8e', '0x52f0458c70af5cdeb555cad800add5f82c3e59f7', '0xd06bb917c099acf24d43552b5aa760aeef7cd4aa', '0xf35074bbd0a9aee46f4ea137971feec024ab704e', '0xd144e30a0571aaf0d0c050070ac435deba461fab', '0x8057c50c6d72f4399862fefbc8d3b8a8757cde57', '0xfbf679d6ed0cb9747e05e7e8ae06e890e6bf2b66', '0x11905bd0863ba579023f662d1935e39d0c671933', '0xe4f3cab1f11d5a917ac73c80927e64ee4b1a445a', '0xae83a3e136e6714e6c1e5483950936d7872fb999', '0x39ec1c88a7a7c1a575e8c8f42eff7630d9278179', '0xd6d27255eaef8c3fcb5433acb5494bf04cb5f2c3', '0x004730417cd2b1d19f6be2679906ded4fa8a64e2', '0x89308111f17a395b82f1e5a2824bd01fd13a53b5', '0x800f25eb68a06ff9671605bd450c29e80f593e0a', '0xa5d9018f6c99ec3230633c1187c5cb607c704ed8', '0xfe59743b65f2afec200ce279a289cb4a43eb7eeb', '0x811bad1a4041a9f6ed8fc2f4e9d421dc82626f81', '0xbd12b4511ec9fd1cf481d5643f307252ae6f55e2', '0x5f7661e493d4f1a318c02e9383568597e8a09b5a', '0xe0bac765ca88706a12e4f5a9c0e92dc823fe6293', '0x40c48b386e15981df5a10552cb97ee6d232c8547', '0x458ddc6a7e924554756f95715a53bf948560ee38', '0x3c6b9edb1f8ec6c85436b7cb384eb607489c732f', '0x2a1efdf9f09869a82e5e6b0f3736aabcb5381206', '0xf30a30315d5214e490458d0511595e42b3d917d0', '0x8c2fdc530815eb4267c8b12f10adafc4ca73484a', '0x254b0e1dee486908345e608da64afe35caa02a1c']
380
428
  shitty_wallets = ['0x7971d8defa89bf68ff4142b2bb1e1e3866927b36', '0x33344541086c709fe585caeabc83e5947e783333', '0xcbb8aaf930497c7bd0de6b19903410698e8adab4', '0xc352d245f25fec51ff15c77fc5bf767bf655276a', '0x9daa24510951bc0ac5d1e4f89de5efd89cc8e0b0', '0x941dab361e6d3f0b310f78c2c9eb6779608de0c3', '0x8877e6657f48aee236b47eb1c65be8e7a44f11f8', '0x1a146e329333919542cdb6d2d87de370275124c6', '0xf7d862d42976662d649cc356f4ca3854d595d53d', '0xd125b9d1415b77e0951d5b91dce3ce5d9e4375d0', '0xb94f03ad1b8ddddb82b08cd038b652cbfc47fbb4', '0x8832abcd7248ed2bd740d3eafdeb774ab8332623', '0x6dfb81b6945967e57052e4132a9ca328f8d12f7c', '0x11817fa65a9c2f68fc03bbbc9f2113d59b96908b']
429
+ callosha_address = '0xb89fd29c048e974f9c3bc320c0b68651b434c159'
430
+ twobears_address = '0x78afc46df1d3eb5cff7044d288a453fe43e17310'
431
+ vipwarz_address = '0x2f48b8887d2d5d5b718c9f6516b44ba1c1bb8db1'
381
432
  internal = true
382
433
  tx_list = []
383
434
  burnt_ether = 0
@@ -398,11 +449,14 @@ module Agents
398
449
  miners_count = tx_list.select { |hash| all_miners.include?(hash['from']) }
399
450
  # log "miners_count #{miners_count.count}"
400
451
  shitty_count = tx_list.select { |hash| shitty_wallets.include?(hash['from']) }
452
+ callosha_count = tx_list.select { |hash| hash['to'] == callosha_address }
453
+ twobears_count = tx_list.select { |hash| hash['to'] == twobears_address }
454
+ vipwarz_count = tx_list.select { |hash| hash['to'] == vipwarz_address }
401
455
  # log "shitty_count #{shitty_count.count}"
402
456
  active = tx_list.map { |p| p['from'] }.uniq.count
403
457
  # log "top_count : #{top_count}"
404
458
  # log "total : #{tx_list.count}"
405
- create_event :payload => { 'total_tx' => "#{tx_list.count}", 'total_active' => "#{active}", 'burnt_clo' => "#{burnt_ether}", 'top_wallet': {'address' => "#{top_tx}", 'percentage' => "#{percentage(top_count.to_i,tx_list.count.to_i)}"}, 'shitty': {'address': 'shitty', 'shitty_percentage' => "#{percentage(shitty_count.count,tx_list.count.to_i)}"}, 'miners': {'address': "miners", 'percentage' => "#{percentage(miners_count.count,tx_list.count.to_i)}"}}
459
+ create_event :payload => { 'total_tx' => "#{tx_list.count}", 'total_active' => "#{active}", 'burnt_clo' => "#{burnt_ether}", 'top_wallet': {'address' => "#{top_tx}", 'percentage' => "#{percentage(top_count.to_i,tx_list.count.to_i)}"}, 'shitty': {'address': 'shitty', 'shitty_percentage' => "#{percentage(shitty_count.count,tx_list.count.to_i)}"}, 'miners': {'address': "miners", 'percentage' => "#{percentage(miners_count.count,tx_list.count.to_i)}"}, 'callosha': {'address': callosha_address, 'percentage' => "#{percentage(callosha_count.count,tx_list.count.to_i)}"}, 'twobears': {'address': twobears_address, 'percentage' => "#{percentage(twobears_count.count,tx_list.count.to_i)}"}, 'vipwarz': {'address': vipwarz_address, 'percentage' => "#{percentage(vipwarz_count.count,tx_list.count.to_i)}"}}
406
460
 
407
461
  end
408
462
 
@@ -450,96 +504,18 @@ module Agents
450
504
  transaction['symbol'] = "CLO"
451
505
  transaction['value'] = "#{transaction['value'].to_i(16) / power.to_i.to_f}"
452
506
  when "0xb88a802f"
453
- transaction['call_type'] = 'claimReward'
454
507
  transaction['symbol'] = find_symbol(transaction['to'])
455
- when "0xe80233c6"
456
- transaction['call_type'] = 'activateNode'
457
- when "0xc180f4f1"
458
- transaction['call_type'] = 'addClassProperty'
459
- when "0xe8e33700"
460
- transaction['call_type'] = 'addLiquidity'
461
- when "0x25498c75"
462
- transaction['call_type'] = 'addNewTokenClass'
463
- when "0xb199892a"
464
- transaction['call_type'] = 'addNode'
465
- when "0x01026099"
466
- transaction['call_type'] = 'addTokens'
467
- when "0x095ea7b3"
468
- transaction['call_type'] = 'approve'
469
- when "0x514fcac7"
470
- transaction['call_type'] = 'cancelOrder'
471
- when "0x8f995234", "0x4e71d92d"
472
- transaction['call_type'] = 'claim'
473
- when "0xa0169f0d"
474
- transaction['call_type'] = 'createDumperShield'
475
- when "0x96d4f640"
476
- transaction['call_type'] = 'createOrder'
477
- when "0x65814455"
478
- transaction['call_type'] = 'deactivateNode'
479
- when "0xbd000546"
480
- transaction['call_type'] = 'DeleteOrder'
481
- when "0x1da7ee0d"
482
- transaction['call_type'] = 'depositPosition'
483
- when "0x487cda0d"
484
- transaction['call_type'] = 'depositTokens'
485
- when "0x83f818b4"
486
- transaction['call_type'] = 'game'
487
- when "0xc4d66de8", "0x1624f6c6"
488
- transaction['call_type'] = 'initialize'
489
- when "0xbf3c35c3"
490
- transaction['call_type'] = 'migrateCLOE'
491
- when "0x2da91f95"
492
- transaction['call_type'] = 'migrationWithdraw'
493
- when "0x40c10f19"
494
- transaction['call_type'] = 'mint'
495
- when "0x3054d9cb"
496
- transaction['call_type'] = 'modifyClassProperty'
497
- when "0xb2b99ec9"
498
- transaction['call_type'] = 'removeNode'
499
- when "0x11411e08"
500
- transaction['call_type'] = 'sellToken'
501
- when "0xcf456ae7"
502
- transaction['call_type'] = 'setMinter'
503
- when "0xcdfdb7dc"
504
- transaction['call_type'] = 'setRatios'
505
- when "0xfe3f3f02"
506
- transaction['call_type'] = 'setSalary'
507
- when "0x957138a4"
508
- transaction['call_type'] = 'setStop'
509
- when "0xc98e0c3c"
510
- transaction['call_type'] = 'silentTransfer'
511
- when "0x84daaf54"
512
- transaction['call_type'] = 'stakingMigrate'
513
- when "0x5d8c85ef"
514
- transaction['call_type'] = 'start_staking'
515
- when "0x2e9b3dc3"
516
- transaction['call_type'] = 'swapExactCLOForTokens'
517
- when "0x38ed1739"
518
- transaction['call_type'] = 'swapExactTokensForTokens'
519
- when "0xa6e83852"
520
- transaction['call_type'] = 'swapTokensForExactCLO'
521
- when "0x8803dbee"
522
- transaction['call_type'] = 'swapTokensForExactTokens'
508
+ when "0x6bd7a97a"
509
+ transaction['vesting_receiver'] = "0x#{transaction['input'][34, 40]}"
510
+ transaction['vesting_amount'] = "#{transaction['input'][74, 64].to_i(16) / power.to_i.to_f}"
511
+ transaction['vesting_symbol'] = "DIFF"
523
512
  when "0xa9059cbb"
524
- transaction['call_type'] = 'TokenTransfer'
525
513
  transaction['symbol'] = find_symbol(transaction['to'])
526
514
  # transaction['to'] = transaction['input'][10, 64]
527
515
  transaction['to'] = "0x#{transaction['input'][34, 40]}"
528
516
  transaction['value'] = "#{transaction['input'][74, 64].to_i(16) / power.to_i.to_f}"
529
- when "0x335a9406"
530
- transaction['call_type'] = 'transfer'
531
- when "0xf2fde38b"
532
- transaction['call_type'] = 'transferOwnership'
533
- when "0xa2e62045", "0x82ab890a"
534
- transaction['call_type'] = 'update'
535
- when "0x3659cfe6"
536
- transaction['call_type'] = 'upgradeTo'
537
- when "0xd9caed12"
538
- transaction['call_type'] = 'withdraw'
539
- when "0x78be0ad4", "0xcd948855"
540
- transaction['call_type'] = 'withdraw_stake'
541
- else
542
- transaction['call_type'] = 'unknown'
517
+ # else
518
+ # transaction['call_type'] = 'unknown'
543
519
  end
544
520
  if transaction['input'] != '0x'
545
521
  hex_string = transaction['input'].dup
@@ -554,6 +530,10 @@ module Agents
554
530
  transaction['input_utf8'] = decoded_string
555
531
  end
556
532
  end
533
+ if !interpolated['sql_db'].empty?
534
+ transaction['call_type'] = function_finder(transaction['to'],transaction['input'][0, 10])
535
+ end
536
+ # log "#{transaction['input'][0, 10]} -> #{function_finder(transaction['to'],true,transaction['input'][0, 10])}"
557
537
  create_event payload: transaction
558
538
  end
559
539
  end
@@ -1667,6 +1647,8 @@ module Agents
1667
1647
  callosha_slots()
1668
1648
  when "2bears_check_order_by_id"
1669
1649
  twobears_check_order_by_id()
1650
+ when "get_abi_json"
1651
+ get_abi_json(interpolated['wallet'],false)
1670
1652
  else
1671
1653
  log "Error: type has an invalid value (#{type})"
1672
1654
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huginn_callisto_network_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.76
4
+ version: 0.1.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Germain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler