Skip to content

Commit 5a3bd28

Browse files
authored
Feature/add prettier formatter (#568)
* Add Prettier configuration and ignore files for code formatting - Created .prettierignore to exclude specific directories and files from formatting. - Added .prettierrc.yml with custom settings for print width and trailing commas. - Updated package.json to include Prettier and its Solidity plugin as dependencies, along with scripts for formatting and checking code. * Run prettier formatting
1 parent 5fa10db commit 5a3bd28

File tree

162 files changed

+12482
-15261
lines changed

Some content is hidden

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

162 files changed

+12482
-15261
lines changed

contracts/.prettierignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# directories
2+
broadcast
3+
cache
4+
coverage
5+
node_modules
6+
out
7+
8+
# files
9+
*.env
10+
*.log
11+
.DS_Store
12+
.pnp.*
13+
bun.lockb
14+
lcov.info
15+
package-lock.json
16+
pnpm-lock.yaml
17+
yarn.lock

contracts/.prettierrc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
printWidth: 120
2+
trailingComma: "all"
3+
overrides:
4+
- files: "*.md"
5+
options:
6+
proseWrap: "always"
7+
plugins:
8+
- prettier-plugin-solidity

contracts/README.md

Lines changed: 76 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ This is the implementation of contracts for verification and management of ident
77
## ⚠️Cautions⚠️
88

99
When you do the upgrade, be careful with this storage patterns
10+
1011
- You can not change the order in which the contract state variables are declared, nor their type.
1112

12-
Pls see this page for more details: https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable#modifying-your-contracts
13+
Pls see this page for more details:
14+
https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable#modifying-your-contracts
1315

1416
## Integration Guide
17+
1518
In the npm package, you'll find the following directory structure:
1619

1720
```bash
@@ -26,7 +29,7 @@ In the npm package, you'll find the following directory structure:
2629
│ ├── IIdentityRegistryV1.sol
2730
│ ├── IIdentityVerificationHubV1.sol
2831
│ ├── IPassportAirdropRoot.sol
29-
│ ├── IRegisterCircuitVerifier.sol
32+
│ ├── IRegisterCircuitVerifier.sol
3033
│ ├── ISelfVerificationRoot.sol
3134
│ └── IVcAndDiscloseCircuitVerifier.sol
3235
└── libraries
@@ -37,75 +40,86 @@ In the npm package, you'll find the following directory structure:
3740
If you want to integrate SelfVerificationRoot.sol into your contract, you should also import these files.
3841

3942
```solidity
40-
import {SelfVerificationRoot} from "@selfxyz/contracts/contracts/abstract/SelfVerificationRoot.sol";
43+
import { SelfVerificationRoot } from "@selfxyz/contracts/contracts/abstract/SelfVerificationRoot.sol";
4144
42-
import {IVcAndDiscloseCircuitVerifier} from "@selfxyz/contracts/contracts/interfaces/IVcAndDiscloseCircuitVerifier.sol";
45+
import {
46+
IVcAndDiscloseCircuitVerifier
47+
} from "@selfxyz/contracts/contracts/interfaces/IVcAndDiscloseCircuitVerifier.sol";
4348
44-
import {IIdentityVerificationHubV1} from "@selfxyz/contracts/contracts/interfaces/IIdentityVerificationHubV1.sol";
49+
import { IIdentityVerificationHubV1 } from "@selfxyz/contracts/contracts/interfaces/IIdentityVerificationHubV1.sol";
4550
46-
import {CircuitConstants} from "@selfxyz/contracts/contracts/constants/CircuitConstants.sol";
51+
import { CircuitConstants } from "@selfxyz/contracts/contracts/constants/CircuitConstants.sol";
4752
```
4853

49-
And override verifySelfProof function and write your own logic.
50-
You can take a look at these examples.
54+
And override verifySelfProof function and write your own logic. You can take a look at these examples.
55+
5156
- [Airdrop](https://github.com/selfxyz/self/blob/main/contracts/contracts/example/Airdrop.sol)
5257
- [HappyBirthday](https://github.com/selfxyz/happy-birthday/blob/main/contracts/contracts/HappyBirthday.sol)
5358

5459
In the verifySelfProof function, you should add these validations
60+
5561
- Mandatory
56-
- scope validation
57-
- attestation id validation
62+
- scope validation
63+
- attestation id validation
5864
- Optional
59-
- nullifier validation
60-
- user id validation
61-
- age verification with olderThan
62-
- forbidden countries validation
63-
- ofac validation
65+
- nullifier validation
66+
- user id validation
67+
- age verification with olderThan
68+
- forbidden countries validation
69+
- ofac validation
6470

6571
Also, if you want to play with some attributes in the passport, you should import these libraries.
66-
``` solidity
67-
import {CircuitAttributeHandler} from "@selfxyz/contracts/contracts/libraries/CircuitAttributeHandler.sol";
68-
import {Formatter} from "@selfxyz/contracts/contracts/libraries/Formatter.sol";
72+
73+
```solidity
74+
import { CircuitAttributeHandler } from "@selfxyz/contracts/contracts/libraries/CircuitAttributeHandler.sol";
75+
import { Formatter } from "@selfxyz/contracts/contracts/libraries/Formatter.sol";
6976
```
7077

71-
CircuitAttributeHandler is the library to extract readable attributes in the passport from public signals.
72-
The formatter is responsible for converting other data included in the public signals.
73-
Use it when you want to validate information related to birthdays or the time when the proof was generated.
78+
CircuitAttributeHandler is the library to extract readable attributes in the passport from public signals. The formatter
79+
is responsible for converting other data included in the public signals. Use it when you want to validate information
80+
related to birthdays or the time when the proof was generated.
7481

7582
As an example, please refer to the following contract.
83+
7684
- [HappyBirthday](https://github.com/selfxyz/happy-birthday/blob/main/contracts/contracts/HappyBirthday.sol)
7785
- [getReadableRevealedData function in the hub contract](https://github.com/selfxyz/self/blob/bdcf9537b01570b2197ae378815adbcc9c8747e8/contracts/contracts/IdentityVerificationHubImplV1.sol#L313-L357)
7886

7987
## Building Contracts
8088

8189
1. Install dependencies:
90+
8291
```bash
8392
yarn install
8493
```
8594

8695
2. Compile the contracts:
96+
8797
```bash
8898
yarn run compile
8999
```
90100

91101
## Deployments
92102

93103
1. Deploy verifiers
104+
94105
```bash
95106
yarn run deploy:allverifiers:celo
96107
```
97108

98109
2. Deploy registry proxy and impl
110+
99111
```bash
100112
yarn run deploy:registry:celo
101113
```
102114

103115
3. Deploy hub proxy and impl
116+
104117
```bash
105118
yarn run deploy:hub:celo
106119
```
107120

108121
4. Update csca, ofac and hub address in registry
122+
109123
```bash
110124
yarn run update:cscaroot:celo
111125
yarn run update:ofacroot:celo
@@ -115,11 +129,11 @@ yarn run update:hub:celo
115129
## Testing
116130

117131
When you compile the circuits, make sure you set the build flag to true for these circuits:
132+
118133
- register_sha256_sha256_sha256_rsa_65537_4096
119134
- dsc_sha256_rsa_65537_4096
120-
- vc_and_disclose
121-
Go to ../circuits/scripts/build/ and change false to true for these circuits.
122-
Then you can run the following command to see the coverage.
135+
- vc_and_disclose Go to ../circuits/scripts/build/ and change false to true for these circuits. Then you can run the
136+
following command to see the coverage.
123137

124138
```shell
125139
cd ../circuits
@@ -130,45 +144,45 @@ yarn run test:coverage:local
130144

131145
## Deployed Contract Addresses
132146

133-
| Contract | Address |
134-
|----------|---------|
135-
| Verifier_dsc_sha1_ecdsa_brainpoolP256r1 | 0xE7B4A70fc1d96D3Fb6577206c932eF1e634Cf2d0 |
136-
| Verifier_dsc_sha1_rsa_65537_4096 | 0x19E25a5772df0D7D6Db59D94a4d6FBd7098a3012 |
137-
| Verifier_dsc_sha256_ecdsa_brainpoolP256r1 | 0x1F3afAe85992B1B8CF6946B091225dAF8307675d |
138-
| Verifier_dsc_sha256_ecdsa_brainpoolP384r1 | 0x52A6EF39655D662A8Cf8eB56CD853883fe43eb2b |
139-
| Verifier_dsc_sha256_ecdsa_secp256r1 | 0x643735Cd44F8b2BDa47b4a7962c8BDf12E6CDdf8 |
140-
| Verifier_dsc_sha256_ecdsa_secp384r1 | 0x00F0D1A32Def293DAB78100A6569ebb4EC035F82 |
141-
| Verifier_dsc_sha256_rsa_65537_4096 | 0x711e655c43410fB985c4EDB48E9bCBdDb770368d |
142-
| Verifier_dsc_sha256_rsapss_3_32_3072 | 0xDAFF470e561F3f96C7410AeF02196913E981fF1B |
143-
| Verifier_dsc_sha256_rsapss_65537_32_3072 | 0x07B6C2FFB098B131eAD104396d399177014ae15f |
144-
| Verifier_dsc_sha256_rsapss_65537_32_4096 | 0xFBDDADb864b24B2c4336081A22f41D04E7b35DA9 |
145-
| Verifier_dsc_sha384_ecdsa_brainpoolP384r1 | 0x6a40dfa6f99FA178aB6cc88928Bf30661e917A76 |
146-
| Verifier_dsc_sha384_ecdsa_secp384r1 | 0x1719430107E66717d8b34d4190838dfABAf810e6 |
147-
| Verifier_dsc_sha512_rsa_65537_4096 | 0xf5eE920d6D50a8A83C22f548bf406fCBcD558751 |
148-
| Verifier_dsc_sha512_rsapss_65537_64_4096 | 0x5438C4ebFD8Fcce6eb54542e3A5C192B22227f70 |
149-
| Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 | 0x8588e473428cf415F10AC96CAa701F6Cd1C8641F |
150-
| Verifier_register_sha1_sha1_sha1_rsa_65537_4096 | 0x15fd0d58cfF9DaA4A60105c0DAC73659530BB7f7 |
151-
| Verifier_register_sha1_sha256_sha256_rsa_65537_4096 | 0xaC5166A01Aee75A10703177896122F4d6e3836d1 |
147+
| Contract | Address |
148+
| ------------------------------------------------------------ | ------------------------------------------ |
149+
| Verifier_dsc_sha1_ecdsa_brainpoolP256r1 | 0xE7B4A70fc1d96D3Fb6577206c932eF1e634Cf2d0 |
150+
| Verifier_dsc_sha1_rsa_65537_4096 | 0x19E25a5772df0D7D6Db59D94a4d6FBd7098a3012 |
151+
| Verifier_dsc_sha256_ecdsa_brainpoolP256r1 | 0x1F3afAe85992B1B8CF6946B091225dAF8307675d |
152+
| Verifier_dsc_sha256_ecdsa_brainpoolP384r1 | 0x52A6EF39655D662A8Cf8eB56CD853883fe43eb2b |
153+
| Verifier_dsc_sha256_ecdsa_secp256r1 | 0x643735Cd44F8b2BDa47b4a7962c8BDf12E6CDdf8 |
154+
| Verifier_dsc_sha256_ecdsa_secp384r1 | 0x00F0D1A32Def293DAB78100A6569ebb4EC035F82 |
155+
| Verifier_dsc_sha256_rsa_65537_4096 | 0x711e655c43410fB985c4EDB48E9bCBdDb770368d |
156+
| Verifier_dsc_sha256_rsapss_3_32_3072 | 0xDAFF470e561F3f96C7410AeF02196913E981fF1B |
157+
| Verifier_dsc_sha256_rsapss_65537_32_3072 | 0x07B6C2FFB098B131eAD104396d399177014ae15f |
158+
| Verifier_dsc_sha256_rsapss_65537_32_4096 | 0xFBDDADb864b24B2c4336081A22f41D04E7b35DA9 |
159+
| Verifier_dsc_sha384_ecdsa_brainpoolP384r1 | 0x6a40dfa6f99FA178aB6cc88928Bf30661e917A76 |
160+
| Verifier_dsc_sha384_ecdsa_secp384r1 | 0x1719430107E66717d8b34d4190838dfABAf810e6 |
161+
| Verifier_dsc_sha512_rsa_65537_4096 | 0xf5eE920d6D50a8A83C22f548bf406fCBcD558751 |
162+
| Verifier_dsc_sha512_rsapss_65537_64_4096 | 0x5438C4ebFD8Fcce6eb54542e3A5C192B22227f70 |
163+
| Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 | 0x8588e473428cf415F10AC96CAa701F6Cd1C8641F |
164+
| Verifier_register_sha1_sha1_sha1_rsa_65537_4096 | 0x15fd0d58cfF9DaA4A60105c0DAC73659530BB7f7 |
165+
| Verifier_register_sha1_sha256_sha256_rsa_65537_4096 | 0xaC5166A01Aee75A10703177896122F4d6e3836d1 |
152166
| Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 | 0x7d9b7D2A95541b50CECDB44d82c0570a818111Ac |
153-
| Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 | 0x48cEc90de8d746efD316968Ea65417e74C6A1a74 |
167+
| Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 | 0x48cEc90de8d746efD316968Ea65417e74C6A1a74 |
154168
| Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 | 0x9C5Af0FC9A32b457e300905929A05356D3C0DB25 |
155169
| Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 | 0x5286E20745A0d4C35E6D97832D56e30A28303BD6 |
156-
| Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 | 0xaC861bf9FC8B44ccbAde8E2A39C851bbCf38c392 |
157-
| Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 | 0x03FCc979cf2d69275647095E4079A3389F24525D |
158-
| Verifier_register_sha256_sha256_sha256_rsa_3_4096 | 0xbE036B26317F013D2c6cB092Aa1fa903220be846 |
159-
| Verifier_register_sha256_sha256_sha256_rsa_65537_4096 | 0xE80537B3399bd405e40136D08e24c250397c09F1 |
160-
| Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 | 0xe063BD3188341B2D17d96cE38FD31584147d3219 |
161-
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 | 0xe93Be9382868f30150cAF77793aF384905c2C7E4 |
162-
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 | 0xD39E5eAfb6d266E3c4AC8255578F23a514fd8B36 |
170+
| Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 | 0xaC861bf9FC8B44ccbAde8E2A39C851bbCf38c392 |
171+
| Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 | 0x03FCc979cf2d69275647095E4079A3389F24525D |
172+
| Verifier_register_sha256_sha256_sha256_rsa_3_4096 | 0xbE036B26317F013D2c6cB092Aa1fa903220be846 |
173+
| Verifier_register_sha256_sha256_sha256_rsa_65537_4096 | 0xE80537B3399bd405e40136D08e24c250397c09F1 |
174+
| Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 | 0xe063BD3188341B2D17d96cE38FD31584147d3219 |
175+
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 | 0xe93Be9382868f30150cAF77793aF384905c2C7E4 |
176+
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 | 0xD39E5eAfb6d266E3c4AC8255578F23a514fd8B36 |
163177
| Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 | 0xd2F65a76A10f5E0e7aE9d18826ab463f4CEb33C9 |
164-
| Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 | 0xC33E6A04b7296A3062Cf438C33dc8D8157c3916d |
165-
| Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 | 0xa7A5A581C2Eb8dF39f486e9ABBc4898546D70C3e |
166-
| Verifier_register_sha512_sha512_sha512_rsa_65537_4096 | 0x6C88A6Afc38cA2859e157532b1b872EcC1ED0424 |
167-
| Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 | 0x04A1D0d51Bc078CB137088424b2ec569699dd7A5 |
168-
| Verifier_vc_and_disclose | 0x44d314c2F9b3690735808d26d17dFCc9F906A9B4 |
169-
| PoseidonT3 | 0xF134707a4C4a3a76b8410fC0294d620A7c341581 |
170-
| IdentityRegistryImplV1 | 0xC473d5F784e424A70Bf7aCf887E33448E64F8798 |
171-
| IdentityRegistry | 0x37F5CB8cB1f6B00aa768D8aA99F1A9289802A968 |
172-
| IdentityVerificationHubImplV1 | 0x85FD004B2312a6703F1ce293242Dc15B719772b1 |
173-
| IdentityVerificationHub | 0x77117D60eaB7C044e785D68edB6C7E0e134970Ea |
174-
| VerifyAll | 0xe6D61680A6ED381bb5A0dB5cF4E9Cc933cF43915 |
178+
| Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 | 0xC33E6A04b7296A3062Cf438C33dc8D8157c3916d |
179+
| Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 | 0xa7A5A581C2Eb8dF39f486e9ABBc4898546D70C3e |
180+
| Verifier_register_sha512_sha512_sha512_rsa_65537_4096 | 0x6C88A6Afc38cA2859e157532b1b872EcC1ED0424 |
181+
| Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 | 0x04A1D0d51Bc078CB137088424b2ec569699dd7A5 |
182+
| Verifier_vc_and_disclose | 0x44d314c2F9b3690735808d26d17dFCc9F906A9B4 |
183+
| PoseidonT3 | 0xF134707a4C4a3a76b8410fC0294d620A7c341581 |
184+
| IdentityRegistryImplV1 | 0xC473d5F784e424A70Bf7aCf887E33448E64F8798 |
185+
| IdentityRegistry | 0x37F5CB8cB1f6B00aa768D8aA99F1A9289802A968 |
186+
| IdentityVerificationHubImplV1 | 0x85FD004B2312a6703F1ce293242Dc15B719772b1 |
187+
| IdentityVerificationHub | 0x77117D60eaB7C044e785D68edB6C7E0e134970Ea |
188+
| VerifyAll | 0xe6D61680A6ED381bb5A0dB5cF4E9Cc933cF43915 |

contracts/contracts/IdentityVerificationHub.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ contract IdentityVerificationHub is ProxyRoot {
1616
* @param _data The initialization data to be executed in the context of the implementation contract.
1717
*/
1818
constructor(address _logic, bytes memory _data) ProxyRoot(_logic, _data) {}
19-
}
19+
}

0 commit comments

Comments
 (0)