-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major overhaul that should've been multiple PRs (#1)
Signed-off-by: Dylan Schultz <hello@schultzie.dev>
- Loading branch information
1 parent
3a33e85
commit 81a9d81
Showing
6 changed files
with
148 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
address,amount | ||
decentr1qd5cvs4tel4a5zzgq2qgsmvyfzp7ytpxpu80vh,136813 | ||
Total Refund Amount,136813 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import csv | ||
from decimal import Decimal | ||
|
||
DENOM_EXPONENTS = { | ||
"ATOM": 0, | ||
"uatom": 6, | ||
"OSMO": 0, | ||
"uosmo": 6, | ||
} | ||
|
||
|
||
def writeRefundsCsv(refund_amounts: dict): | ||
header = ["address", "amount"] | ||
refund_sum = 0 | ||
with open("refunds.csv", "w") as f: | ||
# create the csv writer | ||
writer = csv.writer(f) | ||
writer.writerow(header) | ||
|
||
for k in refund_amounts.items(): | ||
_, refund_amount = k | ||
writer.writerow(k) | ||
refund_sum += refund_amount | ||
|
||
writer.writerow(["Total Refund Amount", refund_sum]) | ||
|
||
|
||
def getRefundAmountsFromCSV(file_obj, denom): | ||
refund_amounts = {} | ||
refund_reader = csv.reader(file_obj, delimiter=",", quotechar="|") | ||
denom_multiplier = 10 ** DENOM_EXPONENTS.get(denom, 1) | ||
for row in refund_reader: | ||
if "address" in row[0]: | ||
continue | ||
delegation_addr = row[0] | ||
refund_amt = Decimal(row[3]) * denom_multiplier | ||
refund_amounts[delegation_addr] = refund_amt | ||
|
||
return refund_amounts |