# IGitConsensus

Matt Stam (@mattstam)

IGitConsensus

The interface for Git Consensus.

Errors IGitConsensusErrors, Events IGitConsensusEvents, and Types IGitConsensusTypes are seperated in different interfaces for clarity and unit testing purposes.

# Methods

# addCommit

function addCommit(IGitConsensusTypes.CommitData commitData) external nonpayable returns (bytes20 commitHash)

Notarizes a commit on-chain, building the hash trustlessly from the commit data. Stores the commit such that tagExists() returns true for this commit hash, and tagAddr() returns the owner address. Emits a IGitConsensusEvents.CommitAdded

# Parameters

Name Type Description
commitData IGitConsensusTypes.CommitData The data of the commit (tree, parents, author, message, etc).commitData.message MUST include an address, which determines where the tokens are sent when/if the corresponding commit is embedded in a future addRelease() call

# Returns

Name Type Description
commitHash bytes20 The hash of the SHA-1'd commitData.

# addRelease

function addRelease(IGitConsensusTypes.TagData tagData, bytes20[] hashes, uint256[] values) external nonpayable returns (bytes20 tagHash)

# Parameters

Name Type Description
tagData IGitConsensusTypes.TagData The data of the tag (type, author, message, etc).tagData.message MUST include an address, which should be the project token address.
hashes bytes20[] Array of git commit hashes to receive tokens. This hash will be used to look up the address that was embedded in the commit data's message. MUST equal length of values. hashes[i]'s owner will be rewarded with values[i] tokens.
values uint256[] Array of amounts of tokens to be given to each commit owner. MUST equal length of hashes. values[i] is the amount minted for hashes[i]'s owner.

# Returns

Name Type Description
tagHash bytes20 The hash of the SHA-1'd tagData.

# hashAddr

function hashAddr(bytes20 gitHash) external view returns (address addr)

# Parameters

Name Type Description
gitHash bytes20 The hash of the git commit. If the this hash does not exist, it means that no corresponding git commit or tag was ever added to the contract.

# Returns

Name Type Description
addr address The address that corresponds to the commit or tag. In the case of a commit, this is equal to the address that was included in the commit message which is generally to represent the owner of the commit. In the case of a tag, this is equal to the address that used was included in the tag message, which should be the token address. If the gitHash was not notarized via addCommit() or addRelease(), then the address eturned is a zero address.

# hashExists

function hashExists(bytes20 gitHash) external view returns (bool exists)

Check if a git hash exists, indicating that the corresponding commit or tag has been notarized in the contract via addCommit() or addRelease() previously.

# Parameters

Name Type Description
gitHash bytes20 The hash of the git commit or tag.

# Returns

Name Type Description
exists bool true if the hash exists, false otherwise.

# Events

# CommitAdded

event CommitAdded(address indexed ownerAddr, bytes20 commitHash)

Emitted when a commit is added via addCommit().

# Parameters

Name Type Description
ownerAddr indexed address The address that was contained in the commit message.
commitash bytes20 The SHA-1 hash generated from the commit data.

# ReleaseAdded

event ReleaseAdded(address indexed tokenAddr, bytes20 tagHash)

Emitted when a release is added via addRelease().

# Parameters

Name Type Description
tokenAddr indexed address The address that was contained in the tag message, and the caller of the addRelease() function. This will be the address of the governor of the project.
tagHash bytes20 The SHA-1 hash generated from the tag data

# Errors

# CommitMsgNeedsAddr

error CommitMsgNeedsAddr(string message)

When commit message does not contain a valid address.

Can occur with addCommit(). Specifically occurs when the message does not contain 0x followed by enough length for an address (40 hex characters).

# Parameters

Name Type Description
message string The commit message string.

# DistributionLengthMismatch

error DistributionLengthMismatch(uint256 hashesLen, uint256 valuesLen)

When distribution hashes/owner array length and values array length do not match.

Can occur with addRelease().

# Parameters

Name Type Description
hashesLen uint256 The length of the hashes array.
valuesLen uint256 The length of the values array.

# SubstringOutOfBounds

error SubstringOutOfBounds(uint256 offset, uint256 substringLen, uint256 stringLen)

When the sender attempts to extract a substring that is out of bounds in a string.

Can occur with addCommit() or addRelease().

# Parameters

Name Type Description
offset uint256 The index of the substring to extract.
substringLen uint256 The length of the substring to extract.
stringLen uint256 The length of the string from which to extract the substring.

# TagMsgNeedsAddr

error TagMsgNeedsAddr(string message)

When tag message does not contain a valid address.

Can occur with addRelease(). Specifically occurs when the message does not contain 0x followed by enough length for an address (40 hex characters).

# Parameters

Name Type Description
message string The tag message string.

# UnauthorizedRelease

error UnauthorizedRelease(address senderAddr, address expectedAddr)

When a release attempt occurs from a sender other than the project's governor.

Can occur with addRelease().

# Parameters

Name Type Description
senderAddr address The address of the unauthorized sender.
expectedAddr address The expected address, which should be the governor.