diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index c654ae6c..88d868e5 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -123,7 +123,7 @@ add_library( graphene_chain offer_object.cpp offer_evaluator.cpp nft_evaluator.cpp - nft_object.cpp + protocol/nft.cpp ${HEADERS} ${PROTOCOL_HEADERS} diff --git a/libraries/chain/custom_account_authority_evaluator.cpp b/libraries/chain/custom_account_authority_evaluator.cpp index 6b7044a4..200590f6 100644 --- a/libraries/chain/custom_account_authority_evaluator.cpp +++ b/libraries/chain/custom_account_authority_evaluator.cpp @@ -27,7 +27,7 @@ struct rbac_operation_hardfork_visitor case operation::tag::value: case operation::tag::value: case operation::tag::value: - FC_ASSERT(block_time >= HARDFORK_RBAC_TIME, "Custom permission not allowed on this operation yet!"); + FC_ASSERT(block_time >= HARDFORK_NFT_TIME, "Custom permission not allowed on this operation yet!"); break; default: FC_ASSERT(op_type < first_allowed_op, "Custom permission not allowed on this operation!"); @@ -41,7 +41,7 @@ void_result create_custom_account_authority_evaluator::do_evaluate(const custom_ { const database &d = db(); auto now = d.head_block_time(); - FC_ASSERT(now >= HARDFORK_RBAC_TIME, "Not allowed until RBAC HF"); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner_account(d); const custom_permission_object &pobj = op.permission_id(d); FC_ASSERT(pobj.account == op.owner_account, "Only owner account can update account authority object"); @@ -79,7 +79,7 @@ void_result update_custom_account_authority_evaluator::do_evaluate(const custom_ { const database &d = db(); auto now = d.head_block_time(); - FC_ASSERT(now >= HARDFORK_RBAC_TIME, "Not allowed until RBAC HF"); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner_account(d); const custom_account_authority_object &aobj = op.auth_id(d); const custom_permission_object &pobj = aobj.permission_id(d); @@ -126,7 +126,7 @@ void_result delete_custom_account_authority_evaluator::do_evaluate(const custom_ { const database &d = db(); auto now = d.head_block_time(); - FC_ASSERT(now >= HARDFORK_RBAC_TIME, "Not allowed until RBAC HF"); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner_account(d); const custom_account_authority_object &aobj = op.auth_id(d); const custom_permission_object &pobj = aobj.permission_id(d); diff --git a/libraries/chain/custom_permission_evaluator.cpp b/libraries/chain/custom_permission_evaluator.cpp index 3a8b0722..77105e8e 100644 --- a/libraries/chain/custom_permission_evaluator.cpp +++ b/libraries/chain/custom_permission_evaluator.cpp @@ -16,7 +16,7 @@ void_result create_custom_permission_evaluator::do_evaluate(const custom_permiss { const database &d = db(); auto now = d.head_block_time(); - FC_ASSERT(now >= HARDFORK_RBAC_TIME, "Not allowed until RBAC HF"); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner_account(d); for (const auto &account_weight_pair : op.auth.account_auths) { @@ -54,7 +54,7 @@ void_result update_custom_permission_evaluator::do_evaluate(const custom_permiss { const database &d = db(); auto now = d.head_block_time(); - FC_ASSERT(now >= HARDFORK_RBAC_TIME, "Not allowed until RBAC HF"); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner_account(d); const custom_permission_object &pobj = op.permission_id(d); FC_ASSERT(pobj.account == op.owner_account, "Only owner account can update permission object"); @@ -93,7 +93,7 @@ void_result delete_custom_permission_evaluator::do_evaluate(const custom_permiss { const database &d = db(); auto now = d.head_block_time(); - FC_ASSERT(now >= HARDFORK_RBAC_TIME, "Not allowed until RBAC HF"); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner_account(d); const custom_permission_object &pobj = op.permission_id(d); FC_ASSERT(pobj.account == op.owner_account, "Only owner account can delete permission object"); diff --git a/libraries/chain/hardfork.d/NFT.hf b/libraries/chain/hardfork.d/NFT.hf new file mode 100644 index 00000000..a5139335 --- /dev/null +++ b/libraries/chain/hardfork.d/NFT.hf @@ -0,0 +1,4 @@ +// RBAC HARDFORK Wednesday, 20-May-20 00:00:00 UTC +#ifndef HARDFORK_NFT_TIME +#define HARDFORK_NFT_TIME (fc::time_point_sec( 1589932800 )) +#endif diff --git a/libraries/chain/hardfork.d/RBAC.hf b/libraries/chain/hardfork.d/RBAC.hf deleted file mode 100644 index e91e1b8b..00000000 --- a/libraries/chain/hardfork.d/RBAC.hf +++ /dev/null @@ -1,4 +0,0 @@ -// RBAC HARDFORK Wednesday, 20-May-20 00:00:00 UTC -#ifndef HARDFORK_RBAC_TIME -#define HARDFORK_RBAC_TIME (fc::time_point_sec( 1589932800 )) -#endif diff --git a/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp b/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp index 91da60ef..f5f8c1cd 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp +++ b/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp @@ -10,7 +10,8 @@ struct custom_account_authority_create_operation : public base_operation { struct fee_parameters_type { - uint64_t fee = 0; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -22,14 +23,14 @@ struct custom_account_authority_create_operation : public base_operation account_id_type fee_payer() const { return owner_account; } void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return 0; } + share_type calculate_fee(const fee_parameters_type &k) const; }; struct custom_account_authority_update_operation : public base_operation { struct fee_parameters_type { - uint64_t fee = 0; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -40,14 +41,14 @@ struct custom_account_authority_update_operation : public base_operation account_id_type fee_payer() const { return owner_account; } void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return 0; } + share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; struct custom_account_authority_delete_operation : public base_operation { struct fee_parameters_type { - uint64_t fee = 0; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -56,13 +57,13 @@ struct custom_account_authority_delete_operation : public base_operation account_id_type fee_payer() const { return owner_account; } void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return 0; } + share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; } // namespace chain } // namespace graphene -FC_REFLECT(graphene::chain::custom_account_authority_create_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::chain::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) FC_REFLECT(graphene::chain::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)) FC_REFLECT(graphene::chain::custom_account_authority_update_operation::fee_parameters_type, (fee)) diff --git a/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp b/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp index 32faf0e2..8093ef07 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp +++ b/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp @@ -10,7 +10,8 @@ struct custom_permission_create_operation : public base_operation { struct fee_parameters_type { - uint64_t fee = 0; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -20,14 +21,14 @@ struct custom_permission_create_operation : public base_operation account_id_type fee_payer() const { return owner_account; } void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return 0; } + share_type calculate_fee(const fee_parameters_type &k) const; }; struct custom_permission_update_operation : public base_operation { struct fee_parameters_type { - uint64_t fee = 0; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -37,14 +38,14 @@ struct custom_permission_update_operation : public base_operation account_id_type fee_payer() const { return owner_account; } void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return 0; } + share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; struct custom_permission_delete_operation : public base_operation { struct fee_parameters_type { - uint64_t fee = 0; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -53,13 +54,13 @@ struct custom_permission_delete_operation : public base_operation account_id_type fee_payer() const { return owner_account; } void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return 0; } + share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; } // namespace chain } // namespace graphene -FC_REFLECT(graphene::chain::custom_permission_create_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::chain::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) FC_REFLECT(graphene::chain::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)) FC_REFLECT(graphene::chain::custom_permission_update_operation::fee_parameters_type, (fee)) diff --git a/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp b/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp index 465ed987..afb85029 100644 --- a/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp +++ b/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp @@ -6,7 +6,11 @@ namespace graphene { namespace chain { struct nft_metadata_create_operation : public base_operation { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + struct fee_parameters_type + { + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; + }; asset fee; account_id_type owner; @@ -20,6 +24,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return owner; } void validate() const; + share_type calculate_fee(const fee_parameters_type &k) const; }; struct nft_metadata_update_operation : public base_operation @@ -39,11 +44,16 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return owner; } void validate() const; + share_type calculate_fee(const fee_parameters_type &k) const; }; struct nft_mint_operation : public base_operation { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + struct fee_parameters_type + { + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; + }; asset fee; account_id_type payer; @@ -56,11 +66,16 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return payer; } void validate() const; + share_type calculate_fee(const fee_parameters_type &k) const; }; struct nft_safe_transfer_from_operation : public base_operation { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + struct fee_parameters_type + { + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; + }; asset fee; account_id_type operator_; @@ -71,6 +86,7 @@ namespace graphene { namespace chain { string data; account_id_type fee_payer()const { return operator_; } + share_type calculate_fee(const fee_parameters_type &k) const; }; struct nft_approve_operation : public base_operation @@ -84,6 +100,7 @@ namespace graphene { namespace chain { nft_id_type token_id; account_id_type fee_payer()const { return operator_; } + share_type calculate_fee(const fee_parameters_type &k) const; }; struct nft_set_approval_for_all_operation : public base_operation @@ -97,14 +114,15 @@ namespace graphene { namespace chain { bool approved; account_id_type fee_payer()const { return owner; } + share_type calculate_fee(const fee_parameters_type &k) const; }; } } // graphene::chain -FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) FC_REFLECT( graphene::chain::nft_metadata_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_mint_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/offer.hpp b/libraries/chain/include/graphene/chain/protocol/offer.hpp index e1dbb082..2bf3dfc2 100644 --- a/libraries/chain/include/graphene/chain/protocol/offer.hpp +++ b/libraries/chain/include/graphene/chain/protocol/offer.hpp @@ -18,9 +18,8 @@ namespace graphene { struct fee_parameters_type { - uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = - 10 * GRAPHENE_BLOCKCHAIN_PRECISION; /// only required for large memos. + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; /// only required for large memos. }; asset fee; set item_ids; @@ -56,9 +55,7 @@ namespace graphene { struct fee_parameters_type { - uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = - 10 * GRAPHENE_BLOCKCHAIN_PRECISION; /// only required for large memos. + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -78,9 +75,7 @@ namespace graphene { struct fee_parameters_type { - uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = - 10 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; @@ -132,12 +127,12 @@ FC_REFLECT(graphene::chain::offer_operation, (fee)(item_ids)(issuer)(minimum_price)(maximum_price)(buying_item)(offer_expiration_date)(memo)(extensions)); FC_REFLECT(graphene::chain::bid_operation::fee_parameters_type, - (fee)(price_per_kbyte)); + (fee)); FC_REFLECT(graphene::chain::bid_operation, (fee)(bidder)(bid_price)(offer_id)(extensions)); FC_REFLECT(graphene::chain::cancel_offer_operation::fee_parameters_type, - (fee)(price_per_kbyte)); + (fee)); FC_REFLECT(graphene::chain::cancel_offer_operation, (fee)(issuer)(offer_id)(extensions)); diff --git a/libraries/chain/nft_evaluator.cpp b/libraries/chain/nft_evaluator.cpp index 7cd9ac87..76c632eb 100644 --- a/libraries/chain/nft_evaluator.cpp +++ b/libraries/chain/nft_evaluator.cpp @@ -1,10 +1,13 @@ #include #include +#include namespace graphene { namespace chain { void_result nft_metadata_create_evaluator::do_evaluate( const nft_metadata_create_operation& op ) { try { + auto now = db().head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner(db()); const auto& idx_nft_md_by_name = db().get_index_type().indices().get(); FC_ASSERT( idx_nft_md_by_name.find(op.name) == idx_nft_md_by_name.end(), "NFT name already in use" ); @@ -36,6 +39,8 @@ object_id_type nft_metadata_create_evaluator::do_apply( const nft_metadata_creat void_result nft_metadata_update_evaluator::do_evaluate( const nft_metadata_update_operation& op ) { try { + auto now = db().head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner(db()); const auto& idx_nft_md = db().get_index_type().indices().get(); auto itr_nft_md = idx_nft_md.find(op.nft_metadata_id); @@ -79,6 +84,8 @@ void_result nft_metadata_update_evaluator::do_apply( const nft_metadata_update_o void_result nft_mint_evaluator::do_evaluate( const nft_mint_operation& op ) { try { + auto now = db().head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.payer(db()); op.owner(db()); op.approved(db()); @@ -108,6 +115,8 @@ object_id_type nft_mint_evaluator::do_apply( const nft_mint_operation& op ) void_result nft_safe_transfer_from_evaluator::do_evaluate( const nft_safe_transfer_from_operation& op ) { try { + auto now = db().head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto& idx_nft = db().get_index_type().indices().get(); const auto& idx_acc = db().get_index_type().indices().get(); @@ -156,6 +165,8 @@ object_id_type nft_safe_transfer_from_evaluator::do_apply( const nft_safe_transf void_result nft_approve_evaluator::do_evaluate( const nft_approve_operation& op ) { try { + auto now = db().head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto& idx_nft = db().get_index_type().indices().get(); const auto& idx_acc = db().get_index_type().indices().get(); @@ -194,6 +205,8 @@ object_id_type nft_approve_evaluator::do_apply( const nft_approve_operation& op void_result nft_set_approval_for_all_evaluator::do_evaluate( const nft_set_approval_for_all_operation& op ) { try { + auto now = db().head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.owner(db()); const auto& idx_acc = db().get_index_type().indices().get(); diff --git a/libraries/chain/offer_evaluator.cpp b/libraries/chain/offer_evaluator.cpp index 47b5397f..3d9c58bc 100644 --- a/libraries/chain/offer_evaluator.cpp +++ b/libraries/chain/offer_evaluator.cpp @@ -16,6 +16,8 @@ namespace graphene try { const database &d = db(); + auto now = d.head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); op.issuer(d); for (const auto &item : op.item_ids) { @@ -78,6 +80,8 @@ namespace graphene try { const database &d = db(); + auto now = d.head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); op.bidder(d); for (const auto &item : offer.item_ids) @@ -144,6 +148,8 @@ namespace graphene try { const database &d = db(); + auto now = d.head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); op.issuer(d); FC_ASSERT(op.issuer == offer.issuer, "Only offer issuer can cancel the offer"); @@ -198,6 +204,8 @@ namespace graphene try { const database &d = db(); + auto now = d.head_block_time(); + FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); if (op.result != result_type::ExpiredNoBid) diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index efa07a46..ba714c21 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -133,29 +133,70 @@ struct proposal_operation_hardfork_visitor } void operator()(const custom_permission_create_operation &v) const { - FC_ASSERT( block_time >= HARDFORK_RBAC_TIME, "custom_permission_create_operation not allowed yet!" ); + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "custom_permission_create_operation not allowed yet!" ); } void operator()(const custom_permission_update_operation &v) const { - FC_ASSERT( block_time >= HARDFORK_RBAC_TIME, "custom_permission_update_operation not allowed yet!" ); + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "custom_permission_update_operation not allowed yet!" ); } void operator()(const custom_permission_delete_operation &v) const { - FC_ASSERT( block_time >= HARDFORK_RBAC_TIME, "custom_permission_delete_operation not allowed yet!" ); + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "custom_permission_delete_operation not allowed yet!" ); } void operator()(const custom_account_authority_create_operation &v) const { - FC_ASSERT( block_time >= HARDFORK_RBAC_TIME, "custom_account_authority_create_operation not allowed yet!" ); + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "custom_account_authority_create_operation not allowed yet!" ); } void operator()(const custom_account_authority_update_operation &v) const { - FC_ASSERT( block_time >= HARDFORK_RBAC_TIME, "custom_account_authority_update_operation not allowed yet!" ); + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "custom_account_authority_update_operation not allowed yet!" ); } void operator()(const custom_account_authority_delete_operation &v) const { - FC_ASSERT( block_time >= HARDFORK_RBAC_TIME, "custom_account_authority_delete_operation not allowed yet!" ); + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "custom_account_authority_delete_operation not allowed yet!" ); } + void operator()(const offer_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "offer_operation not allowed yet!" ); + } + + void operator()(const bid_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "bid_operation not allowed yet!" ); + } + + void operator()(const cancel_offer_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "cancel_offer_operation not allowed yet!" ); + } + + void operator()(const finalize_offer_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "finalize_offer_operation not allowed yet!" ); + } + + void operator()(const nft_metadata_create_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "nft_metadata_create_operation not allowed yet!" ); + } + + void operator()(const nft_metadata_update_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "nft_metadata_update_operation not allowed yet!" ); + } + + void operator()(const nft_mint_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "nft_mint_operation not allowed yet!" ); + } + + void operator()(const nft_safe_transfer_from_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "nft_safe_transfer_from_operation not allowed yet!" ); + } + + void operator()(const nft_approve_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "nft_approve_operation not allowed yet!" ); + } + + void operator()(const nft_set_approval_for_all_operation &v) const { + FC_ASSERT( block_time >= HARDFORK_NFT_TIME, "nft_set_approval_for_all_operation not allowed yet!" ); + } + + // loop and self visit in proposals void operator()(const proposal_create_operation &v) const { for (const op_wrapper &op : v.proposed_ops) diff --git a/libraries/chain/protocol/custom_account_authority.cpp b/libraries/chain/protocol/custom_account_authority.cpp index bfbb51c7..a74234d7 100644 --- a/libraries/chain/protocol/custom_account_authority.cpp +++ b/libraries/chain/protocol/custom_account_authority.cpp @@ -34,5 +34,10 @@ void custom_account_authority_delete_operation::validate() const "Custom permissions and account auths cannot be created for special accounts"); } +share_type custom_account_authority_create_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); +} + } // namespace chain } // namespace graphene diff --git a/libraries/chain/protocol/custom_permission.cpp b/libraries/chain/protocol/custom_permission.cpp index ad240ce7..c0919cbd 100644 --- a/libraries/chain/protocol/custom_permission.cpp +++ b/libraries/chain/protocol/custom_permission.cpp @@ -76,5 +76,10 @@ void custom_permission_delete_operation::validate() const "Custom permissions and account auths cannot be created for special accounts"); } +share_type custom_permission_create_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); +} + } // namespace chain } // namespace graphene diff --git a/libraries/chain/nft_object.cpp b/libraries/chain/protocol/nft.cpp similarity index 69% rename from libraries/chain/nft_object.cpp rename to libraries/chain/protocol/nft.cpp index c72c727b..802bf425 100644 --- a/libraries/chain/nft_object.cpp +++ b/libraries/chain/protocol/nft.cpp @@ -65,5 +65,35 @@ void nft_mint_operation::validate() const FC_ASSERT(token_uri.length() <= NFT_URI_MAX_LENGTH, "Invalid NFT Token URI"); } +share_type nft_metadata_create_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); +} + +share_type nft_metadata_update_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee; +} + +share_type nft_mint_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); +} + +share_type nft_safe_transfer_from_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); +} + +share_type nft_approve_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee; +} + +share_type nft_set_approval_for_all_operation::calculate_fee(const fee_parameters_type &k) const +{ + return k.fee; +} + } // namespace chain } // namespace graphene diff --git a/libraries/chain/protocol/offer.cpp b/libraries/chain/protocol/offer.cpp index bd5dd20e..e83af3f8 100644 --- a/libraries/chain/protocol/offer.cpp +++ b/libraries/chain/protocol/offer.cpp @@ -1,4 +1,5 @@ #include +#include namespace graphene { @@ -6,8 +7,7 @@ namespace graphene { share_type offer_operation::calculate_fee(const fee_parameters_type &schedule) const { - share_type core_fee_required = schedule.fee; - return core_fee_required; + return schedule.fee + calculate_data_fee( fc::raw::pack_size(*this), schedule.price_per_kbyte ); } void offer_operation::validate() const @@ -47,9 +47,9 @@ namespace graphene FC_ASSERT(fee.amount.value >= 0); } - share_type finalize_offer_operation::calculate_fee(const fee_parameters_type &k) const + share_type finalize_offer_operation::calculate_fee(const fee_parameters_type &schedule) const { - share_type core_fee_required = k.fee; + share_type core_fee_required = schedule.fee; return core_fee_required; } diff --git a/tests/tests/custom_permission_tests.cpp b/tests/tests/custom_permission_tests.cpp index 242585b4..4aad1897 100644 --- a/tests/tests/custom_permission_tests.cpp +++ b/tests/tests/custom_permission_tests.cpp @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(permission_create_fail_test) BOOST_REQUIRE(pidx.size() == 0); } // alice fails to create custom permission - generate_blocks(HARDFORK_RBAC_TIME); + generate_blocks(HARDFORK_NFT_TIME); generate_block(); set_expiration(db, trx); { @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(permission_create_success_test) { try { - generate_blocks(HARDFORK_RBAC_TIME); + generate_blocks(HARDFORK_NFT_TIME); generate_block(); set_expiration(db, trx); ACTORS((alice)(bob)(charlie)(dave)(erin)); @@ -893,7 +893,7 @@ BOOST_AUTO_TEST_CASE(transfer_op_multi_sig_with_out_common_auth_test) { try { - generate_blocks(HARDFORK_RBAC_TIME); + generate_blocks(HARDFORK_NFT_TIME); generate_block(); set_expiration(db, trx); ACTORS((alice)(bob)(charlie)(dave)); diff --git a/tests/tests/marketplace_tests.cpp b/tests/tests/marketplace_tests.cpp index 28a186b1..4c702d21 100644 --- a/tests/tests/marketplace_tests.cpp +++ b/tests/tests/marketplace_tests.cpp @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(nft_metadata_create_test) { BOOST_TEST_MESSAGE("nft_metadata_create_test"); - + generate_blocks(HARDFORK_NFT_TIME); generate_block(); set_expiration(db, trx); @@ -59,10 +59,8 @@ BOOST_AUTO_TEST_CASE(nft_mint_test) BOOST_TEST_MESSAGE("nft_mint_test"); - generate_block(); - set_expiration(db, trx); - INVOKE(nft_metadata_create_test); + set_expiration(db, trx); ACTORS((alice)(bob)(charlie)(operator1)(operator2)); upgrade_to_lifetime_member(alice); diff --git a/tests/tests/nft_tests.cpp b/tests/tests/nft_tests.cpp index 8cd5abed..b8fd19ea 100644 --- a/tests/tests/nft_tests.cpp +++ b/tests/tests/nft_tests.cpp @@ -13,7 +13,8 @@ BOOST_FIXTURE_TEST_SUITE( nft_tests, database_fixture ) BOOST_AUTO_TEST_CASE( nft_metadata_create_test ) { BOOST_TEST_MESSAGE("nft_metadata_create_test"); - + generate_blocks(HARDFORK_NFT_TIME); + generate_block(); generate_block(); set_expiration(db, trx);