diff --git a/.gitignore b/.gitignore index 29ad0af..9fa8569 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules -/_MACOSX \ No newline at end of file +/_MACOSX +/build diff --git a/api/index.js b/api/index.js index 582340d..133c5a1 100644 --- a/api/index.js +++ b/api/index.js @@ -8,7 +8,7 @@ const port = process.env.PORT || 5000; app.use(express.json()); app.use(cors()); -const dbURI = "mongodb+srv://dao:dao@cluster0.99uhnut.mongodb.net/?retryWrites=true&w=majority" ; +const dbURI = "mongodb+srv://ravi:ravi@cluster0.2rdjws6.mongodb.net/" ; mongoose.connect(dbURI, { diff --git a/package.json b/package.json index 9e40e0a..ab92184 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "scripts": { "start": "react-scripts start", - "build": "react-scripts build", + "build": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, diff --git a/src/Signature.js b/src/Signature.js index 42d121c..07d4093 100644 --- a/src/Signature.js +++ b/src/Signature.js @@ -8,7 +8,7 @@ function Signature() { name: "Abdul-DAO-8955", version: "675", chainId: 80001, - verifyingContract: "0x9C820370857E403aD50a687c6FDbAC4e2a763C97", + verifyingContract: "0x8B1150881d121e9a6f0c38e5E6CcF5732302394F", }; const value = { diff --git a/src/adminSignature.js b/src/adminSignature.js new file mode 100644 index 0000000..3d27ebc --- /dev/null +++ b/src/adminSignature.js @@ -0,0 +1,41 @@ +import { ethers } from "ethers"; + + const SIGNING_DOMAIN_NAME = "Abdul-DAO-8955" + const SIGNING_DOMAIN_VERSION = "675" + const chainId = 80001 + const contractAddress = "0xB48dbC24F8D883A5890f97d2054a5b0c4E49C735" // Put the address here from remix + const provider = new ethers.providers.Web3Provider(window.ethereum); + const signer = provider.getSigner(); + const domain = { + name: SIGNING_DOMAIN_NAME, + version: SIGNING_DOMAIN_VERSION, + verifyingContract: contractAddress, + chainId + } + + async function createVoucher(user, proposalId, option, numberOfVotes, time) { + const voucher = { user, proposalId, option, numberOfVotes, time } + const types = { + VoteVoucher2: [ + { name: "user", type: "address" }, + { name: "proposalId", type: "uint256" }, + { name: "option", type: "uint256" }, + { name: "numberOfVotes", type: "uint256" }, + { name: "time", type: "uint256" } + ] + } + console.log("domain, types, voucher : ", domain, types, voucher); + const signature = await signer._signTypedData(domain, types, voucher) + return { + ...voucher, + signature + } + } + + async function main(user, proposalId, option, numberOfVotes) { + const voucher = await createVoucher(user, proposalId, option, numberOfVotes, parseInt(Date.now() / 1000)) // the address is the address which receives the NFT + console.log(`[${voucher.user}, ${voucher.proposalId}, "${voucher.option}", "${voucher.numberOfVotes}","${voucher.time}", "${voucher.signature}"]`) + return voucher; + } + + export default main; \ No newline at end of file diff --git a/src/component/Card.js b/src/component/Card.js index 042b3b1..2b6d4ba 100644 --- a/src/component/Card.js +++ b/src/component/Card.js @@ -3,20 +3,25 @@ import { NavLink } from "react-router-dom"; import {contract} from "../connectContract" const Card = ({userAddress}) => { - const [proposal ,setproposal] = useState([]); + const [proposal ,setproposal] = useState([]); const [isOwner,setIsOwner] = useState(); const [account, setAccount] = useState(''); const [isActive, setIsActive] = useState(); + const [loader, setLoader] = useState(false); //connect to metamask useEffect(() => { - if(window.ethereum){ - window.ethereum.request({ method: 'eth_requestAccounts' }).then((res)=>{ - setAccount(res[0]); - }) - } + window.ethereum.request({ method: 'eth_requestAccounts' }) + .then((res) => { + setAccount(res[0]); + userAddress = res[0]; + }) + .catch((err) => { + console.log(err); + }); }, []); const getAllProposal = async () => { console.log("user is",userAddress) + setLoader(true); try{ const owner = await contract.owner(); console.log("owner is",owner,userAddress) @@ -29,9 +34,11 @@ const Card = ({userAddress}) => { proposals.push(element) }); setproposal(proposals); + setLoader(false); }catch(error){ console.log(error) alert(error) + setLoader(false); } } @@ -44,15 +51,21 @@ const Card = ({userAddress}) => { const now = Date.now(); console.log("now is",now,Number(end)*1000) - if(now>=(Number(start)*1000)&&now<=(Number(end)*1000)){ - return(true); + if(now<(Number(start)*1000)){ + return("Upcoming"); + } + else if(now>(Number(start)*1000) && now<(Number(end)*1000)){ + return("Active"); + } + else if(now>(Number(end)*1000)){ + return("Ended"); } else{ - - return(false); + return("Not declared"); } + } const data = async ()=>{ const user = await contract.owner(); @@ -63,10 +76,16 @@ const Card = ({userAddress}) => { data() },[account]) console.log("proposals is",proposal) - return ( + return ( <>
-
+ { + (loader)?
+ +
+ :
{proposal.map((item,index)=>(
@@ -82,26 +101,7 @@ const Card = ({userAddress}) => { {item[3]}
- {/*

- A) Yes (10%) -

-

- B) No (12.34%) -

-

- C) None (77.66%) -

*/} - {/*
-
- - 77.66% Sold - -
-
-
*/} +
@@ -111,7 +111,7 @@ const Card = ({userAddress}) => { Status:{" "}

- {checkActive(item[1],item[2])?"Active":"Not Active"} + {checkActive(item[1],item[2])}

@@ -122,10 +122,10 @@ const Card = ({userAddress}) => { - + {isOwner?
))}
+ } +
); }; -export default Card; +export default Card; \ No newline at end of file diff --git a/src/component/Dashboard.js b/src/component/Dashboard.js index 695697e..551cbf2 100644 --- a/src/component/Dashboard.js +++ b/src/component/Dashboard.js @@ -23,11 +23,15 @@ const Dashboard = () => { useEffect(() => { const user = Cookies.get("user"); setTotalInvestment(JSON.parse(user).total_investment); - const apiURL = "http://localhost:5000/getAmount/"+JSON.parse(user).user_id; + const apiURL = "https://api.prpcommunity.net/getAmount/"+JSON.parse(user).AmbassadorID; axios.get(apiURL).then((res)=>{ console.log(res.data.amount); setClaimAmount(res.data.amount); setRestAmount(totalInvestment-res.data.amount) + + }).catch(error=>{ + console.log(error); + setRestAmount(totalInvestment) }) }, [account]); @@ -39,7 +43,7 @@ const Dashboard = () => { try{ if(amount>restAmount){alert("You can't claim more than your investment");return} const user = Cookies.get("user"); - const username = JSON.parse(user).user_id; + const username = JSON.parse(user).AmbassadorID; const date = new Date(); const timestamp = date.getTime(); const signature = await signCreate(account,ethers.utils.parseEther(amount),timestamp); @@ -47,7 +51,7 @@ const Dashboard = () => { const res = await contract.redeem(voucher); const tx = await res.wait(); console.log(tx); - const update = axios.post("http://localhost:5000/update",{ + const update = axios.post("https://api.prpcommunity.net/update",{ user:username, amount:amount }) @@ -56,6 +60,7 @@ const Dashboard = () => { window.location.href = "/" }catch(error){ console.log(error); + alert(error.reason); } } diff --git a/src/component/Details.js b/src/component/Details.js index d68615c..df8167e 100644 --- a/src/component/Details.js +++ b/src/component/Details.js @@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react"; import { useParams } from 'react-router-dom'; import {contract,tokenContract} from "../connectContract" import { ethers } from "ethers"; +import main from "../adminSignature" export const Details = ({userAddress}) => { const { id } = useParams(); const[title,setTitle] = useState(); @@ -62,7 +63,7 @@ export const Details = ({userAddress}) => { const element = data[5][i]; const adminelement = data[6][i]; votes.push((Number(element)+Number(adminelement))/10**18); - total = total +( Number(element) + Number(adminelement)/10**18); + total = total +( (Number(element) + Number(adminelement))/10**18); if(Number(element)>maxvalue) if(maxvalue===0){max =i;} maxvalue=Number(element); } @@ -77,9 +78,12 @@ export const Details = ({userAddress}) => { useEffect(() => { getData(); }, [isActive,voteValue]); + + console.log("adminsignature",main); console.log("options",options) console.log("votes",votes) console.log(totalVotes); + useEffect(() => { if(window.ethereum){ window.ethereum.request({ method: 'eth_requestAccounts' }).then((res)=>{ @@ -91,15 +95,21 @@ export const Details = ({userAddress}) => { const vote = async(index)=>{ try{ if(!voteValue) {alert("please enter value"); return;} - if(account===owner.toLowerCase()){ - - console.log("admin") - const res = await contract.adminVoteByProposalId(id,index,ethers.utils.parseEther(voteValue)); + if(userAddress===owner.toLowerCase()){ + console.log("admin") + const adminSign = await main(userAddress||account,id,index,ethers.utils.parseEther(voteValue)); + const voucher = [adminSign.user,adminSign.proposalId,adminSign.option,adminSign.numberOfVotes,adminSign.time,adminSign.signature] + const res = await contract.redeem2(voucher); await res.wait(); alert("voted successfully") setVoteValue(""); }else{ console.log("user",account,owner) + const allowance = await tokenContract.allowance(account,contract.address); + if(Number(allowance) { - const [email, setEmail] = useState(""); + const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(); - - const apiUrl = 'https://dapps.12foxs.com/investement_api'; - const urlWithParams = `${apiUrl}?user_id=${email}&password=${password}`; + + const apiUrl = 'https://propertyrobots.com/api/ReturnSelfInvestment'; + const urlWithParams = `${apiUrl}?AmbassadorID=${username}&Password=${password}&APIKey=DSFKJ47FDJK4S4998KS`; const handleSubmit = async (e) => { console.log(userAddress) - if(!userAddress){alert("please connect wallet"); return;} + // if(!userAddress){alert("please connect wallet"); return;} axios.get(urlWithParams).then(response =>{ - console.log(response.data) - if(response.data.total_investment){ - console.log(response.data.total_investment) - Cookies.set('user', JSON.stringify({user_id : email, total_investment : response.data.total_investment})) + const jsonData = JSON.parse(response.data); + console.log(jsonData); + if(jsonData.StatusCode==="200"){ + + Cookies.set('user', JSON.stringify({user_id : jsonData.FullName, total_investment : jsonData.SelfInvestment, AmbassadorID: jsonData.AmbassadorID})) window.location.href= "/" }else{ - setError(response.data.error) + console.log(jsonData.StatusCode) + setError(jsonData.Message) } }).catch(error=>{ console.log(error); - setError(error); + setError("Username or password is incorrect"); }) } return ( @@ -42,9 +45,9 @@ const Hero = ({userAddress}) => {
- {setEmail(e.target.value)}} - class="peer w-full h-full bg-transparent text-blue-gray-700 font-sans font-normal outline outline-0 focus:outline-0 disabled:bg-blue-gray-50 disabled:border-0 transition-all placeholder-shown:border placeholder-shown:border-blue-gray-200 placeholder-shown:border-t-blue-gray-200 border focus:border-2 border-t-transparent focus:border-t-transparent text-md px-3 py-3 rounded-md border-blue-gray-200 focus:border-blue-500" placeholder=" " /> + {setUsername(e.target.value)}} + class="peer w-full h-full bg-transparent text-blue-gray-700 font-sans font-normal outline outline-0 focus:outline-0 disabled:bg-blue-gray-50 disabled:border-0 transition-all placeholder-shown:border placeholder-shown:border-blue-gray-200 placeholder-shown:border-t-blue-gray-200 border focus:border-2 border-t-transparent focus:border-t-transparent text-md px-3 py-3 rounded-md border-blue-gray-200 focus:border-blue-500" placeholder=" " />
{ - {/* error */} - {error &&

{error}

} + + {error &&

{error}

}

Don't have an account? Signup diff --git a/src/connectContract.js b/src/connectContract.js index ac735a6..9c67c4b 100644 --- a/src/connectContract.js +++ b/src/connectContract.js @@ -4,421 +4,565 @@ let signer; let tokenContract; const connectContract = () => { try { - const Address = "0x9C820370857E403aD50a687c6FDbAC4e2a763C97"; + const Address = "0xB48dbC24F8D883A5890f97d2054a5b0c4E49C735"; const Abi = [ { - inputs: [ + "inputs": [ { - internalType: "string", - name: "_topic", - type: "string", + "internalType": "string", + "name": "_topic", + "type": "string" }, { - internalType: "uint256", - name: "_startTime", - type: "uint256", + "internalType": "uint256", + "name": "_startTime", + "type": "uint256" }, { - internalType: "uint256", - name: "_endTime", - type: "uint256", + "internalType": "uint256", + "name": "_endTime", + "type": "uint256" }, { - internalType: "string", - name: "_question", - type: "string", + "internalType": "string", + "name": "_question", + "type": "string" }, { - internalType: "string[]", - name: "_options", - type: "string[]", - }, + "internalType": "string[]", + "name": "_options", + "type": "string[]" + } ], - name: "addProposal", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "addProposal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "_proposalId", - type: "uint256", + "internalType": "uint256", + "name": "_proposalId", + "type": "uint256" }, { - internalType: "uint256", - name: "_option", - type: "uint256", + "internalType": "uint256", + "name": "_option", + "type": "uint256" }, { - internalType: "uint256", - name: "_numberOfVotes", - type: "uint256", - }, + "internalType": "uint256", + "name": "_numberOfVotes", + "type": "uint256" + } ], - name: "adminVoteByProposalId", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "adminVoteByProposalId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "_proposalId", - type: "uint256", + "internalType": "uint256", + "name": "_proposalId", + "type": "uint256" }, { - internalType: "string", - name: "_topic", - type: "string", + "internalType": "string", + "name": "_topic", + "type": "string" }, { - internalType: "uint256", - name: "_startTime", - type: "uint256", + "internalType": "uint256", + "name": "_startTime", + "type": "uint256" }, { - internalType: "uint256", - name: "_endTime", - type: "uint256", + "internalType": "uint256", + "name": "_endTime", + "type": "uint256" }, { - internalType: "string", - name: "_question", - type: "string", + "internalType": "string", + "name": "_question", + "type": "string" }, { - internalType: "string[]", - name: "_options", - type: "string[]", - }, + "internalType": "string[]", + "name": "_options", + "type": "string[]" + } ], - name: "editProposalById", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "editProposalById", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct DAO.VoteVoucher", + "name": "voucher", + "type": "tuple" + } + ], + "name": "redeem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "_tokenContract", - type: "address", - }, + "internalType": "address", + "name": "_tokenContract", + "type": "address" + } ], - stateMutability: "nonpayable", - type: "constructor", + "name": "setTokenContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - anonymous: false, - inputs: [ + "inputs": [ { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, + "internalType": "address", + "name": "_tokenContract", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } ], - name: "OwnershipTransferred", - type: "event", + "name": "OwnershipTransferred", + "type": "event" }, { - inputs: [ + "inputs": [ { - components: [ + "components": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, { - internalType: "address", - name: "user", - type: "address", + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" }, { - internalType: "uint256", - name: "amount", - type: "uint256", + "internalType": "uint256", + "name": "option", + "type": "uint256" }, { - internalType: "uint256", - name: "time", - type: "uint256", + "internalType": "uint256", + "name": "numberOfVotes", + "type": "uint256" }, { - internalType: "bytes", - name: "signature", - type: "bytes", + "internalType": "uint256", + "name": "time", + "type": "uint256" }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } ], - internalType: "struct DAO.VoteVoucher", - name: "voucher", - type: "tuple", - }, + "internalType": "struct DAO.VoteVoucher2", + "name": "voucher", + "type": "tuple" + } ], - name: "redeem", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "redeem2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ { - internalType: "address", - name: "newOwner", - type: "address", - }, + "internalType": "address", + "name": "newOwner", + "type": "address" + } ], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "_proposalId", - type: "uint256", + "internalType": "uint256", + "name": "_proposalId", + "type": "uint256" }, { - internalType: "uint256", - name: "_option", - type: "uint256", + "internalType": "uint256", + "name": "_option", + "type": "uint256" }, { - internalType: "uint256", - name: "_numberOfVotes", - type: "uint256", + "internalType": "uint256", + "name": "_numberOfVotes", + "type": "uint256" + } + ], + "name": "userVoteByProposalId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } ], - name: "userVoteByProposalId", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "withdrawERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: "getAllProposals", - outputs: [ + "inputs": [ { - components: [ + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdrawETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "getAllProposals", + "outputs": [ + { + "components": [ { - internalType: "string", - name: "topic", - type: "string", + "internalType": "string", + "name": "topic", + "type": "string" }, { - internalType: "uint256", - name: "startTime", - type: "uint256", + "internalType": "uint256", + "name": "startTime", + "type": "uint256" }, { - internalType: "uint256", - name: "endTime", - type: "uint256", + "internalType": "uint256", + "name": "endTime", + "type": "uint256" }, { - internalType: "string", - name: "question", - type: "string", + "internalType": "string", + "name": "question", + "type": "string" }, { - internalType: "string[]", - name: "options", - type: "string[]", + "internalType": "string[]", + "name": "options", + "type": "string[]" }, { - internalType: "uint256[]", - name: "votes", - type: "uint256[]", + "internalType": "uint256[]", + "name": "votes", + "type": "uint256[]" }, { - internalType: "uint256[]", - name: "adminVotes", - type: "uint256[]", - }, + "internalType": "uint256[]", + "name": "adminVotes", + "type": "uint256[]" + } ], - internalType: "struct DAO.Proposal[]", - name: "", - type: "tuple[]", - }, + "internalType": "struct DAO.Proposal[]", + "name": "", + "type": "tuple[]" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "_proposalId", - type: "uint256", - }, + "internalType": "uint256", + "name": "_proposalId", + "type": "uint256" + } ], - name: "getProposalById", - outputs: [ + "name": "getProposalById", + "outputs": [ { - internalType: "string", - name: "", - type: "string", + "internalType": "string", + "name": "", + "type": "string" }, { - internalType: "uint256", - name: "", - type: "uint256", + "internalType": "uint256", + "name": "", + "type": "uint256" }, { - internalType: "uint256", - name: "", - type: "uint256", + "internalType": "uint256", + "name": "", + "type": "uint256" }, { - internalType: "string", - name: "", - type: "string", + "internalType": "string", + "name": "", + "type": "string" }, { - internalType: "string[]", - name: "", - type: "string[]", + "internalType": "string[]", + "name": "", + "type": "string[]" }, { - internalType: "uint256[]", - name: "votes", - type: "uint256[]", + "internalType": "uint256[]", + "name": "votes", + "type": "uint256[]" }, { - internalType: "uint256[]", - name: "adminVotes", - type: "uint256[]", - }, + "internalType": "uint256[]", + "name": "adminVotes", + "type": "uint256[]" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "bytes", - name: "", - type: "bytes", - }, + "internalType": "bytes", + "name": "", + "type": "bytes" + } ], - name: "isSignUsed", - outputs: [ + "name": "isSignUsed", + "outputs": [ { - internalType: "bool", - name: "", - type: "bool", - }, + "internalType": "bool", + "name": "", + "type": "bool" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "owner", - outputs: [ + "inputs": [], + "name": "owner", + "outputs": [ { - internalType: "address", - name: "", - type: "address", - }, + "internalType": "address", + "name": "", + "type": "address" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "proposalCount", - outputs: [ + "inputs": [], + "name": "proposalCount", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - components: [ + "components": [ { - internalType: "address", - name: "user", - type: "address", + "internalType": "address", + "name": "user", + "type": "address" }, { - internalType: "uint256", - name: "amount", - type: "uint256", + "internalType": "uint256", + "name": "amount", + "type": "uint256" }, { - internalType: "uint256", - name: "time", - type: "uint256", + "internalType": "uint256", + "name": "time", + "type": "uint256" }, { - internalType: "bytes", - name: "signature", - type: "bytes", - }, + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } ], - internalType: "struct DAO.VoteVoucher", - name: "voucher", - type: "tuple", - }, + "internalType": "struct DAO.VoteVoucher", + "name": "voucher", + "type": "tuple" + } ], - name: "recover", - outputs: [ + "name": "recover", + "outputs": [ { - internalType: "address", - name: "", - type: "address", - }, + "internalType": "address", + "name": "", + "type": "address" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "remainingTokens", - outputs: [ + "inputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "components": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "option", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "numberOfVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct DAO.VoteVoucher2", + "name": "voucher", + "type": "tuple" + } ], - stateMutability: "view", - type: "function", + "name": "recover2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "tokenContract", - outputs: [ + "inputs": [], + "name": "remainingTokens", + "outputs": [ { - internalType: "address", - name: "", - type: "address", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, + { + "inputs": [], + "name": "tokenContract", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } ]; const token = "0x4fb73B501f8884721cc91aaFD5E9FA48676fa91f"; const tokenABI = [ @@ -616,7 +760,7 @@ const connectContract = () => { }, ]; const provider = new ethers.providers.Web3Provider(window.ethereum); - signer = provider.getSigner(); + signer = provider.getSigner("0xc6265eBCD55510aAeF33c7fD00e1615AFA12e745"); console.log("signer at contract: ", signer); contract = new ethers.Contract(Address, Abi, signer); tokenContract = new ethers.Contract(token, tokenABI, signer);