Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

refactor: solidity version update #92

Merged
merged 3 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 28 additions & 20 deletions packages/vvisp-contracts/libs/BytesLib.sol
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
pragma solidity ^0.4.24;
pragma solidity >=0.5.0 <0.6.0;


/**
* @dev https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol
*/
library BytesLib {
function slice(bytes _bytes, uint _start, uint _length) internal pure returns (bytes) {
function slice(
bytes memory _bytes,
uint _start,
uint _length
)
internal
pure
returns (bytes memory)
{
require(_bytes.length >= (_start + _length));

bytes memory tempBytes;

assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)

// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)

// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)

for {
// The multiplication in the next line has the same exact purpose
// as the one above.
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
} lt(mc, end) {
mc := add(mc, 0x20)
Expand All @@ -47,8 +55,8 @@ library BytesLib {

mstore(tempBytes, _length)

//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"upgradeable"
],
"dependencies": {
"openzeppelin-solidity": "2.0.0"
"openzeppelin-solidity": "^2.1.0"
}
}
4 changes: 2 additions & 2 deletions packages/vvisp-contracts/upgradeable/Proxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity >=0.5.0 <0.6.0;


/**
Expand All @@ -11,7 +11,7 @@ contract Proxy {
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
* This function will return whatever the implementation call returns
*/
function() payable public {
function() external payable {
address _impl = implementation();
require(_impl != address(0));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity >=0.5.0 <0.6.0;

import "./Proxy.sol";

Expand Down
27 changes: 21 additions & 6 deletions packages/vvisp-contracts/upgradeable/VvispLibraryRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity >=0.5.0 <0.6.0;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand All @@ -11,7 +11,7 @@ contract VvispLibraryRegistry is Ownable {
using BytesLib for bytes;

event ProxyCreated(address _proxy, string _name);
event UpgradeAll(address[] _proxies, address[] _implementations);
event UpgradeAll(address payable[] _proxies, address[] _implementations);
event UpgradeToAndCallData(bytes _data, uint256 _index, uint256 _length);
event SetNonUpgradeable(address _address, string _name, string _fileName);
event SetFileName(address _address, string _fileName);
Expand All @@ -34,7 +34,15 @@ contract VvispLibraryRegistry is Ownable {
mapping(address => UpgradeableSet) public upgradeableSets;
mapping(address => NonUpgradeableSet) public nonUpgradeableSets;

function setNonUpgradeables(address[] _addresses, string _names, uint256[] _nameLength, string _fileNames, uint256[] _fileNameLength) public onlyOwner {
function setNonUpgradeables(
address[] memory _addresses,
string memory _names,
uint256[] memory _nameLength,
string memory _fileNames,
uint256[] memory _fileNameLength
)
public onlyOwner
{
require(_addresses.length != 0);
require(_addresses.length == _nameLength.length);
require(_addresses.length == _fileNameLength.length);
Expand All @@ -56,7 +64,7 @@ contract VvispLibraryRegistry is Ownable {
}
}

function updateFileNames(address[] _keyAddresses, string _fileNames, uint256[] _fileNameLength) public onlyOwner {
function updateFileNames(address[] memory _keyAddresses, string memory _fileNames, uint256[] memory _fileNameLength) public onlyOwner {
require(_keyAddresses.length != 0);
require(_keyAddresses.length == _fileNameLength.length);

Expand All @@ -75,14 +83,21 @@ contract VvispLibraryRegistry is Ownable {
}
}

function createProxy(string name) public onlyOwner {
function createProxy(string memory name) public onlyOwner {
VvispProxy proxy = new VvispProxy();
upgradeableKeyAddresses.push(address(proxy));
upgradeableSets[address(proxy)].name = name;
emit ProxyCreated(address(proxy), name);
}

function upgradeToAndCalls(address[] _proxies, address[] _business, bytes _data, uint256[] _length) public onlyOwner {
function upgradeToAndCalls(
address payable[] memory _proxies,
address[] memory _business,
bytes memory _data,
uint256[] memory _length
)
public onlyOwner
{
require(_proxies.length != 0);
require(_proxies.length == _business.length);
require(_proxies.length == _length.length);
Expand Down
9 changes: 5 additions & 4 deletions packages/vvisp-contracts/upgradeable/VvispProxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity >=0.5.0 <0.6.0;

import "./UpgradeabilityProxy.sol";

Expand Down Expand Up @@ -70,10 +70,11 @@ contract VvispProxy 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 data) payable public onlyProxyOwner {
function upgradeToAndCall(address implementation, bytes memory data) public payable onlyProxyOwner {
upgradeTo(implementation);
// solium-disable-next-line security/no-call-value
require(address(this).call.value(msg.value)(data));
// solium-disable-next-line security/no-low-level-calls
(bool success, ) = implementation.delegatecall(data);
require(success);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-utils/contracts/DependencyA.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyA {
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-utils/contracts/DependencyB.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyB {
Expand Down
4 changes: 2 additions & 2 deletions packages/vvisp-utils/contracts/DependencyD.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyD {
uint[] integers;
address token;
constructor(uint[] _integers, address _token) public {
constructor(uint[] memory _integers, address _token) public {
integers = _integers;
token = _token;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-utils/contracts/ErrorContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.0;
pragma solidity >=0.5.0 <0.6.0;

contract ErrorContract {
function ErrorContract(){
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-utils/contracts/MyNFT.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity >=0.5.0 <0.6.0;

import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol';
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-utils/contracts/SecondB.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract SecondB {
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
},
"devDependencies": {
"dotenv": "^5.0.1",
"openzeppelin-solidity": "2.0.0"
"openzeppelin-solidity": "^2.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/vvisp-utils/src/compile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = async function(filePath, options) {
const DEFAULT_COMPILER_VERSION = '0.4.24';
const DEFAULT_COMPILER_VERSION = '0.5.0';

const fs = require('fs');
const path = require('path');
Expand Down
4 changes: 2 additions & 2 deletions packages/vvisp-utils/test/compile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('# compile test', function() {
await compile(files, true).should.be.fulfilled;
});
it('should be fulfilled with other solc version', async function() {
process.env.SOLC_VERSION = 'v0.4.24+commit.e67f0147';
process.env.SOLC_VERSION = 'v0.5.0+commit.1d4f565a';
await compile(RIGHT_CONTRACT1, { silent: true }).should.be.fulfilled;
});
it('should be fulfilled with nonOptimization', async function() {
Expand All @@ -56,7 +56,7 @@ describe('# compile test', function() {
process.env.SOLC_VERSION = '';
});
it('should be fulfilled with external solidity library', async function() {
process.env.SOLC_VERSION = '0.4.24';
process.env.SOLC_VERSION = '0.5.0';
await compile(OPEN_NFT, { silent: true }).should.be.fulfilled;
process.env.SOLC_VERSION = '';
});
Expand Down
14 changes: 7 additions & 7 deletions packages/vvisp/contracts/test/Attachment.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand Down Expand Up @@ -32,8 +32,8 @@ contract Attachment is Ownable {

function upsertAttachment(
bytes32 _fileHash,
string _fileType,
string _fileName,
string memory _fileType,
string memory _fileName,
uint256 _registrationDate) public onlyOwner
{
require(_fileHash != 0);
Expand All @@ -55,20 +55,20 @@ contract Attachment is Ownable {
emit RemoveAttachment(_fileHash, beforeFileTypes, beforeFileNames, beforeRegistrationDate);
}

function upsertFileType(bytes32 _fileHash, string _fileType) internal {
function upsertFileType(bytes32 _fileHash, string memory _fileType) internal {
fileTypes[_fileHash] = _fileType;
}

function removeFileType(bytes32 _fileHash) internal returns (string before) {
function removeFileType(bytes32 _fileHash) internal returns (string memory before) {
before = fileTypes[_fileHash];
delete fileTypes[_fileHash];
}

function upsertFileName(bytes32 _fileHash, string _fileName) internal {
function upsertFileName(bytes32 _fileHash, string memory _fileName) internal {
fileNames[_fileHash] = _fileName;
}

function removeFileName(bytes32 _fileHash) internal returns (string before) {
function removeFileName(bytes32 _fileHash) internal returns (string memory before) {
before = fileNames[_fileHash];
delete fileNames[_fileHash];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp/contracts/test/DependencyA.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyA {
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp/contracts/test/DependencyB.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyB {
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp/contracts/test/DependencyC.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyC {
Expand Down
4 changes: 2 additions & 2 deletions packages/vvisp/contracts/test/DependencyD.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract DependencyD {
uint[] integers;
address token;
constructor(uint[] _integers, address _token) public {
constructor(uint[] memory _integers, address _token) public {
integers = _integers;
token = _token;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vvisp/contracts/test/Flattened.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.23;
pragma solidity >=0.5.0 <0.6.0;


contract Foo {
Expand Down
Loading