Skip to content

Commit 1719acd

Browse files
committed
chore: update package dependencies and improve deployment script
- Updated dependencies in package.json for better compatibility and performance. - Refactored deploy.ts to enhance error handling and utilize environment variables. - Improved test structure in DataProtector.ts for better readability and maintainability. - Adjusted tsconfig.json to include additional directories for TypeScript compilation. - Simplified saveDeployment utility function in utils.ts. - Added .prettierignore file to exclude specific file types from formatting. - Introduced env.ts for environment variable validation using zod. - Created eslint.config.mjs for improved linting configuration.
1 parent 7e8d112 commit 1719acd

File tree

15 files changed

+7422
-9683
lines changed

15 files changed

+7422
-9683
lines changed
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# wallet used for transactions
2-
WALLET_PRIVATE_KEY=...
3-
4-
# environment to use for configuration (prod/staging)
5-
ENV=prod
2+
WALLET_PRIVATE_KEY=
63

74
# DatasetRegistry contract address override (deploy script only)
8-
# DATASET_REGISTRY_ADDRESS=0x...
5+
DATASET_REGISTRY_ADDRESS=
6+
7+
## RPC URL for the network
8+
RPC_URL=
9+
10+
## Mnemonic for the network
11+
MNEMONIC=

packages/smart-contract/.eslintrc.json

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.yml
2+
*json
3+
*.md
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
{
2-
"printWidth": 80,
3-
"tabWidth": 2,
4-
"useTabs": false,
5-
"semi": true,
2+
"printWidth": 100,
63
"singleQuote": true,
7-
"trailingComma": "es5",
8-
"bracketSpacing": true,
9-
"arrowParens": "always",
10-
"endOfLine": "lf",
4+
"tabWidth": 4,
5+
"trailingComma": "all",
6+
"endOfLine": "auto",
7+
"plugins": [
8+
"prettier-plugin-organize-imports",
9+
"prettier-plugin-solidity"
10+
],
1111
"overrides": [
12-
{
13-
"files": "*.sol",
14-
"options": {
15-
"printWidth": 80,
16-
"tabWidth": 4,
17-
"useTabs": false,
18-
"singleQuote": false,
19-
"bracketSpacing": false
20-
}
21-
}
12+
{
13+
"files": "*.sol",
14+
"options": {
15+
"singleQuote": false
16+
}
17+
}
2218
]
2319
}
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
{
2-
"extends": ["solhint:recommended"],
3-
"plugins": []
2+
"extends": [
3+
"solhint:recommended"
4+
],
5+
"plugins": [],
6+
"rules": {
7+
"compiler-version": [
8+
"error",
9+
"^0.8.19"
10+
],
11+
"func-visibility": [
12+
"warn",
13+
{
14+
"ignoreConstructors": true
15+
}
16+
],
17+
"quotes": [
18+
"error",
19+
"double"
20+
]
21+
}
422
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export const DATASET_REGISTRY_ADDRESS =
2-
'0x799DAa22654128d0C64d5b79eac9283008158730';
1+
export const DATASET_REGISTRY_ADDRESS = '0x799DAa22654128d0C64d5b79eac9283008158730';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'dotenv/config';
2+
import { z } from 'zod';
3+
4+
const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/;
5+
const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/;
6+
7+
const envSchema = z.object({
8+
// Clé privée du wallet utilisé pour les transactions
9+
WALLET_PRIVATE_KEY: z
10+
.string()
11+
.regex(privateKeyRegex, 'Invalid private key format')
12+
.optional()
13+
.or(z.literal('')),
14+
15+
// Adresse du DatasetRegistry (override)
16+
DATASET_REGISTRY_ADDRESS: z
17+
.string()
18+
.regex(addressRegex, 'Invalid Ethereum address format')
19+
.optional()
20+
.or(z.literal('')),
21+
22+
// URL du RPC utilisé pour la connexion réseau
23+
RPC_URL: z
24+
.string()
25+
.url('RPC_URL must be a valid URL')
26+
.optional()
27+
.or(z.literal('')),
28+
29+
// Mnemonic de déploiement ou interaction réseau
30+
MNEMONIC: z
31+
.string()
32+
.min(1, 'MNEMONIC cannot be empty')
33+
.optional()
34+
.or(z.literal('')),
35+
});
36+
37+
export const env = envSchema.parse(process.env);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import eslint from '@eslint/js';
2+
import tsEslint from '@typescript-eslint/eslint-plugin';
3+
import tsParser from '@typescript-eslint/parser';
4+
import importPlugin from 'eslint-plugin-import';
5+
6+
export default [
7+
{
8+
...eslint.configs.recommended,
9+
ignores: ['./tools/**'],
10+
languageOptions: {
11+
parser: tsParser,
12+
parserOptions: {
13+
ecmaVersion: 'latest',
14+
sourceType: 'module',
15+
},
16+
},
17+
plugins: {
18+
'@typescript-eslint': tsEslint,
19+
import: importPlugin,
20+
},
21+
},
22+
];
Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,58 @@
1-
import { HardhatUserConfig } from 'hardhat/config';
21
import '@nomicfoundation/hardhat-toolbox';
3-
import '@nomiclabs/hardhat-etherscan';
2+
import { HardhatUserConfig } from 'hardhat/config';
3+
import { env } from './config/env';
44

5-
const { WALLET_PRIVATE_KEY } = process.env;
5+
const privateKey = env.WALLET_PRIVATE_KEY;
66

77
const config: HardhatUserConfig = {
8-
defaultNetwork: 'hardhat',
9-
networks: {
10-
hardhat: {},
11-
// modify with the dev network when the environment is ready
12-
bellecour: {
13-
url: 'https://bellecour.iex.ec',
14-
gasPrice: 0,
15-
accounts: WALLET_PRIVATE_KEY ? [WALLET_PRIVATE_KEY] : [],
16-
},
17-
// poco-chain native config
18-
'dev-native': {
19-
chainId: 65535,
20-
url: process.env.RPC_URL ?? 'http://localhost:8545',
21-
accounts: {
22-
mnemonic: process.env.MNEMONIC ?? '',
23-
},
24-
gasPrice: 0,
8+
networks: {
9+
hardhat: {
10+
forking: {
11+
enabled: true,
12+
url: 'https://bellecour.iex.ec',
13+
},
14+
},
15+
// modify with the dev network when the environment is ready
16+
bellecour: {
17+
url: 'https://bellecour.iex.ec',
18+
gasPrice: 0,
19+
accounts: privateKey ? [privateKey] : [],
20+
},
21+
// poco-chain native config
22+
'dev-native': {
23+
chainId: 65535,
24+
url: env.RPC_URL ?? 'http://localhost:8545',
25+
accounts: {
26+
mnemonic: env.MNEMONIC ?? '',
27+
},
28+
gasPrice: 0,
29+
},
2530
},
26-
},
27-
//to verify contract on Blockscout
28-
etherscan: {
29-
apiKey: {
30-
bellecour: 'abc',
31+
//to verify contract on Blockscout
32+
etherscan: {
33+
apiKey: {
34+
bellecour: 'abc',
35+
},
36+
customChains: [
37+
{
38+
network: 'bellecour',
39+
chainId: 134,
40+
urls: {
41+
apiURL: 'https://blockscout.bellecour.iex.ec/api',
42+
browserURL: 'https://blockscout.bellecour.iex.ec',
43+
},
44+
},
45+
],
3146
},
32-
customChains: [
33-
{
34-
network: 'bellecour',
35-
chainId: 134,
36-
urls: {
37-
apiURL: 'https://blockscout.bellecour.iex.ec/api',
38-
browserURL: 'https://blockscout.bellecour.iex.ec',
47+
//compiler version
48+
solidity: {
49+
version: '0.8.19',
50+
settings: {
51+
optimizer: {
52+
enabled: true,
53+
runs: 200,
54+
},
3955
},
40-
},
41-
],
42-
},
43-
//compiler version
44-
solidity: {
45-
version: '0.8.19',
46-
settings: {
47-
optimizer: {
48-
enabled: true,
49-
runs: 200,
50-
},
5156
},
52-
},
5357
};
5458
export default config;

0 commit comments

Comments
 (0)