PackageDB

contract PackageDB is Authorized
Title:Database contract for a package index package data.
Author:Tim Coulter <tim.coulter@consensys.net>, Piper Merriam <pipermerriam@gmail.com>
mapping (bytes32 => Package) _recordedPackages
IndexedOrderedSetLib.IndexedOrderedSet _allPackageNameHashes
event PackageReleaseAdd(bytes32 indexed nameHash, bytes32 indexed releaseHash)
event PackageReleaseRemove(bytes32 indexed nameHash, bytes32 indexed releaseHash)
event PackageCreate(bytes32 indexed nameHash)
event PackageDelete(bytes32 indexed nameHash, string reason)
event PackageOwnerUpdate(bytes32 indexed nameHash, address indexed oldOwner, address indexed newOwner)
modifier onlyIfPackageExists(bytes32 nameHash)
function setPackage(string name)
public
 auth
returns (bool)

Creates or updates a release for a package. Returns success.

Parameters:
  • name – Package name
function removePackage(bytes32 nameHash, string reason)
public
 auth
 onlyIfPackageExists(nameHash)
returns (bool)

Removes a package from the package db. Packages with existing releases may not be removed. Returns success.

Parameters:
  • nameHash – The name hash of a package.
function setPackageOwner(bytes32 nameHash, address newPackageOwner)
public
 auth
 onlyIfPackageExists(nameHash)
returns (bool)

Sets the owner of a package to the provided address. Returns success.

Parameters:
  • nameHash – The name hash of a package.
  • newPackageOwner – The address of the new owner.
function packageExists(bytes32 nameHash)
public
view
returns (bool)

Query the existence of a package with the given name. Returns boolean indicating whether the package exists.

Parameters:
  • nameHash – The name hash of a package.
function getNumPackages()
public
view
returns (uint)

Return the total number of packages

function getPackageNameHash(uint idx)
public
view
returns (bytes32)

Returns package namehash at the provided index from the set of all known name hashes.

Parameters:
  • idx – The index of the package name hash to retrieve.
function getPackageData(bytes32 nameHash)
public
view
 onlyIfPackageExists(nameHash)
returns (address packageOwner, uint createdAt, uint updatedAt)

Returns information about the package.

Parameters:
  • nameHash – The name hash to look up.
function getPackageName(bytes32 nameHash)
public
view
 onlyIfPackageExists(nameHash)
returns (string)

Returns the package name for the given namehash

Parameters:
  • nameHash – The name hash to look up.
function getAllPackageIds(uint _offset, uint limit)
public
view
returns (bytes32[] packageIds, uint offset)

Returns a slice of the array of all package hashes for the named package.

Parameters:
  • offset – The starting index for the slice.
  • limit – The length of the slice
function hashName(string name)
public
pure
returns (bytes32)

Returns name hash for a given package name.

Parameters:
  • name – Package name