@@ -47,7 +47,7 @@ import mapValues from 'lodash.mapvalues'
4747import zip from 'lodash.zip'
4848import { AgentConfigs , NetworkAndOperator } from './types'
4949
50- type ActionReconciliationContext = [ AllocationDecision [ ] , number , number ]
50+ type ActionReconciliationContext = [ AllocationDecision [ ] , number , bigint ]
5151
5252const deploymentInList = (
5353 list : SubgraphDeploymentID [ ] ,
@@ -270,15 +270,15 @@ export class Agent {
270270 } ,
271271 )
272272
273- const maxAllocationEpochs : Eventual < NetworkMapped < number > > =
273+ const maxAllocationEpochs : Eventual < NetworkMapped < bigint > > =
274274 sequentialTimerMap (
275275 { logger, milliseconds : requestIntervalLarge } ,
276276 ( ) =>
277277 this . multiNetworks . map ( ( { network } ) => {
278278 logger . trace ( 'Fetching max allocation epochs' , {
279279 protocolNetwork : network . specification . networkIdentifier ,
280280 } )
281- return network . contracts . staking . maxAllocationEpochs ( )
281+ return network . contracts . LegacyStaking . maxAllocationEpochs ( )
282282 } ) ,
283283 {
284284 onError : error =>
@@ -304,9 +304,9 @@ export class Agent {
304304 await network . networkMonitor . subgraphs ( subgraphRuleIds )
305305 if ( subgraphsMatchingRules . length >= 1 ) {
306306 const epochLength =
307- await network . contracts . epochManager . epochLength ( )
307+ await network . contracts . EpochManager . epochLength ( )
308308 const blockPeriod = 15
309- const bufferPeriod = epochLength . toNumber ( ) * blockPeriod * 100 // 100 epochs
309+ const bufferPeriod = Number ( epochLength ) * blockPeriod * 100 // 100 epochs
310310 rules = convertSubgraphBasedRulesToDeploymentBased (
311311 rules ,
312312 subgraphsMatchingRules ,
@@ -486,7 +486,7 @@ export class Agent {
486486 const matchingTransfer = eligibleTransferDeployments . find (
487487 deployment =>
488488 deployment . ipfsHash == decision . deployment . ipfsHash &&
489- deployment . startedTransferToL2At . toNumber ( ) > oneWeekAgo ,
489+ Number ( deployment . startedTransferToL2At ) > oneWeekAgo ,
490490 )
491491 if ( matchingTransfer ) {
492492 logger . debug ( 'Found a matching subgraph transfer' , {
@@ -682,7 +682,8 @@ export class Agent {
682682 currentEpochNumber : number ,
683683 ) =>
684684 currentEpochNumber -
685- network . specification . indexerOptions . poiDisputableEpochs ,
685+ ( network . specification . indexerOptions
686+ . poiDisputableEpochs as number ) ,
686687 )
687688
688689 // Find disputable allocations
@@ -821,22 +822,22 @@ export class Agent {
821822 await network . networkProvider . getBlock (
822823 pool . previousEpochStartBlockHash ! ,
823824 )
824- pool . closedAtEpochStartBlockNumber = closedAtEpochStartBlock . number
825+ pool . closedAtEpochStartBlockNumber = closedAtEpochStartBlock ! . number
825826 pool . referencePOI = await this . graphNode . proofOfIndexing (
826827 pool . subgraphDeployment ,
827828 {
828- number : closedAtEpochStartBlock . number ,
829- hash : closedAtEpochStartBlock . hash ,
829+ number : closedAtEpochStartBlock ! . number ,
830+ hash : closedAtEpochStartBlock ! . hash ! ,
830831 } ,
831832 pool . allocationIndexer ,
832833 )
833- pool . previousEpochStartBlockHash = previousEpochStartBlock . hash
834- pool . previousEpochStartBlockNumber = previousEpochStartBlock . number
834+ pool . previousEpochStartBlockHash = previousEpochStartBlock ! . hash !
835+ pool . previousEpochStartBlockNumber = previousEpochStartBlock ! . number
835836 pool . referencePreviousPOI = await this . graphNode . proofOfIndexing (
836837 pool . subgraphDeployment ,
837838 {
838- number : previousEpochStartBlock . number ,
839- hash : previousEpochStartBlock . hash ,
839+ number : previousEpochStartBlock ! . number ,
840+ hash : previousEpochStartBlock ! . hash ! ,
840841 } ,
841842 pool . allocationIndexer ,
842843 )
@@ -1006,13 +1007,13 @@ export class Agent {
10061007 activeAllocations : Allocation [ ] ,
10071008 deploymentAllocationDecision : AllocationDecision ,
10081009 epoch : number ,
1009- maxAllocationEpochs : number ,
1010+ maxAllocationEpochs : bigint ,
10101011 network : Network ,
10111012 ) : Promise < Allocation [ ] > {
10121013 const desiredAllocationLifetime = deploymentAllocationDecision . ruleMatch
10131014 . rule ?. allocationLifetime
10141015 ? deploymentAllocationDecision . ruleMatch . rule . allocationLifetime
1015- : Math . max ( 1 , maxAllocationEpochs - 1 )
1016+ : Math . max ( 1 , Number ( maxAllocationEpochs ) - 1 )
10161017
10171018 // Identify expiring allocations
10181019 let expiredAllocations = activeAllocations . filter (
@@ -1028,8 +1029,8 @@ export class Agent {
10281029 async ( allocation : Allocation ) => {
10291030 try {
10301031 const onChainAllocation =
1031- await network . contracts . staking . getAllocation ( allocation . id )
1032- return onChainAllocation . closedAtEpoch . eq ( '0' )
1032+ await network . contracts . LegacyStaking . getAllocation ( allocation . id )
1033+ return onChainAllocation . closedAtEpoch == 0n
10331034 } catch ( err ) {
10341035 this . logger . warn (
10351036 `Failed to cross-check allocation state with contracts; assuming it needs to be closed` ,
@@ -1050,7 +1051,7 @@ export class Agent {
10501051 deploymentAllocationDecision : AllocationDecision ,
10511052 activeAllocations : Allocation [ ] ,
10521053 epoch : number ,
1053- maxAllocationEpochs : number ,
1054+ maxAllocationEpochs : bigint ,
10541055 network : Network ,
10551056 operator : Operator ,
10561057 ) : Promise < void > {
@@ -1145,7 +1146,7 @@ export class Agent {
11451146 async reconcileActions (
11461147 networkDeploymentAllocationDecisions : NetworkMapped < AllocationDecision [ ] > ,
11471148 epoch : NetworkMapped < number > ,
1148- maxAllocationEpochs : NetworkMapped < number > ,
1149+ maxAllocationEpochs : NetworkMapped < bigint > ,
11491150 ) : Promise < void > {
11501151 // --------------------------------------------------------------------------------
11511152 // Filter out networks set to `manual` allocation management mode, and ensure the
0 commit comments