Skip to content

Commit f157503

Browse files
committed
Merge branch 'develop' into ba/polygons-support
# Conflicts: # packages/examples/cvat/exchange-oracle/src/core/types.py # packages/examples/cvat/exchange-oracle/tests/api/test_exchange_api.py # packages/examples/cvat/recording-oracle/src/core/types.py
2 parents 1818a03 + f8e31ec commit f157503

File tree

67 files changed

+908
-456
lines changed

Some content is hidden

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

67 files changed

+908
-456
lines changed

packages/apps/fortune/exchange-oracle/client/src/providers/WagmiProvider.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FC, PropsWithChildren } from 'react';
2-
import { createConfig, WagmiProvider as WWagmiProvider } from 'wagmi';
2+
import { createConfig, http, WagmiProvider as WWagmiProvider } from 'wagmi';
33
import * as wagmiChains from 'wagmi/chains';
44
import { coinbaseWallet, walletConnect } from 'wagmi/connectors';
55

@@ -32,6 +32,21 @@ export const wagmiConfig = createConfig({
3232
appName: 'human-job-launcher',
3333
}),
3434
],
35+
transports: {
36+
[wagmiChains.mainnet.id]: http(),
37+
[wagmiChains.sepolia.id]: http(),
38+
[wagmiChains.bsc.id]: http(),
39+
[wagmiChains.bscTestnet.id]: http(),
40+
[wagmiChains.polygon.id]: http(),
41+
[wagmiChains.polygonAmoy.id]: http(),
42+
[wagmiChains.moonbeam.id]: http(),
43+
[wagmiChains.moonbaseAlpha.id]: http(),
44+
[wagmiChains.avalanche.id]: http(),
45+
[wagmiChains.avalancheFuji.id]: http(),
46+
[wagmiChains.xLayer.id]: http(),
47+
[wagmiChains.xLayerTestnet.id]: http(),
48+
[LOCALHOST.id]: http(LOCALHOST.rpcUrls.default.http[0]),
49+
},
3550
});
3651

3752
export const WagmiProvider: FC<PropsWithChildren> = ({ children }) => {

packages/apps/fortune/exchange-oracle/server/src/common/interceptors/transform-enum.interceptor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export class TransformEnumInterceptor implements NestInterceptor {
5555
: null;
5656
}
5757

58-
private transformEnums(bodyOrQuery: any, targetClass: ClassConstructor<any>): any {
58+
private transformEnums(
59+
bodyOrQuery: any,
60+
targetClass: ClassConstructor<any>,
61+
): any {
5962
// Convert the body or query to an instance of the target class
6063
let transformedInstance = plainToInstance(targetClass, bodyOrQuery);
6164

@@ -111,4 +114,4 @@ export class TransformEnumInterceptor implements NestInterceptor {
111114
}
112115
return bodyOrQuery;
113116
}
114-
}
117+
}

