import { Request , Response , NextFunction } from 'express' ; import { isHexString } from '@liskhq/lisk-validator' ; import { BaseChannel , PluginCodec } from 'lisk-framework' ; export const getAccount = ( channel , codec ) => async ( req , res , next ) : Promise < void > => { const accountAddress = req . params . address ; if ( ! isHexString ( accountAddress ) ) { res . status ( 400 ) . send ( { errors : [ { message : 'The Address parameter should be a hex string.' } ] , } ) ; return ; } try { const account = await channel . invoke ( 'app:getAccount' , { address : accountAddress , } ) ; res . status ( 200 ) . send ( { data : codec . decodeAccount ( account ) , meta : { } } ) ; } catch ( err ) { if ( ( err as Error ) . message . startsWith ( 'Specified key accounts:address' ) ) { res . status ( 404 ) . send ( { errors : [ { message : `Account with address '${ accountAddress }' was not found` } ] , } ) ; } else { next ( err ) ; } } } ;