diff --git a/README.md b/README.md index e392059..a990809 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# Smart Housing \ No newline at end of file +# Smart Housing + diff --git a/packages/backend/contracts/housing-project/HousingSFT.sol b/packages/backend/contracts/housing-project/HousingSFT.sol index c45b7f3..005e730 100644 --- a/packages/backend/contracts/housing-project/HousingSFT.sol +++ b/packages/backend/contracts/housing-project/HousingSFT.sol @@ -85,7 +85,7 @@ contract HousingSFT is SFT { }) ); - return _mint(depositor, mintShare, attributes, ""); + return _mint(depositor, mintShare, attributes); } /// @notice Retrieves the SFT attributes for a given owner and nonce. @@ -101,7 +101,7 @@ contract HousingSFT is SFT { "HousingSFT: No tokens found for user at nonce" ); - return abi.decode(getRawTokenAttributes(nonce), (HousingAttributes)); + return abi.decode(_getRawTokenAttributes(nonce), (HousingAttributes)); } /// @notice Returns the maximum supply of the HousingSFT tokens. diff --git a/packages/backend/contracts/main/HST.sol b/packages/backend/contracts/main/HST.sol index 1d80cb7..af539fb 100644 --- a/packages/backend/contracts/main/HST.sol +++ b/packages/backend/contracts/main/HST.sol @@ -89,11 +89,18 @@ contract HousingStakingToken is SFT { }); // Mint the HST token - uint256 nonce = _mint(caller, 1, abi.encode(attr), ""); + uint256 nonce = _mint(caller, 1, abi.encode(attr)); emit MintHstToken(caller, nonce, attr); } + function getAttribute(uint256 nonce) external view returns (HstAttributes memory) { + return abi.decode( + _getRawTokenAttributes(nonce), + (HstAttributes) + ); + } + /// @notice Retrieves the balance of HST tokens for a specified user. /// @param user Address of the user whose balance is to be retrieved. /// @return balance Array of HSTBalance representing the user's HST holdings. diff --git a/packages/backend/contracts/main/SmartHousing.sol b/packages/backend/contracts/main/SmartHousing.sol index 8e5fffd..6f410b6 100644 --- a/packages/backend/contracts/main/SmartHousing.sol +++ b/packages/backend/contracts/main/SmartHousing.sol @@ -162,10 +162,7 @@ contract SmartHousing is ISmartHousing, Ownable, UserModule, ERC1155Holder { .lastFundsDispatchEpoch < currentEpoch(); if (rewardsCanBeGenerated) return true; - HstAttributes memory hstAttr = abi.decode( - hst.getRawTokenAttributes(tokenNonce), - (HstAttributes) - ); + HstAttributes memory hstAttr = hst.getAttribute(tokenNonce); return hstAttr.shtRewardPerShare < distributionStorage.shtRewardPerShare; } @@ -186,9 +183,7 @@ contract SmartHousing is ISmartHousing, Ownable, UserModule, ERC1155Holder { distributionStorage.generateRewards(epochsAndPeriodsStorage); (uint256 claimedSHT, HstAttributes memory hstAttr) = distributionStorage - .claimRewards( - abi.decode(hst.getRawTokenAttributes(hstNonce), (HstAttributes)) - ); + .claimRewards(hst.getAttribute(hstNonce)); uint256 rentRewards = 0; // Claim rent rewards from HousingProjects diff --git a/packages/backend/contracts/modules/LockedSmartHousingToken.sol b/packages/backend/contracts/modules/LockedSmartHousingToken.sol index 185a593..307f523 100644 --- a/packages/backend/contracts/modules/LockedSmartHousingToken.sol +++ b/packages/backend/contracts/modules/LockedSmartHousingToken.sol @@ -75,8 +75,18 @@ contract LkSHT is SFT { LkSHTAttributes.newAttributes(startTimestamp, amount) ); - super._mint(to, amount, attributes, "LockedSmartHousingToken"); + super._mint(to, amount, attributes); emit TokensMinted(to, amount); } + + function getAttribute( + uint256 nonce + ) external view returns (LkSHTAttributes.Attributes memory) { + return + abi.decode( + _getRawTokenAttributes(nonce), + (LkSHTAttributes.Attributes) + ); + } } diff --git a/packages/backend/contracts/modules/SFT.sol b/packages/backend/contracts/modules/SFT.sol index 4b16a10..a22230c 100644 --- a/packages/backend/contracts/modules/SFT.sol +++ b/packages/backend/contracts/modules/SFT.sol @@ -36,22 +36,19 @@ contract SFT is ERC1155, Ownable { function _mint( address to, uint256 amount, - bytes memory attributes, - bytes memory data - ) internal returns (uint256) { + bytes memory attributes + ) internal returns (uint256 nonce) { _nonceCounter.increment(); - uint256 nonce = _nonceCounter.current(); + nonce = _nonceCounter.current(); // Store the attributes _tokenAttributes[nonce] = attributes; // Mint the token with the nonce as its ID - super._mint(to, nonce, amount, data); + super._mint(to, nonce, amount, ""); // Track the nonce for the address _addressToNonces[to].add(nonce); - - return nonce; } /// @dev Returns the name of the token. @@ -72,9 +69,9 @@ contract SFT is ERC1155, Ownable { /// @dev Returns raw token attributes by nonce. /// @param nonce The nonce of the token. /// @return Attributes in bytes. - function getRawTokenAttributes( + function _getRawTokenAttributes( uint256 nonce - ) public view returns (bytes memory) { + ) internal view returns (bytes memory) { return _tokenAttributes[nonce]; } @@ -106,7 +103,7 @@ contract SFT is ERC1155, Ownable { bytes memory attr ) external onlyOwner returns (uint256) { _burn(user, nonce, amount); - return _mint(user, amount, attr, ""); + return amount > 0 ? _mint(user, amount, attr) : 0; } /// @dev Returns the balance of the user with their token attributes. @@ -151,11 +148,10 @@ contract SFT is ERC1155, Ownable { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { - _addressToNonces[from].remove(ids[i]); - } + uint256 id = ids[i]; - for (uint256 i = 0; i < ids.length; i++) { - _addressToNonces[to].add(ids[i]); + _addressToNonces[from].remove(id); + _addressToNonces[to].add(id); } } } diff --git a/packages/backend/contracts/project-funding/ProjectFunding.sol b/packages/backend/contracts/project-funding/ProjectFunding.sol index cc352fe..578cef9 100644 --- a/packages/backend/contracts/project-funding/ProjectFunding.sol +++ b/packages/backend/contracts/project-funding/ProjectFunding.sol @@ -229,10 +229,7 @@ contract ProjectFunding is Ownable { uint256 lkShtBal = lkSht.balanceOf(caller, nonce); require(lkShtBal > 0, "ProjectFunding: Nothing to unlock"); - LkSHTAttributes.Attributes memory attr = abi.decode( - lkSht.getRawTokenAttributes(nonce), - (LkSHTAttributes.Attributes) - ); + LkSHTAttributes.Attributes memory attr = lkSht.getAttribute(nonce); ( uint256 totalUnlockedAmount, LkSHTAttributes.Attributes memory newAttr diff --git a/packages/ui/app/properties/BuyPropertyModal.tsx b/packages/ui/app/properties/BuyPropertyModal.tsx index f9d97b8..4b72f11 100644 --- a/packages/ui/app/properties/BuyPropertyModal.tsx +++ b/packages/ui/app/properties/BuyPropertyModal.tsx @@ -13,8 +13,8 @@ import useRawCallsInfo from "~~/hooks/useRawCallsInfo"; import { useSpendERC20 } from "~~/hooks/useSpendERC20"; import { RefIdData } from "~~/utils"; -type Props = ProjectsValue["projectData"] & { purchased?: bigint; unitPrice: bigint }; -export default function BuyPropertyModal({ unitPrice, data, fundingToken, sftDetails, purchased }: Props) { +type Props = ProjectsValue["projectData"] & { purchased?: bigint; unitPrice: bigint; imgSrc: string }; +export default function BuyPropertyModal({ imgSrc, unitPrice, data, fundingToken, sftDetails, purchased }: Props) { const unitsLeft = +BigNumber(sftDetails.maxSupply.toString()) .multipliedBy((data.fundingGoal - data.collectedFunds).toString()) .dividedBy(data.fundingGoal.toString()) @@ -88,7 +88,7 @@ export default function BuyPropertyModal({ unitPrice, data, fundingToken, sftDet
- +

