Skip to content
Snippets Groups Projects
Commit ba671227 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'mt-update' into 'master'

Update branch + fix regarding `update_proposal` operation

See merge request !3
parents 4b44fa5e a546dc36
No related branches found
No related tags found
1 merge request!3Update branch + fix regarding `update_proposal` operation
...@@ -336,7 +336,7 @@ class UpdateProposalEndDate(GrapheneObject): ...@@ -336,7 +336,7 @@ class UpdateProposalEndDate(GrapheneObject):
super(UpdateProposalEndDate, self).__init__( super(UpdateProposalEndDate, self).__init__(
OrderedDict([ OrderedDict([
('end_date', PointInTime(kwargs['update_proposal_end_date'])), ('end_date', PointInTime(kwargs['end_date'])),
])) ]))
...@@ -347,25 +347,26 @@ class UpdateProposalExtensions(Static_variant): ...@@ -347,25 +347,26 @@ class UpdateProposalExtensions(Static_variant):
Example:: Example::
[1, {
{'end_date': '2021-03-28T04:00:00'} 'type': '1',
] 'value':
{
'end_date': '2021-04-05T13:39:48'
}
}
""" """
def __init__(self, o): def __init__(self, o):
if type(o) == dict and 'type' in o and 'value' in o: if isinstance(o, dict) and 'type' in o and 'value' in o:
if o['type'] == "end_date": if o['type'] == "update_proposal_end_date":
type_id = 1 type_id = 1
else: else:
type_id = ~0 type_id = ~0
data = o['value']
else:
type_id, data = o
if type_id == 1: if type_id == 1:
data = (UpdateProposalEndDate(data)) data = (UpdateProposalEndDate(o['value']))
else: else:
raise Exception("Unknown UpdateProposalExtension") raise Exception("Unknown UpdateProposalExtension")
super(UpdateProposalExtensions, self).__init__(data, type_id) super(UpdateProposalExtensions, self).__init__(data, type_id, False)
...@@ -347,18 +347,23 @@ class Optional(object): ...@@ -347,18 +347,23 @@ class Optional(object):
class Static_variant(object): class Static_variant(object):
def __init__(self, d, type_id): def __init__(self, d, type_id, legacy_style = True):
self.data = d self.data = d
self.type_id = type_id 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): def __bytes__(self):
"""Returns bytes representation.""" """Returns bytes representation."""
return varint(self.type_id) + py23_bytes(self.data) return varint(self.type_id) + py23_bytes(self.data)
def __str__(self): def __str__(self):
"""Returns data as string.""" """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): class Map(object):
def __init__(self, data): def __init__(self, data):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment