Added default data locations to docs and other external tests.

This commit is contained in:
Chase McDermott 2018-07-14 16:42:01 -05:00
parent 31e56f9f99
commit 3267adcd14
32 changed files with 104 additions and 105 deletions

View File

@ -193,9 +193,9 @@ Given the contract:
pragma solidity ^0.4.16; pragma solidity ^0.4.16;
contract Foo { contract Foo {
function bar(bytes3[2]) public pure {} function bar(bytes3[2] memory) public pure {}
function baz(uint32 x, bool y) public pure returns (bool r) { r = x > 32 || y; } function baz(uint32 x, bool y) public pure returns (bool r) { r = x > 32 || y; }
function sam(bytes, bool, uint[]) public pure {} function sam(bytes memory, bool, uint[] memory) public pure {}
} }
@ -490,8 +490,8 @@ As an example, the code
contract Test { contract Test {
struct S { uint a; uint[] b; T[] c; } struct S { uint a; uint[] b; T[] c; }
struct T { uint x; uint y; } struct T { uint x; uint y; }
function f(S s, T t, uint a) public { } function f(S memory s, T memory t, uint a) public { }
function g() public returns (S s, T t, uint a) {} function g() public returns (S memory s, T memory t, uint a) {}
} }
would result in the JSON: would result in the JSON:

View File

