From a546dc36fd893157b93dcae604af03a7622a53df Mon Sep 17 00:00:00 2001
From: mtrela <mtrela@syncad.com>
Date: Thu, 25 Mar 2021 17:39:52 +0100
Subject: [PATCH] Extensions fix in `update_proposal` operation

---
 beembase/objects.py       | 29 +++++++++++++++--------------
 beemgraphenebase/types.py | 11 ++++++++---
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/beembase/objects.py b/beembase/objects.py
index 934f5b6d..0b712c1d 100644
--- a/beembase/objects.py
+++ b/beembase/objects.py
@@ -336,7 +336,7 @@ class UpdateProposalEndDate(GrapheneObject):
 
             super(UpdateProposalEndDate, self).__init__(
                 OrderedDict([
-                    ('end_date', PointInTime(kwargs['update_proposal_end_date'])),
+                    ('end_date', PointInTime(kwargs['end_date'])),
                 ]))
 
 
@@ -347,25 +347,26 @@ class UpdateProposalExtensions(Static_variant):
 
         Example::
 
-            [1,
-                {'end_date': '2021-03-28T04:00:00'}
-            ]
+            {
+                'type': '1',
+                'value':
+                      {
+                        'end_date': '2021-04-05T13:39:48'
+                      }
+            }
 
     """
     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 isinstance(o, dict) and 'type' in o and 'value' in o:
+          if o['type'] == "update_proposal_end_date":
+              type_id = 1
+          else:
+              type_id = ~0
 
         if type_id == 1:
-            data = (UpdateProposalEndDate(data))
+            data = (UpdateProposalEndDate(o['value']))
         else:
             raise Exception("Unknown UpdateProposalExtension")
-        super(UpdateProposalExtensions, self).__init__(data, type_id)
+        super(UpdateProposalExtensions, self).__init__(data, type_id, False)
 
 
diff --git a/beemgraphenebase/types.py b/beemgraphenebase/types.py
index b62bd2a5..62e0f66d 100644
--- a/beemgraphenebase/types.py
+++ b/beemgraphenebase/types.py
@@ -347,18 +347,23 @@ class Optional(object):
 
 
 class Static_variant(object):
-    def __init__(self, d, type_id):
+    def __init__(self, d, type_id, legacy_style = True):
         self.data = d
         self.type_id = type_id
 
+        #`legacy_style = True` it means, that static variant is treated like an array, otherwise like an object
+        self.legacy_style = legacy_style
+
     def __bytes__(self):
         """Returns bytes representation."""
         return varint(self.type_id) + py23_bytes(self.data)
 
     def __str__(self):
         """Returns data as string."""
-        return json.dumps([self.type_id, self.data.json()])
-
+        if self.legacy_style:
+          return json.dumps([self.type_id, self.data.json()])
+        else:
+          return json.dumps({ 'type': self.type_id, 'value': self.data.json() })
 
 class Map(object):
     def __init__(self, data):
-- 
GitLab