Skip to content

Commit

Permalink
🚀 ui scaling eth
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashshah committed Mar 26, 2023
1 parent f368269 commit 2fdd7d3
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 78 deletions.
6 changes: 3 additions & 3 deletions ui/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const CustomLayout = ({ children }: IProp) => {
"Logout",
]);
const [optionRoutes, setOptionRoutes] = React.useState([
"/propose-investment",
"/propose-tender",
"/my-tenders",
"/my-bids",
"/logout",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -209,7 +209,7 @@ const CustomLayout = ({ children }: IProp) => {
marginTop: "12px",
}}
>
Level: {currLevel! + 1}
Level: {currLevel!}
</p>
</div>
</>
Expand Down
7 changes: 2 additions & 5 deletions ui/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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)
);
}
};
Expand Down
6 changes: 4 additions & 2 deletions ui/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -68,7 +69,7 @@ export default function Home() {
};

useContractEvent({
address: `0x5c876A33570B1202Caf2892ce3D6F53c6c40bEC0`,
address: POLYGON_MUMBAI_ADDRESS,
abi: DTenderJSON.abi,
eventName: "ProofSubmitted",
listener: (event) => {
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 1 addition & 23 deletions ui/pages/my-tenders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 (
<div>
<Head>
Expand Down Expand Up @@ -418,18 +408,6 @@ export default function MyTenders() {
/>
)}
</div>
<Button
onClick={async () => {
console.log("calling upgrade level");
await db!
.collection("DTenderDynamicNFTMetadata")
.record("2")
.call("upgradeLevel", []);
console.log("done");
}}
>
bhendi
</Button>
</div>
);
}
22 changes: 6 additions & 16 deletions ui/pages/propose-tender.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from "react";
import React, { useContext, useState } from "react";
import {
Button,
DatePicker,
Expand All @@ -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;
Expand Down Expand Up @@ -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 (
<div>
<Title level={2} style={{ textAlign: "center" }}>
Expand Down
57 changes: 28 additions & 29 deletions ui/qrcodes/qrcode.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
]
}
}
31 changes: 31 additions & 0 deletions ui/qrcodes/zkevmqrcode.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}
4 changes: 4 additions & 0 deletions ui/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const POLYGON_MUMBAI_ADDRESS =
"0x53e9D85ddB0364509Fc773d3fb1007cd351B8d5A";
export const POLYGON_ZKEVM_ADDRESS =
"0xCc4A6407B36120f21ff21d0F7Eef23DBEaD2A977";

1 comment on commit 2fdd7d3

@vercel
Copy link

@vercel vercel bot commented on 2fdd7d3 Mar 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

d-tender – ./

d-tender.vercel.app
d-tender-kitai.vercel.app
d-tender-git-main-kitai.vercel.app

Please sign in to comment.