Skip to content

Commit

Permalink
Add missing comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
tbfleming committed Aug 10, 2018
1 parent 7a5a543 commit c3aed5c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions libraries/eosiolib/asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,49 @@ namespace eosio {
return {a.quantity + b.quantity, a.contract};
}

/// Addition operator.
friend extended_asset& operator+=( extended_asset& a, const extended_asset& b ) {
eosio_assert( a.contract == b.contract, "type mismatch" );
a.quantity += b.quantity;
return a;
}

/// Subtraction operator.
friend extended_asset& operator-=( extended_asset& a, const extended_asset& b ) {
eosio_assert( a.contract == b.contract, "type mismatch" );
a.quantity -= b.quantity;
return a;
}

/// Less than operator
friend bool operator<( const extended_asset& a, const extended_asset& b ) {
eosio_assert( a.contract == b.contract, "type mismatch" );
return a.quantity < b.quantity;
}


/// Comparison operator
friend bool operator==( const extended_asset& a, const extended_asset& b ) {
return std::tie(a.quantity, a.contract) == std::tie(b.quantity, b.contract);
}

/// Comparison operator
friend bool operator!=( const extended_asset& a, const extended_asset& b ) {
return std::tie(a.quantity, a.contract) != std::tie(b.quantity, b.contract);
}

/// Comparison operator
friend bool operator<=( const extended_asset& a, const extended_asset& b ) {
eosio_assert( a.contract == b.contract, "type mismatch" );
return a.quantity <= b.quantity;
}

/// Comparison operator
friend bool operator>=( const extended_asset& a, const extended_asset& b ) {
eosio_assert( a.contract == b.contract, "type mismatch" );
return a.quantity >= b.quantity;
}

EOSLIB_SERIALIZE( extended_asset, (quantity)(contract) )
};

Expand Down
2 changes: 1 addition & 1 deletion libraries/eosiolib/currency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace eosio {
}

static void inline_transfer( account_name from, account_name to, extended_asset amount, string memo = string(), permission_name perm = N(active) ) {
action act( permission_level( from, perm ), amount.contract, N(transfer), transfer{from,to,amount,memo} );
action act( permission_level( from, perm ), amount.contract, N(transfer), transfer{from,to,amount.quantity,memo} );
act.send();
}

Expand Down

0 comments on commit c3aed5c

Please sign in to comment.