Skip to content

Commit

Permalink
Merge pull request #18 from worldwide-asset-exchange/develop
Browse files Browse the repository at this point in the history
Release wax-1.5.2-1.1.2
  • Loading branch information
mauri-opskins authored Jul 19, 2019
2 parents 67f970a + 975b3cf commit 2a3824c
Show file tree
Hide file tree
Showing 9 changed files with 393 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ IMPROVEMENTS:

BUG FIXES:

## wax-1.5.2-1.1.2

BREAKING CHANGES:

FEATURES:

IMPROVEMENTS:

BUG FIXES:
- [KEW-1405] Fix for prod per block pay

## wax-1.5.2-1.1.1

BREAKING CHANGES:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# wax-eos-contracts [![Build Status](https://travis-ci.org/worldwide-asset-exchange/wax-eos-contracts.svg?branch=develop)](https://travis-ci.org/worldwide-asset-exchange/wax-eos-contracts)
# wax-system-contracts [![Build Status](https://travis-ci.org/worldwide-asset-exchange/wax-system-contracts.svg?branch=develop)](https://travis-ci.org/worldwide-asset-exchange/wax-system-contracts)

## The WAX System Contracts

Expand Down
7 changes: 3 additions & 4 deletions eosio.system/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
eosio.system
----------

This contract enables users to stake tokens, and then configure and vote on producers and worker proposals.
This contract enables users to stake WAX Tokens, and then configure and vote on WAX Guilds (block producers) and worker proposals.

Users can also proxy their voting influence to other users.

The state of this contract is read to determine the 21 active block producers.

Actions:
The naming convention is codeaccount::actionname followed by a list of paramters.
The naming convention is codeaccount::actionname followed by a list of parameters.

Indicates that a particular account wishes to become a producer
Indicates that a particular account wishes to become a block producer.
## eosio.system::cfgproducer account config
- **account** the producer account to update
- updates the configuration settings for a particular producer, these
Expand Down
12 changes: 12 additions & 0 deletions eosio.system/include/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,19 @@ namespace eosiosystem {
[[eosio::action]]
void awardgenesis( name receiver,
const asset tokens, uint64_t nonce );

/**
* Reverts an awardgenesis action
*/
[[eosio::action]]
void delgenesis( uint64_t nonce );

/**
* Removing the amount of tokens from account's refunds
*/
[[eosio::action]]
void removerefund( name account, asset tokens );

/**
* Pays all awarded tokens for period since last claim
*/
Expand Down
55 changes: 55 additions & 0 deletions eosio.system/src/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,61 @@ namespace eosiosystem {
send_genesis_token( genesis_account, receiver, tokens, true);
}

void system_contract::delgenesis( uint64_t nonce )
{
require_auth(genesis_account);

genesis_nonce_table genesis_nonce_tbl(_self, _self.value);
auto it = genesis_nonce_tbl.find(nonce);
eosio_assert(it != genesis_nonce_tbl.end(), "Nonce does not exists.");
asset tokens = it->awarded;
name receiver = it->receiver;
genesis_nonce_tbl.erase(it);

const asset zero_asset( 0, core_symbol() );

del_bandwidth_table del_bw_tbl( _self, receiver.value );
auto del_bw_itr = del_bw_tbl.find( receiver.value );

if( del_bw_itr != del_bw_tbl.end() ) {
auto from_net = std::min(del_bw_itr->net_weight, tokens);
auto from_cpu = std::min(del_bw_itr->cpu_weight, tokens - from_net);

if(from_net != zero_asset || from_cpu != zero_asset) {
INLINE_ACTION_SENDER(system_contract, undelegatebw)(
_self, { {receiver, active_permission} },
{ receiver, receiver, from_net, from_cpu });
}
}

INLINE_ACTION_SENDER( system_contract, removerefund)(
_self, { {_self, active_permission} },
{ receiver, tokens });
}

void system_contract::removerefund( const name account, const asset tokens )
{
require_auth(_self);

const asset zero_asset( 0, core_symbol() );
refunds_table refunds_tbl( _self, account.value );
auto& req = refunds_tbl.get( account.value, "no refund found");
eosio_assert(req.net_amount + req.cpu_amount >= tokens, "account does not have enough staked tokens");

if(req.net_amount + req.cpu_amount == tokens){
refunds_tbl.erase(req);
return;
}

refunds_tbl.modify( req, same_payer, [&]( auto& r ) {
if(req.net_amount >= tokens) {
r.net_amount -= tokens;
}else{
r.cpu_amount -= tokens - req.net_amount;
r.net_amount = zero_asset;
}
});
}

void system_contract::send_genesis_token( name from, name receiver, const asset tokens, bool add_backward_rewards ){
const time_point ct = std::max(current_time_point(), gbm_initial_time);
Expand Down
2 changes: 1 addition & 1 deletion eosio.system/src/eosio.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ EOSIO_DISPATCH( eosiosystem::system_contract,
(init)(setram)(setramrate)(setparams)(setpriv)(setalimits)(setacctram)(setacctnet)(setacctcpu)
(rmvproducer)(updtrevision)(bidname)(bidrefund)
// delegate_bandwidth.cpp
(buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund)(awardgenesis)(claimgenesis)
(buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund)(awardgenesis)(claimgenesis)(delgenesis)(removerefund)
// voting.cpp
(regproducer)(unregprod)(voteproducer)(regproxy)(voterclaim)(claimgbmvote)
// producer_pay.cpp
Expand Down
3 changes: 2 additions & 1 deletion eosio.system/src/producer_pay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ namespace eosiosystem {

int64_t producer_per_block_pay = 0;
if( _gstate.total_unpaid_blocks > 0 ) {
producer_per_block_pay = (_gstate.perblock_bucket * prod.unpaid_blocks) / _gstate.total_unpaid_blocks;
producer_per_block_pay = (static_cast<double>(_gstate.perblock_bucket) * prod.unpaid_blocks) / _gstate.total_unpaid_blocks;
eosio_assert( producer_per_block_pay >= 0, "producer per block pay must be greater or equal to 0" );
}

double new_votepay_share = update_producer_votepay_share( prod2,
Expand Down
7 changes: 7 additions & 0 deletions tests/eosio.system_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ class eosio_system_tester : public TESTER {
mvo()( "receiver",receiver)("tokens",tokens)("nonce",nonce) );
}

action_result delgenesis( uint64_t nonce ) {
return push_action(
N(genesis.wax),
N(delgenesis),
mvo()("nonce",nonce) );
}

action_result claimgenesis( const account_name& claimer ) {
return push_action(
claimer,
Expand Down
Loading

0 comments on commit 2a3824c

Please sign in to comment.