Skip to content

Redundant usage of msg.sender and msg.value#

Informational

In Canvas.sol there are multiple cases where libraries are called with msg.sender and msg.value forwarded as arguments. Since a call to a library is a delegateCall, there is no need for that. Reading msg.sender or msg.value within the library will give the same result as reading it in the contract that is calling the library.

Example#

Code in Canvas.sol

function mint(
    uint256 canvasId,
    bytes calldata data
  ) external payable {
    Minting.mint(
      msg.sender,
      msg.value,
      canvasId,
      data
    );
  }
Code in Minting.sol
function mint(
    address msgSender,
    uint256 ethValue,
    uint256 canvasId,
    bytes calldata data
  ) external nonReentrant {
    Schema.Storage storage ds = canvasStorage();
    Schema.Canvas storage canvas = ds.canvas[canvasId];

    Schema.MintRequest memory mintRequest = getMintRequest(data);

    if (!canvas.reserveAuction) defaultMint(msgSender, canvasId, ethValue, mintRequest);
    else {
      mintReserveAuction(msgSender, canvasId, mintRequest.selectedTraits);
      emit OneMinted(msgSender, canvasId, mintRequest);
    }
  }

Recommendation#

Remove msg.sender and msg.value forwarding. Use msg.sender and msg.value directly where needed in libraries.