Review comments - change variable names, use scoped enums

This commit is contained in:
sierra19XX 2020-08-04 14:12:15 +00:00
parent b2e2d7e966
commit 218d826e65
8 changed files with 41 additions and 40 deletions

View file

@ -18,8 +18,8 @@ namespace graphene { namespace chain {
std::string base_uri;
optional<account_id_type> revenue_partner;
optional<double> revenue_split;
bool isTransferable = false;
bool isSellable = true;
bool is_transferable = false;
bool is_sellable = true;
};
class nft_object : public abstract_object<nft_object>
@ -94,8 +94,8 @@ FC_REFLECT_DERIVED( graphene::chain::nft_metadata_object, (graphene::db::object)
(base_uri)
(revenue_partner)
(revenue_split)
(isTransferable)
(isSellable) )
(is_transferable)
(is_sellable) )
FC_REFLECT_DERIVED( graphene::chain::nft_object, (graphene::db::object),
(nft_metadata_id)

View file

@ -15,8 +15,8 @@ namespace graphene { namespace chain {
std::string base_uri;
optional<account_id_type> revenue_partner;
optional<double> revenue_split;
bool isTransferable = false;
bool isSellable = true;
bool is_transferable = false;
bool is_sellable = true;
account_id_type fee_payer()const { return owner; }
void validate() const;
@ -34,8 +34,8 @@ namespace graphene { namespace chain {
optional<std::string> base_uri;
optional<account_id_type> revenue_partner;
optional<double> revenue_split;
optional<bool> isTransferable;
optional<bool> isSellable;
optional<bool> is_transferable;
optional<bool> is_sellable;
account_id_type fee_payer()const { return owner; }
void validate() const;
@ -108,8 +108,8 @@ FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_ty
FC_REFLECT( graphene::chain::nft_approve_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (isTransferable) (isSellable) )
FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (isTransferable) (isSellable) )
FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) )
FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) )
FC_REFLECT( graphene::chain::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) )
FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) )
FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) )

View file

@ -114,7 +114,7 @@ namespace graphene
offer_id_type offer_id;
fc::enum_type<uint8_t, result_type> result;
result_type result;
extensions_type extensions;

View file

@ -27,8 +27,8 @@ object_id_type nft_metadata_create_evaluator::do_apply( const nft_metadata_creat
obj.base_uri = op.base_uri;
obj.revenue_partner = op.revenue_partner;
obj.revenue_split = op.revenue_split;
obj.isTransferable = op.isTransferable;
obj.isSellable = op.isSellable;
obj.is_transferable = op.is_transferable;
obj.is_sellable = op.is_sellable;
});
return new_nft_metadata_object.id;
} FC_CAPTURE_AND_RETHROW( (op) ) }
@ -62,10 +62,10 @@ void_result nft_metadata_update_evaluator::do_apply( const nft_metadata_update_o
obj.revenue_partner = op.revenue_partner;
if( op.revenue_split.valid() )
obj.revenue_split = op.revenue_split;
if( op.isTransferable.valid() )
obj.isTransferable = *op.isTransferable;
if( op.isSellable.valid() )
obj.isSellable = *op.isSellable;
if( op.is_transferable.valid() )
obj.is_transferable = *op.is_transferable;
if( op.is_sellable.valid() )
obj.is_sellable = *op.is_sellable;
});
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
@ -127,7 +127,7 @@ void_result nft_safe_transfer_from_evaluator::do_evaluate( const nft_safe_transf
FC_ASSERT( (itr_nft->owner == op.operator_) || (itr_nft->approved == itr_operator->id) || (itr_approved_op != itr_nft->approved_operators.end()), "Operator is not NFT owner or approved operator" );
const auto& nft_meta_obj = itr_nft->nft_metadata_id(db());
FC_ASSERT( nft_meta_obj.isTransferable == true, "NFT is not transferable");
FC_ASSERT( nft_meta_obj.is_transferable == true, "NFT is not transferable");
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }

View file

