-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (47 loc) · 1.74 KB
/
main.py
File metadata and controls
65 lines (47 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import asyncio
import sys
import traceback
from core.grass import GrassFoundation
from data.config import THREADS
from utils import logger
from core import claimer
async def process_account(private_key, semaphore):
address = ""
async with semaphore:
try:
grass = GrassFoundation(private_key)
address = grass.address
proof = await grass.get_sign_msg()
claim_res = await claimer(private_key=private_key, version=proof['versionNumber'], claim_proof=proof['claimProof'],
allocation=proof["allocation"],
)
if claim_res:
logger.info("Successfully claimed")
with open(f'{path}/success.txt', 'a') as f:
f.write(f"{private_key}\n")
return True
except Exception as e:
logger.error(f"{address} | {e} | {traceback.format_exc()}")
finally:
await grass.close()
with open(f'{path}/failed.txt', 'a') as f:
f.write(f"{private_key}\n")
async def main():
keys = [account for account in open(f'{path}/keys.txt').read().splitlines()]
# proxies = open(f'{path}/proxies.txt').read().splitlines()
logger.info(f"Keys: {len(keys)}")
semaphore = asyncio.Semaphore(THREADS)
tasks = []
for i, _ in enumerate(keys):
task = asyncio.create_task(process_account(
keys[i],
# proxies[i] if len(proxies) > i else None,
semaphore
))
tasks.append(task)
await asyncio.gather(*tasks)
if __name__ == '__main__':
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
path = "data"
asyncio.run(main())