示例#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).address),
                reverse=False,
            )
            accountAuths = Map([
                [ObjectId(e[0], "account"), 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().__init__(OrderedDict([
                ('weight_threshold', Uint32(int(kwargs["weight_threshold"]))),
                ('account_auths', accountAuths),
                ('key_auths', keyAuths),
                ('extensions', Set([])),
            ]))
示例#2
0
    def __init__(self, *args, **kwargs):
        # Allow for overwrite of prefix
        prefix = kwargs.pop("prefix", default_prefix)

        if isArgsThisClass(self, args):
            self.data = args[0].data
        else:
            if len(args) == 1 and len(kwargs) == 0:
                kwargs = args[0]
            # remove dublicates
            kwargs["votes"] = list(set(kwargs["votes"]))
            # Sort votes
            kwargs["votes"] = sorted(kwargs["votes"],
                                     key=lambda x: float(x.split(":")[1]))
            super().__init__(
                OrderedDict([
                    ("memo_key", PublicKey(kwargs["memo_key"], prefix=prefix)),
                    (
                        "voting_account",
                        ObjectId(kwargs["voting_account"], "account"),
                    ),
                    ("num_witness", Uint16(kwargs["num_witness"])),
                    ("num_committee", Uint16(kwargs["num_committee"])),
                    ("votes", Array([VoteId(o) for o in kwargs["votes"]])),
                    ("extensions", Set([])),
                ]))
示例#3
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]
            kwargs["key_auths"] = sorted(
                kwargs["key_auths"],
                key=lambda x: PublicKey(x[0], prefix=prefix),
                reverse=False,
            )
            accountAuths = Map([[ObjectId(e[0], "account"),
                                 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().__init__(
                OrderedDict([
                    ("weight_threshold",
                     Uint32(int(kwargs["weight_threshold"]))),
                    ("account_auths", accountAuths),
                    ("key_auths", keyAuths),
                    ("extensions", Set([])),
                ]))
示例#4
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([
                 ("feed_lifetime_sec", Uint32(kwargs["feed_lifetime_sec"])),
                 ("minimum_feeds", Uint8(kwargs["minimum_feeds"])),
                 (
                     "force_settlement_delay_sec",
                     Uint32(kwargs["force_settlement_delay_sec"]),
                 ),
                 (
                     "force_settlement_offset_percent",
                     Uint16(kwargs["force_settlement_offset_percent"]),
                 ),
                 (
                     "maximum_force_settlement_volume",
                     Uint16(kwargs["maximum_force_settlement_volume"]),
                 ),
                 (
                     "short_backing_asset",
                     ObjectId(kwargs["short_backing_asset"], "asset"),
                 ),
                 ("extensions", Set([])),
             ]))
示例#5
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(
                 [
                     ("max_supply", Int64(kwargs["max_supply"])),
                     ("market_fee_percent", Uint16(kwargs["market_fee_percent"])),
                     ("max_market_fee", Int64(kwargs["max_market_fee"])),
                     ("issuer_permissions", Uint16(kwargs["issuer_permissions"])),
                     ("flags", Uint16(kwargs["flags"])),
                     ("core_exchange_rate", Price(kwargs["core_exchange_rate"])),
                     (
                         "whitelist_authorities",
                         Array(
                             [
                                 ObjectId(x, "account")
                                 for x in kwargs["whitelist_authorities"]
                             ]
                         ),
                     ),
                     (
                         "blacklist_authorities",
                         Array(
                             [
                                 ObjectId(x, "account")
                                 for x in kwargs["blacklist_authorities"]
                             ]
                         ),
                     ),
                     (
                         "whitelist_markets",
                         Array(
                             [
                                 ObjectId(x, "asset")
                                 for x in kwargs["whitelist_markets"]
                             ]
                         ),
                     ),
                     (
                         "blacklist_markets",
                         Array(
                             [
                                 ObjectId(x, "asset")
                                 for x in kwargs["blacklist_markets"]
                             ]
                         ),
                     ),
                     ("description", String(kwargs["description"])),
                     ("extensions", Set([])),
                 ]
             )
         )
示例#6
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(PriceFeed, self).__init__(OrderedDict([
             ('settlement_price', Price(kwargs["settlement_price"])),
             ('maintenance_collateral_ratio', Uint16(kwargs["maintenance_collateral_ratio"])),
             ('maximum_short_squeeze_ratio', Uint16(kwargs["maximum_short_squeeze_ratio"])),
             ('core_exchange_rate', Price(kwargs["core_exchange_rate"])),
         ]))
示例#7
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]

            # Sorting
            for key in [
                    "whitelist_authorities", "blacklist_authorities",
                    "whitelist_markets", "blacklist_markets"
            ]:
                kwargs[key] = sorted(
                    set(kwargs[key]),
                    key=lambda x: int(x.split(".")[2]),
                )

            super().__init__(
                OrderedDict([
                    ('max_supply', Uint64(kwargs["max_supply"])),
                    ('market_fee_percent',
                     Uint16(kwargs["market_fee_percent"])),
                    ('max_market_fee', Uint64(kwargs["max_market_fee"])),
                    ('issuer_permissions',
                     Uint16(kwargs["issuer_permissions"])),
                    ('flags', Uint16(kwargs["flags"])),
                    ('core_exchange_rate',
                     Price(kwargs["core_exchange_rate"])),
                    ('whitelist_authorities',
                     Array([
                         ObjectId(o, "account")
                         for o in kwargs["whitelist_authorities"]
                     ])),
                    ('blacklist_authorities',
                     Array([
                         ObjectId(o, "account")
                         for o in kwargs["blacklist_authorities"]
                     ])),
                    ('whitelist_markets',
                     Array([
                         ObjectId(o, "asset")
                         for o in kwargs["whitelist_markets"]
                     ])),
                    ('blacklist_markets',
                     Array([
                         ObjectId(o, "asset")
                         for o in kwargs["blacklist_markets"]
                     ])),
                    ('description', String(kwargs["description"])),
                    ('extensions', Set([])),
                ]))
示例#8
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(
                 [
                     ("fee", Asset(kwargs["fee"])),
                     ("payer", ObjectId(kwargs["payer"], "account")),
                     (
                         "required_auths",
                         Array(
                             [
                                 ObjectId(o, "account")
                                 for o in kwargs["required_auths"]
                             ]
                         ),
                     ),
                     ("id", Uint16(kwargs["id"])),
                     ("data", Bytes(kwargs["data"])),
                 ]
             )
         )
示例#9
0
    def __init__(self, *args, **kwargs):
        # Allow for overwrite of prefix
        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)

            super().__init__(
                OrderedDict([
                    ('fee', Asset(kwargs["fee"])),
                    ('registrar', ObjectId(kwargs["registrar"], "account")),
                    ('referrer', ObjectId(kwargs["referrer"], "account")),
                    ('referrer_percent', Uint16(kwargs["referrer_percent"])),
                    ('name', String(kwargs["name"])),
                    ('owner', Permission(kwargs["owner"], prefix=prefix)),
                    ('active', Permission(kwargs["active"], prefix=prefix)),
                    ('limitactive',
                     Permission(kwargs["limitactive"],
                                prefix=prefix)),  # zos chain add
                    ('options', AccountOptions(kwargs["options"],
                                               prefix=prefix)),
                    # ('owner_special_authority', Static_variant(SpecialAuthority({}), 0)),
                    # ('active_special_authority', Static_variant(SpecialAuthority({}), 0)),
                    ('owner_special_authority', Optional(None)),
                    ('active_special_authority', Optional(None)),
                    ('buyback_options', Optional(None)),
                    # ('extensions', AccountCreateExtensions(kwargs["extensions"])),
                    ('extensions', Set([])),
                ]))
