Skip to content

Conversation

@FarzeenKist
Copy link

Fixes and Improvement

  1. Improved documentation by adding more comments using natspec
  2. Removed redundant variables and functions
  3. Added the modifier exist and mapping exists to keep track of properties that exist and to prevent any unexpected bugs and behaviors
  4. Grouped common checks into their own modifiers
  5. Grouped functions canbeCancelled,canUpdateShares and canUpdatePrices into canModifyProperty and also fixed a bug(all the listed conditions should be true to be able to update the respective values but the functions return true as long as one condition was true)
  6. Property owners shouldn't be able to buy their own property
  7. Added checks when creating property and updating any values to prevent unexpected bugs

@FarzeenKist
Copy link
Author

I've also forgot to mention that anyone could approve a spender for shares of a contract. I've added a check to prevent that

address spender,
uint _index,
uint amount
) external exist(_index) onlyPropertyOwner(_index) {
Copy link
Owner

Choose a reason for hiding this comment

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

This function can be removed entirely because it's not used.
In the end I decided to let the smart contract of the marketplace to own the House Tokens.

Copy link
Author

Choose a reason for hiding this comment

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

That's fine too!


/// @dev checks if a property exist
modifier exist(uint _index) {
require(exists[_index], "Query of non existent property");
Copy link
Owner

Choose a reason for hiding this comment

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

nothing is passed to the exist variable in this PR so maybe it would be better to check if the index is in the properties mapping? or am I missing something?

Copy link
Owner

Choose a reason for hiding this comment

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

Ok i just sure the exist function but not sure if I agree/understand that choice for the implementation, would love to hear the rationale

Copy link
Author

Choose a reason for hiding this comment

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

Oh I'm sorry, I forgot to add the related line when writing a property. In your case, your functions have enough checks to prevent the bugs I could find that were related to that, but the transactions would be reverted with a misleading reason.

_;
}
/// @dev checks if any property's shares have been sold
modifier onlySharesNotSold(uint _index) {
Copy link
Owner

Choose a reason for hiding this comment

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

great idea to make these modifiers

public
view
returns (uint){
function getPropertiesLength() public view returns (uint) {
Copy link
Owner

Choose a reason for hiding this comment

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

there are some times you change the function signatures to have one item per line and then in this case it's been compressed to one line. What's the reason?

Copy link
Author

Choose a reason for hiding this comment

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

It's my formatting extension (I believe it's currently set on the hardhat + solidity)

view
returns(bool)
/// @dev returns the number of shares available for sale
function getPropertyTokensRemaining(uint _index)
Copy link
Owner

Choose a reason for hiding this comment

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

yes this is a useful function to have when the code is extended, thank you

require(msg.sender==properties[_index].owner, "Only the property owner can cancel the sale");
require(properties[_index].stockData.sold==0, "The sale cannot be updated if some tokens are already issued");
require(properties[_index].status!=Status.SaleCancelled, "The property sale is cancelled");
require(_price > 0);
Copy link
Owner

Choose a reason for hiding this comment

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

awesome!

{
require(
properties[_index].owner != msg.sender,
"You can't buy shares off your own property"
Copy link
Owner

Choose a reason for hiding this comment

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

haha i don't mind if they do buy shares of their own property, they can be a part owner with other folks. that's ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants