Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions contracts/Organisation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ contract Organisation is DataVerifiable
using SecurityLibrary for address;
address public eternalStorage;

function Organisation(address _tokenLedger, address _eternalStorage) {
tokenLedger = ITokenLedger(_tokenLedger);
eternalStorage = _eternalStorage;
}

modifier onlyAdmins {
if (!eternalStorage.isUserAdmin(msg.sender)) throw;
_;
}

function setDataStore(address _tokenLedger, address _eternalStorage) {
tokenLedger = ITokenLedger(_tokenLedger);
eternalStorage = _eternalStorage;
}

function addProposal(bytes32 _name)
onlyAdmins
refundEtherSentByAccident
Expand Down
33 changes: 33 additions & 0 deletions contracts/OrganisationInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pragma solidity ^0.4.8;

import "./DataVerifiable.sol";
import "./ITokenLedger.sol";

contract OrganisationInterface is DataVerifiable
{
function tokenLedger() constant returns (ITokenLedger);

function eternalStorage() constant returns (address);

function setDataStore(address _tokenLedger, address _eternalStorage);

function addProposal(bytes32 _name);

function proposalsCount() constant returns (uint256);

function getProposal(uint256 _id) constant returns (bytes32 _name, uint256 _eth);

function updateProposal(uint256 _id, bytes32 _name);

function fundProposal(uint256 _id);

function setProposalFund(uint256 _id, uint256 _eth);

function generateTokens(uint256 _amount);

function getBalance(address _account) constant returns (uint256);

function setTokenLedgerAddress(address _tokenLedger);

function kill(address upgradedOrganisation_);
}
79 changes: 0 additions & 79 deletions contracts/OrganisationUpdated.sol

This file was deleted.

26 changes: 12 additions & 14 deletions contracts/Parent.sol
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
pragma solidity ^0.4.8;

import "./Organisation.sol";
import "./OrganisationUpdated.sol";
import "./OrganisationInterface.sol";
import "./TokenLedger.sol";
import "./EternalStorage.sol";
import "./SecurityLibrary.sol";

contract Parent {

event OrganisationCreated(address organisation, uint now);
event OrganisationUpgraded(address organisation, uint now);

using SecurityLibrary for EternalStorage;

mapping(bytes32 => address) public organisations;

function createOrganisation(bytes32 key_)
function registerOrganisation(bytes32 key_, address orgAddress)
{

var tokenLedger = new TokenLedger();
var eternalStorage = new EternalStorage();
// Set the calling user as the first colony admin
eternalStorage.addAdmin(msg.sender);

var organisation = new Organisation(tokenLedger, eternalStorage);
OrganisationInterface(orgAddress).setDataStore(tokenLedger, eternalStorage);
// Set the organisation as the storage owner
eternalStorage.changeOwner(organisation);
eternalStorage.changeOwner(orgAddress);

organisations[key_] = organisation;
OrganisationCreated(organisation, now);
organisations[key_] = orgAddress;
}

function getOrganisation(bytes32 key_) constant returns (address)
{
return organisations[key_];
}

function upgradeOrganisation(bytes32 key_)
function upgradeOrganisation(bytes32 key_, address newOrgAddress)
{
address organisationAddress = organisations[key_];
var organisation = Organisation(organisationAddress);
var organisation = OrganisationInterface(organisationAddress);
var tokenLedger = organisation.tokenLedger();
var eternalStorage = organisation.eternalStorage();

OrganisationUpdated organisationNew = new OrganisationUpdated(tokenLedger, eternalStorage);
OrganisationInterface(newOrgAddress).setDataStore(tokenLedger, eternalStorage);

organisation.kill(organisationNew);
organisation.kill(newOrgAddress);

organisations[key_] = organisationNew;
OrganisationUpgraded(organisationNew, now);
organisations[key_] = newOrgAddress;
OrganisationUpgraded(newOrgAddress, now);
}
}
13 changes: 13 additions & 0 deletions migrations/2_deploy_parent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var EternalStorage = artifacts.require("./EternalStorage.sol");
var SecurityLibrary = artifacts.require("./SecurityLibrary.sol");
var TokenLedger = artifacts.require("./TokenLedger.sol");
var Parent = artifacts.require("./Parent.sol");

module.exports = function(deployer) {
deployer.deploy(EternalStorage);
deployer.deploy(SecurityLibrary);
deployer.deploy(TokenLedger);

deployer.link(SecurityLibrary, Parent);
deployer.deploy(Parent);
};
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
var DataVerifiable = artifacts.require("./DataVerifiable.sol");
var EternalStorage = artifacts.require("./EternalStorage.sol");
var Organisation = artifacts.require("./Organisation.sol");
var OrganisationUpdated = artifacts.require("./OrganisationUpdated.sol");
var Ownable = artifacts.require("./Ownable.sol");
var Parent = artifacts.require("./Parent.sol");
var ProposalsLibrary = artifacts.require("./ProposalsLibrary.sol");
var SecurityLibrary = artifacts.require("./SecurityLibrary.sol");
var TokenLedger = artifacts.require("./TokenLedger.sol");

module.exports = function(deployer) {
deployer.deploy(DataVerifiable);
deployer.deploy(EternalStorage);
deployer.deploy(OrganisationUpdated);
deployer.deploy(Ownable);
deployer.deploy(TokenLedger);

deployer.deploy(ProposalsLibrary);
deployer.deploy(SecurityLibrary);

deployer.link(ProposalsLibrary, Organisation);
deployer.link(SecurityLibrary, Organisation);
deployer.deploy(Organisation);

deployer.link(ProposalsLibrary, Parent);
deployer.link(SecurityLibrary, Parent);
deployer.deploy(Parent);
};