Added sport_delete operation, evaluator and API. Fixed various compilation issues.
Added tests file.
This commit is contained in:
parent
ce35081ad1
commit
4f501f6aaf
11 changed files with 127 additions and 0 deletions
|
|
@ -211,6 +211,7 @@ struct get_impacted_account_visitor
|
||||||
|
|
||||||
void operator()( const sport_create_operation& op ) {}
|
void operator()( const sport_create_operation& op ) {}
|
||||||
void operator()( const sport_update_operation& op ) {}
|
void operator()( const sport_update_operation& op ) {}
|
||||||
|
void operator()( const sport_delete_operation& op ) {}
|
||||||
void operator()( const event_group_create_operation& op ) {}
|
void operator()( const event_group_create_operation& op ) {}
|
||||||
void operator()( const event_group_update_operation& op ) {}
|
void operator()( const event_group_update_operation& op ) {}
|
||||||
void operator()( const event_create_operation& op ) {}
|
void operator()( const event_create_operation& op ) {}
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ void database::initialize_evaluators()
|
||||||
register_evaluator<asset_claim_fees_evaluator>();
|
register_evaluator<asset_claim_fees_evaluator>();
|
||||||
register_evaluator<sport_create_evaluator>();
|
register_evaluator<sport_create_evaluator>();
|
||||||
register_evaluator<sport_update_evaluator>();
|
register_evaluator<sport_update_evaluator>();
|
||||||
|
register_evaluator<sport_delete_evaluator>();
|
||||||
register_evaluator<event_group_create_evaluator>();
|
register_evaluator<event_group_create_evaluator>();
|
||||||
register_evaluator<event_group_update_evaluator>();
|
register_evaluator<event_group_update_evaluator>();
|
||||||
register_evaluator<event_create_evaluator>();
|
register_evaluator<event_create_evaluator>();
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ struct get_impacted_account_visitor
|
||||||
}
|
}
|
||||||
void operator()(const sport_create_operation&){}
|
void operator()(const sport_create_operation&){}
|
||||||
void operator()(const sport_update_operation&){}
|
void operator()(const sport_update_operation&){}
|
||||||
|
void operator()(const sport_delete_operation&){}
|
||||||
void operator()(const event_group_create_operation&){}
|
void operator()(const event_group_create_operation&){}
|
||||||
void operator()(const event_group_update_operation& op ) {}
|
void operator()(const event_group_update_operation& op ) {}
|
||||||
void operator()(const event_create_operation&){}
|
void operator()(const event_create_operation&){}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ namespace graphene { namespace chain {
|
||||||
tournament_leave_operation,
|
tournament_leave_operation,
|
||||||
sport_create_operation,
|
sport_create_operation,
|
||||||
sport_update_operation,
|
sport_update_operation,
|
||||||
|
sport_delete_operation,
|
||||||
event_group_create_operation,
|
event_group_create_operation,
|
||||||
event_group_update_operation,
|
event_group_update_operation,
|
||||||
event_create_operation,
|
event_create_operation,
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,19 @@ struct sport_update_operation : public base_operation
|
||||||
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
||||||
void validate()const;
|
void validate()const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sport_delete_operation : public base_operation
|
||||||
|
{
|
||||||
|
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
|
||||||
|
asset fee;
|
||||||
|
|
||||||
|
sport_id_type sport_id;
|
||||||
|
|
||||||
|
extensions_type extensions;
|
||||||
|
|
||||||
|
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
|
||||||
|
void validate()const;
|
||||||
|
};
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|
@ -68,3 +81,7 @@ FC_REFLECT( graphene::chain::sport_create_operation,
|
||||||
FC_REFLECT( graphene::chain::sport_update_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::sport_update_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT( graphene::chain::sport_update_operation,
|
FC_REFLECT( graphene::chain::sport_update_operation,
|
||||||
(fee)(sport_id)(new_name)(extensions) )
|
(fee)(sport_id)(new_name)(extensions) )
|
||||||
|
|
||||||
|
FC_REFLECT( graphene::chain::sport_delete_operation::fee_parameters_type, (fee) )
|
||||||
|
FC_REFLECT( graphene::chain::sport_delete_operation,
|
||||||
|
(fee)(sport_id)(extensions) )
|
||||||
|
|
|
||||||
|
|
@ -47,4 +47,13 @@ namespace graphene { namespace chain {
|
||||||
void_result do_apply( const sport_update_operation& o );
|
void_result do_apply( const sport_update_operation& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class sport_delete_evaluator : public evaluator<sport_delete_evaluator>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef sport_delete_operation operation_type;
|
||||||
|
|
||||||
|
void_result do_evaluate( const sport_delete_operation& o );
|
||||||
|
void_result do_apply( const sport_delete_operation& o );
|
||||||
|
};
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@ void sport_update_operation::validate() const
|
||||||
FC_ASSERT( fee.amount >= 0 );
|
FC_ASSERT( fee.amount >= 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sport_delete_operation::validate() const
|
||||||
|
{
|
||||||
|
FC_ASSERT( fee.amount >= 0 );
|
||||||
|
}
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,5 +70,11 @@ void_result sport_update_evaluator::do_evaluate(const sport_update_operation& op
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
|
||||||
|
void_result sport_delete_evaluator::do_evaluate( const sport_delete_operation& o )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void_result sport_delete_evaluator::do_apply( const sport_delete_operation& o )
|
||||||
|
{}
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -1605,6 +1605,12 @@ class wallet_api
|
||||||
sport_id_type sport_id,
|
sport_id_type sport_id,
|
||||||
fc::optional<internationalized_string_type> name,
|
fc::optional<internationalized_string_type> name,
|
||||||
bool broadcast = false);
|
bool broadcast = false);
|
||||||
|
|
||||||
|
signed_transaction propose_delete_sport(
|
||||||
|
const string& proposing_account,
|
||||||
|
fc::time_point_sec expiration_time,
|
||||||
|
sport_id_type sport_id,
|
||||||
|
bool broadcast = false);
|
||||||
|
|
||||||
signed_transaction propose_create_event_group(
|
signed_transaction propose_create_event_group(
|
||||||
const string& proposing_account,
|
const string& proposing_account,
|
||||||
|
|
|
||||||
|
|
@ -5138,6 +5138,33 @@ signed_transaction wallet_api::propose_update_sport(
|
||||||
return my->sign_transaction(tx, broadcast);
|
return my->sign_transaction(tx, broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signed_transaction wallet_api::propose_delete_sport(
|
||||||
|
const string& proposing_account,
|
||||||
|
fc::time_point_sec expiration_time,
|
||||||
|
sport_id_type sport_id,
|
||||||
|
bool broadcast /*= false*/)
|
||||||
|
{
|
||||||
|
FC_ASSERT( !is_locked() );
|
||||||
|
const chain_parameters& current_params = get_global_properties().parameters;
|
||||||
|
|
||||||
|
sport_delete_operation sport_delete_op;
|
||||||
|
sport_delete_op.sport_id = sport_id;
|
||||||
|
|
||||||
|
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_delete_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(
|
signed_transaction wallet_api::propose_create_event_group(
|
||||||
const string& proposing_account,
|
const string& proposing_account,
|
||||||
fc::time_point_sec expiration_time,
|
fc::time_point_sec expiration_time,
|
||||||
|
|
|
||||||
54
tests/tests/sports_and_events_tests.cpp
Normal file
54
tests/tests/sports_and_events_tests.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
||||||
|
*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <graphene/chain/database.hpp>
|
||||||
|
#include <graphene/chain/exceptions.hpp>
|
||||||
|
#include <graphene/chain/hardfork.hpp>
|
||||||
|
|
||||||
|
#include <graphene/chain/account_object.hpp>
|
||||||
|
#include <graphene/chain/asset_object.hpp>
|
||||||
|
#include <graphene/chain/committee_member_object.hpp>
|
||||||
|
#include <graphene/chain/market_object.hpp>
|
||||||
|
#include <graphene/chain/vesting_balance_object.hpp>
|
||||||
|
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||||
|
#include <graphene/chain/witness_object.hpp>
|
||||||
|
#include <graphene/account_history/account_history_plugin.hpp>
|
||||||
|
|
||||||
|
#include <fc/crypto/digest.hpp>
|
||||||
|
|
||||||
|
#include "../common/database_fixture.hpp"
|
||||||
|
|
||||||
|
using namespace graphene::chain;
|
||||||
|
using namespace graphene::chain::test;
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_SUITE( sports_and_events_tests, database_fixture )
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( propose_delete_sport )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
Loading…
Reference in a new issue