Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Westlad committed Oct 3, 2022
1 parent c4bf8f2 commit fc965c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
19 changes: 19 additions & 0 deletions doc/kyc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Nightfall KYC adaptions

Nightfall now incorporates the ability to manage a whitelist of accounts in support of KYC (Know Your Customer). When whitelisting is enabled, only accounts that are added to the whitelist are able to move funds from Layer 1 to Layer 2 and to withdraw Layer 1 funds from the Shield contract.

Whitelisting can be controlled either externally to the blockchain or via a smart contract. Nightfall is agnostic about how KYC is applied.

## Enabling Whitelisting

To enable whitelisting, the deployer container should have its `WHITELISTING` environment variable set to `enable`. Setting the `WHITELISTING` variable to anything else will desable whitlisting.

## Operating Whitelisting

The KYC adaptions have recognise a new actor, the whitelist manager. A whitelist manager is able to whitelist users and to remove them from the whitelist. Each whitelist manager manager has a group ID associated with them, and users are added to the whitelist managers group ID when they are whitelisted. In practice, the group ID currently has little effect, other than acting as a grouping variable; all whitelisted users can interact, regardless of their group ID.

Whitelist managers are created/removed by the contract owner (multisig). They can also operate as normal Nightfall users, thus they are able to whitelist themselves.

All whitelisting functionality is managed by the contract `KYC.sol`, the functions therein are self-explanatory.

Note that all users are, by default members of the null group (group ID = 0). Members of this group are NOT whitelisted when whitelisting is enabled. Memebership of any other group confirs whitlisted status.
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'hardhat-contract-sizer';

const config: HardhatUserConfig = {
solidity: {
version: '0.8.2',
version: '0.8.3',
settings: {
optimizer: {
enabled: true,
Expand Down
6 changes: 0 additions & 6 deletions nightfall-client/src/routes/kyc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import { addUserToWhitelist, removeUserFromWhitelist, isWhitelisted } from '../s
const router = express.Router();

router.get('/check', async (req, res, next) => {
logger.debug('kyc/check endpoint received GET');
try {
const { address } = req.query;
logger.debug(`Details requested with address ${address}`);
const whitelisted = await isWhitelisted(address);
res.json({ isWhitelisted: whitelisted });
} catch (err) {
logger.error(err);
next(err);
}
});
Expand All @@ -25,13 +23,11 @@ router.get('/check', async (req, res, next) => {
Add a use to a KYC whitelist (only works if user is a whitelist manager, otherwise just wastes gas)
*/
router.post('/add', async (req, res, next) => {
logger.debug('kyc/add endpoint received POST');
const { address } = req.body;
try {
const response = await addUserToWhitelist(address);
res.json(response);
} catch (err) {
logger.error(err);
next(err);
}
});
Expand All @@ -40,13 +36,11 @@ router.post('/add', async (req, res, next) => {
Add a use to a KYC whitelist (only works if user is a relevant (to the group) whitelist manager, otherwise just wastes gas)
*/
router.post('/remove', async (req, res, next) => {
logger.debug('kyc/remove endpoint received POST');
const { address } = req.body;
try {
const response = await removeUserFromWhitelist(address);
res.json(response);
} catch (err) {
logger.error(err);
next(err);
}
});
Expand Down
6 changes: 0 additions & 6 deletions test/kyc.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ describe('KYC tests', () => {
}
});

/*
beforeEach(async () => {
await nf3Users[0].deposit(erc20Address, tokenType, transferValue * 2, tokenId, fee);
await emptyL2();
});
*/
describe('Deposits from a non-whitelisted then whitelisted account', () => {
it('deposits from a non-whitelisted should revert', async function () {
logger.debug('Remove user from whitelist, they probably already are');
Expand Down

0 comments on commit fc965c5

Please sign in to comment.