added is_live_market to event_update operation
This commit is contained in:
parent
f417dc0391
commit
ec77685264
9 changed files with 34 additions and 11 deletions
|
|
@ -154,7 +154,7 @@ void_result betting_market_group_update_evaluator::do_evaluate(const betting_mar
|
|||
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");
|
||||
FC_ASSERT(_betting_market_group->frozen != *op.freeze, "freeze would not change the state of the betting market group");
|
||||
}
|
||||
|
||||
return void_result();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,11 @@ object_id_type event_create_evaluator::do_apply(const event_create_operation& op
|
|||
void_result event_update_evaluator::do_evaluate(const event_update_operation& op)
|
||||
{ try {
|
||||
FC_ASSERT(trx_state->_is_proposed_trx);
|
||||
FC_ASSERT(op.new_event_group_id.valid() || op.new_name.valid() || op.new_season.valid() || op.new_start_time.valid(), "nothing to change");
|
||||
FC_ASSERT(op.new_event_group_id.valid() ||
|
||||
op.new_name.valid() ||
|
||||
op.new_season.valid() ||
|
||||
op.new_start_time.valid() ||
|
||||
op.is_live_market.valid(), "nothing to change");
|
||||
|
||||
if (op.new_event_group_id.valid())
|
||||
{
|
||||
|
|
@ -88,6 +92,12 @@ void_result event_update_evaluator::do_evaluate(const event_update_operation& op
|
|||
event_group_id = resolved_event_group_id;
|
||||
}
|
||||
|
||||
if (op.is_live_market.valid())
|
||||
{
|
||||
const auto& _event_object = &op.event_id(db());
|
||||
FC_ASSERT(_event_object->is_live_market != *op.is_live_market, "is_live_market would not change the state of the event");
|
||||
}
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
|
|
@ -108,6 +118,8 @@ void_result event_update_evaluator::do_apply(const event_update_operation& op)
|
|||
eo.start_time = *op.new_start_time;
|
||||
if( op.new_event_group_id.valid() )
|
||||
eo.event_group_id = event_group_id;
|
||||
if( op.is_live_market.valid() )
|
||||
eo.is_live_market = *op.is_live_market;
|
||||
});
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ class event_object : public graphene::db::abstract_object< event_object >
|
|||
|
||||
event_group_id_type event_group_id;
|
||||
|
||||
bool is_live_market;
|
||||
|
||||
event_status status;
|
||||
vector<string> scores;
|
||||
};
|
||||
|
|
@ -57,4 +59,4 @@ typedef multi_index_container<
|
|||
typedef generic_index<event_object, event_object_multi_index_type> event_object_index;
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::event_object, (graphene::db::object), (name)(season)(start_time)(event_group_id)(status)(scores) )
|
||||
FC_REFLECT_DERIVED( graphene::chain::event_object, (graphene::db::object), (name)(season)(start_time)(event_group_id)(is_live_market)(status)(scores) )
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ struct event_update_operation : public base_operation
|
|||
|
||||
optional<time_point_sec> new_start_time;
|
||||
|
||||
optional<bool> is_live_market;
|
||||
|
||||
extensions_type extensions;
|
||||
|
||||
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
||||
|
|
@ -130,7 +132,7 @@ FC_REFLECT( graphene::chain::event_create_operation,
|
|||
|
||||
FC_REFLECT( graphene::chain::event_update_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::event_update_operation,
|
||||
(fee)(event_id)(new_event_group_id)(new_name)(new_season)(new_start_time)(extensions) )
|
||||
(fee)(event_id)(new_event_group_id)(new_name)(new_season)(new_start_time)(is_live_market)(extensions) )
|
||||
|
||||
FC_REFLECT_ENUM( graphene::chain::event_status, (upcoming)(in_progress)(frozen)(completed)(canceled)(STATUS_COUNT) )
|
||||
FC_REFLECT( graphene::chain::event_update_status_operation::fee_parameters_type, (fee) )
|
||||
|
|
|
|||
|
|
@ -1625,6 +1625,7 @@ class wallet_api
|
|||
fc::optional<object_id_type> event_group_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
fc::optional<internationalized_string_type> season,
|
||||
fc::optional<bool> is_live_market,
|
||||
fc::optional<time_point_sec> start_time,
|
||||
bool broadcast = false);
|
||||
|
||||
|
|
|
|||
|
|
@ -5180,6 +5180,7 @@ signed_transaction wallet_api::propose_update_event(
|
|||
fc::optional<object_id_type> event_group_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
fc::optional<internationalized_string_type> season,
|
||||
fc::optional<bool> is_live_market,
|
||||
fc::optional<time_point_sec> start_time,
|
||||
bool broadcast /*= false*/)
|
||||
{
|
||||
|
|
@ -5192,6 +5193,7 @@ signed_transaction wallet_api::propose_update_event(
|
|||
event_update_op.new_start_time = start_time;
|
||||
event_update_op.new_name = name;
|
||||
event_update_op.new_season = season;
|
||||
event_update_op.is_live_market = is_live_market;
|
||||
|
||||
proposal_create_operation prop_op;
|
||||
prop_op.expiration_time = expiration_time;
|
||||
|
|
|
|||
|
|
@ -619,16 +619,17 @@ BOOST_AUTO_TEST_CASE(event_update_test)
|
|||
fc::optional<internationalized_string_type> name = internationalized_string_type({{"en", "Washington Capitals vs. Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホーク"}});
|
||||
fc::optional<internationalized_string_type> season = internationalized_string_type({{"en", "2017-18"}});
|
||||
fc::optional<object_id_type> empty_object_id;
|
||||
fc::optional<bool> empty_bool;
|
||||
|
||||
update_event(capitals_vs_blackhawks.id, empty_object_id, name, empty);
|
||||
update_event(capitals_vs_blackhawks.id, empty_object_id, empty, season);
|
||||
update_event(capitals_vs_blackhawks.id, empty_object_id, name, season);
|
||||
update_event(capitals_vs_blackhawks.id, empty_object_id, name, empty, empty_bool);
|
||||
update_event(capitals_vs_blackhawks.id, empty_object_id, empty, season, empty_bool);
|
||||
update_event(capitals_vs_blackhawks.id, empty_object_id, name, season, empty_bool);
|
||||
|
||||
const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
|
||||
const event_group_object& nhl2 = create_event_group({{"en", "NHL2"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_on_hockey.id); \
|
||||
fc::optional<object_id_type> event_group_id = nhl2.id;
|
||||
|
||||
update_event(capitals_vs_blackhawks.id, event_group_id , empty, empty);
|
||||
update_event(capitals_vs_blackhawks.id, event_group_id , empty, empty, empty_bool);
|
||||
|
||||
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 */);
|
||||
|
||||
|
|
@ -958,7 +959,7 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test )
|
|||
update_event(cilic_vs_federer.id,
|
||||
fc::optional<object_id_type>(),
|
||||
internationalized_string_type({{"en", "R. Federer vs. M. Cilic"}}),
|
||||
fc::optional<internationalized_string_type>());
|
||||
fc::optional<internationalized_string_type>(), fc::optional<bool>());
|
||||
|
||||
generate_blocks(13);
|
||||
|
||||
|
|
|
|||
|
|
@ -1310,13 +1310,15 @@ const event_object& database_fixture::create_event(internationalized_string_type
|
|||
void database_fixture::update_event(event_id_type event_id,
|
||||
fc::optional<object_id_type> event_group_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
fc::optional<internationalized_string_type> season)
|
||||
fc::optional<internationalized_string_type> season,
|
||||
fc::optional<bool> is_live_market)
|
||||
{ try {
|
||||
event_update_operation event_update_op;
|
||||
event_update_op.event_id = event_id;
|
||||
event_update_op.new_event_group_id = event_group_id;
|
||||
event_update_op.new_name = name;
|
||||
event_update_op.new_season = season;
|
||||
event_update_op.is_live_market = is_live_market;
|
||||
process_operation_by_witnesses(event_update_op);
|
||||
} FC_CAPTURE_AND_RETHROW( (name)(season) ) }
|
||||
|
||||
|
|
|
|||
|
|
@ -300,7 +300,8 @@ struct database_fixture {
|
|||
void update_event(event_id_type event_id,
|
||||
fc::optional<object_id_type> event_group_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
fc::optional<internationalized_string_type> season);
|
||||
fc::optional<internationalized_string_type> season,
|
||||
fc::optional<bool> is_live_market);
|
||||
const betting_market_rules_object& create_betting_market_rules(internationalized_string_type name, internationalized_string_type description);
|
||||
void update_betting_market_rules(betting_market_rules_id_type rules_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
|
|
|
|||
Loading…
Reference in a new issue