Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
saremeskandary committed Aug 25, 2024
1 parent fcfbe6b commit 051ce26
Show file tree
Hide file tree
Showing 89 changed files with 30,061 additions and 24,332 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ node_modules

# cli
dist
/packages/hardhat/lib
packages/hardhat/lib/forge-std
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
"husky": "^9.1.4",
"lint-staged": "^13.0.3",
"yarn-audit-fix": "^10.0.8"
"yarn-audit-fix": "^10.0.9"
},
"engines": {
"node": ">=18.17.0"
Expand Down
198 changes: 100 additions & 98 deletions packages/hardhat/deploy/01_deploy.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,100 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { Contract } from "ethers";

const deployContracts: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();
const network = hre.network.name;

// Example of setting TOKEN_ADDRESS based on the network
let tokenAddress: string;

// If deploying on local networks, deploy a mock USDT
if (["hardhat", "localhost", "anvil", "truffleDashboard"].includes(network)) {
const mockToken = await deploy("MockToken", {
from: deployer,
log: true,
});
tokenAddress = mockToken.address;
} else if (network === "mainnet") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "crossfiTestnet") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "k9") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "shibarium") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "polygon") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourPolygonUSDTAddress"; // CHANGEME
} else {
throw new Error("You need to choose your network.");
}

// Now deploy the contracts
const accessRestriction = await deploy("AccessRestriction", {
from: deployer,
args: [deployer],
log: true,
});

const reputation = await deploy("Reputation", {
from: deployer,
args: [accessRestriction.address],
log: true,
});

const socialFi = await deploy("SocialFi", {
from: deployer,
args: [tokenAddress],
log: true,
});

const inspection = await deploy("Inspection", {
from: deployer,
log: true,
});

const rentalDAO = await deploy("RentalDAO", {
from: deployer,
args: [accessRestriction.address, 100],
log: true,
});

const escrow = await deploy("Escrow", {
from: deployer,
args: [tokenAddress, rentalDAO.address, accessRestriction.address],
log: true,
});

const disputeResolution = await deploy("DisputeResolution", {
from: deployer,
args: [],
log: true,
});

const rentalAgreement = await deploy("RentalAgreement", {
from: deployer,
args: [
tokenAddress,
escrow.address,
inspection.address,
disputeResolution.address,
socialFi.address,
rentalDAO.address,
],
log: true,
});

// Get the deployed contract to interact with it after deploying.
const disputeResolutionContract = await hre.ethers.getContract<Contract>("DisputeResolution", deployer);
console.log(
"👋 Initiate Dispute Resolution Contract",
await disputeResolutionContract.init(rentalAgreement.address, reputation.address, accessRestriction.address),
);
};

export default deployContracts;
deployContracts.tags = ["All"];
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { Contract } from "ethers";

const deployContracts: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();
const network = hre.network.name;

// Example of setting TOKEN_ADDRESS based on the network
let tokenAddress: string;

// Now deploy the contracts
const accessRestriction = await deploy("AccessRestriction", {
from: deployer,
args: [deployer],
log: true,
});

// If deploying on local networks, deploy a mock USDT
if (["hardhat", "localhost", "anvil", "truffleDashboard"].includes(network)) {
const mockToken = await deploy("MockToken", {
from: deployer,
args: ["MockToken", "MKT", accessRestriction.address],
log: true,
});
tokenAddress = mockToken.address;
} else if (network === "mainnet") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "crossfiTestnet") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "k9") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "shibarium") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourMainnetUSDTAddress"; // CHANGEME
} else if (network === "polygon") {
tokenAddress = process.env.USDT_ADDRESS || "0xYourPolygonUSDTAddress"; // CHANGEME
} else {
throw new Error("You need to choose your network.");
}

const reputation = await deploy("Reputation", {
from: deployer,
args: [accessRestriction.address],
log: true,
});

const socialFi = await deploy("SocialFi", {
from: deployer,
args: [tokenAddress, accessRestriction.address],
log: true,
});

const inspection = await deploy("Inspection", {
from: deployer,
args: [accessRestriction.address],
log: true,
});

const rentalDAO = await deploy("RentalDAO", {
from: deployer,
args: [accessRestriction.address, 100],
log: true,
});

const escrow = await deploy("Escrow", {
from: deployer,
args: [tokenAddress, rentalDAO.address, accessRestriction.address],
log: true,
});

const disputeResolution = await deploy("DisputeResolution", {
from: deployer,
args: [],
log: true,
});

const rentalAgreement = await deploy("RentalAgreement", {
from: deployer,
args: [
tokenAddress,
escrow.address,
inspection.address,
disputeResolution.address,
socialFi.address,
rentalDAO.address,
],
log: true,
});

// Get the deployed contract to interact with it after deploying.
const disputeResolutionContract = await hre.ethers.getContract<Contract>("DisputeResolution", deployer);
console.log(
"👋 Initiate Dispute Resolution Contract",
await disputeResolutionContract.init(rentalAgreement.address, reputation.address, accessRestriction.address),
);
};

