rename of main and oracles, erc677, registry index, better folder structure, stop using factory-library
This commit is contained in:
parent
be27e5dc4c
commit
32d744d71a
|
@ -1,8 +1,9 @@
|
|||
pragma solidity ^0.4.11;
|
||||
|
||||
import "./management/Controlled.sol";
|
||||
import "./oraclize/oraclizeAPI_0.4.sol";
|
||||
import "./helpers/strings.sol";
|
||||
import "./common/Controlled.sol";
|
||||
import "./common/oraclizeAPI_0.4.sol";
|
||||
import "./common/strings.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title GitHubAPIReg.sol
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
pragma solidity ^0.4.10;
|
||||
|
||||
import "./management/Controlled.sol";
|
||||
import "./GHPoints.sol";
|
||||
import "./GHUserReg.sol";
|
||||
import "./GHRepoReg.sol";
|
||||
|
||||
import "./common/Controlled.sol";
|
||||
import "./PointsOracle.sol";
|
||||
import "./UserOracle.sol";
|
||||
import "./RepositoryOracle.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title GitHubOracle.sol
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)]
|
||||
* @title GitPivot.sol
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
*/
|
||||
contract GitHubOracle is Controlled, DGitI {
|
||||
contract GitPivot is Controlled, DGitI {
|
||||
|
||||
GitHubUserReg public userReg;
|
||||
GitHubRepositoryReg public repositoryReg;
|
||||
GitHubPoints public gitHubPoints;
|
||||
UserOracle public userOracle;
|
||||
RepositoryOracle public repositoryOracle;
|
||||
PointsOracle public pointsOracle;
|
||||
|
||||
mapping (uint256 => Repository) repositories;
|
||||
mapping (uint256 => mapping (uint256 => uint256)) pending;
|
||||
|
@ -23,7 +22,7 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
address public newContract;
|
||||
|
||||
modifier package {
|
||||
require(msg.sender == address(gitHubPoints));
|
||||
require(msg.sender == address(pointsOracle));
|
||||
_;
|
||||
}
|
||||
|
||||
|
@ -39,19 +38,19 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
}
|
||||
|
||||
function getRepository(string _repository, string _branch) public constant returns (uint repoId) {
|
||||
repoId = repositoryReg.getId(_repository);
|
||||
repoId = repositoryOracle.getId(_repository);
|
||||
require(repoId != 0);
|
||||
require(repositoryReg.getBranch(repoId) == keccak256(_branch));
|
||||
require(repositoryOracle.getBranch(repoId) == keccak256(_branch));
|
||||
}
|
||||
|
||||
function start(string _repository, string _branch, string _token) public payable {
|
||||
getRepository(_repository, _branch);
|
||||
gitHubPoints.start.value(msg.value)(_repository, _branch, _token);
|
||||
pointsOracle.start.value(msg.value)(_repository, _branch, _token);
|
||||
}
|
||||
|
||||
function update(string _repository, string _branch, string _token) public payable {
|
||||
uint256 repoId = getRepository(_repository, _branch);
|
||||
gitHubPoints.update.value(msg.value)(
|
||||
pointsOracle.update.value(msg.value)(
|
||||
_repository,
|
||||
_branch,
|
||||
repositories[repoId].head,
|
||||
|
@ -72,7 +71,7 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
string memory claimedCommit = repositories[repoId].pending[_pendingTail];
|
||||
require(bytes(claimedCommit).length != 0);
|
||||
delete repositories[repoId].pending[_pendingTail];
|
||||
gitHubPoints.resume.value(msg.value)(
|
||||
pointsOracle.resume.value(msg.value)(
|
||||
_repository,
|
||||
_branch,
|
||||
_pendingTail,
|
||||
|
@ -83,7 +82,7 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
|
||||
function rtail(string _repository, string _branch, string _token) public payable {
|
||||
uint256 repoId = getRepository(_repository, _branch);
|
||||
gitHubPoints.rtail.value(msg.value)(
|
||||
pointsOracle.rtail.value(msg.value)(
|
||||
_repository,
|
||||
_branch,
|
||||
repositories[repoId].tail,
|
||||
|
@ -92,39 +91,35 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
}
|
||||
|
||||
function issue(string _repository, string _issue, string _token) public payable {
|
||||
gitHubPoints.issue.value(msg.value)(_repository, _issue, _token);
|
||||
pointsOracle.issue.value(msg.value)(_repository, _issue, _token);
|
||||
}
|
||||
|
||||
//claims pending points
|
||||
function claimPending(uint _repoId, uint _userId) public {
|
||||
GitRepositoryI repoaddr = GitRepositoryI(repositoryReg.getAddr(_repoId));
|
||||
GitRepositoryI repoaddr = GitRepositoryI(repositoryOracle.getAddr(_repoId));
|
||||
uint total = pending[_userId][_repoId];
|
||||
delete pending[_userId][_repoId];
|
||||
require(repoaddr.claim(userReg.getAddr(_userId), total));
|
||||
require(repoaddr.claim(userOracle.getAddr(_userId), total));
|
||||
}
|
||||
|
||||
function initRegs() public onlyController {
|
||||
if (address(userReg) == 0) {
|
||||
userReg = GHUserReg.create();
|
||||
}
|
||||
if (address(repositoryReg) == 0) {
|
||||
repositoryReg = GHRepoReg.create();
|
||||
}
|
||||
function setUserOracle(address _userOracle) public onlyController {
|
||||
userOracle = UserOracle(_userOracle);
|
||||
}
|
||||
|
||||
function setPointsScript(string _arg) public onlyController {
|
||||
if (address(gitHubPoints) == 0) {
|
||||
gitHubPoints = GHPoints.create(_arg);
|
||||
} else {
|
||||
gitHubPoints.setScript(_arg);
|
||||
}
|
||||
function setRepositoryOracle(address _repoOracle) public onlyController {
|
||||
repositoryOracle = RepositoryOracle(_repoOracle);
|
||||
}
|
||||
|
||||
function setPointsOracle(address _pointsOracle) public onlyController {
|
||||
pointsOracle = PointsOracle(_pointsOracle);
|
||||
}
|
||||
|
||||
|
||||
function upgradeContract(address _newContract) public onlyController {
|
||||
require(_newContract != 0);
|
||||
userReg.changeController(_newContract);
|
||||
repositoryReg.changeController(_newContract);
|
||||
gitHubPoints.changeController(_newContract);
|
||||
userOracle.changeController(_newContract);
|
||||
repositoryOracle.changeController(_newContract);
|
||||
pointsOracle.changeController(_newContract);
|
||||
newContract = _newContract;
|
||||
if (this.balance > 0) {
|
||||
_newContract.transfer(this.balance);
|
||||
|
@ -134,7 +129,7 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
function upgrade(uint[] _repoIds) public onlyUpgrading onlyController {
|
||||
uint len = _repoIds.length;
|
||||
for (uint i = 0; i < len; i++) {
|
||||
Controlled(repositoryReg.getAddr(_repoIds[i])).changeController(newContract);
|
||||
Controlled(repositoryOracle.getAddr(_repoIds[i])).changeController(newContract);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +154,7 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
public
|
||||
package
|
||||
{
|
||||
GitRepositoryI repo = GitRepositoryI(repositoryReg.getAddr(_projectId));
|
||||
GitRepositoryI repo = GitRepositoryI(repositoryOracle.getAddr(_projectId));
|
||||
repo.setBounty(_issueId, _state, _closedAt);
|
||||
}
|
||||
|
||||
|
@ -172,21 +167,21 @@ contract GitHubOracle is Controlled, DGitI {
|
|||
public
|
||||
package
|
||||
{
|
||||
GitRepositoryI repo = GitRepositoryI(repositoryReg.getAddr(_projectId));
|
||||
GitRepositoryI repo = GitRepositoryI(repositoryOracle.getAddr(_projectId));
|
||||
uint len = _userId.length;
|
||||
for (uint i = 0; i < len; i++) {
|
||||
address addr = userReg.getAddr(_userId[i]);
|
||||
address addr = userOracle.getAddr(_userId[i]);
|
||||
repo.setBountyPoints(_issueId, addr, _points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function newPoints(uint _repoId, uint[] _userIds, uint[] _points) public package {
|
||||
GitRepositoryI repo = GitRepositoryI(repositoryReg.getAddr(_repoId));
|
||||
GitRepositoryI repo = GitRepositoryI(repositoryOracle.getAddr(_repoId));
|
||||
uint len = _userIds.length;
|
||||
for (uint i = 0; i < len; i++) {
|
||||
uint _userId = _userIds[i];
|
||||
uint _uPoints = _points[i];
|
||||
address addr = userReg.getAddr(_userId);
|
||||
address addr = userOracle.getAddr(_userId);
|
||||
if (addr == 0x0 || !repo.claim(addr, _uPoints)) {
|
||||
pending[_userId][_repoId] += _uPoints;
|
||||
}
|
|
@ -2,7 +2,7 @@ pragma solidity ^0.4.11;
|
|||
|
||||
import "./bank/CollaborationBank.sol";
|
||||
import "./bank/BountyBank.sol";
|
||||
import "./management/Controlled.sol";
|
||||
import "./common/Controlled.sol";
|
||||
|
||||
|
||||
contract GitRepositoryI is Controlled {
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
|
||||
import "./oraclize/oraclizeAPI_0.4.sol";
|
||||
import "./management/Controlled.sol";
|
||||
import "./helpers/strings.sol";
|
||||
pragma solidity ^0.4.10;
|
||||
|
||||
import "./common/oraclizeAPI_0.4.sol";
|
||||
import "./common/Controlled.sol";
|
||||
import "./common/strings.sol";
|
||||
|
||||
/**
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
*/
|
||||
contract DGitI {
|
||||
contract GitPivotI {
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,7 +53,7 @@ contract DGitI {
|
|||
/**
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
*/
|
||||
contract GitHubPoints is Controlled, usingOraclize {
|
||||
contract PointsOracle is Controlled, usingOraclize {
|
||||
|
||||
event OracleEvent(bytes32 myid, string result, bytes proof);
|
||||
using strings for string;
|
||||
|
@ -222,7 +221,7 @@ contract GitHubPoints is Controlled, usingOraclize {
|
|||
*/
|
||||
function __callback(bytes32 myid, string result, bytes proof) public {
|
||||
OracleEvent(myid, result, proof);
|
||||
require (msg.sender == oraclize.cbAddress());
|
||||
require (msg.sender == oraclize.cbAddress());
|
||||
processRequest(bytes(result), request[myid]);
|
||||
delete request[myid];
|
||||
}
|
||||
|
@ -233,20 +232,19 @@ contract GitHubPoints is Controlled, usingOraclize {
|
|||
function processRequest(bytes v, Request _request)
|
||||
internal
|
||||
{
|
||||
DGitI dGit = DGitI(controller);
|
||||
GitPivotI pivot = GitPivotI(controller);
|
||||
uint8 pos = 0;
|
||||
string memory temp;
|
||||
uint256 projectId;
|
||||
uint256 issueId;
|
||||
uint256 projectId;
|
||||
uint256 issueId;
|
||||
(projectId, pos) = getNextUInt(v, pos);
|
||||
|
||||
if (_request.command == Command.ISSUE) {
|
||||
(issueId, pos) = getNextUInt(v, pos);
|
||||
(temp, pos) = getNextString(v, pos);//temp = issue state
|
||||
uint256 closedAt;
|
||||
(closedAt, pos) = getNextUInt(v, pos);
|
||||
bool open = keccak256("open") == keccak256(temp);
|
||||
dGit.setIssue(
|
||||
bool open = (keccak256("open") == keccak256(temp));
|
||||
pivot.setIssue(
|
||||
projectId,
|
||||
issueId,
|
||||
open,
|
||||
|
@ -259,15 +257,15 @@ contract GitHubPoints is Controlled, usingOraclize {
|
|||
|
||||
if (_request.command == Command.START || _request.command == Command.UPDATE) {
|
||||
(temp, pos) = getNextString(v, pos); //temp = scan head
|
||||
dGit.setHead(projectId, temp);
|
||||
pivot.setHead(projectId, temp);
|
||||
}
|
||||
(temp,pos) = getNextString(v,pos); //temp = scan tail
|
||||
if (_request.command == Command.START || _request.command == Command.RTAIL) {
|
||||
dGit.setTail(projectId, temp);
|
||||
pivot.setTail(projectId, temp);
|
||||
}
|
||||
if ((_request.command == Command.RESUME || _request.command == Command.UPDATE) && keccak256(_request.lastCommit) != keccak256(temp)) {
|
||||
//update didn't reached _lastCommit
|
||||
dGit.pendingScan(projectId, temp, _request.lastCommit);
|
||||
pivot.pendingScan(projectId, temp, _request.lastCommit);
|
||||
}
|
||||
}
|
||||
uint numAuthors;
|
||||
|
@ -279,21 +277,21 @@ contract GitHubPoints is Controlled, usingOraclize {
|
|||
(points[i],pos) = getNextUInt(v,pos);
|
||||
}
|
||||
if (_request.command == Command.ISSUE) {
|
||||
dGit.setIssuePoints(
|
||||
pivot.setIssuePoints(
|
||||
projectId,
|
||||
issueId,
|
||||
userId,
|
||||
points
|
||||
);
|
||||
} else {
|
||||
dGit.newPoints(projectId,userId,points);
|
||||
pivot.newPoints(projectId,userId,points);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function GitHubPoints(string _script) {
|
||||
function PointsOracle(string _script) {
|
||||
script = _script;
|
||||
}
|
||||
|
||||
|
@ -499,16 +497,4 @@ contract GitHubPoints is Controlled, usingOraclize {
|
|||
}
|
||||
return (val, _pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
library GHPoints {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function create(string _script) public returns (GitHubPoints) {
|
||||
return new GitHubPoints(_script);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +1,24 @@
|
|||
pragma solidity ^0.4.11;
|
||||
|
||||
import "./GitHubAPIReg.sol";
|
||||
import "./management/NameRegistry.sol";
|
||||
import "./management/RegistryIndex.sol";
|
||||
import "./GitRepository.sol";
|
||||
import "./helpers/strings.sol";
|
||||
import "./common/strings.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title GitHubRepositoryReg.sol
|
||||
* @title RepositoryOracle
|
||||
* Registers the master branch of a Repository for GitHubOracle tracking.
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)]
|
||||
*/
|
||||
contract GitHubRepositoryReg is NameRegistry, GitHubAPIReg {
|
||||
contract RepositoryOracle is GitHubAPIReg, RegistryIndex {
|
||||
using strings for string;
|
||||
using strings for strings.slice;
|
||||
|
||||
mapping (uint256 => Repository) public repositories;
|
||||
mapping (uint256 => bytes32) public branch;
|
||||
|
||||
event NewRepository(address addr, uint256 projectId, string fullName, string defaultBranch);
|
||||
|
||||
struct Repository {
|
||||
address addr;
|
||||
string name;
|
||||
bytes32 branch;
|
||||
}
|
||||
|
||||
function register(string _repository, string _cred) payable {
|
||||
if (bytes(_cred).length == 0) {
|
||||
_cred = cred;
|
||||
|
@ -36,23 +30,7 @@ contract GitHubRepositoryReg is NameRegistry, GitHubAPIReg {
|
|||
gas
|
||||
);
|
||||
}
|
||||
|
||||
function getAddr(uint256 _id) public constant returns(address addr) {
|
||||
return repositories[_id].addr;
|
||||
}
|
||||
|
||||
function getName(address _addr) public constant returns(string name) {
|
||||
return repositories[indexes[keccak256(_addr)]].name;
|
||||
}
|
||||
|
||||
function getAddr(string _name) public constant returns(address addr) {
|
||||
return repositories[indexes[keccak256(_name)]].addr;
|
||||
}
|
||||
|
||||
function getBranch(uint256 _id) public constant returns(bytes32 branch) {
|
||||
return repositories[_id].branch;
|
||||
}
|
||||
|
||||
|
||||
//oraclize response callback
|
||||
function __callback(bytes32 myid, string result, bytes proof) {
|
||||
OracleEvent(myid, result, proof);
|
||||
|
@ -71,21 +49,16 @@ contract GitHubRepositoryReg is NameRegistry, GitHubAPIReg {
|
|||
(full_name, pos) = getNextString(v, pos);
|
||||
string memory default_branch;
|
||||
(default_branch, pos) = getNextString(v, pos);
|
||||
address repoAddr = repositories[projectId].addr;
|
||||
address repoAddr = registry[projectId].addr;
|
||||
if (repoAddr == 0x0) {
|
||||
NewRepository(repoAddr, projectId, full_name, default_branch);
|
||||
GitRepositoryI repo = new GitRepository(projectId, full_name);
|
||||
repo.changeController(controller);
|
||||
repoAddr = address(repo);
|
||||
indexes[keccak256(repoAddr)] = projectId;
|
||||
indexes[keccak256(full_name)] = projectId;
|
||||
NewRepository(repoAddr, projectId, full_name, default_branch);
|
||||
repositories[projectId] = Repository({addr: repoAddr, name: full_name, branch: keccak256(default_branch)});
|
||||
repoAddr = address(repo);
|
||||
branch[projectId] = keccak256(default_branch);
|
||||
setRegistry(repoAddr, projectId, full_name);
|
||||
} else {
|
||||
bytes32 _new = keccak256(full_name);
|
||||
bytes32 _old = keccak256(repositories[projectId].name);
|
||||
if(_new != _old){
|
||||
_updateIndex(_old, _new);
|
||||
}
|
||||
updateIndex(repositories[projectId].name, full_name);
|
||||
}
|
||||
}
|
||||
//internal helper functions
|
||||
|
@ -98,12 +71,3 @@ contract GitHubRepositoryReg is NameRegistry, GitHubAPIReg {
|
|||
return strings.toSlice("").join(cm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
library GHRepoReg {
|
||||
|
||||
function create() returns (GitHubRepositoryReg) {
|
||||
return new GitHubRepositoryReg();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +1,20 @@
|
|||
pragma solidity ^0.4.11;
|
||||
|
||||
import "./GitHubAPIReg.sol";
|
||||
import "./management/NameRegistry.sol";
|
||||
import "./helpers/strings.sol";
|
||||
|
||||
import "./common/strings.sol";
|
||||
import "./management/RegistryIndex.sol";
|
||||
|
||||
/**
|
||||
* @title GitHubUserReg.sol
|
||||
* Registers GitHub user login to an address
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)]
|
||||
*/
|
||||
contract GitHubUserReg is NameRegistry, GitHubAPIReg {
|
||||
contract UserOracle is GitHubAPIReg, RegistryIndex {
|
||||
using strings for string;
|
||||
using strings for strings.slice;
|
||||
|
||||
mapping (bytes32 => UserClaim) userClaim; //temporary db for oraclize user register queries
|
||||
mapping (uint256 => User) users;
|
||||
|
||||
|
||||
event RegisterUpdated(string name);
|
||||
|
||||
|
@ -24,31 +23,16 @@ contract GitHubUserReg is NameRegistry, GitHubAPIReg {
|
|||
address sender;
|
||||
string login;
|
||||
}
|
||||
|
||||
|
||||
struct User {
|
||||
address addr;
|
||||
string login;
|
||||
}
|
||||
|
||||
function register(string _github_user, string _gistid, string _cred) public payable {
|
||||
function register(string _githubUser, string _gistId, string _cred) public payable {
|
||||
if (bytes(_cred).length == 0) {
|
||||
_cred = cred;
|
||||
}
|
||||
bytes32 ocid = oraclize_query("nested", _query_script(_github_user, _gistid,_cred));
|
||||
userClaim[ocid] = UserClaim({sender: msg.sender, login: _github_user});
|
||||
bytes32 ocid = oraclize_query("nested", _queryScript(_githubUser, _gistId, _cred));
|
||||
userClaim[ocid] = UserClaim({sender: msg.sender, login: _githubUser});
|
||||
}
|
||||
|
||||
function getAddr(uint256 _id) public constant returns(address addr) {
|
||||
return users[_id].addr;
|
||||
}
|
||||
|
||||
function getName(address _addr) public constant returns(string name) {
|
||||
return users[indexes[keccak256(_addr)]].login;
|
||||
}
|
||||
|
||||
function getAddr(string _name) public constant returns(address addr) {
|
||||
return users[indexes[keccak256(_name)]].addr;
|
||||
}
|
||||
|
||||
//oraclize response callback
|
||||
function __callback(bytes32 myid, string result, bytes proof) public {
|
||||
|
@ -68,38 +52,22 @@ contract GitHubUserReg is NameRegistry, GitHubAPIReg {
|
|||
(userId, pos) = getNextUInt(v, pos);
|
||||
if (userClaim[myid].sender == addrLoaded && keccak256(userClaim[myid].login) == keccak256(login)) {
|
||||
RegisterUpdated(login);
|
||||
if (users[userId].addr != 0x0) {
|
||||
delete indexes[keccak256(users[userId].login)];
|
||||
delete indexes[keccak256(users[userId].addr)];
|
||||
}
|
||||
indexes[keccak256(addrLoaded)] = userId;
|
||||
indexes[keccak256(login)] = userId;
|
||||
users[userId].addr = addrLoaded;
|
||||
users[userId].login = login;
|
||||
setRegistry(userId, addrLoaded, login);
|
||||
}
|
||||
delete userClaim[myid];
|
||||
}
|
||||
|
||||
function _query_script(string _github_user, string _gistid, string _cred) internal returns (string) {
|
||||
function _queryScript(string _githubUser, string _gistId, string _cred) internal returns (string) {
|
||||
strings.slice[] memory cm = new strings.slice[](8);
|
||||
cm[0] = strings.toSlice("[identity] ${[URL] https://gist.githubusercontent.com/");
|
||||
cm[1] = _github_user.toSlice();
|
||||
cm[1] = _githubUser.toSlice();
|
||||
cm[2] = strings.toSlice("/");
|
||||
cm[3] = _gistid.toSlice();
|
||||
cm[3] = _gistId.toSlice();
|
||||
cm[4] = strings.toSlice("/raw/register.txt}, ${[URL] json(https://api.github.com/gists/");
|
||||
cm[5] = _gistid.toSlice();
|
||||
cm[5] = _gistId.toSlice();
|
||||
cm[6] = _cred.toSlice();
|
||||
cm[7] = strings.toSlice(").owner.[login,id]}");
|
||||
return strings.toSlice("").join(cm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
library GHUserReg {
|
||||
|
||||
function create() returns (GitHubUserReg) {
|
||||
return new GitHubUserReg();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
pragma solidity ^0.4.11;
|
||||
|
||||
import "../management/Controlled.sol";
|
||||
import "../common/Controlled.sol";
|
||||
|
||||
/**
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pragma solidity ^0.4.10;
|
||||
|
||||
import "../token/MiniMeToken.sol";
|
||||
import "../common/MiniMeToken.sol";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
pragma solidity ^0.4.11;
|
||||
|
||||
import "../token/TokenLedger.sol";
|
||||
import "../management/Controlled.sol";
|
||||
import "../management/TokenLedger.sol";
|
||||
import "../common/Controlled.sol";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
pragma solidity ^0.4.14;
|
||||
|
||||
/**
|
||||
* @title TokenReceiver
|
||||
* @dev Used by ERC223
|
||||
*/
|
||||
contract ERC223Receiver {
|
||||
function tokenFallback(address _from, uint _value, bytes _data);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
pragma solidity ^0.4.14;
|
||||
|
||||
import "./ERC20.sol";
|
||||
import "./ERC677Receiver.sol";
|
||||
|
||||
contract ERC677 is ERC20 {
|
||||
function transferAndCall(address receiver, uint amount, bytes data) returns (bool success) {
|
||||
require(transfer(receiver, amount));
|
||||
return _postTransferCall(receiver, amount, data);
|
||||
}
|
||||
|
||||
function _postTransferCall(address receiver, uint amount, bytes data) internal returns (bool success) {
|
||||
return ERC677Receiver(receiver).tokenFallback(msg.sender, amount, data);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
pragma solidity ^0.4.14;
|
||||
|
||||
/**
|
||||
* @title TokenReceiver
|
||||
* @dev Used by ERC677
|
||||
*/
|
||||
contract TokenReceiver {
|
||||
function tokenFallback(address _from, uint _value, bytes _data) public returns (bool);
|
||||
}
|
|
@ -25,7 +25,7 @@ pragma solidity ^0.4.6;
|
|||
/// affecting the original token
|
||||
/// @dev It is ERC20 compliant, but still needs to under go further testing.
|
||||
|
||||
import "../management/Controlled.sol";
|
||||
import "./Controlled.sol";
|
||||
import "./TokenController.sol";
|
||||
import "./ApproveAndCallFallBack.sol";
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
pragma solidity ^0.4.11;
|
||||
|
||||
/**
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
* @title NameRegistry
|
||||
* Interface for Name Registries.
|
||||
*/
|
||||
contract NameRegistry {
|
||||
function getAddr(uint256 _id) public constant returns(address addr);
|
||||
function getAddr(string _name) public constant returns(address addr);
|
||||
function getName(address _addr) public constant returns(string name);
|
||||
|
||||
mapping (bytes32 => uint256) indexes;
|
||||
|
||||
function getId(address _addr) public constant returns(uint256 id){
|
||||
return indexes[keccak256(_addr)];
|
||||
}
|
||||
|
||||
function getId(string _name) public constant returns(uint256 id) {
|
||||
return indexes[keccak256(_name)];
|
||||
}
|
||||
|
||||
function _updateIndex(bytes32 _old, bytes32 _new) internal {
|
||||
indexes[_new] = indexes[_old];
|
||||
delete indexes[_old];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
pragma solidity ^0.4.11;
|
||||
|
||||
/**
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
* @title RegistryIndex
|
||||
* @dev abstract registry index handling.
|
||||
*/
|
||||
contract RegistryIndex {
|
||||
|
||||
string private constant STR_PREFIX = "name";
|
||||
string private constant ADDR_PREFIX = "address";
|
||||
mapping (bytes32 => uint256) private indexes;
|
||||
mapping (uint256 => Registry) public registry;
|
||||
|
||||
struct Registry {
|
||||
address addr;
|
||||
string name;
|
||||
}
|
||||
|
||||
function getAddr(uint256 _id) public constant returns(address addr) {
|
||||
return registry[_id].addr;
|
||||
}
|
||||
|
||||
function getName(address _addr) public constant returns(string name) {
|
||||
return registry[getId(_addr)].name;
|
||||
}
|
||||
|
||||
function getAddr(string _name) public constant returns(address addr) {
|
||||
return registry[getId(_name)].addr;
|
||||
}
|
||||
|
||||
function getId(address _addr) public constant returns(uint256 id){
|
||||
return indexes[keccak256(ADDR_PREFIX, _addr)];
|
||||
}
|
||||
|
||||
function getId(string _name) public constant returns(uint256 id) {
|
||||
return indexes[keccak256(STR_PREFIX, _name)];
|
||||
}
|
||||
|
||||
function setRegistry(uint _uid, address _addr, string _name) internal {
|
||||
if (registry[_uid].addr != 0x0) {
|
||||
delete indexes[keccak256(ADDR_PREFIX, _addr)];
|
||||
delete indexes[keccak256(STR_PREFIX, _name)];
|
||||
}
|
||||
indexes[keccak256(ADDR_PREFIX, _addr)] = _uid;
|
||||
indexes[keccak256(STR_PREFIX, _name)] = _uid;
|
||||
registry[_uid] = Registry(
|
||||
{
|
||||
addr: _addr,
|
||||
name: _name
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function setIndex(uint256 _uid, address _addr) internal {
|
||||
indexes[keccak256(ADDR_PREFIX, _addr)] = _uid;
|
||||
}
|
||||
|
||||
function setIndex(uint256 _uid, string _name) internal {
|
||||
indexes[keccak256(STR_PREFIX, _name)] = _uid;
|
||||
}
|
||||
|
||||
function clearIndex(address _addr) internal {
|
||||
delete indexes[keccak256(ADDR_PREFIX, _addr)];
|
||||
}
|
||||
|
||||
function clearIndex(string _name) internal {
|
||||
delete indexes[keccak256(STR_PREFIX, _name)];
|
||||
}
|
||||
|
||||
function updateIndex(bytes32 _old, bytes32 _new) private {
|
||||
if (_old != _new) {
|
||||
indexes[_new] = indexes[_old];
|
||||
delete indexes[_old];
|
||||
}
|
||||
}
|
||||
|
||||
function updateIndex(string _old, string _new) internal {
|
||||
updateIndex(keccak256(STR_PREFIX, _old), keccak256(STR_PREFIX, _new));
|
||||
}
|
||||
|
||||
function updateIndex(address _old, address _new) internal {
|
||||
updateIndex(keccak256(ADDR_PREFIX, _old), keccak256(ADDR_PREFIX, _new));
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
pragma solidity ^0.4.14;
|
||||
|
||||
import "./ERC223.sol";
|
||||
import "./MiniMeToken.sol";
|
||||
import "./ERC223Receiver.sol";
|
||||
import "../common/ERC223.sol";
|
||||
import "../common/MiniMeToken.sol";
|
||||
import "../common/ERC223Receiver.sol";
|
||||
/**
|
||||
* @title TokenLedger
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
|
@ -9,8 +9,5 @@ module.exports = function(deployer) {
|
|||
deployer.deploy(strings);
|
||||
deployer.link(strings, [GHUserReg, GHRepoReg, GHPoints]);
|
||||
deployer.deploy([[GHUserReg], [GHRepoReg], [GHPoints]]);
|
||||
deployer.link(GHUserReg, GitHubOracle);
|
||||
deployer.link(GHRepoReg, GitHubOracle);
|
||||
deployer.link(GHPoints, GitHubOracle);
|
||||
deployer.deploy(GitHubOracle);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue