huginn_callisto_network_agent 0.1.90 → 0.1.91
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 +67 -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: '0479d50053b1a7094cdcc70aadcc8471463a24ea941d34e11ed85a91a29a8dc6'
|
4
|
+
data.tar.gz: 044ce7e109b3f6e6b66f9679f013561510ffa7424faf346eee0078f34527c021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6275dcd886f4a8c38cd150a2838b84572ed1a12354c737190efcde2fb71b4eb5e70e585dda5032f2362df9c4c9e1c999c177d6b4414bfdbbc8d85b01d2cb80ef
|
7
|
+
data.tar.gz: bd3dc01de00e85e1e9390c1621fe3f8b9b659eb5da27cd2d1b392bd491a74e1c719b3a77732e8bb17c6492c4f4b05ee844e3b19aa4aac5d54f52bf331877e106
|
@@ -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']
|
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'") 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).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"
|
@@ -1861,6 +1914,8 @@ module Agents
|
|
1861
1914
|
dao_auto_claim()
|
1862
1915
|
when "dao_check_missing_vote"
|
1863
1916
|
dao_check_missing_vote()
|
1917
|
+
when "dao_vote_id"
|
1918
|
+
dao_vote_id(interpolated['value'],false)
|
1864
1919
|
else
|
1865
1920
|
log "Error: type has an invalid value (#{type})"
|
1866
1921
|
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.91
|
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-04-
|
11
|
+
date: 2024-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|