Skip to content

Commit

Permalink
fix: Slither Issues (#81)
Browse files Browse the repository at this point in the history
* Clean up naming conventions

* Fix boolean constants

* Clean up linter warnings
  • Loading branch information
codynhat authored Sep 1, 2022
1 parent 20628c1 commit 2e0c21e
Show file tree
Hide file tree
Showing 31 changed files with 257 additions and 317 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "CI"
name: "Linter"
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
tests:
name: "Tests"
name: "Lint"
runs-on: ubuntu-latest
needs: []
steps:
Expand Down
5 changes: 4 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"extends": "solhint:recommended",
"rules": {
"prettier/prettier": "error",
"compiler-version": ["error", "^0.8.4"]
"compiler-version": ["error", "^0.8.4"],
"not-rely-on-time": "off",
"reason-string": ["warn", { "maxLength": 100 }],
"func-visibility": ["warn", { "ignoreConstructors": true }]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
},
{
"internalType": "contract IERC721",
"name": "_license",
"name": "initLicense",
"type": "address"
},
{
"internalType": "uint256",
"name": "_licenseId",
"name": "initLicenseId",
"type": "uint256"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@
"inputs": [
{
"internalType": "string",
"name": "_name",
"name": "initName",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"name": "initSymbol",
"type": "string"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_auctionEnd",
"name": "auctionEnd",
"type": "uint256"
}
],
Expand All @@ -212,7 +212,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_auctionStart",
"name": "auctionStart",
"type": "uint256"
}
],
Expand All @@ -225,7 +225,7 @@
"inputs": [
{
"internalType": "address",
"name": "_beacon",
"name": "beacon",
"type": "address"
}
],
Expand All @@ -238,7 +238,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_endingBid",
"name": "endingBid",
"type": "uint256"
}
],
Expand All @@ -251,7 +251,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_startingBid",
"name": "startingBid",
"type": "uint256"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"outputs": [
{
"internalType": "uint256",
"name": "i_x",
"name": "iX",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "i_y",
"name": "iY",
"type": "uint256"
},
{
Expand All @@ -68,40 +68,40 @@
},
{
"internalType": "uint256",
"name": "_i_x",
"name": "iX",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_i_y",
"name": "iY",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_i",
"name": "i",
"type": "uint256"
}
],
"name": "traverse",
"outputs": [
{
"internalType": "uint64",
"name": "destination",
"name": "",
"type": "uint64"
},
{
"internalType": "uint256",
"name": "i_x",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "i_y",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "i",
"name": "",
"type": "uint256"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
},
{
"internalType": "contract IERC721",
"name": "_license",
"name": "initLicense",
"type": "address"
},
{
"internalType": "uint256",
"name": "_licenseId",
"name": "initLicenseId",
"type": "uint256"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@
"inputs": [
{
"internalType": "string",
"name": "_name",
"name": "initName",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"name": "initSymbol",
"type": "string"
}
],
Expand Down Expand Up @@ -680,7 +680,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_auctionEnd",
"name": "auctionEnd",
"type": "uint256"
}
],
Expand All @@ -693,7 +693,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_auctionStart",
"name": "auctionStart",
"type": "uint256"
}
],
Expand All @@ -706,7 +706,7 @@
"inputs": [
{
"internalType": "address",
"name": "_beacon",
"name": "beacon",
"type": "address"
}
],
Expand All @@ -719,7 +719,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_endingBid",
"name": "endingBid",
"type": "uint256"
}
],
Expand All @@ -732,7 +732,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "_startingBid",
"name": "startingBid",
"type": "uint256"
}
],
Expand Down
3 changes: 3 additions & 0 deletions contracts/beacon-diamond/BeaconDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract BeaconDiamond {

// Find facet for function that is called and execute the
// function if a facet is found and return any value.
// solhint-disable-next-line no-complex-fallback
fallback() external payable {
LibBeaconDiamond.DiamondStorage storage ds = LibBeaconDiamond
.diamondStorage();
Expand All @@ -28,6 +29,7 @@ contract BeaconDiamond {
address facet = ds.beacon.facetAddress(msg.sig);
require(facet != address(0), "Diamond: Function does not exist");
// Execute external function from facet using delegatecall and return any value.
// solhint-disable-next-line no-inline-assembly
assembly {
// copy function selector and any arguments
calldatacopy(0, 0, calldatasize())
Expand All @@ -46,5 +48,6 @@ contract BeaconDiamond {
}
}

// solhint-disable-next-line no-empty-blocks
receive() external payable {}
}
4 changes: 3 additions & 1 deletion contracts/beacon-diamond/libraries/LibBeaconDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
import {IDiamondLoupe} from "hardhat-deploy/solc_0.8/diamond/interfaces/IDiamondLoupe.sol";

library LibBeaconDiamond {
bytes32 constant STORAGE_POSITION =
bytes32 private constant STORAGE_POSITION =
keccak256("diamond.standard.diamond.storage.LibBeaconDiamond");

struct DiamondStorage {
Expand All @@ -18,6 +18,8 @@ library LibBeaconDiamond {
returns (DiamondStorage storage ds)
{
bytes32 position = STORAGE_POSITION;

// solhint-disable-next-line no-inline-assembly
assembly {
ds.slot := position
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/pco-license/facets/CFABasePCOFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ contract CFABasePCOFacet is IBasePCO, CFABasePCOFacetModifiers {
* - Must have payment token buffer deposited
* - Must have permissions to create flow for bidder
* @param paramsStore Global store for parameters
* @param _license Underlying ERC721 license
* @param _licenseId Token ID of license
* @param initLicense Underlying ERC721 license
* @param initLicenseId Token ID of license
* @param bidder Initial bidder
* @param newContributionRate New contribution rate for bid
* @param newForSalePrice Intented new for sale price. Must be within rounding bounds of newContributionRate
*/
function initializeBid(
IPCOLicenseParamsStore paramsStore,
IERC721 _license,
uint256 _licenseId,
IERC721 initLicense,
uint256 initLicenseId,
address bidder,
int96 newContributionRate,
uint256 newForSalePrice
Expand All @@ -63,8 +63,8 @@ contract CFABasePCOFacet is IBasePCO, CFABasePCOFacetModifiers {
LibCFABasePCO.DiamondStorage storage ds = LibCFABasePCO
.diamondStorage();
ds.paramsStore = paramsStore;
ds.license = _license;
ds.licenseId = _licenseId;
ds.license = initLicense;
ds.licenseId = initLicenseId;

uint256 perSecondFeeNumerator = ds
.paramsStore
Expand Down
8 changes: 4 additions & 4 deletions contracts/pco-license/facets/CFAPenaltyBidFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract CFAPenaltyBidFacet is ICFABiddable, CFABasePCOFacetModifiers {
modifier onlyIfPendingBid() {
// Check if pending bid exists
require(
this.hasPendingBid() == true,
this.hasPendingBid(),
"CFAPenaltyBidFacet: Pending bid does not exist"
);
_;
Expand All @@ -50,7 +50,7 @@ contract CFAPenaltyBidFacet is ICFABiddable, CFABasePCOFacetModifiers {
modifier onlyIfNotPendingBid() {
// Check if pending bid exists
require(
this.hasPendingBid() == false,
!this.hasPendingBid(),
"CFAPenaltyBidFacet: Pending bid exists"
);
_;
Expand All @@ -64,7 +64,7 @@ contract CFAPenaltyBidFacet is ICFABiddable, CFABasePCOFacetModifiers {
.diamondStorage();

// Succeed if payer bid is not active
if (LibCFABasePCO._isPayerBidActive() == true) {
if (LibCFABasePCO._isPayerBidActive()) {
uint256 bidPeriodLengthInSeconds = ds
.paramsStore
.getBidPeriodLengthInSeconds();
Expand Down Expand Up @@ -156,7 +156,7 @@ contract CFAPenaltyBidFacet is ICFABiddable, CFABasePCOFacetModifiers {

// Check if pending bid exists
require(
this.hasPendingBid() == false,
!this.hasPendingBid(),
"CFAPenaltyBidFacet: Pending bid already exists"
);

Expand Down
9 changes: 6 additions & 3 deletions contracts/pco-license/libraries/LibCFABasePCO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ library LibCFABasePCO {
using CFAv1Library for CFAv1Library.InitData;
using SafeERC20 for ISuperToken;

bytes32 constant STORAGE_POSITION =
bytes32 private constant STORAGE_POSITION =
keccak256("diamond.standard.diamond.storage.LibBasePCO");

bytes32 constant STORAGE_POSITION_CUR_BID =
bytes32 private constant STORAGE_POSITION_CUR_BID =
keccak256("diamond.standard.diamond.storage.LibBasePCO.currentBid");

bytes32 constant STORAGE_POSITION_CFA =
bytes32 private constant STORAGE_POSITION_CFA =
keccak256("diamond.standard.diamond.storage.LibBasePCO.cfa");

struct Bid {
Expand Down Expand Up @@ -56,6 +56,7 @@ library LibCFABasePCO {
returns (DiamondStorage storage ds)
{
bytes32 position = STORAGE_POSITION;
// solhint-disable-next-line no-inline-assembly
assembly {
ds.slot := position
}
Expand All @@ -64,6 +65,7 @@ library LibCFABasePCO {
/// @dev Store currentBid in separate position so struct is upgradeable
function _currentBid() internal pure returns (Bid storage bid) {
bytes32 position = STORAGE_POSITION_CUR_BID;
// solhint-disable-next-line no-inline-assembly
assembly {
bid.slot := position
}
Expand All @@ -72,6 +74,7 @@ library LibCFABasePCO {
/// @dev Store cfa in separate position so struct is upgradeable
function cfaStorage() internal pure returns (DiamondCFAStorage storage ds) {
bytes32 position = STORAGE_POSITION_CFA;
// solhint-disable-next-line no-inline-assembly
assembly {
ds.slot := position
}
Expand Down
Loading

0 comments on commit 2e0c21e

Please sign in to comment.