From 2fdd7d375dd20679f730675788d87a46e27feb91 Mon Sep 17 00:00:00 2001
From: kalashshah <202051096@iiitvadodara.ac.in>
Date: Sun, 26 Mar 2023 21:46:16 +0530
Subject: [PATCH] :rocket: ui scaling eth
---
ui/components/Layout.tsx | 6 ++--
ui/context/AuthContext.tsx | 7 ++---
ui/pages/index.tsx | 6 ++--
ui/pages/my-tenders.tsx | 24 +---------------
ui/pages/propose-tender.tsx | 22 ++++----------
ui/qrcodes/qrcode.json | 57 ++++++++++++++++++-------------------
ui/qrcodes/zkevmqrcode.json | 31 ++++++++++++++++++++
ui/utils/constants.ts | 4 +++
8 files changed, 79 insertions(+), 78 deletions(-)
create mode 100644 ui/qrcodes/zkevmqrcode.json
create mode 100644 ui/utils/constants.ts
diff --git a/ui/components/Layout.tsx b/ui/components/Layout.tsx
index 31fea77..d6f5f2f 100644
--- a/ui/components/Layout.tsx
+++ b/ui/components/Layout.tsx
@@ -44,7 +44,7 @@ const CustomLayout = ({ children }: IProp) => {
"Logout",
]);
const [optionRoutes, setOptionRoutes] = React.useState([
- "/propose-investment",
+ "/propose-tender",
"/my-tenders",
"/my-bids",
"/logout",
@@ -145,7 +145,7 @@ const CustomLayout = ({ children }: IProp) => {
const { data, block } = await db!
.collection("DTenderDynamicNFTMetadata")
// .record(localStorage.getItem("walletAddress") as string)
- .record("1")
+ .record("2")
.get();
// return data?.level;
@@ -209,7 +209,7 @@ const CustomLayout = ({ children }: IProp) => {
marginTop: "12px",
}}
>
- Level: {currLevel! + 1}
+ Level: {currLevel!}
>
diff --git a/ui/context/AuthContext.tsx b/ui/context/AuthContext.tsx
index 86656dd..da5943d 100644
--- a/ui/context/AuthContext.tsx
+++ b/ui/context/AuthContext.tsx
@@ -8,6 +8,7 @@ import { polygonMumbai } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";
import DTenderContract from "@/contracts/DTender.json";
import { Contract, ethers } from "ethers";
+import { POLYGON_MUMBAI_ADDRESS } from "@/utils/constants";
const auth = typeof window !== "undefined" ? new Auth() : null;
const db = new Polybase({
@@ -65,11 +66,7 @@ export const AuthProvider = ({ children }: AuthProviderProps) => {
console.log("signer: ", signer);
setSigner(signer);
setContract(
- new ethers.Contract(
- "0x5c876A33570B1202Caf2892ce3D6F53c6c40bEC0",
- DTenderContract.abi,
- signer
- )
+ new ethers.Contract(POLYGON_MUMBAI_ADDRESS, DTenderContract.abi, signer)
);
}
};
diff --git a/ui/pages/index.tsx b/ui/pages/index.tsx
index 757648a..9a8dbc2 100644
--- a/ui/pages/index.tsx
+++ b/ui/pages/index.tsx
@@ -14,6 +14,7 @@ import QRJson from "../qrcodes/qrcode.json";
import { AuthContext } from "@/context/AuthContext";
import { useContractEvent } from "wagmi";
import DTenderJSON from "@/contracts/DTender.json";
+import { POLYGON_MUMBAI_ADDRESS } from "@/utils/constants";
const { Title } = Typography;
@@ -68,7 +69,7 @@ export default function Home() {
};
useContractEvent({
- address: `0x5c876A33570B1202Caf2892ce3D6F53c6c40bEC0`,
+ address: POLYGON_MUMBAI_ADDRESS,
abi: DTenderJSON.abi,
eventName: "ProofSubmitted",
listener: (event) => {
@@ -116,7 +117,8 @@ export default function Home() {
localStorage.getItem("walletAddress") as string
)
.get();
- if (records) {
+ console.log("RECORDS: ", records);
+ if (records.data.length > 0) {
setShowQR(false);
} else {
setShowQR(true);
diff --git a/ui/pages/my-tenders.tsx b/ui/pages/my-tenders.tsx
index 9bb448a..cebfb75 100644
--- a/ui/pages/my-tenders.tsx
+++ b/ui/pages/my-tenders.tsx
@@ -264,6 +264,7 @@ export default function MyTenders() {
setIsMine(query?.mine === "true");
const getTenders = async () => {
if (contract) {
+ console.log("contract", contract);
const tenders = await contract?.getTenders();
let tenderList: Tender[] = [];
for (const tender of tenders) {
@@ -316,17 +317,6 @@ export default function MyTenders() {
getBids();
}, [contract, viewBidsModal]);
- useEffect(() => {
- if (!isSignedInMetamask || !selectedOption) {
- notification.destroy();
- notification.error({
- message: "Not Signed In",
- description: "Please sign in to continue",
- });
- router.push("/");
- }
- }, [isSignedInMetamask, selectedOption]);
-
return (
@@ -418,18 +408,6 @@ export default function MyTenders() {
/>
)}
-
);
}
diff --git a/ui/pages/propose-tender.tsx b/ui/pages/propose-tender.tsx
index 725afff..ce381eb 100644
--- a/ui/pages/propose-tender.tsx
+++ b/ui/pages/propose-tender.tsx
@@ -1,4 +1,4 @@
-import React, { useContext, useEffect, useState } from "react";
+import React, { useContext, useState } from "react";
import {
Button,
DatePicker,
@@ -9,12 +9,10 @@ import {
Typography,
Upload,
} from "antd";
+import Moralis from "moralis";
import { AuthContext } from "@/context/AuthContext";
-import { Contract, ethers } from "ethers";
-import DTenderContract from "@/contracts/DTender.json";
import { PlusOutlined } from "@ant-design/icons";
import { getSolidityDate } from "@/utils/solidity";
-import Moralis from "moralis";
import { useRouter } from "next/router";
const { Title } = Typography;
@@ -51,21 +49,13 @@ export default function ProposeInvestment() {
values.maximumBidAmount
);
console.log(res);
+ notification.success({
+ message: "Tender Created",
+ description: "Tender has been successfully created.",
+ });
setLoading(false);
};
- useEffect(() => {
- if (!isSignedInMetamask || !isCompany) {
- notification.destroy();
- notification.error({
- message: "Not a Company",
- description: "Only companies can propose tenders.",
- });
- router.push("/");
- return;
- }
- }, []);
-
return (
diff --git a/ui/qrcodes/qrcode.json b/ui/qrcodes/qrcode.json
index f59db12..92ec1b8 100644
--- a/ui/qrcodes/qrcode.json
+++ b/ui/qrcodes/qrcode.json
@@ -1,32 +1,31 @@
{
- "id": "7f38a193-0918-4a48-9fac-36adfdb8b542",
- "typ": "application/iden3comm-plain-json",
- "type": "https://iden3-communication.io/proofs/1.0/contract-invoke-request",
- "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542",
- "body": {
- "reason": "tender validation",
- "transaction_data": {
- "contract_address": "0x5c876A33570B1202Caf2892ce3D6F53c6c40bEC0",
- "method_id": "b68967e2",
- "chain_id": 80001,
- "network": "polygon-mumbai"
- },
- "scope": [
- {
- "id": 1,
- "circuitId": "credentialAtomicQuerySigV2OnChain",
- "query": {
- "allowedIssuers": ["*"],
- "context": "https://raw.githubusercontent.com/kitai-hazure/DTender/main/schema/cin-verification.json-ld",
- "credentialSubject": {
- "corporateIdentificationNumber": {
- "$eq": 1234
- }
- },
- "type": "IsAValidCompany"
- }
+ "id": "7f38a193-0918-4a48-9fac-36adfdb8b542",
+ "typ": "application/iden3comm-plain-json",
+ "type": "https://iden3-communication.io/proofs/1.0/contract-invoke-request",
+ "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542",
+ "body": {
+ "reason": "tender validation",
+ "transaction_data": {
+ "contract_address": "0x53e9D85ddB0364509Fc773d3fb1007cd351B8d5A",
+ "method_id": "b68967e2",
+ "chain_id": 80001,
+ "network": "polygon-mumbai"
+ },
+ "scope": [
+ {
+ "id": 1,
+ "circuitId": "credentialAtomicQuerySigV2OnChain",
+ "query": {
+ "allowedIssuers": ["*"],
+ "context": "https://raw.githubusercontent.com/kitai-hazure/DTender/main/schema/cin-verification.json-ld",
+ "credentialSubject": {
+ "corporateIdentificationNumber": {
+ "$eq": 1234
+ }
+ },
+ "type": "IsAValidCompany"
}
- ]
- }
+ }
+ ]
}
-
\ No newline at end of file
+}
diff --git a/ui/qrcodes/zkevmqrcode.json b/ui/qrcodes/zkevmqrcode.json
new file mode 100644
index 0000000..b6b966e
--- /dev/null
+++ b/ui/qrcodes/zkevmqrcode.json
@@ -0,0 +1,31 @@
+{
+ "id": "7f38a193-0918-4a48-9fac-36adfdb8b542",
+ "typ": "application/iden3comm-plain-json",
+ "type": "https://iden3-communication.io/proofs/1.0/contract-invoke-request",
+ "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542",
+ "body": {
+ "reason": "tender validation",
+ "transaction_data": {
+ "contract_address": "0xCc4A6407B36120f21ff21d0F7Eef23DBEaD2A977",
+ "method_id": "b68967e2",
+ "chain_id": 1442,
+ "network": "zkEVM"
+ },
+ "scope": [
+ {
+ "id": 1,
+ "circuitId": "credentialAtomicQuerySigV2OnChain",
+ "query": {
+ "allowedIssuers": ["*"],
+ "context": "https://raw.githubusercontent.com/kitai-hazure/DTender/main/schema/cin-verification.json-ld",
+ "credentialSubject": {
+ "corporateIdentificationNumber": {
+ "$eq": 1234
+ }
+ },
+ "type": "IsAValidCompany"
+ }
+ }
+ ]
+ }
+}
diff --git a/ui/utils/constants.ts b/ui/utils/constants.ts
new file mode 100644
index 0000000..07287c1
--- /dev/null
+++ b/ui/utils/constants.ts
@@ -0,0 +1,4 @@
+export const POLYGON_MUMBAI_ADDRESS =
+ "0x53e9D85ddB0364509Fc773d3fb1007cd351B8d5A";
+export const POLYGON_ZKEVM_ADDRESS =
+ "0xCc4A6407B36120f21ff21d0F7Eef23DBEaD2A977";