Exemplo n.º 1
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)

        if not len(kwargs["new_account_name"]) <= 16:
            raise AssertionError("Account name must be at most 16 chars long")

        meta = ""
        if "json_metadata" in kwargs and kwargs["json_metadata"]:
            if isinstance(kwargs["json_metadata"], dict):
                meta = json.dumps(kwargs["json_metadata"])
            else:
                meta = kwargs["json_metadata"]

        super(Create_claimed_account, self).__init__(
            OrderedDict([
                ('creator', String(kwargs["creator"])),
                ('new_account_name', String(kwargs["new_account_name"])),
                ('owner', Permission(kwargs["owner"], prefix=prefix)),
                ('active', Permission(kwargs["active"], prefix=prefix)),
                ('posting', Permission(kwargs["posting"], prefix=prefix)),
                ('memo_key', PublicKey(kwargs["memo_key"], prefix=prefix)),
                ('json_metadata', String(meta)),
                ('extensions', Array([])),
            ]))
Exemplo n.º 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)

        # 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"], prefix=prefix)),
                ('percent_dpay_dollars',
                 Uint16(int(kwargs["percent_dpay_dollars"]))),
                ('allow_votes', Bool(bool(kwargs["allow_votes"]))),
                ('allow_curation_rewards',
                 Bool(bool(kwargs["allow_curation_rewards"]))),
                ('extensions', extensions),
            ]))
Exemplo n.º 3
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)
     meta = ""
     if "json_meta" in kwargs and kwargs["json_meta"]:
         if (isinstance(kwargs["json_meta"], dict)
                 or isinstance(kwargs["json_meta"], list)):
             meta = json.dumps(kwargs["json_meta"])
         else:
             meta = kwargs["json_meta"]
     super(Escrow_transfer, self).__init__(
         OrderedDict([
             ('from', String(kwargs["from"])),
             ('to', String(kwargs["to"])),
             ('agent', String(kwargs["agent"])),
             ('escrow_id', Uint32(kwargs["escrow_id"])),
             ('bbd_amount', Amount(kwargs["bbd_amount"], prefix=prefix)),
             ('dpay_amount', Amount(kwargs["dpay_amount"], prefix=prefix)),
             ('fee', Amount(kwargs["fee"], prefix=prefix)),
             ('ratification_deadline',
              PointInTime(kwargs["ratification_deadline"])),
             ('escrow_expiration',
              PointInTime(kwargs["escrow_expiration"])),
             ('json_meta', String(meta)),
         ]))
Exemplo n.º 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]
        prefix = kwargs.pop("prefix", default_prefix)

        if "block_signing_key" in kwargs and kwargs["block_signing_key"]:
            block_signing_key = (PublicKey(kwargs["block_signing_key"],
                                           prefix=prefix))
        else:
            block_signing_key = PublicKey(
                prefix + "1111111111111111111111111111111114T1Anm",
                prefix=prefix)
        if 'prefix' not in kwargs['props']:
            kwargs['props']['prefix'] = prefix

        super(Witness_update, self).__init__(
            OrderedDict([
                ('owner', String(kwargs["owner"])),
                ('url', String(kwargs["url"])),
                ('block_signing_key', block_signing_key),
                ('props', WitnessProps(kwargs["props"])),
                ('fee', Amount(kwargs["fee"], prefix=prefix)),
            ]))
Exemplo n.º 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]
     super(Account_witness_proxy, self).__init__(
         OrderedDict([
             ('account', String(kwargs["account"])),
             ('proxy', String(kwargs["proxy"])),
         ]))
Exemplo n.º 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(Delete_comment, self).__init__(
         OrderedDict([
             ('author', String(kwargs["author"])),
             ('permlink', String(kwargs["permlink"])),
         ]))
Exemplo n.º 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]
     super(Account_witness_vote, self).__init__(
         OrderedDict([
             ('account', String(kwargs["account"])),
             ('witness', String(kwargs["witness"])),
             ('approve', Bool(bool(kwargs["approve"]))),
         ]))
Exemplo n.º 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(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"])),
         ]))
Exemplo n.º 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(Escrow_dispute, self).__init__(
         OrderedDict([
             ('from', String(kwargs["from"])),
             ('to', String(kwargs["to"])),
             ('who', String(kwargs["who"])),
             ('escrow_id', Uint32(kwargs["escrow_id"])),
         ]))
