@@ -64,7 +64,7 @@ export class UInt128 implements Codec {
64
64
*/
65
65
populateFromBytes ( bytes : u8 [ ] , index : i32 = 0 ) : void {
66
66
assert ( bytes . length - index > 0 , 'Invalid input: Byte array should not be empty' ) ;
67
- const value = UInt128 . _computeValue ( bytes . slice ( index ) ) ;
67
+ const value = UInt128 . _computeValue ( bytes , index ) ;
68
68
this . _value = value ;
69
69
this . bitLength = UInt128 . _computeBitLength ( this . _value ) ;
70
70
}
@@ -80,15 +80,15 @@ export class UInt128 implements Codec {
80
80
* @param bytes
81
81
* @param index
82
82
*/
83
- static _computeValue ( bytes : u8 [ ] ) : u128 {
84
- const mode = bytes [ 0 ] & 0x03 ;
83
+ static _computeValue ( bytes : u8 [ ] , index : i32 = 0 ) : u128 {
84
+ const mode = bytes [ index ] & 0x03 ;
85
85
if ( i32 ( mode ) <= 2 ) {
86
- return new u128 ( u64 ( Bytes . decodeSmallInt ( bytes , mode , 0 ) . value ) , 0 ) ;
86
+ return new u128 ( u64 ( Bytes . decodeSmallInt ( bytes , mode , index ) . value ) , 0 ) ;
87
87
}
88
- const topSixBits = bytes [ 0 ] >> 2 ;
88
+ const topSixBits = bytes [ index ] >> 2 ;
89
89
const byteLength = topSixBits + 4 ;
90
90
91
- const value = bytes . slice ( 1 , byteLength + 1 ) ;
91
+ const value = bytes . slice ( index + 1 , byteLength + index + 1 ) ;
92
92
Bytes . appendZeroBytes ( value , BIT_LENGTH . INT_128 ) ;
93
93
return u128 . fromBytesLE ( value )
94
94
}
@@ -111,7 +111,7 @@ export class UInt128 implements Codec {
111
111
/** Instantiates new UInt128 from u8[] SCALE encoded bytes */
112
112
static fromU8a ( input : u8 [ ] , index : i32 = 0 ) : UInt128 {
113
113
assert ( input . length - index != 0 , 'Invalid input: Byte array should not be empty' ) ;
114
- return new UInt128 ( UInt128 . _computeValue ( input . slice ( index ) ) ) ;
114
+ return new UInt128 ( UInt128 . _computeValue ( input , index ) ) ;
115
115
}
116
116
117
117
@inline @operator ( '==' )
0 commit comments