This is first release of this module. Readme under construction but here are a couple of tips
yarn add nest-caver
yarn add nest-caver
Register CaverModule module in yours app.module.ts
(or other main module of yours project)
import { Module } from '@nestjs/common';
import { CaverModule } from 'nest-caver';
@Module({
imports: [
CaverModule.forRoot({
name: 'klay',
url: 'http://localhost:3450',
}),
]
})
export class AppModule {}
Or with Async
import { Module } from '@nestjs/common';
import { CaverModule } from 'nest-caver';
@Module({
imports: [
CaverModule.forRootAsync({
useFactory: (configService: ConfigService) => configService.get('caver'),
inject:[ConfigService]
}),
]
})
export class AppModule {}
For now module accept two parameters:
export interface CaverModuleOptions {
name?: string;
url: string;
}
import { Injectable } from '@nestjs/common';
import { CaverService } from "nest-caver";
@Injectable()
export class SomeClass {
constructor(
private readonly caverService: CaverService
) {}
async method(): Promise<number> {
const client = this.caverService.getClient('klay'); // we are give name of client in config file
return await client.klay.getChainId();
}
}
Available methods and API of caver available here https://klaytn.gitbook.io/docs/bapp/sdk/caver-js