HARDFORK - adding operation to claim asset fees #413
This commit is contained in:
parent
a1b00b2749
commit
5d6091e581
9 changed files with 68 additions and 4 deletions
|
|
@ -39,6 +39,7 @@ struct get_impacted_account_visitor
|
|||
_impacted.insert( op.to );
|
||||
}
|
||||
|
||||
void operator()( const asset_claim_fees_operation& op ){}
|
||||
void operator()( const limit_order_create_operation& op ) {}
|
||||
void operator()( const limit_order_cancel_operation& op )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -514,4 +514,31 @@ void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_ope
|
|||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
||||
|
||||
|
||||
|
||||
void_result asset_claim_fees_evaluator::do_evaluate( const asset_claim_fees_operation& o )
|
||||
{ try {
|
||||
FC_ASSERT( o.amount_to_claim.asset_id(db()).issuer == o.issuer, "Asset fees may only be claimed by the issuer" );
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||
|
||||
|
||||
void_result asset_claim_fees_evaluator::do_apply( const asset_claim_fees_operation& o )
|
||||
{ try {
|
||||
database& d = db();
|
||||
|
||||
const asset_object& a = o.amount_to_claim.asset_id(d);
|
||||
const asset_dynamic_data_object& addo = a.dynamic_asset_data_id(d);
|
||||
FC_ASSERT( o.amount_to_claim.amount <= addo.accumulated_fees, "Attempt to claim more fees than have accumulated", ("addo",addo) );
|
||||
|
||||
d.modify( addo, [&]( asset_dynamic_data_object& _addo ) {
|
||||
_addo.accumulated_fees -= o.amount_to_claim.amount;
|
||||
});
|
||||
|
||||
d.adjust_balance( o.issuer, o.amount_to_claim );
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ void database::initialize_evaluators()
|
|||
register_evaluator<transfer_to_blind_evaluator>();
|
||||
register_evaluator<transfer_from_blind_evaluator>();
|
||||
register_evaluator<blind_transfer_evaluator>();
|
||||
register_evaluator<asset_claim_fees_evaluator>();
|
||||
}
|
||||
|
||||
void database::initialize_indexes()
|
||||
|
|
|
|||
|
|
@ -133,4 +133,13 @@ namespace graphene { namespace chain {
|
|||
std::map<std::pair<asset_id_type,asset_id_type>,price_feed> median_feed_values;
|
||||
};
|
||||
|
||||
class asset_claim_fees_evaluator : public evaluator<asset_claim_fees_evaluator>
|
||||
{
|
||||
public:
|
||||
typedef asset_claim_fees_operation operation_type;
|
||||
|
||||
void_result do_evaluate( const asset_claim_fees_operation& o );
|
||||
void_result do_apply( const asset_claim_fees_operation& o );
|
||||
};
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
|
|||
|
|
@ -20,5 +20,3 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 ))
|
||||
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
|
||||
|
|
|
|||
|
|
@ -420,8 +420,30 @@ namespace graphene { namespace chain {
|
|||
void validate()const;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief used to transfer accumulated fees back to the issuer's balance.
|
||||
*/
|
||||
struct asset_claim_fees_operation : public base_operation
|
||||
{
|
||||
struct fee_parameters_type {
|
||||
uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
|
||||
};
|
||||
|
||||
asset fee;
|
||||
account_id_type issuer;
|
||||
asset amount_to_claim; /// amount_to_claim.asset_id->issuer must == issuer
|
||||
extensions_type extensions;
|
||||
|
||||
account_id_type fee_payer()const { return issuer; }
|
||||
void validate()const;
|
||||
};
|
||||
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT( graphene::chain::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) )
|
||||
FC_REFLECT( graphene::chain::asset_claim_fees_operation::fee_parameters_type, (fee) )
|
||||
|
||||
FC_REFLECT( graphene::chain::asset_options,
|
||||
(max_supply)
|
||||
(market_fee_percent)
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ namespace graphene { namespace chain {
|
|||
transfer_to_blind_operation,
|
||||
blind_transfer_operation,
|
||||
transfer_from_blind_operation,
|
||||
|
||||
asset_settle_cancel_operation // VIRTUAL
|
||||
asset_settle_cancel_operation, // VIRTUAL
|
||||
asset_claim_fees_operation
|
||||
> operation;
|
||||
|
||||
/// @} // operations group
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ asset limit_order_cancel_evaluator::do_apply(const limit_order_cancel_operation&
|
|||
auto quote_asset = _order->sell_price.quote.asset_id;
|
||||
auto refunded = _order->amount_for_sale();
|
||||
|
||||
/// TODO... implement this refund in a better way
|
||||
if( true ) // HARD FORK d.head_block_time() >
|
||||
{
|
||||
const auto& fees = d.current_fee_schedule();
|
||||
|
|
|
|||
|
|
@ -224,4 +224,9 @@ void asset_options::validate()const
|
|||
}
|
||||
}
|
||||
|
||||
void asset_claim_fees_operation::validate()const {
|
||||
FC_ASSERT( fee.amount >= 0 );
|
||||
FC_ASSERT( amount_to_claim.amount > 0 );
|
||||
}
|
||||
|
||||
} } // namespace graphene::chain
|
||||
|
|
|
|||
Loading…
Reference in a new issue