Skip to content

Commit 3a5c09a

Browse files
committed
Merge branch 'develop' into contracts-v2
2 parents 07a2f01 + d5f21bd commit 3a5c09a

File tree

13 files changed

+110
-297
lines changed

13 files changed

+110
-297
lines changed

docker-setup/docker-compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ services:
7373

7474
graph-node-db:
7575
container_name: hp-dev-graph-node-db
76-
image: postgres:latest
76+
image: postgres:16
7777
restart: *default-restart
7878
logging:
7979
<<: *default-logging

packages/apps/fortune/exchange-oracle/server/src/common/enums/job.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export enum JobStatus {
22
ACTIVE = 'active',
3-
PAUSED = 'paused',
43
COMPLETED = 'completed',
54
CANCELED = 'canceled',
65
}

packages/apps/fortune/exchange-oracle/server/src/common/enums/webhook.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export enum EventType {
66
SUBMISSION_REJECTED = 'submission_rejected',
77
SUBMISSION_IN_REVIEW = 'submission_in_review',
88
ABUSE_DETECTED = 'abuse_detected',
9-
ABUSE_DISMISSED = 'abuse_dismissed',
109
CANCELLATION_REQUESTED = 'cancellation_requested',
1110
}
1211

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class RemovePausedStatus1762175785287 implements MigrationInterface {
4+
name = 'RemovePausedStatus1762175785287';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`
8+
ALTER TYPE "hmt"."jobs_status_enum"
9+
RENAME TO "jobs_status_enum_old"
10+
`);
11+
await queryRunner.query(`
12+
CREATE TYPE "hmt"."jobs_status_enum" AS ENUM('active', 'completed', 'canceled')
13+
`);
14+
await queryRunner.query(`
15+
ALTER TABLE "hmt"."jobs"
16+
ALTER COLUMN "status" TYPE "hmt"."jobs_status_enum" USING "status"::"text"::"hmt"."jobs_status_enum"
17+
`);
18+
await queryRunner.query(`
19+
DROP TYPE "hmt"."jobs_status_enum_old"
20+
`);
21+
}
22+
23+
public async down(queryRunner: QueryRunner): Promise<void> {
24+
await queryRunner.query(`
25+
CREATE TYPE "hmt"."jobs_status_enum_old" AS ENUM('active', 'paused', 'completed', 'canceled')
26+
`);
27+
await queryRunner.query(`
28+
ALTER TABLE "hmt"."jobs"
29+
ALTER COLUMN "status" TYPE "hmt"."jobs_status_enum_old" USING "status"::"text"::"hmt"."jobs_status_enum_old"
30+
`);
31+
await queryRunner.query(`
32+
DROP TYPE "hmt"."jobs_status_enum"
33+
`);
34+
await queryRunner.query(`
35+
ALTER TYPE "hmt"."jobs_status_enum_old"
36+
RENAME TO "jobs_status_enum"
37+
`);
38+
}
39+
}

packages/apps/fortune/exchange-oracle/server/src/modules/assignment/assignment.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('AssignmentService', () => {
229229
id: 1,
230230
manifestUrl: MOCK_MANIFEST_URL,
231231
reputationNetwork: reputationNetwork,
232-
status: JobStatus.PAUSED,
232+
status: JobStatus.CANCELED,
233233
} as any);
234234

235235
await expect(

packages/apps/fortune/exchange-oracle/server/src/modules/job/job.service.spec.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -667,54 +667,4 @@ describe('JobService', () => {
667667
).rejects.toThrow(`Solution not found in Escrow: ${escrowAddress}`);
668668
});
669669
});
670-
671-
describe('pauseJob', () => {
672-
const webhook: WebhookDto = {
673-
chainId,
674-
escrowAddress,
675-
eventType: EventType.ABUSE_DETECTED,
676-
};
677-
678-
it('should create a new job in the database', async () => {
679-
jest
680-
.spyOn(jobRepository, 'findOneByChainIdAndEscrowAddress')
681-
.mockResolvedValue({
682-
chainId: chainId,
683-
escrowAddress: escrowAddress,
684-
status: JobStatus.ACTIVE,
685-
} as JobEntity);
686-
const result = await jobService.pauseJob(webhook);
687-
688-
expect(result).toEqual(undefined);
689-
expect(jobRepository.updateOne).toHaveBeenCalledWith({
690-
chainId: chainId,
691-
escrowAddress: escrowAddress,
692-
status: JobStatus.PAUSED,
693-
});
694-
});
695-
696-
it('should fail if job not exists', async () => {
697-
jest
698-
.spyOn(jobRepository, 'findOneByChainIdAndEscrowAddress')
699-
.mockResolvedValue(null);
700-
701-
await expect(jobService.pauseJob(webhook)).rejects.toThrow(
702-
ErrorJob.NotFound,
703-
);
704-
});
705-
706-
it('should fail if job is not in Active status', async () => {
707-
jest
708-
.spyOn(jobRepository, 'findOneByChainIdAndEscrowAddress')
709-
.mockResolvedValue({
710-
chainId: chainId,
711-
escrowAddress: escrowAddress,
712-
status: JobStatus.CANCELED,
713-
} as JobEntity);
714-
715-
await expect(jobService.pauseJob(webhook)).rejects.toThrow(
716-
ErrorJob.InvalidStatus,
717-
);
718-
});
719-
});
720670
});

