Skip to content

Commit

Permalink
Add polygon network to monitor (#49)
Browse files Browse the repository at this point in the history
* add polygon address and model event

* add polling block service for polygon

* update env for polygon

* fix erc721 address lowercase

* export event history

* config polygon monitor servie

* fix polygon provider

* add polygon module

* add polygon monitor provider

* export provider

* fix env

* open provider

* open worker provider

* open polygon worker controller

* update blocksync

* Add provide for polygon monitor address model

* update log

* add await when emit transaction to catching error block

---------

Co-authored-by: thong.nguyen5 <[email protected]>
  • Loading branch information
cauta and thongnguyen5 committed Apr 28, 2024
1 parent fa40821 commit c168cf5
Show file tree
Hide file tree
Showing 26 changed files with 824 additions and 205 deletions.
9 changes: 7 additions & 2 deletions app/.env
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ WEBHOOK_API_URL=http://127.0.0.1:8000


# Blockchain environment variables
WEB3_PROVIDER_URL=https://goerli.infura.io/v3/d7aa2a84a44548819617058aa0a3e347
# WEB3_PROVIDER_URL=https://goerli.infura.io/v3/d7aa2a84a44548819617058aa0a3e347
ETH_PROVIDER_URL=https://atcrpc-dev.odw.ai
EVM_DISABLE=false
EVM_START_BLOCK=10199699
EVM_START_BLOCK_CONFIG=latest # 'config' or 'latest' or 'db'

MANTLE_WEB3_PROVIDER_URL=https://1rpc.io/4n4xz9Bow96oZU2n9/mantle
POLYGON_PROVIDER_URL=https://goerli.infura.io/v3/d7aa2a84a44548819617058aa0a3e347
POLYGON_DISABLE=false
POLYGON_START_BLOCK=56154832
POLYGON_START_BLOCK_CONFIG=latest # 'config' or 'latest' or 'db'

MANTLE_PROVIDER_URL=https://1rpc.io/4n4xz9Bow96oZU2n9/mantle
MANTLE_DISABLE=true
MANTLE_START_BLOCK=26620500
MANTLE_START_BLOCK_CONFIG=db # 'config' or 'latest' or 'db'
143 changes: 0 additions & 143 deletions app/apps/monitor-service/src/ethereum/dto/eth.webhook-delivery.dto.ts

This file was deleted.

18 changes: 0 additions & 18 deletions app/apps/monitor-service/src/ethereum/ethereum.controller.spec.ts

This file was deleted.

18 changes: 0 additions & 18 deletions app/apps/monitor-service/src/ethereum/ethereum.service.spec.ts

This file was deleted.

2 changes: 2 additions & 0 deletions app/apps/monitor-service/src/monitor-service.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { EthereumModule } from './ethereum/ethereum.module';
import { MonitorServiceController } from './monitor-service.controller';
import { PolygonModule } from './polygon/polygon.module';

@Module({
imports: [
Expand All @@ -11,6 +12,7 @@ import { MonitorServiceController } from './monitor-service.controller';
expandVariables: true,
}),
EthereumModule,
PolygonModule,
],
controllers: [MonitorServiceController],
providers: [],
Expand Down
24 changes: 24 additions & 0 deletions app/apps/monitor-service/src/polygon/polygon.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TopicName } from '@app/utils/topicUtils';
import { Controller } from '@nestjs/common';
import { EventPattern } from '@nestjs/microservices';
import { PolygonService } from './polygon.service';

@Controller()
export class PolygonController {
constructor(private readonly polygon: PolygonService) {}

@EventPattern(TopicName.POLYGON_NATIVE_TRANSFER)
handleNativeTransfer(data: any): void {
this.polygon.handleNativeTransfer(data);
}

@EventPattern(TopicName.POLYGON_ERC20_TRANSFER)
handleErc20Transfer(data: any): void {
this.polygon.handleErc20Transfer(data);
}

@EventPattern(TopicName.POLYGON_ERC721_TRANSFER)
handleErc721Transfer(data: any): void {
this.polygon.handleErc721Transfer(data);
}
}
38 changes: 38 additions & 0 deletions app/apps/monitor-service/src/polygon/polygon.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { EventHistoryModelModule } from '@app/shared_modules/event_history/event_history.module';
import { MonitorModule } from '@app/shared_modules/monitor/monitor.module';
import { ProjectModule } from '@app/shared_modules/project/project.module';
import { WebhookModule } from '@app/shared_modules/webhook/webhook.module';
import { Module } from '@nestjs/common';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { PolygonController } from './polygon.controller';
import { PolygonService } from './polygon.service';

@Module({
providers: [PolygonService],
controllers: [PolygonController],
exports: [PolygonService],
imports: [
ClientsModule.registerAsync([
{
name: 'WEBHOOK_SERVICE',
useFactory: () => ({
transport: Transport.KAFKA,
options: {
client: {
clientId: 'webhook',
brokers: process.env.KAFKA_BROKERS.split(','),
},
consumer: {
groupId: 'webhook-consumer',
},
},
}),
},
]),
WebhookModule,
MonitorModule,
ProjectModule,
EventHistoryModelModule,
],
})
export class PolygonModule {}
Loading

0 comments on commit c168cf5

Please sign in to comment.