@@ -23,21 +23,26 @@ async def layout(
2323 return None
2424
2525 @staticmethod
26- def _readAccountIdLookupOfT_V15 (rawtx : codec .base .ScaleBytes , address_type ) -> str :
27- value = rawtx .get_next_bytes (1 )[0 ]
28- if value == 0 : # Id
26+ def _readAccountIdLookupOfT_V15 (
27+ rawtx : codec .base .ScaleBytes , address_type , skip_type_lookup : bool = False
28+ ) -> str :
29+ if not skip_type_lookup :
30+ value = rawtx .get_next_bytes (1 )[0 ]
31+ else :
32+ value = 0
33+ if value == 0 :
2934 accountid = helper .ss58_encode (rawtx .get_next_bytes (32 ), address_type )
30- elif value == 1 : # Index
35+ elif value == 1 :
3136 obj = codec .types .Compact (rawtx )
3237 accountid = str (obj .decode (check_remaining = False ))
33- elif value == 2 : # Raw
38+ elif value == 2 :
3439 obj = codec .types .Compact (rawtx )
3540 value = obj .decode (check_remaining = False )
3641 clen = int (0 if value is None else value )
3742 accountid = hexlify (rawtx .get_next_bytes (clen )).decode ()
38- elif value == 3 : # Address32
43+ elif value == 3 :
3944 accountid = hexlify (rawtx .get_next_bytes (32 )).decode ()
40- elif value == 4 : # Address20
45+ elif value == 4 :
4146 accountid = hexlify (rawtx .get_next_bytes (20 )).decode ()
4247 else :
4348 raise Exception ("Unexpected value" )
@@ -49,23 +54,23 @@ def deserialize_polkadot(
4954 rawtx : codec .base .ScaleBytes , callPrivIdx : int
5055 ) -> "Transaction" :
5156 tx = TransactionUnknown (rawtx )
52- if callPrivIdx in (1287 , 1280 ):
57+ if callPrivIdx in (1287 , 1280 , 2560 ):
5358 desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 0 )
5459 obj = codec .types .Compact (rawtx )
5560 balance = obj .decode (check_remaining = False )
5661 tx = BalancesTransfer (desc , balance )
57- elif callPrivIdx == 1282 :
62+ elif callPrivIdx in ( 1282 , 2562 ) :
5863 source = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 0 )
5964 dest = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 0 )
6065 obj = codec .types .Compact (rawtx )
6166 balance = obj .decode (check_remaining = False )
6267 tx = BalancesForceTransfer (source , dest , balance )
63- elif callPrivIdx == 1283 :
68+ elif callPrivIdx in ( 1283 , 2563 ) :
6469 desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 0 )
6570 obj = codec .types .Compact (rawtx )
6671 balance = obj .decode (check_remaining = False )
6772 tx = BalancesTransferKeepAlive (desc , balance )
68- elif callPrivIdx == 1284 :
73+ elif callPrivIdx in ( 1284 , 2564 ) :
6974 desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 0 )
7075 keep_alive = rawtx .get_next_bytes (1 )[0 ]
7176 tx = BalancesTransferAll (desc , keep_alive )
@@ -77,23 +82,23 @@ def deserialize_kusama(
7782 rawtx : codec .base .ScaleBytes , callPrivIdx : int
7883 ) -> "Transaction" :
7984 tx = TransactionUnknown (rawtx )
80- if callPrivIdx in (1031 , 1024 ):
85+ if callPrivIdx in (1031 , 1024 , 2560 ):
8186 desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 2 )
8287 obj = codec .types .Compact (rawtx )
8388 balance = obj .decode (check_remaining = False )
8489 tx = BalancesTransfer (desc , balance )
85- elif callPrivIdx == 1026 :
90+ elif callPrivIdx in ( 1026 , 2562 ) :
8691 source = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 2 )
8792 dest = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 2 )
8893 obj = codec .types .Compact (rawtx )
8994 balance = obj .decode (check_remaining = False )
9095 tx = BalancesForceTransfer (source , dest , balance )
91- elif callPrivIdx == 1027 :
96+ elif callPrivIdx in ( 1027 , 2563 ) :
9297 desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 2 )
9398 obj = codec .types .Compact (rawtx )
9499 balance = obj .decode (check_remaining = False )
95100 tx = BalancesTransferKeepAlive (desc , balance )
96- elif callPrivIdx == 1028 :
101+ elif callPrivIdx in ( 1028 , 2564 ) :
97102 desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 2 )
98103 keep_alive = rawtx .get_next_bytes (1 )[0 ]
99104 tx = BalancesTransferAll (desc , keep_alive )
@@ -162,47 +167,101 @@ def deserialize_joy(
162167 ) -> "Transaction" :
163168 tx = TransactionUnknown (rawtx )
164169 if callPrivIdx == 1280 :
165- dest = helper .ss58_encode (rawtx .get_next_bytes (32 ), 126 )
170+ dest = Transaction ._readAccountIdLookupOfT_V15 (
171+ rawtx , 126 , skip_type_lookup = True
172+ )
166173 obj = codec .types .Compact (rawtx )
167174 balance = obj .decode (check_remaining = False )
168175 tx = BalancesTransfer (dest , balance )
176+ elif callPrivIdx == 1282 :
177+ source = Transaction ._readAccountIdLookupOfT_V15 (
178+ rawtx , 126 , skip_type_lookup = True
179+ )
180+ dest = Transaction ._readAccountIdLookupOfT_V15 (
181+ rawtx , 126 , skip_type_lookup = True
182+ )
183+ obj = codec .types .Compact (rawtx )
184+ balance = obj .decode (check_remaining = False )
185+ tx = BalancesForceTransfer (source , dest , balance )
169186 elif callPrivIdx == 1283 :
170- dest = helper .ss58_encode (rawtx .get_next_bytes (32 ), 126 )
187+ dest = Transaction ._readAccountIdLookupOfT_V15 (
188+ rawtx , 126 , skip_type_lookup = True
189+ )
171190 obj = codec .types .Compact (rawtx )
172191 balance = obj .decode (check_remaining = False )
173192 tx = BalancesTransferKeepAlive (dest , balance )
174193 elif callPrivIdx == 1284 :
175- dest = helper .ss58_encode (rawtx .get_next_bytes (32 ), 126 )
194+ dest = Transaction ._readAccountIdLookupOfT_V15 (
195+ rawtx , 126 , skip_type_lookup = True
196+ )
176197 keep_alive = rawtx .get_next_bytes (1 )[0 ]
177198 tx = BalancesTransferAll (dest , keep_alive )
178199
179200 return tx
180201
181202 @staticmethod
182203 def deserialize_manta (
183- rawtx : codec .base .ScaleBytes , callPrivIdx : int
204+ rawtx : codec .base .ScaleBytes , callPrivIdx : int , address_type : int
184205 ) -> "Transaction" :
185206 tx = TransactionUnknown (rawtx )
186207 if callPrivIdx == 2560 :
187- desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 77 )
208+ desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , address_type )
188209 obj = codec .types .Compact (rawtx )
189210 balance = obj .decode (check_remaining = False )
190211 tx = BalancesTransfer (desc , balance )
212+ elif callPrivIdx == 2562 :
213+ source = Transaction ._readAccountIdLookupOfT_V15 (rawtx , address_type )
214+ dest = Transaction ._readAccountIdLookupOfT_V15 (rawtx , address_type )
215+ obj = codec .types .Compact (rawtx )
216+ balance = obj .decode (check_remaining = False )
217+ tx = BalancesForceTransfer (source , dest , balance )
191218 elif callPrivIdx == 2563 :
192- desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 77 )
219+ desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , address_type )
193220 obj = codec .types .Compact (rawtx )
194221 balance = obj .decode (check_remaining = False )
195222 tx = BalancesTransferKeepAlive (desc , balance )
196223 elif callPrivIdx == 2564 :
197- desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 77 )
224+ desc = Transaction ._readAccountIdLookupOfT_V15 (rawtx , address_type )
198225 keep_alive = rawtx .get_next_bytes (1 )[0 ]
199226 tx = BalancesTransferAll (desc , keep_alive )
200- elif callPrivIdx == 2562 :
201- source = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 77 )
202- dest = Transaction ._readAccountIdLookupOfT_V15 (rawtx , 77 )
227+
228+ return tx
229+
230+ @staticmethod
231+ def deserialize_hydration (
232+ rawtx : codec .base .ScaleBytes , callPrivIdx : int
233+ ) -> "Transaction" :
234+ tx = TransactionUnknown (rawtx )
235+ if callPrivIdx == 1792 :
236+ desc = Transaction ._readAccountIdLookupOfT_V15 (
237+ rawtx , 0 , skip_type_lookup = True
238+ )
239+ obj = codec .types .Compact (rawtx )
240+ balance = obj .decode (check_remaining = False )
241+ tx = BalancesTransfer (desc , balance )
242+ elif callPrivIdx == 1794 :
243+ source = Transaction ._readAccountIdLookupOfT_V15 (
244+ rawtx , 0 , skip_type_lookup = True
245+ )
246+ dest = Transaction ._readAccountIdLookupOfT_V15 (
247+ rawtx , 0 , skip_type_lookup = True
248+ )
203249 obj = codec .types .Compact (rawtx )
204250 balance = obj .decode (check_remaining = False )
205251 tx = BalancesForceTransfer (source , dest , balance )
252+ elif callPrivIdx == 1795 :
253+ desc = Transaction ._readAccountIdLookupOfT_V15 (
254+ rawtx , 0 , skip_type_lookup = True
255+ )
256+ obj = codec .types .Compact (rawtx )
257+ balance = obj .decode (check_remaining = False )
258+ tx = BalancesTransferKeepAlive (desc , balance )
259+ elif callPrivIdx == 1796 :
260+ desc = Transaction ._readAccountIdLookupOfT_V15 (
261+ rawtx , 0 , skip_type_lookup = True
262+ )
263+ keep_alive = rawtx .get_next_bytes (1 )[0 ]
264+ tx = BalancesTransferAll (desc , keep_alive )
206265
207266 return tx
208267
@@ -224,8 +283,14 @@ def deserialize(raw_tx: bytes, network: str) -> "Transaction":
224283 tx = Transaction .deserialize_astar (rawtx , callPrivIdx )
225284 elif network == "joystream" :
226285 tx = Transaction .deserialize_joy (rawtx , callPrivIdx )
227- elif network == "manta" :
228- tx = Transaction .deserialize_manta (rawtx , callPrivIdx )
286+ elif network in ("manta" , "bifrost" , "bifrost-ksm" ):
287+ if network == "manta" :
288+ address_type = 77
289+ else :
290+ address_type = 0
291+ tx = Transaction .deserialize_manta (rawtx , callPrivIdx , address_type )
292+ elif network == "hydration" :
293+ tx = Transaction .deserialize_hydration (rawtx , callPrivIdx )
229294 else :
230295 tx = TransactionUnknown (rawtx )
231296
@@ -248,6 +313,9 @@ def deserialize(raw_tx: bytes, network: str) -> "Transaction":
248313 tip = obj .decode (check_remaining = False )
249314 tx .tip = tip if tip is not None else 0
250315
316+ # optional: assetId(asset location if assetId is not equal to 0)
317+ # optional: mode
318+
251319 return tx
252320
253321
0 commit comments