1
1
import { BigInt , log , store } from "@graphprotocol/graph-ts" ;
2
2
3
- import { BIG_INT_1E18 } from "const" ;
3
+ import { BIG_INT_1E18 , BIG_INT_ONE } from "const" ;
4
4
import {
5
5
Activated ,
6
6
ActivatedValidatorsUpdated ,
@@ -19,6 +19,7 @@ import {
19
19
createOrLoadDepositActivation ,
20
20
createOrLoadNetwork ,
21
21
createOrLoadOperator ,
22
+ createOrLoadOperatorAllocation ,
22
23
createOrLoadPool ,
23
24
createOrLoadValidator ,
24
25
getDepositActivationId ,
@@ -175,9 +176,11 @@ export function handleValidatorInitialized(event: ValidatorInitialized): void {
175
176
validator . registrationStatus = "Initialized" ;
176
177
validator . save ( ) ;
177
178
178
- operator . validatorsCount = operator . validatorsCount . plus (
179
- BigInt . fromString ( "1" )
180
- ) ;
179
+ let allocation = createOrLoadOperatorAllocation ( operator ) ;
180
+ allocation . validatorsCount = allocation . validatorsCount . plus ( BIG_INT_ONE ) ;
181
+ allocation . save ( ) ;
182
+
183
+ operator . validatorsCount = operator . validatorsCount . plus ( BIG_INT_ONE ) ;
181
184
operator . locked = true ;
182
185
operator . updatedAtBlock = event . block . number ;
183
186
operator . updatedAtTimestamp = event . block . timestamp ;
@@ -202,24 +205,24 @@ export function handleValidatorRegistered(event: ValidatorRegistered): void {
202
205
let validator = createOrLoadValidator ( event . params . publicKey ) ;
203
206
204
207
let pool = createOrLoadPool ( ) ;
205
- pool . pendingValidators = pool . pendingValidators . plus ( BigInt . fromString ( "1" ) ) ;
208
+ pool . pendingValidators = pool . pendingValidators . plus ( BIG_INT_ONE ) ;
206
209
207
210
if ( validator . registrationStatus == "Uninitialized" ) {
208
211
// compatibility with v1 contracts
209
212
pool . balance = pool . balance . minus (
210
213
BigInt . fromString ( "32" ) . times ( BIG_INT_1E18 )
211
214
) ;
212
- operator . validatorsCount = operator . validatorsCount . plus (
213
- BigInt . fromString ( "1" )
214
- ) ;
215
+ operator . validatorsCount = operator . validatorsCount . plus ( BIG_INT_ONE ) ;
216
+
217
+ let allocation = createOrLoadOperatorAllocation ( operator ) ;
218
+ allocation . validatorsCount = allocation . validatorsCount . plus ( BIG_INT_ONE ) ;
219
+ allocation . save ( ) ;
215
220
} else {
216
221
// finalization is done with 31 ether deposit to the eth2 contract
217
222
pool . balance = pool . balance . minus (
218
223
BigInt . fromString ( "31" ) . times ( BIG_INT_1E18 )
219
224
) ;
220
- operator . depositDataIndex = operator . depositDataIndex . plus (
221
- BigInt . fromString ( "1" )
222
- ) ;
225
+ operator . depositDataIndex = operator . depositDataIndex . plus ( BIG_INT_ONE ) ;
223
226
operator . locked = false ;
224
227
}
225
228
pool . save ( ) ;
0 commit comments