Redundant conversions in views#
Informational
In View.sol there are multiple functions that return a struct from storage. In the process of doing that, the struct is first saved to memory, converted to bytes, and then the bytes are returned. That is unnecessary, since you can just return the struct and the return value will be the same.
These functions are: contractInfo
, getCanvasData
and getCanvasSystem
.
Example#
function contractInfo()
external view returns (
bytes memory
) {
Schema.ContractInfo memory info = canvasStorage().contractInfo;
return bytes.concat(
abi.encode(
info.daoAddress,
info.newDaoRequest,
info.curatorAddress,
info.newCuratorRequest,
info.canvasAddress,
info.licenseRegistryAddress,
info.tokenRegistryAddress,
info.vrfAddress,
info.keeperAddress,
info.keeperRegistrarAddress,
info.linkTokenAddress,
info.collectionContractAddress
),
abi.encode(
info.canvasOneAddress,
info.canvasOneCuratedAddress,
info.protocolFeeRecipient,
info.protocolFeeBps,
info.protocolDutchRefundFeeBps,
info.canvasCounter,
info.canvasCuratedCounter,
info.canvasOpenCounter,
info.canvasOneCounter,
info.canvasOneCuratedCounter,
info.openCanvas,
info.openCanvasOne
)
);
}
Recommendation#
Change the code like this: