@poolsea-nestjs/execution
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Execution layer (Eth1 RPC Provider)

NestJS Logger for Lido Finance projects. Part of Lido NestJS Modules

Install

yarn add @poolsea-nestjs/execution

Usage

Basic usage

// Import
import { Injectable, Module } from '@nestjs/common';
import { FallbackProviderModule } from '@poolsea-nestjs/execution';
import { MyService } from './my.service';

@Module({
  imports: [
    LoggerModule.forRoot({}),
    FallbackProviderModule.forRoot({
      imports: [],
      urls: ['http://localhost:8545', 'http://fallback:8545'],
      network: 1,
    }),
  ],
  providers: [MyService],
  exports: [MyService],
})
export class MyModule {}

// Usage
import { SimpleFallbackJsonRpcBatchProvider } from '@poolsea-nestjs/execution';

@Injectable
export class MyService {
  constructor(private provider: SimpleFallbackJsonRpcBatchProvider) {}

  async doSomeWork() {
    return await this.provider.getBlock(1000);
  }
}

Async usage

import { Module } from '@nestjs/common';
import { FallbackProviderModule } from '@poolsea-nestjs/execution';
import { ConfigModule, ConfigService } from './my.service';

@Module({
  imports: [
    ConfigModule.forRoot(), // exports ConfigService
    FetchModule.forRoot(),
    FallbackProviderModule.forRootAsync({
      async useFactory(configService: ConfigService) {
        return {
          urls: configService.urls,
          network: configService.network,
        };
      },
      inject: [ConfigService],
    }),
  ],
})
export class MyModule {}

// Usage
import { SimpleFallbackJsonRpcBatchProvider } from '@poolsea-nestjs/execution';

@Injectable
export class MyService {
    constructor(private provider: SimpleFallbackJsonRpcBatchProvider) {}

    async doSomeWork() {
        return await this.provider.getBlock(1000);
    }
}

Package Sidebar

Install

npm i @poolsea-nestjs/execution

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

63.3 kB

Total Files

51

Last publish

Collaborators

  • gomel-tdl1