Skip to content
Snippets Groups Projects
Select Git revision
  • ecb32a8a436202cfa0cca51ec53f90a28f3ba2c3
  • main default protected
  • pages protected
  • release/0.12 protected
  • 429_rm_features
  • release/0.11 protected
  • 175_gva_migration
  • i18n
  • v0.12.1 protected
  • v0.12.0 protected
  • v0.11.2 protected
  • v0.11.1 protected
  • v0.11.0 protected
  • v0.11.0rc0 protected
  • v0.10.0 protected
  • v0.10.0rc1 protected
  • v0.10.0rc0 protected
  • v0.3.0 protected
  • v0.8.1 protected
  • v0.9.0 protected
  • v0.9.0rc protected
  • v0.8.0 protected
  • v0.7.6 protected
  • v0.7.5 protected
  • v0.7.4 protected
  • v0.7.3 protected
  • v0.7.2 protected
  • v0.7.1 protected
28 results

test_auth.py

Blame
  • data_handler.ts 26.50 KiB
    import { strict as assert } from 'assert';
    import { In } from "typeorm";
    import {
      Account,
      Cert,
      CertEvent,
      ChangeOwnerKey,
      Event,
      EventType,
      Identity,
      IdentityStatus,
      MembershipEvent,
      SmithEvent,
      SmithEventType,
      Smith,
      SmithCert,
      SmithStatus,
      PopulationHistory,
      Transfer,
      TxComment,
      UdReeval,
      UniversalDividend,
      Validator,
    } from "./model";
    import { Address, Ctx, Data, IdtyIndex, NewData } from "./types_custom";
    import { hexToString } from "./utils";
    import { events } from "./types";
    import { getCommentType } from "./comment";
    
    export class DataHandler {
      private data: Data;
    
      constructor() {
        this.data = {
          accounts: new Map(),
          identities: new Map(),
          smiths: new Map(),
          populationHistories: [],
          validators: new Map(),
          membershipEvents: [],
          smithEvents: [],
          changeOwnerKey: [],
          transfers: new Map(),
          certification: new Map(),
          certEvent: [],
          smithCert: new Map(),
          universalDividend: [],
          udReeval: [],
          comments: []
        };
      }
    
      async processNewData(newData: NewData, ctx: Ctx) {
    
        // Process population history by adding the value
        // of the last point in database.
        if (newData.populationHistories) {
          const lastHistory = await ctx.store.findOneOrFail(PopulationHistory, {
            where: {},
            order: { blockNumber: 'DESC' }
          });
    
          this.data.populationHistories = newData.populationHistories.map(history => (new PopulationHistory({
            activeAccountCount: history.activeAccountCount + lastHistory.activeAccountCount,
            memberCount: history.memberCount + lastHistory.memberCount,
            smithCount: history.smithCount + lastHistory.smithCount,
            blockNumber: history.blockNumber,
            id: `population-${history.blockNumber}`,
          })));
        }