@@ -112,7 +112,7 @@ def process(self):
112
112
113
113
self .era = self .process_type ('Era' )
114
114
115
- self .nonce = self .process_type ('Compact<U64 >' )
115
+ self .nonce = self .process_type ('Compact<Index >' )
116
116
117
117
self .tip = self .process_type ('Compact<Balance>' )
118
118
@@ -129,7 +129,7 @@ def process(self):
129
129
130
130
self .era = self .process_type ('Era' )
131
131
132
- self .nonce = self .process_type ('Compact<U64 >' )
132
+ self .nonce = self .process_type ('Compact<Index >' )
133
133
134
134
self .tip = self .process_type ('Compact<Balance>' )
135
135
@@ -148,7 +148,7 @@ def process(self):
148
148
149
149
self .era = self .process_type ('Era' )
150
150
151
- self .nonce = self .process_type ('Compact<U64 >' )
151
+ self .nonce = self .process_type ('Compact<Index >' )
152
152
153
153
self .tip = self .process_type ('Compact<Balance>' )
154
154
@@ -195,6 +195,7 @@ def process(self):
195
195
result ['account_id' ] = self .address .account_id
196
196
result ['account_index' ] = self .address .account_index
197
197
result ['account_idx' ] = self .address .account_idx
198
+ result ['signature_version' ] = self .signature_version .value
198
199
result ['signature' ] = self .signature .value .replace ('0x' , '' )
199
200
result ['extrinsic_hash' ] = self .extrinsic_hash
200
201
if self .call_index :
@@ -216,14 +217,14 @@ def process(self):
216
217
return result
217
218
218
219
def process_encode (self , value ):
219
- # Check requirements
220
+
220
221
if 'call_index' in value :
221
222
self .call_index = value ['call_index' ]
222
223
223
224
elif 'call_module' in value and 'call_function' in value :
224
225
# Look up call module from metadata
225
226
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' ]:
227
228
self .call_index = call_index
228
229
self .call_module = call_module
229
230
self .call = call
@@ -235,14 +236,44 @@ def process_encode(self, value):
235
236
elif not self .call_module or not self .call :
236
237
raise ValueError ('No call module and function specified' )
237
238
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
+
238
247
if self .contains_transaction :
239
248
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
+
241
268
else :
242
269
data = ScaleBytes ('0x04' )
243
270
244
271
data += ScaleBytes (bytearray .fromhex (self .call_index ))
245
272
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
+
246
277
# Encode call params
247
278
if len (self .call .args ) > 0 :
248
279
for arg in self .call .args :
@@ -254,7 +285,7 @@ def process_encode(self, value):
254
285
arg_obj = self .get_decoder_class (arg .type , metadata = self .metadata )
255
286
data += arg_obj .encode (param_value )
256
287
257
- # Wrap payload with een length Compact<u32>
288
+ # Wrap payload with a length Compact<u32>
258
289
length_obj = self .get_decoder_class ('Compact<u32>' )
259
290
data = length_obj .encode (data .length ) + data
260
291
0 commit comments