This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function requestVotingRights(uint numTokens) external { | |
require(token.balanceOf(msg.sender) >= numTokens); | |
require(token.transferFrom(msg.sender, this, numTokens)); | |
voteTokenBalance[msg.sender] += numTokens; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withdrawVotingRights(uint numTokens) external { | |
uint availableTokens = voteTokenBalance[msg.sender] - getLockedTokens(msg.sender); | |
require(availableTokens >= numTokens); | |
require(token.transfer(msg.sender, numTokens)); | |
voteTokenBalance[msg.sender] -= numTokens; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function commitVote(uint pollID, bytes32 secretHash, uint numTokens, uint prevPollID) external { | |
require(commitPeriodActive(pollID)); | |
require(voteTokenBalance[msg.sender] >= numTokens); // prevent user from overspending | |
require(pollID != 0); // prevent user from committing to zero node placerholder | |
uint nextPollID = dllMap[msg.sender].getNext(prevPollID); | |
require(validPosition(prevPollID, nextPollID, msg.sender, numTokens)); | |
dllMap[msg.sender].insert(prevPollID, pollID, nextPollID); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function revealVote(uint pollID, uint voteOption, uint salt) external { | |
// Make sure the reveal period is active | |
require(revealPeriodActive(pollID)); | |
require(!hasBeenRevealed(msg.sender, pollID)); // prevent user from revealing multiple times | |
require(sha3(voteOption, salt) == getCommitHash(msg.sender, pollID)); // compare resultant hash from inputs to original commitHash | |
uint numTokens = getNumTokens(msg.sender, pollID); | |
if (voteOption == 1) // apply numTokens to appropriate poll choice | |
pollMap[pollID].votesFor += numTokens; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library DLL { | |
struct Node { | |
uint next; | |
uint prev; | |
} | |
struct Data { | |
mapping(uint => Node) dll; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library AttributeStore { | |
struct Data { | |
mapping(bytes32 => uint) store; | |
} | |
function getAttribute(Data storage self, bytes32 UUID, string attrName) returns (uint) { | |
bytes32 key = sha3(UUID, attrName); | |
return self.store[key]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startPoll(uint _voteQuorum, uint _commitDuration, uint _revealDuration) public returns (uint pollID) { | |
pollNonce = pollNonce + 1; | |
pollMap[pollNonce] = Poll({ | |
voteQuorum: _voteQuorum, | |
commitEndDate: block.timestamp + _commitDuration, | |
revealEndDate: block.timestamp + _commitDuration + _revealDuration, | |
votesFor: 0, | |
votesAgainst: 0 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Registry( | |
address _tokenAddr, | |
address _plcrAddr, | |
address _paramsAddr | |
) { | |
token = StandardToken(_tokenAddr); | |
voting = PLCRVoting(_plcrAddr); | |
parameterizer = Parameterizer(_paramsAddr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function apply(string _domain, uint _amount) external { | |
require(!isWhitelisted(_domain)); | |
require(!appWasMade(_domain)); | |
require(_amount >= parameterizer.get("minDeposit")); | |
// Sets owner | |
Listing storage listing = listings[keccak256(_domain)]; | |
listing.owner = msg.sender; | |
// Transfers tokens from user to Registry contract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Listing { | |
uint applicationExpiry; // Expiration date of apply stage | |
bool whitelisted; // Indicates registry status | |
address owner; // Owner of Listing | |
uint unstakedDeposit; // Number of unlocked tokens with potential risk if challenged | |
uint challengeID; // Identifier of canonical challenge | |
} |
OlderNewer