Created
January 31, 2017 09:14
-
-
Save xeroc/2432ab1aa6d1f3e5135babb4dcf41f0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import csv | |
from steem import Steem | |
from steem.amount import Amount | |
from steem.transactionbuilder import TransactionBuilder | |
from steembase.operations import Transfer | |
import argparse | |
parser = argparse.ArgumentParser( | |
description="Payout tool for Streemian guilds" | |
) | |
parser.add_argument( | |
'--curators', | |
type=str, | |
default="curator.csv", | |
help='CSV file with curators' | |
) | |
parser.add_argument( | |
'--reviewers', | |
type=str, | |
default="reviewer.csv", | |
help='CSV file with reviewers' | |
) | |
parser.add_argument( | |
'--account', | |
type=str, | |
default="curie", | |
help='Send amounts from this account' | |
) | |
parser.add_argument( | |
'--proposerfee', | |
type=str, | |
default="0.05 SBD", | |
help='Proposer fee' | |
) | |
parser.add_argument( | |
'--reviewerfee', | |
type=str, | |
default="0.05 SBD", | |
help='Reviewer fee' | |
) | |
args = parser.parse_args() | |
tx = TransactionBuilder() | |
proposer_base_reward = Amount(args.proposerfee) | |
reviewer_base_reward = Amount(args.reviewerfee) | |
# curators | |
with open(args.curators) as fp: | |
for row in csv.reader(fp, delimiter=";", quotechar='"'): | |
# ignore comments | |
if row[0][0] == "#": | |
continue | |
account = row[0] | |
proposed = int(row[1]) | |
accepted = int(row[2]) | |
memo = "Finder's Fee" | |
if not accepted: | |
continue | |
tx.appendOps(Transfer( | |
**{"from": args.account, | |
"to": account, | |
"amount": str(proposer_base_reward * accepted), | |
"memo": memo | |
} | |
)) | |
# reviewer | |
with open(args.reviewers) as fp: | |
for row in csv.reader(fp, delimiter=";", quotechar='"'): | |
# ignore comments | |
if row[0][0] == "#": | |
continue | |
account = row[0] | |
reviewed = int(row[1]) | |
accepted = int(row[2]) | |
memo = "Reviewer's Fee" | |
if not reviewed: | |
continue | |
tx.appendOps(Transfer( | |
**{"from": args.account, | |
"to": account, | |
"amount": str(reviewer_base_reward * reviewed), | |
"memo": memo | |
} | |
)) | |
tx.appendSigner(args.account, "active") | |
from pprint import pprint | |
pprint(tx.json()) | |
#tx.broadcast() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment