Skip to content

Commit

Permalink
Upgrade to solidity 6.12
Browse files Browse the repository at this point in the history
  • Loading branch information
pooleja committed Nov 20, 2020
1 parent dd3c258 commit a9e691d
Show file tree
Hide file tree
Showing 75 changed files with 30,804 additions and 25,132 deletions.
937 changes: 560 additions & 377 deletions build/contracts/Address.json

Large diffs are not rendered by default.

1,983 changes: 1,096 additions & 887 deletions build/contracts/Blacklistable.json

Large diffs are not rendered by default.

1,245 changes: 662 additions & 583 deletions build/contracts/BlacklisterRole.json

Large diffs are not rendered by default.

605 changes: 323 additions & 282 deletions build/contracts/Burnable.json

Large diffs are not rendered by default.

1,221 changes: 650 additions & 571 deletions build/contracts/BurnerRole.json

Large diffs are not rendered by default.

100 changes: 57 additions & 43 deletions build/contracts/Context.json

Large diffs are not rendered by default.

383 changes: 216 additions & 167 deletions build/contracts/ERC1404.json

Large diffs are not rendered by default.

4,847 changes: 2,752 additions & 2,095 deletions build/contracts/ERC20.json

Large diffs are not rendered by default.

897 changes: 495 additions & 402 deletions build/contracts/ERC20Detailed.json

Large diffs are not rendered by default.

4,801 changes: 2,565 additions & 2,236 deletions build/contracts/Escrowable.json

Large diffs are not rendered by default.

1,307 changes: 694 additions & 613 deletions build/contracts/EscrowerRole.json

Large diffs are not rendered by default.

723 changes: 464 additions & 259 deletions build/contracts/IERC20.json

Large diffs are not rendered by default.

687 changes: 437 additions & 250 deletions build/contracts/Initializable.json

Large diffs are not rendered by default.

547 changes: 318 additions & 229 deletions build/contracts/Math.json

Large diffs are not rendered by default.

450 changes: 246 additions & 204 deletions build/contracts/Migrations.json

Large diffs are not rendered by default.

609 changes: 325 additions & 284 deletions build/contracts/Mintable.json

Large diffs are not rendered by default.

1,221 changes: 650 additions & 571 deletions build/contracts/MinterRole.json

Large diffs are not rendered by default.

1,223 changes: 654 additions & 569 deletions build/contracts/OwnerRole.json

Large diffs are not rendered by default.

835 changes: 493 additions & 342 deletions build/contracts/Pausable.json

Large diffs are not rendered by default.

1,221 changes: 650 additions & 571 deletions build/contracts/PauserRole.json

Large diffs are not rendered by default.

1,031 changes: 702 additions & 329 deletions build/contracts/Proxiable.json

Large diffs are not rendered by default.

1,151 changes: 994 additions & 157 deletions build/contracts/Proxy.json

Large diffs are not rendered by default.

585 changes: 311 additions & 274 deletions build/contracts/Revocable.json

Large diffs are not rendered by default.

2,297 changes: 0 additions & 2,297 deletions build/contracts/RevocableTo.json

This file was deleted.

645 changes: 347 additions & 298 deletions build/contracts/RevocableToAddress.json

Large diffs are not rendered by default.

1,221 changes: 650 additions & 571 deletions build/contracts/RevokerRole.json

Large diffs are not rendered by default.

729 changes: 422 additions & 307 deletions build/contracts/Roles.json

Large diffs are not rendered by default.

1,935 changes: 1,112 additions & 823 deletions build/contracts/SafeERC20.json

Large diffs are not rendered by default.

1,553 changes: 903 additions & 650 deletions build/contracts/SafeMath.json

Large diffs are not rendered by default.

3,063 changes: 1,694 additions & 1,369 deletions build/contracts/TokenSoftToken.json

Large diffs are not rendered by default.

2,569 changes: 1,398 additions & 1,171 deletions build/contracts/TokenSoftTokenEscrow.json

Large diffs are not rendered by default.

2,355 changes: 1,284 additions & 1,071 deletions build/contracts/TokenSoftTokenEscrowNotProxiable.json

Large diffs are not rendered by default.

3,436 changes: 2,378 additions & 1,058 deletions build/contracts/TokenSoftTokenV2.json

Large diffs are not rendered by default.

3,541 changes: 1,934 additions & 1,607 deletions build/contracts/Whitelistable.json

Large diffs are not rendered by default.

1,221 changes: 650 additions & 571 deletions build/contracts/WhitelisterRole.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

import "../../../upgrades/contracts/Initializable.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