packages/apps/fortune/exchange-oracle/server/src/common/pagination/pagination.dto.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2-
import {
3-
IsNumber,
4-
IsOptional,
5-
Max,
6-
Min,
7-
IsArray,
8-
} from 'class-validator';
2+
import { IsNumber, IsOptional, Max, Min, IsArray } from 'class-validator';
93
import { Type } from 'class-transformer';
104
import { SortDirection } from '../enums/collection';
115
import { IsEnumCaseInsensitive } from '../decorators/enums';

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ describe('assignmentController', () => {
5757
.spyOn(assignmentService, 'getAssignmentList')
5858
.mockResolvedValue(expectedResult);
5959

60-
const result = await assignmentController.getAssignments(
61-
query,
62-
{
63-
user: { address: userAddress, reputationNetwork: reputationNetwork },
64-
headers: { referer: MOCK_EXCHANGE_ORACLE },
65-
} as any,
66-
);
60+
const result = await assignmentController.getAssignments(query, {
61+
user: { address: userAddress, reputationNetwork: reputationNetwork },
62+
headers: { referer: MOCK_EXCHANGE_ORACLE },
63+
} as any);
6764
expect(result).toBe(expectedResult);
6865
expect(assignmentService.getAssignmentList).toHaveBeenCalledWith(
6966
query,
@@ -82,12 +79,9 @@ describe('assignmentController', () => {
8279
jest
8380
.spyOn(assignmentService, 'createAssignment')
8481
.mockResolvedValue({ id: 1 } as any);
85-
await assignmentController.createAssignment(
86-
body,
87-
{
88-
user: { address: userAddress },
89-
} as RequestWithUser,
90-
);
82+
await assignmentController.createAssignment(body, {
83+
user: { address: userAddress },
84+
} as RequestWithUser);
9185
expect(assignmentService.createAssignment).toHaveBeenCalledWith(body, {
9286
address: userAddress,
9387
});
@@ -103,10 +97,9 @@ describe('assignmentController', () => {
10397

10498
jest.spyOn(assignmentService, 'resign').mockResolvedValue();
10599

106-
await assignmentController.resign(
107-
resignJobDto,
108-
{ user: { address: userAddress } } as RequestWithUser,
109-
);
100+
await assignmentController.resign(resignJobDto, {
101+
user: { address: userAddress },
102+
} as RequestWithUser);
110103

111104
expect(assignmentService.resign).toHaveBeenCalledWith(
112105
assignmentId,

packages/apps/human-app/frontend/.eslintrc.cjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ module.exports = {
2020
},
2121
plugins: ['react-refresh'],
2222
rules: {
23-
'react-refresh/only-export-components': [
24-
'warn',
25-
{ allowConstantExport: true },
26-
],
23+
'react-refresh/only-export-components': 'off',
2724
'import/extensions': [
2825
'error',
2926
'ignorePackages',

packages/apps/human-app/frontend/src/api/api-paths.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const apiPaths = {
4545
resignJob: {
4646
path: '/assignment/resign-job',
4747
},
48+
refreshJob: {
49+
path: '/assignment/refresh',
50+
},
4851
registerAddress: {
4952
path: '/user/register-address',
5053
withAuthRetry: true,

packages/apps/human-app/frontend/src/api/services/worker/assign-job.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { z } from 'zod';
2-
import { useMutation, useQueryClient } from '@tanstack/react-query';
2+
import {
3+
type MutationKey,
4+
useMutation,
5+
useQueryClient,
6+
} from '@tanstack/react-query';
37
import { apiClient } from '@/api/api-client';
48
import { apiPaths } from '@/api/api-paths';
59

@@ -18,10 +22,13 @@ function assignJob(data: AssignJobBody) {
1822
});
1923
}
2024

21-
export function useAssignJobMutation(callbacks?: {
22-
onSuccess: () => Promise<void>;
23-
onError: (error: unknown) => Promise<void>;
24-
}) {
25+
export function useAssignJobMutation(
26+
callbacks?: {
27+
onSuccess: () => Promise<void>;
28+
onError: (error: unknown) => Promise<void>;
29+
},
30+
mutationKey?: MutationKey
31+
) {
2532
const queryClient = useQueryClient();
2633

2734
return useMutation({
@@ -34,5 +41,6 @@ export function useAssignJobMutation(callbacks?: {
3441
await queryClient.invalidateQueries();
3542
void callbacks?.onError(error);
3643
},
44+
mutationKey,
3745
});
3846
}

packages/apps/human-app/frontend/src/api/services/worker/oracles.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ export async function getOracles({
3737
signal: AbortSignal;
3838
}) {
3939
let oracles = [H_CAPTCHA_ORACLE];
40-
const queryParams = selected_job_types.length
41-
? `?${stringifyUrlQueryObject({ selected_job_types })}`
42-
: '';
40+
if (env.VITE_FEATURE_FLAG_JOBS_DISCOVERY) {
41+
const queryParams = selected_job_types.length
42+
? `?${stringifyUrlQueryObject({ selected_job_types })}`
43+
: '';
4344

44-
const result = await apiClient(
45-
`${apiPaths.worker.oracles.path}${queryParams}`,
46-
{
47-
successSchema: OraclesSuccessSchema,
48-
options: { method: 'GET' },
49-
},
50-
signal
51-
);
52-
53-
oracles = oracles.concat(result);
45+
const result = await apiClient(
46+
`${apiPaths.worker.oracles.path}${queryParams}`,
47+
{
48+
successSchema: OraclesSuccessSchema,
49+
options: { method: 'GET' },
50+
},
51+
signal
52+
);
5453

54+
oracles = oracles.concat(result);
55+
}
5556
return oracles;
5657
}
5758

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { z } from 'zod';
2+
import { useMutation, useQueryClient } from '@tanstack/react-query';
3+
import { apiClient } from '@/api/api-client';
4+
import { apiPaths } from '@/api/api-paths';
5+
6+
function refreshTasks(data: { oracle_address: string }) {
7+
return apiClient(apiPaths.worker.refreshJob.path, {
8+
successSchema: z.unknown(),
9+
authenticated: true,
10+
options: { method: 'PUT', body: JSON.stringify(data) },
11+
});
12+
}
13+
14+
export function useRefreshTasksMutation(callbacks?: {
15+
onSuccess?: () => Promise<void>;
16+
onError?: (error: unknown) => Promise<void>;
17+
}) {
18+
const queryClient = useQueryClient();
19+
20+
return useMutation({
21+
mutationFn: refreshTasks,
22+
onSuccess: async () => {
23+
if (callbacks?.onSuccess) {
24+
void callbacks.onSuccess();
25+
}
26+
await queryClient.invalidateQueries();
27+
},
28+
onError: async (error) => {
29+
if (callbacks?.onError) {
30+
void callbacks.onError(error);
31+
}
32+
await queryClient.invalidateQueries();
33+
},
34+
});
35+
}

packages/apps/human-app/frontend/src/components/layout/drawer-menu-items/drawer-menu-items-worker.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,21 @@ import type {
55
} from '@/components/layout/protected/drawer-navigation';
66
import { HelpIcon, UserOutlinedIcon, WorkIcon } from '@/components/ui/icons';
77
import { routerPaths } from '@/router/router-paths';
8-
import { env } from '@/shared/env';
98
import { DarkModeSwitch } from '@/components/ui/dark-mode-switch';
109
import type { UserData } from '@/auth/auth-context';
1110

1211
export const workerDrawerTopMenuItems = (
1312
user: UserData | null
1413
): TopMenuItem[] => {
1514
return [
16-
...(env.VITE_FEATURE_FLAG_JOBS_DISCOVERY
17-
? [
18-
{
19-
label: t('components.DrawerNavigation.jobs'),
20-
icon: <WorkIcon />,
21-
link: routerPaths.worker.jobsDiscovery,
22-
disabled: !user?.wallet_address || user.kyc_status !== 'approved',
23-
},
24-
]
25-
: []),
15+
...[
16+
{
17+
label: t('components.DrawerNavigation.jobs'),
18+
icon: <WorkIcon />,
19+
link: routerPaths.worker.jobsDiscovery,
20+
disabled: !user?.wallet_address || user.kyc_status !== 'approved',
21+
},
22+
],
2623
];
2724
};
2825

0 commit comments

Comments
 (0)