How to use the @requestnetwork/utils.SimpleLogger function in @requestnetwork/utils

To help you get started, we’ve selected a few @requestnetwork/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RequestNetwork / requestNetwork / packages / request-node / src / requestNode.ts View on Github external
constructor(logger?: LogTypes.ILogger) {
    this.initialized = false;

    this.logger = logger || new Utils.SimpleLogger();

    const initializationStoragePath = getInitializationStorageFilePath();

    const store = initializationStoragePath
      ? new KeyvFile({
          filename: initializationStoragePath,
        })
      : undefined;

    // Use ethereum storage for the storage layer
    const ethereumStorage: StorageTypes.IStorage = getEthereumStorage(
      getMnemonic(),
      this.logger,
      store,
    );
github RequestNetwork / requestNetwork / packages / ethereum-storage / src / ethereum-blocks.ts View on Github external
public constructor(
    eth: any,
    firstSignificantBlockNumber: number,
    retryDelay: number,
    maxRetries: number,
    getLastBlockNumberMinDelay: number = 0,
    logger?: LogTypes.ILogger,
  ) {
    this.eth = eth;

    this.firstSignificantBlockNumber = firstSignificantBlockNumber;

    this.getLastBlockNumberMinDelay = getLastBlockNumberMinDelay;

    this.logger = logger || new Utils.SimpleLogger();

    // Get retry parameter values from config
    this.retryDelay = retryDelay;
    this.maxRetries = maxRetries;

    // Setup the throttled and retriable getLastBlockNumber function
    this.getLastBlockNumber = Utils.cachedThrottle(
      () =>
        Utils.retry(
          () => {
            this.logger.debug(`Getting last block number`, ['ethereum', 'ethereum-blocks']);
            return this.eth.getBlockNumber();
          },
          {
            maxRetries: this.maxRetries,
            retryDelay: this.retryDelay,
github RequestNetwork / requestNetwork / packages / ethereum-storage / src / smart-contract-manager.ts View on Github external
getLastBlockNumberDelay,
      logger,
      maxRetries,
      retryDelay,
    }: {
      maxConcurrency: number;
      logger?: LogTypes.ILogger;
      getLastBlockNumberDelay?: number;
      maxRetries?: number;
      retryDelay?: number;
    } = {
      maxConcurrency: Number.MAX_SAFE_INTEGER,
    },
  ) {
    this.maxConcurrency = maxConcurrency;
    this.logger = logger || new Utils.SimpleLogger();

    this.maxRetries = maxRetries;
    this.retryDelay = retryDelay;

    web3Connection = web3Connection || {};

    try {
      this.eth = new web3Eth(
        web3Connection.web3Provider ||
          new web3Eth.providers.HttpProvider(config.getDefaultEthereumProvider()),
      );
    } catch (error) {
      throw Error(`Can't initialize web3-eth ${error}`);
    }

    // Checks if networkId is defined
github RequestNetwork / requestNetwork / packages / data-access / src / data-access.ts View on Github external
public constructor(storage: StorageTypes.IStorage, options?: IDataAccessOptions) {
    const defaultOptions: IDataAccessOptions = {
      logger: new Utils.SimpleLogger(),
      synchronizationIntervalTime: DEFAULT_INTERVAL_TIME,
      transactionIndex: new TransactionIndex(),
    };
    options = {
      ...defaultOptions,
      ...options,
    };
    this.storage = storage;
    this.lastSyncStorageTimestamp = 0;
    this.synchronizationTimer = new IntervalTimer(
      (): Promise => this.synchronizeNewDataIds(),
      options.synchronizationIntervalTime!,
      options.logger!,
      5,
    );
    this.transactionIndex = options.transactionIndex!;
github RequestNetwork / requestNetwork / packages / ethereum-storage / src / gas-price-definer.ts View on Github external
public constructor(logger?: LogTypes.ILogger) {
    this.logger = logger || new Utils.SimpleLogger();
  }
github RequestNetwork / requestNetwork / packages / ethereum-storage / src / ethereum-storage.ts View on Github external
getLastBlockNumberDelay,
      logger,
      maxConcurrency,
      maxRetries,
      retryDelay,
    }: {
      getLastBlockNumberDelay?: number;
      logger?: LogTypes.ILogger;
      maxConcurrency?: number;
      maxRetries?: number;
      retryDelay?: number;
    } = {},
    metadataStore?: Keyv.Store,
  ) {
    this.maxConcurrency = maxConcurrency || getMaxConcurrency();
    this.logger = logger || new Utils.SimpleLogger();
    this.ipfsManager = new IpfsManager(ipfsGatewayConnection);
    this.smartContractManager = new SmartContractManager(web3Connection, {
      getLastBlockNumberDelay,
      logger: this.logger,
      maxConcurrency: this.maxConcurrency,
      maxRetries,
      retryDelay,
    });
    this.ethereumMetadataCache = new EthereumMetadataCache(
      this.smartContractManager,
      metadataStore,
    );
  }