Skip to content

Commit

Permalink
Merge pull request #152 from yuzu-finance/izzyg/fix-solidity-compiler…
Browse files Browse the repository at this point in the history
…-warnings

Address all solidity compiler (`solc`) warnings.
  • Loading branch information
ecp4224 authored Oct 14, 2022
2 parents e98cf99 + b12ff80 commit 6ec8de4
Show file tree
Hide file tree
Showing 45 changed files with 119 additions and 79 deletions.
63 changes: 31 additions & 32 deletions contracts/ERC1400.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down Expand Up @@ -165,29 +166,27 @@ contract ERC1400 is IERC20, IERC1400, Ownable, ERC1820Client, ERC1820Implementer

/**
* @dev Initialize ERC1400 + register the contract implementation in ERC1820Registry.
* @param name Name of the token.
* @param symbol Symbol of the token.
* @param granularity Granularity of the token.
* @param controllers Array of initial controllers.
* @param tokenName Name of the token.
* @param tokenSymbol Symbol of the token.
* @param tokenGranularity Granularity of the token.
* @param initialControllers Array of initial controllers.
* @param defaultPartitions Partitions chosen by default, when partition is
* not specified, like the case ERC20 tranfers.
*/
constructor(
string memory name,
string memory symbol,
uint256 granularity,
address[] memory controllers,
string memory tokenName,
string memory tokenSymbol,
uint256 tokenGranularity,
address[] memory initialControllers,
bytes32[] memory defaultPartitions
)
public
{
_name = name;
_symbol = symbol;
) {
_name = tokenName;
_symbol = tokenSymbol;
_totalSupply = 0;
require(granularity >= 1); // Constructor Blocked - Token granularity can not be lower than 1
_granularity = granularity;
require(tokenGranularity >= 1); // Constructor Blocked - Token granularity can not be lower than 1
_granularity = tokenGranularity;

_setControllers(controllers);
_setControllers(initialControllers);

_defaultPartitions = defaultPartitions;

Expand Down Expand Up @@ -285,26 +284,26 @@ contract ERC1400 is IERC20, IERC1400, Ownable, ERC1820Client, ERC1820Implementer
/************************************* Document Management **************************************/
/**
* @dev Access a document associated with the token.
* @param name Short name (represented as a bytes32) associated to the document.
* @param documentName Short name (represented as a bytes32) associated to the document.
* @return Requested document + document hash + document timestamp.
*/
function getDocument(bytes32 name) external override view returns (string memory, bytes32, uint256) {
require(bytes(_documents[name].docURI).length != 0); // Action Blocked - Empty document
function getDocument(bytes32 documentName) external override view returns (string memory, bytes32, uint256) {
require(bytes(_documents[documentName].docURI).length != 0); // Action Blocked - Empty document
return (
_documents[name].docURI,
_documents[name].docHash,
_documents[name].timestamp
_documents[documentName].docURI,
_documents[documentName].docHash,
_documents[documentName].timestamp
);
}
/**
* @dev Associate a document with the token.
* @param name Short name (represented as a bytes32) associated to the document.
* @param documentName Short name (represented as a bytes32) associated to the document.
* @param uri Document content.
* @param documentHash Hash of the document [optional parameter].
*/
function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external override {
function setDocument(bytes32 documentName, string calldata uri, bytes32 documentHash) external override {
require(_isController[msg.sender]);
_documents[name] = Doc({
_documents[documentName] = Doc({
docURI: uri,
docHash: documentHash,
timestamp: block.timestamp
Expand All @@ -315,14 +314,14 @@ contract ERC1400 is IERC20, IERC1400, Ownable, ERC1820Client, ERC1820Implementer
_indexOfDocHashes[documentHash] = _docHashes.length;
}

emit DocumentUpdated(name, uri, documentHash);
emit DocumentUpdated(documentName, uri, documentHash);
}

function removeDocument(bytes32 _name) external override {
function removeDocument(bytes32 documentName) external override {
require(_isController[msg.sender], "Unauthorized");
require(bytes(_documents[_name].docURI).length != 0, "Document doesnt exist"); // Action Blocked - Empty document
require(bytes(_documents[documentName].docURI).length != 0, "Document doesnt exist"); // Action Blocked - Empty document

Doc memory data = _documents[_name];
Doc memory data = _documents[documentName];

uint256 index1 = _indexOfDocHashes[data.docHash];
require(index1 > 0, "Invalid index"); //Indexing starts at 1, 0 is not allowed
Expand All @@ -336,9 +335,9 @@ contract ERC1400 is IERC20, IERC1400, Ownable, ERC1820Client, ERC1820Implementer
_docHashes.pop();
_indexOfDocHashes[data.docHash] = 0;

delete _documents[_name];
delete _documents[documentName];

emit DocumentRemoved(_name, data.docURI, data.docHash);
emit DocumentRemoved(documentName, data.docURI, data.docHash);
}

function getAllDocuments() external override view returns (bytes32[] memory) {
Expand Down Expand Up @@ -1436,7 +1435,7 @@ contract ERC1400 is IERC20, IERC1400, Ownable, ERC1820Client, ERC1820Implementer
return _name;
}

function domainVersion() public override view returns (string memory) {
function domainVersion() public override pure returns (string memory) {
return "1";
}
/************************************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions contracts/IERC1400.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
1 change: 1 addition & 0 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;


Expand Down
2 changes: 1 addition & 1 deletion contracts/certificate/ERC1400HoldableCertificateToken.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down Expand Up @@ -71,7 +72,6 @@ contract ERC1400HoldableCertificateToken is ERC1400, IExtensionTypes {
address certificateSigner,
CertificateValidation certificateActivated
)
public
ERC1400(name, symbol, granularity, controllers, defaultPartitions)
{
if(extension != address(0)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down Expand Up @@ -33,7 +34,7 @@ contract ERC1400TokensChecker is IERC1400TokensChecker, ERC1820Client, ERC1820Im
string constant internal ERC1400_TOKENS_SENDER = "ERC1400TokensSender";
string constant internal ERC1400_TOKENS_RECIPIENT = "ERC1400TokensRecipient";

constructor() public {
constructor() {
ERC1820Implementer._setInterface(ERC1400_TOKENS_CHECKER);
}

Expand Down
17 changes: 9 additions & 8 deletions contracts/extensions/tokenExtensions/ERC1400TokensValidator.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down Expand Up @@ -469,9 +470,9 @@ contract ERC1400TokensValidator is IERC1400TokensValidator, Pausable, Certificat
if (_holdsActivated[token] && from != address(0)) {
if(operator != from) {
(, bytes32 holdId) = _retrieveHoldHashId(token, partition, operator, from, to, value);
Hold storage hold = _holds[token][holdId];
Hold storage hold_ = _holds[token][holdId];

if (_holdCanBeExecutedAsNotary(hold, operator, value) && value <= IERC1400(token).balanceOfByPartition(partition, from)) {
if (_holdCanBeExecutedAsNotary(hold_, operator, value) && value <= IERC1400(token).balanceOfByPartition(partition, from)) {
return true;
}
}
Expand Down Expand Up @@ -877,8 +878,8 @@ contract ERC1400TokensValidator is IERC1400TokensValidator, Pausable, Certificat
/**
* @dev Execute hold.
*/
function executeHold(address token, bytes32 holdId, uint256 value, bytes32 secret) external override returns (bool) {
return _executeHold(
function executeHold(address token, bytes32 holdId, uint256 value, bytes32 secret) external override {
_executeHold(
token,
holdId,
msg.sender,
Expand All @@ -891,8 +892,8 @@ contract ERC1400TokensValidator is IERC1400TokensValidator, Pausable, Certificat
/**
* @dev Execute hold and keep open.
*/
function executeHoldAndKeepOpen(address token, bytes32 holdId, uint256 value, bytes32 secret) external returns (bool) {
return _executeHold(
function executeHoldAndKeepOpen(address token, bytes32 holdId, uint256 value, bytes32 secret) external {
_executeHold(
token,
holdId,
msg.sender,
Expand All @@ -912,7 +913,7 @@ contract ERC1400TokensValidator is IERC1400TokensValidator, Pausable, Certificat
uint256 value,
bytes32 secret,
bool keepOpenIfHoldHasBalance
) internal returns (bool)
) internal
{
Hold storage executableHold = _holds[token][holdId];

Expand Down Expand Up @@ -1017,7 +1018,7 @@ contract ERC1400TokensValidator is IERC1400TokensValidator, Pausable, Certificat
/**
* @dev Increase held balance.
*/
function _increaseHeldBalance(address token, Hold storage executableHold, bytes32 holdId) private {
function _increaseHeldBalance(address token, Hold storage executableHold, bytes32/*holdId*/) private {
_heldBalance[token][executableHold.sender] = _heldBalance[token][executableHold.sender].add(executableHold.value);
_totalHeldBalance[token] = _totalHeldBalance[token].add(executableHold.value);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
1 change: 1 addition & 0 deletions contracts/interface/ERC1820Implementer.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
1 change: 1 addition & 0 deletions contracts/interface/HoldStatusCode.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

enum HoldStatusCode {
Expand Down
1 change: 1 addition & 0 deletions contracts/interface/IERC1643.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

/// @title IERC1643 Document Management (part of the ERC1400 Security Token Standards)
Expand Down
5 changes: 3 additions & 2 deletions contracts/interface/IERC20HoldableToken.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down Expand Up @@ -40,12 +41,12 @@ interface IERC20HoldableToken is IERC20 {

/**
@notice Called by the sender to hold some tokens for a recipient that the sender can not release back to themself until after the expiration date.
@param holdId a unique identifier for the hold.
@param recipient optional account the tokens will be transferred to on execution. If a zero address, the recipient must be specified on execution of the hold.
@param notary account that can execute the hold. Typically the recipient but can be a third party or a smart contact.
@param amount of tokens to be transferred to the recipient on execution. Must be a non zero amount.
@param expirationDateTime UNIX epoch seconds the held amount can be released back to the sender by the sender. Past dates are allowed.
@param lockHash optional keccak256 hash of a lock preimage. An empty hash will not enforce the hash lock when the hold is executed.
@return bool Whether the call was successful or not.
*/
function hold(
bytes32 holdId,
Expand All @@ -54,7 +55,7 @@ interface IERC20HoldableToken is IERC20 {
uint256 amount,
uint256 expirationDateTime,
bytes32 lockHash
) external returns (bool);
) external;

function retrieveHoldData(bytes32 holdId) external view returns (ERC20HoldData memory);

Expand Down
3 changes: 2 additions & 1 deletion contracts/interface/IHoldableERC1400TokenExtension.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./HoldStatusCode.sol";
Expand All @@ -8,7 +9,7 @@ interface IHoldableERC1400TokenExtension {
bytes32 holdId,
uint256 value,
bytes32 lockPreimage
) external returns (bool);
) external;

function retrieveHoldData(address token, bytes32 holdId) external view returns (
bytes32 partition,
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/AllowlistMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// MOCK CONTRACT TO REACH FULL COVERAGE BY CALLING "onlyNotAllowlisted" MODIFIER
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/BlocklistMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// MOCK CONTRACT TO REACH FULL COVERAGE BY CALLING "onlyNotBlocklisted" MODIFIER
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/CertificateSignerMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// MOCK CONTRACT TO REACH FULL COVERAGE BY CALLING "onlyNotPausered" MODIFIER
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/Clock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// MOCK CONTRACT TO RETRIEVE TIME ON CHAIN
Expand Down
4 changes: 3 additions & 1 deletion contracts/mocks/ERC1400TokensRecipientMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../extensions/userExtensions/IERC1400TokensRecipient.sol";
Expand All @@ -24,7 +25,7 @@ contract ERC1400TokensRecipientMock is IERC1400TokensRecipient, ERC1820Implement
) // Comments to avoid compilation warnings for unused variables.
external
override
view
pure
returns(bool)
{
return(_canReceive(from, to, value, data));
Expand All @@ -42,6 +43,7 @@ contract ERC1400TokensRecipientMock is IERC1400TokensRecipient, ERC1820Implement
) // Comments to avoid compilation warnings for unused variables.
external
override
pure
{
require(_canReceive(from, to, value, data), "57"); // 0x57 invalid receiver
}
Expand Down
4 changes: 3 additions & 1 deletion contracts/mocks/ERC1400TokensSenderMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../extensions/userExtensions/IERC1400TokensSender.sol";
Expand All @@ -23,7 +24,7 @@ contract ERC1400TokensSenderMock is IERC1400TokensSender, ERC1820Implementer {
bytes calldata /*operatorData*/
) // Comments to avoid compilation warnings for unused variables.
external
view
pure
override
returns(bool)
{
Expand All @@ -41,6 +42,7 @@ contract ERC1400TokensSenderMock is IERC1400TokensSender, ERC1820Implementer {
bytes calldata /*operatorData*/
) // Comments to avoid compilation warnings for unused variables.
external
pure
override
{
require(_canTransfer(from, to, value, data), "56"); // 0x56 invalid sender
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/ERC1400TokensValidatorMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../extensions/tokenExtensions/ERC1400TokensValidator.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/FakeERC1400Mock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../ERC1400.sol";
Expand Down Expand Up @@ -35,7 +36,6 @@ contract FakeERC1400Mock is ERC1400 {
address extension,
address mockAddress
)
public
ERC1400(name, symbol, granularity, controllers, defaultPartitions)
{
if(extension != address(0)) {
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/MinterRoleMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// MOCK CONTRACT TO REACH FULL COVERAGE BY CALLING "onlyMinter" MODIFIER
Expand Down
1 change: 1 addition & 0 deletions contracts/mocks/PauserMock.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// MOCK CONTRACT TO REACH FULL COVERAGE BY CALLING "onlyNotPausered" MODIFIER
Expand Down
1 change: 1 addition & 0 deletions contracts/roles/AllowlistAdminRole.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
1 change: 1 addition & 0 deletions contracts/roles/AllowlistedRole.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
/*
* This code has not been reviewed.
* Do not use or deploy this code before reviewing it personally first.
Expand Down
Loading

0 comments on commit 6ec8de4

Please sign in to comment.