web3-wizzard-lib 0.0.3__py3-none-any.whl → 0.1.2__py3-none-any.whl
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.
- web3_wizzard_lib/core/modules/linea_appeal.py +59 -9
- web3_wizzard_lib/core/utils/ai_utils.py +19 -1
- web3_wizzard_lib/core/utils/benchmark_utils.py +12 -0
- web3_wizzard_lib/core/utils/module_memory.py +26 -0
- web3_wizzard_lib-0.1.2.data/data/requirements.txt +1 -0
- {web3_wizzard_lib-0.0.3.dist-info → web3_wizzard_lib-0.1.2.dist-info}/METADATA +2 -2
- {web3_wizzard_lib-0.0.3.dist-info → web3_wizzard_lib-0.1.2.dist-info}/RECORD +9 -7
- web3_wizzard_lib-0.0.3.data/data/requirements.txt +0 -1
- {web3_wizzard_lib-0.0.3.dist-info → web3_wizzard_lib-0.1.2.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-0.0.3.dist-info → web3_wizzard_lib-0.1.2.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,18 @@
|
|
1
|
+
import random
|
1
2
|
import webbrowser
|
2
3
|
|
3
4
|
from loguru import logger
|
4
5
|
from sybil_engine.module.module import Module
|
6
|
+
from sybil_engine.utils.accumulator import add_accumulator, get_value
|
7
|
+
from sybil_engine.utils.statistic_utils import get_statistic_writer, statistic_date_string
|
5
8
|
|
6
|
-
from web3_wizzard_lib.core.utils.ai_utils import
|
9
|
+
from web3_wizzard_lib.core.utils.ai_utils import get_ai_chat
|
10
|
+
from sybil_engine.utils.telegram import add_config
|
11
|
+
|
12
|
+
from web3_wizzard_lib.core.utils.module_memory import get_by_key, accumulate_by_key, remove_key
|
13
|
+
|
14
|
+
APPEAL_ACCOUNTS = "APPEAL_ACCOUNTS"
|
15
|
+
APPEAL_ACCOUNTS_AMOUNT = "APPEAL_ACCOUNTS_AMOUNT"
|
7
16
|
|
8
17
|
|
9
18
|
class LineaAppeal(Module):
|
@@ -14,24 +23,65 @@ class LineaAppeal(Module):
|
|
14
23
|
with open("resources/linea_appeal.txt") as f:
|
15
24
|
linea_appeal_reason = f.read()
|
16
25
|
|
17
|
-
def execute(self,
|
18
|
-
|
26
|
+
def execute(self, token, accounts, statistic_write, ai_type, account):
|
27
|
+
add_accumulator("Acc Num", 1)
|
19
28
|
|
20
|
-
|
29
|
+
statistics = get_statistic_writer()
|
30
|
+
statistics.init_if_required(
|
31
|
+
f"linea_appeal_{statistic_date_string}",
|
32
|
+
["#", "MainAddress", "GPT Answer"]
|
33
|
+
)
|
21
34
|
|
35
|
+
chat_gpt = get_ai_chat(ai_type, token)
|
36
|
+
reason = chat_gpt.ask(self.linea_appeal_reason)
|
22
37
|
logger.info(reason)
|
23
38
|
|
39
|
+
statistics.write_row(
|
40
|
+
statistic_date_string,
|
41
|
+
[account.app_id, account.address, reason]
|
42
|
+
)
|
43
|
+
|
44
|
+
if get_by_key(APPEAL_ACCOUNTS_AMOUNT) is None:
|
45
|
+
add_config(
|
46
|
+
APPEAL_ACCOUNTS_AMOUNT,
|
47
|
+
random.randint(accounts['from'], accounts['to'])
|
48
|
+
)
|
49
|
+
|
50
|
+
accumulate_by_key(
|
51
|
+
APPEAL_ACCOUNTS, {
|
52
|
+
"address": account.address,
|
53
|
+
"reason": reason,
|
54
|
+
}
|
55
|
+
)
|
56
|
+
|
57
|
+
logger.info(f"Acc: {get_value("Acc Num")}")
|
58
|
+
logger.info(f"Acc Amount: {get_value("Acc Amount")}")
|
59
|
+
|
60
|
+
if (get_by_key(APPEAL_ACCOUNTS_AMOUNT) == len(get_by_key(APPEAL_ACCOUNTS))
|
61
|
+
or get_value("Acc Num") == get_value("Acc Amount")):
|
62
|
+
wallets = get_by_key(APPEAL_ACCOUNTS)
|
63
|
+
address_list = [wallet["address"] for wallet in wallets]
|
64
|
+
address_list.remove(account.address)
|
65
|
+
formatted_string = "\n".join(f"{wallet['address']}\n{wallet['reason']}" for wallet in wallets)
|
66
|
+
self.open_appeal_form(account, "\n".join(address_list), formatted_string)
|
67
|
+
remove_key(APPEAL_ACCOUNTS)
|
68
|
+
remove_key(APPEAL_ACCOUNTS_AMOUNT)
|
69
|
+
|
70
|
+
def open_appeal_form(self, account, address_list, formatted_string):
|
24
71
|
payload = {
|
25
72
|
"entry.1292139045": account.address,
|
26
|
-
"entry.1099559693": "",
|
27
|
-
"entry.1296389817":
|
73
|
+
"entry.1099559693": address_list.replace("\n", "%0A"),
|
74
|
+
"entry.1296389817": formatted_string.replace("\n", "%0A")
|
28
75
|
}
|
29
|
-
|
30
76
|
query_string = "&".join(f"{key}={value}" for key, value in payload.items())
|
31
77
|
pre_filled_url = f"{self.base_url}?{query_string}"
|
32
|
-
|
33
78
|
print(f"Opening form: {pre_filled_url}")
|
34
79
|
webbrowser.open(pre_filled_url)
|
35
80
|
|
36
81
|
def parse_params(self, module_params):
|
37
|
-
return
|
82
|
+
return (
|
83
|
+
module_params['ai_token'],
|
84
|
+
module_params['accounts'],
|
85
|
+
module_params['write_mode'],
|
86
|
+
module_params['ai_type']
|
87
|
+
)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import requests
|
2
2
|
|
3
|
+
from web3_wizzard_lib.core.utils.benchmark_utils import benchmark
|
4
|
+
|
3
5
|
|
4
6
|
class AIChat:
|
5
7
|
def ask(self, question):
|
@@ -10,6 +12,7 @@ class ChatGPT:
|
|
10
12
|
def __init__(self, token):
|
11
13
|
self.token = token
|
12
14
|
|
15
|
+
@benchmark
|
13
16
|
def ask(self, question):
|
14
17
|
url = "https://api.openai.com/v1/chat/completions"
|
15
18
|
headers = {
|
@@ -24,4 +27,19 @@ class ChatGPT:
|
|
24
27
|
|
25
28
|
response = requests.post(url, headers=headers, json=data)
|
26
29
|
|
27
|
-
return response.json()
|
30
|
+
return response.json()['choices'][0]['message']['content']
|
31
|
+
|
32
|
+
|
33
|
+
class MockAIChat:
|
34
|
+
def __init__(self, token):
|
35
|
+
self.token = token
|
36
|
+
|
37
|
+
def ask(self, question):
|
38
|
+
return f"ANSWER {question}"
|
39
|
+
|
40
|
+
|
41
|
+
def get_ai_chat(ai_config, token):
|
42
|
+
if ai_config == 'CHAT_GPT':
|
43
|
+
return ChatGPT(token)
|
44
|
+
else:
|
45
|
+
return MockAIChat(token)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
|
4
|
+
def benchmark(func):
|
5
|
+
def wrap(*args, **kwargs):
|
6
|
+
start = time.perf_counter()
|
7
|
+
result = func(*args, **kwargs)
|
8
|
+
end = time.perf_counter()
|
9
|
+
print(f"{func.__name__} executed in {end - start:.4f} seconds")
|
10
|
+
return result
|
11
|
+
|
12
|
+
return wrap
|
@@ -0,0 +1,26 @@
|
|
1
|
+
memory = {
|
2
|
+
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
def add_memory_list(key, value):
|
7
|
+
memory[key] = value
|
8
|
+
|
9
|
+
|
10
|
+
def accumulate_by_key(key, value):
|
11
|
+
if key not in memory:
|
12
|
+
memory[key] = []
|
13
|
+
|
14
|
+
memory[key].append(value)
|
15
|
+
# if isinstance(value, map):
|
16
|
+
# (list(value))
|
17
|
+
# else:
|
18
|
+
# memory[key] += value
|
19
|
+
|
20
|
+
|
21
|
+
def remove_key(key):
|
22
|
+
del memory[key]
|
23
|
+
|
24
|
+
|
25
|
+
def get_by_key(key):
|
26
|
+
return memory.get(key)
|
@@ -0,0 +1 @@
|
|
1
|
+
sybil-engine==10.0.2
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: web3_wizzard_lib
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: Engine for web3 smart contracts automatization.
|
5
5
|
Home-page: https://github.com/Indeoo/web3-wizzard-lib/
|
6
6
|
Author: Indeoo
|
7
7
|
Author-email: indeooars@gmail.com
|
8
8
|
Description-Content-Type: text/markdown
|
9
|
-
Requires-Dist: sybil-engine==
|
9
|
+
Requires-Dist: sybil-engine==10.0.2
|
10
10
|
Dynamic: author
|
11
11
|
Dynamic: author-email
|
12
12
|
Dynamic: description-content-type
|
@@ -105,7 +105,7 @@ web3_wizzard_lib/core/modules/erc20_balance.py,sha256=4mxd6QpOgnHHqUB0u6ya1Kh_xw
|
|
105
105
|
web3_wizzard_lib/core/modules/intract_claim.py,sha256=TyWtlZ6Rlx8ukG2elc4Lcr_ImF1K2RL2lz_EkhNfJBc,3744
|
106
106
|
web3_wizzard_lib/core/modules/layer_2_20.py,sha256=1MvidKQBS5GhBzH6yAmjTf1VHnM96_Wb0sGF24TTXJo,2475
|
107
107
|
web3_wizzard_lib/core/modules/lending_module.py,sha256=Sy0P-Ojt3e1JVMUCqpG06-DsiuTCvvHilgSj_QJPCwg,5517
|
108
|
-
web3_wizzard_lib/core/modules/linea_appeal.py,sha256=
|
108
|
+
web3_wizzard_lib/core/modules/linea_appeal.py,sha256=KPkPt97pko_9ENVverdtm-v1J-mHHmWsR0mjTdoHUXU,3267
|
109
109
|
web3_wizzard_lib/core/modules/linea_poh_lxp.py,sha256=keipTIhT3SrOESNJdIJesHBOOM-NKVzMGqKEACEKIvQ,2320
|
110
110
|
web3_wizzard_lib/core/modules/liquidity_pool.py,sha256=vu0vBoXomvAJFa10n9woo66v62hQbEO726M4lkiLWNE,2181
|
111
111
|
web3_wizzard_lib/core/modules/merkly_refuel.py,sha256=whQD6CplGt-hQxFN7lg40F6SmFU5niOO529lKMj0dyA,3488
|
@@ -252,10 +252,12 @@ web3_wizzard_lib/core/modules/swap/woofi.py,sha256=X1I6T4EVYpPVOdYuO_RALFubslCTm
|
|
252
252
|
web3_wizzard_lib/core/modules/swap/xy_finance.py,sha256=PO-dcFhPzr3D5a9-D31vPCgqcs-_SUf1YXCE85Bjehw,2058
|
253
253
|
web3_wizzard_lib/core/modules/swap/zebra.py,sha256=AnoBSRkh1YFyIbbL87JN9JwMTKnyGt5XY5K_7C7DcyM,1423
|
254
254
|
web3_wizzard_lib/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
255
|
-
web3_wizzard_lib/core/utils/ai_utils.py,sha256=
|
255
|
+
web3_wizzard_lib/core/utils/ai_utils.py,sha256=v1aVEAQz9IoI1B9qdfeDUohoMrHr8EBFKBFbqM8Ddng,1030
|
256
|
+
web3_wizzard_lib/core/utils/benchmark_utils.py,sha256=3YBPXseWJb_BpBJtWWU6Dc5kydyhX4YWSvEWj4v6ekk,286
|
257
|
+
web3_wizzard_lib/core/utils/module_memory.py,sha256=-EoEG5KvmWxGervESzCw0htjraFvNw6Fck7_aMwU4NE,385
|
256
258
|
web3_wizzard_lib/core/utils/sub_module.py,sha256=r7C89nhlOUAYtCI92JINapS_-5hUUYX7YnY9hQLgHKg,117
|
257
|
-
web3_wizzard_lib-0.
|
258
|
-
web3_wizzard_lib-0.
|
259
|
-
web3_wizzard_lib-0.
|
260
|
-
web3_wizzard_lib-0.
|
261
|
-
web3_wizzard_lib-0.
|
259
|
+
web3_wizzard_lib-0.1.2.data/data/requirements.txt,sha256=YhDe0eUumhIfPZauGghmAKIlbFEO4wyxP2iEMUC6Z28,20
|
260
|
+
web3_wizzard_lib-0.1.2.dist-info/METADATA,sha256=_aoL2rNEBLo0A3TPUCoDNNXMtwG9o3nYhF0YYca3baE,428
|
261
|
+
web3_wizzard_lib-0.1.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
262
|
+
web3_wizzard_lib-0.1.2.dist-info/top_level.txt,sha256=8dD8S5HQo4dKtxogttWY_sh4n3yCVy0MwiTelYp6kug,28
|
263
|
+
web3_wizzard_lib-0.1.2.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
sybil-engine==9.9.0
|
File without changes
|
File without changes
|