huginn_callisto_network_agent 0.1.5 → 0.1.61
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 +96 -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: ec95ede49c3ffc674a7eb6dcaa1e7f9e72a2f7f1ce935dba9a11bf40b254c090
|
4
|
+
data.tar.gz: 58532401192364c6646ee806c2e0cd7d9aee208ac5e328b4f291edd2f14bfbdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d972f8e11d90356015e514d2c01afb62a88c2ec853dcc629a6cedd6da163643bc6ba2c5b9ca0d2130fdfd42c38a889fe92c411293c9b08a486d416cb3be14fbb
|
7
|
+
data.tar.gz: 6941acb185a9015fd5371e9bc676d4ae04c1fa20cbf625abf3a6db6747fdf34928066e7dd64820ab423a43bcc5fc767df9dd4fc02b63983fcf3d1664a0b68d26
|
@@ -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']
|
@@ -344,6 +410,8 @@ module Agents
|
|
344
410
|
transaction['call_type'] = 'mint'
|
345
411
|
when "0x78be0ad4"
|
346
412
|
transaction['call_type'] = 'withdraw_stake'
|
413
|
+
when "0x5d8c85ef"
|
414
|
+
transaction['call_type'] = 'start_staking'
|
347
415
|
else
|
348
416
|
transaction['call_type'] = 'unknown'
|
349
417
|
end
|
@@ -521,8 +589,8 @@ module Agents
|
|
521
589
|
if interpolated['debug'] == 'true'
|
522
590
|
log "the wallet is unlocked"
|
523
591
|
end
|
524
|
-
power_of_10 = 18
|
525
|
-
final_value = interpolated['value'].to_i * 10**power_of_10
|
592
|
+
# power_of_10 = 18
|
593
|
+
# final_value = interpolated['value'].to_i * 10**power_of_10
|
526
594
|
uri = URI.parse("#{interpolated['rpc_server']}")
|
527
595
|
request = Net::HTTP::Post.new(uri)
|
528
596
|
request.content_type = "application/json"
|
@@ -1366,7 +1434,7 @@ module Agents
|
|
1366
1434
|
end
|
1367
1435
|
end
|
1368
1436
|
|
1369
|
-
def get_balance()
|
1437
|
+
def get_balance(internal=false,address)
|
1370
1438
|
|
1371
1439
|
uri = URI.parse("#{interpolated['rpc_server']}")
|
1372
1440
|
request = Net::HTTP::Post.new(uri)
|
@@ -1374,7 +1442,7 @@ module Agents
|
|
1374
1442
|
request.body = JSON.dump({
|
1375
1443
|
"method" => "eth_getBalance",
|
1376
1444
|
"params" => [
|
1377
|
-
"#{
|
1445
|
+
"#{address}",
|
1378
1446
|
"latest"
|
1379
1447
|
],
|
1380
1448
|
"id" => 1,
|
@@ -1393,22 +1461,25 @@ module Agents
|
|
1393
1461
|
|
1394
1462
|
payload = JSON.parse(response.body)
|
1395
1463
|
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1464
|
+
power = (10 ** 18).to_i
|
1465
|
+
if internal == false
|
1466
|
+
if interpolated['changes_only'] == 'true'
|
1467
|
+
if payload != memory['get_balance']
|
1468
|
+
memory['get_balance'] = payload
|
1469
|
+
payload['name'] = "callisto"
|
1470
|
+
payload['symbol'] = "CLO"
|
1471
|
+
payload['result'] = payload['result'].to_i(16) / power.to_i.to_f
|
1472
|
+
create_event payload: payload
|
1473
|
+
end
|
1474
|
+
else
|
1475
|
+
if payload.to_s != memory['get_balance']
|
1476
|
+
memory['get_balance'] = payload
|
1477
|
+
end
|
1402
1478
|
payload['result'] = payload['result'].to_i(16) / power.to_i.to_f
|
1403
1479
|
create_event payload: payload
|
1404
1480
|
end
|
1405
1481
|
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
|
1482
|
+
payload['result'].to_i(16) / power.to_i.to_f
|
1412
1483
|
end
|
1413
1484
|
end
|
1414
1485
|
|
@@ -1416,7 +1487,7 @@ module Agents
|
|
1416
1487
|
|
1417
1488
|
case interpolated['type']
|
1418
1489
|
when "get_balance"
|
1419
|
-
get_balance()
|
1490
|
+
get_balance(false,interpolated['wallet'])
|
1420
1491
|
when "net_peerCount"
|
1421
1492
|
net_peerCount()
|
1422
1493
|
when "net_version"
|
@@ -1453,6 +1524,8 @@ module Agents
|
|
1453
1524
|
get_tx_by_address_with_filter()
|
1454
1525
|
when "get_tx_stats"
|
1455
1526
|
get_tx_stats()
|
1527
|
+
when "callosha_slots"
|
1528
|
+
callosha_slots()
|
1456
1529
|
else
|
1457
1530
|
log "Error: type has an invalid value (#{type})"
|
1458
1531
|
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.61
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|