Git Product home page Git Product logo

gotchiverse-crowdfarming-contracts's Introduction

Hi there ๐Ÿ‘‹

gotchiverse-crowdfarming-contracts's People

Contributors

mudgen avatar programmablewealth avatar

Watchers

 avatar

gotchiverse-crowdfarming-contracts's Issues

Unnecesssary requires

require(msg.sender == IAavegotchiRealmDiamond(aavegotchiRealmDiamond).ownerOf(_landTokenId), "Sender must own the land parcel");

require(address(this) == IAavegotchiRealmDiamond(aavegotchiRealmDiamond).ownerOf(_tokenId), "Smart contract must own the land parcel");

The transfer call will fail if the owner is not correct, so these checks are redundant. It's fine to keep them if it makes you feel more comfortable, but personally I think it's a wasted check.

Provide internal entry point

This function only has an external entry point. Because of this, the function requires calling this.calculateBudget. This is dangerous when combined with LibMeta, as LibMeta relies on making external function calls to address(this) to manipulate sender address.

I recommend either:

  1. Making the function public so that you don't have to make an external call to your own contract.
  2. Making a library that would contain all internal logic. This would be useful if you ever added more facets to your contract, as this internal functionality can be shared between facets.

Use internal calls

budget: this.calculateBudget(_installationIds, _installationQuantities, _instaBuild),

uint256[] memory cost = this.getCummulativeAlchemicaCost(_installationIds[i]);

These lines should be using internal calls, e.g. just using "calculateBudget()" rather than "this.calculateBudget()"

A public function is both an external and internal function. By using "this", you are telling solidity to call this function externally which changes msg.sender. This also increases gas cost as internal calls are cheaper than external ones.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.