export default deployContracts;
deployContracts.tags = ["All"];
67 changes: 54 additions & 13 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,70 @@
{
"name": "rentalhub",
"name": "@se-2/hardhat",
"version": "1.0.0",
"description": "[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)",
"main": "index.js",
"scripts": {
"test": "bash scripts/run_test.sh",
"format": "prettier --write \"./**/*.{sol,js,json}\""
"account": "hardhat run scripts/listAccount.ts",
"chain": "hardhat node --network hardhat --no-deploy",
"compile": "hardhat compile",
"deploy": "hardhat deploy",
"fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy",
"generate": "hardhat run scripts/generateAccount.ts",
"flatten": "hardhat flatten",
"lint": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
"lint-staged": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore",
"format": "prettier --write ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
"test": "REPORT_GAS=true hardhat test --network hardhat",
"testm": "bash scripts/run_test.sh",
"verify": "hardhat etherscan-verify",
"hardhat-verify": "hardhat verify",
"clean": "rm -rf ./artifacts && rm -rf ./cache && rm -rf ./hardhat-deploy && rm -rf ./deployments && rm -rf ./typechain-types && forge clean",
"anvil": "make anvil",
"build": "forge build",
"ftest": "forge test",
"fdeploy": "make deploy-anvil",
"dashboard": "truffle dashboard",
"tdeploy": "hardhat deploy --network truffle-dashboard --export-all ./temp/hardhat_contracts.json \"$@\" && hardhat run utils/generateTsAbis.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@nomicfoundation/hardhat-verify": "^2.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@openzeppelin/test-helpers": "^0.5.16",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-foundry": "^1.1.2",
"@nomicfoundation/hardhat-ignition": "^0.15.5",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.3",
"@nomicfoundation/ignition-core": "^0.15.5",
"@truffle/dashboard-hardhat-plugin": "^0.2.15",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@typechain/hardhat": "^9.1.0",
"@types/eslint": "^8",
"@types/mocha": "^10.0.1",
"@types/prettier": "^2",
"@types/qrcode": "^1",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",
"chai": "^4.3.6",
"eslint": "^8.26.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eth-gas-reporter": "^0.2.27",
"ethers": "^6.10.0",
"hardhat": "^2.22.8",
"hardhat-deploy": "^0.11.45",
"hardhat-deploy-ethers": "^0.4.1",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-preprocessor": "^0.1.5",
"nc": "^1.0.3",
"solidity-coverage": "^0.8.4",
"prettier": "^3.3.2",
"solidity-coverage": "^0.8.5",
"truffle": "^5.11.5",
"ts-node": "^10.9.2",
"typechain": "^8.1.0",
"typescript": "^5.5.4"
Expand All @@ -37,19 +75,22 @@
"@openzeppelin/contracts-upgradeable": "^4.9.3",
"@openzeppelin/hardhat-upgrades": "^1.22.1",
"@pancakeswap/pancake-swap-lib": "^0.0.4",
"@typechain/ethers-v6": "^0.5.1",
"@wallet-standard/wallet": "^1.0.1",
"big.js": "^6.2.1",
"chai": "^4.3.7",
"circomlib": "^2.0.5",
"dotenv": "^16.0.3",
"eip-712": "^1.0.0",
"envfile": "^6.18.0",
"eth-sig-util": "^3.0.1",
"ethereumjs-wallet": "^1.0.2",
"ethers-utils": "^2.1.11",
"hardhat-console": "^1.0.0",
"hardhat-laika": "^0.1.1",
"hardhat-slither": "^1.0.4",
"node-forge": "^1.3.1",
"qrcode": "^1.5.1",
"solidity-code-metrics": "^0.0.25"
},
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss"],
"arrowParens": "avoid",
"printWidth": 120,
"tabWidth": 2,
Expand Down
8 changes: 4 additions & 4 deletions packages/nextjs/app/debug/_components/DebugContracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ export function DebugContracts() {
}, [selectedContract, setSelectedContract]);

return (
<div className="flex flex-col gap-y-6 lg:gap-y-8 py-8 lg:py-12 justify-center items-center">
<div className="lg:gap-y-8 lg:py-12 flex flex-col items-center justify-center gap-y-6 py-8">
{contractNames.length === 0 ? (
<p className="text-3xl mt-14">No contracts found!</p>
<p className="mt-14 text-3xl">No contracts found!</p>
) : (
<>
{contractNames.length > 1 && (
<div className="flex flex-row gap-2 w-full max-w-7xl pb-1 px-6 lg:px-10 flex-wrap">
<div className="lg:px-10 flex w-full max-w-7xl flex-row flex-wrap gap-2 px-6 pb-1">
{contractNames.map(contractName => (
<button
className={`btn btn-secondary btn-sm font-light hover:border-transparent ${
contractName === selectedContract
? "bg-base-300 hover:bg-base-300 no-animation"
? "no-animation bg-base-300 hover:bg-base-300"
: "bg-base-100 hover:bg-secondary"
}`}
key={contractName}
Expand Down
8 changes: 4 additions & 4 deletions packages/nextjs/app/debug/_components/contract/Tuple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export const Tuple = ({ abiTupleParameter, setParentForm, parentStateObjectKey }

return (
<div>
<div className="collapse collapse-arrow bg-base-200 pl-4 py-1.5 border-2 border-secondary">
<input type="checkbox" className="min-h-fit peer" />
<div className="collapse-title p-0 min-h-fit peer-checked:mb-2 text-primary-content/50">
<div className="collapse collapse-arrow border-2 border-secondary bg-base-200 py-1.5 pl-4">
<input type="checkbox" className="peer min-h-fit" />
<div className="collapse-title min-h-fit p-0 text-primary-content/50 peer-checked:mb-2">
<p className="m-0 p-0 text-[1rem]">{abiTupleParameter.internalType}</p>
</div>
<div className="ml-3 flex-col space-y-4 border-secondary/80 border-l-2 pl-4 collapse-content">
<div className="collapse-content ml-3 flex-col space-y-4 border-l-2 border-secondary/80 pl-4">
{abiTupleParameter?.components?.map((param, index) => {
const key = getFunctionInputKey(abiTupleParameter.name || "tuple", param, index);
return <ContractInput setForm={setForm} form={form} key={key} stateObjectKey={key} paramType={param} />;
Expand Down
Loading

0 comments on commit 051ce26

Please sign in to comment.