Skip to content

Commit 964fd22

Browse files
authored
Merge pull request #2589 from humanprotocol/develop
Release 20241004
2 parents 3fbc5fc + 0ff14ed commit 964fd22

File tree

86 files changed

+1997
-1687
lines changed

Some content is hidden

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

86 files changed

+1997
-1687
lines changed

packages/apps/dashboard/ui-2024/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"@emotion/react": "^11.11.4",
1717
"@emotion/styled": "^11.11.5",
18-
"@mui/icons-material": "^5.15.18",
18+
"@mui/icons-material": "^6.1.1",
1919
"@mui/material": "^5.15.18",
2020
"@mui/styled-engine-sc": "6.0.0-alpha.18",
2121
"@mui/x-date-pickers": "^7.5.0",

packages/apps/dashboard/ui/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@emotion/react": "^11.10.5",
99
"@emotion/styled": "^11.10.5",
1010
"@human-protocol/sdk": "*",
11-
"@mui/icons-material": "^5.15.11",
11+
"@mui/icons-material": "^6.1.1",
1212
"@mui/material": "^5.16.7",
1313
"@reduxjs/toolkit": "^2.2.7",
1414
"@tanstack/query-sync-storage-persister": "^5.38.0",
@@ -25,7 +25,7 @@
2525
"jszip": "^3.10.1",
2626
"nft.storage": "^7.2.0",
2727
"numeral": "^2.0.6",
28-
"openpgp": "^5.11.1",
28+
"openpgp": "^5.11.2",
2929
"react": "^18.2.0",
3030
"react-dom": "^18.2.0",
3131
"react-gtm-module": "^2.0.11",
@@ -41,7 +41,7 @@
4141
"web-vitals": "^4.2.2"
4242
},
4343
"devDependencies": {
44-
"@testing-library/jest-dom": "^6.4.2",
44+
"@testing-library/jest-dom": "^6.5.0",
4545
"@testing-library/react": "^15.0.7",
4646
"@types/crypto-js": "^4.1.2",
4747
"@types/file-saver": "^2.0.5",
Lines changed: 64 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,98 @@
11
# Environment Variables
22

3-
### POSTGRES_URL
4-
The URL for connecting to the PostgreSQL database.
5-
Required
3+
### The URL for connecting to the PostgreSQL database.
4+
POSTGRES_URL=
65

7-
### POSTGRES_HOST
8-
The hostname or IP address of the PostgreSQL database server.
9-
Required
6+
### The hostname or IP address of the PostgreSQL database server. Default: '127.0.0.1'
7+
POSTGRES_HOST="127.0.0.1"
108

11-
### POSTGRES_PORT
12-
The port number on which the PostgreSQL database server is listening.
13-
Required
9+
### The port number on which the PostgreSQL database server is listening. Default: 5432
10+
POSTGRES_PORT="5432"
1411

15-
### POSTGRES_USER
16-
The username for authenticating with the PostgreSQL database.
17-
Required
12+
### The username for authenticating with the PostgreSQL database. Default: 'operator'
13+
POSTGRES_USER="operator"
1814

19-
### POSTGRES_PASSWORD
20-
The password for authenticating with the PostgreSQL database.
21-
Required
15+
### The password for authenticating with the PostgreSQL database. Default: 'qwerty'
16+
POSTGRES_PASSWORD="qwerty"
2217

23-
### POSTGRES_DATABASE
24-
The name of the PostgreSQL database to connect to.
25-
Default: 'exchange-oracle'
18+
### The name of the PostgreSQL database to connect to. Default: 'exchange-oracle'
19+
POSTGRES_DATABASE="exchange-oracle"
2620

27-
### POSTGRES_SSL
28-
Indicates whether to use SSL for connections to the PostgreSQL database.
29-
Default: false
21+
### Indicates whether to use SSL for connections to the PostgreSQL database. Default: false
22+
POSTGRES_SSL="false"
3023

31-
### POSTGRES_LOGGING
32-
The logging level for PostgreSQL operations (e.g., 'debug', 'info').
33-
Required
24+
### The logging level for PostgreSQL operations (e.g., 'debug', 'info'). Default: 'log,info,warn,error'
25+
POSTGRES_LOGGING="log,info,warn,error"
3426

35-
### RPC_URL_SEPOLIA
36-
The RPC URL for the Sepolia network.
37-
Required
27+
### The RPC URL for the Sepolia network.
28+
RPC_URL_SEPOLIA=
3829

39-
### RPC_URL_POLYGON
40-
The RPC URL for the Polygon network.
41-
Required
30+
### The RPC URL for the Polygon network.
31+
RPC_URL_POLYGON=
4232

43-
### RPC_URL_POLYGON_AMOY
44-
The RPC URL for the Polygon Amoy network.
45-
Required
33+
### The RPC URL for the Polygon Amoy network.
34+
RPC_URL_POLYGON_AMOY=
4635

47-
### RPC_URL_BSC_MAINNET
48-
The RPC URL for the BSC Mainnet network.
49-
Required
36+
### The RPC URL for the BSC Mainnet network.
37+
RPC_URL_BSC_MAINNET=
5038

51-
### RPC_URL_BSC_TESTNET
52-
The RPC URL for the BSC Testnet network.
53-
Required
39+
### The RPC URL for the BSC Testnet network.
40+
RPC_URL_BSC_TESTNET=
5441

55-
### RPC_URL_MOONBEAM
56-
The RPC URL for the Moonbeam network.
57-
Required
42+
### The RPC URL for the Moonbeam network.
43+
RPC_URL_MOONBEAM=
5844

59-
### RPC_URL_XLAYER
60-
The RPC URL for the XLayer network.
61-
Required
45+
### The RPC URL for the XLayer network.
46+
RPC_URL_XLAYER=
6247

63-
### RPC_URL_LOCALHOST
64-
The RPC URL for the Localhost network.
65-
Required
48+
### The RPC URL for the Localhost network.
49+
RPC_URL_LOCALHOST=
6650

67-
### PGP_ENCRYPT
68-
Indicates whether PGP encryption should be used.
69-
Default: false
51+
### Indicates whether PGP encryption should be used. Default: false
52+
PGP_ENCRYPT="false"
7053

71-
### PGP_PRIVATE_KEY
72-
The private key used for PGP encryption or decryption.
73-
Required
54+
### The private key used for PGP encryption or decryption.
55+
PGP_PRIVATE_KEY=
7456

75-
### PGP_PASSPHRASE
76-
The passphrase associated with the PGP private key.
77-
Required
57+
### The passphrase associated with the PGP private key.
58+
PGP_PASSPHRASE=
7859

79-
### S3_ENDPOINT
80-
The endpoint URL for connecting to the S3 service.
81-
Default: '127.0.0.1'
60+
### The endpoint URL for connecting to the S3 service. Default: '127.0.0.1'
61+
S3_ENDPOINT="127.0.0.1"
8262

83-
### S3_PORT
84-
The port number for connecting to the S3 service.
85-
Default: 9000
63+
### The port number for connecting to the S3 service. Default: 9000
64+
S3_PORT="9000"
8665

87-
### S3_ACCESS_KEY
88-
The access key ID used to authenticate requests to the S3 service.
89-
Required
66+
### The access key ID used to authenticate requests to the S3 service. Required
67+
S3_ACCESS_KEY=
9068

91-
### S3_SECRET_KEY
92-
The secret access key used to authenticate requests to the S3 service.
93-
Required
69+
### The secret access key used to authenticate requests to the S3 service. Required
70+
S3_SECRET_KEY=
9471

95-
### S3_BUCKET
96-
The name of the S3 bucket where files will be stored.
97-
Default: 'exchange'
72+
### The name of the S3 bucket where files will be stored. Default: 'exchange'
73+
S3_BUCKET="exchange"
9874

99-
### S3_USE_SSL
100-
Indicates whether to use SSL (HTTPS) for connections to the S3 service.
101-
Default: false
75+
### Indicates whether to use SSL (HTTPS) for connections to the S3 service. Default: false
76+
S3_USE_SSL="false"
10277

103-
### NODE_ENV
104-
The environment in which the server is running (e.g., 'development', 'production').
105-
Default: 'development'
78+
### The environment in which the server is running (e.g., 'development', 'production'). Default: 'development'
79+
NODE_ENV="development"
10680

107-
### HOST
108-
The hostname or IP address on which the server will run.
109-
Default: 'localhost'
81+
### The hostname or IP address on which the server will run. Default: 'localhost'
82+
HOST="localhost"
11083

111-
### PORT
112-
The port number on which the server will listen for incoming connections.
113-
Default: 5000
84+
### The port number on which the server will listen for incoming connections. Default: 5000
85+
PORT="5000"
11486

115-
### FE_URL
116-
The URL of the frontend application that the server will communicate with.
117-
Default: 'http://localhost:3005'
87+
### The URL of the frontend application that the server will communicate with. Default: 'http://localhost:3005'
88+
FE_URL="http://localhost:3005"
11889

119-
### MAX_RETRY_COUNT
120-
The maximum number of retry attempts for certain operations.
121-
Default: 5
90+
### The maximum number of retry attempts for certain operations. Default: 5
91+
MAX_RETRY_COUNT="5"
12292

123-
### WEB3_ENV
124-
The environment in which the Web3 application is running.
125-
Default: 'testnet'
93+
### The environment in which the Web3 application is running. Default: 'testnet'
94+
WEB3_ENV="testnet"
12695

127-
### WEB3_PRIVATE_KEY
128-
The private key used for signing transactions.
129-
Required
96+
### The private key used for signing transactions. Required
97+
WEB3_PRIVATE_KEY=
13098

packages/apps/fortune/exchange-oracle/server/scripts/generate-env-doc.ts

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ const CONFIG_FOLDER_PATH = path.join(__dirname, '../src/common/config');
55
const OUTPUT_FILE_PATH = path.join(__dirname, '../ENV.md');
66

77
const envVarRegex =
8-
/(?:this\.configService\.)?(?:getOrThrow|get)(?:<[\w<>[\]]+>)?\(\s*'(\w+)'\s*(?:,\s*[^)]*)?\)/gs;
9-
const commentRegex = /\/\*\*([^*]*\*+([^/*][^*]*\*+)*)\//g;
8+
/(?:this\.configService\.)?(?:getOrThrow|get)(?:<[\w<>[\]]+>)?\(\s*'(\w+)'\s*(?:,\s*([^)]*))?\)/gs; // captures variable name and additional options
9+
const commentRegex = /\/\*\*([^*]*\*+([^/*][^*]*\*+)*)\//g; // captures comments
1010

1111
function extractEnvVarsWithComments(content: string) {
12-
const envVarsWithComments: { comment: string; envVar: string }[] = [];
12+
const envVarsWithComments: {
13+
comment: string;
14+
envVar: string;
15+
defaultValue?: string;
16+
}[] = [];
1317
let match: RegExpExecArray | null;
1418

1519
// Extract comments
@@ -19,49 +23,76 @@ function extractEnvVarsWithComments(content: string) {
1923
.split('\n') // Split the comment by lines
2024
.map((line) => line.replace(/^\s*\*\s?/, '').trim()) // Remove leading * and extra whitespace
2125
.filter((line) => line.length > 0) // Remove any empty lines
22-
.join('\n'); // Join lines back with line breaks
26+
.join(' '); // Join lines back with spaces (not line breaks)
2327
comments.push(cleanedComment);
2428
}
2529

2630
// Extract environment variables and their comments
27-
const envVarsMap = new Map<string, string>();
31+
const envVarsMap = new Map<
32+
string,
33+
{ comment: string; defaultValue?: string; required?: boolean }
34+
>();
2835
let commentIndex = 0;
2936

3037
while ((match = envVarRegex.exec(content)) !== null) {
3138
const envVar = match[1];
39+
const additionalOptions = match[2]; // capture additional options
40+
41+
// Skip variables without comments
42+
if (!comments[commentIndex]) {
43+
commentIndex++;
44+
continue;
45+
}
46+
3247
if (!envVarsMap.has(envVar)) {
33-
if (comments[commentIndex]) {
34-
const comment = comments[commentIndex];
35-
envVarsMap.set(envVar, comment);
48+
const comment = comments[commentIndex] || '';
49+
let required = false;
50+
let defaultValue: string | undefined;
51+
52+
// Check if the additional options include a default value or a required marker
53+
if (additionalOptions) {
54+
const defaultMatch = additionalOptions.match(/['"]([^'"]+)['"]/); // Match default values inside quotes
55+
if (defaultMatch) {
56+
defaultValue = defaultMatch[1];
57+
}
58+
required = additionalOptions.includes('required');
3659
}
60+
61+
// Check for default values in comments
62+
const defaultCommentMatch = comment.match(
63+
/Default:\s*['"]?([^'"]+)['"]?/,
64+
);
65+
if (defaultCommentMatch) {
66+
defaultValue = defaultCommentMatch[1];
67+
}
68+
69+
envVarsMap.set(envVar, {
70+
comment: `${comment}${required ? ' (Required)' : ''}${defaultValue ? `` : ''}`,
71+
defaultValue,
72+
required,
73+
});
3774
commentIndex++;
3875
}
3976
}
4077

41-
envVarsMap.forEach((comment, envVar) => {
42-
envVarsWithComments.push({ comment, envVar });
78+
envVarsMap.forEach(({ comment, defaultValue }, envVar) => {
79+
envVarsWithComments.push({ comment, envVar, defaultValue });
4380
});
4481

4582
return envVarsWithComments;
4683
}
4784

4885
function generateEnvMarkdown(
49-
envVarsWithComments: { comment: string; envVar: string }[],
86+
envVarsWithComments: {
87+
comment: string;
88+
envVar: string;
89+
defaultValue?: string;
90+
}[],
5091
) {
5192
let markdown = '# Environment Variables\n\n';
52-
let currentSection: string | null = null;
5393

54-
envVarsWithComments.forEach(({ comment, envVar }) => {
55-
if (comment.startsWith('Web3 config variables')) {
56-
if (currentSection) {
57-
markdown += `\n\n`;
58-
}
59-
markdown += `## ${comment}\n\n`;
60-
currentSection = comment;
61-
} else {
62-
markdown += `### ${envVar}\n`;
63-
markdown += `${comment}\n\n`;
64-
}
94+
envVarsWithComments.forEach(({ comment, envVar, defaultValue }) => {
95+
markdown += `### ${comment}\n${envVar}${defaultValue !== undefined ? `="${defaultValue}"` : '='}\n\n`;
6596
});
6697

6798
return markdown;
@@ -73,10 +104,24 @@ function processConfigFiles() {
73104
.filter(
74105
(file) =>
75106
file.endsWith('.ts') &&
76-
!['index.ts', 'env-schema.ts', 'config.module.ts'].includes(file),
107+
![
108+
'index.ts',
109+
'env-schema.ts',
110+
'config.module.ts',
111+
'cache-factory.config.ts',
112+
'common-config.module.ts',
113+
'gateway-config.service.ts',
114+
'gateway-config.types.ts',
115+
'params-decorators.ts',
116+
'spec',
117+
].includes(file),
77118
);
78119

79-
let allEnvVarsWithComments: { comment: string; envVar: string }[] = [];
120+
let allEnvVarsWithComments: {
121+
comment: string;
122+
envVar: string;
123+
defaultValue?: string;
124+
}[] = [];
80125

81126
files.forEach((file) => {
82127
const filePath = path.join(CONFIG_FOLDER_PATH, file);

0 commit comments

Comments
 (0)