import { UnwrappableCodec } from "./interfaces/UnwrappableCodec" ; import { BIT_LENGTH } from "./utils/Bytes" ; export class Byte implements UnwrappableCodec < u8 > { private _value : u8 ; protected bitLength : i32 ; constructor ( value = 0 ) { this . _value = value ; this . bitLength = BIT_LENGTH . INT_8 ; } description public unwrap ( ) { return this . _value ; } description public toU8a ( ) { return [ this . _value ] ; } description param bytes param index public populateFromBytes ( bytes , index = 0 ) { assert ( bytes . length - index > 0 , 'Bool: Cannot decode invalid input' ) ; this . _value = bytes [ index ] ; } eq ( other ) { return this . _value == other . unwrap ( ) ; } notEq ( other ) { return this . _value != other . unwrap ( ) ; } description public encodedLength ( ) { return this . bitLength ; } /** Instantiates new Byte from u8[] SCALE encoded bytes */ static fromU8a ( value , index = 0 ) { assert ( value . length - index > 0 , 'Byte: cannot decode invalid type' ) ; return new Byte ( value [ index ] ) ; } @ inline @ operator ( '==' ) static eq ( a , b ) { return a . eq ( b ) ; } @ inline @ operator ( '!=' ) static notEq ( a , b ) { return a . notEq ( b ) ; } toU8aPacked ( ) { return this . toU8a ( ) ; } encodedLengthPacked ( ) { return this . encodedLength ( ) ; } populateFromPackedBytes ( bytes , index = 0 ) { this . populateFromBytes ( bytes , index ) ; } }