Add son_wallet_transfer_process_operation

This commit is contained in:
Srdjan Obucina 2020-02-05 14:07:00 +01:00
parent 01f1b6137a
commit bb8d334e6c
6 changed files with 56 additions and 0 deletions

View file

@ -325,6 +325,9 @@ struct get_impacted_account_visitor
void operator()( const son_wallet_transfer_create_operation& op ){
_impacted.insert( op.payer );
}
void operator()( const son_wallet_transfer_process_operation& op ){
_impacted.insert( op.payer );
}
void operator()( const sidechain_address_add_operation& op ){
_impacted.insert( op.sidechain_address_account );
}

View file

@ -312,6 +312,9 @@ struct get_impacted_account_visitor
void operator()( const son_wallet_transfer_create_operation& op ) {
_impacted.insert( op.payer );
}
void operator()( const son_wallet_transfer_process_operation& op ) {
_impacted.insert( op.payer );
}
void operator()( const sidechain_address_add_operation& op ) {
_impacted.insert( op.sidechain_address_account );
}

View file

@ -149,6 +149,7 @@ namespace graphene { namespace chain {
son_wallet_recreate_operation,
son_wallet_update_operation,
son_wallet_transfer_create_operation,
son_wallet_transfer_process_operation,
sidechain_address_add_operation,
sidechain_address_update_operation,
sidechain_address_delete_operation

View file

@ -22,8 +22,24 @@ namespace graphene { namespace chain {
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
};
struct son_wallet_transfer_process_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = 0; };
asset fee;
account_id_type payer;
son_wallet_transfer_id_type son_wallet_transfer_id;
account_id_type fee_payer()const { return payer; }
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
};
} } // namespace graphene::chain
FC_REFLECT(graphene::chain::son_wallet_transfer_create_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_wallet_transfer_create_operation, (fee)(payer)
(uid) (timestamp) (sidechain) (transaction_id) (from) (to) (amount))
FC_REFLECT(graphene::chain::son_wallet_transfer_process_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_wallet_transfer_process_operation, (fee)(payer)
(son_wallet_transfer_id))

View file

@ -12,4 +12,13 @@ public:
object_id_type do_apply(const son_wallet_transfer_create_operation& o);
};
class process_son_wallet_transfer_evaluator : public evaluator<process_son_wallet_transfer_evaluator>
{
public:
typedef son_wallet_transfer_process_operation operation_type;
void_result do_evaluate(const son_wallet_transfer_process_operation& o);
object_id_type do_apply(const son_wallet_transfer_process_operation& o);
};
} } // namespace graphene::chain

View file

@ -31,4 +31,28 @@ object_id_type create_son_wallet_transfer_evaluator::do_apply(const son_wallet_t
return new_son_wallet_transfer_object.id;
} FC_CAPTURE_AND_RETHROW( (op) ) }
void_result process_son_wallet_transfer_evaluator::do_evaluate(const son_wallet_transfer_process_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
//FC_ASSERT(db().get_global_properties().parameters.get_son_btc_account_id() != GRAPHENE_NULL_ACCOUNT, "SON paying account not set.");
FC_ASSERT( op.payer == db().get_global_properties().parameters.get_son_btc_account_id() );
const auto& idx = db().get_index_type<son_wallet_transfer_index>().indices().get<by_id>();
FC_ASSERT(idx.find(op.son_wallet_transfer_id) != idx.end(), "Son wallet transfer not found");
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type process_son_wallet_transfer_evaluator::do_apply(const son_wallet_transfer_process_operation& op)
{ try {
const auto& idx = db().get_index_type<son_wallet_transfer_index>().indices().get<by_id>();
auto itr = idx.find(op.son_wallet_transfer_id);
if(itr != idx.end())
{
db().modify(*itr, [&op](son_wallet_transfer_object &swto) {
swto.processed = true;
});
}
return op.son_wallet_transfer_id;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} } // namespace graphene::chain