Screenshot of the error after trying the solution I get the following error
Cannot read properties of undefined (reading 'get')
Here is my code from the files.
@Injectable()
export class EVMService {
public web3: Web3;
@Inject(ConfigService)
private readonly configService: ConfigService;
constructor(@Optional() public chain: AvailableChains) {
let jsonRPC: null | string = null;
switch (chain) {
case AvailableChains.BNB:
jsonRPC = this.configService.get<string>('BNB_RPC_URL');
break;
case AvailableChains.ETH:
jsonRPC = this.configService.get<string>('ETH_RPC_URL');
default:
break;
}
this.web3 = new Web3(jsonRPC);
}
}
@Injectable()
export class BinanceService extends EVMService {
constructor() {
super(AvailableChains.BNB);
}
}
@Global()
@Module({
providers: [
SharedService,
EncryptionService,
EVMService,
],
exports: [SharedService],
})
export class SharedModule {}
I am expecting to the get the data from the config as it is declared globally.