docs: Added natspec to escrow contract

This commit is contained in:
Richard Ramos 2018-12-17 16:18:37 -04:00
parent 22ff471530
commit 90881fa94c
1 changed files with 31 additions and 0 deletions

View File

@ -31,6 +31,14 @@ contract Escrow is Pausable {
event Paid(uint escrowId); event Paid(uint escrowId);
event Canceled(uint escrowId); event Canceled(uint escrowId);
/**
* @dev Create a new escrow
* @param _buyer The address that will perform the buy for the escrow
* @param _expirationTime Unix timestamp before the transaction is considered expired
* @notice Requires contract to be unpaused.
* The seller needs to be licensed.
* The expiration time must be at least 10min in the future
*/
function create(address payable _buyer, uint _expirationTime) public payable whenNotPaused { function create(address payable _buyer, uint _expirationTime) public payable whenNotPaused {
require(_expirationTime > (block.timestamp + 600), "Expiration time must be at least 10min in the future"); require(_expirationTime > (block.timestamp + 600), "Expiration time must be at least 10min in the future");
require(msg.value > 0, "ETH amount is required"); // TODO: abstract this to use ERC20. Maybe thru the use of wETH require(msg.value > 0, "ETH amount is required"); // TODO: abstract this to use ERC20. Maybe thru the use of wETH
@ -48,6 +56,14 @@ contract Escrow is Pausable {
emit Created(msg.sender, _buyer, msg.value, escrowId); emit Created(msg.sender, _buyer, msg.value, escrowId);
} }
/**
* @dev Release escrow funds to buyer
* @param _escrowId Id of the escrow
* @notice Requires contract to be unpaused.
* Can only be executed by the seller
* Transaction must not be expired, or previously canceled or released
*/
function release(uint _escrowId) public whenNotPaused { function release(uint _escrowId) public whenNotPaused {
require(_escrowId < transactions.length, "Invalid escrow id"); require(_escrowId < transactions.length, "Invalid escrow id");
@ -64,6 +80,13 @@ contract Escrow is Pausable {
emit Paid(_escrowId); emit Paid(_escrowId);
} }
/**
* @dev Cancel an escrow operation
* @param _escrowId Id of the escrow
* @notice Requires contract to be unpaused.
* Can only be executed by the seller
* Transaction must not be expired, or previously canceled or released
*/
function cancel(uint _escrowId) public whenNotPaused { function cancel(uint _escrowId) public whenNotPaused {
require(_escrowId < transactions.length, "Invalid escrow id"); require(_escrowId < transactions.length, "Invalid escrow id");
@ -79,6 +102,14 @@ contract Escrow is Pausable {
emit Canceled(_escrowId); emit Canceled(_escrowId);
} }
/**
* @dev Withdraws funds to the sellers in case of emergency
* @param _escrowId Id of the escrow
* @notice Requires contract to be paused.
* Can be executed by anyone
* Transaction must not be canceled or released
*/
function withdraw_emergency(uint _escrowId) public whenPaused { function withdraw_emergency(uint _escrowId) public whenPaused {
require(_escrowId < transactions.length, "Invalid escrow id"); require(_escrowId < transactions.length, "Invalid escrow id");