@ -54,7 +54,7 @@ idea is that assembly libraries will be used to enhance the language in such way
pragma solidity ^0.4.0; pragma solidity ^0.4.0;
library GetCode { library GetCode {
function at(address _addr) public view returns (bytes o_code) { function at(address _addr) public view returns (bytes memory o_code) {
assembly { assembly {
// retrieve the size of the code, this needs assembly // retrieve the size of the code, this needs assembly
let size := extcodesize(_addr) let size := extcodesize(_addr)
@ -83,7 +83,7 @@ you really know what you are doing.
library VectorSum { library VectorSum {
// This function is less efficient because the optimizer currently fails to // This function is less efficient because the optimizer currently fails to
// remove the bounds checks in array access. // remove the bounds checks in array access.
function sumSolidity(uint[] _data) public view returns (uint o_sum) { function sumSolidity(uint[] memory _data) public view returns (uint o_sum) {
for (uint i = 0; i < _data.length; ++i) for (uint i = 0; i < _data.length; ++i)
o_sum += _data[i]; o_sum += _data[i];
} }
@ -91,7 +91,7 @@ you really know what you are doing.
// We know that we only access the array in bounds, so we can avoid the check. // We know that we only access the array in bounds, so we can avoid the check.
// 0x20 needs to be added to an array because the first slot contains the // 0x20 needs to be added to an array because the first slot contains the
// array length. // array length.
function sumAsm(uint[] _data) public view returns (uint o_sum) { function sumAsm(uint[] memory _data) public view returns (uint o_sum) {
for (uint i = 0; i < _data.length; ++i) { for (uint i = 0; i < _data.length; ++i) {
assembly { assembly {
o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20)))) o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))
@ -100,7 +100,7 @@ you really know what you are doing.
} }
// Same as above, but accomplish the entire code within inline assembly. // Same as above, but accomplish the entire code within inline assembly.
function sumPureAsm(uint[] _data) public view returns (uint o_sum) { function sumPureAsm(uint[] memory _data) public view returns (uint o_sum) {
assembly { assembly {
// Load the length (first 32 bytes) // Load the length (first 32 bytes)
let len := mload(_data) let len := mload(_data)

View File

@ -1295,12 +1295,12 @@ custom types without the overhead of external function calls:
uint[] limbs; uint[] limbs;
} }
function fromUint(uint x) internal pure returns (bigint r) { function fromUint(uint x) internal pure returns (bigint memory r) {
r.limbs = new uint[](1); r.limbs = new uint[](1);
r.limbs[0] = x; r.limbs[0] = x;
} }
function add(bigint _a, bigint _b) internal pure returns (bigint r) { function add(bigint memory _a, bigint memory _b) internal pure returns (bigint memory r) {
r.limbs = new uint[](max(_a.limbs.length, _b.limbs.length)); r.limbs = new uint[](max(_a.limbs.length, _b.limbs.length));
uint carry = 0; uint carry = 0;
for (uint i = 0; i < r.limbs.length; ++i) { for (uint i = 0; i < r.limbs.length; ++i) {
@ -1323,7 +1323,7 @@ custom types without the overhead of external function calls:
} }
} }
function limb(bigint _a, uint _limb) internal pure returns (uint) { function limb(bigint memory _a, uint _limb) internal pure returns (uint) {
return _limb < _a.limbs.length ? _a.limbs[_limb] : 0; return _limb < _a.limbs.length ? _a.limbs[_limb] : 0;
} }

View File

@ -85,7 +85,7 @@ Example::
pragma solidity ^0.4.16; pragma solidity ^0.4.16;
contract C { contract C {
function f() public pure returns (uint8[5]) { function f() public pure returns (uint8[5] memory) {
string[4] memory adaArr = ["This", "is", "an", "array"]; string[4] memory adaArr = ["This", "is", "an", "array"];
return ([1, 2, 3, 4, 5]); return ([1, 2, 3, 4, 5]);
} }
@ -445,7 +445,7 @@ independent copies will be created::
h(x); h(x);
} }
function g(uint[20] y) internal pure { function g(uint[20] memory y) internal pure {
y[2] = 3; y[2] = 3;
} }
@ -455,10 +455,9 @@ independent copies will be created::
} }
The call to ``g(x)`` will not have an effect on ``x`` because it needs The call to ``g(x)`` will not have an effect on ``x`` because it needs
to create an independent copy of the storage value in memory to create an independent copy of the storage value in memory.
(the default storage location is memory). On the other hand, On the other hand, ``h(x)`` successfully modifies ``x`` because only
``h(x)`` successfully modifies ``x`` because only a reference a reference and not a copy is passed.
and not a copy is passed.
Sometimes, when I try to change the length of an array with ex: ``arrayname.length = 7;`` I get a compiler error ``Value must be an lvalue``. Why? Sometimes, when I try to change the length of an array with ex: ``arrayname.length = 7;`` I get a compiler error ``Value must be an lvalue``. Why?
================================================================================================================================================== ==================================================================================================================================================

View File

@ -66,7 +66,7 @@ of votes.
Proposal[] public proposals; Proposal[] public proposals;
/// Create a new ballot to choose one of `proposalNames`. /// Create a new ballot to choose one of `proposalNames`.
constructor(bytes32[] proposalNames) public { constructor(bytes32[] memory proposalNames) public {
chairperson = msg.sender; chairperson = msg.sender;
voters[chairperson].weight = 1; voters[chairperson].weight = 1;
@ -452,9 +452,9 @@ high or low invalid bids.
/// correctly blinded invalid bids and for all bids except for /// correctly blinded invalid bids and for all bids except for
/// the totally highest. /// the totally highest.
function reveal( function reveal(
uint[] _values, uint[] memory _values,
bool[] _fake, bool[] memory _fake,
bytes32[] _secret bytes32[] memory _secret
) )
public public
onlyAfter(biddingEnd) onlyAfter(biddingEnd)

View File

@ -471,11 +471,11 @@ Another example that uses external function types::
} }
Request[] requests; Request[] requests;
event NewRequest(uint); event NewRequest(uint);
function query(bytes data, function(bytes memory) external callback) public { function query(bytes memory data, function(bytes memory) external callback) public {
requests.push(Request(data, callback)); requests.push(Request(data, callback));
emit NewRequest(requests.length - 1); emit NewRequest(requests.length - 1);
} }
function reply(uint requestID, bytes response) public { function reply(uint requestID, bytes memory response) public {
// Here goes the check that the reply comes from a trusted source // Here goes the check that the reply comes from a trusted source
requests[requestID].callback(response); requests[requestID].callback(response);
} }
@ -486,7 +486,7 @@ Another example that uses external function types::
function buySomething() { function buySomething() {
oracle.query("USD", this.oracleResponse); oracle.query("USD", this.oracleResponse);
} }
function oracleResponse(bytes response) public { function oracleResponse(bytes memory response) public {
require( require(
msg.sender == address(oracle), msg.sender == address(oracle),
"Only oracle can call this." "Only oracle can call this."
@ -540,7 +540,7 @@ memory-stored reference type do not create a copy.
uint[] x; // the data location of x is storage uint[] x; // the data location of x is storage
// the data location of memoryArray is memory // the data location of memoryArray is memory
function f(uint[] memoryArray) public { function f(uint[] memory memoryArray) public {
x = memoryArray; // works, copies the whole array to storage x = memoryArray; // works, copies the whole array to storage
uint[] storage y = x; // works, assigns a pointer, data location of y is storage uint[] storage y = x; // works, assigns a pointer, data location of y is storage
y[7]; // fine, returns the 8th element y[7]; // fine, returns the 8th element
@ -557,7 +557,7 @@ memory-stored reference type do not create a copy.
} }
function g(uint[] storage storageArray) internal {} function g(uint[] storage storageArray) internal {}
function h(uint[] memoryArray) public {} function h(uint[] memory memoryArray) public {}
} }
Summary Summary
@ -646,7 +646,7 @@ assigned to a variable right away.
function f() public pure { function f() public pure {
g([uint(1), 2, 3]); g([uint(1), 2, 3]);
} }
function g(uint[3] _data) public pure { function g(uint[3] memory _data) public pure {
// ... // ...
} }
} }
@ -713,7 +713,7 @@ Members
bool[2][] m_pairsOfFlags; bool[2][] m_pairsOfFlags;
// newPairs is stored in memory - the default for function arguments // newPairs is stored in memory - the default for function arguments
function setAllFlagPairs(bool[2][] newPairs) public { function setAllFlagPairs(bool[2][] memory newPairs) public {
// assignment to a storage array replaces the complete array // assignment to a storage array replaces the complete array
m_pairsOfFlags = newPairs; m_pairsOfFlags = newPairs;
} }
@ -739,7 +739,7 @@ Members
bytes m_byteData; bytes m_byteData;
function byteArrays(bytes data) public { function byteArrays(bytes memory data) public {
// byte arrays ("bytes") are different as they are stored without padding, // byte arrays ("bytes") are different as they are stored without padding,
// but can be treated identical to "uint8[]" // but can be treated identical to "uint8[]"
m_byteData = data; m_byteData = data;
@ -748,11 +748,11 @@ Members
delete m_byteData[2]; delete m_byteData[2];
} }
function addFlag(bool[2] flag) public returns (uint) { function addFlag(bool[2] memory flag) public returns (uint) {
return m_pairsOfFlags.push(flag); return m_pairsOfFlags.push(flag);
} }
function createMemoryArray(uint size) public pure returns (bytes) { function createMemoryArray(uint size) public pure returns (bytes memory) {
// Dynamic memory arrays are created using `new`: // Dynamic memory arrays are created using `new`:
uint[2][] memory arrayOfPairs = new uint[2][](size); uint[2][] memory arrayOfPairs = new uint[2][](size);
// Create a dynamic byte array: // Create a dynamic byte array:

View File

@ -103,7 +103,7 @@ contract MultiSigWallet {
/// @dev Contract constructor sets initial owners and required number of confirmations. /// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners. /// @param _owners List of initial owners.
/// @param _required Number of required confirmations. /// @param _required Number of required confirmations.
constructor(address[] _owners, uint _required) constructor(address[] memory _owners, uint _required)
public public
validRequirement(_owners.length, _required) validRequirement(_owners.length, _required)
{ {
@ -185,7 +185,7 @@ contract MultiSigWallet {
/// @param value Transaction ether value. /// @param value Transaction ether value.
/// @param data Transaction data payload. /// @param data Transaction data payload.
/// @return Returns transaction ID. /// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data) function submitTransaction(address destination, uint value, bytes memory data)
public public
returns (uint transactionId) returns (uint transactionId)
{ {
@ -261,7 +261,7 @@ contract MultiSigWallet {
/// @param value Transaction ether value. /// @param value Transaction ether value.
/// @param data Transaction data payload. /// @param data Transaction data payload.
/// @return Returns transaction ID. /// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data) function addTransaction(address destination, uint value, bytes memory data)
internal internal
notNull(destination) notNull(destination)
returns (uint transactionId) returns (uint transactionId)
@ -313,7 +313,7 @@ contract MultiSigWallet {
function getOwners() function getOwners()
public public
view view
returns (address[]) returns (address[] memory)
{ {
return owners; return owners;
} }
@ -324,7 +324,7 @@ contract MultiSigWallet {
function getConfirmations(uint transactionId) function getConfirmations(uint transactionId)
public public
view view
returns (address[] _confirmations) returns (address[] memory _confirmations)
{ {
address[] memory confirmationsTemp = new address[](owners.length); address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0; uint count = 0;
@ -348,7 +348,7 @@ contract MultiSigWallet {
function getTransactionIds(uint from, uint to, bool pending, bool executed) function getTransactionIds(uint from, uint to, bool pending, bool executed)
public public
view view
returns (uint[] _transactionIds) returns (uint[] memory _transactionIds)
{ {
uint[] memory transactionIdsTemp = new uint[](transactionCount); uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0; uint count = 0;

View File

@ -11,7 +11,7 @@ contract MultiSigWalletFactory is Factory {
/// @param _owners List of initial owners. /// @param _owners List of initial owners.
/// @param _required Number of required confirmations. /// @param _required Number of required confirmations.
/// @return Returns wallet address. /// @return Returns wallet address.
function create(address[] _owners, uint _required) function create(address[] memory _owners, uint _required)
public public
returns (address wallet) returns (address wallet)
{ {

View File

@ -19,7 +19,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet {
/// @param _owners List of initial owners. /// @param _owners List of initial owners.
/// @param _required Number of required confirmations. /// @param _required Number of required confirmations.
/// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis.
constructor(address[] _owners, uint _required, uint _dailyLimit) constructor(address[] memory _owners, uint _required, uint _dailyLimit)
public public
MultiSigWallet(_owners, _required) MultiSigWallet(_owners, _required)
{ {

View File

@ -12,7 +12,7 @@ contract MultiSigWalletWithDailyLimitFactory is Factory {
/// @param _required Number of required confirmations. /// @param _required Number of required confirmations.
/// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis.
/// @return Returns wallet address. /// @return Returns wallet address.
function create(address[] _owners, uint _required, uint _dailyLimit) function create(address[] memory _owners, uint _required, uint _dailyLimit)
public public
returns (address wallet) returns (address wallet)
{ {

View File

@ -50,7 +50,7 @@ contract ico is safeMath {
uint256 public totalMint; uint256 public totalMint;
uint256 public totalPremiumMint; uint256 public totalPremiumMint;
constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] genesisAddr, uint256[] genesisValue) public { constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public {
/* /*
Installation function. Installation function.

View File

@ -36,7 +36,7 @@ contract moduleHandler is multiOwner, announcementTypes {
uint256 debugModeUntil = block.number + 1000000; uint256 debugModeUntil = block.number + 1000000;
constructor(address[] newOwners) multiOwner(newOwners) public {} constructor(address[] memory newOwners) multiOwner(newOwners) public {}
function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) public { function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) public {
/* /*
Loading modulest to ModuleHandler. Loading modulest to ModuleHandler.
@ -60,7 +60,7 @@ contract moduleHandler is multiOwner, announcementTypes {
addModule( modules_s(Schelling, keccak256('Schelling'), false, true), ! forReplace); addModule( modules_s(Schelling, keccak256('Schelling'), false, true), ! forReplace);
addModule( modules_s(Provider, keccak256('Provider'), true, true), ! forReplace); addModule( modules_s(Provider, keccak256('Provider'), true, true), ! forReplace);
} }
function addModule(modules_s input, bool call) internal { function addModule(modules_s memory input, bool call) internal {
/* /*
Inside function for registration of the modules in the database. Inside function for registration of the modules in the database.
If the call is false, won't happen any direct call. If the call is false, won't happen any direct call.
@ -81,7 +81,7 @@ contract moduleHandler is multiOwner, announcementTypes {
} }
modules[id] = input; modules[id] = input;
} }
function getModuleAddressByName(string name) public view returns( bool success, bool found, address addr ) { function getModuleAddressByName(string memory name) public view returns( bool success, bool found, address addr ) {
/* /*
Search by name for module. The result is an Ethereum address. Search by name for module. The result is an Ethereum address.
@ -109,7 +109,7 @@ contract moduleHandler is multiOwner, announcementTypes {
} }
return (true, false, 0); return (true, false, 0);
} }
function getModuleIDByName(string name) public view returns( bool success, bool found, uint256 id ) { function getModuleIDByName(string memory name) public view returns( bool success, bool found, uint256 id ) {
/* /*
Search by name for module. The result is an index array. Search by name for module. The result is an index array.

View File

@ -12,7 +12,7 @@ contract multiOwner is safeMath {
/* /*
Constructor Constructor
*/ */
constructor(address[] newOwners) public { constructor(address[] memory newOwners) public {
for ( uint256 a=0 ; a<newOwners.length ; a++ ) { for ( uint256 a=0 ; a<newOwners.length ; a++ ) {
_addOwner(newOwners[a]); _addOwner(newOwners[a]);
} }
@ -41,7 +41,7 @@ contract multiOwner is safeMath {
function ownersForChange() public view returns (uint256 owners) { function ownersForChange() public view returns (uint256 owners) {
return ownerCount * 75 / 100; return ownerCount * 75 / 100;
} }
function calcDoHash(string job, bytes32 data) public pure returns (bytes32 hash) { function calcDoHash(string memory job, bytes32 data) public pure returns (bytes32 hash) {
return keccak256(abi.encodePacked(job, data)); return keccak256(abi.encodePacked(job, data));
} }
function validDoHash(bytes32 doHash) public view returns (bool valid) { function validDoHash(bytes32 doHash) public view returns (bool valid) {

View File

@ -40,7 +40,7 @@ contract premium is module, safeMath {
mapping(address => bool) public genesis; mapping(address => bool) public genesis;
constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] genesisAddr, uint256[] genesisValue) public { constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) public {
/* /*
Setup function. Setup function.
If an ICOaddress is defined then the balance of the genesis addresses will be set as well. If an ICOaddress is defined then the balance of the genesis addresses will be set as well.
@ -246,7 +246,7 @@ contract premium is module, safeMath {
return true; return true;
} }
function transferToContract(address from, address to, uint256 amount, bytes extraData) internal { function transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal {
/* /*
Inner function in order to transact a contract. Inner function in order to transact a contract.

View File

@ -299,7 +299,7 @@ contract provider is module, safeMath, announcementTypes {
providers[addr].data[currHeight].currentRate = rate; providers[addr].data[currHeight].currentRate = rate;
emit EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin); emit EProviderDetailsChanged(addr, currHeight, website, country, info, rate, admin);
} }
function getProviderInfo(address addr, uint256 height) public view returns (string name, string website, string country, string info, uint256 create) { function getProviderInfo(address addr, uint256 height) public view returns (string memory name, string memory website, string memory country, string memory info, uint256 create) {
/* /*
for the infos of the provider. for the infos of the provider.
In case the height is unknown then the system will use the last known height. In case the height is unknown then the system will use the last known height.

View File

@ -70,7 +70,7 @@ contract publisher is announcementTypes, module, safeMath {
super.registerModuleHandler(moduleHandler); super.registerModuleHandler(moduleHandler);
} }
function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string Announcement, string Link, bool Opposited, string _str, uint256 _uint, address _addr) { function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string memory Announcement, string memory Link, bool Opposited, string memory _str, uint256 _uint, address _addr) {
/* /*
Announcement data query Announcement data query

View File

@ -174,7 +174,7 @@ contract schelling is module, announcementTypes, schellingVars {
function setFunds(address addr, uint256 amount) internal { function setFunds(address addr, uint256 amount) internal {
require( db.setFunds(addr, amount) ); require( db.setFunds(addr, amount) );
} }
function setVoter(address owner, _voter voter) internal { function setVoter(address owner, _voter memory voter) internal {
require( db.setVoter(owner, require( db.setVoter(owner,
voter.roundID, voter.roundID,
voter.hash, voter.hash,
@ -183,12 +183,12 @@ contract schelling is module, announcementTypes, schellingVars {
voter.rewards voter.rewards
) ); ) );
} }
function getVoter(address addr) internal view returns (_voter) { function getVoter(address addr) internal view returns (_voter memory) {
(bool a, uint256 b, bytes32 c, schellingVars.voterStatus d, bool e, uint256 f) = db.getVoter(addr); (bool a, uint256 b, bytes32 c, schellingVars.voterStatus d, bool e, uint256 f) = db.getVoter(addr);
require( a ); require( a );
return _voter(b, c, d, e, f); return _voter(b, c, d, e, f);
} }
function setRound(uint256 id, _rounds round) internal { function setRound(uint256 id, _rounds memory round) internal {
require( db.setRound(id, require( db.setRound(id,
round.totalAboveWeight, round.totalAboveWeight,
round.totalBelowWeight, round.totalBelowWeight,
@ -197,7 +197,7 @@ contract schelling is module, announcementTypes, schellingVars {
round.voted round.voted
) ); ) );
} }
function pushRound(_rounds round) internal returns (uint256) { function pushRound(_rounds memory round) internal returns (uint256) {
(bool a, uint256 b) = db.pushRound( (bool a, uint256 b) = db.pushRound(
round.totalAboveWeight, round.totalAboveWeight,
round.totalBelowWeight, round.totalBelowWeight,
@ -208,7 +208,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( a ); require( a );
return b; return b;
} }
function getRound(uint256 id) internal returns (_rounds) { function getRound(uint256 id) internal returns (_rounds memory) {
(bool a, uint256 b, uint256 c, uint256 d, uint256 e, bool f) = db.getRound(id); (bool a, uint256 b, uint256 c, uint256 d, uint256 e, bool f) = db.getRound(id);
require( a ); require( a );
return _rounds(b, c, d, e, f); return _rounds(b, c, d, e, f);
@ -529,7 +529,7 @@ contract schelling is module, announcementTypes, schellingVars {
return belowW; return belowW;
} }
} }
function isWinner(_rounds round, bool aboveVote) internal returns (bool) { function isWinner(_rounds memory round, bool aboveVote) internal returns (bool) {
/* /*
Inside function for calculating the result of the game. Inside function for calculating the result of the game.

View File

@ -48,7 +48,7 @@ contract token is safeMath, module, announcementTypes {
mapping(address => bool) public genesis; mapping(address => bool) public genesis;
constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] genesisAddr, uint256[] genesisValue) public payable { constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] memory genesisAddr, uint256[] memory genesisValue) public payable {
/* /*
Installation function Installation function
@ -288,7 +288,7 @@ contract token is safeMath, module, announcementTypes {
return true; return true;
} }
function _transferToContract(address from, address to, uint256 amount, bytes extraData) internal { function _transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal {
/* /*
Internal function to start transactions to a contract Internal function to start transactions to a contract

View File

@ -101,7 +101,7 @@ contract Event {
function getOutcomeTokens() function getOutcomeTokens()
public public
view view
returns (OutcomeToken[]) returns (OutcomeToken[] memory)
{ {
return outcomeTokens; return outcomeTokens;
} }
@ -111,7 +111,7 @@ contract Event {
function getOutcomeTokenDistribution(address owner) function getOutcomeTokenDistribution(address owner)
public public
view view
returns (uint[] outcomeTokenDistribution) returns (uint[] memory outcomeTokenDistribution)
{ {
outcomeTokenDistribution = new uint[](outcomeTokens.length); outcomeTokenDistribution = new uint[](outcomeTokens.length);
for (uint8 i = 0; i < outcomeTokenDistribution.length; i++) for (uint8 i = 0; i < outcomeTokenDistribution.length; i++)

View File

@ -108,7 +108,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @param netOutcomeTokensSold Net outcome tokens sold by market /// @param netOutcomeTokensSold Net outcome tokens sold by market
/// @param funding Initial funding for market /// @param funding Initial funding for market
/// @return Cost level /// @return Cost level
function calcCostLevel(int logN, int[] netOutcomeTokensSold, uint funding) function calcCostLevel(int logN, int[] memory netOutcomeTokensSold, uint funding)
private private
view view
returns(int costLevel) returns(int costLevel)
@ -129,7 +129,7 @@ contract LMSRMarketMaker is MarketMaker {
/// @param funding Initial funding for market /// @param funding Initial funding for market
/// @param outcomeIndex Index of exponential term to extract (for use by marginal price function) /// @param outcomeIndex Index of exponential term to extract (for use by marginal price function)
/// @return A result structure composed of the sum, the offset used, and the summand associated with the supplied index /// @return A result structure composed of the sum, the offset used, and the summand associated with the supplied index
function sumExpOffset(int logN, int[] netOutcomeTokensSold, uint funding, uint8 outcomeIndex) function sumExpOffset(int logN, int[] memory netOutcomeTokensSold, uint funding, uint8 outcomeIndex)
private private
view view
returns (uint sum, int offset, uint outcomeExpTerm) returns (uint sum, int offset, uint outcomeExpTerm)
@ -171,7 +171,7 @@ contract LMSRMarketMaker is MarketMaker {
function getNetOutcomeTokensSold(Market market) function getNetOutcomeTokensSold(Market market)
private private
view view
returns (int[] quantities) returns (int[] memory quantities)
{ {
quantities = new int[](market.eventContract().getOutcomeCount()); quantities = new int[](market.eventContract().getOutcomeCount());
for (uint8 i = 0; i < quantities.length; i++) for (uint8 i = 0; i < quantities.length; i++)

View File

@ -34,7 +34,7 @@ contract CentralizedOracle is Oracle {
*/ */
/// @dev Constructor sets owner address and IPFS hash /// @dev Constructor sets owner address and IPFS hash
/// @param _ipfsHash Hash identifying off chain event description /// @param _ipfsHash Hash identifying off chain event description
constructor(address _owner, bytes _ipfsHash) constructor(address _owner, bytes memory _ipfsHash)
public public
{ {
// Description hash cannot be null // Description hash cannot be null

View File

@ -17,7 +17,7 @@ contract CentralizedOracleFactory {
/// @dev Creates a new centralized oracle contract /// @dev Creates a new centralized oracle contract
/// @param ipfsHash Hash identifying off chain event description /// @param ipfsHash Hash identifying off chain event description
/// @return Oracle contract /// @return Oracle contract
function createCentralizedOracle(bytes ipfsHash) function createCentralizedOracle(bytes memory ipfsHash)
public public
returns (CentralizedOracle centralizedOracle) returns (CentralizedOracle centralizedOracle)
{ {

View File

@ -16,7 +16,7 @@ contract MajorityOracle is Oracle {
*/ */
/// @dev Allows to create an oracle for a majority vote based on other oracles /// @dev Allows to create an oracle for a majority vote based on other oracles
/// @param _oracles List of oracles taking part in the majority vote /// @param _oracles List of oracles taking part in the majority vote
constructor(Oracle[] _oracles) constructor(Oracle[] memory _oracles)
public public
{ {
// At least 2 oracles should be defined // At least 2 oracles should be defined

View File

@ -17,7 +17,7 @@ contract MajorityOracleFactory {
/// @dev Creates a new majority oracle contract /// @dev Creates a new majority oracle contract
/// @param oracles List of oracles taking part in the majority vote /// @param oracles List of oracles taking part in the majority vote
/// @return Oracle contract /// @return Oracle contract
function createMajorityOracle(Oracle[] oracles) function createMajorityOracle(Oracle[] memory oracles)
public public
returns (MajorityOracle majorityOracle) returns (MajorityOracle majorityOracle)
{ {

View File

@ -176,7 +176,7 @@ library Math {
/// @dev Returns maximum of an array /// @dev Returns maximum of an array
/// @param nums Numbers to look through /// @param nums Numbers to look through
/// @return Maximum number /// @return Maximum number
function max(int[] nums) function max(int[] memory nums)
public public
pure pure
returns (int max) returns (int max)

View File

@ -175,7 +175,7 @@ contract MilestoneTracker {
/// uint reviewTime /// uint reviewTime
/// address paymentSource, /// address paymentSource,
/// bytes payData, /// bytes payData,
function proposeMilestones(bytes _newMilestones function proposeMilestones(bytes memory _newMilestones
) public onlyRecipient campaignNotCanceled { ) public onlyRecipient campaignNotCanceled {
proposedMilestones = _newMilestones; proposedMilestones = _newMilestones;
changingMilestones = true; changingMilestones = true;

View File

@ -63,7 +63,7 @@ library strings {
* @param self The string to make a slice from. * @param self The string to make a slice from.
* @return A newly allocated slice containing the entire string. * @return A newly allocated slice containing the entire string.
*/ */
function toSlice(string self) internal returns (slice) { function toSlice(string memory self) internal returns (slice memory) {
uint ptr; uint ptr;
assembly { assembly {
ptr := add(self, 0x20) ptr := add(self, 0x20)
@ -109,7 +109,7 @@ library strings {
* @return A new slice containing the value of the input argument up to the * @return A new slice containing the value of the input argument up to the
* first null. * first null.
*/ */
function toSliceB32(bytes32 self) internal returns (slice ret) { function toSliceB32(bytes32 self) internal returns (slice memory ret) {
// Allocate space for `self` in memory, copy it there, and point ret at it // Allocate space for `self` in memory, copy it there, and point ret at it
assembly { assembly {
let ptr := mload(0x40) let ptr := mload(0x40)
@ -125,7 +125,7 @@ library strings {
* @param self The slice to copy. * @param self The slice to copy.
* @return A new slice containing the same data as `self`. * @return A new slice containing the same data as `self`.
*/ */
function copy(slice self) internal returns (slice) { function copy(slice memory self) internal returns (slice memory) {
return slice(self._len, self._ptr); return slice(self._len, self._ptr);
} }
@ -134,7 +134,7 @@ library strings {
* @param self The slice to copy. * @param self The slice to copy.
* @return A newly allocated string containing the slice's text. * @return A newly allocated string containing the slice's text.
*/ */
function toString(slice self) internal returns (string) { function toString(slice memory self) internal returns (string memory) {
string memory ret = new string(self._len); string memory ret = new string(self._len);
uint retptr; uint retptr;
assembly { retptr := add(ret, 32) } assembly { retptr := add(ret, 32) }
@ -151,7 +151,7 @@ library strings {
* @param self The slice to operate on. * @param self The slice to operate on.
* @return The length of the slice in runes. * @return The length of the slice in runes.
*/ */
function len(slice self) internal returns (uint) { function len(slice memory self) internal returns (uint) {
// Starting at ptr-31 means the LSB will be the byte we care about // Starting at ptr-31 means the LSB will be the byte we care about
uint ptr = self._ptr - 31; uint ptr = self._ptr - 31;
uint end = ptr + self._len; uint end = ptr + self._len;
@ -181,7 +181,7 @@ library strings {
* @param self The slice to operate on. * @param self The slice to operate on.
* @return True if the slice is empty, False otherwise. * @return True if the slice is empty, False otherwise.
*/ */
function empty(slice self) internal returns (bool) { function empty(slice memory self) internal returns (bool) {
return self._len == 0; return self._len == 0;
} }
@ -194,7 +194,7 @@ library strings {
* @param other The second slice to compare. * @param other The second slice to compare.
* @return The result of the comparison. * @return The result of the comparison.
*/ */
function compare(slice self, slice other) internal returns (int) { function compare(slice memory self, slice memory other) internal returns (int) {
uint shortest = self._len; uint shortest = self._len;
if (other._len < self._len) if (other._len < self._len)
shortest = other._len; shortest = other._len;
@ -227,7 +227,7 @@ library strings {
* @param self The second slice to compare. * @param self The second slice to compare.
* @return True if the slices are equal, false otherwise. * @return True if the slices are equal, false otherwise.
*/ */
function equals(slice self, slice other) internal returns (bool) { function equals(slice memory self, slice memory other) internal returns (bool) {
return compare(self, other) == 0; return compare(self, other) == 0;
} }
@ -238,7 +238,7 @@ library strings {
* @param rune The slice that will contain the first rune. * @param rune The slice that will contain the first rune.
* @return `rune`. * @return `rune`.
*/ */
function nextRune(slice self, slice rune) internal returns (slice) { function nextRune(slice memory self, slice memory rune) internal returns (slice memory) {
rune._ptr = self._ptr; rune._ptr = self._ptr;
if (self._len == 0) { if (self._len == 0) {
@ -280,7 +280,7 @@ library strings {
* @param self The slice to operate on. * @param self The slice to operate on.
* @return A slice containing only the first rune from `self`. * @return A slice containing only the first rune from `self`.
*/ */
function nextRune(slice self) internal returns (slice ret) { function nextRune(slice memory self) internal returns (slice memory ret) {
nextRune(self, ret); nextRune(self, ret);
} }
@ -289,7 +289,7 @@ library strings {
* @param self The slice to operate on. * @param self The slice to operate on.
* @return The number of the first codepoint in the slice. * @return The number of the first codepoint in the slice.
*/ */
function ord(slice self) internal returns (uint ret) { function ord(slice memory self) internal returns (uint ret) {
if (self._len == 0) { if (self._len == 0) {
return 0; return 0;
} }
@ -338,7 +338,7 @@ library strings {
* @param self The slice to hash. * @param self The slice to hash.
* @return The hash of the slice. * @return The hash of the slice.
*/ */
function keccak(slice self) internal returns (bytes32 ret) { function keccak(slice memory self) internal returns (bytes32 ret) {
assembly { assembly {
ret := keccak256(mload(add(self, 32)), mload(self)) ret := keccak256(mload(add(self, 32)), mload(self))
} }
@ -350,7 +350,7 @@ library strings {
* @param needle The slice to search for. * @param needle The slice to search for.
* @return True if the slice starts with the provided text, false otherwise. * @return True if the slice starts with the provided text, false otherwise.
*/ */
function startsWith(slice self, slice needle) internal returns (bool) { function startsWith(slice memory self, slice memory needle) internal returns (bool) {
if (self._len < needle._len) { if (self._len < needle._len) {
return false; return false;
} }
@ -376,7 +376,7 @@ library strings {
* @param needle The slice to search for. * @param needle The slice to search for.
* @return `self` * @return `self`
*/ */
function beyond(slice self, slice needle) internal returns (slice) { function beyond(slice memory self, slice memory needle) internal returns (slice memory) {
if (self._len < needle._len) { if (self._len < needle._len) {
return self; return self;
} }
@ -405,7 +405,7 @@ library strings {
* @param needle The slice to search for. * @param needle The slice to search for.
* @return True if the slice starts with the provided text, false otherwise. * @return True if the slice starts with the provided text, false otherwise.
*/ */
function endsWith(slice self, slice needle) internal returns (bool) { function endsWith(slice memory self, slice memory needle) internal returns (bool) {
if (self._len < needle._len) { if (self._len < needle._len) {
return false; return false;
} }
@ -433,7 +433,7 @@ library strings {
* @param needle The slice to search for. * @param needle The slice to search for.
* @return `self` * @return `self`
*/ */
function until(slice self, slice needle) internal returns (slice) { function until(slice memory self, slice memory needle) internal returns (slice memory) {
if (self._len < needle._len) { if (self._len < needle._len) {
return self; return self;
} }
@ -542,7 +542,7 @@ library strings {
* @param needle The text to search for. * @param needle The text to search for.
* @return `self`. * @return `self`.
*/ */
function find(slice self, slice needle) internal returns (slice) { function find(slice memory self, slice memory needle) internal returns (slice memory) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
self._len -= ptr - self._ptr; self._len -= ptr - self._ptr;
self._ptr = ptr; self._ptr = ptr;
@ -557,7 +557,7 @@ library strings {
* @param needle The text to search for. * @param needle The text to search for.
* @return `self`. * @return `self`.
*/ */
function rfind(slice self, slice needle) internal returns (slice) { function rfind(slice memory self, slice memory needle) internal returns (slice memory) {
uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
self._len = ptr - self._ptr; self._len = ptr - self._ptr;
return self; return self;
@ -573,7 +573,7 @@ library strings {
* @param token An output parameter to which the first token is written. * @param token An output parameter to which the first token is written.
* @return `token`. * @return `token`.
*/ */
function split(slice self, slice needle, slice token) internal returns (slice) { function split(slice memory self, slice memory needle, slice memory token) internal returns (slice memory) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
token._ptr = self._ptr; token._ptr = self._ptr;
token._len = ptr - self._ptr; token._len = ptr - self._ptr;
@ -596,7 +596,7 @@ library strings {
* @param needle The text to search for in `self`. * @param needle The text to search for in `self`.
* @return The part of `self` up to the first occurrence of `delim`. * @return The part of `self` up to the first occurrence of `delim`.
*/ */
function split(slice self, slice needle) internal returns (slice token) { function split(slice memory self, slice memory needle) internal returns (slice memory token) {
split(self, needle, token); split(self, needle, token);
} }
@ -610,7 +610,7 @@ library strings {
* @param token An output parameter to which the first token is written. * @param token An output parameter to which the first token is written.
* @return `token`. * @return `token`.
*/ */
function rsplit(slice self, slice needle, slice token) internal returns (slice) { function rsplit(slice memory self, slice memory needle, slice memory token) internal returns (slice memory) {
uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
token._ptr = ptr; token._ptr = ptr;
token._len = self._len - (ptr - self._ptr); token._len = self._len - (ptr - self._ptr);
@ -632,7 +632,7 @@ library strings {
* @param needle The text to search for in `self`. * @param needle The text to search for in `self`.
* @return The part of `self` after the last occurrence of `delim`. * @return The part of `self` after the last occurrence of `delim`.
*/ */
function rsplit(slice self, slice needle) internal returns (slice token) { function rsplit(slice memory self, slice memory needle) internal returns (slice memory token) {
rsplit(self, needle, token); rsplit(self, needle, token);
} }
@ -642,7 +642,7 @@ library strings {
* @param needle The text to search for in `self`. * @param needle The text to search for in `self`.
* @return The number of occurrences of `needle` found in `self`. * @return The number of occurrences of `needle` found in `self`.
*/ */
function count(slice self, slice needle) internal returns (uint count) { function count(slice memory self, slice memory needle) internal returns (uint count) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;
while (ptr <= self._ptr + self._len) { while (ptr <= self._ptr + self._len) {
count++; count++;
@ -656,7 +656,7 @@ library strings {
* @param needle The text to search for in `self`. * @param needle The text to search for in `self`.
* @return True if `needle` is found in `self`, false otherwise. * @return True if `needle` is found in `self`, false otherwise.
*/ */
function contains(slice self, slice needle) internal returns (bool) { function contains(slice memory self, slice memory needle) internal returns (bool) {
return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
} }
@ -667,7 +667,7 @@ library strings {
* @param other The second slice to concatenate. * @param other The second slice to concatenate.
* @return The concatenation of the two strings. * @return The concatenation of the two strings.
*/ */
function concat(slice self, slice other) internal returns (string) { function concat(slice memory self, slice memory other) internal returns (string memory) {
string memory ret = new string(self._len + other._len); string memory ret = new string(self._len + other._len);
uint retptr; uint retptr;
assembly { retptr := add(ret, 32) } assembly { retptr := add(ret, 32) }
@ -684,7 +684,7 @@ library strings {
* @return A newly allocated string containing all the slices in `parts`, * @return A newly allocated string containing all the slices in `parts`,
* joined with `self`. * joined with `self`.
*/ */
function join(slice self, slice[] parts) internal returns (string) { function join(slice memory self, slice[] memory parts) internal returns (string memory) {
if (parts.length == 0) if (parts.length == 0)
return ""; return "";

View File

@ -25,7 +25,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
* @param _owners A list of owners. * @param _owners A list of owners.
* @param _required The amount required for a transaction to be approved. * @param _required The amount required for a transaction to be approved.
*/ */
constructor(address[] _owners, uint256 _required, uint256 _daylimit) constructor(address[] memory _owners, uint256 _required, uint256 _daylimit)
Shareable(_owners, _required) Shareable(_owners, _required)
DayLimit(_daylimit) public { } DayLimit(_daylimit) public { }

View File

@ -21,7 +21,7 @@ contract TokenDestructible is Ownable {
* @notice The called token contracts could try to re-enter this contract. Only * @notice The called token contracts could try to re-enter this contract. Only
supply token contracts you trust. supply token contracts you trust.
*/ */
function destroy(address[] tokens) public onlyOwner { function destroy(address[] memory tokens) public onlyOwner {
// Transfer tokens to owner // Transfer tokens to owner
for(uint256 i = 0; i < tokens.length; i++) { for(uint256 i = 0; i < tokens.length; i++) {

View File

@ -15,7 +15,7 @@ contract Contactable is Ownable{
* @dev Allows the owner to set a string with their contact information. * @dev Allows the owner to set a string with their contact information.
* @param info The contact information to attach to the contract. * @param info The contact information to attach to the contract.
*/ */
function setContactInformation(string info) public onlyOwner{ function setContactInformation(string memory info) public onlyOwner{
contactInformation = info; contactInformation = info;
} }
} }

View File

@ -59,7 +59,7 @@ contract Shareable {
* @param _owners A list of owners. * @param _owners A list of owners.
* @param _required The amount required for a transaction to be approved. * @param _required The amount required for a transaction to be approved.
*/ */
constructor(address[] _owners, uint256 _required) public { constructor(address[] memory _owners, uint256 _required) public {
owners[1] = msg.sender; owners[1] = msg.sender;
ownerIndex[msg.sender] = 1; ownerIndex[msg.sender] = 1;
for (uint256 i = 0; i < _owners.length; ++i) { for (uint256 i = 0; i < _owners.length; ++i) {

View File

@ -212,7 +212,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @param time The time to be checked * @param time The time to be checked
* @return An uint256 representing the amount of vested tokens of a specific grant at a specific time. * @return An uint256 representing the amount of vested tokens of a specific grant at a specific time.
*/ */
function vestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) { function vestedTokens(TokenGrant memory grant, uint64 time) private view returns (uint256) {
return calculateVestedTokens( return calculateVestedTokens(
grant.value, grant.value,
uint256(time), uint256(time),
@ -229,7 +229,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @return An uint256 representing the amount of non vested tokens of a specific grant on the * @return An uint256 representing the amount of non vested tokens of a specific grant on the
* passed time frame. * passed time frame.
*/ */
function nonVestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) { function nonVestedTokens(TokenGrant memory grant, uint64 time) private view returns (uint256) {
return grant.value.sub(vestedTokens(grant, time)); return grant.value.sub(vestedTokens(grant, time));
} }