File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,34 @@ export class IndexerService {
110110 } else {
111111 this . logger . log ( `Bootstrap: existed tokenFactory=${ indexerState . name } , blockNumber=${ indexerState . blockNumber } ` )
112112 }
113+
114+ try {
115+ // create initial competition id = 1
116+ const contract = new this . web3 . eth . Contract ( TokenFactoryABI , address ) ;
117+ const currentCompetitionId = await contract . methods
118+ . currentCompetitionId ( )
119+ . call ( ) as bigint
120+ if ( currentCompetitionId === 1n ) {
121+ const [ initialCompetition ] = await this . appService
122+ . getCompetitions ( { competitionId : Number ( currentCompetitionId ) } )
123+ if ( ! initialCompetition ) {
124+ const block = await this . web3 . eth . getBlock ( blockNumber )
125+ await this . dataSource . manager . insert ( CompetitionEntity , {
126+ txnHash : '' ,
127+ blockNumber : blockNumber ,
128+ tokenFactoryAddress : address ,
129+ competitionId : Number ( currentCompetitionId ) ,
130+ timestampStart : Number ( block . timestamp ) ,
131+ timestampEnd : null ,
132+ isCompleted : false ,
133+ winnerToken : null ,
134+ } ) ;
135+ this . logger . log ( `INITIAL NewCompetitionStarted: competitionId=${ 1 } , timestamp=${ Number ( block . timestamp ) } ` ) ;
136+ }
137+ }
138+ } catch ( e ) {
139+
140+ }
113141 }
114142
115143 return tokenFactories
You can’t perform that action at this time.
0 commit comments