Skip to content

Commit

Permalink
Rename auditor => approver
Browse files Browse the repository at this point in the history
fixes #4
  • Loading branch information
DenisCarriere committed May 11, 2019
1 parent f230a67 commit b7b5b15
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 81 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -8,14 +8,14 @@ An escrow contract designed for paying worker proposals. The intention is that
- The sender of an escrow will temporarily be whitelisted to BOS executives. In the future anyone may be a sender
- The sender may only have one unfilled escrow at any given time, however they may have many filled escrows
- To fill an escrow the sender must transfer the `BOS` tokens to this contract. An unfilled escrow will be filled
- The receiver is considered as always approving the escrow. An approval must come from either the sender or the auditor
- The receiver is considered as always approving the escrow. An approval must come from either the sender or the approver
- The sender may only cancel an escrow that has not been filled
- The sender may only refund an escrow that has passed it's expiry
- Unapprove only removes an existing approval, if the action is made before the receiver uses the claim action
- A sender may extend the expiry but not shorten it
- The auditor may change extend or shorten the expiry
- The auditor may close an escrow. This is essentially the same as refunding it, however without waiting for the expiry to lapse
- The auditor may Lock and Unlock an escrow. This prevents ALL actions except unlock and actions made by the auditor.
- The approver may change extend or shorten the expiry
- The approver may close an escrow. This is essentially the same as refunding it, however without waiting for the expiry to lapse
- The approver may Lock and Unlock an escrow. This prevents ALL actions except unlock and actions made by the approver.

<h1 class="contract">
init
Expand All @@ -27,7 +27,7 @@ An escrow contract designed for paying worker proposals. The intention is that

- __sender__ is an eosio account name.
- __receiver__ is an eosio account name.
- __auditor__ is an eosio account name.
- __approver__ is an eosio account name.
- __expires__ The date/time after which the escrow amount can be refunded by the sender.
- __memo__ is a memo to send as the eventual transfer memo at the end of the escrow contract.
- __ext_reference__ is a reference to to external id held my another contract or entity as opposed to the internal auto-incrementing key.
Expand Down
4 changes: 2 additions & 2 deletions escrow.abi
Expand Up @@ -113,7 +113,7 @@
"type": "name"
},
{
"name": "auditor",
"name": "approver",
"type": "name"
},
{
Expand Down Expand Up @@ -183,7 +183,7 @@
"type": "name"
},
{
"name": "auditor",
"name": "approver",
"type": "name"
},
{
Expand Down
24 changes: 12 additions & 12 deletions escrow.cpp
Expand Up @@ -49,7 +49,7 @@ namespace bos {
eosio_assert(found, "Could not find existing escrow to deposit to, transfer cancelled");
}

ACTION escrow::init(name sender, name receiver, name auditor, time_point_sec expires, string memo, std::optional<uint64_t> ext_reference ) {
ACTION escrow::init(name sender, name receiver, name approver, time_point_sec expires, string memo, std::optional<uint64_t> ext_reference ) {
require_auth(sender);

// Ensure sender is a BOS Executive
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace bos {
p.key = escrows.available_primary_key();
p.sender = sender;
p.receiver = receiver;
p.auditor = auditor;
p.approver = approver;
p.ext_asset = zero_asset;
p.expires = expires;
p.memo = memo;
Expand All @@ -102,7 +102,7 @@ namespace bos {

eosio_assert(esc_itr->ext_asset.quantity.amount > 0, "This has not been initialized with a transfer");

eosio_assert(esc_itr->sender == approver || esc_itr->auditor == approver, "You are not allowed to approve this escrow.");
eosio_assert(esc_itr->sender == approver || esc_itr->approver == approver, "You are not allowed to approve this escrow.");

auto approvals = esc_itr->approvals;
eosio_assert(std::find(approvals.begin(), approvals.end(), approver) == approvals.end(), "You have already approved this escrow");
Expand Down Expand Up @@ -146,7 +146,7 @@ namespace bos {

eosio_assert(esc_itr->ext_asset.quantity.amount > 0, "This has not been initialized with a transfer");

eosio_assert(esc_itr->locked == false, "This escrow has been locked by the auditor");
eosio_assert(esc_itr->locked == false, "This escrow has been locked by the approver");

auto approvals = esc_itr->approvals;

Expand Down Expand Up @@ -204,7 +204,7 @@ namespace bos {

eosio_assert(esc_itr->ext_asset.quantity.amount > 0, "This has not been initialized with a transfer");

eosio_assert(esc_itr->locked == false, "This escrow has been locked by the auditor");
eosio_assert(esc_itr->locked == false, "This escrow has been locked by the approver");

time_point_sec time_now = time_point_sec(current_time_point());

Expand Down Expand Up @@ -239,12 +239,12 @@ namespace bos {

time_point_sec time_now = time_point_sec(current_time_point());

//auditors may extend or shorten the time
//the sender may only extend
// approver may extend or shorten the time
// the sender may only extend
if(has_auth(esc_itr->sender)) {
eosio_assert(expires > esc_itr->expires, "You may only extend the expiry");
} else {
require_auth(esc_itr->auditor);
require_auth(esc_itr->approver);
}

escrows.modify(esc_itr, eosio::same_payer, [&](escrow_info &e){
Expand All @@ -262,13 +262,13 @@ namespace bos {


/*
* Allows the auditor to close and refund an unexpired escrow
* Allows the approver to close and refund an unexpired escrow
*/
ACTION escrow::close(uint64_t key) {
auto esc_itr = escrows.find(key);
eosio_assert(esc_itr != escrows.end(), "Could not find escrow with that index");

require_auth(esc_itr->auditor);
require_auth(esc_itr->approver);
eosio_assert(esc_itr->ext_asset.quantity.amount > 0, "This has not been initialized with a transfer");

eosio::action(
Expand All @@ -287,13 +287,13 @@ namespace bos {
}

/*
* Allows the auditor to lock an escrow preventing any actions by sender or receiver
* Allows the approver to lock an escrow preventing any actions by sender or receiver
*/
ACTION escrow::lock(uint64_t key, bool locked) {

auto esc_itr = escrows.find(key);
eosio_assert(esc_itr != escrows.end(), "Could not find escrow with that index");
require_auth(esc_itr->auditor);
require_auth(esc_itr->approver);
eosio_assert(esc_itr->ext_asset.quantity.amount > 0, "This has not been initialized with a transfer");

escrows.modify(esc_itr, eosio::same_payer, [&](escrow_info &e){
Expand Down
2 changes: 1 addition & 1 deletion escrow.hpp
Expand Up @@ -28,7 +28,7 @@ namespace bos {
* Escrow contract
*/

ACTION init(name sender, name receiver, name auditor, time_point_sec expires, string memo, std::optional<uint64_t> ext_reference);
ACTION init(name sender, name receiver, name approver, time_point_sec expires, string memo, std::optional<uint64_t> ext_reference);

ACTION transfer(name from, name to, asset quantity, string memo);

Expand Down
2 changes: 1 addition & 1 deletion escrow_shared.hpp
Expand Up @@ -10,7 +10,7 @@ struct [[eosio::table("escrows"), eosio::contract("escrow")]] escrow_info {
uint64_t key;
name sender;
name receiver;
name auditor;
name approver;
vector<name> approvals;
extended_asset ext_asset;
string memo;
Expand Down

0 comments on commit b7b5b15

Please sign in to comment.