@@ -112,7 +112,7 @@ def process(self):
112112
113113 self .era = self .process_type ('Era' )
114114
115- self .nonce = self .process_type ('Compact<U64 >' )
115+ self .nonce = self .process_type ('Compact<Index >' )
116116
117117 self .tip = self .process_type ('Compact<Balance>' )
118118
@@ -129,7 +129,7 @@ def process(self):
129129
130130 self .era = self .process_type ('Era' )
131131
132- self .nonce = self .process_type ('Compact<U64 >' )
132+ self .nonce = self .process_type ('Compact<Index >' )
133133
134134 self .tip = self .process_type ('Compact<Balance>' )
135135
@@ -148,7 +148,7 @@ def process(self):
148148
149149 self .era = self .process_type ('Era' )
150150
151- self .nonce = self .process_type ('Compact<U64 >' )
151+ self .nonce = self .process_type ('Compact<Index >' )
152152
153153 self .tip = self .process_type ('Compact<Balance>' )
154154
@@ -195,6 +195,7 @@ def process(self):
195195 result ['account_id' ] = self .address .account_id
196196 result ['account_index' ] = self .address .account_index
197197 result ['account_idx' ] = self .address .account_idx
198+ result ['signature_version' ] = self .signature_version .value
198199 result ['signature' ] = self .signature .value .replace ('0x' , '' )
199200 result ['extrinsic_hash' ] = self .extrinsic_hash
200201 if self .call_index :
@@ -216,14 +217,14 @@ def process(self):
216217 return result
217218
218219 def process_encode (self , value ):
219- # Check requirements
220+
220221 if 'call_index' in value :
221222 self .call_index = value ['call_index' ]
222223
223224 elif 'call_module' in value and 'call_function' in value :
224225 # Look up call module from metadata
225226 for call_index , (call_module , call ) in self .metadata .call_index .items ():
226- if call_module .name == value ['call_module' ] and call .name == value ['call_function' ]:
227+ if call_module .name . lower () == value ['call_module' ]. lower () and call .name == value ['call_function' ]:
227228 self .call_index = call_index
228229 self .call_module = call_module
229230 self .call = call
@@ -235,14 +236,44 @@ def process_encode(self, value):
235236 elif not self .call_module or not self .call :
236237 raise ValueError ('No call module and function specified' )
237238
239+ # Determine version (Fixed to V4 for now)
240+ if 'account_id' in value :
241+ self .version_info = '84'
242+ self .contains_transaction = True
243+ else :
244+ self .version_info = '04'
245+ self .contains_transaction = False
246+
238247 if self .contains_transaction :
239248 data = ScaleBytes ('0x84' )
240- raise NotImplementedError ('Encoding of signed extrinsics not supported' )
249+
250+ self .address = self .get_decoder_class ('Address' , metadata = self .metadata )
251+ data += self .address .encode (value ['account_id' ])
252+
253+ self .signature_version = self .get_decoder_class ('U8' , metadata = self .metadata )
254+ data += self .signature_version .encode (value ['signature_version' ])
255+
256+ self .signature = self .get_decoder_class ('Signature' , metadata = self .metadata )
257+ data += self .signature .encode ('0x{}' .format (value ['signature' ].replace ('0x' , '' )))
258+
259+ self .era = self .get_decoder_class ('Era' , metadata = self .metadata )
260+ data += self .era .encode (value ['era' ])
261+
262+ self .nonce = self .get_decoder_class ('Compact<Index>' , metadata = self .metadata )
263+ data += self .nonce .encode (value ['nonce' ])
264+
265+ self .tip = self .get_decoder_class ('Compact<Balance>' , metadata = self .metadata )
266+ data += self .tip .encode (value ['tip' ])
267+
241268 else :
242269 data = ScaleBytes ('0x04' )
243270
244271 data += ScaleBytes (bytearray .fromhex (self .call_index ))
245272
273+ # Convert params to call_args TODO refactor
274+ if not value .get ('call_args' ) and value .get ('params' ):
275+ value ['call_args' ] = {call_arg ['name' ]: call_arg ['value' ] for call_arg in value .get ('params' )}
276+
246277 # Encode call params
247278 if len (self .call .args ) > 0 :
248279 for arg in self .call .args :
@@ -254,7 +285,7 @@ def process_encode(self, value):
254285 arg_obj = self .get_decoder_class (arg .type , metadata = self .metadata )
255286 data += arg_obj .encode (param_value )
256287
257- # Wrap payload with een length Compact<u32>
288+ # Wrap payload with a length Compact<u32>
258289 length_obj = self .get_decoder_class ('Compact<u32>' )
259290 data = length_obj .encode (data .length ) + data
260291
0 commit comments