huginn_callisto_network_agent 0.1.90 → 0.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/huginn_callisto_network_agent/callisto_network_agent.rb +78 -12
- 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: 938131a443634c93dc79e45e1bf8b30c4dbc9ed1d68c002ea7d864509219722a
|
4
|
+
data.tar.gz: 3ef5965fb3ab9b43cda7aa83d13275bffce9fad6dd52174c73daac3050b8ef90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d98d24f42046a30b388e5aa78b91f0acd648dd351016376012dc53409629203e4ee9ab6b773de095108a68ff459fba2b12d8e83dd40d98cee144304a02704560
|
7
|
+
data.tar.gz: b0d312f5f5a0c6744eaf19c6145f7ee8be174b3ca4e70dc767ac4244226c06eb9d937d90c9eee714ec126593fe398ef0039058ea1c3b668aabe9246c542a844e
|
@@ -51,6 +51,7 @@ module Agents
|
|
51
51
|
'round' => '',
|
52
52
|
'wallet_dest' => '',
|
53
53
|
'changes_only' => 'true',
|
54
|
+
'vote' => 'true',
|
54
55
|
'filter_for_method_id' => '',
|
55
56
|
'first_block' => '',
|
56
57
|
'last_block' => '',
|
@@ -62,7 +63,8 @@ module Agents
|
|
62
63
|
form_configurable :emit_events, type: :boolean
|
63
64
|
form_configurable :expected_receive_period_in_days, type: :string
|
64
65
|
form_configurable :changes_only, type: :boolean
|
65
|
-
form_configurable :
|
66
|
+
form_configurable :vote, type: :boolean
|
67
|
+
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', 'dao_vote_id', 'get_cs_stats']
|
66
68
|
form_configurable :wallet, type: :string
|
67
69
|
form_configurable :rpc_server, type: :string
|
68
70
|
form_configurable :wallet_password, type: :string
|
@@ -74,13 +76,13 @@ module Agents
|
|
74
76
|
form_configurable :last_block, type: :string
|
75
77
|
form_configurable :sql_db, type: :string
|
76
78
|
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' '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'])
|
79
|
+
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' 'dao_vote_id' 'get_cs_stats'") 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 dao_vote_id get_cs_stats).include?(interpolated['type'])
|
78
80
|
|
79
81
|
unless options['wallet_password'].present? || !['clo_sendtx' 'start_cs_clo' 'withdraw_cs_clo' 'dao_auto_claim'].include?(options['type'])
|
80
82
|
errors.add(:base, "wallet_password is a required field")
|
81
83
|
end
|
82
84
|
|
83
|
-
unless options['value'].present? || !['clo_sendtx' 'start_cs_clo' 'callosha_slots' '2bears_check_order_by_id' 'dao_check_missing_vote'].include?(options['type'])
|
85
|
+
unless options['value'].present? || !['clo_sendtx' 'start_cs_clo' 'callosha_slots' '2bears_check_order_by_id' 'dao_check_missing_vote' 'dao_vote_id' 'dao_vote_id'].include?(options['type'])
|
84
86
|
errors.add(:base, "value is a required field")
|
85
87
|
end
|
86
88
|
|
@@ -96,7 +98,7 @@ module Agents
|
|
96
98
|
errors.add(:base, "rpc_server is a required field")
|
97
99
|
end
|
98
100
|
|
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'])
|
101
|
+
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' 'dao_vote_id'].include?(options['type'])
|
100
102
|
errors.add(:base, "wallet is a required field")
|
101
103
|
end
|
102
104
|
|
@@ -161,8 +163,6 @@ module Agents
|
|
161
163
|
end
|
162
164
|
|
163
165
|
def to_hex(value, length = 64, with_0x = false)
|
164
|
-
# log value
|
165
|
-
# log value.class
|
166
166
|
hex = value.to_s(16)
|
167
167
|
hex = hex.rjust(length, '0')
|
168
168
|
hex = hex.sub(/^0x/, '') unless with_0x
|
@@ -260,6 +260,60 @@ module Agents
|
|
260
260
|
|
261
261
|
end
|
262
262
|
|
263
|
+
def bool_to_int(bool)
|
264
|
+
if bool == 'false'
|
265
|
+
return 0
|
266
|
+
else
|
267
|
+
return 1
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def dao_vote_id(id,internal=false)
|
272
|
+
|
273
|
+
if interpolated['debug'] == 'true'
|
274
|
+
log "unlocking the wallet"
|
275
|
+
end
|
276
|
+
response = JSON.parse(unlock_wallet())
|
277
|
+
if response['result'] == true
|
278
|
+
if interpolated['debug'] == 'true'
|
279
|
+
log "the wallet is unlocked"
|
280
|
+
end
|
281
|
+
uri = URI.parse("#{interpolated['rpc_server']}")
|
282
|
+
request = Net::HTTP::Post.new(uri)
|
283
|
+
request.content_type = "application/json"
|
284
|
+
request.body = JSON.dump({
|
285
|
+
"jsonrpc" => "2.0",
|
286
|
+
"id" => 1,
|
287
|
+
"method" => "eth_sendTransaction",
|
288
|
+
"params" => [
|
289
|
+
{
|
290
|
+
"from" => "#{interpolated['wallet']}",
|
291
|
+
"data" => "0xc9d27afe#{to_hex(id.to_i)}#{to_hex(bool_to_int(interpolated['vote']))}",
|
292
|
+
"to" => "0x810059e1406dedafd1bdca4e0137cba306c0ce36"
|
293
|
+
}
|
294
|
+
]
|
295
|
+
})
|
296
|
+
|
297
|
+
req_options = {
|
298
|
+
use_ssl: uri.scheme == "https",
|
299
|
+
}
|
300
|
+
|
301
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
302
|
+
http.request(request)
|
303
|
+
end
|
304
|
+
|
305
|
+
payload = JSON.parse(response.body)
|
306
|
+
|
307
|
+
if internal == false
|
308
|
+
create_event payload: payload
|
309
|
+
else
|
310
|
+
return payload['result']
|
311
|
+
end
|
312
|
+
else
|
313
|
+
end
|
314
|
+
|
315
|
+
end
|
316
|
+
|
263
317
|
def dao_get_last_vote_id()
|
264
318
|
uri = URI.parse("#{interpolated['rpc_server']}")
|
265
319
|
request = Net::HTTP::Post.new(uri)
|
@@ -291,16 +345,15 @@ module Agents
|
|
291
345
|
end
|
292
346
|
|
293
347
|
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
|
348
|
+
# function_id = '0x379607f5'
|
349
|
+
# formatted_value = id.to_s(16).rjust(64, '0')
|
350
|
+
# data = "#{function_id}#{formatted_value}"
|
298
351
|
if interpolated['debug'] == 'true'
|
299
352
|
log "unlocking the wallet"
|
300
353
|
end
|
301
354
|
response = JSON.parse(unlock_wallet())
|
302
|
-
log "response -> #{response}"
|
303
|
-
log "response result -> #{response['result']}"
|
355
|
+
# log "response -> #{response}"
|
356
|
+
# log "response result -> #{response['result']}"
|
304
357
|
if response['result'] == true
|
305
358
|
if interpolated['debug'] == 'true'
|
306
359
|
log "the wallet is unlocked"
|
@@ -402,6 +455,15 @@ module Agents
|
|
402
455
|
return JSON.parse(response.body)
|
403
456
|
end
|
404
457
|
|
458
|
+
def get_cs_stats()
|
459
|
+
uri = URI.parse("http://web3wrapper:5000/cs/stats_last_30d")
|
460
|
+
response = Net::HTTP.get_response(uri)
|
461
|
+
|
462
|
+
log_curl_output(response.code,response.body)
|
463
|
+
|
464
|
+
create_event payload: response.body
|
465
|
+
end
|
466
|
+
|
405
467
|
def dao_auto_claim()
|
406
468
|
last_vote_id = dao_get_last_vote_id()
|
407
469
|
user_claim_list = dao_check_claim_list(last_vote_id)
|
@@ -1861,6 +1923,10 @@ module Agents
|
|
1861
1923
|
dao_auto_claim()
|
1862
1924
|
when "dao_check_missing_vote"
|
1863
1925
|
dao_check_missing_vote()
|
1926
|
+
when "dao_vote_id"
|
1927
|
+
dao_vote_id(interpolated['value'],false)
|
1928
|
+
when "get_cs_stats"
|
1929
|
+
get_cs_stats()
|
1864
1930
|
else
|
1865
1931
|
log "Error: type has an invalid value (#{type})"
|
1866
1932
|
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.92
|
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-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|