added sport_update_operation
This commit is contained in:
parent
a70c3799e5
commit
a24f671c02
13 changed files with 123 additions and 0 deletions
|
|
@ -210,6 +210,7 @@ struct get_impacted_account_visitor
|
|||
}
|
||||
|
||||
void operator()( const sport_create_operation& op ) {}
|
||||
void operator()( const sport_update_operation& op ) {}
|
||||
void operator()( const event_group_create_operation& op ) {}
|
||||
void operator()( const event_create_operation& op ) {}
|
||||
void operator()( const betting_market_rules_create_operation& op ) {}
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ void database::initialize_evaluators()
|
|||
register_evaluator<blind_transfer_evaluator>();
|
||||
register_evaluator<asset_claim_fees_evaluator>();
|
||||
register_evaluator<sport_create_evaluator>();
|
||||
register_evaluator<sport_update_evaluator>();
|
||||
register_evaluator<event_group_create_evaluator>();
|
||||
register_evaluator<event_create_evaluator>();
|
||||
register_evaluator<betting_market_rules_create_evaluator>();
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ struct get_impacted_account_visitor
|
|||
_impacted.insert( op.account_id );
|
||||
}
|
||||
void operator()(const sport_create_operation&){}
|
||||
void operator()(const sport_update_operation&){}
|
||||
void operator()(const event_group_create_operation&){}
|
||||
void operator()(const event_create_operation&){}
|
||||
void operator()(const betting_market_rules_create_operation&){}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,9 @@ namespace graphene { namespace chain {
|
|||
asset_update_dividend_operation,
|
||||
asset_dividend_distribution_operation, // VIRTUAL
|
||||
sport_create_operation,
|
||||
sport_update_operation,
|
||||
event_group_create_operation,
|
||||
/*event_group_update_operation,*/
|
||||
event_create_operation,
|
||||
betting_market_rules_create_operation,
|
||||
betting_market_group_create_operation,
|
||||
|
|
|
|||
|
|
@ -44,8 +44,27 @@ struct sport_create_operation : public base_operation
|
|||
void validate()const;
|
||||
};
|
||||
|
||||
struct sport_update_operation : public base_operation
|
||||
{
|
||||
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
|
||||
asset fee;
|
||||
|
||||
sport_id_type sport_id;
|
||||
|
||||
optional<internationalized_string_type> new_name;
|
||||
|
||||
extensions_type extensions;
|
||||
|
||||
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
||||
void validate()const;
|
||||
};
|
||||
|
||||
} }
|
||||
|
||||
FC_REFLECT( graphene::chain::sport_create_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::sport_create_operation,
|
||||
(fee)(name)(extensions) )
|
||||
|
||||
FC_REFLECT( graphene::chain::sport_update_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT( graphene::chain::sport_update_operation,
|
||||
(fee)(sport_id)(new_name)(extensions) )
|
||||
|
|
|
|||
|
|
@ -38,4 +38,14 @@ namespace graphene { namespace chain {
|
|||
object_id_type do_apply( const sport_create_operation& o );
|
||||
};
|
||||
|
||||
class sport_update_evaluator : public evaluator<sport_update_evaluator>
|
||||
{
|
||||
public:
|
||||
typedef sport_update_operation operation_type;
|
||||
|
||||
void_result do_evaluate( const sport_update_operation& o );
|
||||
void_result do_apply( const sport_update_operation& o );
|
||||
};
|
||||
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ void sport_create_operation::validate() const
|
|||
FC_ASSERT( fee.amount >= 0 );
|
||||
}
|
||||
|
||||
void sport_update_operation::validate() const
|
||||
{
|
||||
FC_ASSERT( fee.amount >= 0 );
|
||||
}
|
||||
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
|
|
|
|||
|
|
@ -47,4 +47,26 @@ object_id_type sport_create_evaluator::do_apply(const sport_create_operation& op
|
|||
return new_sport.id;
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
|
||||
void_result sport_update_evaluator::do_evaluate(const sport_update_operation& op)
|
||||
{ try {
|
||||
FC_ASSERT(trx_state->_is_proposed_trx);
|
||||
FC_ASSERT(op.new_name.valid());
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
void_result sport_update_evaluator::do_apply(const sport_update_operation& op)
|
||||
{ try {
|
||||
database& _db = db();
|
||||
_db.modify(
|
||||
_db.get(op.sport_id),
|
||||
[&]( sport_object& spo )
|
||||
{
|
||||
if( op.new_name.valid() )
|
||||
spo.name = *op.new_name;
|
||||
});
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
|
|||
|
|
@ -1582,6 +1582,13 @@ class wallet_api
|
|||
internationalized_string_type name,
|
||||
bool broadcast = false);
|
||||
|
||||
signed_transaction propose_update_sport(
|
||||
const string& proposing_account,
|
||||
fc::time_point_sec expiration_time,
|
||||
sport_id_type sport_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
bool broadcast = false);
|
||||
|
||||
signed_transaction propose_create_event_group(
|
||||
const string& proposing_account,
|
||||
fc::time_point_sec expiration_time,
|
||||
|
|
|
|||
|
|
@ -5047,6 +5047,35 @@ signed_transaction wallet_api::propose_create_sport(
|
|||
return my->sign_transaction(tx, broadcast);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::propose_update_sport(
|
||||
const string& proposing_account,
|
||||
fc::time_point_sec expiration_time,
|
||||
sport_id_type sport_id,
|
||||
fc::optional<internationalized_string_type> name,
|
||||
bool broadcast /*= false*/)
|
||||
{
|
||||
FC_ASSERT( !is_locked() );
|
||||
const chain_parameters& current_params = get_global_properties().parameters;
|
||||
|
||||
sport_update_operation sport_update_op;
|
||||
sport_update_op.sport_id = sport_id;
|
||||
sport_update_op.new_name = name;
|
||||
|
||||
proposal_create_operation prop_op;
|
||||
prop_op.expiration_time = expiration_time;
|
||||
prop_op.review_period_seconds = current_params.committee_proposal_review_period;
|
||||
prop_op.fee_paying_account = get_account(proposing_account).id;
|
||||
prop_op.proposed_ops.emplace_back( sport_update_op );
|
||||
current_params.current_fees->set_fee( prop_op.proposed_ops.back().op );
|
||||
|
||||
signed_transaction tx;
|
||||
tx.operations.push_back(prop_op);
|
||||
my->set_operation_fees(tx, current_params.current_fees);
|
||||
tx.validate();
|
||||
|
||||
return my->sign_transaction(tx, broadcast);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::propose_create_event_group(
|
||||
const string& proposing_account,
|
||||
fc::time_point_sec expiration_time,
|
||||
|
|
|
|||
|
|
@ -180,6 +180,23 @@ BOOST_AUTO_TEST_CASE( peerplays_sport_create_test )
|
|||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(peerplays_sport_update_test)
|
||||
{
|
||||
try
|
||||
{
|
||||
ACTORS( (alice) );
|
||||
CREATE_ICE_HOCKEY_BETTING_MARKET();
|
||||
update_sport(ice_hockey.id, {{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}});
|
||||
|
||||
transfer(account_id_type(), alice_id, asset(10000000));
|
||||
place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION, 1000000 / 50 /* chain defaults to 2% fees */);
|
||||
|
||||
BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 20000);
|
||||
|
||||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( cancel_unmatched_in_betting_group_test )
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -1208,6 +1208,14 @@ const sport_object& database_fixture::create_sport(internationalized_string_type
|
|||
return *sport_index.rbegin();
|
||||
} FC_CAPTURE_AND_RETHROW( (name) ) }
|
||||
|
||||
void database_fixture::update_sport(sport_id_type sport_id, internationalized_string_type name)
|
||||
{ try {
|
||||
sport_update_operation sport_update_op;
|
||||
sport_update_op.sport_id = sport_id;
|
||||
sport_update_op.new_name = name;
|
||||
process_operation_by_witnesses(sport_update_op);
|
||||
} FC_CAPTURE_AND_RETHROW( (sport_id)(name) ) }
|
||||
|
||||
const event_group_object& database_fixture::create_event_group(internationalized_string_type name, sport_id_type sport_id)
|
||||
{ try {
|
||||
event_group_create_operation event_group_create_op;
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ struct database_fixture {
|
|||
vector< operation_history_object > get_operation_history( account_id_type account_id )const;
|
||||
void process_operation_by_witnesses(operation op);
|
||||
const sport_object& create_sport(internationalized_string_type name);
|
||||
void update_sport(sport_id_type sport_id, internationalized_string_type name);
|
||||
const event_group_object& create_event_group(internationalized_string_type name, sport_id_type sport_id);
|
||||
const event_object& create_event(internationalized_string_type name, internationalized_string_type season, event_group_id_type event_group_id);
|
||||
const betting_market_rules_object& create_betting_market_rules(internationalized_string_type name, internationalized_string_type description);
|
||||
|
|
|
|||
Loading…
Reference in a new issue