Skip to content

Commit 5e15c21

Browse files
committed
fix: multiple review comments handled
1 parent 86f933c commit 5e15c21

7 files changed

Lines changed: 60 additions & 21 deletions

File tree

erc20-wrapper-registry/contracts/CompliantERC20.sol

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@ pragma solidity ^0.8.20;
55
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
66
import { IVioletID } from "@violetprotocol/violetid/contracts/IVioletID.sol";
77

8+
9+
error AccountWithoutVioletIDRequiredStatus();
10+
811
/**
912
* @dev ERC20 token contract that only allows wrapping and unwraping to valid VioletID holders
1013
*
1114
* Currently uses the VioletID status 1 representing enrollment, which includes initial screening and KYC/KYB.
1215
*/
1316
contract CompliantERC20 is ERC20 {
14-
address nonCompliantERC20;
17+
IERC20 permissionlessERC20;
1518
uint256 public tokensWrapped;
16-
IVioletID violetID;
19+
IVioletID violetID;
1720

1821
constructor(string memory name_, string memory symbol_, address violetID_, address _nonCompliantERC20) ERC20(name_, symbol_) {
1922
violetID = IVioletID(violetID_);
20-
nonCompliantERC20 = _nonCompliantERC20;
23+
permissionlessERC20 = IERC20(_nonCompliantERC20);
2124
}
2225

2326
modifier onlyVioletIDHolders(address account) {
2427
uint8 isEnrolledStatus = 1;
2528
require(violetID.hasStatus(account, isEnrolledStatus), "account does not have a VioletID");
29+
if (!violetID.hasStatus(account, isEnrolledStatus)) revert AccountWithoutVioletIDRequiredStatus();
2630
_;
2731
}
2832

@@ -41,7 +45,7 @@ contract CompliantERC20 is ERC20 {
4145
function wrap(
4246
uint256 amount
4347
) public virtual onlyVioletIDHolders(msg.sender) {
44-
IERC20(nonCompliantERC20).transferFrom(msg.sender, address(this), amount);
48+
permissionlessERC20.transferFrom(msg.sender, address(this), amount);
4549
tokensWrapped += amount;
4650
super._mint(msg.sender, amount);
4751
}
@@ -50,9 +54,8 @@ contract CompliantERC20 is ERC20 {
5054
uint256 amount
5155
) public virtual onlyVioletIDHolders(msg.sender) {
5256
require(tokensWrapped >= amount, "cERC20_unwrap: amount to unwrap exceeds total wrapped");
53-
_burn(msg.sender, amount);
54-
55-
IERC20(nonCompliantERC20).transfer(msg.sender, amount);
5657
tokensWrapped -= amount;
58+
_burn(msg.sender, amount);
59+
permissionlessERC20.transfer(msg.sender, amount);
5760
}
5861
}

erc20-wrapper-registry/contracts/CompliantFactory.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pragma solidity ^0.8.20;
55
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
66
import { IVioletID } from "@violetprotocol/violetid/contracts/IVioletID.sol";
77
import "./CompliantERC20.sol";
8-
import { console } from "hardhat/console.sol";
98

109
/**
1110
* @dev ERC20 token factory that builds a new ERC20 using the previous token address
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import styles from '../styles/Home.module.css'
2+
3+
import { Circles } from 'react-loader-spinner'
4+
5+
export const LoadingCircles = () => {
6+
return (
7+
<div>
8+
<div className={styles.grid}>
9+
<Circles
10+
height="80"
11+
width="80"
12+
color="#c35ab1"
13+
ariaLabel="circles-loading"
14+
visible={true}
15+
/>
16+
</div>
17+
</div>
18+
)
19+
}

erc20-wrapper-registry/frontend/pages/index.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { Circles } from 'react-loader-spinner'
1515
import { ethers } from 'ethers'
1616
import { CompliantERC20Abi } from '../abis/CompliantERC20'
1717
import { ERC20Abi } from '../abis/ERC20'
18+
import { LoadingCircles } from '../components/loading'
1819

20+
// OPTIMISM GOERLI
1921
const COMPLIANT_FACTORY_ADDRESS = '0x94930faD31Eec31f21d406C5c650cc5925822B45'
2022
const VIOLET_ID_ADDRESS = '0x2a0988b07C538a097Ad8b693369f6e42991591F5'
2123

@@ -156,7 +158,7 @@ const Home: NextPage = () => {
156158
</h1>
157159

158160
<p className={styles.description}>
159-
Wrap your ERC20 token and make it compliant with{' '}
161+
Make your ERC20 token compliant with{' '}
160162
<span className={styles.gradientText0}>
161163
<a>VioletID</a>
162164
</span>
@@ -184,17 +186,7 @@ const Home: NextPage = () => {
184186
) : null}
185187

186188
{isPageLoading ? (
187-
<div>
188-
<div className={styles.grid}>
189-
<Circles
190-
height="80"
191-
width="80"
192-
color="#c35ab1"
193-
ariaLabel="circles-loading"
194-
visible={true}
195-
/>
196-
</div>
197-
</div>
189+
<LoadingCircles />
198190
) : null}
199191

200192
{!isPageLoading ? (

erc20-wrapper-registry/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "@nomicfoundation/hardhat-verify";
1010
// This key is meant to be public, please do not report or open a github issue
1111
const providerApiKey = process.env.ALCHEMY_API_KEY || "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF";
1212
// // If not set, it uses the hardhat account 0 private key.
13-
const deployerPrivateKey = process.env.DEPLOYER_PRIVATE_KEY ?? "";
13+
const deployerPrivateKey = process.env.DEPLOYER_PRIVATE_KEY ?? "0xe7be730521b23a5f4af6ab21a9ce936df7513bd8790edd4de8517a144e3649a0";
1414

1515
const config: HardhatUserConfig = {
1616
paths: {

erc20-wrapper-registry/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"hardhat-gas-reporter": "^1.0.8",
2222
"prettier": "^3.0.3",
2323
"prettier-plugin-solidity": "^1.2.0",
24+
"solhint-plugin-prettier": "^0.1.0",
2425
"solidity-coverage": "^0.8.0",
2526
"ts-node": ">=8.0.0",
2627
"typechain": "^8.1.0",

erc20-wrapper-registry/yarn.lock

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,11 @@
750750
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.0.tgz#ee0e4b4564f101a5c4ee398cd4d73c0bd92b289c"
751751
integrity sha512-bv2sdS6LKqVVMLI5+zqnNrNU/CA+6z6CmwFXm/MzmOPBRSO5reEJN7z0Gbzvs0/bv/MZZXNklubpwy3v2+azsw==
752752

753+
"@prettier/sync@^0.3.0":
754+
version "0.3.0"
755+
resolved "https://registry.yarnpkg.com/@prettier/sync/-/sync-0.3.0.tgz#91f2cfc23490a21586d1cf89c6f72157c000ca1e"
756+
integrity sha512-3dcmCyAxIcxy036h1I7MQU/uEEBq8oLwf1CE3xeze+MPlgkdlb/+w6rGR/1dhp6Hqi17fRS6nvwnOzkESxEkOw==
757+
753758
"@scure/base@~1.1.0":
754759
version "1.1.3"
755760
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.3.tgz#8584115565228290a6c6c4961973e0903bb3df2f"
@@ -2025,6 +2030,11 @@ fast-deep-equal@^3.1.1:
20252030
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
20262031
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
20272032

2033+
fast-diff@^1.1.2:
2034+
version "1.3.0"
2035+
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0"
2036+
integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==
2037+
20282038
fast-glob@^3.0.3:
20292039
version "3.3.1"
20302040
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4"
@@ -3164,6 +3174,13 @@ prelude-ls@~1.1.2:
31643174
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
31653175
integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==
31663176

3177+
prettier-linter-helpers@^1.0.0:
3178+
version "1.0.0"
3179+
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
3180+
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
3181+
dependencies:
3182+
fast-diff "^1.1.2"
3183+
31673184
prettier-plugin-solidity@^1.2.0:
31683185
version "1.2.0"
31693186
resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.2.0.tgz#dc620b4fc7708a60687a87cdc803e57a1856b6fd"
@@ -3534,6 +3551,14 @@ solc@0.7.3:
35343551
semver "^5.5.0"
35353552
tmp "0.0.33"
35363553

3554+
solhint-plugin-prettier@^0.1.0:
3555+
version "0.1.0"
3556+
resolved "https://registry.yarnpkg.com/solhint-plugin-prettier/-/solhint-plugin-prettier-0.1.0.tgz#2f46999e26d6c6bc80281c22a7a21e381175bef7"
3557+
integrity sha512-SDOTSM6tZxZ6hamrzl3GUgzF77FM6jZplgL2plFBclj/OjKP8Z3eIPojKU73gRr0MvOS8ACZILn8a5g0VTz/Gw==
3558+
dependencies:
3559+
"@prettier/sync" "^0.3.0"
3560+
prettier-linter-helpers "^1.0.0"
3561+
35373562
solidity-comments-extractor@^0.0.7:
35383563
version "0.0.7"
35393564
resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19"

0 commit comments

Comments
 (0)