Created
September 25, 2018 20:01
-
-
Save spalladino/2254a2058b35f7558c49d9d83b6422d8 to your computer and use it in GitHub Desktop.
Sample package 2.0 contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract RepoPackage { | |
event NewVersion(uint256 versionId, uint16[3] semanticVersion); | |
struct Version { | |
uint16[3] semanticVersion; | |
address contractAddress; | |
bytes contentURI; | |
} | |
mapping (bytes32 => Version) versions; | |
function newVersion(uint16[3] _newSemanticVersion, address _contractAddress, bytes _contentURI) public { | |
versions[semanticVersionHash(_newSemanticVersion)] = Version(_newSemanticVersion, _contractAddress, _contentURI); | |
} | |
function getBySemanticVersion(uint16[3] _semanticVersion) public view returns (uint16[3], address, bytes); | |
Version storage version = versions[semanticVersionHash(_semanticVersion)]; | |
return (version.semanticVersion, version.contractAddress, version.contentURI); | |
} | |
function semanticVersionHash(uint16[3] version) internal pure returns (bytes32) { | |
return keccak256(abi.encodePacked(version[0], version[1], version[2])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment