mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixed compilation tests and upgraded ext. tests branch
This commit is contained in:
parent
aed6c22318
commit
92cf61d4f9
@ -128,7 +128,7 @@ restrictions highly readable.
|
|||||||
// phase, where `msg.sender` is the account
|
// phase, where `msg.sender` is the account
|
||||||
// creating this contract.
|
// creating this contract.
|
||||||
address public owner = msg.sender;
|
address public owner = msg.sender;
|
||||||
uint public creationTime = now;
|
uint public creationTime = block.timestamp;
|
||||||
|
|
||||||
// Modifiers can be used to change
|
// Modifiers can be used to change
|
||||||
// the body of a function.
|
// the body of a function.
|
||||||
@ -159,7 +159,7 @@ restrictions highly readable.
|
|||||||
|
|
||||||
modifier onlyAfter(uint _time) {
|
modifier onlyAfter(uint _time) {
|
||||||
require(
|
require(
|
||||||
now >= _time,
|
block.timestamp >= _time,
|
||||||
"Function called too early."
|
"Function called too early."
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
@ -287,7 +287,7 @@ function finishes.
|
|||||||
// This is the current stage.
|
// This is the current stage.
|
||||||
Stages public stage = Stages.AcceptingBlindedBids;
|
Stages public stage = Stages.AcceptingBlindedBids;
|
||||||
|
|
||||||
uint public creationTime = now;
|
uint public creationTime = block.timestamp;
|
||||||
|
|
||||||
modifier atStage(Stages _stage) {
|
modifier atStage(Stages _stage) {
|
||||||
require(
|
require(
|
||||||
@ -306,10 +306,10 @@ function finishes.
|
|||||||
// will not take the new stage into account.
|
// will not take the new stage into account.
|
||||||
modifier timedTransitions() {
|
modifier timedTransitions() {
|
||||||
if (stage == Stages.AcceptingBlindedBids &&
|
if (stage == Stages.AcceptingBlindedBids &&
|
||||||
now >= creationTime + 10 days)
|
block.timestamp >= creationTime + 10 days)
|
||||||
nextStage();
|
nextStage();
|
||||||
if (stage == Stages.RevealBids &&
|
if (stage == Stages.RevealBids &&
|
||||||
now >= creationTime + 12 days)
|
block.timestamp >= creationTime + 12 days)
|
||||||
nextStage();
|
nextStage();
|
||||||
// The other stages transition by transaction
|
// The other stages transition by transaction
|
||||||
_;
|
_;
|
||||||
|
@ -111,6 +111,9 @@ Block and Transaction Properties
|
|||||||
The function ``gasleft`` was previously known as ``msg.gas``, which was deprecated in
|
The function ``gasleft`` was previously known as ``msg.gas``, which was deprecated in
|
||||||
version 0.4.21 and removed in version 0.5.0.
|
version 0.4.21 and removed in version 0.5.0.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
In version 0.7.0, the alias ``now`` (for ``block.timestamp``) was removed.
|
||||||
|
|
||||||
.. index:: abi, encoding, packed
|
.. index:: abi, encoding, packed
|
||||||
|
|
||||||
ABI Encoding and Decoding Functions
|
ABI Encoding and Decoding Functions
|
||||||
|
@ -582,9 +582,6 @@ Available upgrade modules
|
|||||||
+-----------------+---------+--------------------------------------------------+
|
+-----------------+---------+--------------------------------------------------+
|
||||||
| ``now`` | 0.7.0 | The ``now`` keyword is deprecated. Use |
|
| ``now`` | 0.7.0 | The ``now`` keyword is deprecated. Use |
|
||||||
| | | ``block.timestamp`` instead. |
|
| | | ``block.timestamp`` instead. |
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
+-----------------+---------+--------------------------------------------------+
|
+-----------------+---------+--------------------------------------------------+
|
||||||
|
|
||||||
Please read :doc:`0.5.0 release notes <050-breaking-changes>`,
|
Please read :doc:`0.5.0 release notes <050-breaking-changes>`,
|
||||||
|
@ -256,7 +256,7 @@ contract provider is module, safeMath, announcementTypes {
|
|||||||
providers[msg.sender].data[currHeight].country = country;
|
providers[msg.sender].data[currHeight].country = country;
|
||||||
providers[msg.sender].data[currHeight].info = info;
|
providers[msg.sender].data[currHeight].info = info;
|
||||||
providers[msg.sender].data[currHeight].currentRate = rate;
|
providers[msg.sender].data[currHeight].currentRate = rate;
|
||||||
providers[msg.sender].data[currHeight].create = now;
|
providers[msg.sender].data[currHeight].create = block.timestamp;
|
||||||
providers[msg.sender].data[currHeight].lastPaidRate = rate;
|
providers[msg.sender].data[currHeight].lastPaidRate = rate;
|
||||||
providers[msg.sender].data[currHeight].priv = priv;
|
providers[msg.sender].data[currHeight].priv = priv;
|
||||||
providers[msg.sender].data[currHeight].lastSupplyID = currentSchellingRound;
|
providers[msg.sender].data[currHeight].lastSupplyID = currentSchellingRound;
|
||||||
@ -436,7 +436,7 @@ contract provider is module, safeMath, announcementTypes {
|
|||||||
clients[msg.sender].lastSupplyID = currentSchellingRound;
|
clients[msg.sender].lastSupplyID = currentSchellingRound;
|
||||||
clients[msg.sender].paidUpTo = currentSchellingRound;
|
clients[msg.sender].paidUpTo = currentSchellingRound;
|
||||||
clients[msg.sender].lastRate = providers[provider].data[currHeight].currentRate;
|
clients[msg.sender].lastRate = providers[provider].data[currHeight].currentRate;
|
||||||
clients[msg.sender].providerConnected = now;
|
clients[msg.sender].providerConnected = block.timestamp;
|
||||||
emit ENewClient(msg.sender, provider, currHeight, bal);
|
emit ENewClient(msg.sender, provider, currHeight, bal);
|
||||||
}
|
}
|
||||||
function partProvider() isReady external {
|
function partProvider() isReady external {
|
||||||
|
@ -55,7 +55,7 @@ contract Campaign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modifier timedTransitions() {
|
modifier timedTransitions() {
|
||||||
if (stage == Stages.AuctionStarted && deadline < now)
|
if (stage == Stages.AuctionStarted && deadline < block.timestamp)
|
||||||
stage = Stages.AuctionFailed;
|
stage = Stages.AuctionFailed;
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ contract Campaign {
|
|||||||
&& address(_marketMaker) != address(0)
|
&& address(_marketMaker) != address(0)
|
||||||
&& _fee < FEE_RANGE
|
&& _fee < FEE_RANGE
|
||||||
&& _funding > 0
|
&& _funding > 0
|
||||||
&& now < _deadline);
|
&& block.timestamp < _deadline);
|
||||||
eventContract = _eventContract;
|
eventContract = _eventContract;
|
||||||
marketFactory = _marketFactory;
|
marketFactory = _marketFactory;
|
||||||
marketMaker = _marketMaker;
|
marketMaker = _marketMaker;
|
||||||
|
@ -71,7 +71,7 @@ contract FutarchyOracle is Oracle {
|
|||||||
public
|
public
|
||||||
{
|
{
|
||||||
// Deadline is in the future
|
// Deadline is in the future
|
||||||
require(_deadline > now);
|
require(_deadline > block.timestamp);
|
||||||
// Create decision event
|
// Create decision event
|
||||||
categoricalEvent = eventFactory.createCategoricalEvent(collateralToken, this, outcomeCount);
|
categoricalEvent = eventFactory.createCategoricalEvent(collateralToken, this, outcomeCount);
|
||||||
// Create outcome events
|
// Create outcome events
|
||||||
@ -131,7 +131,7 @@ contract FutarchyOracle is Oracle {
|
|||||||
public
|
public
|
||||||
{
|
{
|
||||||
// Outcome is not set yet and deadline has passed
|
// Outcome is not set yet and deadline has passed
|
||||||
require(!isSet && deadline <= now);
|
require(!isSet && deadline <= block.timestamp);
|
||||||
// Find market with highest marginal price for long outcome tokens
|
// Find market with highest marginal price for long outcome tokens
|
||||||
uint highestMarginalPrice = markets[0].marketMaker().calcMarginalPrice(markets[0], LONG);
|
uint highestMarginalPrice = markets[0].marketMaker().calcMarginalPrice(markets[0], LONG);
|
||||||
uint highestIndex = 0;
|
uint highestIndex = 0;
|
||||||
|
@ -80,7 +80,7 @@ contract UltimateOracle is Oracle {
|
|||||||
&& forwardedOutcomeSetTimestamp == 0
|
&& forwardedOutcomeSetTimestamp == 0
|
||||||
&& forwardedOracle.isOutcomeSet());
|
&& forwardedOracle.isOutcomeSet());
|
||||||
forwardedOutcome = forwardedOracle.getOutcome();
|
forwardedOutcome = forwardedOracle.getOutcome();
|
||||||
forwardedOutcomeSetTimestamp = now;
|
forwardedOutcomeSetTimestamp = block.timestamp;
|
||||||
emit ForwardedOracleOutcomeAssignment(forwardedOutcome);
|
emit ForwardedOracleOutcomeAssignment(forwardedOutcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ contract UltimateOracle is Oracle {
|
|||||||
totalOutcomeAmounts[_outcome] = challengeAmount;
|
totalOutcomeAmounts[_outcome] = challengeAmount;
|
||||||
totalAmount = challengeAmount;
|
totalAmount = challengeAmount;
|
||||||
frontRunner = _outcome;
|
frontRunner = _outcome;
|
||||||
frontRunnerSetTimestamp = now;
|
frontRunnerSetTimestamp = block.timestamp;
|
||||||
emit OutcomeChallenge(msg.sender, _outcome);
|
emit OutcomeChallenge(msg.sender, _outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ contract UltimateOracle is Oracle {
|
|||||||
if (_outcome != frontRunner && totalOutcomeAmounts[_outcome] > totalOutcomeAmounts[frontRunner])
|
if (_outcome != frontRunner && totalOutcomeAmounts[_outcome] > totalOutcomeAmounts[frontRunner])
|
||||||
{
|
{
|
||||||
frontRunner = _outcome;
|
frontRunner = _outcome;
|
||||||
frontRunnerSetTimestamp = now;
|
frontRunnerSetTimestamp = block.timestamp;
|
||||||
}
|
}
|
||||||
emit OutcomeVote(msg.sender, _outcome, amount);
|
emit OutcomeVote(msg.sender, _outcome, amount);
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ contract UltimateOracle is Oracle {
|
|||||||
view
|
view
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
return forwardedOutcomeSetTimestamp != 0 && now.sub(forwardedOutcomeSetTimestamp) > challengePeriod;
|
return forwardedOutcomeSetTimestamp != 0 && (block.timestamp).sub(forwardedOutcomeSetTimestamp) > challengePeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Checks if time to overbid the front runner is over
|
/// @dev Checks if time to overbid the front runner is over
|
||||||
@ -157,7 +157,7 @@ contract UltimateOracle is Oracle {
|
|||||||
view
|
view
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
return frontRunnerSetTimestamp != 0 && now.sub(frontRunnerSetTimestamp) > frontRunnerPeriod;
|
return frontRunnerSetTimestamp != 0 && (block.timestamp).sub(frontRunnerSetTimestamp) > frontRunnerPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Checks if outcome was challenged
|
/// @dev Checks if outcome was challenged
|
||||||
|
@ -264,10 +264,10 @@ contract MilestoneTracker {
|
|||||||
&&(msg.sender != recipient))
|
&&(msg.sender != recipient))
|
||||||
revert();
|
revert();
|
||||||
if (milestone.status != MilestoneStatus.AcceptedAndInProgress) revert();
|
if (milestone.status != MilestoneStatus.AcceptedAndInProgress) revert();
|
||||||
if (now < milestone.minCompletionDate) revert();
|
if (block.timestamp < milestone.minCompletionDate) revert();
|
||||||
if (now > milestone.maxCompletionDate) revert();
|
if (block.timestamp > milestone.maxCompletionDate) revert();
|
||||||
milestone.status = MilestoneStatus.Completed;
|
milestone.status = MilestoneStatus.Completed;
|
||||||
milestone.doneTime = now;
|
milestone.doneTime = block.timestamp;
|
||||||
emit ProposalStatusChanged(_idMilestone, milestone.status);
|
emit ProposalStatusChanged(_idMilestone, milestone.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ contract MilestoneTracker {
|
|||||||
&&(msg.sender != recipient))
|
&&(msg.sender != recipient))
|
||||||
revert();
|
revert();
|
||||||
if ((milestone.status != MilestoneStatus.Completed) ||
|
if ((milestone.status != MilestoneStatus.Completed) ||
|
||||||
(now < milestone.doneTime + milestone.reviewTime))
|
(block.timestamp < milestone.doneTime + milestone.reviewTime))
|
||||||
revert();
|
revert();
|
||||||
|
|
||||||
authorizePayment(_idMilestone);
|
authorizePayment(_idMilestone);
|
||||||
|
@ -38,7 +38,6 @@ namespace solidity::frontend::test
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
static char const* registrarCode = R"DELIMITER(
|
static char const* registrarCode = R"DELIMITER(
|
||||||
pragma solidity >=0.4.0 <0.8.0;
|
pragma solidity >=0.4.0 <0.8.0;
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ abstract contract AuctionSystem {
|
|||||||
|
|
||||||
function bid(string memory _name, address payable _bidder, uint _value) internal {
|
function bid(string memory _name, address payable _bidder, uint _value) internal {
|
||||||
Auction storage auction = m_auctions[_name];
|
Auction storage auction = m_auctions[_name];
|
||||||
if (auction.endDate > 0 && now > auction.endDate)
|
if (auction.endDate > 0 && block.timestamp > auction.endDate)
|
||||||
{
|
{
|
||||||
emit AuctionEnded(_name, auction.highestBidder);
|
emit AuctionEnded(_name, auction.highestBidder);
|
||||||
onAuctionEnd(_name);
|
onAuctionEnd(_name);
|
||||||
@ -82,7 +81,7 @@ abstract contract AuctionSystem {
|
|||||||
auction.sumOfBids += _value;
|
auction.sumOfBids += _value;
|
||||||
auction.highestBid = _value;
|
auction.highestBid = _value;
|
||||||
auction.highestBidder = _bidder;
|
auction.highestBidder = _bidder;
|
||||||
auction.endDate = now + c_biddingTime;
|
auction.endDate = block.timestamp + c_biddingTime;
|
||||||
|
|
||||||
emit NewBid(_name, _bidder, _value);
|
emit NewBid(_name, _bidder, _value);
|
||||||
}
|
}
|
||||||
@ -120,7 +119,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
|||||||
Auction storage auction = m_auctions[_name];
|
Auction storage auction = m_auctions[_name];
|
||||||
Record storage record = m_toRecord[_name];
|
Record storage record = m_toRecord[_name];
|
||||||
address previousOwner = record.owner;
|
address previousOwner = record.owner;
|
||||||
record.renewalDate = now + c_renewalInterval;
|
record.renewalDate = block.timestamp + c_renewalInterval;
|
||||||
record.owner = auction.highestBidder;
|
record.owner = auction.highestBidder;
|
||||||
emit Changed(_name);
|
emit Changed(_name);
|
||||||
if (previousOwner != 0x0000000000000000000000000000000000000000) {
|
if (previousOwner != 0x0000000000000000000000000000000000000000) {
|
||||||
@ -138,7 +137,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
|||||||
bool needAuction = requiresAuction(_name);
|
bool needAuction = requiresAuction(_name);
|
||||||
if (needAuction)
|
if (needAuction)
|
||||||
{
|
{
|
||||||
if (now < m_toRecord[_name].renewalDate)
|
if (block.timestamp < m_toRecord[_name].renewalDate)
|
||||||
revert();
|
revert();
|
||||||
bid(_name, msg.sender, msg.value);
|
bid(_name, msg.sender, msg.value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,7 +40,6 @@ using namespace solidity::util;
|
|||||||
|
|
||||||
namespace solidity::frontend::test
|
namespace solidity::frontend::test
|
||||||
{
|
{
|
||||||
|
|
||||||
static char const* walletCode = R"DELIMITER(
|
static char const* walletCode = R"DELIMITER(
|
||||||
//sol Wallet
|
//sol Wallet
|
||||||
// Multi-sig, daily-limited account proxy/wallet.
|
// Multi-sig, daily-limited account proxy/wallet.
|
||||||
@ -317,7 +316,7 @@ abstract contract daylimit is multiowned {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// determines today's index.
|
// determines today's index.
|
||||||
function today() private view returns (uint) { return now / 1 days; }
|
function today() private view returns (uint) { return block.timestamp / 1 days; }
|
||||||
|
|
||||||
// FIELDS
|
// FIELDS
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ function colony_test
|
|||||||
FORCE_ABIv2=false
|
FORCE_ABIv2=false
|
||||||
CONFIG="truffle.js"
|
CONFIG="truffle.js"
|
||||||
|
|
||||||
truffle_setup https://github.com/solidity-external-tests/colonyNetwork.git develop_060
|
truffle_setup https://github.com/solidity-external-tests/colonyNetwork.git develop_070
|
||||||
run_install install_fn
|
run_install install_fn
|
||||||
|
|
||||||
cd lib
|
cd lib
|
||||||
|
@ -33,7 +33,7 @@ function gnosis_safe_test
|
|||||||
OPTIMIZER_LEVEL=1
|
OPTIMIZER_LEVEL=1
|
||||||
CONFIG="truffle.js"
|
CONFIG="truffle.js"
|
||||||
|
|
||||||
truffle_setup https://github.com/solidity-external-tests/safe-contracts.git development_060
|
truffle_setup https://github.com/solidity-external-tests/safe-contracts.git development_070
|
||||||
|
|
||||||
force_truffle_version
|
force_truffle_version
|
||||||
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070|g' package.json
|
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070|g' package.json
|
||||||
|
@ -381,7 +381,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
revert();
|
revert();
|
||||||
if (address(DAOrewardAccount) == 0x0000000000000000000000000000000000000000)
|
if (address(DAOrewardAccount) == 0x0000000000000000000000000000000000000000)
|
||||||
revert();
|
revert();
|
||||||
lastTimeMinQuorumMet = now;
|
lastTimeMinQuorumMet = block.timestamp;
|
||||||
minQuorumDivisor = 5; // sets the minimal quorum to 20%
|
minQuorumDivisor = 5; // sets the minimal quorum to 20%
|
||||||
proposals.push(); // avoids a proposal with ID 0 because it is used
|
proposals.push(); // avoids a proposal with ID 0 because it is used
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
receive() external payable override(DAOInterface, TokenCreation) {
|
receive() external payable override(DAOInterface, TokenCreation) {
|
||||||
if (now < closingTime + creationGracePeriod && msg.sender != address(extraBalance))
|
if (block.timestamp < closingTime + creationGracePeriod && msg.sender != address(extraBalance))
|
||||||
createTokenProxy(msg.sender);
|
createTokenProxy(msg.sender);
|
||||||
else
|
else
|
||||||
receiveEther();
|
receiveEther();
|
||||||
@ -430,13 +430,13 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
revert();
|
revert();
|
||||||
|
|
||||||
if (!isFueled
|
if (!isFueled
|
||||||
|| now < closingTime
|
|| block.timestamp < closingTime
|
||||||
|| (msg.value < proposalDeposit && !_newCurator)) {
|
|| (msg.value < proposalDeposit && !_newCurator)) {
|
||||||
|
|
||||||
revert();
|
revert();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now + _debatingPeriod < now) // prevents overflow
|
if (block.timestamp + _debatingPeriod < block.timestamp) // prevents overflow
|
||||||
revert();
|
revert();
|
||||||
|
|
||||||
// to prevent a 51% attacker to convert the ether into deposit
|
// to prevent a 51% attacker to convert the ether into deposit
|
||||||
@ -445,7 +445,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
|
|
||||||
// to prevent curator from halving quorum before first proposal
|
// to prevent curator from halving quorum before first proposal
|
||||||
if (proposals.length == 1) // initial length is 1 (see constructor)
|
if (proposals.length == 1) // initial length is 1 (see constructor)
|
||||||
lastTimeMinQuorumMet = now;
|
lastTimeMinQuorumMet = block.timestamp;
|
||||||
|
|
||||||
Proposal storage p = proposals.push();
|
Proposal storage p = proposals.push();
|
||||||
_proposalID = proposals.length - 1;
|
_proposalID = proposals.length - 1;
|
||||||
@ -453,7 +453,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
p.amount = _amount;
|
p.amount = _amount;
|
||||||
p.description = _description;
|
p.description = _description;
|
||||||
p.proposalHash = keccak256(abi.encodePacked(_recipient, _amount, _transactionData));
|
p.proposalHash = keccak256(abi.encodePacked(_recipient, _amount, _transactionData));
|
||||||
p.votingDeadline = now + _debatingPeriod;
|
p.votingDeadline = block.timestamp + _debatingPeriod;
|
||||||
p.open = true;
|
p.open = true;
|
||||||
//p.proposalPassed = False; // that's default
|
//p.proposalPassed = False; // that's default
|
||||||
p.newCurator = _newCurator;
|
p.newCurator = _newCurator;
|
||||||
@ -493,7 +493,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
Proposal storage p = proposals[_proposalID];
|
Proposal storage p = proposals[_proposalID];
|
||||||
if (p.votedYes[msg.sender]
|
if (p.votedYes[msg.sender]
|
||||||
|| p.votedNo[msg.sender]
|
|| p.votedNo[msg.sender]
|
||||||
|| now >= p.votingDeadline) {
|
|| block.timestamp >= p.votingDeadline) {
|
||||||
|
|
||||||
revert();
|
revert();
|
||||||
}
|
}
|
||||||
@ -529,13 +529,13 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
? splitExecutionPeriod
|
? splitExecutionPeriod
|
||||||
: executeProposalPeriod;
|
: executeProposalPeriod;
|
||||||
// If we are over deadline and waiting period, assert proposal is closed
|
// If we are over deadline and waiting period, assert proposal is closed
|
||||||
if (p.open && now > p.votingDeadline + waitPeriod) {
|
if (p.open && block.timestamp > p.votingDeadline + waitPeriod) {
|
||||||
closeProposal(_proposalID);
|
closeProposal(_proposalID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the proposal can be executed
|
// Check if the proposal can be executed
|
||||||
if (now < p.votingDeadline // has the voting deadline arrived?
|
if (block.timestamp < p.votingDeadline // has the voting deadline arrived?
|
||||||
// Have the votes been counted?
|
// Have the votes been counted?
|
||||||
|| !p.open
|
|| !p.open
|
||||||
|| p.proposalPassed // anyone trying to call us recursively?
|
|| p.proposalPassed // anyone trying to call us recursively?
|
||||||
@ -573,7 +573,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
if (!p.creator.send(p.proposalDeposit))
|
if (!p.creator.send(p.proposalDeposit))
|
||||||
revert();
|
revert();
|
||||||
|
|
||||||
lastTimeMinQuorumMet = now;
|
lastTimeMinQuorumMet = block.timestamp;
|
||||||
// set the minQuorum to 20% again, in the case it has been reached
|
// set the minQuorum to 20% again, in the case it has been reached
|
||||||
if (quorum > totalSupply / 5)
|
if (quorum > totalSupply / 5)
|
||||||
minQuorumDivisor = 5;
|
minQuorumDivisor = 5;
|
||||||
@ -628,9 +628,9 @@ contract DAO is DAOInterface, Token, TokenCreation {
|
|||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
|
|
||||||
if (now < p.votingDeadline // has the voting deadline arrived?
|
if (block.timestamp < p.votingDeadline // has the voting deadline arrived?
|
||||||
//The request for a split expires XX days after the voting deadline
|
//The request for a split expires XX days after the voting deadline
|
||||||
|| now > p.votingDeadline + splitExecutionPeriod
|
|| block.timestamp > p.votingDeadline + splitExecutionPeriod
|
||||||
// Does the new Curator address match?
|
// Does the new Curator address match?
|
||||||
|| p.recipient != _newCurator
|
|| p.recipient != _newCurator
|
||||||
// Is it a new curator proposal?
|
// Is it a new curator proposal?
|
||||||
@ -759,7 +759,7 @@ override returns (bool _success) {
|
|||||||
|
|
||||||
function transfer(address _to, uint256 _value) public override returns (bool success) {
|
function transfer(address _to, uint256 _value) public override returns (bool success) {
|
||||||
if (isFueled
|
if (isFueled
|
||||||
&& now > closingTime
|
&& block.timestamp > closingTime
|
||||||
&& !isBlocked(msg.sender)
|
&& !isBlocked(msg.sender)
|
||||||
&& _to != address(this)
|
&& _to != address(this)
|
||||||
&& transferPaidOut(msg.sender, _to, _value)
|
&& transferPaidOut(msg.sender, _to, _value)
|
||||||
@ -782,7 +782,7 @@ override returns (bool _success) {
|
|||||||
function transferFrom(address _from, address _to, uint256 _value) public
|
function transferFrom(address _from, address _to, uint256 _value) public
|
||||||
override returns (bool success) {
|
override returns (bool success) {
|
||||||
if (isFueled
|
if (isFueled
|
||||||
&& now > closingTime
|
&& block.timestamp > closingTime
|
||||||
&& !isBlocked(_from)
|
&& !isBlocked(_from)
|
||||||
&& _to != address(this)
|
&& _to != address(this)
|
||||||
&& transferPaidOut(_from, _to, _value)
|
&& transferPaidOut(_from, _to, _value)
|
||||||
@ -869,11 +869,11 @@ override returns (bool _success) {
|
|||||||
// this can only be called after `quorumHalvingPeriod` has passed or at anytime after
|
// this can only be called after `quorumHalvingPeriod` has passed or at anytime after
|
||||||
// fueling by the curator with a delay of at least `minProposalDebatePeriod`
|
// fueling by the curator with a delay of at least `minProposalDebatePeriod`
|
||||||
// between the calls
|
// between the calls
|
||||||
if ((lastTimeMinQuorumMet < (now - quorumHalvingPeriod) || msg.sender == curator)
|
if ((lastTimeMinQuorumMet < (block.timestamp - quorumHalvingPeriod) || msg.sender == curator)
|
||||||
&& lastTimeMinQuorumMet < (now - minProposalDebatePeriod)
|
&& lastTimeMinQuorumMet < (block.timestamp - minProposalDebatePeriod)
|
||||||
&& now >= closingTime
|
&& block.timestamp >= closingTime
|
||||||
&& proposals.length > 1) {
|
&& proposals.length > 1) {
|
||||||
lastTimeMinQuorumMet = now;
|
lastTimeMinQuorumMet = block.timestamp;
|
||||||
minQuorumDivisor *= 2;
|
minQuorumDivisor *= 2;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -887,7 +887,7 @@ override returns (bool _success) {
|
|||||||
_newCurator,
|
_newCurator,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
now + splitExecutionPeriod,
|
block.timestamp + splitExecutionPeriod,
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
decimals
|
decimals
|
||||||
@ -907,7 +907,7 @@ override returns (bool _success) {
|
|||||||
if (blocked[_account] == 0)
|
if (blocked[_account] == 0)
|
||||||
return false;
|
return false;
|
||||||
Proposal storage p = proposals[blocked[_account]];
|
Proposal storage p = proposals[blocked[_account]];
|
||||||
if (now > p.votingDeadline) {
|
if (block.timestamp > p.votingDeadline) {
|
||||||
blocked[_account] = 0;
|
blocked[_account] = 0;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,7 +102,7 @@ contract TokenCreation is TokenCreationInterface, Token {
|
|||||||
|
|
||||||
function createTokenProxy(address payable _tokenHolder) payable public
|
function createTokenProxy(address payable _tokenHolder) payable public
|
||||||
override returns (bool success) {
|
override returns (bool success) {
|
||||||
if (now < closingTime && msg.value > 0
|
if (block.timestamp < closingTime && msg.value > 0
|
||||||
&& (privateCreation == 0x0000000000000000000000000000000000000000 || privateCreation == msg.sender)) {
|
&& (privateCreation == 0x0000000000000000000000000000000000000000 || privateCreation == msg.sender)) {
|
||||||
|
|
||||||
uint token = (msg.value * 20) / divisor();
|
uint token = (msg.value * 20) / divisor();
|
||||||
@ -121,7 +121,7 @@ override returns (bool success) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function refund() public override {
|
function refund() public override {
|
||||||
if (now > closingTime && !isFueled) {
|
if (block.timestamp > closingTime && !isFueled) {
|
||||||
// Get extraBalance - will only succeed when called for the first time
|
// Get extraBalance - will only succeed when called for the first time
|
||||||
if (address(extraBalance).balance >= extraBalance.accumulatedInput())
|
if (address(extraBalance).balance >= extraBalance.accumulatedInput())
|
||||||
extraBalance.payOut(address(this), extraBalance.accumulatedInput());
|
extraBalance.payOut(address(this), extraBalance.accumulatedInput());
|
||||||
@ -141,11 +141,11 @@ override returns (bool success) {
|
|||||||
// The number of (base unit) tokens per wei is calculated
|
// The number of (base unit) tokens per wei is calculated
|
||||||
// as `msg.value` * 20 / `divisor`
|
// as `msg.value` * 20 / `divisor`
|
||||||
// The fueling period starts with a 1:1 ratio
|
// The fueling period starts with a 1:1 ratio
|
||||||
if (closingTime - 2 weeks > now) {
|
if (closingTime - 2 weeks > block.timestamp) {
|
||||||
return 20;
|
return 20;
|
||||||
// Followed by 10 days with a daily creation rate increase of 5%
|
// Followed by 10 days with a daily creation rate increase of 5%
|
||||||
} else if (closingTime - 4 days > now) {
|
} else if (closingTime - 4 days > block.timestamp) {
|
||||||
return (20 + (now - (closingTime - 2 weeks)) / (1 days));
|
return (20 + (block.timestamp - (closingTime - 2 weeks)) / (1 days));
|
||||||
// The last 4 days there is a constant creation rate ratio of 1:1.5
|
// The last 4 days there is a constant creation rate ratio of 1:1.5
|
||||||
} else {
|
} else {
|
||||||
return 30;
|
return 30;
|
||||||
|
@ -1025,29 +1025,6 @@ BOOST_AUTO_TEST_CASE(blockchain)
|
|||||||
ABI_CHECK(callContractFunctionWithValue("someInfo()", 28), encodeArgs(28, u256("0x1212121212121212121212121212121212121212"), 7));
|
ABI_CHECK(callContractFunctionWithValue("someInfo()", 28), encodeArgs(28, u256("0x1212121212121212121212121212121212121212"), 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(now)
|
|
||||||
{
|
|
||||||
char const* sourceCode = R"(
|
|
||||||
contract test {
|
|
||||||
function someInfo() public returns (bool equal, uint val) {
|
|
||||||
equal = block.timestamp == now;
|
|
||||||
val = now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
ALSO_VIA_YUL(
|
|
||||||
compileAndRun(sourceCode);
|
|
||||||
u256 startBlock = blockNumber();
|
|
||||||
size_t startTime = blockTimestamp(startBlock);
|
|
||||||
auto ret = callContractFunction("someInfo()");
|
|
||||||
u256 endBlock = blockNumber();
|
|
||||||
size_t endTime = blockTimestamp(endBlock);
|
|
||||||
BOOST_CHECK(startBlock != endBlock);
|
|
||||||
BOOST_CHECK(startTime != endTime);
|
|
||||||
ABI_CHECK(ret, encodeArgs(true, endTime));
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(send_ether)
|
BOOST_AUTO_TEST_CASE(send_ether)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
|
@ -346,9 +346,9 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
|
|||||||
mapping(uint => uint) data;
|
mapping(uint => uint) data;
|
||||||
function f() public returns (uint)
|
function f() public returns (uint)
|
||||||
{
|
{
|
||||||
if (data[now] == 0)
|
if (data[block.timestamp] == 0)
|
||||||
data[uint(-7)] = 5;
|
data[uint(-7)] = 5;
|
||||||
return data[now];
|
return data[block.timestamp];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
@ -10,7 +10,7 @@ contract C
|
|||||||
assert(tx.origin == msg.sender);
|
assert(tx.origin == msg.sender);
|
||||||
uint x = block.number;
|
uint x = block.number;
|
||||||
assert(x + 2 > block.number);
|
assert(x + 2 > block.number);
|
||||||
assert(now > 10);
|
assert(block.timestamp > 10);
|
||||||
assert(gasleft() > 100);
|
assert(gasleft() > 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,5 +22,5 @@ contract C
|
|||||||
// Warning: (244-275): Assertion violation happens here
|
// Warning: (244-275): Assertion violation happens here
|
||||||
// Warning: (311-316): Overflow (resulting value larger than 2**256 - 1) happens here
|
// Warning: (311-316): Overflow (resulting value larger than 2**256 - 1) happens here
|
||||||
// Warning: (304-332): Assertion violation happens here
|
// Warning: (304-332): Assertion violation happens here
|
||||||
// Warning: (336-352): Assertion violation happens here
|
// Warning: (336-364): Assertion violation happens here
|
||||||
// Warning: (356-379): Assertion violation happens here
|
// Warning: (368-391): Assertion violation happens here
|
||||||
|
@ -270,20 +270,7 @@ public:
|
|||||||
|
|
||||||
static std::string nowUpdate(langutil::SourceLocation const& _location)
|
static std::string nowUpdate(langutil::SourceLocation const& _location)
|
||||||
{
|
{
|
||||||
std::regex nowRegex{"now"};
|
return regex_replace(_location.text(), std::regex{"now"}, "block.timestamp");
|
||||||
|
|
||||||
if (regex_search(_location.text(), nowRegex))
|
|
||||||
{
|
|
||||||
return regex_replace(_location.text(), nowRegex, "block.timestamp");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
solAssert(
|
|
||||||
false,
|
|
||||||
LocationHelper() << "Could not fix: " << _location.text() << " at " << _location <<
|
|
||||||
"\nNeeds to be fixed manually."
|
|
||||||
);
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,9 +45,10 @@ void NowKeyword::endVisit(Identifier const& _identifier)
|
|||||||
{
|
{
|
||||||
IdentifierAnnotation& annotation = _identifier.annotation();
|
IdentifierAnnotation& annotation = _identifier.annotation();
|
||||||
|
|
||||||
if (MagicVariableDeclaration const* magicVar
|
if (
|
||||||
= dynamic_cast<MagicVariableDeclaration const*>(annotation.referencedDeclaration))
|
MagicVariableDeclaration const* magicVar =
|
||||||
{
|
dynamic_cast<MagicVariableDeclaration const*>(annotation.referencedDeclaration)
|
||||||
|
)
|
||||||
if (magicVar->type()->category() == Type::Category::Integer)
|
if (magicVar->type()->category() == Type::Category::Integer)
|
||||||
{
|
{
|
||||||
solAssert(_identifier.name() == "now", "");
|
solAssert(_identifier.name() == "now", "");
|
||||||
@ -57,5 +58,4 @@ void NowKeyword::endVisit(Identifier const& _identifier)
|
|||||||
SourceTransform::nowUpdate(_identifier.location())
|
SourceTransform::nowUpdate(_identifier.location())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user