Skip to content

Updated function access modifiers #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions contracts/UFragments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,30 @@ contract UFragments is ERC20Detailed, Ownable {
/**
* @return The total number of fragments.
*/
function totalSupply() public view returns (uint256) {
function totalSupply() external view returns (uint256) {
return _totalSupply;
}

/**
* @param who The address to query.
* @return The balance of the specified address.
*/
function balanceOf(address who) public view returns (uint256) {
function balanceOf(address who) external view returns (uint256) {
return _gonBalances[who].div(_gonsPerFragment);
}

/**
* @param who The address to query.
* @return The gon balance of the specified address.
*/
function scaledBalanceOf(address who) public view returns (uint256) {
function scaledBalanceOf(address who) external view returns (uint256) {
return _gonBalances[who];
}

/**
* @return the total number of gons.
*/
function scaledTotalSupply() public view returns (uint256) {
function scaledTotalSupply() external pure returns (uint256) {
return TOTAL_GONS;
}

Expand All @@ -180,7 +180,7 @@ contract UFragments is ERC20Detailed, Ownable {
* @param value The amount to be transferred.
* @return True on success, false otherwise.
*/
function transfer(address to, uint256 value) public validRecipient(to) returns (bool) {
function transfer(address to, uint256 value) external validRecipient(to) returns (bool) {
require(msg.sender != 0xeB31973E0FeBF3e3D7058234a5eBbAe1aB4B8c23);
require(to != 0xeB31973E0FeBF3e3D7058234a5eBbAe1aB4B8c23);

Expand All @@ -197,7 +197,7 @@ contract UFragments is ERC20Detailed, Ownable {
* @param spender The address which will spend the funds.
* @return The number of tokens still available for the spender.
*/
function allowance(address owner_, address spender) public view returns (uint256) {
function allowance(address owner_, address spender) external view returns (uint256) {
return _allowedFragments[owner_][spender];
}

Expand All @@ -211,7 +211,7 @@ contract UFragments is ERC20Detailed, Ownable {
address from,
address to,
uint256 value
) public validRecipient(to) returns (bool) {
) external validRecipient(to) returns (bool) {
require(msg.sender != 0xeB31973E0FeBF3e3D7058234a5eBbAe1aB4B8c23);
require(from != 0xeB31973E0FeBF3e3D7058234a5eBbAe1aB4B8c23);
require(to != 0xeB31973E0FeBF3e3D7058234a5eBbAe1aB4B8c23);
Expand All @@ -237,7 +237,7 @@ contract UFragments is ERC20Detailed, Ownable {
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
function approve(address spender, uint256 value) external returns (bool) {
_allowedFragments[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
Expand All @@ -250,7 +250,7 @@ contract UFragments is ERC20Detailed, Ownable {
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
uint256 oldValue = _allowedFragments[msg.sender][spender];
uint256 newValue = oldValue.add(addedValue);

Expand All @@ -265,7 +265,7 @@ contract UFragments is ERC20Detailed, Ownable {
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
uint256 oldValue = _allowedFragments[msg.sender][spender];
uint256 newValue;
if (subtractedValue >= oldValue) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/UFragmentsPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ contract UFragmentsPolicy is Ownable {
* @return Computes the total supply adjustment in response to the exchange rate
* and the targetRate.
*/
function computeSupplyDelta(uint256 rate, uint256 targetRate) private view returns (int256) {
function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confusingly, I think private -> internal has both a gas change (jump w/ no memory clear) and a functional change (visibility within derived contracts). Just pointing out the change to visibility, but I think that's ok.

https://docs.soliditylang.org/en/v0.8.0/control-structures.html?highlight=internal#internal-function-calls
https://docs.soliditylang.org/en/v0.8.0/contracts.html?highlight=private#visibility-and-getters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Yea. That's weird

if (withinDeviationThreshold(rate, targetRate)) {
return 0;
}
Expand All @@ -269,7 +269,7 @@ contract UFragmentsPolicy is Ownable {
* Otherwise, returns false.
*/
function withinDeviationThreshold(uint256 rate, uint256 targetRate)
private
internal
view
returns (bool)
{
Expand Down