@@ -15,6 +15,7 @@ import {
15
15
AllocationStatus ,
16
16
CloseAllocationResult ,
17
17
CreateAllocationResult ,
18
+ DipsManager ,
18
19
fetchIndexingRules ,
19
20
GraphNode ,
20
21
indexerError ,
@@ -98,12 +99,23 @@ export type TransactionResult =
98
99
| ActionFailure [ ]
99
100
100
101
export class AllocationManager {
102
+ declare dipsManager : DipsManager | null
101
103
constructor (
102
104
private logger : Logger ,
103
105
private models : IndexerManagementModels ,
104
106
private graphNode : GraphNode ,
105
107
private network : Network ,
106
- ) { }
108
+ ) {
109
+ if ( this . network . specification . indexerOptions . dipperEndpoint ) {
110
+ this . dipsManager = new DipsManager (
111
+ this . logger ,
112
+ this . models ,
113
+ this . graphNode ,
114
+ this . network ,
115
+ this ,
116
+ )
117
+ }
118
+ }
107
119
108
120
async executeBatch ( actions : Action [ ] ) : Promise < AllocationResult [ ] > {
109
121
const logger = this . logger . child ( { function : 'executeBatch' } )
@@ -511,6 +523,14 @@ export class AllocationManager {
511
523
await upsertIndexingRule ( logger , this . models , indexingRule )
512
524
}
513
525
526
+ if ( this . dipsManager ) {
527
+ await this . dipsManager . tryUpdateAgreementAllocation (
528
+ deployment ,
529
+ null ,
530
+ createAllocationEventLogs . allocationID ,
531
+ )
532
+ }
533
+
514
534
return {
515
535
actionID,
516
536
type : 'allocate' ,
@@ -667,6 +687,15 @@ export class AllocationManager {
667
687
668
688
await upsertIndexingRule ( logger , this . models , neverIndexingRule )
669
689
690
+ if ( this . dipsManager ) {
691
+ await this . dipsManager . tryCancelAgreement ( allocationID )
692
+ await this . dipsManager . tryUpdateAgreementAllocation (
693
+ allocation . subgraphDeployment . id . toString ( ) ,
694
+ allocationID ,
695
+ null ,
696
+ )
697
+ }
698
+
670
699
return {
671
700
actionID,
672
701
type : 'unallocate' ,
@@ -966,6 +995,14 @@ export class AllocationManager {
966
995
await upsertIndexingRule ( logger , this . models , indexingRule )
967
996
}
968
997
998
+ if ( this . dipsManager ) {
999
+ await this . dipsManager . tryUpdateAgreementAllocation (
1000
+ subgraphDeploymentID . toString ( ) ,
1001
+ allocationID ,
1002
+ createAllocationEventLogs . allocationID ,
1003
+ )
1004
+ }
1005
+
969
1006
return {
970
1007
actionID,
971
1008
type : 'reallocate' ,
0 commit comments