/**
* @title Roles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

/**
* @dev Standard math utilities missing in the Solidity language.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

import "../../../../upgrades/contracts/Initializable.sol";

Expand Down Expand Up @@ -42,14 +42,14 @@ contract ERC20 is Initializable, Context, IERC20 {
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}

/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view returns (uint256) {
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}

Expand All @@ -61,15 +61,15 @@ contract ERC20 is Initializable, Context, IERC20 {
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}

/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}

Expand All @@ -80,7 +80,7 @@ contract ERC20 is Initializable, Context, IERC20 {
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public returns (bool) {
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
Expand All @@ -97,7 +97,7 @@ contract ERC20 is Initializable, Context, IERC20 {
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

import "../../../../upgrades/contracts/Initializable.sol";
import "./IERC20.sol";

/**
* @dev Optional functions from the ERC20 standard.
*/
contract ERC20Detailed is Initializable, IERC20 {
abstract contract ERC20Detailed is Initializable, IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity 0.6.12;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.5;
pragma solidity 0.6.12;

/**
* @dev Collection of functions related to the address type
Expand Down Expand Up @@ -64,7 +64,7 @@ library Address {
require(address(this).balance >= amount, "Address: insufficient balance");

// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call.value(amount)("");
(bool success, ) = recipient.call{value:amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
8 changes: 4 additions & 4 deletions contracts/ERC1404.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

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

contract ERC1404 is IERC20 {
abstract contract ERC1404 is IERC20 {
/// @notice Detects if a transfer will be reverted and if so returns an appropriate reference code
/// @param from Sending address
/// @param to Receiving address
/// @param value Amount of tokens being transferred
/// @return Code by which to reference message for rejection reasoning
/// @dev Overwrite with your custom transfer restriction logic
function detectTransferRestriction (address from, address to, uint256 value) public view returns (uint8);
function detectTransferRestriction (address from, address to, uint256 value) public virtual view returns (uint8);

/// @notice Returns a human-readable message for a given restriction code
/// @param restrictionCode Identifier for looking up a message
/// @return Text showing the restriction's reasoning
/// @dev Overwrite with your custom message and restrictionCode handling
function messageForTransferRestriction (uint8 restrictionCode) public view returns (string memory);
function messageForTransferRestriction (uint8 restrictionCode) public virtual view returns (string memory);
}
2 changes: 1 addition & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

contract Migrations {
address public owner;
Expand Down
15 changes: 8 additions & 7 deletions contracts/Proxy.sol
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

contract Proxy {
// Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"
uint256 constant PROXIABLE_MEM_SLOT = 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7;
// constructor(bytes memory constructData, address contractLogic) public {
constructor(address contractLogic) public {
// Verify a valid address was passed in
require(contractLogic != address(0), "Contract Logic cannot be 0x0");

// save the code address
assembly { // solium-disable-line
sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, contractLogic)
sstore(PROXIABLE_MEM_SLOT, contractLogic)
}
}

function() external payable {
fallback() external payable {
assembly { // solium-disable-line
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
let contractLogic := sload(PROXIABLE_MEM_SLOT)
let ptr := mload(0x40)
calldatacopy(ptr, 0x0, calldatasize)
let success := delegatecall(gas, contractLogic, ptr, calldatasize, 0, 0)
let retSz := returndatasize
calldatacopy(ptr, 0x0, calldatasize())
let success := delegatecall(gas(), contractLogic, ptr, calldatasize(), 0, 0)
let retSz := returndatasize()
returndatacopy(ptr, 0, retSz)
switch success
case 0 {
Expand Down
10 changes: 9 additions & 1 deletion contracts/TokenSoftToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "./capabilities/Proxiable.sol";
import "./@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";
Expand Down Expand Up @@ -50,6 +50,8 @@ contract TokenSoftToken is Proxiable, ERC20Detailed, ERC1404, OwnerRole, Whiteli
function detectTransferRestriction (address from, address to, uint256)
public
view
virtual
override
returns (uint8)
{
// Check the paused status of the contract
Expand Down Expand Up @@ -80,6 +82,8 @@ contract TokenSoftToken is Proxiable, ERC20Detailed, ERC1404, OwnerRole, Whiteli
function messageForTransferRestriction (uint8 restrictionCode)
public
view
virtual
override
returns (string memory)
{
if (restrictionCode == SUCCESS_CODE) {
Expand Down Expand Up @@ -112,6 +116,8 @@ contract TokenSoftToken is Proxiable, ERC20Detailed, ERC1404, OwnerRole, Whiteli
*/
function transfer (address to, uint256 value)
public
virtual
override(ERC20, IERC20)
notRestricted(msg.sender, to, value)
returns (bool success)
{
Expand All @@ -123,6 +129,8 @@ contract TokenSoftToken is Proxiable, ERC20Detailed, ERC1404, OwnerRole, Whiteli
*/
function transferFrom (address from, address to, uint256 value)
public
virtual
override(ERC20, IERC20)
notRestricted(from, to, value)
returns (bool success)
{
Expand Down
34 changes: 30 additions & 4 deletions contracts/TokenSoftTokenV2.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "./TokenSoftToken.sol";
import "./capabilities/Blacklistable.sol";
Expand All @@ -8,10 +8,11 @@ contract TokenSoftTokenV2 is TokenSoftToken, Blacklistable, RevocableToAddress {

// ERC1404 Error codes and messages
uint8 public constant FAILURE_BLACKLIST = 3;
string public constant FAILURE_BLACKLIST_MESSAGE = "The transfer was restricted due to blacklist configuration.";
string public constant FAILURE_BLACKLIST_MESSAGE = "Restricted due to blacklist";

function detectTransferRestriction (address from, address to, uint256 amt)
public
override
view
returns (uint8)
{
Expand All @@ -21,18 +22,43 @@ contract TokenSoftTokenV2 is TokenSoftToken, Blacklistable, RevocableToAddress {
return FAILURE_BLACKLIST;
}

return super.detectTransferRestriction(from, to, amt);
return TokenSoftToken.detectTransferRestriction(from, to, amt);
}

function messageForTransferRestriction (uint8 restrictionCode)
public
override
view
returns (string memory)
{
if (restrictionCode == FAILURE_BLACKLIST) {
return FAILURE_BLACKLIST_MESSAGE;
}

return super.messageForTransferRestriction(restrictionCode);
return TokenSoftToken.messageForTransferRestriction(restrictionCode);
}

/**
Overrides the parent class token transfer function to enforce restrictions.
*/
function transfer (address to, uint256 value)
public
override(TokenSoftToken, ERC20)
notRestricted(msg.sender, to, value)
returns (bool success)
{
return TokenSoftToken.transfer(to, value);
}

/**
Overrides the parent class token transferFrom function to enforce restrictions.
*/
function transferFrom (address from, address to, uint256 value)
public
override(TokenSoftToken, ERC20)
notRestricted(from, to, value)
returns (bool success)
{
return TokenSoftToken.transferFrom(from, to, value);
}
}
10 changes: 5 additions & 5 deletions contracts/capabilities/Blacklistable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "../roles/BlacklisterRole.sol";

Expand Down Expand Up @@ -28,10 +28,10 @@ contract Blacklistable is BlacklisterRole {
*/
function _addToBlacklist(address addressToAdd) internal {
// Verify a valid address was passed in
require(addressToAdd != address(0), "Cannot add address 0x0 to the blacklist.");
require(addressToAdd != address(0), "Cannot add 0x0");

// Verify the address is on the blacklist before it can be removed
require(!addressBlacklists[addressToAdd], "Address specified already on the black list.");
require(!addressBlacklists[addressToAdd], "Already on list");

// Set the address's white list ID
addressBlacklists[addressToAdd] = true;
Expand All @@ -45,10 +45,10 @@ contract Blacklistable is BlacklisterRole {
*/
function _removeFromBlacklist(address addressToRemove) internal {
// Verify a valid address was passed in
require(addressToRemove != address(0), "Cannot remove address 0x0 from the blacklist.");
require(addressToRemove != address(0), "Cannot remove 0x0");

// Verify the address is on the blacklist before it can be removed
require(addressBlacklists[addressToRemove], "Address specified is not on the black list.");
require(addressBlacklists[addressToRemove], "Not on list");

// Zero out the previous white list
addressBlacklists[addressToRemove] = false;
Expand Down
2 changes: 1 addition & 1 deletion contracts/capabilities/Burnable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "../@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "../roles/BurnerRole.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/capabilities/Mintable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "../@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "../roles/MinterRole.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/capabilities/Pausable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "../roles/PauserRole.sol";

Expand Down
11 changes: 6 additions & 5 deletions contracts/capabilities/Proxiable.sol
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

contract Proxiable {
// Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"
uint256 constant PROXIABLE_MEM_SLOT = 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7;

event CodeAddressUpdated(address newAddress);

function _updateCodeAddress(address newAddress) internal {
require(
bytes32(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7) == Proxiable(newAddress).proxiableUUID(),
bytes32(PROXIABLE_MEM_SLOT) == Proxiable(newAddress).proxiableUUID(),
"Not compatible"
);
assembly { // solium-disable-line
sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, newAddress)
sstore(PROXIABLE_MEM_SLOT, newAddress)
}

emit CodeAddressUpdated(newAddress);
}

function getLogicAddress() public view returns (address logicAddress) {
assembly { // solium-disable-line
logicAddress := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
logicAddress := sload(PROXIABLE_MEM_SLOT)
}
}

function proxiableUUID() public pure returns (bytes32) {
return 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7;
return bytes32(PROXIABLE_MEM_SLOT);
}
}
2 changes: 1 addition & 1 deletion contracts/capabilities/Revocable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "../@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "../roles/RevokerRole.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/capabilities/RevocableToAddress.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.5.16;
pragma solidity 0.6.12;

import "../@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "../roles/RevokerRole.sol";
Expand Down
Loading

0 comments on commit a9e691d

Please sign in to comment.