示例#10
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(
                    [
                        # initial, version 0
                        ("account_creation_fee", Amount(kwargs["account_creation_fee"])),
                        ("maximum_block_size", Uint32(kwargs["maximum_block_size"])),
                        ("create_account_delegation_ratio", Uint32(kwargs["create_account_delegation_ratio"])),
                        ("create_account_delegation_time", Uint32(kwargs["create_account_delegation_time"])),
                        ("min_delegation", Amount(kwargs["min_delegation"])),
                        ("min_curation_percent", Uint16(kwargs["min_curation_percent"])),
                        ("max_curation_percent", Uint16(kwargs["max_curation_percent"])),
                        ("bandwidth_reserve_percent", Uint16(kwargs["bandwidth_reserve_percent"])),
                        ("bandwidth_reserve_below", Amount(kwargs["bandwidth_reserve_below"])),
                        ("flag_energy_additional_cost", Uint16(kwargs["flag_energy_additional_cost"])),
                        ("vote_accounting_min_rshares", Uint32(kwargs["vote_accounting_min_rshares"])),
                        (
                            "committee_request_approve_min_percent",
                            Uint16(kwargs["committee_request_approve_min_percent"]),
                        ),
                        # chain_properties_hf4, version 1
                        ("inflation_witness_percent", Uint16(kwargs["inflation_witness_percent"])),
                        (
                            "inflation_ratio_committee_vs_reward_fund",
                            Uint16(kwargs["inflation_ratio_committee_vs_reward_fund"]),
                        ),
                        ("inflation_recalc_period", Uint32(kwargs["inflation_recalc_period"])),
                        # chain_properties_hf6: version 2
                        (
                            "data_operations_cost_additional_bandwidth",
                            Uint32(kwargs["data_operations_cost_additional_bandwidth"]),
                        ),
                        ("witness_miss_penalty_percent", Uint16(kwargs["witness_miss_penalty_percent"])),
                        ("witness_miss_penalty_duration", Uint32(kwargs["witness_miss_penalty_duration"])),
                        # chain_properties_hf9: version 3
                        ("create_invite_min_balance", Amount(kwargs["create_invite_min_balance"])),
                        ("committee_create_request_fee", Amount(kwargs["committee_create_request_fee"])),
                        ("create_paid_subscription_fee", Amount(kwargs["create_paid_subscription_fee"])),
                        ("account_on_sale_fee", Amount(kwargs["account_on_sale_fee"])),
                        ("subaccount_on_sale_fee", Amount(kwargs["subaccount_on_sale_fee"])),
                        ("witness_declaration_fee", Amount(kwargs["witness_declaration_fee"])),
                        ("withdraw_intervals", Uint16(kwargs["withdraw_intervals"])),
                    ]
                )
            )
示例#11
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(Vesting_balance_worker_initializer, self).__init__(OrderedDict([
             ('pay_vesting_period_days', Uint16(kwargs["pay_vesting_period_days"])),
         ]))
示例#12
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([
                    ("fee", Asset(kwargs["fee"])),
                    ("account", ObjectId(kwargs["account"], "account")),
                    ("asset_a", ObjectId(kwargs["asset_a"], "asset")),
                    ("asset_b", ObjectId(kwargs["asset_b"], "asset")),
                    ("share_asset", ObjectId(kwargs["share_asset"], "asset")),
                    ("taker_fee_percent", Uint16(kwargs["taker_fee_percent"])),
                    ("withdrawal_fee_percent",
                     Uint16(kwargs["withdrawal_fee_percent"])),
                    ("extensions", Set([])),
                ]))
示例#13
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]
            kwargs["key_auths"] = sorted(kwargs["key_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().__init__(
                OrderedDict(
                    [
                        ("weight_threshold", Uint32(int(kwargs["weight_threshold"]))),
                        ("account_auths", accountAuths),
                        ("key_auths", keyAuths),
                    ]
                )
            )
示例#14
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([(
                 "pay_vesting_period_days",
                 Uint16(kwargs["pay_vesting_period_days"]),
             )]))
