generated from proofoftom/buidler-waffle-typechain-quasar
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from clrfund/brightid-v6
Upgrade to brightId v6 api
- Loading branch information
Showing
43 changed files
with
2,045 additions
and
2,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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 || 'clr.fund'), | ||
process.env.BRIGHTID_VERIFIER_ADDR, | ||
process.env.BRIGHTID_SPONSOR | ||
) | ||
console.log('transaction hash', userRegistry.deployTransaction.hash) | ||
} else { | ||
throw new Error('unsupported user registry type') | ||
} | ||
await userRegistry.deployTransaction.wait() | ||
console.log( | ||
`Deployed ${userRegistryType} user registry at ${userRegistry.address}` | ||
) | ||
|
||
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) | ||
}) |
Oops, something went wrong.