@@ -10,18 +10,15 @@ class Association(Transaction):
1010 TYPE = 16
1111 DEFAULT_VERSION = 3
1212
13- def __init__ (self , recipient , association_type , anchor = '' , expires = 0 ):
13+ def __init__ (self , recipient , association_type , anchor = '' , expires = None ):
1414 super ().__init__ ()
1515 self .recipient = recipient
1616 self .association_type = association_type
1717 self .anchor = anchor
1818 self .tx_fee = self .DEFAULT_FEE
1919 self .version = self .DEFAULT_VERSION
20-
2120 self .expires = expires
22- current = int (time () * 1000 )
23- if self .expires != 0 and self .expires <= current :
24- raise Exception ('Wring exipration date' )
21+
2522
2623 def __to_binary_v1 (self ):
2724 if self .anchor :
@@ -58,7 +55,7 @@ def __to_binary_v3(self):
5855 struct .pack (">Q" , self .tx_fee ) +
5956 base58 .b58decode (self .recipient ) +
6057 struct .pack (">i" , self .association_type ) +
61- struct .pack (">Q" , self .expires ) +
58+ struct .pack (">Q" , self .expires or 0 ) +
6259 struct .pack (">H" , len (crypto .str2bytes (self .anchor ))) +
6360 crypto .str2bytes (self .anchor ))
6461
@@ -73,8 +70,8 @@ def to_binary(self):
7370
7471
7572 def to_json (self ):
76- tx = {
77- "id" : self .id if self . id else "" ,
73+ return crypto . clean_dict ( {
74+ "id" : self .id ,
7875 "type" : self .TYPE ,
7976 "version" : self .version ,
8077 "sender" : self .sender ,
@@ -86,12 +83,12 @@ def to_json(self):
8683 "timestamp" : self .timestamp ,
8784 "expires" : self .expires if self .version != 1 else None ,
8885 "fee" : self .tx_fee ,
89- "proofs " : self .proofs ,
90- "height " : self .height if self . height else ""
91- }
92- if self .version == 1 :
93- tx . pop ( 'expires' )
94- return crypto . merge_dicts ( tx , self . _sponsor_json () )
86+ "sponsor " : self .sponsor ,
87+ "sponsorKeyType " : self .sponsor_key_type ,
88+ "sponsorPublicKey" : self . sponsor_public_key ,
89+ "proofs" : self .proofs or None ,
90+ "height" : self . height
91+ } )
9592
9693
9794 @staticmethod
0 commit comments