示例#15
0
 def detail(self, *args, **kwargs):
     return OrderedDict([
         ("fee", Asset(kwargs["fee"])),
         ("from", ObjectId(kwargs["from"], "account")),
         ("to", ObjectId(kwargs["to"], "account")),
         ("amount", Asset(kwargs["amount"])),
         ("preimage_hash", HtlcHash(kwargs["preimage_hash"])),
         ("preimage_size", Uint16(kwargs["preimage_size"])),
         ("claim_period_seconds", Uint32(kwargs["claim_period_seconds"])),
         ("extensions", Set([])),
     ])
示例#16
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([
             ('from_account', String(kwargs["from_account"])),
             ('to_account', String(kwargs["to_account"])),
             ('percent', Uint16((kwargs["percent"]))),
             ('auto_vest', Bool(kwargs["auto_vest"])),
         ]))
示例#17
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([
                ('account_creation_fee', Amount(kwargs["account_creation_fee"])),
                ('maximum_block_size', Uint32(kwargs["maximum_block_size"])),
                ('sbd_interest_rate', Uint16(kwargs["sbd_interest_rate"])),
            ]))
示例#18
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([("fee", Asset(kwargs["fee"])),
                          ("owner", ObjectId(kwargs["owner"], "account")),
                          ("total_participants",
                           Uint32(kwargs["total_participants"])),
                          ("ticket_price", Asset(kwargs["ticket_price"])),
                          ("latency_sec", Uint16(kwargs["latency_sec"])),
                          ("img_url", String(kwargs["img_url"])),
                          ("description", String(kwargs["description"]))]))
示例#19
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([
                 ('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', Array([])),
             ]))
示例#20
0
    def __init__(self, *args, **kwargs):
        # Allow for overwrite of prefix
        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)

            super().__init__(OrderedDict([
                ('fee', Asset(kwargs["fee"])),
                ('registrar', ObjectId(kwargs["registrar"], "account")),
                ('referrer', ObjectId(kwargs["referrer"], "account")),
                ('referrer_percent', Uint16(kwargs["referrer_percent"])),
                ('name', String(kwargs["name"])),
                ('owner', Permission(kwargs["owner"], prefix=prefix)),
                ('active', Permission(kwargs["active"], prefix=prefix)),
                ('options', AccountOptions(kwargs["options"], prefix=prefix)),
                ('extensions', Set([])),
            ]))
示例#21
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]
            if "custom_sequence" not in kwargs:
                kwargs["custom_sequence"] = 0

            super().__init__(
                OrderedDict([
                    ("initiator", String(kwargs["initiator"])),
                    ("receiver", String(kwargs["receiver"])),
                    ("energy", Uint16(kwargs["energy"])),
                    ("custom_sequence", Uint64(kwargs["custom_sequence"])),
                    ("memo", String(kwargs["memo"])),
                    (
                        "beneficiaries",
                        Array(
                            [Beneficiary(o) for o in kwargs["beneficiaries"]]),
                    ),
                ]))
示例#22
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]
         if "extensions" in kwargs and kwargs["extensions"]:
             extensions = Array(
                 [CommentOptionExtensions(o) for o in kwargs["extensions"]])
         else:
             extensions = Array([])
         super().__init__(
             OrderedDict([
                 ('author', String(kwargs["author"])),
                 ('permlink', String(kwargs["permlink"])),
                 ('max_accepted_payout',
                  Amount(kwargs["max_accepted_payout"])),
                 ('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),
             ]))
示例#23
0
 def targetCollateralRatio(value):
     if value:
         return Uint16(value)
     else:
         return None
示例#24
0
    def __init__(self, threshold=0):
        self.data = OrderedDict({"threshold": Uint16(threshold)})

        super(Handicap, self).__init__(self.data)
示例#25
0
    def __init__(self, home=0, away=0):
        self.data = OrderedDict({"home": Uint16(home), "away": Uint16(away)})

        super(CorrectScoreParametrized, self).__init__(self.data)
示例#26
0
    def __init__(self, threshold=0):
        self.data = OrderedDict({"threshold": Uint16(threshold)})

        super(TotalGoals, self).__init__(self.data)