Skip to content

Instantly share code, notes, and snippets.

Feb 10, 2021 Eth1 JSON-RPC Standards Meeting ethereum-oasis-op/eth1.x-JSON-RPC-API-standard#9

pragma solidity ^0.4.20;
// File: tokens/eip20/EIP20Interface.sol
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.8;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
pragma solidity ^0.4.20;
// File: tokens/eip20/EIP20Interface.sol
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.8;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
// File: contracts/inherited/Proxy.sol
/// @title Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.pm>
contract Proxy {
address masterCopy;
/// @dev Constructor function sets address of master copy contract.
/// @param _masterCopy Master copy address.
// We don't know at commit time what the votes are, so can't do any ordering work there.
// We can, however, store all commits with timestamps.
// At reveal time, we can look at the timestamp of the revealed commit and insert it into a DLL
// for its plurality, and require the insert point be computed off-chain. (We check on-chain that
// the timestampe for the new inserted node is >= the timestamp for the previous inserted node).
// After reveal time, we then have a time-ordered list of who voted when in the plurality. We'll
// model it as a simple array here. The logic sketched here would be executed at claimFee time.
//
// The motivation for this sketch is that payouts for any arbiter cannot be computed unless the
// sum of all previous payout percentages are known. Because the number of arbiters who reveal in
function voterReward(Data storage _self, address _voter, uint _salt)
public constant returns (uint) {
uint voterTokens = _self.voting.getNumPassingTokens(_voter, _self.challengeID, _salt);
return (voterTokens * _self.rewardPool) / _self.winningTokens;
}
function claimReward(Data storage _self, address _voter, uint _salt) public returns (uint) {
// Ensures the voter has not already claimed tokens and challenge results have been processed
require(_self.tokenClaims[_voter] == false);
require(isResolved(_self));
uint voterTokens = _self.voting.getNumPassingTokens(_voter, _self.challengeID, _salt);
uint reward = voterReward(_self, _voter, _salt);
// Subtracts the voter's information to preserve the participation ratios
// of other voters compared to the remaining pool of rewards
function challengeWinnerReward(Data storage _self) public constant returns (uint) {
// Edge case, nobody voted, give all tokens to the challenger.
if (_self.voting.getTotalNumberOfTokensForWinningOption(_self.challengeID) == 0) {
return 2 * _self.stake;
}
return (2 * _self.stake) - _self.rewardPool;
}
function resolveChallenge(string _domain) private {
bytes32 domainHash = keccak256(_domain);
Listing storage listing = listings[domainHash];
Challenge.Data storage challenge = challenges[listing.challengeID];
// Calculates the winner's reward,
// which is: (winner's full stake) + (dispensationPct * loser's stake)
uint winnerReward = challenge.challengeWinnerReward();
// Records whether the domain is a listing or an application
function canBeWhitelisted(string _domain) constant public returns (bool) {
bytes32 domainHash = keccak256(_domain);
uint challengeID = listings[domainHash].challengeID;
// Ensures that the application was made,
// the application period has ended,
// the domain can be whitelisted,
// and either: the challengeID == 0, or the challenge has been resolved.
if (
appWasMade(_domain) &&