Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brand new design for clr.fund dapp #546

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c14e626
use brightid v6 api
yuetloo Aug 10, 2022
9233d16
enable brightid blind signatures
yuetloo Aug 10, 2022
f387a0f
update brightid verification check to work with v6 and fix ipfs uploa…
yuetloo Aug 12, 2022
736589e
fix lint warning
yuetloo Aug 12, 2022
4c8c616
feat: added new font
pkretzschmar Aug 16, 2022
6804ad2
styles: change font style and text color
pkretzschmar Aug 16, 2022
3ab2fcd
Merge branch 'brightid-v6' into styles/new-themes
pkretzschmar Aug 16, 2022
ac059a2
feat: new images
pkretzschmar Aug 23, 2022
4432cd5
styles: added new font style
pkretzschmar Aug 23, 2022
fa8c27c
style: change button to new format
pkretzschmar Aug 23, 2022
c5617db
style: added new buttons and typography to theme
pkretzschmar Aug 23, 2022
0b5d83c
style: new colors and variables to manage light/dark theme
pkretzschmar Aug 23, 2022
5c967cb
hotfix: added new criterias
pkretzschmar Aug 23, 2022
0ae3921
styles: minor css changes
pkretzschmar Aug 23, 2022
9f086e6
style: change bright id widget to match new design
pkretzschmar Aug 23, 2022
4260221
styles: refactor cart to match new design
pkretzschmar Aug 23, 2022
4006edd
styles: refactor profile component
pkretzschmar Aug 23, 2022
dd0b5b5
styles: refactor success pages to match new design
pkretzschmar Aug 23, 2022
90b35f8
style: refactor project page
pkretzschmar Aug 23, 2022
485f1f4
hotfix: small css changes
pkretzschmar Aug 23, 2022
e6d39aa
style: refactor time-left component
pkretzschmar Aug 23, 2022
8d89b36
style: refactor about page
pkretzschmar Aug 23, 2022
4de3fb9
style: refactor join page
pkretzschmar Aug 23, 2022
b06fedc
style: refactor landing page
pkretzschmar Aug 23, 2022
82f20bc
Merge pull request #1 from GeneralMagicio/styles/new-themes
pkretzschmar Aug 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions contracts/contracts/userRegistry/BrightIdSponsor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.6.12;

contract BrightIdSponsor {
event Sponsor(address indexed addr);

/**
* @dev sponsor a BrightId user by emitting an event
* that a BrightId node is listening for
*/
function sponsor(address addr) public {
emit Sponsor(addr);
}
}
39 changes: 21 additions & 18 deletions contracts/contracts/userRegistry/BrightIdUserRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity ^0.6.12;

import './IUserRegistry.sol';
import './BrightIdSponsor.sol';
import '@openzeppelin/contracts/access/Ownable.sol';

