@@ -16,23 +16,26 @@ class LayoutSerializationUtils {
1616 return const SubstrateScaleCUintEncoder ().encode (value.toString ());
1717 }
1818
19- static Tuple <int , BigInt > decodeLength (List <int > bytes, {bool sign = false }) {
20- switch (bytes[0 ] & 0x03 ) {
19+ static Tuple <int , BigInt > decodeLength (List <int > bytes,
20+ {bool sign = false , int offset = 0 }) {
21+ final byte = bytes[offset];
22+
23+ switch (byte & 0x03 ) {
2124 case 0x00 :
22- return Tuple (1 , BigInt .from (bytes[ 0 ] ) >> 2 );
25+ return Tuple (1 , BigInt .from (byte ) >> 2 );
2326 case 0x01 :
24- final val = BigintUtils .fromBytes (bytes.sublist (0 , 2 ),
27+ final val = BigintUtils .fromBytes (bytes.sublist (offset, offset + 2 ),
2528 sign: sign, byteOrder: Endian .little);
2629 return Tuple (2 , val >> 2 );
2730 case 0x02 :
28- final val = BigintUtils .fromBytes (bytes.sublist (0 , 4 ),
31+ final val = BigintUtils .fromBytes (bytes.sublist (offset, offset + 4 ),
2932 sign: sign, byteOrder: Endian .little);
3033 return Tuple (4 , val >> 2 );
3134 default :
32- final int offset = (bytes[ 0 ] >> 2 ) + 5 ;
33- final val = BigintUtils .fromBytes (bytes.sublist (1 , offset),
35+ final int o = (byte >> 2 ) + 5 ;
36+ final val = BigintUtils .fromBytes (bytes.sublist (offset + 1 , offset + o ),
3437 sign: sign, byteOrder: Endian .little);
35- return Tuple (offset , val);
38+ return Tuple (o , val);
3639 }
3740 }
3841
0 commit comments