Exemple #1
0
    def __init__(self, *args, **kwargs):
        if isArgsThisClass(self, args):
            self.data = args[0].data
        else:
            prefix = kwargs.pop("prefix", default_prefix)

            if len(args) == 1 and len(kwargs) == 0:
                kwargs = args[0]

            # Sort keys (FIXME: ideally, the sorting is part of Public
            # Key and not located here)
            kwargs["key_auths"] = sorted(
                kwargs["key_auths"],
                key=lambda x: repr(PublicKey(x[0], prefix=prefix)),
                reverse=False,
            )
            kwargs["account_auths"] = sorted(
                kwargs["account_auths"],
                key=lambda x: x[0],
                reverse=False,
            )
            accountAuths = Map([[String(e[0]), Uint16(e[1])]
                                for e in kwargs["account_auths"]])
            keyAuths = Map([[PublicKey(e[0], prefix=prefix),
                             Uint16(e[1])] for e in kwargs["key_auths"]])
            super(Permission, self).__init__(
                OrderedDict([
                    ('weight_threshold',
                     Uint32(int(kwargs["weight_threshold"]))),
                    ('account_auths', accountAuths),
                    ('key_auths', keyAuths),
                ]))
Exemple #2
0
 def __init__(self, *args, **kwargs):
     if check_for_class(self, args):
         return
     if len(args) == 1 and len(kwargs) == 0:
         kwargs = args[0]
     prefix = kwargs.get("prefix", default_prefix)
     replace_hive_by_steem = kwargs.get("replace_hive_by_steem", True)
     # handle beneficiaries
     if "beneficiaries" in kwargs and kwargs['beneficiaries']:
         kwargs['extensions'] = [[
             0, {
                 'beneficiaries': kwargs['beneficiaries']
             }
         ]]
     extensions = Array([])
     if "extensions" in kwargs and kwargs["extensions"]:
         extensions = Array(
             [CommentOptionExtensions(o) for o in kwargs["extensions"]])
     if "percent_steem_dollars" in kwargs:
         super(Comment_options, self).__init__(
             OrderedDict([
                 ('author', String(kwargs["author"])),
                 ('permlink', String(kwargs["permlink"])),
                 ('max_accepted_payout',
                  Amount(kwargs["max_accepted_payout"],
                         prefix=prefix,
                         replace_hive_by_steem=replace_hive_by_steem)),
                 ('percent_steem_dollars',
                  Uint16(int(kwargs["percent_steem_dollars"]))),
                 ('allow_votes', Bool(bool(kwargs["allow_votes"]))),
                 ('allow_curation_rewards',
                  Bool(bool(kwargs["allow_curation_rewards"]))),
                 ('extensions', extensions),
             ]))
     else:
         super(Comment_options, self).__init__(
             OrderedDict([
                 ('author', String(kwargs["author"])),
                 ('permlink', String(kwargs["permlink"])),
                 ('max_accepted_payout',
                  Amount(kwargs["max_accepted_payout"],
                         prefix=prefix,
                         replace_hive_by_steem=False)),
                 ('percent_hbd', Uint16(int(kwargs["percent_hbd"]))),
                 ('allow_votes', Bool(bool(kwargs["allow_votes"]))),
                 ('allow_curation_rewards',
                  Bool(bool(kwargs["allow_curation_rewards"]))),
                 ('extensions', extensions),
             ]))
Exemple #3
0
 def __init__(self, *args, **kwargs):
     if isArgsThisClass(self, args):
         self.data = args[0].data
     else:
         if len(args) == 1 and len(kwargs) == 0:
             kwargs = args[0]
         prefix = kwargs.get("prefix", default_prefix)
         if "sbd_interest_rate" in kwargs:
             super(WitnessProps, self).__init__(
                 OrderedDict([
                     ('account_creation_fee',
                      Amount(kwargs["account_creation_fee"],
                             prefix=prefix)),
                     ('maximum_block_size',
                      Uint32(kwargs["maximum_block_size"])),
                     ('sbd_interest_rate',
                      Uint16(kwargs["sbd_interest_rate"])),
                 ]))
         else:
             super(WitnessProps, self).__init__(
                 OrderedDict([
                     ('account_creation_fee',
                      Amount(kwargs["account_creation_fee"],
                             prefix=prefix)),
                     ('maximum_block_size',
                      Uint32(kwargs["maximum_block_size"])),
                 ]))
Exemple #4
0
    def __init__(self, *args, **kwargs):
        if check_for_class(self, args):
            return
        if len(args) == 1 and len(kwargs) == 0:
            kwargs = args[0]

        # handle beneficiaries
        if "beneficiaries" in kwargs and kwargs['beneficiaries']:
            kwargs['extensions'] = [[
                0, {
                    'beneficiaries': kwargs['beneficiaries']
                }
            ]]

        extensions = Array([])
        if "extensions" in kwargs and kwargs["extensions"]:
            extensions = Array(
                [CommentOptionExtensions(o) for o in kwargs["extensions"]])

        super(Comment_options, self).__init__(
            OrderedDict([
                ('author', String(kwargs["author"])),
                ('permlink', String(kwargs["permlink"])),
                ('max_accepted_payout', Amount(kwargs["max_accepted_payout"])),
                ('percent_steem_dollars',
                 Uint16(int(kwargs["percent_steem_dollars"]))),
                ('allow_votes', Bool(bool(kwargs["allow_votes"]))),
                ('allow_curation_rewards',
                 Bool(bool(kwargs["allow_curation_rewards"]))),
                ('extensions', extensions),
            ]))
