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

Fixed Dynamic imports and hardhat scripts #4

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules
# testing
server/coverage
server/coverage.json
server/cache

# misc
.DS_Store
Expand Down
424 changes: 329 additions & 95 deletions client/package-lock.json

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions client/src/Components/Screens/Auth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useState, useEffect } from "react";
import { ethers } from "ethers";
import Authentication from "../../build/Authentication.json";
import Authentication from "../../artifacts/contracts/facets/Authentication.sol/Authentication.json";
import "../styles/Auth.scss";
import { CONTRACTADDRESS } from '../constants'
import { Navigate } from "react-router-dom";
Expand All @@ -12,7 +12,7 @@ function Auth() {
const [registered, setRegistered] = useState(false);
const [fullName, setFullName] = useState({
name: "",
password : ""
password: ""
});
const [newRegistered, setNewRegistered] = useState(false);
const [loggedInStatus, setLoggedInStatus] = useState(false);
Expand All @@ -36,27 +36,27 @@ function Auth() {

const registerUser = async (e) => {
e.preventDefault();
if((registered == false && loggedInStatus == false)){
if ((registered == false && loggedInStatus == false)) {
try {
const { ethereum } = window;
if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
console.log(signer);
const contract = new ethers.Contract(
contractAddress,
Authentication.abi,
signer
const signer = provider.getSigner();
console.log(signer);
const contract = new ethers.Contract(
contractAddress,
Authentication.abi,
signer
);
console.log(fullName.name);
let name = fullName.name;
let hashedPassword = CryptoJS.SHA256(fullName.password).toString();
const add = await signer.getAddress();
const add = await signer.getAddress();



//changed hardcoded address to signer address
const tx = await contract.createUser([1,fullName.name,add], hashedPassword, {gasLimit:800000});
const tx = await contract.createUser([1, fullName.name, add], hashedPassword, { gasLimit: 800000 });
await tx.wait();
localStorage.setItem(add, hashedPassword);
console.log("Successfully new User registered");
Expand All @@ -74,7 +74,7 @@ function Auth() {
if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
const add = await signer.getAddress();
const add = await signer.getAddress();
const contract = new ethers.Contract(
contractAddress,
Authentication.abi,
Expand All @@ -83,9 +83,9 @@ function Auth() {

console.log(fullName);
let myPass = CryptoJS.SHA256(fullName.password).toString();
const loggedStatus = await contract.getLoggedInStatus(add, myPass);
console.log(loggedStatus);
if(loggedStatus == true){
const loggedStatus = await contract.getLoggedInStatus(add, myPass);
console.log(loggedStatus);
if (loggedStatus == true) {
localStorage.setItem(add, myPass)
setLoggedInStatus(loggedStatus);
}
Expand All @@ -100,26 +100,26 @@ function Auth() {
const { ethereum } = window;
if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
const signer = provider.getSigner();
const contract = new ethers.Contract(
contractAddress,
Authentication.abi,
signer
);

//await contract.init(contractAddress) //This step you have to do one time

//changed hardcoded address to signer address
const add = await signer.getAddress();
const add = await signer.getAddress();
const authStatus = await contract.getAuthStatus(add);
setRegistered(authStatus);
console.log('Register Status - ',authStatus);
console.log('Register Status - ', authStatus);

const myPass = localStorage.getItem(add);
if(myPass == null) throw 'SignUp/SignIn to proceed'
if (myPass == null) throw 'SignUp/SignIn to proceed'
const loggedStatus = await contract.getLoggedInStatus(add, myPass);
setLoggedInStatus(loggedStatus)
console.log("Auth Status - ",loggedStatus);
console.log("Auth Status - ", loggedStatus);
}
} catch (err) {
console.log(err);
Expand Down Expand Up @@ -148,18 +148,18 @@ function Auth() {
<>
<form onSubmit={registerUser} style={{ margin: "10px" }}>
{
((loggedInStatus == false && registered == false)) &&
<>
<label className="form-label">Name</label>
<input
className="form-control"
placeholder="Enter your full name"
onChange={handleNameChange}
value={fullName.name}
type="text"
/>
</>
}
((loggedInStatus == false && registered == false)) &&
<>
<label className="form-label">Name</label>
<input
className="form-control"
placeholder="Enter your full name"
onChange={handleNameChange}
value={fullName.name}
type="text"
/>
</>
}
<br />

<label className="form-label">Wallet address</label>
Expand All @@ -168,7 +168,7 @@ function Auth() {
type="text"
value={window?.ethereum?.selectedAddress}
disabled
// value={initialized ? account : "Loading..."}
// value={initialized ? account : "Loading..."}
/>
<br />

Expand All @@ -183,25 +183,25 @@ function Auth() {

<br />
{
(registered==true && loggedInStatus == true)
?
<Navigate to='/dashboard' />
:
<div>
{
(registered == true && loggedInStatus == false) &&
(registered == true && loggedInStatus == true)
?
<Navigate to='/dashboard' />
:
<div>
{
(registered == true && loggedInStatus == false) &&
<button onClick={SignInUser} className="authButtons">
SIGN IN
</button>
}
}

{
(registered == false && loggedInStatus == false) &&
{
(registered == false && loggedInStatus == false) &&
<button onClick={registerUser} className="authButtons">
SIGN UP
</button>
}
</div>
}
</div>
}
</form>

Expand Down
44 changes: 22 additions & 22 deletions client/src/Components/Screens/BrightID.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import QRCode from "react-qr-code";

import { useState, useEffect } from "react";
import { Flex, Modal, Button, Card } from "rimble-ui";
import Brightid from "../../build/BrightID.json";
import Brightid from "../../blockchainBuild/BrightID.json";
import { ethers } from "ethers";

import background from "../assets/bg.jpg";
import brightidimg from "../assets/brightid.jpeg";

function BrightID() {
// const [isOpen, setIsOpen] = useState(false);
// const [isOpen, setIsOpen] = useState(false);
const [verified, setVerified] = useState(false);
const [data, setData] = useState({
addresses: [],
Expand All @@ -25,15 +25,15 @@ function BrightID() {
let detail;
const contractAddress = "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0";

// const closeModal = (e) => {
// e.preventDefault();
// setIsOpen(false);
// };
// const closeModal = (e) => {
// e.preventDefault();
// setIsOpen(false);
// };

// const openModal = async (e) => {
// e.preventDefault();
// if (verified == false) setIsOpen(true);
// };
// const openModal = async (e) => {
// e.preventDefault();
// if (verified == false) setIsOpen(true);
// };

const value = `brightid://link-verification/http:%2f%2fnode.brightid.org/snapshot/0xa1C2668091b30CA136F065883bF8bE744bF6b37A`;

Expand Down Expand Up @@ -134,7 +134,7 @@ function BrightID() {
useEffect(() => {
brightid();
getVerifiers();
},[]);
}, []);
console.log("verifiers -> ", verifiers);
return (
<div>
Expand Down Expand Up @@ -162,21 +162,21 @@ function BrightID() {
style={{ height: "550px", width: "300px", margin: "10px" }}
/>

<h2 style={{margin:"10px"}}>Step 2 : Join A BrightID Verification Meeting. </h2>
<h2 style={{ margin: "10px" }}>Step 2 : Join A BrightID Verification Meeting. </h2>
<b>You can find out the next meeting <a href="https://meet.brightid.org/#/">over here.</a></b>
<h2 style={{margin:"10px"}}>Step 3 : Link your account to our App. </h2>
<h2 style={{margin:"10px"}}>Step 4 : Get Sponsored.. </h2>
<h2 style={{margin:"10px"}}>Step 5 : Confirm Verification. </h2>
<h2 style={{ margin: "10px" }}>Step 3 : Link your account to our App. </h2>
<h2 style={{ margin: "10px" }}>Step 4 : Get Sponsored.. </h2>
<h2 style={{ margin: "10px" }}>Step 5 : Confirm Verification. </h2>
<div>
<p>Scan the QR Code to link to the BrightID!</p>
<p>Scan the QR Code to link to the BrightID!</p>

<br />
</div>
<br />
</div>

<QRCode title="snapshot" value={value} />
<Button ml={3} type="submit" onClick={provehumanity}>
Confirm Verification!
</Button>
<QRCode title="snapshot" value={value} />
<Button ml={3} type="submit" onClick={provehumanity}>
Confirm Verification!
</Button>
</div>
<br /> <br />
</div>
Expand Down
Loading