Skip to content

Commit 95b322f

Browse files
authored
[Reputation Oracle] refactor: escrow-completion process (#3299)
1 parent e9c758c commit 95b322f

File tree

72 files changed

+2506
-2106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2506
-2106
lines changed
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
import { createDefaultPreset } from 'ts-jest';
2+
13
process.env['GIT_HASH'] = 'test_value_hardcoded_in_jest_config';
24

5+
const jestTsPreset = createDefaultPreset({});
6+
37
module.exports = {
8+
...jestTsPreset,
49
coverageDirectory: '../coverage',
510
collectCoverageFrom: ['**/*.(t|j)s'],
611
moduleFileExtensions: ['js', 'json', 'ts'],
712
rootDir: 'src',
813
testEnvironment: 'node',
914
testRegex: '.*\\.spec\\.ts$',
10-
transform: {
11-
'^.+\\.(t|j)s$': 'ts-jest',
12-
},
1315
moduleNameMapper: {
1416
'^uuid$': require.resolve('uuid'),
1517
'^typeorm$': require.resolve('typeorm'),
1618
},
19+
clearMocks: true,
1720
};

packages/apps/reputation-oracle/server/src/common/constants/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export const CVAT_VALIDATION_META_FILENAME = 'validation_meta.json';
77
export const AUDINO_RESULTS_ANNOTATIONS_FILENAME = 'resulting_annotations.zip';
88
export const AUDINO_VALIDATION_META_FILENAME = 'validation_meta.json';
99

10-
export const DEFAULT_BULK_PAYOUT_TX_ID = 1;
11-
1210
export const HEADER_SIGNATURE_KEY = 'human-signature';
1311

1412
export const RESEND_EMAIL_VERIFICATION_PATH =

packages/apps/reputation-oracle/server/src/common/enums/database.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from './job';
2-
export * from './webhook';
31
export * from './collection';
42
export * from './hcaptcha';
53
export * from './http';
4+
export * from './manifest';
5+
export * from './web3';
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
export enum JobRequestType {
1+
export enum FortuneJobType {
2+
FORTUNE = 'fortune',
3+
}
4+
5+
export enum CvatJobType {
26
IMAGE_BOXES = 'image_boxes',
37
IMAGE_POINTS = 'image_points',
48
IMAGE_BOXES_FROM_POINTS = 'image_boxes_from_points',
59
IMAGE_SKELETONS_FROM_BOXES = 'image_skeletons_from_boxes',
6-
FORTUNE = 'fortune',
710
IMAGE_POLYGONS = 'image_polygons',
8-
AUDIO_TRANSCRIPTION = 'audio_transcription',
911
}
1012

11-
export enum SolutionError {
12-
Duplicated = 'duplicated',
13-
CurseWord = 'curse_word',
13+
export enum AudinoJobType {
14+
AUDIO_TRANSCRIPTION = 'audio_transcription',
1415
}

packages/apps/reputation-oracle/server/src/common/errors/database.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { QueryFailedError } from 'typeorm';
2-
import { PostgresErrorCodes } from '../enums/database';
32
import { BaseError } from './base';
43

4+
export enum PostgresErrorCodes {
5+
Duplicated = '23505',
6+
NumericFieldOverflow = '22003',
7+
}
8+
59
export class DatabaseError extends BaseError {}
610

711
export function handleQueryFailedError(error: QueryFailedError): DatabaseError {

packages/apps/reputation-oracle/server/src/common/errors/manifest.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import { BaseError } from './base';
33
class ManifestError extends BaseError {}
44

55
export class MissingManifestUrlError extends ManifestError {
6-
constructor(public readonly escrowAddress: string) {
6+
constructor(readonly escrowAddress: string) {
77
super('Manifest url is missing for escrow');
88
}
99
}
10-
11-
export class UnsupportedManifestTypeError extends ManifestError {
12-
constructor(public readonly manifestType: unknown) {
13-
super('Unsupported manifest type');
14-
}
15-
}

packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
jest.mock('@human-protocol/sdk');
22

3+
import { faker } from '@faker-js/faker';
34
import { EscrowUtils } from '@human-protocol/sdk';
45
import { ExecutionContext, HttpException, HttpStatus } from '@nestjs/common';
56

6-
import {
7-
generateContractAddress,
8-
generateEthWallet,
9-
} from '../../../test/fixtures/web3';
7+
import { generateEthWallet } from '../../../test/fixtures/web3';
108
import {
119
createExecutionContextMock,
1210
ExecutionContextMock,
@@ -43,7 +41,7 @@ describe('SignatureAuthGuard', () => {
4341
executionContextMock = createExecutionContextMock();
4442
body = {
4543
chain_id: generateTestnetChainId(),
46-
escrow_address: generateContractAddress(),
44+
escrow_address: faker.finance.ethereumAddress(),
4745
};
4846
});
4947

packages/apps/reputation-oracle/server/src/common/interfaces/job-result.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/apps/reputation-oracle/server/src/common/interfaces/manifest.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)