contract BrightIdUserRegistry is Ownable, IUserRegistry {
Expand All @@ -13,48 +14,52 @@ contract BrightIdUserRegistry is Ownable, IUserRegistry {

bytes32 public context;
address public verifier;
BrightIdSponsor public brightIdSponsor;


struct Verification {
uint256 time;
bool isVerified;
}
mapping(address => Verification) public verifications;

event SetBrightIdSettings(bytes32 context, address verifier);
event Sponsor(address indexed addr);
event SetBrightIdSettings(bytes32 context, address verifier, address sponsor);
event Registered(address indexed addr, uint256 timestamp, bool isVerified);

/**
* @param _context BrightID context used for verifying users
* @param _verifier BrightID verifier address that signs BrightID verifications
*/
constructor(bytes32 _context, address _verifier) public {
constructor(bytes32 _context, address _verifier, address _sponsor) public {
// ecrecover returns zero on error
require(_verifier != address(0), ERROR_INVALID_VERIFIER);

context = _context;
verifier = _verifier;
brightIdSponsor = BrightIdSponsor(_sponsor);
}

/**
* @notice Sponsor a BrightID user by context id
* @param addr BrightID context id
*/
function sponsor(address addr) public {
emit Sponsor(addr);
brightIdSponsor.sponsor(addr);
}

/**
* @notice Set BrightID settings
* @param _context BrightID context used for verifying users
* @param _verifier BrightID verifier address that signs BrightID verifications
*/
function setSettings(bytes32 _context, address _verifier) external onlyOwner {
function setSettings(bytes32 _context, address _verifier, address _sponsor) external onlyOwner {
// ecrecover returns zero on error
require(_verifier != address(0), ERROR_INVALID_VERIFIER);

context = _context;
verifier = _verifier;
emit SetBrightIdSettings(_context, _verifier);
brightIdSponsor = BrightIdSponsor(_sponsor);
emit SetBrightIdSettings(_context, _verifier, _sponsor);
}

/**
Expand All @@ -74,34 +79,32 @@ contract BrightIdUserRegistry is Ownable, IUserRegistry {
/**
* @notice Register a user by BrightID verification
* @param _context The context used in the users verification
* @param _addrs The history of addresses used by this user in this context
* @param _addr The address used by this user in this context
* @param _verificationHash sha256 of the verification expression
* @param _timestamp The BrightID node's verification timestamp
* @param _v Component of signature
* @param _r Component of signature
* @param _s Component of signature
*/
function register(
bytes32 _context,
address[] calldata _addrs,
address _addr,
bytes32 _verificationHash,
uint _timestamp,
uint8 _v,
bytes32 _r,
bytes32 _s
) external {
require(context == _context, ERROR_INVALID_CONTEXT);
require(verifications[_addrs[0]].time < _timestamp, ERROR_NEWER_VERIFICATION);
require(verifications[_addr].time < _timestamp, ERROR_NEWER_VERIFICATION);

bytes32 message = keccak256(abi.encodePacked(_context, _addrs, _timestamp));
bytes32 message = keccak256(abi.encodePacked(_context, _addr, _verificationHash, _timestamp));
address signer = ecrecover(message, _v, _r, _s);
require(verifier == signer, ERROR_NOT_AUTHORIZED);

verifications[_addrs[0]].time = _timestamp;
verifications[_addrs[0]].isVerified = true;
for(uint i = 1; i < _addrs.length; i++) {
// update time of all previous context ids to be sure no one can use old verifications again
verifications[_addrs[i]].time = _timestamp;
// set old verifications unverified
verifications[_addrs[i]].isVerified = false;
}
verifications[_addr].time = _timestamp;
verifications[_addr].isVerified = true;

emit Registered(_addr, _timestamp, true);
}
}
60 changes: 60 additions & 0 deletions contracts/scripts/deployBrightIdSponsor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ethers } from 'hardhat'
import { Contract, utils } from 'ethers'

async function main() {
console.log('*******************')
console.log('Deploying a user registry!')
console.log('*******************')

if (!process.env.BRIGHTID_USER_REGISTRY) {
console.error('Missing BRIGHTID_USER_REGISTRY environment variable')
return
}
if (!process.env.BRIGHTID_CONTEXT) {
console.error('Missing BRIGHTID_CONTEXT environment variable')
return
}
if (!process.env.BRIGHTID_VERIFIER_ADDR) {
console.error('Missing BRIGHTID_VERIFIER_ADDR environment variable')
return
}

const [deployer] = await ethers.getSigners()
console.log('deployer.address: ', deployer.address)

console.log('deploying brightid sponsor contract')
const BrightIdSponsor = await ethers.getContractFactory(
'BrightIdSponsor',
deployer
)
const sponsor = await BrightIdSponsor.deploy()
const receipt = await sponsor.deployTransaction.wait()
console.log(`Deployed BrightId Sponsor Contract at ${sponsor.address}`)
console.log('transaction hash', receipt.transactionHash)

const userRegistry = await ethers.getContractAt(
'BrightIdUserRegistry',
process.env.BRIGHTID_USER_REGISTRY
)
const tx = await userRegistry.setSettings(
utils.formatBytes32String(process.env.BRIGHTID_CONTEXT),
process.env.BRIGHTID_VERIFIER_ADDR,
sponsor.address
)
const settingReceipt = await tx.wait()
console.log(
'Set user registry settings at hash',
settingReceipt.transactionHash
)

console.log('*******************')
console.log('Deploy complete!')
console.log('*******************')
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
71 changes: 71 additions & 0 deletions contracts/scripts/deployUserRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { ethers } from 'hardhat'
import { Contract, utils } from 'ethers'

async function main() {
console.log('*******************')
console.log('Deploying a user registry!')
console.log('*******************')
const [deployer] = await ethers.getSigners()
console.log('deployer.address: ', deployer.address)

const fundingRoundFactoryAddress = process.env.FUNDING_ROUND_FACTORY_ADDRESS

if (!fundingRoundFactoryAddress) {
throw new Error(
'Environment variable FUNDING_ROUND_FACTORY_ADDRESS is not setup'
)
}
const fundingRoundFactory = await ethers.getContractAt(
'FundingRoundFactory',
fundingRoundFactoryAddress
)
console.log('funding round factory address ', fundingRoundFactory.address)

const userRegistryType = process.env.USER_REGISTRY_TYPE || 'simple'
let userRegistry: Contract
if (userRegistryType === 'simple') {
const SimpleUserRegistry = await ethers.getContractFactory(
'SimpleUserRegistry',
deployer
)
userRegistry = await SimpleUserRegistry.deploy()
} else if (userRegistryType === 'brightid') {
console.log('deploying brightid user registry')
const BrightIdUserRegistry = await ethers.getContractFactory(
'BrightIdUserRegistry',
deployer
)
userRegistry = await BrightIdUserRegistry.deploy(
utils.formatBytes32String(process.env.BRIGHTID_CONTEXT),
process.env.BRIGHTID_VERIFIER_ADDR,
process.env.BRIGHTID_SPONSOR
)
} else {
throw new Error('unsupported user registry type')
}
const receipt = await userRegistry.deployTransaction.wait()
console.log(
`Deployed ${userRegistryType} user registry at ${userRegistry.address}`
)
console.log('transaction hash', receipt.transactionHash)

const setUserRegistryTx = await fundingRoundFactory.setUserRegistry(
userRegistry.address
)
await setUserRegistryTx.wait()
console.log(
'set user registry in funding round factory',
setUserRegistryTx.hash
)

console.log('*******************')
console.log('Deploy complete!')
console.log('*******************')
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
Loading