Exemplo n.º 10
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(Vote, self).__init__(
         OrderedDict([
             ('voter', String(kwargs["voter"])),
             ('author', String(kwargs["author"])),
             ('permlink', String(kwargs["permlink"])),
             ('weight', Int16(kwargs["weight"])),
         ]))
Exemplo n.º 11
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)
     super(Transfer_to_vesting, self).__init__(
         OrderedDict([
             ('from', String(kwargs["from"])),
             ('to', String(kwargs["to"])),
             ('amount', Amount(kwargs["amount"], prefix=prefix)),
         ]))
Exemplo n.º 12
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"])),
         ]))
Exemplo n.º 13
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(Change_recovery_account, self).__init__(
         OrderedDict([
             ('account_to_recover', String(kwargs["account_to_recover"])),
             ('new_recovery_account',
              String(kwargs["new_recovery_account"])),
             ('extensions', Array([])),
         ]))
Exemplo n.º 14
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)
     super(Delegate_vesting_shares, self).__init__(
         OrderedDict([
             ('delegator', String(kwargs["delegator"])),
             ('delegatee', String(kwargs["delegatee"])),
             ('vesting_shares',
              Amount(kwargs["vesting_shares"], prefix=prefix)),
         ]))
Exemplo n.º 15
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)
     new_owner = Permission(kwargs["new_owner_authority"], prefix=prefix)
     super(Request_account_recovery, self).__init__(
         OrderedDict([
             ('recovery_account', String(kwargs["recovery_account"])),
             ('account_to_recover', String(kwargs["account_to_recover"])),
             ('new_owner_authority', new_owner),
             ('extensions', Array([])),
         ]))
Exemplo n.º 16
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)
     super(Escrow_release, self).__init__(
         OrderedDict([
             ('from', String(kwargs["from"])),
             ('to', String(kwargs["to"])),
             ('who', String(kwargs["who"])),
             ('escrow_id', Uint32(kwargs["escrow_id"])),
             ('bbd_amount', Amount(kwargs["bbd_amount"], prefix=prefix)),
             ('dpay_amount', Amount(kwargs["dpay_amount"], prefix=prefix)),
         ]))
Exemplo n.º 17
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),
            ]))
Exemplo n.º 18
0
    def __init__(self, d, prefix=default_prefix):
        if isinstance(d, string_types):
            self.amount, self.symbol = d.strip().split(" ")
            self.precision = None
            for c in known_chains:
                if self.precision is not None:
                    continue
                if known_chains[c]["prefix"] != prefix:
                    continue
                for asset in known_chains[c]["chain_assets"]:
                    if self.precision is not None:
                        continue
                    if asset["symbol"] == self.symbol:
                        self.precision = asset["precision"]
                        self.asset = asset["asset"]
                    elif asset["asset"] == self.symbol:
                        self.precision = asset["precision"]
                        self.asset = asset["asset"]
            if self.precision is None:
                raise Exception("Asset unknown")
            self.amount = int(float(self.amount) * 10 ** self.precision)

            self.str_repr = '{:.{}f} {}'.format((float(self.amount) / 10 ** self.precision), self.precision, self.symbol)
        elif isinstance(d, list):
            self.amount = d[0]
            self.asset = d[2]
            self.precision = d[1]
            self.symbol = None
            for c in known_chains:
                if known_chains[c]["prefix"] != prefix:
                    continue
                for asset in known_chains[c]["chain_assets"]:
                    if asset["asset"] == self.asset:
                        self.symbol = asset["symbol"]
            if self.symbol is None:
                raise ValueError("Unknown NAI, cannot resolve symbol")
            a = Array([String(d[0]), d[1], d[2]])
            self.str_repr = str(a.__str__())
        elif isinstance(d, dict) and "nai" in d:
            self.asset = d["nai"]
            self.symbol = None
            for c in known_chains:
                if known_chains[c]["prefix"] != prefix:
                    continue
                for asset in known_chains[c]["chain_assets"]:
                    if asset["asset"] == d["nai"]:
                        self.symbol = asset["symbol"]
            if self.symbol is None:
                raise ValueError("Unknown NAI, cannot resolve symbol")
            self.amount = d["amount"]
            self.precision = d["precision"]
            self.str_repr = json.dumps(d)
        else:
            self.amount = d.amount
            self.symbol = d.symbol
            self.asset = d.asset["asset"]
            self.precision = d.asset["precision"]
            self.amount = int(float(self.amount) * 10 ** self.precision)
            self.str_repr = str(d)
Exemplo n.º 19
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)
        if "memo" not in kwargs:
            kwargs["memo"] = ""

        super(Transfer_from_savings, self).__init__(
            OrderedDict([
                ('from', String(kwargs["from"])),
                ('request_id', Uint32(kwargs["request_id"])),
                ('to', String(kwargs["to"])),
                ('amount', Amount(kwargs["amount"], prefix=prefix)),
                ('memo', String(kwargs["memo"])),
            ]))
Exemplo n.º 20
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"])),
         ]))
Exemplo n.º 21
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(Decline_voting_rights, self).__init__(
         OrderedDict([
             ('account', String(kwargs["account"])),
             ('decline', Bool(kwargs["decline"])),
         ]))
Exemplo n.º 22
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(Limit_order_cancel, self).__init__(
         OrderedDict([
             ('owner', String(kwargs["owner"])),
             ('orderid', Uint32(kwargs["orderid"])),
         ]))
Exemplo n.º 23
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(Cancel_transfer_from_savings, self).__init__(
         OrderedDict([
             ('from', String(kwargs["from"])),
             ('request_id', Uint32(kwargs["request_id"])),
         ]))
Exemplo n.º 24
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]
     super(Beneficiary, self).__init__(
         OrderedDict([
             ('account', String(kwargs["account"])),
             ('weight', Int16(kwargs["weight"])),
         ]))
Exemplo n.º 25
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)
     super(Withdraw_vesting, self).__init__(
         OrderedDict([
             ('account', String(kwargs["account"])),
             ('vesting_shares',
              Amount(kwargs["vesting_shares"], prefix=prefix)),
         ]))
Exemplo n.º 26
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)
     super(Convert, self).__init__(
         OrderedDict([
             ('owner', String(kwargs["owner"])),
             ('requestid', Uint32(kwargs["requestid"])),
             ('amount', Amount(kwargs["amount"], prefix=prefix)),
         ]))
Exemplo n.º 27
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)
     super(Claim_account, self).__init__(
         OrderedDict([
             ('creator', String(kwargs["creator"])),
             ('fee', Amount(kwargs["fee"], prefix=prefix)),
             ('extensions', Array([])),
         ]))
Exemplo n.º 28
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)
     if 'prefix' not in kwargs['exchange_rate']:
         kwargs['exchange_rate']['prefix'] = prefix
     super(Feed_publish, self).__init__(
         OrderedDict([
             ('publisher', String(kwargs["publisher"])),
             ('exchange_rate', ExchangeRate(kwargs["exchange_rate"])),
         ]))
Exemplo n.º 29
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)

        if "owner" in kwargs:
            owner = Optional(Permission(kwargs["owner"], prefix=prefix))
        else:
            owner = Optional(None)

        if "active" in kwargs:
            active = Optional(Permission(kwargs["active"], prefix=prefix))
        else:
            active = Optional(None)

        if "posting" in kwargs:
            posting = Optional(Permission(kwargs["posting"], prefix=prefix))
        else:
            posting = Optional(None)

        meta = ""
        if "json_metadata" in kwargs and kwargs["json_metadata"]:
            if isinstance(kwargs["json_metadata"], dict):
                meta = json.dumps(kwargs["json_metadata"])
            else:
                meta = kwargs["json_metadata"]

        super(Account_update, self).__init__(
            OrderedDict([
                ('account', String(kwargs["account"])),
                ('owner', owner),
                ('active', active),
                ('posting', posting),
                ('memo_key', PublicKey(kwargs["memo_key"], prefix=prefix)),
                ('json_metadata', String(meta)),
            ]))
Exemplo n.º 30
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)
     super(Claim_reward_balance, self).__init__(
         OrderedDict([
             ('account', String(kwargs["account"])),
             ('reward_dpay', Amount(kwargs["reward_dpay"], prefix=prefix)),
             ('reward_bbd', Amount(kwargs["reward_bbd"], prefix=prefix)),
             ('reward_vests', Amount(kwargs["reward_vests"],
                                     prefix=prefix)),
         ]))