From a8c3d60512b5c38b4fc57ae06ba2f07fae526ee1 Mon Sep 17 00:00:00 2001 From: litepresence Date: Fri, 16 Dec 2022 20:04:56 -0500 Subject: [PATCH] add samet fund and credit deal to operations.py --- bitsharesbase/operations.py | 688 ++++++++++++++++++++++++++++++++++++ 1 file changed, 688 insertions(+) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index b437748..abdabaf 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1226,4 +1226,692 @@ def __init__(self, *args, **kwargs): ) +class Fill_order(GrapheneObject): + """Virtual operation.""" + + def __init__(self, *args, **kwargs): + raise VirtualOperationException() + + +class Account_transfer(GrapheneObject): + 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_id", ObjectId(kwargs["account_id"], "account")), + ("new_owner", ObjectId(kwargs["new_owner"], "account")), + ("extensions", Set([])), + ] + ) + ) + + +class Witness_create(GrapheneObject): + def __init__(self, *args, **kwargs): + 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] + super().__init__( + OrderedDict( + [ + ("fee", Asset(kwargs["fee"])), + ( + "witness_account", + ObjectId(kwargs["witness_account"], "account"), + ), + ("url", String(kwargs["url"])), + ( + "block_signing_key", + PublicKey(kwargs["block_signing_key"], prefix=prefix), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Proposal_delete(GrapheneObject): + 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_paying_account", + ObjectId(kwargs["fee_paying_account"], "account"), + ), + ( + "using_owner_authority", + Bool(kwargs["using_owner_authority"]), + ), + ("fee", Asset(kwargs["fee"])), + ("proposal", ObjectId(kwargs["proposal"], "proposal")), + ("extensions", Set([])), + ] + ) + ) + + +class Withdraw_permission_update(GrapheneObject): + 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"])), + ( + "withdraw_from_account", + ObjectId(kwargs["withdraw_from_account"], "account"), + ), + ( + "authorized_account", + ObjectId(kwargs["authorized_account"], "account"), + ), + ( + "permission_to_update", + ObjectId( + kwargs["permission_to_update"], "withdraw_permission" + ), + ), + ("withdrawal_limit", Asset(kwargs["withdrawal_limit"])), + ( + "withdrawal_period_sec", + Uint32(kwargs["withdrawal_period_sec"]), + ), + ("period_start_time", PointInTime(kwargs["period_start_time"])), + ( + "periods_until_expiration", + Uint32(kwargs["periods_until_expiration"]), + ), + ] + ) + ) + + +class Withdraw_permission_claim(GrapheneObject): + def __init__(self, *args, **kwargs): + 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] + if "memo" in kwargs and kwargs["memo"]: + if isinstance(kwargs["memo"], dict): + kwargs["memo"]["prefix"] = prefix + memo = Optional(Memo(**kwargs["memo"])) + else: + memo = Optional(Memo(kwargs["memo"])) + else: + memo = Optional(None) + super().__init__( + OrderedDict( + [ + ("fee", Asset(kwargs["fee"])), + ( + "permission_to_update", + ObjectId( + kwargs["permission_to_update"], "withdraw_permission" + ), + ), + ( + "withdraw_from_account", + ObjectId(kwargs["withdraw_from_account"], "account"), + ), + ( + "withdraw_to_account", + ObjectId(kwargs["withdraw_to_account"], "account"), + ), + ("amount_to_withdraw", Asset(kwargs["amount_to_withdraw"])), + ("memo", memo), + ] + ) + ) + + +class Withdraw_permission_delete(GrapheneObject): + 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"])), + ( + "withdraw_from_account", + ObjectId(kwargs["withdraw_from_account"], "account"), + ), + ( + "authorized_account", + ObjectId(kwargs["authorized_account"], "account"), + ), + ( + "withdrawal_permission", + ObjectId( + kwargs["withdrawal_permission"], "withdraw_permission" + ), + ), + ] + ) + ) + + +class Committee_member_update(GrapheneObject): + 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"])), + ( + "committee_member", + ObjectId(kwargs["committee_member"], "committee_member"), + ), + ( + "committee_member_account", + ObjectId(kwargs["committee_member_account"], "account"), + ), + ("new_url", String(kwargs["new_url"])), + ] + ) + ) + + +class Committee_member_update_global_parameters(GrapheneObject): + 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"])), + ("new_parameters", ChainParameters(kwargs["new_parameters"])), + ] + ) + ) + + +class Vesting_balance_create(GrapheneObject): + 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"])), + ("creator", ObjectId(kwargs["creator"], "account")), + ("owner", ObjectId(kwargs["owner"], "account")), + ("amount", Asset(kwargs["amount"])), + ("policy", VestingPolicy(kwargs["policy"])), + ] + ) + ) + + +class Transfer_to_blind(GrapheneObject): + def __init__(self, *args, **kwargs): + raise NotImplementedError + + +class Transfer_from_blind(GrapheneObject): + def __init__(self, *args, **kwargs): + raise NotImplementedError + + +class Blind_transfer(GrapheneObject): + def __init__(self, *args, **kwargs): + raise NotImplementedError + + +class Asset_settle_cancel(GrapheneObject): + """Virtual Operation.""" + + def __init__(self, *args, **kwargs): + raise VirtualOperationException() + + +class Fba_distribute(GrapheneObject): + """Virtual Operation.""" + + def __init__(self, *args, **kwargs): + raise VirtualOperationException() + + +class Execute_bid(GrapheneObject): + """Virtual Operation.""" + + def __init__(self, *args, **kwargs): + raise VirtualOperationException() + + +class Htlc_redeemed(GrapheneObject): + """Virtual Operation.""" + + def __init__(self, *args, **kwargs): + raise VirtualOperationException() + + +class Htlc_refund(GrapheneObject): + """Virtual Operation.""" + + def __init__(self, *args, **kwargs): + raise VirtualOperationException() + + +class Custom_authority_create_operation(GrapheneObject): + def __init__(self, *args, **kwargs): + raise NotImplementedError() + 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")), + ("enabled", Bool(kwargs["enabled"])), + ("valid_from", PointInTime(kwargs["valid_from"])), + ("valid_to", PointInTime(kwargs["valid_to"])), + ("operation_type", Uint32(kwargs["operation_type"])), + ("auth", Permission(kwargs["auth"])), + ( + "restrictions", + Array( + [CustomRestriction(o) for o in kwargs["restrictions"]] + ), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Custom_authority_update_operation(GrapheneObject): + def __init__(self, *args, **kwargs): + raise NotImplementedError() + 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")), + ( + "authority_to_update", + ObjectId(kwargs["authority_to_update"], "custom_authority"), + ), + ("new_enabled", Bool(kwargs["enabled"])), + ("new_valid_from", PointInTime(kwargs["valid_from"])), + ("new_valid_to", PointInTime(kwargs["valid_to"])), + ("new_auth", Permission(kwargs["auth"])), + ( + "restrictions_to_remove", + Array( + [Uint16(o) for o in kwargs["restrictions_to_remove"]] + ), + ), + ( + "restrictions_to_add", + Array( + [ + CustomRestriction(o) + for o in kwargs["restrictions_to_add"] + ] + ), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Custom_authority_delete_operation(GrapheneObject): + def __init__(self, *args, **kwargs): + raise NotImplementedError() + 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")), + ( + "authority_to_delete", + ObjectId(kwargs["authority_to_update"], "custom_authority"), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Samet_fund_create(GrapheneObject): + 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_account", ObjectId(kwargs["owner_account"], "account")), + ("asset_type", ObjectId(kwargs["asset_type"], "asset")), + ("balance", Int64(kwargs["balance"])), + ("fee_rate", Uint32(kwargs["fee_rate"])), + ("extensions", Set([])), + ] + ) + ) + + +class Samet_fund_delete(GrapheneObject): + 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_account", ObjectId(kwargs["owner_account"], "account")), + ("fund_id", ObjectId(kwargs["fund_id"], "samet_fund")), + ("extensions", Set([])), + ] + ) + ) + + +class Samet_fund_update(GrapheneObject): + 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_account", ObjectId(kwargs["owner_account"], "account")), + ("fund_id", ObjectId(kwargs["fund_id"], "samet_fund")), + ("delta_amount", Optional(Asset(kwargs["delta_amount"]))), + ("new_fee_rate", Optional(Uint32(kwargs["new_fee_rate"]))), + ("extensions", Set([])), + ] + ) + ) + + +class Samet_fund_borrow(GrapheneObject): + 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"])), + ("borrower", ObjectId(kwargs["borrower"], "account")), + ("fund_id", ObjectId(kwargs["fund_id"], "samet_fund")), + ("borrow_amount", Asset(kwargs["borrow_amount"])), + ("extensions", Set([])), + ] + ) + ) + + +class Samet_fund_repay(GrapheneObject): + 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")), + ("fund_id", ObjectId(kwargs["fund_id"], "samet_fund")), + ("repay_amount", Asset(kwargs["repay_amount"])), + ("fund_fee", Asset(kwargs["fund_fee"])), + ("extensions", Set([])), + ] + ) + ) + + +class Credit_offer_create(GrapheneObject): + 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_account", ObjectId(kwargs["owner_account"], "account")), + ("asset_type", ObjectId(kwargs["asset_type"], "asset")), + ("balance", Int64(kwargs["balance"])), + ("fee_rate", Uint32(kwargs["fee_rate"])), + ( + "max_duration_seconds", + Uint32(kwargs["max_duration_seconds"]), + ), + ("min_deal_amount", Int64(kwargs["min_deal_amount"])), + ("enabled", Bool(kwargs["enabled"])(kwargs["enabled"])), + ("auto_disable_time", PointInTime(kwargs["auto_disable_time"])), + ( + "acceptable_collateral", + Map( + [ + [ObjectId(k[0], "asset"), Price(k[1])] + for k in kwargs["acceptable_collateral"] + ] + ), + ), + ( + "acceptable_borrowers", + Map( + [ + [ObjectId(k[0], "account"), Int64(k[1])] + for k in kwargs["acceptable_borrowers"] + ] + ), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Credit_offer_delete(GrapheneObject): + 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_account", ObjectId(kwargs["owner_account"], "account")), + ("offer_id", ObjectId(kwargs["offer_id"], "credit_offer")), + ("extensions", Set([])), + ] + ) + ) + + +class Credit_offer_update(GrapheneObject): + 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_account", ObjectId(kwargs["owner_account"], "account")), + ("offer_id", ObjectId(kwargs["offer_id"], "credit_offer")), + ("delta_amount", Optional(Asset(kwargs["fee"]))), + ("fee_rate", Optional(Uint32(kwargs["fee_rate"]))), + ( + "max_duration_seconds", + Optional(Uint32(kwargs["max_duration_seconds"])), + ), + ("min_deal_amount", Optional(Int64(kwargs["min_deal_amount"]))), + ("enabled", Optional(Bool(kwargs["enabled"]))), + ( + "auto_disable_time", + Optional(PointInTime(kwargs["auto_disable_time"])), + ), + ( + "acceptable_collateral", + Optional( + Map( + [ + [ObjectId(k[0], "asset"), Price(k[1])] + for k in kwargs["acceptable_collateral"] + ] + ) + ), + ), + ( + "acceptable_borrowers", + Optional( + Map( + [ + [ObjectId(k[0], "account"), Int64(k[1])] + for k in kwargs["acceptable_borrowers"] + ] + ) + ), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Credit_offer_accept(GrapheneObject): + 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"])), + ("borrower", ObjectId(kwargs["borrower"], "account")), + ("offer_id", ObjectId(kwargs["offer_id"], "credit_offer")), + ("borrow_amount", Asset(kwargs["fee"])), + ("collateral", Asset(kwargs["fee"])), + ("max_fee_rate", Uint32(kwargs["max_fee_rate"])), + ( + "min_duration_seconds", + Uint32(kwargs["min_duration_seconds"]), + ), + ("extensions", Set([])), + ] + ) + ) + + +class Credit_deal_repay(GrapheneObject): + 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")), + ("deal_id", ObjectId(kwargs["deal_id"], "credit_deal")), + ("repay_amount", Asset(kwargs["fee"])), + ("credit_fee", Asset(kwargs["fee"])), + ("extensions", Set([])), + ] + ) + ) + + +class Credit_deal_expired(GrapheneObject): + 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"])), + ("deal_id", ObjectId(kwargs["deal_id"], "credit_deal")), + ("offer_id", ObjectId(kwargs["offer_id"], "credit_offer")), + ("offer_owner", ObjectId(kwargs["offer_owner"], "account")), + ("borrower", ObjectId(kwargs["borrower"], "account")), + ("unpaid_amount", Asset(kwargs["fee"])), + ("collateral", Asset(kwargs["fee"])), + ("fee_rate", Uint32(kwargs["fee_rate"])), + ] + ) + ) + + fill_classmaps()