fix: removing warnings (pt. 1) (#341)

This commit is contained in:
Richard Ramos 2019-07-02 15:14:46 -04:00 committed by GitHub
parent ac289bf0b0
commit d81ab596ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 53 deletions

View File

@ -54,7 +54,7 @@ contract Ownable {
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
function renounceOwnership() external onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
@ -63,7 +63,7 @@ contract Ownable {
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
function transferOwnership(address newOwner) external onlyOwner {
_transferOwnership(newOwner);
}

View File

@ -23,13 +23,13 @@ contract Pausable is Ownable {
_;
}
function pause() public onlyOwner whenNotPaused {
function pause() external onlyOwner whenNotPaused {
paused = true;
emit Paused();
}
function unpause() public onlyOwner whenPaused {
function unpause() external onlyOwner whenPaused {
paused = false;
emit Unpaused();
}

View File

@ -63,7 +63,7 @@ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferProxyOwnership(address newOwner) public onlyProxyOwner {
function transferProxyOwnership(address newOwner) external onlyProxyOwner {
require(newOwner != address(0), "Invalid newOwner");
emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
setUpgradeabilityOwner(newOwner);
@ -73,7 +73,7 @@ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
* @dev Allows the proxy owner to upgrade the current version of the proxy.
* @param implementation representing the address of the new implementation to be set.
*/
function upgradeTo(address implementation) public onlyProxyOwner {
function upgradeTo(address implementation) external onlyProxyOwner {
_upgradeTo(implementation);
}
@ -84,8 +84,8 @@ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
* @param data represents the msg.data to bet sent in the low level call. This parameter may include the function
* signature of the implementation to be called with the needed payload
*/
function upgradeToAndCall(address implementation, bytes memory data) public payable onlyProxyOwner {
upgradeTo(implementation);
function upgradeToAndCall(address implementation, bytes calldata data) external payable onlyProxyOwner {
_upgradeTo(implementation);
(bool success,) = implementation.delegatecall(data);
require(success, "Upgrade failed");
}

View File

@ -62,7 +62,7 @@ contract Arbitrable {
* @notice Cancel arbitration
* @param _escrowId Escrow to cancel
*/
function cancelArbitration(uint _escrowId) public {
function cancelArbitration(uint _escrowId) external {
require(arbitrationCases[_escrowId].openBy == msg.sender, "Arbitration can only be canceled by the opener");
require(arbitrationCases[_escrowId].result == ArbitrationResult.UNSOLVED && arbitrationCases[_escrowId].open,
"Arbitration already solved or not open");
@ -92,7 +92,7 @@ contract Arbitrable {
* @param _escrowId Id of the escrow
* @param _result Result of the arbitration
*/
function setArbitrationResult(uint _escrowId, ArbitrationResult _result) public {
function setArbitrationResult(uint _escrowId, ArbitrationResult _result) external {
require(arbitrationCases[_escrowId].open && arbitrationCases[_escrowId].result == ArbitrationResult.UNSOLVED,
"Case must be open and unsolved");
require(_result != ArbitrationResult.UNSOLVED, "Arbitration does not have result");

View File

@ -45,6 +45,7 @@ contract Escrow is IEscrow, Pausable, MessageSigned, Fees, Arbitrable {
Arbitrable(_arbitratorLicenses)
public {
_initialized = true;
relayer = _relayer;
sellerLicenses = License(_sellerLicenses);
metadataStore = MetadataStore(_metadataStore);
}
@ -56,7 +57,7 @@ contract Escrow is IEscrow, Pausable, MessageSigned, Fees, Arbitrable {
address _metadataStore,
address payable _feeDestination,
uint _feeMilliPercent
) public {
) external {
assert(_initialized == false);
_initialized = true;
@ -71,16 +72,16 @@ contract Escrow is IEscrow, Pausable, MessageSigned, Fees, Arbitrable {
_setOwner(msg.sender);
}
function setRelayer(address _relayer) public onlyOwner {
function setRelayer(address _relayer) external onlyOwner {
relayer = _relayer;
}
function setLicenses(address _sellerLicenses, address _arbitratorLicenses) public onlyOwner {
function setLicenses(address _sellerLicenses, address _arbitratorLicenses) external onlyOwner {
sellerLicenses = License(_sellerLicenses);
arbitratorLicenses = License(_arbitratorLicenses);
}
function setMetadataStore(address _metadataStore) public onlyOwner {
function setMetadataStore(address _metadataStore) external onlyOwner {
metadataStore = MetadataStore(_metadataStore);
}
@ -145,7 +146,7 @@ contract Escrow is IEscrow, Pausable, MessageSigned, Fees, Arbitrable {
uint _tokenAmount,
uint _assetPrice
) internal whenNotPaused returns(uint escrowId) {
address payable seller;
address payable arbitrator;
bool deleted;

View File

@ -47,7 +47,7 @@ contract EscrowRelay is RelayRecipient, Ownable {
* @dev Only contract owner can execute this function
* @param _metadataStore New metadata store address
*/
function setMetadataStore(address _metadataStore) public onlyOwner {
function setMetadataStore(address _metadataStore) external onlyOwner {
metadataStore = MetadataStore(_metadataStore);
}
@ -56,7 +56,7 @@ contract EscrowRelay is RelayRecipient, Ownable {
* @dev Only contract owner can execute this function
* @param _escrow New escrow address
*/
function setEscrow(address _escrow) public onlyOwner {
function setEscrow(address _escrow) external onlyOwner {
escrow = IEscrow(_escrow);
}
@ -65,7 +65,7 @@ contract EscrowRelay is RelayRecipient, Ownable {
* @dev Only contract owner can execute this function
* @param _relayHub New relay hub address
*/
function setRelayHubAddress(address _relayHub) public onlyOwner {
function setRelayHubAddress(address _relayHub) external onlyOwner {
set_relay_hub(RelayHub(_relayHub));
}
@ -74,7 +74,7 @@ contract EscrowRelay is RelayRecipient, Ownable {
* @param _account Account to verify
* @return bool
*/
function canCreateOrCancel(address _account) public view returns(bool) {
function canCreateOrCancel(address _account) external view returns(bool) {
return (lastActivity[_account] + 15 minutes) < block.timestamp;
}
@ -100,7 +100,7 @@ contract EscrowRelay is RelayRecipient, Ownable {
bytes memory _signature
) public returns (uint escrowId) {
lastActivity[get_sender()] = block.timestamp;
return escrow.create(
escrowId = escrow.create(
_offerId,
_tokenAmount,
_assetPrice,

View File

@ -33,7 +33,7 @@ contract Fees is Ownable {
* @dev Can only be called by the owner of the contract
* TODO: if the contract will be changed to remove ownership, remove this function
*/
function setFeeDestinationAddress(address payable _addr) public onlyOwner {
function setFeeDestinationAddress(address payable _addr) external onlyOwner {
feeDestination = _addr;
emit FeeDestinationChanged(_addr);
}
@ -44,7 +44,7 @@ contract Fees is Ownable {
* @dev Can only be called by the owner of the contract
* TODO: if the contract will be changed to remove ownership, remove this function
*/
function setFeeAmount(uint _feeMilliPercent) public onlyOwner {
function setFeeAmount(uint _feeMilliPercent) external onlyOwner {
feeMilliPercent = _feeMilliPercent;
emit FeeMilliPercentChanged(_feeMilliPercent);
}

View File

@ -43,7 +43,7 @@ contract License is Ownable, ApproveAndCallFallBack {
* @param _address The address to check
* @return bool
*/
function isLicenseOwner(address _address) public view returns (bool) {
function isLicenseOwner(address _address) external view returns (bool) {
return licenseDetails[_address].price != 0 && licenseDetails[_address].creationTime != 0;
}
@ -52,7 +52,7 @@ contract License is Ownable, ApproveAndCallFallBack {
* @dev Requires value to be equal to the price of the license.
* The msg.sender must not already own a license.
*/
function buy() public {
function buy() external {
buyFrom(msg.sender);
}
@ -61,19 +61,20 @@ contract License is Ownable, ApproveAndCallFallBack {
* @dev Requires value to be equal to the price of the license.
* The _owner must not already own a license.
*/
function buyFrom(address _owner) private {
require(licenseDetails[_owner].creationTime == 0, "License already bought");
require(token.transferFrom(_owner, burnAddress, price), "Unsuccessful token transfer");
function buyFrom(address _licenseOwner) private {
require(licenseDetails[_licenseOwner].creationTime == 0, "License already bought");
licenseDetails[_owner] = LicenseDetails({
licenseDetails[_licenseOwner] = LicenseDetails({
price: price,
creationTime: block.timestamp
});
uint idx = licenseOwners.push(_owner);
idxLicenseOwners[_owner] = idx;
uint idx = licenseOwners.push(_licenseOwner);
idxLicenseOwners[_licenseOwner] = idx;
emit Bought(_owner, price);
emit Bought(_licenseOwner, price);
require(token.transferFrom(_licenseOwner, burnAddress, price), "Unsuccessful token transfer");
}
/**
@ -81,7 +82,7 @@ contract License is Ownable, ApproveAndCallFallBack {
* @param _price The new price of the license
* @dev Only the owner of the contract can perform this action
*/
function setPrice(uint256 _price) public onlyOwner {
function setPrice(uint256 _price) external onlyOwner {
price = _price;
emit PriceChanged(_price);
}
@ -90,7 +91,7 @@ contract License is Ownable, ApproveAndCallFallBack {
* @dev Get number of license owners
* @return uint
*/
function getNumLicenseOwners() public view returns (uint256) {
function getNumLicenseOwners() external view returns (uint256) {
return licenseOwners.length;
}

View File

@ -154,12 +154,12 @@ contract MetadataStore is MessageSigned {
* @return Signing user address
*/
function addOrUpdateUser(
bytes memory _signature,
bytes memory _statusContactCode,
string memory _location,
string memory _username,
bytes calldata _signature,
bytes calldata _statusContactCode,
string calldata _location,
string calldata _username,
uint _nonce
) public returns(address payable _user) {
) external returns(address payable _user) {
_user = address(uint160(_getSigner(_username, _statusContactCode, _nonce, _signature)));
require(_nonce == user_nonce[_user], "Invalid nonce");
@ -178,10 +178,10 @@ contract MetadataStore is MessageSigned {
* @return Signing user address
*/
function addOrUpdateUser(
bytes memory _statusContactCode,
string memory _location,
string memory _username
) public {
bytes calldata _statusContactCode,
string calldata _location,
string calldata _username
) external {
_addOrUpdateUser(msg.sender, _statusContactCode, _location, _username);
}
@ -215,9 +215,9 @@ contract MetadataStore is MessageSigned {
_addOrUpdateUser(msg.sender, _statusContactCode, _location, _username);
Offer memory offer = Offer(_margin, _paymentMethods, _asset, _currency, msg.sender, _arbitrator, false);
Offer memory newOffer = Offer(_margin, _paymentMethods, _asset, _currency, msg.sender, _arbitrator, false);
uint256 offerId = offers.push(offer) - 1;
uint256 offerId = offers.push(newOffer) - 1;
offerWhitelist[msg.sender][offerId] = true;
addressToOffers[msg.sender].push(offerId);
@ -230,7 +230,7 @@ contract MetadataStore is MessageSigned {
* @param _location Location on earth
* @param _username Username of the user
*/
function updateUser(bytes memory _statusContactCode, string memory _location, string memory _username) public {
function updateUser(bytes calldata _statusContactCode, string calldata _location, string calldata _username) external {
require(userWhitelist[msg.sender], "User does not exist");
User storage tmpUser = users[addressToUser[msg.sender]];
@ -246,7 +246,7 @@ contract MetadataStore is MessageSigned {
* @dev Removed offers are marked as deleted instead of being deleted
* @param _offerId Id of the offer to remove
*/
function removeOffer(uint256 _offerId) public {
function removeOffer(uint256 _offerId) external {
require(userWhitelist[msg.sender], "User does not exist");
require(offerWhitelist[msg.sender][_offerId], "Offer does not exist");
@ -261,7 +261,7 @@ contract MetadataStore is MessageSigned {
* @param _id Offer id
* @return Offer data (see Offer struct)
*/
function offer(uint256 _id) public view returns (
function offer(uint256 _id) external view returns (
address asset,
string memory currency,
int8 margin,
@ -287,7 +287,7 @@ contract MetadataStore is MessageSigned {
* @param _id Offer id
* @return Seller address
*/
function getOfferOwner(uint256 _id) public view returns (address payable) {
function getOfferOwner(uint256 _id) external view returns (address payable) {
return (offers[_id].owner);
}
@ -297,7 +297,7 @@ contract MetadataStore is MessageSigned {
* @param _id Offer id
* @return Token address used in the offer
*/
function getAsset(uint256 _id) public view returns (address) {
function getAsset(uint256 _id) external view returns (address) {
return (offers[_id].asset);
}
@ -307,7 +307,7 @@ contract MetadataStore is MessageSigned {
* @param _id Offer id
* @return Arbitrator address
*/
function getArbitrator(uint256 _id) public view returns (address payable) {
function getArbitrator(uint256 _id) external view returns (address payable) {
return (offers[_id].arbitrator);
}
@ -315,7 +315,7 @@ contract MetadataStore is MessageSigned {
* @notice Get the size of the users
* @return Number of users stored in the contract
*/
function usersSize() public view returns (uint256) {
function usersSize() external view returns (uint256) {
return users.length;
}
@ -323,7 +323,7 @@ contract MetadataStore is MessageSigned {
* @notice Get the size of the offers
* @return Number of offers stored in the contract
*/
function offersSize() public view returns (uint256) {
function offersSize() external view returns (uint256) {
return offers.length;
}
@ -332,7 +332,7 @@ contract MetadataStore is MessageSigned {
* @param _address Address of the offers
* @return Array of offer ids for a specific address
*/
function getOfferIds(address _address) public view returns (uint256[] memory) {
function getOfferIds(address _address) external view returns (uint256[] memory) {
return addressToOffers[_address];
}
}