Exemple #5
0
    def __init__(self, *args, **kwargs):
        if check_for_class(self, args):
            return
        if len(args) == 1 and len(kwargs) == 0:
            kwargs = args[0]

        # handle beneficiaries
        extensions = Array([])
        beneficiaries = kwargs.get('beneficiaries')
        if beneficiaries and type(beneficiaries) == list:
            ext_obj = [0, {'beneficiaries': beneficiaries}]
            ext = CommentOptionExtensions(ext_obj)
            extensions = Array([ext])

        super(Comment_options, self).__init__(
            OrderedDict([
                ('author', String(kwargs["author"])),
                ('permlink', String(kwargs["permlink"])),
                ('max_accepted_payout', Amount(kwargs["max_accepted_payout"])),
                ('percent_steem_dollars',
                 Uint16(int(kwargs["percent_steem_dollars"]))),
                ('allow_votes', Bool(bool(kwargs["allow_votes"]))),
                ('allow_curation_rewards',
                 Bool(bool(kwargs["allow_curation_rewards"]))),
                ('extensions', extensions),
            ]))
Exemple #6
0
 def __init__(self, *args, **kwargs):
     if check_for_class(self, args):
         return
     if len(args) == 1 and len(kwargs) == 0:
         kwargs = args[0]
     super(Custom_binary, self).__init__(OrderedDict([
         ('id', Uint16(int(kwargs["id"]))),
         ('data', String(kwargs["data"])),
     ]))
Exemple #7
0
    def __init__(self, *args, **kwargs):
        if check_for_class(self, args):
            return
        if len(args) == 1 and len(kwargs) == 0:
            kwargs = args[0]
        prefix = kwargs.pop("prefix", default_prefix)
        extensions = Array([])
        props = {}
        for k in kwargs["props"]:
            if "key" == k[0]:
                block_signing_key = (PublicKey(k[1], prefix=prefix))
                props["key"] = repr(block_signing_key)
            elif "new_signing_key" == k[0]:
                new_signing_key = (PublicKey(k[1], prefix=prefix))
                props["new_signing_key"] = repr(new_signing_key)
        for k in kwargs["props"]:
            if k[0] in ["key", "new_signing_key"]:
                continue
            if isinstance(k[1], str) and PY3:
                is_hex = re.fullmatch(r'[0-9a-fA-F]+', k[1] or '') is not None
            elif isinstance(k[1], str) and PY2:
                is_hex = re.match(r'[0-9a-fA-F]+', k[1] or '') is not None
            else:
                is_hex = False
            if isinstance(k[1], int) and k[0] in ["account_subsidy_budget", "account_subsidy_decay", "maximum_block_size"]:
                props[k[0]] = (hexlify(Uint32(k[1]).__bytes__())).decode()
            elif isinstance(k[1], int) and k[0] in ["sbd_interest_rate"]:
                props[k[0]] = (hexlify(Uint16(k[1]).__bytes__())).decode()
            elif not isinstance(k[1], str) and k[0] in ["account_creation_fee"]:
                props[k[0]] = (hexlify(Amount(k[1], prefix=prefix).__bytes__())).decode()
            elif not is_hex and isinstance(k[1], str) and k[0] in ["account_creation_fee"]:
                props[k[0]] = (hexlify(Amount(k[1], prefix=prefix).__bytes__())).decode()
            elif not isinstance(k[1], str) and k[0] in ["sbd_exchange_rate"]:
                if 'prefix' not in k[1]:
                    k[1]['prefix'] = prefix
                props[k[0]] = (hexlify(ExchangeRate(k[1]).__bytes__())).decode()
            elif not is_hex and k[0] in ["url"]:
                props[k[0]] = (hexlify(String(k[1]).__bytes__())).decode()
            else:
                props[k[0]] = (k[1])
        props_list = []
        for k in props:
            props_list.append(([String(k), HexString(props[k])]))
        props_list = sorted(
            props_list,
            key=lambda x: str(x[0]),
            reverse=False,
        )
        map_props = Map(props_list)

        super(Witness_set_properties, self).__init__(OrderedDict([
            ('owner', String(kwargs["owner"])),
            ('props', map_props),
            ('extensions', extensions),
        ]))
Exemple #8
0
 def __init__(self, *args, **kwargs):
     if check_for_class(self, args):
         return
     if len(args) == 1 and len(kwargs) == 0:
         kwargs = args[0]
     super(Custom, self).__init__(OrderedDict([
         ('required_auths',
             Array([String(o) for o in kwargs["required_auths"]])),
         ('id', Uint16(int(kwargs["id"]))),
         ('data', String(kwargs["data"])),
     ]))
Exemple #9
0
 def __init__(self, *args, **kwargs):
     if check_for_class(self, args):
         return
     if len(args) == 1 and len(kwargs) == 0:
         kwargs = args[0]
     super(Set_withdraw_vesting_route, self).__init__(
         OrderedDict([
             ('from_account', String(kwargs["from_account"])),
             ('to_account', String(kwargs["to_account"])),
             ('percent', Uint16((kwargs["percent"]))),
             ('auto_vest', Bool(kwargs["auto_vest"])),
         ]))