@ -34,8 +34,8 @@ namespace graphene
{
FC_ASSERT(is_owner, "Issuer has no authority to sell the item");
}
const auto& nft_meta_obj = nft_obj.nft_metadata_id(d);
FC_ASSERT( nft_meta_obj.isSellable == true, "NFT is not sellable");
const auto &nft_meta_obj = nft_obj.nft_metadata_id(d);
FC_ASSERT(nft_meta_obj.is_sellable == true, "NFT is not sellable");
}
FC_ASSERT(op.offer_expiration_date > d.head_block_time(), "Expiration should be in future");
FC_ASSERT(op.fee.amount >= 0, "Invalid fee");
@ -160,7 +160,7 @@ namespace graphene
database &d = db();
const auto &offer = op.offer_id(d);
if(offer.buying_item)
if (offer.buying_item)
{
// Refund the max price to issuer
d.adjust_balance(offer.issuer, offer.maximum_price);
@ -243,9 +243,10 @@ namespace graphene
const auto &rev_partner = *nft_meta_obj.revenue_partner;
const auto &rev_split = *nft_meta_obj.revenue_split;
int64_t item_fee = static_cast<int64_t>((rev_split * (*offer.bid_price).amount.value) / offer.item_ids.size());
const auto& fee_asset = asset(item_fee, (*offer.bid_price).asset_id);
const auto &fee_asset = asset(item_fee, (*offer.bid_price).asset_id);
auto ret_val = fee_map.insert({rev_partner, fee_asset});
if ( ret_val.second == false ) {
if (ret_val.second == false)
{
fee_map[rev_partner] += fee_asset;
}
tot_fees += item_fee;

View file

@ -1937,8 +1937,8 @@ class wallet_api
* @param base_uri Base URI for token URI
* @param revenue_partner revenue partner for this type of Token
* @param revenue_split revenue split for the sale
* @param isTransferable can transfer the NFT or not
* @param isSellable can sell NFT or not
* @param is_transferable can transfer the NFT or not
* @param is_sellable can sell NFT or not
* @param broadcast true to broadcast transaction to the network
* @return Signed transaction transfering the funds
*/
@ -1948,8 +1948,8 @@ class wallet_api
string base_uri,
optional<string> revenue_partner,
optional<double> revenue_split,
bool isTransferable,
bool isSellable,
bool is_transferable,
bool is_sellable,
bool broadcast);
/**
@ -1960,8 +1960,8 @@ class wallet_api
* @param base_uri Base URI for token URI
* @param revenue_partner revenue partner for this type of Token
* @param revenue_split revenue split for the sale
* @param isTransferable can transfer the NFT or not
* @param isSellable can sell NFT or not
* @param is_transferable can transfer the NFT or not
* @param is_sellable can sell NFT or not
* @param broadcast true to broadcast transaction to the network
* @return Signed transaction transfering the funds
*/
@ -1971,8 +1971,8 @@ class wallet_api
string base_uri,
optional<string> revenue_partner,
optional<double> revenue_split,
optional<bool> isTransferable,
optional<bool> isSellable,
optional<bool> is_transferable,
optional<bool> is_sellable,
bool broadcast);
/**

View file

@ -6373,8 +6373,8 @@ signed_transaction wallet_api::nft_metadata_create(string owner_account_id_or_na
string base_uri,
optional<string> revenue_partner,
optional<double> revenue_split,
bool isTransferable,
bool isSellable,
bool is_transferable,
bool is_sellable,
bool broadcast)
{
account_object owner_account = my->get_account(owner_account_id_or_name);
@ -6395,8 +6395,8 @@ signed_transaction wallet_api::nft_metadata_create(string owner_account_id_or_na
}
op.revenue_split = rev_split;
}
op.isTransferable = isTransferable;
op.isSellable = isSellable;
op.is_transferable = is_transferable;
op.is_sellable = is_sellable;
signed_transaction trx;
trx.operations.push_back(op);
@ -6412,8 +6412,8 @@ signed_transaction wallet_api::nft_metadata_update(string owner_account_id_or_na
string base_uri,
optional<string> revenue_partner,
optional<double> revenue_split,
optional<bool> isTransferable,
optional<bool> isSellable,
optional<bool> is_transferable,
optional<bool> is_sellable,
bool broadcast)
{
account_object owner_account = my->get_account(owner_account_id_or_name);
@ -6434,8 +6434,8 @@ signed_transaction wallet_api::nft_metadata_update(string owner_account_id_or_na
}
op.revenue_split = rev_split;
}
op.isTransferable = isTransferable;
op.isSellable = isSellable;
op.is_transferable = is_transferable;
op.is_sellable = is_sellable;
signed_transaction trx;
trx.operations.push_back(op);

View file

@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE( nft_metadata_create_test ) {
op.symbol = "NFT";
op.base_uri = "http://nft.example.com";
op.name = "123";
op.isTransferable = true;
op.is_transferable = true;
BOOST_CHECK_THROW(op.validate(), fc::exception);
op.name = "";
BOOST_CHECK_THROW(op.validate(), fc::exception);