Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/user-brief-page
Browse files Browse the repository at this point in the history
  • Loading branch information
everGreenGH committed Jun 3, 2023
2 parents 9c7366b + 64bf902 commit edeff14
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 31 deletions.
21 changes: 14 additions & 7 deletions src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Test, TestingModule } from "@nestjs/testing";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { EtherscanApiService } from "./external-api/etherscan/etherscan-api.service";

describe('AppController', () => {
describe("AppController", () => {
let appController: AppController;

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
providers: [
AppService,
{
provide: EtherscanApiService,
useValue: {},
},
],
}).compile();

appController = app.get<AppController>(AppController);
});

describe('root', () => {
describe("root", () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
// expect(appController.getHello()).toBe("Hello World!");
});
});
});
10 changes: 8 additions & 2 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { Controller, Get } from "@nestjs/common";
import { Controller, Get, Query } from "@nestjs/common";
import { AppService } from "./app.service";
import { EtherscanApiService } from "./external-api/etherscan/etherscan-api.service";

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService, private readonly etherscanApiService: EtherscanApiService) {}

@Get()
getHello(): string {
return this.appService.getHello();
}

@Get("sync")
async syncTransactions(@Query("protocolAddress") protocolAddress: string) {
return await this.etherscanApiService.syncTransactions(protocolAddress);
}
}
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ConfigModule } from "@nestjs/config";
import * as path from "path";
import { ThrottlerModule } from "@nestjs/throttler";
import { TypeOrmModule } from "@nestjs/typeorm";
import postgresConfig from "@common/config/postgres.config";
import postgresConfig from "./common/config/postgres.config";
import { EtherscanApiModule } from "./external-api/etherscan/etherscan-api.module";
import etherscanApiConfig from "./common/config/etherscan.api.config";

Expand Down
5 changes: 3 additions & 2 deletions src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Injectable } from '@nestjs/common';
import { Injectable } from "@nestjs/common";
import { EtherscanApiService } from "./external-api/etherscan/etherscan-api.service";

@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
return "Hello World!";
}
}
6 changes: 3 additions & 3 deletions src/common/config/postgres.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Protocol } from "@common/database/entities/protocol.entity";
import { Transaction } from "@common/database/entities/transaction.entity";
import { Wallet } from "@common/database/entities/wallet.entity";
import { Protocol } from "../../common/database/entities/protocol.entity";
import { Transaction } from "../../common/database/entities/transaction.entity";
import { Wallet } from "../../common/database/entities/wallet.entity";
import { DataSourceOptions } from "typeorm";

export default () =>
Expand Down
8 changes: 4 additions & 4 deletions src/external-api/etherscan/etherscan-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { ConfigService } from "@nestjs/config";
import { EtherscanApiService } from "./etherscan-api.service";

import { HttpModule } from "@nestjs/axios";
import { EtherscanApiConfig } from "@common/config/etherscan.api.config";
import { EtherscanApiConfig } from "../../common/config/etherscan.api.config";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Transaction } from "@common/database/entities/transaction.entity";
import { Wallet } from "@common/database/entities/wallet.entity";
import { Protocol } from "@common/database/entities/protocol.entity";
import { Transaction } from "../../common/database/entities/transaction.entity";
import { Wallet } from "../../common/database/entities/wallet.entity";
import { Protocol } from "../../common/database/entities/protocol.entity";

@Module({
imports: [
Expand Down
10 changes: 5 additions & 5 deletions src/external-api/etherscan/etherscan-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { HttpService } from "@nestjs/axios";
import { ConfigService } from "@nestjs/config";
import { catchError, firstValueFrom } from "rxjs";
import { AxiosError } from "axios";
import { Transaction } from "@common/database/entities/transaction.entity";
import { Transaction } from "../../common/database/entities/transaction.entity";
import { Wallet } from "../../common/database/entities/wallet.entity";
import { Protocol } from "../../common/database/entities/protocol.entity";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Wallet } from "@common/database/entities/wallet.entity";
import { Protocol } from "@common/database/entities/protocol.entity";
import { ethers } from "ethers";

@Injectable()
Expand Down Expand Up @@ -146,7 +146,7 @@ export class EtherscanApiService {
}

const savedLastBlockNumber = transactions[0].blockNumber;
const lastBlockNumber = await this.getLastBlockNumberFromEtherscan(
const lastBlockNumber = await this._getLastBlockNumberFromEtherscan(
protocolAddress,
savedLastBlockNumber.toString(),
);
Expand All @@ -166,7 +166,7 @@ export class EtherscanApiService {
}
}

async getLastBlockNumberFromEtherscan(protocolAddress: string, savedBlockNumber: string): Promise<number> {
private async _getLastBlockNumberFromEtherscan(protocolAddress: string, savedBlockNumber: string): Promise<number> {
const request: EtherScanTxListRequest = {
address: protocolAddress,
startblock: savedBlockNumber,
Expand Down
6 changes: 3 additions & 3 deletions src/protocol/protocol.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from "@nestjs/common";
import { ProtocolService } from "./protocol.service";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Transaction } from "@common/database/entities/transaction.entity";
import { Wallet } from "@common/database/entities/wallet.entity";
import { Protocol } from "@common/database/entities/protocol.entity";
import { Transaction } from "../common/database/entities/transaction.entity";
import { Wallet } from "../common/database/entities/wallet.entity";
import { Protocol } from "../common/database/entities/protocol.entity";

@Module({
imports: [TypeOrmModule.forFeature([Transaction, Wallet, Protocol])],
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.dtos.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet } from "@common/database/entities/wallet.entity";
import { Wallet } from "../common/database/entities/wallet.entity";

export class WalletsByTimestampInterval {
startTimestamp: number;
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from "@nestjs/common";
import { WalletService } from "./wallet.service";
import { TypeOrmModule } from "@nestjs/typeorm";
import { Wallet } from "@common/database/entities/wallet.entity";
import { Transaction } from "@common/database/entities/transaction.entity";
import { Wallet } from "../common/database/entities/wallet.entity";
import { Transaction } from "../common/database/entities/transaction.entity";

@Module({
imports: [TypeOrmModule.forFeature([Transaction, Wallet])],
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { LessThan, Repository } from "typeorm";
import { Wallet } from "../common/database/entities/wallet.entity";
import { Transaction } from "@common/database/entities/transaction.entity";
import { Transaction } from "../common/database/entities/transaction.entity";
import { WalletsByTimestampInterval } from "./wallet.dtos";

@Injectable()
Expand Down

0 comments on commit edeff14

Please sign in to comment.