diff --git a/packages/ui/app/properties/index.tsx b/packages/ui/app/properties/index.tsx index f7fe535..ce564df 100644 --- a/packages/ui/app/properties/index.tsx +++ b/packages/ui/app/properties/index.tsx @@ -180,6 +180,7 @@ export default function Properties() { onClick={() => openModal(
-
+ smart-housing
{APP_NAME}
diff --git a/packages/ui/components/TransactionWaitingIcon/index.tsx b/packages/ui/components/TransactionWaitingIcon/index.tsx index 15251db..8b93c0b 100644 --- a/packages/ui/components/TransactionWaitingIcon/index.tsx +++ b/packages/ui/components/TransactionWaitingIcon/index.tsx @@ -7,7 +7,7 @@ import styles from "./style.module.scss"; export type IconReqState = "idle" | "error" | "success" | "pending"; -const matchStrings = [" reason:", " Error:"]; +const matchStrings = [" reason:", " Error:", "TransactionExecutionError:"]; const processedMatchString = matchStrings.reduce((acc, curr, index) => { acc += curr; @@ -21,8 +21,6 @@ const errorMsg = (msg: string) => { const regEx = new RegExp("(" + processedMatchString + ")(\n)?(.*)", "g"); const match = msg.match(regEx); - console.log({ match, msg }); - const error = match?.at(-1)?.replace(processedMatchString, ""); return error; diff --git a/packages/ui/contracts/deployedContracts.ts b/packages/ui/contracts/deployedContracts.ts index e022583..36d5a6f 100644 --- a/packages/ui/contracts/deployedContracts.ts +++ b/packages/ui/contracts/deployedContracts.ts @@ -1482,7 +1482,6 @@ const deployedContracts = { balanceOf: "contracts/modules/SFT.sol", balanceOfBatch: "contracts/modules/SFT.sol", getNonces: "contracts/modules/SFT.sol", - getRawTokenAttributes: "contracts/modules/SFT.sol", hasSFT: "contracts/modules/SFT.sol", isApprovedForAll: "contracts/modules/SFT.sol", name: "contracts/modules/SFT.sol", @@ -5109,25 +5108,6 @@ const deployedContracts = { stateMutability: "view", type: "function", }, - { - inputs: [ - { - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - ], - name: "getRawTokenAttributes", - outputs: [ - { - internalType: "bytes", - name: "", - type: "bytes", - }, - ], - stateMutability: "view", - type: "function", - }, { inputs: [ { @@ -5581,7 +5561,6 @@ const deployedContracts = { balanceOf: "contracts/modules/SFT.sol", balanceOfBatch: "contracts/modules/SFT.sol", getNonces: "contracts/modules/SFT.sol", - getRawTokenAttributes: "contracts/modules/SFT.sol", hasSFT: "contracts/modules/SFT.sol", isApprovedForAll: "contracts/modules/SFT.sol", name: "contracts/modules/SFT.sol", @@ -5873,17 +5852,71 @@ const deployedContracts = { { inputs: [ { - internalType: "address", - name: "owner", - type: "address", + internalType: "uint256", + name: "nonce", + type: "uint256", }, ], - name: "getNonces", + name: "getAttribute", outputs: [ { - internalType: "uint256[]", + components: [ + { + components: [ + { + internalType: "address", + name: "token", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + ], + internalType: "struct TokenPayment[]", + name: "projectTokens", + type: "tuple[]", + }, + { + internalType: "uint256", + name: "projectsShareCheckpoint", + type: "uint256", + }, + { + internalType: "uint256", + name: "shtRewardPerShare", + type: "uint256", + }, + { + internalType: "uint256", + name: "shtAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "stakeWeight", + type: "uint256", + }, + { + internalType: "uint256", + name: "lkDuration", + type: "uint256", + }, + { + internalType: "uint256[]", + name: "lkShtNonces", + type: "uint256[]", + }, + ], + internalType: "struct HstAttributes", name: "", - type: "uint256[]", + type: "tuple", }, ], stateMutability: "view", @@ -5892,17 +5925,17 @@ const deployedContracts = { { inputs: [ { - internalType: "uint256", - name: "nonce", - type: "uint256", + internalType: "address", + name: "owner", + type: "address", }, ], - name: "getRawTokenAttributes", + name: "getNonces", outputs: [ { - internalType: "bytes", + internalType: "uint256[]", name: "", - type: "bytes", + type: "uint256[]", }, ], stateMutability: "view", @@ -6628,17 +6661,39 @@ const deployedContracts = { { inputs: [ { - internalType: "address", - name: "owner", - type: "address", + internalType: "uint256", + name: "nonce", + type: "uint256", }, ], - name: "getNonces", + name: "getAttribute", outputs: [ { - internalType: "uint256[]", + components: [ + { + internalType: "uint256", + name: "initialAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTimestamp", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTimestamp", + type: "uint256", + }, + ], + internalType: "struct LkSHTAttributes.Attributes", name: "", - type: "uint256[]", + type: "tuple", }, ], stateMutability: "view", @@ -6647,17 +6702,17 @@ const deployedContracts = { { inputs: [ { - internalType: "uint256", - name: "nonce", - type: "uint256", + internalType: "address", + name: "owner", + type: "address", }, ], - name: "getRawTokenAttributes", + name: "getNonces", outputs: [ { - internalType: "bytes", + internalType: "uint256[]", name: "", - type: "bytes", + type: "uint256[]", }, ], stateMutability: "view", diff --git a/packages/ui/public/favicon.ico b/packages/ui/public/favicon.ico new file mode 100644 index 0000000..76684db Binary files /dev/null and b/packages/ui/public/favicon.ico differ diff --git a/packages/ui/public/favicon.png b/packages/ui/public/favicon.png deleted file mode 100644 index 4bef7f2..0000000 Binary files a/packages/ui/public/favicon.png and /dev/null differ diff --git a/packages/ui/public/logo.png b/packages/ui/public/logo.png new file mode 100644 index 0000000..76684db Binary files /dev/null and b/packages/ui/public/logo.png differ diff --git a/packages/ui/public/logo.svg b/packages/ui/public/logo.svg index 93e4b40..da61efb 100644 --- a/packages/ui/public/logo.svg +++ b/packages/ui/public/logo.svg @@ -1,10 +1,13 @@ - - - - - - - - - + + + + + + + + + + + + diff --git a/packages/ui/public/manifest.json b/packages/ui/public/manifest.json index bb1c96d..02853e2 100644 --- a/packages/ui/public/manifest.json +++ b/packages/ui/public/manifest.json @@ -1,5 +1,5 @@ { - "name": "Scaffold-ETH 2 DApp", - "description": "A DApp built with Scaffold-ETH", + "name": "SmartHousing", + "description": "The future of real estate", "iconPath": "logo.svg" } diff --git a/packages/ui/public/thumbnail.jpg b/packages/ui/public/thumbnail.jpg deleted file mode 100644 index a3bf231..0000000 Binary files a/packages/ui/public/thumbnail.jpg and /dev/null differ