Skip to content

Commit

Permalink
Use *func_args in raffled transactions as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rbval committed Apr 23, 2020
1 parent c9ac133 commit c39e3a0
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions hmt_escrow/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,21 +558,18 @@ def bulk_payout(self,
bool: returns True if paying to ethereum addresses and oracles succeeds.
"""
try:
(hash_, url) = upload(results, pub_key)
eth_addrs = [eth_addr for eth_addr, amount in payouts]
hmt_amounts = [
int(amount * 10**18) for eth_addr, amount in payouts
]

txn_func = self.job_contract.functions.bulkPayOut
func_args = [eth_addrs, hmt_amounts, url, hash_, 1]
txn_info = {
"gas_payer": self.gas_payer,
"gas_payer_priv": self.gas_payer_priv,
"gas": gas
}
(hash_, url) = upload(results, pub_key)
eth_addrs = [eth_addr for eth_addr, amount in payouts]
hmt_amounts = [int(amount * 10**18) for eth_addr, amount in payouts]

txn_func = self.job_contract.functions.bulkPayOut
func_args = [eth_addrs, hmt_amounts, url, hash_, 1]
txn_info = {
"gas_payer": self.gas_payer,
"gas_payer_priv": self.gas_payer_priv,
"gas": gas
}
try:
handle_transaction(txn_func, *func_args, **txn_info)
return self._bulk_paid() == True
except Exception as e:
Expand All @@ -589,7 +586,7 @@ def bulk_payout(self,
"gas": gas
}
try:
handle_transaction(txn_func, *[], **txn_info)
handle_transaction(txn_func, *func_args, **txn_info)
self.gas_payer = gas_payer
self.gas_payer_priv = gas_payer_priv
bulk_paid = True
Expand Down Expand Up @@ -784,16 +781,15 @@ def store_intermediate_results(self,
returns True if contract's state is updated and IPFS upload succeeds.
"""
(hash_, url) = upload(results, pub_key)
txn_func = self.job_contract.functions.storeResults
func_args = [url, hash_]
txn_info = {
"gas_payer": self.gas_payer,
"gas_payer_priv": self.gas_payer_priv,
"gas": gas
}
try:
(hash_, url) = upload(results, pub_key)
txn_func = self.job_contract.functions.storeResults
func_args = [url, hash_]
txn_info = {
"gas_payer": self.gas_payer,
"gas_payer_priv": self.gas_payer_priv,
"gas": gas
}

handle_transaction(txn_func, *func_args, **txn_info)
return True
except Exception as e:
Expand All @@ -810,7 +806,7 @@ def store_intermediate_results(self,
"gas": gas
}
try:
handle_transaction(txn_func, *[], **txn_info)
handle_transaction(txn_func, *func_args, **txn_info)
self.gas_payer = gas_payer
self.gas_payer_priv = gas_payer_priv
results_stored = True
Expand Down

0 comments on commit c39e3a0

Please sign in to comment.