Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/crisp-buckets-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@human-protocol/sdk": minor
---

Added typed subgraph errors (SubgraphRequestError, SubgraphBadIndexerError) and wrapped subgraph request failures with these classes
5 changes: 5 additions & 0 deletions .changeset/shaggy-months-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@human-protocol/sdk": patch
---

Split combined domain files into module folders with explicit files per responsibility.
2 changes: 1 addition & 1 deletion .github/workflows/cd-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GH_GITBOOK_TOKEN }}
token: ${{ secrets.RELEASE_GH_TOKEN }}
- name: Setup git identity
run: |
git config --global user.name "github-actions[bot]"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd-python-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GH_GITBOOK_TOKEN }}
token: ${{ secrets.RELEASE_GH_TOKEN }}
- name: Setup git identity
run: |
git config --global user.name "github-actions[bot]"
Expand Down
14 changes: 11 additions & 3 deletions docker-setup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
build-services services-up services-stop

export COMPOSE_BAKE=false
DOCKER_PARALLEL ?= 4
DOCKER_PARALLEL ?= 2

check-env-file:
@if [ ! -f "./.env.compose.local" ]; then \
Expand All @@ -17,11 +17,19 @@ infra-stop:
@docker compose --env-file .env.compose.local stop postgres redis minio minio-client

build-services: check-env-file
@docker compose --env-file .env.compose.local --parallel $(DOCKER_PARALLEL) up --no-start
@# TODO: Revisit compose-native parallel builds once Docker Compose v5 parallel limits are reliable again.
@docker compose --env-file .env.compose.local config --services | \
xargs -n $(DOCKER_PARALLEL) docker compose --env-file .env.compose.local build
@docker compose --env-file .env.compose.local up --no-start

services-up: check-env-file
@service_names="$(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))"; \
docker compose --env-file .env.compose.local --parallel $(DOCKER_PARALLEL) up -d $$service_names
@# TODO: Revisit compose-native parallel builds once Docker Compose v5 parallel limits are reliable again.
if [ -n "$$service_names" ]; then \
printf '%s\n' $$service_names | xargs -n $(DOCKER_PARALLEL) docker compose --env-file .env.compose.local up -d; \
else \
docker compose --env-file .env.compose.local config --services | xargs -n $(DOCKER_PARALLEL) docker compose --env-file .env.compose.local up -d; \
fi

services-stop:
@service_names="$(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))"; \
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/dashboard/client/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default tseslint.config(
},
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'react/prop-types': 'off',
'react/display-name': 'off',
'react/react-in-jsx-scope': 'off',
Expand Down
8 changes: 4 additions & 4 deletions packages/apps/dashboard/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@human-protocol/sdk": "workspace:*",
"@mui/icons-material": "^7.2.0",
"@mui/icons-material": "^7.3.8",
"@mui/material": "^7.2.0",
"@mui/styled-engine-sc": "7.2.0",
"@mui/system": "^7.2.0",
Expand All @@ -35,7 +35,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-number-format": "^5.4.3",
"react-router-dom": "^6.23.1",
"react-router-dom": "^7.13.0",
"recharts": "^2.13.0-alpha.4",
"simplebar-react": "^3.3.2",
"styled-components": "^6.1.11",
Expand All @@ -46,7 +46,7 @@
"zustand": "^5.0.10"
},
"devDependencies": {
"@eslint/js": "^9.27.0",
"@eslint/js": "^10.0.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^7.2.0",
Expand All @@ -59,7 +59,7 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.11",
"globals": "^16.2.0",
"prettier": "^3.7.4",
"prettier": "^3.8.1",
"sass": "^1.89.2",
"terser": "^5.36.0",
"typescript": "^5.6.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/dashboard/server/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default tseslint.config(
jest: jestPlugin,
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/dashboard/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-prettier": "^5.5.5",
"jest": "^29.7.0",
"prettier": "^3.7.4",
"prettier": "^3.8.1",
"source-map-support": "^0.5.20",
"ts-jest": "29.2.5",
"ts-node": "^10.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
HttpException,
} from '@nestjs/common';
import { Request, Response } from 'express';
import { SubgraphRequestError } from '@human-protocol/sdk';

import logger from '../../logger';

Expand All @@ -23,7 +24,15 @@ export class ExceptionFilter implements IExceptionFilter {
message: 'Internal server error',
};

