Skip to content

Commit

Permalink
Remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bingen committed Jan 26, 2024
1 parent 7fbaa4c commit 244692d
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 20 deletions.
18 changes: 8 additions & 10 deletions contracts/src/BoldToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ contract BoldToken is CheckContract, IBoldToken {
address _troveManagerAddress,
address _stabilityPoolAddress,
address _borrowerOperationsAddress
)
public
{
) {
checkContract(_troveManagerAddress);
checkContract(_stabilityPoolAddress);
checkContract(_borrowerOperationsAddress);
Expand Down Expand Up @@ -203,8 +201,8 @@ contract BoldToken is CheckContract, IBoldToken {
}
}

function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, name, version, _chainID(), address(this)));
function _buildDomainSeparator(bytes32 _typeHash, bytes32 _name, bytes32 _version) private view returns (bytes32) {
return keccak256(abi.encode(_typeHash, _name, _version, _chainID(), address(this)));
}

// --- Internal operations ---
Expand Down Expand Up @@ -284,23 +282,23 @@ contract BoldToken is CheckContract, IBoldToken {

// --- Optional functions ---

function name() external view override returns (string memory) {
function name() external pure override returns (string memory) {
return _NAME;
}

function symbol() external view override returns (string memory) {
function symbol() external pure override returns (string memory) {
return _SYMBOL;
}

function decimals() external view override returns (uint8) {
function decimals() external pure override returns (uint8) {
return _DECIMALS;
}

function version() external view override returns (string memory) {
function version() external pure override returns (string memory) {
return _VERSION;
}

function permitTypeHash() external view override returns (bytes32) {
function permitTypeHash() external pure override returns (bytes32) {
return _PERMIT_TYPEHASH;
}
}
2 changes: 1 addition & 1 deletion contracts/src/MultiTroveGetter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract MultiTroveGetter {
TroveManager public troveManager; // XXX Troves missing from ITroveManager?
ISortedTroves public sortedTroves;

constructor(TroveManager _troveManager, ISortedTroves _sortedTroves) public {
constructor(TroveManager _troveManager, ISortedTroves _sortedTroves) {
troveManager = _troveManager;
sortedTroves = _sortedTroves;
}
Expand Down
69 changes: 69 additions & 0 deletions contracts/src/OldTestContracts/BoldTokenTester.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.18;

import "../BoldToken.sol";

contract BoldTokenTester is BoldToken {

bytes32 private immutable _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

constructor(
address _troveManagerAddress,
address _stabilityPoolAddress,
address _borrowerOperationsAddress
) BoldToken(
_troveManagerAddress,
_stabilityPoolAddress,
_borrowerOperationsAddress
) {}

function unprotectedMint(address _account, uint256 _amount) external {
// No check on caller here

_mint(_account, _amount);
}

function unprotectedBurn(address _account, uint _amount) external {
// No check on caller here

_burn(_account, _amount);
}

function unprotectedSendToPool(address _sender, address _poolAddress, uint256 _amount) external {
// No check on caller here

_transfer(_sender, _poolAddress, _amount);
}

function unprotectedReturnFromPool(address _poolAddress, address _receiver, uint256 _amount ) external {
// No check on caller here

_transfer(_poolAddress, _receiver, _amount);
}

function callInternalApprove(address owner, address spender, uint256 amount) external returns (bool) {
_approve(owner, spender, amount);
return true;
}

function getChainId() external view returns (uint256 chainID) {
//return _chainID(); // it’s private
assembly {
chainID := chainid()
}
}

function getDigest(address owner, address spender, uint amount, uint nonce, uint deadline) external view returns (bytes32) {
return keccak256(abi.encodePacked(
uint16(0x1901),
domainSeparator(),
keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, amount, nonce, deadline))
)
);
}

function recoverAddress(bytes32 digest, uint8 v, bytes32 r, bytes32 s) external pure returns (address) {
return ecrecover(digest, v, r, s);
}
}
11 changes: 7 additions & 4 deletions contracts/src/TestContracts/BoldTokenTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ contract BoldTokenTester is BoldToken {
address _troveManagerAddress,
address _stabilityPoolAddress,
address _borrowerOperationsAddress
) public BoldToken(_troveManagerAddress,
_stabilityPoolAddress,
_borrowerOperationsAddress) {}

) BoldToken(
_troveManagerAddress,
_stabilityPoolAddress,
_borrowerOperationsAddress
) {}

function unprotectedMint(address _account, uint256 _amount) external {
// No check on caller here

Expand All @@ -42,6 +44,7 @@ contract BoldTokenTester is BoldToken {

function callInternalApprove(address owner, address spender, uint256 amount) external returns (bool) {
_approve(owner, spender, amount);
return true;
}

function getChainId() external view returns (uint256 chainID) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/TestContracts/FunctionCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ contract FunctionCaller {

// --- Non-view wrapper functions used for calculating gas ---

function troveManager_getCurrentICR(address _address, uint _price) external returns (uint) {
function troveManager_getCurrentICR(address _address, uint _price) external view returns (uint) {
return troveManager.getCurrentICR(_address, _price);
}

function sortedTroves_findInsertPosition(uint _NICR, address _prevId, address _nextId) external returns (address, address) {
function sortedTroves_findInsertPosition(uint _NICR, address _prevId, address _nextId) external view returns (address, address) {
return sortedTroves.findInsertPosition(_NICR, _prevId, _nextId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract TroveManagerTester is TroveManager {
}

function callGetRedemptionFee(uint _ETHDrawn) external view returns (uint) {
_getRedemptionFee(_ETHDrawn);
return _getRedemptionFee(_ETHDrawn);
}

function getActualDebtFromComposite(uint _debtVal) external pure returns (uint) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/test/TestContracts/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract BaseTest is Test {
accountsList = tempAccounts;
}

function logContractAddresses() public {
function logContractAddresses() view public {
console.log("ActivePool addr: ", address(activePool));
console.log("BorrowerOps addr: ", address(borrowerOperations));
console.log("CollSurplusPool addr: ", address(collSurplusPool));
Expand All @@ -67,4 +67,4 @@ contract BaseTest is Test {
console.log("TroveManager addr: ", address(troveManager));
console.log("BoldToken addr: ", address(boldToken));
}
}
}

0 comments on commit 244692d

Please sign in to comment.