Skip to content

Commit 3427a3a

Browse files
committed
chore: add dips actions in allocations resolvers
1 parent 7b9061f commit 3427a3a

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

packages/indexer-common/src/indexer-management/allocations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export type TransactionResult =
9999
| ActionFailure[]
100100

101101
export class AllocationManager {
102-
private dipsManager: DipsManager | null = null
102+
declare dipsManager: DipsManager | null
103103
constructor(
104104
private logger: Logger,
105105
private models: IndexerManagementModels,

packages/indexer-common/src/indexer-management/resolvers/allocations.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ export default {
374374
amount: string
375375
protocolNetwork: string
376376
},
377-
{ network, graphNode, logger, models }: IndexerManagementResolverContext,
377+
{ network, graphNode, logger, models, actionManager }: IndexerManagementResolverContext,
378378
): Promise<CreateAllocationResult> => {
379379
logger.debug('Execute createAllocation() mutation', {
380380
deployment,
@@ -571,6 +571,14 @@ export default {
571571

572572
await models.IndexingRule.upsert(indexingRule)
573573

574+
if (actionManager?.allocationManager?.dipsManager) {
575+
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
576+
deployment,
577+
null,
578+
createAllocationEventLogs.allocationID,
579+
)
580+
}
581+
574582
// Since upsert succeeded, we _must_ have a rule
575583
const updatedRule = await models.IndexingRule.findOne({
576584
where: { identifier: indexingRule.identifier },
@@ -608,7 +616,7 @@ export default {
608616
poi: string | undefined
609617
force: boolean
610618
},
611-
{ logger, models, network }: IndexerManagementResolverContext,
619+
{ logger, models, network, actionManager }: IndexerManagementResolverContext,
612620
): Promise<CloseAllocationResult> => {
613621
logger.debug('Execute closeAllocation() mutation', {
614622
allocationID: allocation,
@@ -726,6 +734,17 @@ export default {
726734

727735
await models.IndexingRule.upsert(offchainIndexingRule)
728736

737+
if (actionManager?.allocationManager?.dipsManager) {
738+
await actionManager.allocationManager.dipsManager.tryCancelAgreement(
739+
allocation,
740+
)
741+
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
742+
allocationData.subgraphDeployment.id.toString(),
743+
allocation,
744+
null,
745+
)
746+
}
747+
729748
// Since upsert succeeded, we _must_ have a rule
730749
const updatedRule = await models.IndexingRule.findOne({
731750
where: { identifier: offchainIndexingRule.identifier },
@@ -765,7 +784,7 @@ export default {
765784
force: boolean
766785
protocolNetwork: string
767786
},
768-
{ logger, models, network }: IndexerManagementResolverContext,
787+
{ logger, models, network, actionManager }: IndexerManagementResolverContext,
769788
): Promise<ReallocateAllocationResult> => {
770789
logger = logger.child({
771790
component: 'reallocateAllocationResolver',
@@ -1032,6 +1051,14 @@ export default {
10321051

10331052
await models.IndexingRule.upsert(indexingRule)
10341053

1054+
if (actionManager?.allocationManager?.dipsManager) {
1055+
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
1056+
allocationData.subgraphDeployment.id.toString(),
1057+
allocation,
1058+
createAllocationEventLogs.allocationID,
1059+
)
1060+
}
1061+
10351062
// Since upsert succeeded, we _must_ have a rule
10361063
const updatedRule = await models.IndexingRule.findOne({
10371064
where: { identifier: indexingRule.identifier },

0 commit comments

Comments
 (0)