if (exception instanceof HttpException) {
if (exception instanceof SubgraphRequestError) {
status = HttpStatus.BAD_GATEWAY;
responseBody.message = exception.message;

this.logger.error('Subgraph request failed', {
error: exception,
path: request.url,
});
} else if (exception instanceof HttpException) {
status = exception.getStatus();
const exceptionResponse = exception.getResponse();
if (typeof exceptionResponse === 'string') {
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/faucet/client/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default tseslint.config(
},
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/faucet/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@human-protocol/sdk": "workspace:*",
"@mui/icons-material": "^7.0.1",
"@mui/icons-material": "^7.3.8",
"@mui/material": "^5.16.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-loading-skeleton": "^3.3.1",
"react-router-dom": "^6.4.3",
"react-router-dom": "^7.13.0",
"serve": "^14.2.4",
"viem": "2.x"
},
Expand All @@ -41,7 +41,7 @@
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^5.1.0",
"prettier": "^3.7.4",
"prettier": "^3.8.1",
"typescript": "^5.8.3",
"vite": "^6.2.4",
"vite-plugin-node-polyfills": "^0.25.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/faucet/server/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default tseslint.config(
},
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'no-console': 'warn',
'prettier/prettier': 'error',
'@/quotes': [
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/fortune/exchange-oracle/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN yarn workspaces focus @apps/fortune-exchange-oracle-client
# Copy base TS config that is required to build packages
COPY tsconfig.base.json ./
# Build libs (scoped)
RUN yarn workspaces foreach -Rpt --from @apps/fortune-exchange-oracle-client run build
RUN yarn workspaces foreach -Rpt --from @apps/fortune-exchange-oracle-client --exclude @apps/fortune-exchange-oracle-client run build

# Copy everything else
COPY ${APP_PATH} ./${APP_PATH}
Expand All @@ -32,4 +32,4 @@ WORKDIR ./${APP_PATH}
RUN yarn build

# Start the server using the build
CMD [ "yarn", "start:prod" ]
CMD [ "yarn", "start:prod" ]
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const config = tseslint.config(
'react-refresh': reactRefreshPlugin,
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react-refresh/only-export-components': [
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/fortune/exchange-oracle/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@human-protocol/sdk": "workspace:^",
"@mui/icons-material": "^7.0.1",
"@mui/icons-material": "^7.3.8",
"@mui/material": "^5.16.7",
"@tanstack/query-sync-storage-persister": "^5.68.0",
"@tanstack/react-query": "^5.67.2",
Expand All @@ -39,7 +39,7 @@
"ethers": "^6.15.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.1",
"react-router-dom": "^7.13.0",
"serve": "^14.2.4",
"viem": "2.x",
"wagmi": "^2.14.6"
Expand All @@ -54,7 +54,7 @@
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.11",
"prettier": "^3.7.4",
"prettier": "^3.8.1",
"typescript": "^5.6.3",
"vite": "^6.2.4",
"vite-plugin-node-polyfills": "^0.25.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/fortune/exchange-oracle/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN yarn workspaces focus @apps/fortune-exchange-oracle-server
# Copy base TS config that is required to build packages
COPY tsconfig.base.json ./
# Build libs (scoped)
RUN yarn workspaces foreach -Rpt --from @apps/fortune-exchange-oracle-server run build
RUN yarn workspaces foreach -Rpt --from @apps/fortune-exchange-oracle-server --exclude @apps/fortune-exchange-oracle-server run build

# Copy everything else
COPY ${APP_PATH} ./${APP_PATH}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const config = tseslint.config(
jest: jestPlugin,
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/fortune/exchange-oracle/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-prettier": "^5.5.5",
"jest": "^29.7.0",
"prettier": "^3.7.4",
"prettier": "^3.8.1",
"source-map-support": "^0.5.20",
"ts-jest": "29.2.5",
"ts-node": "^10.9.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
HttpStatus,
} from '@nestjs/common';
import { Request, Response } from 'express';
import { SubgraphRequestError } from '@human-protocol/sdk';

import logger from '../../logger';
import {
Expand Down Expand Up @@ -36,6 +37,8 @@ export class ExceptionFilter implements IExceptionFilter {
return HttpStatus.UNPROCESSABLE_ENTITY;
} else if (exception instanceof DatabaseError) {
return HttpStatus.UNPROCESSABLE_ENTITY;
} else if (exception instanceof SubgraphRequestError) {
return HttpStatus.BAD_GATEWAY;
}

const exceptionStatusCode = exception.statusCode || exception.status;
Expand All @@ -51,7 +54,12 @@ export class ExceptionFilter implements IExceptionFilter {
const status = this.getStatus(exception);
const message = exception.message || 'Internal server error';

if (status === HttpStatus.INTERNAL_SERVER_ERROR) {
if (exception instanceof SubgraphRequestError) {
this.logger.error('Subgraph request failed', {
error: exception,
path: request.url,
});
} else if (status === HttpStatus.INTERNAL_SERVER_ERROR) {
this.logger.error('Unhandled exception', {
error: exception,
path: request.url,
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/fortune/recording-oracle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN yarn workspaces focus @apps/fortune-recording-oracle
# Copy base TS config that is required to build packages
COPY tsconfig.base.json ./
# Build libs (scoped)
RUN yarn workspaces foreach -Rpt --from @apps/fortune-recording-oracle run build
RUN yarn workspaces foreach -Rpt --from @apps/fortune-recording-oracle --exclude @apps/fortune-recording-oracle run build

# Copy everything else
COPY ${APP_PATH} ./${APP_PATH}
Expand Down
2 changes: 2 additions & 0 deletions packages/apps/fortune/recording-oracle/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default tseslint.config(
jest: jestPlugin,
},
rules: {
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'no-console': 'warn',
'prettier/prettier': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/fortune/recording-oracle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-prettier": "^5.5.5",
"jest": "^29.7.0",
"prettier": "^3.7.4",
"prettier": "^3.8.1",
"ts-jest": "29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.8.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const envValidator = Joi.object({
PORT: Joi.string(),
// Web3
WEB3_PRIVATE_KEY: Joi.string().required(),
SDK_TX_TIMEOUT_MS: Joi.number(),
RPC_URL_POLYGON: Joi.string(),
RPC_URL_BSC: Joi.string(),
RPC_URL_POLYGON_AMOY: Joi.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ export class Web3ConfigService {
get privateKey(): string {
return this.configService.getOrThrow<string>('WEB3_PRIVATE_KEY');
}

/**
* Timeout for web3 transactions in milliseconds.
* Default: 60000 (60 seconds)
*/
get txTimeoutMs(): number {
return +this.configService.get<number>('SDK_TX_TIMEOUT_MS', 60000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
HttpStatus,
} from '@nestjs/common';
import { Request, Response } from 'express';
import { SubgraphRequestError } from '@human-protocol/sdk';

import logger from '../../logger';
import {
Expand Down Expand Up @@ -33,6 +34,8 @@ export class ExceptionFilter implements IExceptionFilter {
return HttpStatus.CONFLICT;
} else if (exception instanceof ServerError) {
return HttpStatus.UNPROCESSABLE_ENTITY;
} else if (exception instanceof SubgraphRequestError) {
return HttpStatus.BAD_GATEWAY;
}

const exceptionStatusCode = exception.statusCode || exception.status;
Expand All @@ -48,7 +51,12 @@ export class ExceptionFilter implements IExceptionFilter {
const status = this.getStatus(exception);
const message = exception.message || 'Internal server error';

if (status === HttpStatus.INTERNAL_SERVER_ERROR) {
if (exception instanceof SubgraphRequestError) {
this.logger.error('Subgraph request failed', {
error: exception,
path: request.url,
});
} else if (status === HttpStatus.INTERNAL_SERVER_ERROR) {
this.logger.error('Unhandled exception', {
error: exception,
path: request.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export class JobService {
jobSolutionUploaded.url,
jobSolutionUploaded.hash,
!lastProcessedSolution?.error ? amountToReserve : 0n,
{ timeoutMs: this.web3ConfigService.txTimeoutMs },
);

if (
Expand Down Expand Up @@ -307,6 +308,7 @@ export class JobService {
intermediateResultsURL,
intermediateResultsHash,
0n,
{ timeoutMs: this.web3ConfigService.txTimeoutMs },
);

let reputationOracleWebhook: string | null = null;
Expand Down
Loading
Loading