@siglesiasg/node-red-hyperledger-fabric-gateway
Version:
Hyperledger Fabric 2.x nodes for node-red with latest fabric-gateway library
17 lines (12 loc) • 590 B
text/typescript
import { buildChannelInfoModel } from '../models/channel-info.model';
import { buildBlockEventModel } from '../models/block.model';
export type FabricDecoderType = (getResult: Uint8Array) => string;
export function buildGenericDecoder(): FabricDecoderType {
return (data) => new TextDecoder().decode(data);
}
export function buildChannelInfoDecoder(): FabricDecoderType {
return (data) => JSON.stringify(buildChannelInfoModel(data));
}
export function buildBlockDecoder(channel: string): FabricDecoderType {
return (data) => JSON.stringify(buildBlockEventModel(data, channel));
}