Skip to content

Commit

Permalink
Merge branch 'la-audit-fixes' of github.com:NeokingdomDAO/contracts i…
Browse files Browse the repository at this point in the history
…nto la-audit-fixes
  • Loading branch information
sirnicolaz committed Oct 20, 2023
2 parents f590a6e + d139cd8 commit 7d7d086
Show file tree
Hide file tree
Showing 40 changed files with 81 additions and 44 deletions.
6 changes: 5 additions & 1 deletion contracts/GovernanceToken/GovernanceToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
Expand Down Expand Up @@ -46,6 +46,10 @@ contract GovernanceToken is Initializable, HasRole, GovernanceTokenSnapshot {
string memory name,
string memory symbol
) public initializer {
require(
address(roles) != address(0),
"GovernanceToken: 0x0 not allowed"
);
_initialize(name, symbol);
_setRoles(roles);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/GovernanceToken/GovernanceTokenBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "../RedemptionController/IRedemptionController.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/GovernanceToken/GovernanceTokenSnapshot.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/utils/Arrays.sol";
import "./IGovernanceToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/GovernanceToken/IGovernanceToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../extensions/ISnapshot.sol";
Expand Down
13 changes: 9 additions & 4 deletions contracts/InternalMarket/InternalMarket.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
Expand All @@ -22,13 +22,18 @@ contract InternalMarket is Initializable, HasRole, InternalMarketBase {
/**
* @dev Initializes the contract with the given roles and internal token.
* @param roles DAORoles instance containing custom access control roles.
* @param tokenInternal_ Reference to governance token.
* @param governanceToken Reference to governance token.
*/
function initialize(
DAORoles roles,
IGovernanceToken tokenInternal_
IGovernanceToken governanceToken
) public initializer {
_initialize(tokenInternal_, 7 days);
require(
address(roles) != address(0) &&
address(governanceToken) != address(0),
"InternalMarket: 0x0 not allowed"
);
_initialize(governanceToken, 7 days);
_setRoles(roles);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/InternalMarket/InternalMarketBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../ShareholderRegistry/IShareholderRegistry.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/NeokingdomToken/INeokingdomToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/NeokingdomToken/NeokingdomToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/RedemptionController/IRedemptionController.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
Expand Down
6 changes: 5 additions & 1 deletion contracts/RedemptionController/RedemptionController.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "./RedemptionControllerBase.sol";
Expand Down Expand Up @@ -35,6 +35,10 @@ contract RedemptionController is
* @param roles The addresses of DAORoles for this contract.
*/
function initialize(DAORoles roles) public initializer {
require(
address(roles) != address(0),
"RedemptionController: 0x0 not allowed"
);
_setRoles(roles);
_initialize();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "./IRedemptionController.sol";

Expand Down
9 changes: 8 additions & 1 deletion contracts/ResolutionManager/ResolutionManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { Roles } from "../extensions/Roles.sol";
Expand All @@ -26,6 +26,13 @@ contract ResolutionManager is Initializable, ResolutionManagerBase, HasRole {
IGovernanceToken governanceToken,
IVoting voting
) public initializer {
require(
address(roles) != address(0) &&
address(shareholderRegistry) != address(0) &&
address(governanceToken) != address(0) &&
address(voting) != address(0),
"ResolutionManager: 0x0 not allowed"
);
_setRoles(roles);
_initialize(shareholderRegistry, governanceToken, voting);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/ResolutionManager/ResolutionManagerBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../ShareholderRegistry/IShareholderRegistry.sol";
import "../GovernanceToken/IGovernanceToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/ShareholderRegistry/IShareholderRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../extensions/ISnapshot.sol";

Expand Down
6 changes: 5 additions & 1 deletion contracts/ShareholderRegistry/ShareholderRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "./ShareholderRegistrySnapshot.sol";
Expand Down Expand Up @@ -28,6 +28,10 @@ contract ShareholderRegistry is
string memory name,
string memory symbol
) public initializer {
require(
address(roles) != address(0),
"ShareholderRegistry: 0x0 not allowed"
);
_initialize(name, symbol);
_setRoles(roles);
}
Expand Down
7 changes: 5 additions & 2 deletions contracts/ShareholderRegistry/ShareholderRegistryBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
Expand Down Expand Up @@ -84,7 +84,10 @@ contract ShareholderRegistryBase is ERC20Upgradeable {
) internal view virtual returns (bool) {
return
balance > 0 &&
// shareholder < investor < contributor < managing board
// investor < contributor < managing board
// TODO: shareholder is currently equivalent to investor.
// We need to verify with the lawyer whether we can remove it
// completely from the smart contracts.
(status == INVESTOR_STATUS ||
status == SHAREHOLDER_STATUS ||
status == accountStatus ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "./ShareholderRegistryBase.sol";
import "../extensions/Snapshottable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/Voting/IVoting.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../extensions/ISnapshot.sol";

Expand Down
5 changes: 3 additions & 2 deletions contracts/Voting/Voting.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../ShareholderRegistry/IShareholderRegistry.sol";
Expand All @@ -18,6 +18,7 @@ contract Voting is VotingSnapshot, Initializable, HasRole {
* @param roles Instance of a DAORoles contract.
*/
function initialize(DAORoles roles) public initializer {
require(address(roles) != address(0), "Voting: 0x0 not allowed");
_setRoles(roles);
}

Expand Down Expand Up @@ -95,7 +96,7 @@ contract Voting is VotingSnapshot, Initializable, HasRole {

/**
* @notice Hook called on every governance token transfer.
* @dev Only the governance token can call this method.
* @dev Called by GovernanceToken and ShareholderRegistry.
* @param from The sender's address.
* @param to The receiver's address.
* @param amount The amount transferred.
Expand Down
2 changes: 1 addition & 1 deletion contracts/Voting/VotingBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../ShareholderRegistry/IShareholderRegistry.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/Voting/VotingSnapshot.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/utils/Arrays.sol";
import "../extensions/Snapshottable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/DAORoles.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/access/AccessControl.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/HasRole.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/ISnapshot.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

interface ISnapshot {
function snapshot() external returns (uint256);
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/Roles.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

library Roles {
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/Snapshottable.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/utils/Arrays.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ERC20Mock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/HasRoleMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../extensions/HasRole.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/NeokingdomTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

contract GovernanceTokenMock {
mapping(address => uint256) mockResult_balanceOfAt;
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/NeokingdomTokenV2Mock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../GovernanceToken/GovernanceToken.sol";
import "../extensions/Roles.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/NewTelediskoTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/utils/Arrays.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ResolutionExecutorMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

contract ResolutionExecutorMock {
event MockExecutionSimple(uint256 a);
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ResolutionManagerV2Mock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../ResolutionManager/ResolutionManager.sol";
import "../extensions/Roles.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ShareholderRegistryMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../ShareholderRegistry/IShareholderRegistry.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/TokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/VotingMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

contract VotingMock {
event AfterTokenTransferCalled(address from, address to, uint256 amount);
Expand Down
2 changes: 1 addition & 1 deletion echidna/proxies/InternalMarketProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "./TokenMock.sol";
import "../../contracts/InternalMarket/InternalMarket.sol";
Expand Down
2 changes: 1 addition & 1 deletion echidna/proxies/RedemptionControllerProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "../../contracts/RedemptionController/RedemptionController.sol";

Expand Down
2 changes: 1 addition & 1 deletion echidna/proxies/TokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;
pragma solidity 0.8.16;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand Down
Loading

0 comments on commit 7d7d086

Please sign in to comment.