huginn_callisto_network_agent 0.1.5 → 0.1.60
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 +94 -23
- 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: c8a8ba441d0044a70088ab56c13d98b5696e4cf1f815c4db3580f10913d33197
|
4
|
+
data.tar.gz: 4b91fef828ac3db3efbe2964585924bf18a685dcda64dcc9cd14cb3ea711100f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ee7440723e26fa4ce09d56af8f5cc559a44c46175a22819656f0a94262f8bf639003a469aafc67dabe541a1fa2e5d78244bca0942102079f64e8a141fcc2b1f
|
7
|
+
data.tar.gz: a52af74b2fd5540a585ad3be297fcd776b5704e197e1edf3ed809e5c152e71920f3f4d152f9fcade011eb4a13b1eb0eb2a2be02e222b6cf6815adaa4ff78a842
|
@@ -61,7 +61,7 @@ module Agents
|
|
61
61
|
form_configurable :emit_events, type: :boolean
|
62
62
|
form_configurable :expected_receive_period_in_days, type: :string
|
63
63
|
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']
|
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']
|
65
65
|
form_configurable :wallet, type: :string
|
66
66
|
form_configurable :rpc_server, type: :string
|
67
67
|
form_configurable :wallet_password, type: :string
|
@@ -72,13 +72,13 @@ module Agents
|
|
72
72
|
form_configurable :first_block, type: :string
|
73
73
|
form_configurable :last_block, type: :string
|
74
74
|
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'") 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).include?(interpolated['type'])
|
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'") 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).include?(interpolated['type'])
|
76
76
|
|
77
77
|
unless options['wallet_password'].present? || !['clo_sendtx' 'start_cs_clo' 'withdraw_cs_clo'].include?(options['type'])
|
78
78
|
errors.add(:base, "wallet_password is a required field")
|
79
79
|
end
|
80
80
|
|
81
|
-
unless options['value'].present? || !['clo_sendtx' 'start_cs_clo'].include?(options['type'])
|
81
|
+
unless options['value'].present? || !['clo_sendtx' 'start_cs_clo' 'callosha_slots'].include?(options['type'])
|
82
82
|
errors.add(:base, "value is a required field")
|
83
83
|
end
|
84
84
|
|
@@ -86,7 +86,7 @@ module Agents
|
|
86
86
|
errors.add(:base, "wallet_dest is a required field")
|
87
87
|
end
|
88
88
|
|
89
|
-
unless options['round'].present? || !['start_cs_clo'].include?(options['type'])
|
89
|
+
unless options['round'].present? || !['start_cs_clo' 'callosha_slots'].include?(options['type'])
|
90
90
|
errors.add(:base, "round is a required field")
|
91
91
|
end
|
92
92
|
|
@@ -94,7 +94,7 @@ module Agents
|
|
94
94
|
errors.add(:base, "rpc_server is a required field")
|
95
95
|
end
|
96
96
|
|
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'].include?(options['type'])
|
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'])
|
98
98
|
errors.add(:base, "wallet is a required field")
|
99
99
|
end
|
100
100
|
|
@@ -142,6 +142,22 @@ module Agents
|
|
142
142
|
|
143
143
|
private
|
144
144
|
|
145
|
+
def max_gain(contract)
|
146
|
+
internal = true
|
147
|
+
balance = get_balance(internal,contract)
|
148
|
+
max_gain_for_1000 = balance * 0.7
|
149
|
+
max_gain_for_1 = max_gain_for_1000 / 1000
|
150
|
+
max_gain = interpolated['value'].to_i * max_gain_for_1
|
151
|
+
if interpolated['debug'] == 'true'
|
152
|
+
log "bank balance : #{balance}"
|
153
|
+
log "max gain for 1000 : #{max_gain_for_1000}"
|
154
|
+
log "max gain for 1 : #{max_gain_for_1}"
|
155
|
+
log "max gain : #{max_gain}"
|
156
|
+
end
|
157
|
+
return max_gain
|
158
|
+
|
159
|
+
end
|
160
|
+
|
145
161
|
def to_hex(value, length = 64, with_0x = false)
|
146
162
|
# log value
|
147
163
|
# log value.class
|
@@ -155,7 +171,7 @@ module Agents
|
|
155
171
|
def log_curl_output(code,body)
|
156
172
|
|
157
173
|
if interpolated['debug'] == 'true'
|
158
|
-
|
174
|
+
log "request status : #{code}"
|
159
175
|
log "body"
|
160
176
|
log body
|
161
177
|
end
|
@@ -229,6 +245,56 @@ module Agents
|
|
229
245
|
return total
|
230
246
|
end
|
231
247
|
|
248
|
+
def callosha_slots()
|
249
|
+
|
250
|
+
internal = true
|
251
|
+
contract = "0x7777265DC7FD2a15A7f2E8d8Ad87b3DAec677777"
|
252
|
+
power_of_10 = 18
|
253
|
+
final_value = interpolated['value'].to_i * 10**power_of_10
|
254
|
+
# log "0x83f818b4000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000000000000000001"
|
255
|
+
# log "0x83f818b4#{to_hex(max_gain(contract).to_i)}#{to_hex(interpolated['round'].to_i)}"
|
256
|
+
if interpolated['debug'] == 'true'
|
257
|
+
log "unlocking the wallet"
|
258
|
+
end
|
259
|
+
response = JSON.parse(unlock_wallet())
|
260
|
+
log "response -> #{response}"
|
261
|
+
log "response result -> #{response['result']}"
|
262
|
+
if response['result'] == true
|
263
|
+
if interpolated['debug'] == 'true'
|
264
|
+
log "the wallet is unlocked"
|
265
|
+
end
|
266
|
+
uri = URI.parse("#{interpolated['rpc_server']}")
|
267
|
+
request = Net::HTTP::Post.new(uri)
|
268
|
+
request.content_type = "application/json"
|
269
|
+
request.body = JSON.dump({
|
270
|
+
"jsonrpc" => "2.0",
|
271
|
+
"method" => "eth_sendTransaction",
|
272
|
+
"params" => [
|
273
|
+
{
|
274
|
+
"to" => "#{contract}",
|
275
|
+
"from" => "#{interpolated['wallet']}",
|
276
|
+
"value" => "0x#{final_value.to_s(16)}",
|
277
|
+
"data" => "0x83f818b4#{to_hex(max_gain(contract).to_i)}#{to_hex(interpolated['round'].to_i)}",
|
278
|
+
"gasPrice" => "#{eth_gasPrice(internal)}"
|
279
|
+
}
|
280
|
+
],
|
281
|
+
# "gas" => "0x186a0",
|
282
|
+
"id" => 1
|
283
|
+
})
|
284
|
+
|
285
|
+
req_options = {
|
286
|
+
use_ssl: uri.scheme == "https",
|
287
|
+
}
|
288
|
+
|
289
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
290
|
+
http.request(request)
|
291
|
+
end
|
292
|
+
|
293
|
+
log_curl_output(response.code,response.body)
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
|
232
298
|
def get_tx_stats()
|
233
299
|
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']
|
234
300
|
shitty_wallets = ['0x7971d8defa89bf68ff4142b2bb1e1e3866927b36', '0x33344541086c709fe585caeabc83e5947e783333', '0xcbb8aaf930497c7bd0de6b19903410698e8adab4', '0xc352d245f25fec51ff15c77fc5bf767bf655276a', '0x9daa24510951bc0ac5d1e4f89de5efd89cc8e0b0', '0x941dab361e6d3f0b310f78c2c9eb6779608de0c3', '0x8877e6657f48aee236b47eb1c65be8e7a44f11f8', '0x1a146e329333919542cdb6d2d87de370275124c6', '0xf7d862d42976662d649cc356f4ca3854d595d53d', '0xd125b9d1415b77e0951d5b91dce3ce5d9e4375d0', '0xb94f03ad1b8ddddb82b08cd038b652cbfc47fbb4', '0x8832abcd7248ed2bd740d3eafdeb774ab8332623', '0x6dfb81b6945967e57052e4132a9ca328f8d12f7c', '0x11817fa65a9c2f68fc03bbbc9f2113d59b96908b']
|
@@ -521,8 +587,8 @@ module Agents
|
|
521
587
|
if interpolated['debug'] == 'true'
|
522
588
|
log "the wallet is unlocked"
|
523
589
|
end
|
524
|
-
power_of_10 = 18
|
525
|
-
final_value = interpolated['value'].to_i * 10**power_of_10
|
590
|
+
# power_of_10 = 18
|
591
|
+
# final_value = interpolated['value'].to_i * 10**power_of_10
|
526
592
|
uri = URI.parse("#{interpolated['rpc_server']}")
|
527
593
|
request = Net::HTTP::Post.new(uri)
|
528
594
|
request.content_type = "application/json"
|
@@ -1366,7 +1432,7 @@ module Agents
|
|
1366
1432
|
end
|
1367
1433
|
end
|
1368
1434
|
|
1369
|
-
def get_balance()
|
1435
|
+
def get_balance(internal=false,address)
|
1370
1436
|
|
1371
1437
|
uri = URI.parse("#{interpolated['rpc_server']}")
|
1372
1438
|
request = Net::HTTP::Post.new(uri)
|
@@ -1374,7 +1440,7 @@ module Agents
|
|
1374
1440
|
request.body = JSON.dump({
|
1375
1441
|
"method" => "eth_getBalance",
|
1376
1442
|
"params" => [
|
1377
|
-
"#{
|
1443
|
+
"#{address}",
|
1378
1444
|
"latest"
|
1379
1445
|
],
|
1380
1446
|
"id" => 1,
|
@@ -1393,22 +1459,25 @@ module Agents
|
|
1393
1459
|
|
1394
1460
|
payload = JSON.parse(response.body)
|
1395
1461
|
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1462
|
+
power = (10 ** 18).to_i
|
1463
|
+
if internal == false
|
1464
|
+
if interpolated['changes_only'] == 'true'
|
1465
|
+
if payload != memory['get_balance']
|
1466
|
+
memory['get_balance'] = payload
|
1467
|
+
payload['name'] = "callisto"
|
1468
|
+
payload['symbol'] = "CLO"
|
1469
|
+
payload['result'] = payload['result'].to_i(16) / power.to_i.to_f
|
1470
|
+
create_event payload: payload
|
1471
|
+
end
|
1472
|
+
else
|
1473
|
+
if payload.to_s != memory['get_balance']
|
1474
|
+
memory['get_balance'] = payload
|
1475
|
+
end
|
1402
1476
|
payload['result'] = payload['result'].to_i(16) / power.to_i.to_f
|
1403
1477
|
create_event payload: payload
|
1404
1478
|
end
|
1405
1479
|
else
|
1406
|
-
|
1407
|
-
memory['get_balance'] = payload
|
1408
|
-
end
|
1409
|
-
power = (10 ** 18).to_i
|
1410
|
-
payload['result'] = payload['result'].to_i(16) / power.to_i.to_f
|
1411
|
-
create_event payload: payload
|
1480
|
+
payload['result'].to_i(16) / power.to_i.to_f
|
1412
1481
|
end
|
1413
1482
|
end
|
1414
1483
|
|
@@ -1416,7 +1485,7 @@ module Agents
|
|
1416
1485
|
|
1417
1486
|
case interpolated['type']
|
1418
1487
|
when "get_balance"
|
1419
|
-
get_balance()
|
1488
|
+
get_balance(false,interpolated['wallet'])
|
1420
1489
|
when "net_peerCount"
|
1421
1490
|
net_peerCount()
|
1422
1491
|
when "net_version"
|
@@ -1453,6 +1522,8 @@ module Agents
|
|
1453
1522
|
get_tx_by_address_with_filter()
|
1454
1523
|
when "get_tx_stats"
|
1455
1524
|
get_tx_stats()
|
1525
|
+
when "callosha_slots"
|
1526
|
+
callosha_slots()
|
1456
1527
|
else
|
1457
1528
|
log "Error: type has an invalid value (#{type})"
|
1458
1529
|
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.60
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Germain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|