Skip to content

Instantly share code, notes, and snippets.

@cicorias
Forked from elenadimitrova/Parent.sol
Created March 15, 2017 09:17
Show Gist options
  • Save cicorias/d42afe1c554a8e004e625da975c9771a to your computer and use it in GitHub Desktop.
Save cicorias/d42afe1c554a8e004e625da975c9771a to your computer and use it in GitHub Desktop.
import "Organisation.sol";
import "TokenLedger.sol";
import "EternalStorage.sol";
contract Parent {
event OrganisationCreated(address organisation, uint now);
event OrganisationUpgraded(address organisation, uint now);
mapping(bytes32 => address) public organisations;
function createOrganisation(bytes32 key_)
{
var tokenLedger = new TokenLedger();
var eternalStorage = new EternalStorage();
var organisation = new Organisation(tokenLedger, eternalStorage);
organisations[key_] = organisation;
OrganisationCreated(organisation, now);
}
function getOrganisation(bytes32 key_) constant returns (address)
{
return organisations[key_];
}
function upgradeOrganisation(bytes32 key_)
{
address organisationAddress = organisations[key_];
var organisation = Organisation(organisationAddress);
var tokenLedger = organisation.tokenLedger();
var eternalStorage = organisation.eternalStorage();
Organisation organisationNew = new Organisation(tokenLedger, eternalStorage);
organisation.kill(organisationNew);
organisations[key_] = organisationNew;
OrganisationUpgraded(organisationNew, now);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment