Ejemplo n.º 1
0
 def add_required_fees(self, ops, asset_id="1.3.0"):
     """ Auxiliary method to obtain the required fees for a set of
         operations. Requires a websocket connection to a witness node!
     """
     ws = self.blockchain.rpc
     fees = ws.get_required_fees([i.json() for i in ops], asset_id)
     for i, d in enumerate(ops):
         if isinstance(fees[i], list):
             # Operation is a proposal
             ops[i].op.data["fee"] = Asset(
                 amount=fees[i][0]["amount"], asset_id=fees[i][0]["asset_id"]
             )
             for j, _ in enumerate(ops[i].op.data["proposed_ops"].data):
                 ops[i].op.data["proposed_ops"].data[j].data["op"].op.data[
                     "fee"
                 ] = Asset(
                     amount=fees[i][1][j]["amount"],
                     asset_id=fees[i][1][j]["asset_id"],
                 )
         else:
             # Operation is a regular operation
             ops[i].op.data["fee"] = Asset(
                 amount=fees[i]["amount"], asset_id=fees[i]["asset_id"]
             )
     return ops
Ejemplo n.º 2
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().__init__(
             OrderedDict([("base", Asset(kwargs["base"])),
                          ("quote", Asset(kwargs["quote"]))]))
Ejemplo n.º 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]

            start_time = Optional(
                PointInTime(kwargs["start_time"]) if "start_time" in
                kwargs else None)
            start_delay = Optional(
                Uint32(kwargs["start_delay"]) if "start_delay" in
                kwargs else None)

            if "meta" in kwargs and kwargs["meta"]:
                raise NotImplementedError(
                    '"meta" cannot yet be used with this library')

            super().__init__(
                OrderedDict([
                    (
                        "registration_deadline",
                        PointInTime(kwargs["registration_deadline"]),
                    ),
                    ("number_of_players", Uint32(kwargs["number_of_players"])),
                    ("buy_in", Asset(kwargs["buy_in"])),
                    (
                        "whitelist",
                        Array([
                            ObjectId(x, "account") for x in kwargs["whitelist"]
                        ]),
                    ),
                    ("start_time", start_time),
                    ("start_delay", start_delay),
                    ("round_delay", Uint32(kwargs["round_delay"])),
                    ("number_of_wins", Uint32(kwargs["number_of_wins"])),
                    ("meta", Optional(None)),
                    ("game_options",
                     GameSpecificOptions(kwargs["game_options"])),
                ]))