Skip to content

Commit

Permalink
yaml changes
Browse files Browse the repository at this point in the history
  • Loading branch information
habanoz committed Feb 10, 2019
1 parent 04a9eb9 commit 119c6b2
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/BusinessConfiguration.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# baker's bussiness parameters

# baker's 'tz' address, NOT A KT address
BAKING_ADDRESS = "tz1YZReTLamLhyPLGSALa4TbMhjjgnSi2cqP"
BAKING_ADDRESS = "tz1Z1tMai15JWUWeN2PKL9faXXVPMuWamzJj"

# standard fee that is valid for everybody
STANDARD_FEE=0.045
STANDARD_FEE=0

# Minimum delegation amount (in Tez)
MIN_DELEGATION_AMT=1000
MIN_DELEGATION_AMT=0

# founders that shares the profits. map of founder payment address and share of the profit. Shares should sum up to 1.
founders_map={"tz1MWTkFRXA2dwez4RHJWnDWziLpaN6iDTZ9":1.0}
# deposit owners map of address and deposit ratio which must sum up to 1
owners_map={"KT1MMhmTkUoHez4u58XMZL7NkpU9FWY4QLn2":1.0}
# no fee customers, e.g. founders, supporters
supporters_set={"KT1T4RgrQ986qp2ndZ2YTnxKVSSUrD2BoKFH","KT1MMhmTkUoHez4u58XMZL7NkpU9FWY4QLn2"}
supporters_set={}
# customers with special rates. map of KT address and baking fee
specials_map={"KT1VYLbR7Cp4xxywWR4c12BPbkmrqSf5UXad":0.01}
specials_map={}
11 changes: 0 additions & 11 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,6 @@ def retry_failed_payments(self):
os.rename(payment_failed_report_file, payment_failed_report_file + BUSY_FILE)


# all shares in the map must sum up to 1
def validate_map_share_sum(share_map, map_name):
if len(share_map) > 0:
if abs(1 - sum(share_map.values()) > 1e-4): # a zero check actually
raise Exception("Map '{}' shares does not sum up to 1!".format(map_name))


def validate_standard_fee(fee):
FeeValidator("standard_fee").validate(fee)


def validate_release_override(release_override):
if not release_override:
pass
Expand Down
79 changes: 75 additions & 4 deletions src/util/client_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,91 @@ def clear_terminal_chars(content):
return result


def get_manager_for_contract(client_cmd, pkh, verbose):
response = send_request(client_cmd + " get manager for " + pkh, verbose)

response = clear_terminal_chars(response)

return dict


def parse_get_manager_for_contract_response(response, verbose=None):
manager = None
for line in response.splitlines():
line = line.strip()
if line.startswith("tz"):
line = line.replace(" (", ':')
manager, alias_plus = line.split(":", maxsplit=1)
break

if verbose:
print("Manager address is : {}".format(manager))

return manager


def client_generate_address_dict(client_cmd, verbose: None):
contr_dict = client_list_known_contracts(client_cmd, verbose)
addr_dict = client_list_known_addresses(client_cmd, verbose)

for alias, pkh in contr_dict.items():
if pkh.startswith("KT"):
manager = get_manager_for_contract(client_cmd, pkh, verbose)
manager_sk = addr_dict[manager]['sk']
addr_dict[pkh] = {"pkh": pkh, "originated": True, "alias": alias, "sk": manager_sk, "manager": manager}


def client_list_known_contracts(client_cmd, verbose=None):
response = send_request(client_cmd + " list known contracts")
response = send_request(client_cmd + " list known contracts", verbose)

response = clear_terminal_chars(response)

dict = {}
dict = parse_client_list_known_contracts_response(response, verbose)

return dict


def parse_client_list_known_contracts_response(response, verbose=None):
dict = {}
for line in response.splitlines():
if ":" in line and "Warning" not in line[0:10]:
line = line.strip()
if ":" in line and not_indicator_line(line):
alias, pkh = line.split(":", maxsplit=1)
dict[alias.strip()] = pkh.strip()

if verbose:
print("known contracts: {}".format(dict))
return dict


def client_list_known_addresses(client_cmd, verbose=None):
response = send_request(client_cmd + " list known addresses", verbose)

response = clear_terminal_chars(response)

dict = parse_list_known_addresses_response(response, verbose)

return dict


def not_indicator_line(line):
return "Warning" not in line[0:15] and "Disclaimer" not in line[0:15]


def parse_list_known_addresses_response(response, verbose=None):
dict = {}

for line in response.splitlines():
line = line.strip()
if ":" in line and not_indicator_line(line):
alias, pkh_plus_braces = line.split(":", maxsplit=1)
pkh_plus_braces = pkh_plus_braces.replace(' (', ':')
pkh, sk_section = pkh_plus_braces.split(":", maxsplit=1)
sk_known = "sk known" in sk_section
pkh = pkh.strip()
alias = alias.strip()
dict[pkh] = {"pkh": pkh, "originated": False, "alias": alias, "sk": sk_known, "manager": pkh}
if verbose:
print("known addresses: {}".format(dict))

return dict

Expand Down
14 changes: 9 additions & 5 deletions src/util/fee_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ class FeeValidator:

def __init__(self, specifier) -> None:
super().__init__()
self.specifier=specifier
self.specifier = specifier

def validate(self, fee):
if fee < 0:
raise Exception("Fee for {} cannot be less than 0, it is {}".format(self.specifier, fee))
failed=False
try:
if fee != 0 and not 1 <= fee <= 100:
failed=True
except TypeError:
failed=True

if fee > 1:
raise Exception("Fee for {} cannot be greater than 1, it is {}".format(self.specifier, fee))
if failed:
raise Exception("Fee for {} cannot be {}. Valid values are 0, [1-100]".format(self.specifier, fee))

0 comments on commit 119c6b2

Please sign in to comment.