-
Notifications
You must be signed in to change notification settings - Fork 9
/
sync-abi.py
52 lines (46 loc) · 1.56 KB
/
sync-abi.py
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
import json
import asyncio
import aiohttp
import aiofiles
sync_config = {
'branch': 'ad7dff9858cfb88d220f32e7e80111aa11c26e86',
'repo': 'lidofinance/lido-dao',
'syncMap': [
{
'local': 'src/abi/lido.abi.json',
'remote': 'lib/abi/Lido.json',
},
{
'local': 'src/abi/registry.abi.json',
'remote': 'lib/abi/NodeOperatorsRegistry.json',
},
{
'local': 'src/abi/staking-router.abi.json',
'remote': 'lib/abi/StakingRouter.json'
}, {
'local': 'src/abi/security.abi.json',
'remote': 'lib/abi/DepositSecurityModule.json'
},
{
'local': 'src/abi/locator.abi.json',
'remote': 'lib/abi/LidoLocator.json'
}
],
}
async def get_file_from_github(repo, branch, file_path):
async with aiohttp.ClientSession() as session:
async with session.get(f'https://raw.githubusercontent.com/{repo}/{branch}/{file_path}') as response:
file_content = await response.text()
return json.loads(file_content)
async def run():
branch = sync_config['branch']
repo = sync_config['repo']
sync_map = sync_config['syncMap']
for file in sync_map:
local_path = file['local']
remote_path = file['remote']
file_content = await get_file_from_github(repo, branch, remote_path)
async with aiofiles.open(local_path, 'w') as f:
await f.write(json.dumps(file_content, indent=2))
loop = asyncio.get_event_loop()
loop.run_until_complete(run())