packages/apps/fortune/exchange-oracle/server/src/modules/job/job.service.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -382,34 +382,4 @@ export class JobService {
382382

383383
return manifest;
384384
}
385-
386-
public async pauseJob(webhook: WebhookDto): Promise<void> {
387-
const jobEntity = await this.jobRepository.findOneByChainIdAndEscrowAddress(
388-
webhook.chainId,
389-
webhook.escrowAddress,
390-
);
391-
if (!jobEntity) {
392-
throw new ServerError(ErrorJob.NotFound);
393-
}
394-
if (jobEntity.status !== JobStatus.ACTIVE) {
395-
throw new ConflictError(ErrorJob.InvalidStatus);
396-
}
397-
jobEntity.status = JobStatus.PAUSED;
398-
await this.jobRepository.updateOne(jobEntity);
399-
}
400-
401-
public async resumeJob(webhook: WebhookDto): Promise<void> {
402-
const jobEntity = await this.jobRepository.findOneByChainIdAndEscrowAddress(
403-
webhook.chainId,
404-
webhook.escrowAddress,
405-
);
406-
if (!jobEntity) {
407-
throw new ServerError(ErrorJob.NotFound);
408-
}
409-
if (jobEntity.status !== JobStatus.PAUSED) {
410-
throw new ConflictError(ErrorJob.InvalidStatus);
411-
}
412-
jobEntity.status = JobStatus.ACTIVE;
413-
await this.jobRepository.updateOne(jobEntity);
414-
}
415385
}

packages/apps/fortune/exchange-oracle/server/src/modules/webhook/webhook.service.spec.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe('WebhookService', () => {
169169
});
170170

171171
it('should handle an incoming escrow abuse webhook', async () => {
172-
jest.spyOn(jobService, 'pauseJob').mockResolvedValue();
172+
jest.spyOn(jobService, 'cancelJob').mockResolvedValue();
173173
const webhook: WebhookDto = {
174174
chainId,
175175
escrowAddress,
@@ -178,16 +178,6 @@ describe('WebhookService', () => {
178178
expect(await webhookService.handleWebhook(webhook)).toBe(undefined);
179179
});
180180

181-
it('should handle an incoming escrow resume webhook', async () => {
182-
jest.spyOn(jobService, 'resumeJob').mockResolvedValue();
183-
const webhook: WebhookDto = {
184-
chainId,
185-
escrowAddress,
186-
eventType: EventType.ABUSE_DISMISSED,
187-
};
188-
expect(await webhookService.handleWebhook(webhook)).toBe(undefined);
189-
});
190-
191181
it('should return an error when the event type is invalid', async () => {
192182
const webhook: WebhookDto = {
193183
chainId,

packages/apps/fortune/exchange-oracle/server/src/modules/webhook/webhook.service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export class WebhookService {
5454
break;
5555

5656
case EventType.ABUSE_DETECTED:
57-
await this.jobService.pauseJob(webhook);
58-
break;
59-
60-
case EventType.ABUSE_DISMISSED:
61-
await this.jobService.resumeJob(webhook);
57+
await this.jobService.cancelJob(webhook);
6258
break;
6359

6460
case EventType.ESCROW_CANCELED:

packages/apps/job-launcher/server/src/modules/job/job.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class JobService {
119119
// DISABLE HMT
120120
if (
121121
requestType !== HCaptchaJobType.HCAPTCHA &&
122+
dto.chainId !== ChainId.LOCALHOST &&
122123
(dto.escrowFundToken === EscrowFundToken.HMT ||
123124
dto.paymentCurrency === PaymentCurrency.HMT)
124125
) {

0 commit comments

Comments
 (0)