Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bug add days #22

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

Bug add days #22

wants to merge 9 commits into from

Conversation

bitbeckers
Copy link
Member

@bitbeckers bitbeckers commented Dec 24, 2020

closes #6

  • amountOfDays as parameter
  • updated test and finalized multiple tests that were still skipped

on #6:
Discord: "If I understand the case correctly, we could check on the timestamp of the previous block (as a threshold for 'the past'), but that is not something that could be done without querying the chain. My proposal would be to drop this and fix it in the front-end. So a CommitPool application specific requirement instead of a contract requirement. "

@spengrah
Copy link
Member

@@ -0,0 +1,3188 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Update flat file

address oracle,
bool allowed,
bool exists);
event RequestActivityDistanceFulfilled(bytes32 indexed requestId, uint256 indexed distance);
Copy link
Member

Choose a reason for hiding this comment

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

Is this the event our app is waiting on? If so, should we include the committer's address as well?

@@ -163,84 +149,72 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
/// @notice Create commitment, store on-chain and emit event
/// @param _activityKey Keccak256 hashed, encoded name of activity
/// @param _goalValue Distance of activity as goal
/// @param _startTime Starttime of commitment, also used for endTime
/// @param _daysToStart Starttime of commitment, also used for endTime
Copy link
Member

Choose a reason for hiding this comment

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

I think we should generalize this to _timeToStart for greater precision. For example, we should be able to handle scenarios when a user wants to start in a few hours, or some number of hours and minutes.

Also, lets update the comment to reflect the new param.

userId: _userId,
exists: true
});
uint256 startTime = _daysToStart > 0 ? addDays(_daysToStart, block.timestamp): block.timestamp;
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here, I think we may need to user something other than the addDays function, e.g. if the offset is in hours or fractions of days.

_startTime,
endTime,
_stake);
emit NewCommitment(msg.sender, activities[_activityKey].name, _goalValue, _daysToStart, endTime, _stake);
Copy link
Member

Choose a reason for hiding this comment

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

let's include startTime instead of _daysToStart in the event


return true;
}

/// @notice Wrapper function to deposit <token> and create commitment in one call
/// @param _activityKey Keccak256 hashed, encoded name of activity
/// @param _goalValue Distance of activity as goal
/// @param _startTime Starttime of commitment, also used for endTime
/// @param _daysToStart Starttime of commitment, also used for endTime
Copy link
Member

Choose a reason for hiding this comment

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

same change here to _timeToStart

_userId
), "SPC::depositAndCommit - commitment creation failed");
require(
makeCommitment(_activityKey, _goalValue, _daysToStart, _amountOfDays, _stake, _userId),
Copy link
Member

Choose a reason for hiding this comment

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

and here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creation of new commitment successfull with startdate in past
2 participants