-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_pending_distribution.py
57 lines (42 loc) · 1.7 KB
/
check_pending_distribution.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
53
54
55
56
57
# Optional helper script, NOT tested yet.
from dotenv import load_dotenv
import submit_distribution
import asyncio
import sys
import argparse
from pprint import pprint
async def main(argv):
load_dotenv()
parser = argparse.ArgumentParser(
description="Validate submitted distribution pending in DistributionManager. Safety check.",
)
parser.parse_args(argv)
try:
pending_distributions_here = submit_distribution.load_last_distributions()
pending_dtpls_here = [d.to_tuple() for d in pending_distributions_here]
print("Expected pending distributions:")
pprint(pending_distributions_here)
print()
except FileNotFoundError:
# So you can view the pending distributions even without the file, for testing / debugging.
# The check below is gonna fail but the output is gonna be there.
print("No pending distributions file.")
print()
pending_dtpls_here = None
print("Expected pending distributions, encoded:")
pprint(pending_dtpls_here)
print()
# We only need the distribution_manager but it's easiest to just get everything.
chainstuff = await submit_distribution.get_chainstuff()
distribution_manager = chainstuff["distribution_manager"]
pending_dtpls_there = (
await distribution_manager.functions.getPendingDistributionsBatch().call()
)
print("On-chain pending distributions, encoded:")
pprint(pending_dtpls_there)
print()
# TODO check if this check actually passes on equality (i.e., the types are equal enough and everything)
assert pending_dtpls_here == pending_dtpls_there
print("Equal.")
if __name__ == "__main__":
asyncio.run(main(sys.argv[1:]))