import { ByteArray , BytesReader , Codec } from "as-scale-codec" ; import { Storage , Utils } from "subsembly-core" ; description export class StorageEntry < T extends Codec > { /**
     * Module prefix
     */ private prefix : string ; /**
     * Key name
     */ private key : string ; constructor ( prefix , key ) { this . prefix = prefix ; this . key = key ; } description param suffix get ( suffix = null ) { const value = Storage . get ( Utils . getHashedKey ( this . prefix , this . key , suffix ) ) ; if ( value . isSome ( ) ) { return BytesReader . decodeInto < T > ( ( < ByteArray > value . unwrap ( ) ) . unwrap ( ) ) ; } return instantiate < T > ( ) ; } description param value param append set ( value , suffix = null ) { const key = Utils . getHashedKey ( this . prefix , this . key , suffix ) ; Storage . set ( key , value . toU8a ( ) ) ; } description param suffix clear ( suffix = null ) { const key = Utils . getHashedKey ( this . prefix , this . key , suffix ) ; Storage . clear ( key ) ; } description param suffix take ( suffix = null ) { const value = Storage . take ( Utils . getHashedKey ( this . prefix , this . key , suffix ) ) ; return value . length ? BytesReader . decodeInto < T > ( value ) : instantiate < T > ( ) ; } }