pragma solidity ^0.5.9; contract DAppContract { enum SDCType {"DC", "AC", "DU"}; enum ConsentStatus {"OptIn", "OptOut"}; mapping (string => uint) statusToEventTimer; enum ConsentModel {"auto_opt_in", "explicit_opt_in"}; ConsentModel consent_model; event StatusChanged(string status); address organizerAddr; mapping (string => address) public vendorToCreator; struct Organizer { SDCType type; string vendorId; uint joinedAt; //timestamp uint exitedAt; } struct Creator { SDCType type; string vendorId; uint joinedAt; //timestamp uint exitedAt; } Creator[] public creators; struct Subcriber { SDCType type; // 'DU' string vendorId; } struct Investor { string podId; uint joinedAt; //timestamp uint exitedAt; ConsentStatus status; } Investor[] private investors; struct DataSource { string type; // localtion/activity string format; uint size; // kilobyte uint8 timeRange; // months of data / years of data string genderPercentage; string country; } DataSource[] private dataSources; struct AlgorithmReq { string dataType; string dataFormat; uint minSize; // kilobyte string environment; string dependencies; } struct ReportInfo { string level; // LOW/MEDIUM/HIGH string type; // data/algo/payment string message; // invalid message } struct ErrorInfo { string level; // INFO/WARNING/ERROR string type; // data/algo/network/server string message; // error message } function createSDC(string type, string vendorId) public { // check permission here - should use ownable // require(); // store addresses of organizer and creators organizerAddr = Organizer(type, vendorId, now, '')); id = creators.push(Creator(type, vendorId, now, '')); vendorToCreator[id] = msg.sender; // data_sources = array of DCes’ addresses if (keccak256(abi.encodePacked((SDCType.DC))) == keccak256(abi.encodePacked((type)))) { // dataSources.push(msg.sender); // how can i get DCes' addresses?? } // investors = array of DSes’ addresses // algorithm_requirements : follow the doc // status = “definition" emit StatusChanged("definition"); // created_at = timestamp in miliseconds statusToEventTimer["definition"] = now; // consent_model = “auto_opt_in" consent_model = ConsentModel.auto_opt_in; } function onFunding() { //todo: sth like trigger // change status to “funding" emit StatusChanged("funding"); statusToEventTimer["funding"] = now; } function publish() { // change status of SDC to “published" emit StatusChanged("published"); statusToEventTimer["published"] = now; } function joinDC() { // append DC’s address into data_sources } function DUSubscribe() { // add DU’s address into subscribers // change status of SDC to “subscribed" emit StatusChanged("subscribed"); statusToEventTimer["subscribed"] = now; } function DSConsent() { // append DS’s address into investor } function ACRequirement() { // add data requirement follow the doc. } }
0.5.9