Skip to content

Instantly share code, notes, and snippets.

function updateStatus(string _domain) public {
if (canBeWhitelisted(_domain)) {
whitelistApplication(_domain);
_NewDomainWhitelisted(_domain);
} else if (challengeCanBeResolved(_domain)) {
resolveChallenge(_domain);
} else {
revert();
}
}
function resetListing(string _domain) private {
bytes32 domainHash = keccak256(_domain);
Listing storage listing = listings[domainHash];
// Transfers any remaining balance back to the owner
if (listing.unstakedDeposit > 0)
require(token.transfer(listing.owner, listing.unstakedDeposit));
delete listings[domainHash];
}
struct Data {
uint rewardPool; // (remaining) Pool of tokens distributed amongst winning voters
PLCRVoting voting; // Address of a PLCRVoting contract
StandardToken token; // Address of an ERC20 token contract
uint challengeID; // An ID corresponding to a pollID in the PLCR contract
address challenger; // Owner of Challenge
bool resolved; // Indication of if challenge is resolved
uint stake; // Number of tokens at risk for either party during challenge
uint winningTokens; // (remaining) Amount of tokens used for voting by the winning side
mapping(address =>
function challenge(string _domain) external returns (uint challengeID) {
bytes32 domainHash = keccak256(_domain);
Listing storage listing = listings[domainHash];
uint deposit = parameterizer.get("minDeposit");
// Domain must be in apply stage or already on the whitelist
require(appWasMade(_domain) || listing.whitelisted);
// Prevent multiple challenges
require(!challenges[listing.challengeID].isInitialized() ||
challenges[listing.challengeID].isResolved());
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
}
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
function Registry(
address _tokenAddr,
address _plcrAddr,
address _paramsAddr
) {
token = StandardToken(_tokenAddr);
voting = PLCRVoting(_plcrAddr);
parameterizer = Parameterizer(_paramsAddr);
}
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
});
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];
}
library DLL {
struct Node {
uint next;
uint prev;
}
struct Data {
mapping(uint => Node) dll;
}