Skip to content

Commit

Permalink
chore: add dips actions in allocations resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranzav committed Feb 14, 2025
1 parent 7b9061f commit 3427a3a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export type TransactionResult =
| ActionFailure[]

export class AllocationManager {
private dipsManager: DipsManager | null = null
declare dipsManager: DipsManager | null
constructor(
private logger: Logger,
private models: IndexerManagementModels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default {
amount: string
protocolNetwork: string
},
{ network, graphNode, logger, models }: IndexerManagementResolverContext,
{ network, graphNode, logger, models, actionManager }: IndexerManagementResolverContext,
): Promise<CreateAllocationResult> => {
logger.debug('Execute createAllocation() mutation', {
deployment,
Expand Down Expand Up @@ -571,6 +571,14 @@ export default {

await models.IndexingRule.upsert(indexingRule)

if (actionManager?.allocationManager?.dipsManager) {
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
deployment,
null,
createAllocationEventLogs.allocationID,
)
}

// Since upsert succeeded, we _must_ have a rule
const updatedRule = await models.IndexingRule.findOne({
where: { identifier: indexingRule.identifier },
Expand Down Expand Up @@ -608,7 +616,7 @@ export default {
poi: string | undefined
force: boolean
},
{ logger, models, network }: IndexerManagementResolverContext,
{ logger, models, network, actionManager }: IndexerManagementResolverContext,
): Promise<CloseAllocationResult> => {
logger.debug('Execute closeAllocation() mutation', {
allocationID: allocation,
Expand Down Expand Up @@ -726,6 +734,17 @@ export default {

await models.IndexingRule.upsert(offchainIndexingRule)

if (actionManager?.allocationManager?.dipsManager) {
await actionManager.allocationManager.dipsManager.tryCancelAgreement(
allocation,
)
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
allocationData.subgraphDeployment.id.toString(),
allocation,
null,
)
}

// Since upsert succeeded, we _must_ have a rule
const updatedRule = await models.IndexingRule.findOne({
where: { identifier: offchainIndexingRule.identifier },
Expand Down Expand Up @@ -765,7 +784,7 @@ export default {
force: boolean
protocolNetwork: string
},
{ logger, models, network }: IndexerManagementResolverContext,
{ logger, models, network, actionManager }: IndexerManagementResolverContext,
): Promise<ReallocateAllocationResult> => {
logger = logger.child({
component: 'reallocateAllocationResolver',
Expand Down Expand Up @@ -1032,6 +1051,14 @@ export default {

await models.IndexingRule.upsert(indexingRule)

if (actionManager?.allocationManager?.dipsManager) {
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
allocationData.subgraphDeployment.id.toString(),
allocation,
createAllocationEventLogs.allocationID,
)
}

// Since upsert succeeded, we _must_ have a rule
const updatedRule = await models.IndexingRule.findOne({
where: { identifier: indexingRule.identifier },
Expand Down

0 comments on commit 3427a3a

Please sign in to comment.