diff --git a/app/lib/common-libs/parsers/block.ts b/app/lib/common-libs/parsers/block.ts index 343095f485c87a77a7f6a79c6e52ecf5f9901ed1..04798f164d2c4ae2973e48f44cdafd14ba7b47f6 100644 --- a/app/lib/common-libs/parsers/block.ts +++ b/app/lib/common-libs/parsers/block.ts @@ -20,35 +20,79 @@ import {BlockDTO} from "../../dto/BlockDTO" export class BlockParser extends GenericParser { constructor() { - super([ - {prop: "version", regexp: CommonConstants.BLOCK.VERSION}, - {prop: "type", regexp: CommonConstants.BLOCK.TYPE}, - {prop: "currency", regexp: CommonConstants.BLOCK.CURRENCY}, - {prop: "number", regexp: CommonConstants.BLOCK.BNUMBER}, - {prop: "powMin", regexp: CommonConstants.BLOCK.POWMIN}, - {prop: "time", regexp: CommonConstants.BLOCK.TIME}, - {prop: "medianTime", regexp: CommonConstants.BLOCK.MEDIAN_TIME}, - {prop: "dividend", regexp: CommonConstants.BLOCK.UD}, - {prop: "unitbase", regexp: CommonConstants.BLOCK.UNIT_BASE}, - {prop: "issuer", regexp: CommonConstants.BLOCK.BLOCK_ISSUER}, - {prop: "issuersFrame", regexp: CommonConstants.BLOCK.BLOCK_ISSUERS_FRAME}, - {prop: "issuersFrameVar", regexp: CommonConstants.BLOCK.BLOCK_ISSUERS_FRAME_VAR}, - {prop: "issuersCount", regexp: CommonConstants.BLOCK.DIFFERENT_ISSUERS_COUNT}, - {prop: "parameters", regexp: CommonConstants.BLOCK.PARAMETERS}, - {prop: "previousHash", regexp: CommonConstants.BLOCK.PREV_HASH}, - {prop: "previousIssuer", regexp: CommonConstants.BLOCK.PREV_ISSUER}, - {prop: "membersCount", regexp: CommonConstants.BLOCK.MEMBERS_COUNT}, - {prop: "identities", regexp: /Identities:\n([\s\S]*)Joiners/, parser: splitAndMatch('\n', CommonConstants.IDENTITY.INLINE)}, - {prop: "joiners", regexp: /Joiners:\n([\s\S]*)Actives/, parser: splitAndMatch('\n', CommonConstants.BLOCK.JOINER)}, - {prop: "actives", regexp: /Actives:\n([\s\S]*)Leavers/, parser: splitAndMatch('\n', CommonConstants.BLOCK.ACTIVE)}, - {prop: "leavers", regexp: /Leavers:\n([\s\S]*)Excluded/, parser: splitAndMatch('\n', CommonConstants.BLOCK.LEAVER)}, - {prop: "revoked", regexp: /Revoked:\n([\s\S]*)Excluded/, parser: splitAndMatch('\n', CommonConstants.BLOCK.REVOCATION)}, - {prop: "excluded", regexp: /Excluded:\n([\s\S]*)Certifications/, parser: splitAndMatch('\n', CommonConstants.PUBLIC_KEY)}, - {prop: "certifications", regexp: /Certifications:\n([\s\S]*)Transactions/, parser: splitAndMatch('\n', CommonConstants.CERT.OTHER.INLINE)}, - {prop: "transactions", regexp: /Transactions:\n([\s\S]*)/, parser: extractTransactions}, - {prop: "inner_hash", regexp: CommonConstants.BLOCK.INNER_HASH}, - {prop: "nonce", regexp: CommonConstants.BLOCK.NONCE} - ], rawer.getBlock) + super( + [ + { prop: "version", regexp: CommonConstants.BLOCK.VERSION }, + { prop: "type", regexp: CommonConstants.BLOCK.TYPE }, + { prop: "currency", regexp: CommonConstants.BLOCK.CURRENCY }, + { prop: "number", regexp: CommonConstants.BLOCK.BNUMBER }, + { prop: "powMin", regexp: CommonConstants.BLOCK.POWMIN }, + { prop: "time", regexp: CommonConstants.BLOCK.TIME }, + { prop: "medianTime", regexp: CommonConstants.BLOCK.MEDIAN_TIME }, + { prop: "dividend", regexp: CommonConstants.BLOCK.UD }, + { prop: "unitbase", regexp: CommonConstants.BLOCK.UNIT_BASE }, + { prop: "issuer", regexp: CommonConstants.BLOCK.BLOCK_ISSUER }, + { + prop: "issuersFrame", + regexp: CommonConstants.BLOCK.BLOCK_ISSUERS_FRAME, + }, + { + prop: "issuersFrameVar", + regexp: CommonConstants.BLOCK.BLOCK_ISSUERS_FRAME_VAR, + }, + { + prop: "issuersCount", + regexp: CommonConstants.BLOCK.DIFFERENT_ISSUERS_COUNT, + }, + { prop: "parameters", regexp: CommonConstants.BLOCK.PARAMETERS }, + { prop: "previousHash", regexp: CommonConstants.BLOCK.PREV_HASH }, + { prop: "previousIssuer", regexp: CommonConstants.BLOCK.PREV_ISSUER }, + { prop: "membersCount", regexp: CommonConstants.BLOCK.MEMBERS_COUNT }, + { + prop: "identities", + regexp: /Identities:\n([\s\S]*)Joiners/, + parser: splitAndMatch("\n", CommonConstants.IDENTITY.INLINE), + }, + { + prop: "joiners", + regexp: /Joiners:\n([\s\S]*)Actives/, + parser: splitAndMatch("\n", CommonConstants.BLOCK.JOINER), + }, + { + prop: "actives", + regexp: /Actives:\n([\s\S]*)Leavers/, + parser: splitAndMatch("\n", CommonConstants.BLOCK.ACTIVE), + }, + { + prop: "leavers", + regexp: /Leavers:\n([\s\S]*)Excluded/, + parser: splitAndMatch("\n", CommonConstants.BLOCK.LEAVER), + }, + { + prop: "revoked", + regexp: /Revoked:\n([\s\S]*)Excluded/, + parser: splitAndMatch("\n", CommonConstants.BLOCK.REVOCATION), + }, + { + prop: "excluded", + regexp: /Excluded:\n([\s\S]*?)Certifications/, + parser: splitAndMatch("\n", CommonConstants.PUBLIC_KEY), + }, + { + prop: "certifications", + regexp: /Certifications:\n([\s\S]*)Transactions/, + parser: splitAndMatch("\n", CommonConstants.CERT.OTHER.INLINE), + }, + { + prop: "transactions", + regexp: /Transactions:\n([\s\S]*)/, + parser: extractTransactions, + }, + { prop: "inner_hash", regexp: CommonConstants.BLOCK.INNER_HASH }, + { prop: "nonce", regexp: CommonConstants.BLOCK.NONCE }, + ], + rawer.getBlock + ); } _clean(obj:any) {