Skip to content

Commit

Permalink
delegator_pays_xfer_fee moved to yaml config
Browse files Browse the repository at this point in the history
  • Loading branch information
habanoz committed Feb 13, 2019
1 parent 053f73a commit af80208
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
1 change: 0 additions & 1 deletion fee.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[DEFAULT]
fee=1274
delegator_pays_xfer_fee=true

[KTTX]
storage_limit=0
Expand Down
34 changes: 19 additions & 15 deletions src/config/yaml_baking_conf_parser.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
from config.addr_type import AddrType
from config.yaml_conf_parser import YamlConfParser
from model.baking_conf import FOUNDERS_MAP, OWNERS_MAP, BAKING_ADDRESS, SUPPORTERS_SET, EXCLUDED_DELEGATORS_SET, \
PYMNT_SCALE, PRCNT_SCALE, SERVICE_FEE, FULL_SUPPORTERS_SET, MIN_DELEGATION_AMT, PAYMENT_ADDRESS, SPECIALS_MAP, \
DELEGATOR_PAYS_XFER_FEE
from util.address_validator import AddressValidator
from util.fee_validator import FeeValidator

SERVICE_FEE = 'service_fee'
OWNERS_MAP = 'owners_map'
FOUNDERS_MAP = 'founders_map'
BAKING_ADDRESS = 'baking_address'
PRCNT_SCALE = "prcnt_scale"
PYMNT_SCALE = "pymnt_scale"
EXCLUDED_DELEGATORS_SET = "excluded_delegators_set"
SPECIALS_MAP = 'specials_map'
SUPPORTERS_SET = 'supporters_set'
PAYMENT_ADDRESS = 'payment_address'
MIN_DELEGATION_AMT = 'min_delegation_amt'
### extensions
FULL_SUPPORTERS_SET = "full_supporters_set"

PKH_LENGHT = 36


Expand All @@ -42,6 +31,7 @@ def validate(self):
self.__validate_specials_map(conf_obj)
self.__validate_scale(conf_obj, PYMNT_SCALE)
self.__validate_scale(conf_obj, PRCNT_SCALE)
self.__parse_bool(conf_obj, DELEGATOR_PAYS_XFER_FEE)

def process(self):
conf_obj = self.get_conf_obj()
Expand Down Expand Up @@ -146,7 +136,7 @@ def __validate_specials_map(self, conf_obj):
addr_validator = AddressValidator(SPECIALS_MAP)
for key, value in conf_obj[SPECIALS_MAP].items():
addr_validator.validate(key)
FeeValidator("specials_map:"+key).validate(value)
FeeValidator("specials_map:" + key).validate(value)

def __validate_address_set(self, conf_obj, set_name):
if set_name not in conf_obj:
Expand Down Expand Up @@ -193,3 +183,17 @@ def __validate_non_negative_int(self, param_value):
return False

return True

def __parse_bool(self, conf_obj, param_name):

if param_name not in conf_obj:
conf_obj[param_name] = False

# already a bool value
if type(conf_obj[param_name]) == type(False):
return

if isinstance(conf_obj[param_name], str) and "true" == conf_obj[param_name].lower():
conf_obj[param_name] = True
else:
conf_obj[param_name] = False
23 changes: 20 additions & 3 deletions src/model/baking_conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import json

from config.yaml_baking_conf_parser import SERVICE_FEE, OWNERS_MAP, FOUNDERS_MAP, BAKING_ADDRESS, PAYMENT_ADDRESS, \
PYMNT_SCALE, PRCNT_SCALE, EXCLUDED_DELEGATORS_SET, SPECIALS_MAP, SUPPORTERS_SET, FULL_SUPPORTERS_SET, \
MIN_DELEGATION_AMT

SERVICE_FEE = 'service_fee'
OWNERS_MAP = 'owners_map'
FOUNDERS_MAP = 'founders_map'
BAKING_ADDRESS = 'baking_address'
PRCNT_SCALE = "prcnt_scale"
PYMNT_SCALE = "pymnt_scale"
EXCLUDED_DELEGATORS_SET = "excluded_delegators_set"
SPECIALS_MAP = 'specials_map'
SUPPORTERS_SET = 'supporters_set'
PAYMENT_ADDRESS = 'payment_address'
MIN_DELEGATION_AMT = 'min_delegation_amt'
DELEGATOR_PAYS_XFER_FEE = 'delegator_pays_xfer_fee'
### extensions
FULL_SUPPORTERS_SET = "full_supporters_set"

from model.custom_json_encoder import CustomJsonEncoder


Expand Down Expand Up @@ -57,6 +70,10 @@ def get_percentage_scale(self):
def get_min_delegation_amount(self):
return self.get_attribute(MIN_DELEGATION_AMT)

def get_delegator_pays_xfer_fee(self):
return self.get_attribute(DELEGATOR_PAYS_XFER_FEE)


def __repr__(self) -> str:
return json.dumps(self.__dict__, cls=CustomJsonEncoder, indent=1)

3 changes: 2 additions & 1 deletion tz1boot1pK9h2BVGXdyvfQSv8kd1LQM6H889.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pymnt_scale : None
specials_map : {}
supporters_set : {}
min_delegation_amt : 0
excluded_delegators_set : {}
excluded_delegators_set : {}
delegator_pays_xfer_fee : True

0 comments on commit af80208

Please sign in to comment.