import { u128 } from "as-bignum" ; import { BytesReader , CompactInt } from ".." ; import { DecodedData } from "../interfaces/DecodedData" ; import { UInt128 } from "../UInt/UInt128" ; import { BIT_LENGTH } from "../utils/Bytes" ; import { AbstractArray } from "./AbstractArray" ; export class UInt128Array extends AbstractArray < UInt128 , u128 > { description public decodeElement ( value ) { const u128Instance = UInt128 . fromU8a ( value ) ; return new DecodedData < u128 > ( u128Instance . unwrap ( ) , u128Instance . encodedLength ( ) ) ; } description param bytes param index populateFromBytes ( bytes , index = 0 ) { const bytesReader = new BytesReader ( bytes . slice ( index ) ) ; const data = bytesReader . readInto < CompactInt > ( ) ; for ( let i = 0 ; i < data . unwrap ( ) ; i ++ ) { const element = bytesReader . readInto < UInt128 > ( ) ; this . values . push ( element . unwrap ( ) ) ; } } description static fromU8a ( input ) { return AbstractArray . fromU8a < UInt128Array > ( input ) ; } description public encodedLength ( ) { return ( new CompactInt ( this . values . length ) . encodedLength ( ) ) + super . values . length * BIT_LENGTH . INT_128 ; } @ inline @ operator ( "==" ) static eq ( a , b ) { return a . eq ( b ) ; } @ inline @ operator ( "!=" ) static notEq ( a , b ) { return a . notEq ( b ) ; } }