Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dogfood the package index #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ chains/
*.sqlite
.env
public/
installed_packages/
91 changes: 0 additions & 91 deletions contracts/IndexedOrderedSetLib.sol

This file was deleted.

9 changes: 4 additions & 5 deletions contracts/PackageDB.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
pragma solidity ^0.4.0;

import {SemVersionLib} from "./SemVersionLib.sol";
import {IndexedOrderedSetLib} from "./IndexedOrderedSetLib.sol";
import {IndexedEnumerableSetLib} from "indexed-enumerable-set-lib/contracts/IndexedEnumerableSetLib.sol";

import {Authorized} from "./Authority.sol";


/// @title Database contract for a package index package data.
/// @author Tim Coulter <[email protected]>, Piper Merriam <[email protected]>
contract PackageDB is Authorized {
using SemVersionLib for SemVersionLib.SemVersion;
using IndexedOrderedSetLib for IndexedOrderedSetLib.IndexedOrderedSet;
using IndexedEnumerableSetLib for IndexedEnumerableSetLib.IndexedEnumerableSet;

struct Package {
bool exists;
Expand All @@ -21,7 +20,7 @@ contract PackageDB is Authorized {

// Package Data: (nameHash => value)
mapping (bytes32 => Package) _recordedPackages;
IndexedOrderedSetLib.IndexedOrderedSet _allPackageNameHashes;
IndexedEnumerableSetLib.IndexedEnumerableSet _allPackageNameHashes;

// Events
event PackageReleaseAdd(bytes32 indexed nameHash, bytes32 indexed releaseHash);
Expand Down
17 changes: 10 additions & 7 deletions contracts/PackageIndex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,24 @@ contract PackageIndex is Authorized, PackageIndexInterface {

/// @dev Returns the release data for the release associated with the given release hash.
/// @param releaseHash The release hash.
function getReleaseData(bytes32 releaseHash) constant returns (uint32 major,
uint32 minor,
uint32 patch,
function getReleaseData(bytes32 releaseHash) constant returns (string packageName,
uint32,
uint32,
uint32,
string preRelease,
string build,
string releaseLockfileURI,
uint createdAt,
uint updatedAt) {
bytes32 versionHash;
(,versionHash, createdAt, updatedAt) = releaseDb.getReleaseData(releaseHash);
(major, minor, patch) = releaseDb.getMajorMinorPatch(versionHash);
bytes32[2] memory hashes;
uint32[3] memory versionNumbers;
(hashes[0] ,hashes[1], createdAt, updatedAt) = releaseDb.getReleaseData(releaseHash);
(versionNumbers[0], versionNumbers[1], versionNumbers[2]) = releaseDb.getMajorMinorPatch(hashes[1]);
packageName = getPackageName(hashes[0]);
preRelease = getPreRelease(releaseHash);
build = getBuild(releaseHash);
releaseLockfileURI = getReleaseLockfileURI(releaseHash);
return (major, minor, patch, preRelease, build, releaseLockfileURI, createdAt, updatedAt);
return (packageName, versionNumbers[0], versionNumbers[1], versionNumbers[2], preRelease, build, releaseLockfileURI, createdAt, updatedAt);
}

/// @dev Returns the release hash at the provide index in the array of all release hashes.
Expand Down
7 changes: 4 additions & 3 deletions contracts/PackageIndexInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ contract PackageIndexInterface is AuthorizedInterface {

/// @dev Returns the release data for the release associated with the given release hash.
/// @param releaseHash The release hash.
function getReleaseData(bytes32 releaseHash) constant returns (uint32 major,
uint32 minor,
uint32 patch,
function getReleaseData(bytes32 releaseHash) constant returns (string packageName,
uint32,
uint32,
uint32,
string preRelease,
string build,
string releaseLockfileURI,
Expand Down
11 changes: 6 additions & 5 deletions contracts/ReleaseDB.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
pragma solidity ^0.4.0;

import {SemVersionLib} from "./SemVersionLib.sol";
import {IndexedOrderedSetLib} from "./IndexedOrderedSetLib.sol";
import {SemVersionLib} from "sem-version-lib/contracts/SemVersionLib.sol";
import {IndexedEnumerableSetLib} from "indexed-enumerable-set-lib/contracts/IndexedEnumerableSetLib.sol";

import {Authorized} from "./Authority.sol";


/// @title Database contract for a package index.
/// @author Tim Coulter <[email protected]>, Piper Merriam <[email protected]>
contract ReleaseDB is Authorized {
using SemVersionLib for SemVersionLib.SemVersion;
using IndexedOrderedSetLib for IndexedOrderedSetLib.IndexedOrderedSet;
using IndexedEnumerableSetLib for IndexedEnumerableSetLib.IndexedEnumerableSet;

struct Release {
bool exists;
Expand All @@ -22,8 +23,8 @@ contract ReleaseDB is Authorized {

// Release Data: (releaseHash => value)
mapping (bytes32 => Release) _recordedReleases;
IndexedOrderedSetLib.IndexedOrderedSet _allReleaseHashes;
mapping (bytes32 => IndexedOrderedSetLib.IndexedOrderedSet) _releaseHashesByNameHash;
IndexedEnumerableSetLib.IndexedEnumerableSet _allReleaseHashes;
mapping (bytes32 => IndexedEnumerableSetLib.IndexedEnumerableSet) _releaseHashesByNameHash;

// Version Data: (versionHash => value)
mapping (bytes32 => SemVersionLib.SemVersion) _recordedVersions;
Expand Down
Loading