-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_airdrop_data.py
36 lines (26 loc) · 1 KB
/
import_airdrop_data.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
import argparse
import json
from decimal import Decimal
import settings # noqa
from models import Airdrop, Session
def main():
parser = argparse.ArgumentParser(description="Import Merkle Tree data")
parser.add_argument(
"-f", "--file", metavar="path", type=argparse.FileType("r"), help="JSON file to import", required=True
)
parser.add_argument(
"-c", "--contract", metavar="address", type=str, help="Merkle Distributor contract address", required=True
)
parser.add_argument("-t", "--token", metavar="symbol", type=str, help="ERC20 token symbol", required=True)
args = parser.parse_args()
data = json.loads(args.file.read())
# Add to database
with Session() as s:
for address, claim in data["claims"].items():
Airdrop.insert(
s, claim["index"], address, Decimal(int(claim["amount"], 16)), args.token, args.contract, claim["proof"]
)
s.commit()
print("Success!")
if __name__ == "__main__":
main()