removed betting_market_group_freeze operation
added freeze to betting_market_group_update operation
This commit is contained in:
parent
e9f1788eae
commit
f417dc0391
13 changed files with 32 additions and 69 deletions
12
genesis.json
12
genesis.json
|
|
@ -234,7 +234,9 @@
|
|||
"fee": 100000
|
||||
}
|
||||
],[
|
||||
55,{}
|
||||
55,{
|
||||
"fee": 100000
|
||||
}
|
||||
],[
|
||||
56,{
|
||||
"fee": 100000
|
||||
|
|
@ -244,17 +246,17 @@
|
|||
"fee": 100000
|
||||
}
|
||||
],[
|
||||
58,{}
|
||||
],[
|
||||
59,{
|
||||
58,{
|
||||
"fee": 100000
|
||||
}
|
||||
],[
|
||||
59,{}
|
||||
]
|
||||
],
|
||||
"scale": 10000
|
||||
},
|
||||
"block_interval": 5,
|
||||
"maintenance_interval": 6000,
|
||||
"maintenance_interval": 600,
|
||||
"maintenance_skip_slots": 3,
|
||||
"committee_proposal_review_period": 900,
|
||||
"maximum_transaction_size": 2048,
|
||||
|
|
|
|||
|
|
@ -222,7 +222,6 @@ struct get_impacted_account_visitor
|
|||
void operator()( const betting_market_create_operation& op ) {}
|
||||
void operator()( const betting_market_update_operation& op ) {}
|
||||
void operator()( const betting_market_group_resolve_operation& op ) {}
|
||||
void operator()( const betting_market_group_freeze_operation& op ) {}
|
||||
void operator()( const betting_market_group_cancel_unmatched_bets_operation& op ) {}
|
||||
|
||||
void operator()( const bet_place_operation& op )
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ object_id_type betting_market_group_create_evaluator::do_apply(const betting_mar
|
|||
void_result betting_market_group_update_evaluator::do_evaluate(const betting_market_group_update_operation& op)
|
||||
{ try {
|
||||
FC_ASSERT(trx_state->_is_proposed_trx);
|
||||
FC_ASSERT(op.new_event_id.valid() || op.new_description || op.new_rules_id, "nothing to change");
|
||||
FC_ASSERT(op.new_event_id.valid() || op.new_description.valid() || op.new_rules_id.valid() || op.freeze.valid(), "nothing to change");
|
||||
|
||||
// the event_id in the operation can be a relative id. If it is,
|
||||
// resolve it and verify that it is truly an event
|
||||
|
|
@ -151,6 +151,12 @@ void_result betting_market_group_update_evaluator::do_evaluate(const betting_mar
|
|||
FC_ASSERT( db().find_object(rules_id), "invalid rules specified" );
|
||||
}
|
||||
|
||||
if (op.freeze.valid())
|
||||
{
|
||||
const auto& _betting_market_group = &op.betting_market_group_id(db());
|
||||
FC_ASSERT(_betting_market_group->frozen != *op.freeze, "Freeze operation would not change the state of the betting market group");
|
||||
}
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
|
|
@ -167,6 +173,8 @@ void_result betting_market_group_update_evaluator::do_apply(const betting_market
|
|||
bmgo.event_id = event_id;
|
||||
if( op.new_rules_id.valid() )
|
||||
bmgo.rules_id = rules_id;
|
||||
if( op.freeze.valid() )
|
||||
bmgo.frozen = *op.freeze;
|
||||
});
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
@ -356,23 +364,6 @@ void_result betting_market_group_resolve_evaluator::do_apply(const betting_marke
|
|||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
void_result betting_market_group_freeze_evaluator::do_evaluate(const betting_market_group_freeze_operation& op)
|
||||
{ try {
|
||||
const database& d = db();
|
||||
_betting_market_group = &op.betting_market_group_id(d);
|
||||
FC_ASSERT(_betting_market_group->frozen != op.freeze, "Freeze operation would not change the state of the betting market group");
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
void_result betting_market_group_freeze_evaluator::do_apply(const betting_market_group_freeze_operation& op)
|
||||
{ try {
|
||||
db().modify(*_betting_market_group, [&]( betting_market_group_object& betting_market_group_obj ) {
|
||||
betting_market_group_obj.frozen = op.freeze;
|
||||
});
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
void_result betting_market_group_cancel_unmatched_bets_evaluator::do_evaluate(const betting_market_group_cancel_unmatched_bets_operation& op)
|
||||
{ try {
|
||||
const database& d = db();
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ struct get_impacted_account_visitor
|
|||
void operator()(const betting_market_update_operation&){}
|
||||
void operator()(const bet_place_operation&){}
|
||||
void operator()(const betting_market_group_resolve_operation&){}
|
||||
void operator()(const betting_market_group_freeze_operation&){}
|
||||
void operator()(const betting_market_group_resolved_operation &){}
|
||||
void operator()(const betting_market_group_cancel_unmatched_bets_operation&){}
|
||||
void operator()(const bet_matched_operation &){}
|
||||
|
|
|
|||
|
|
@ -129,18 +129,6 @@ namespace graphene { namespace chain {
|
|||
const betting_market_group_object* _betting_market_group;
|
||||
};
|
||||
|
||||
class betting_market_group_freeze_evaluator : public evaluator<betting_market_group_freeze_evaluator>
|
||||
{
|
||||
public:
|
||||
typedef betting_market_group_freeze_operation operation_type;
|
||||
|
||||
void_result do_evaluate( const betting_market_group_freeze_operation& o );
|
||||
void_result do_apply( const betting_market_group_freeze_operation& o );
|
||||
private:
|
||||
const betting_market_group_object* _betting_market_group;
|
||||
};
|
||||
|
||||
|
||||
class betting_market_group_cancel_unmatched_bets_evaluator : public evaluator<betting_market_group_cancel_unmatched_bets_evaluator>
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ struct betting_market_group_update_operation : public base_operation
|
|||
|
||||
optional<object_id_type> new_rules_id;
|
||||
|
||||
optional<bool> freeze;
|
||||
|
||||
extensions_type extensions;
|
||||
|
||||
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
||||
|
|
@ -217,20 +219,6 @@ struct betting_market_group_resolved_operation : public base_operation
|
|||
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
||||
};
|
||||
|
||||
struct betting_market_group_freeze_operation : public base_operation
|
||||
{
|
||||
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
|
||||
asset fee;
|
||||
|
||||
betting_market_group_id_type betting_market_group_id;
|
||||
bool freeze; // the new state of the betting market
|
||||
|
||||
extensions_type extensions;
|
||||
|
||||
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
||||
void validate()const;
|
||||
};
|
||||
|
||||
struct betting_market_group_cancel_unmatched_bets_operation : public base_operation
|
||||
{
|
||||
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
|
||||
|
|
@ -381,7 +369,7 @@ FC_REFLECT( graphene::chain::betting_market_group_create_operation,
|
|||
|
||||
FC_REFLECT( graphene::chain::betting_market_group_update_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::betting_market_group_update_operation,
|
||||
(fee)(betting_market_group_id)(new_description)(new_event_id)(new_rules_id)(extensions) )
|
||||
(fee)(betting_market_group_id)(new_description)(new_event_id)(new_rules_id)(freeze)(extensions) )
|
||||
|
||||
FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::betting_market_create_operation,
|
||||
|
|
@ -401,10 +389,6 @@ FC_REFLECT( graphene::chain::betting_market_group_resolved_operation::fee_parame
|
|||
FC_REFLECT( graphene::chain::betting_market_group_resolved_operation,
|
||||
(bettor_id)(betting_market_group_id)(resolutions)(winnings)(fees_paid)(fee) )
|
||||
|
||||
FC_REFLECT( graphene::chain::betting_market_group_freeze_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::betting_market_group_freeze_operation,
|
||||
(fee)(betting_market_group_id)(freeze)(extensions) )
|
||||
|
||||
FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation,
|
||||
(fee)(betting_market_group_id)(extensions) )
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ namespace graphene { namespace chain {
|
|||
bet_place_operation,
|
||||
betting_market_group_resolve_operation,
|
||||
betting_market_group_resolved_operation, // VIRTUAL
|
||||
betting_market_group_freeze_operation,
|
||||
betting_market_group_cancel_unmatched_bets_operation,
|
||||
bet_matched_operation, // VIRTUAL
|
||||
bet_cancel_operation,
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@ void betting_market_group_resolve_operation::validate() const
|
|||
FC_ASSERT( fee.amount >= 0 );
|
||||
}
|
||||
|
||||
void betting_market_group_freeze_operation::validate() const
|
||||
{
|
||||
FC_ASSERT( fee.amount >= 0 );
|
||||
}
|
||||
|
||||
void betting_market_group_cancel_unmatched_bets_operation::validate() const
|
||||
{
|
||||
FC_ASSERT( fee.amount >= 0 );
|
||||
|
|
|
|||
|
|
@ -1659,6 +1659,7 @@ class wallet_api
|
|||
fc::optional<internationalized_string_type> description,
|
||||
fc::optional<object_id_type> event_id,
|
||||
fc::optional<object_id_type> rules_id,
|
||||
fc::optional<bool> freeze,
|
||||
bool broadcast = false);
|
||||
|
||||
signed_transaction propose_create_betting_market(
|
||||
|
|
|
|||
|
|
@ -5308,6 +5308,7 @@ signed_transaction wallet_api::propose_update_betting_market_group(
|
|||
fc::optional<internationalized_string_type> description,
|
||||
fc::optional<object_id_type> event_id,
|
||||
fc::optional<object_id_type> rules_id,
|
||||
fc::optional<bool> freeze,
|
||||
bool broadcast /*= false*/)
|
||||
{
|
||||
FC_ASSERT( !is_locked() );
|
||||
|
|
@ -5318,7 +5319,7 @@ signed_transaction wallet_api::propose_update_betting_market_group(
|
|||
betting_market_group_update_op.new_description = description;
|
||||
betting_market_group_update_op.new_event_id = event_id;
|
||||
betting_market_group_update_op.new_rules_id = rules_id;
|
||||
//betting_market_group_create_op.asset_id = asset_id;
|
||||
betting_market_group_update_op.freeze = freeze;
|
||||
|
||||
proposal_create_operation prop_op;
|
||||
prop_op.expiration_time = expiration_time;
|
||||
|
|
|
|||
|
|
@ -693,11 +693,12 @@ BOOST_AUTO_TEST_CASE(betting_market_group_update_test)
|
|||
|
||||
const betting_market_rules_object& new_betting_market_rules = create_betting_market_rules({{"en", "NHL Rules v2.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}});
|
||||
fc::optional<object_id_type> new_rule = new_betting_market_rules.id;
|
||||
fc::optional<bool> freeze;
|
||||
|
||||
update_betting_market_group(moneyline_betting_markets.id, new_desc, empty_object_id, empty_object_id);
|
||||
update_betting_market_group(moneyline_betting_markets.id, dempty, new_event, empty_object_id);
|
||||
update_betting_market_group(moneyline_betting_markets.id, dempty, empty_object_id, new_rule);
|
||||
update_betting_market_group(moneyline_betting_markets.id, new_desc, new_event, new_rule);
|
||||
update_betting_market_group(moneyline_betting_markets.id, new_desc, empty_object_id, empty_object_id, freeze);
|
||||
update_betting_market_group(moneyline_betting_markets.id, dempty, new_event, empty_object_id, freeze);
|
||||
update_betting_market_group(moneyline_betting_markets.id, dempty, empty_object_id, new_rule, freeze);
|
||||
update_betting_market_group(moneyline_betting_markets.id, new_desc, new_event, new_rule, freeze);
|
||||
|
||||
transfer(account_id_type(), bob_id, asset(10000000));
|
||||
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION, 1000000 / 50 /* chain defaults to 2% fees */);
|
||||
|
|
|
|||
|
|
@ -1357,13 +1357,15 @@ const betting_market_group_object& database_fixture::create_betting_market_group
|
|||
void database_fixture::update_betting_market_group(betting_market_group_id_type betting_market_group_id,
|
||||
fc::optional<internationalized_string_type> description,
|
||||
fc::optional<object_id_type> event_id,
|
||||
fc::optional<object_id_type> rules_id)
|
||||
fc::optional<object_id_type> rules_id,
|
||||
fc::optional<bool> freeze)
|
||||
{ try {
|
||||
betting_market_group_update_operation betting_market_group_update_op;
|
||||
betting_market_group_update_op.betting_market_group_id = betting_market_group_id;
|
||||
betting_market_group_update_op.new_description = description;
|
||||
betting_market_group_update_op.new_event_id = event_id;
|
||||
betting_market_group_update_op.new_rules_id = rules_id;
|
||||
betting_market_group_update_op.freeze = freeze;
|
||||
process_operation_by_witnesses(betting_market_group_update_op);
|
||||
} FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(description)(event_id)(rules_id)) }
|
||||
|
||||
|
|
|
|||
|
|
@ -309,7 +309,8 @@ struct database_fixture {
|
|||
void update_betting_market_group(betting_market_group_id_type betting_market_group_id,
|
||||
fc::optional<internationalized_string_type> description,
|
||||
fc::optional<object_id_type> event_id,
|
||||
fc::optional<object_id_type> rules_id);
|
||||
fc::optional<object_id_type> rules_id,
|
||||
fc::optional<bool> freeze);
|
||||
|
||||
const betting_market_object& create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition);
|
||||
void update_betting_market(betting_market_id_type betting_market_id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue