From 7a33d32aa67eeea51beb6910cf0181df853e352b Mon Sep 17 00:00:00 2001 From: Martin Lees <drov0@users.noreply.github.com> Date: Fri, 19 Mar 2021 23:05:30 +0100 Subject: [PATCH] support for the end_date extension for the update_proposal op --- beem/version.py | 4 ++-- beemapi/version.py | 4 ++-- beembase/objects.py | 45 +++++++++++++++++++++++++++++++++++++ beembase/operations.py | 6 ++++- beembase/version.py | 4 ++-- beemgraphenebase/version.py | 4 ++-- 6 files changed, 58 insertions(+), 9 deletions(-) diff --git a/beem/version.py b/beem/version.py index e3053201..38ac4019 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ -"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.22' +"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" +version = '0.24.22' diff --git a/beemapi/version.py b/beemapi/version.py index e3053201..38ac4019 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ -"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.22' +"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" +version = '0.24.22' diff --git a/beembase/objects.py b/beembase/objects.py index 666c23ec..934f5b6d 100644 --- a/beembase/objects.py +++ b/beembase/objects.py @@ -324,3 +324,48 @@ class CommentOptionExtensions(Static_variant): else: raise Exception("Unknown CommentOptionExtension") super(CommentOptionExtensions, self).__init__(data, type_id) + + +class UpdateProposalEndDate(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(UpdateProposalEndDate, self).__init__( + OrderedDict([ + ('end_date', PointInTime(kwargs['update_proposal_end_date'])), + ])) + + +class UpdateProposalExtensions(Static_variant): + """ Serialize Update proposal extensions. + + :param end_date: A static_variant containing the new end_date. + + Example:: + + [1, + {'end_date': '2021-03-28T04:00:00'} + ] + + """ + def __init__(self, o): + if type(o) == dict and 'type' in o and 'value' in o: + if o['type'] == "end_date": + type_id = 1 + else: + type_id = ~0 + data = o['value'] + else: + type_id, data = o + + if type_id == 1: + data = (UpdateProposalEndDate(data)) + else: + raise Exception("Unknown UpdateProposalExtension") + super(UpdateProposalExtensions, self).__init__(data, type_id) + + diff --git a/beembase/operations.py b/beembase/operations.py index f2675033..41e40ab0 100644 --- a/beembase/operations.py +++ b/beembase/operations.py @@ -25,7 +25,8 @@ from .objects import ( ExchangeRate, Beneficiaries, Beneficiary, - CommentOptionExtensions + CommentOptionExtensions, + UpdateProposalExtensions ) default_prefix = "STM" @@ -401,6 +402,9 @@ class Update_proposal(GrapheneObject): prefix = kwargs.get("prefix", default_prefix) extensions = Array([]) + if "extensions" in kwargs and kwargs["extensions"]: + extensions = Array([UpdateProposalExtensions(o) for o in kwargs["extensions"]]) + super(Update_proposal, self).__init__( OrderedDict([ diff --git a/beembase/version.py b/beembase/version.py index e3053201..38ac4019 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ -"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.22' +"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" +version = '0.24.22' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index e3053201..38ac4019 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ -"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.22' +"""THIS FILE IS GENERATED FROM beem SETUP.PY.""" +version = '0.24.22' -- GitLab