huginn_callisto_network_agent 0.1.87 → 0.1.88
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/huginn_callisto_network_agent/callisto_network_agent.rb +174 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41cca2b967f492b886536cc74c9499d89d08fd9129cae25ec3b79b948100d69
|
4
|
+
data.tar.gz: becae15f51f023c3c2fffe5a1904e6502203238a96e5e9bc6063accc574e3916
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30350b639f6d7447cb5791548572caa2a4e5097a8aaa7276a84710a035966afe6d2e3ee8688a0756d0f8c3f6542e2dd63ee1d0ec03a2bbcd4c2029f4ae4ac56b
|
7
|
+
data.tar.gz: 2ad02e09aa547a8e9dd853233b85e395de8798c16a11f7ff9b21110d36d100df52ace0bba5989cc422d4311cc5ddfae9a961962715e3aa6605f28bbd0b4f4680
|
@@ -62,7 +62,7 @@ module Agents
|
|
62
62
|
form_configurable :emit_events, type: :boolean
|
63
63
|
form_configurable :expected_receive_period_in_days, type: :string
|
64
64
|
form_configurable :changes_only, type: :boolean
|
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
|
+
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', 'dao_auto_claim' 'dao_check_missing_vote']
|
66
66
|
form_configurable :wallet, type: :string
|
67
67
|
form_configurable :rpc_server, type: :string
|
68
68
|
form_configurable :wallet_password, type: :string
|
@@ -74,13 +74,13 @@ module Agents
|
|
74
74
|
form_configurable :last_block, type: :string
|
75
75
|
form_configurable :sql_db, type: :string
|
76
76
|
def validate_options
|
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'])
|
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' 'dao_auto_claim' 'dao_check_missing_vote'") 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 dao_auto_claim dao_check_missing_vote).include?(interpolated['type'])
|
78
78
|
|
79
|
-
unless options['wallet_password'].present? || !['clo_sendtx' 'start_cs_clo' 'withdraw_cs_clo'].include?(options['type'])
|
79
|
+
unless options['wallet_password'].present? || !['clo_sendtx' 'start_cs_clo' 'withdraw_cs_clo' 'dao_auto_claim'].include?(options['type'])
|
80
80
|
errors.add(:base, "wallet_password is a required field")
|
81
81
|
end
|
82
82
|
|
83
|
-
unless options['value'].present? || !['clo_sendtx' 'start_cs_clo' 'callosha_slots' '2bears_check_order_by_id'].include?(options['type'])
|
83
|
+
unless options['value'].present? || !['clo_sendtx' 'start_cs_clo' 'callosha_slots' '2bears_check_order_by_id' 'dao_check_missing_vote'].include?(options['type'])
|
84
84
|
errors.add(:base, "value is a required field")
|
85
85
|
end
|
86
86
|
|
@@ -96,7 +96,7 @@ module Agents
|
|
96
96
|
errors.add(:base, "rpc_server is a required field")
|
97
97
|
end
|
98
98
|
|
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'])
|
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' 'dao_auto_claim'].include?(options['type'])
|
100
100
|
errors.add(:base, "wallet is a required field")
|
101
101
|
end
|
102
102
|
|
@@ -255,11 +255,175 @@ module Agents
|
|
255
255
|
if internal == false
|
256
256
|
create_event payload: payload
|
257
257
|
else
|
258
|
-
return payload
|
258
|
+
return payload['result']
|
259
259
|
end
|
260
260
|
|
261
261
|
end
|
262
262
|
|
263
|
+
def dao_get_last_vote_id()
|
264
|
+
uri = URI.parse("#{interpolated['rpc_server']}")
|
265
|
+
request = Net::HTTP::Post.new(uri)
|
266
|
+
request.content_type = "application/json"
|
267
|
+
request.body = JSON.dump({
|
268
|
+
"jsonrpc" => "2.0",
|
269
|
+
"id" => 1,
|
270
|
+
"method" => "eth_call",
|
271
|
+
"params" => [
|
272
|
+
{
|
273
|
+
"data" => "0xbe8e4d19",
|
274
|
+
"to" => "0x810059e1406dedafd1bdca4e0137cba306c0ce36"
|
275
|
+
},
|
276
|
+
"latest"
|
277
|
+
]
|
278
|
+
})
|
279
|
+
|
280
|
+
req_options = {
|
281
|
+
use_ssl: uri.scheme == "https",
|
282
|
+
}
|
283
|
+
|
284
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
285
|
+
http.request(request)
|
286
|
+
end
|
287
|
+
|
288
|
+
log_curl_output(response.code,response.body)
|
289
|
+
|
290
|
+
return JSON.parse(response.body)['result'].to_i(16)
|
291
|
+
end
|
292
|
+
|
293
|
+
def dao_claim(id)
|
294
|
+
function_id = '0x379607f5'
|
295
|
+
formatted_value = id.to_s(16).rjust(64, '0')
|
296
|
+
data = "#{function_id}#{formatted_value}"
|
297
|
+
log data
|
298
|
+
if interpolated['debug'] == 'true'
|
299
|
+
log "unlocking the wallet"
|
300
|
+
end
|
301
|
+
response = JSON.parse(unlock_wallet())
|
302
|
+
log "response -> #{response}"
|
303
|
+
log "response result -> #{response['result']}"
|
304
|
+
if response['result'] == true
|
305
|
+
if interpolated['debug'] == 'true'
|
306
|
+
log "the wallet is unlocked"
|
307
|
+
end
|
308
|
+
uri = URI.parse("#{interpolated['rpc_server']}")
|
309
|
+
request = Net::HTTP::Post.new(uri)
|
310
|
+
request.content_type = "application/json"
|
311
|
+
request.body = JSON.dump({
|
312
|
+
"jsonrpc" => "2.0",
|
313
|
+
"id" => 1,
|
314
|
+
"method" => "eth_sendTransaction",
|
315
|
+
"params" => [
|
316
|
+
{
|
317
|
+
"from" => "#{interpolated['wallet']}",
|
318
|
+
"data" => "0x379607f5#{to_hex(id)}",
|
319
|
+
"to" => "0x810059e1406dedafd1bdca4e0137cba306c0ce36"
|
320
|
+
}
|
321
|
+
]
|
322
|
+
})
|
323
|
+
|
324
|
+
req_options = {
|
325
|
+
use_ssl: uri.scheme == "https",
|
326
|
+
}
|
327
|
+
|
328
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
329
|
+
http.request(request)
|
330
|
+
end
|
331
|
+
|
332
|
+
log_curl_output(response.code,response.body)
|
333
|
+
|
334
|
+
return JSON.parse(response.body)
|
335
|
+
else
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
def dao_get_total_user()
|
340
|
+
uri = URI.parse("#{interpolated['rpc_server']}")
|
341
|
+
request = Net::HTTP::Post.new(uri)
|
342
|
+
request.content_type = "application/json"
|
343
|
+
request.body = JSON.dump({
|
344
|
+
"jsonrpc" => "2.0",
|
345
|
+
"id" => 1,
|
346
|
+
"method" => "eth_call",
|
347
|
+
"params" => [
|
348
|
+
{
|
349
|
+
"data" => "0x40912990",
|
350
|
+
"to" => "0x810059e1406dedafd1bdca4e0137cba306c0ce36"
|
351
|
+
},
|
352
|
+
"latest"
|
353
|
+
]
|
354
|
+
})
|
355
|
+
|
356
|
+
req_options = {
|
357
|
+
use_ssl: uri.scheme == "https",
|
358
|
+
}
|
359
|
+
|
360
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
361
|
+
http.request(request)
|
362
|
+
end
|
363
|
+
|
364
|
+
log_curl_output(response.code,response.body)
|
365
|
+
|
366
|
+
return JSON.parse(response.body)['result'].to_i(16)
|
367
|
+
end
|
368
|
+
|
369
|
+
def dao_get_users_list(count)
|
370
|
+
uri = URI.parse("http://web3wrapper:5000/dao/getuserslist?&start=1&limit=#{count}")
|
371
|
+
response = Net::HTTP.get_response(uri)
|
372
|
+
|
373
|
+
log_curl_output(response.code,response.body)
|
374
|
+
|
375
|
+
return JSON.parse(response.body)
|
376
|
+
end
|
377
|
+
|
378
|
+
def dao_check_missing_vote()
|
379
|
+
users_list = dao_get_users_list(dao_get_total_user)
|
380
|
+
proposal = dao_check_proposal(interpolated['value'])
|
381
|
+
user_addresses = users_list.map { |user| user['userAddr'] }
|
382
|
+
missing_votes = user_addresses - (proposal['voces_yes'] + proposal['voces_no'])
|
383
|
+
proposal['missing_voces'] = missing_votes
|
384
|
+
create_event payload: proposal
|
385
|
+
end
|
386
|
+
|
387
|
+
def dao_check_claim_list(last_id)
|
388
|
+
uri = URI.parse("http://web3wrapper:5000/dao/getclaimlist?address=#{interpolated['wallet']}&start=0&limit=#{last_id}")
|
389
|
+
response = Net::HTTP.get_response(uri)
|
390
|
+
|
391
|
+
log_curl_output(response.code,response.body)
|
392
|
+
|
393
|
+
return JSON.parse(response.body)
|
394
|
+
end
|
395
|
+
|
396
|
+
def dao_check_proposal(id)
|
397
|
+
uri = URI.parse("http://web3wrapper:5000/dao/getproposal?proposal_id=#{id}")
|
398
|
+
response = Net::HTTP.get_response(uri)
|
399
|
+
|
400
|
+
log_curl_output(response.code,response.body)
|
401
|
+
|
402
|
+
return JSON.parse(response.body)
|
403
|
+
end
|
404
|
+
|
405
|
+
def dao_auto_claim()
|
406
|
+
last_vote_id = dao_get_last_vote_id()
|
407
|
+
user_claim_list = dao_check_claim_list(last_vote_id)
|
408
|
+
start = 0
|
409
|
+
stop = last_vote_id
|
410
|
+
(start..stop).each do |id|
|
411
|
+
if user_claim_list['bool'][id] == true
|
412
|
+
proposal = dao_check_proposal(user_claim_list['uint256'][id])
|
413
|
+
if proposal['status'] == 3 or proposal['status'] == 2
|
414
|
+
dao_claim(user_claim_list['uint256'][id])
|
415
|
+
else
|
416
|
+
if interpolated['debug'] == 'true'
|
417
|
+
log "claim not ready"
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
if interpolated['debug'] == 'true'
|
422
|
+
log "id #{id} : #{user_claim_list['uint256'][id]}"
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
263
427
|
def get_tx_receipt(hash)
|
264
428
|
|
265
429
|
uri = URI.parse("#{interpolated['rpc_server']}")
|
@@ -1693,6 +1857,10 @@ module Agents
|
|
1693
1857
|
twobears_check_order_by_id()
|
1694
1858
|
when "get_abi_json"
|
1695
1859
|
get_abi_json(interpolated['wallet'],false)
|
1860
|
+
when "dao_auto_claim"
|
1861
|
+
dao_auto_claim()
|
1862
|
+
when "dao_check_missing_vote"
|
1863
|
+
dao_check_missing_vote()
|
1696
1864
|
else
|
1697
1865
|
log "Error: type has an invalid value (#{type})"
|
1698
1866
|
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.
|
4
|
+
version: 0.1.88
|
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-
|
11
|
+
date: 2024-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|