NFT HF checks and op fee addition changes
This commit is contained in:
parent
92eb5c441f
commit
5783648cfb
19 changed files with 177 additions and 61 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ struct rbac_operation_hardfork_visitor
|
|||
case operation::tag<custom_account_authority_create_operation>::value:
|
||||
case operation::tag<custom_account_authority_update_operation>::value:
|
||||
case operation::tag<custom_account_authority_delete_operation>::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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
4
libraries/chain/hardfork.d/NFT.hf
Normal file
4
libraries/chain/hardfork.d/NFT.hf
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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) )
|
||||
|
||||
|
|
|
|||
|
|
@ -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<nft_id_type> 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));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
#include <graphene/chain/nft_evaluator.hpp>
|
||||
#include <graphene/chain/nft_object.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
|
||||
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<nft_metadata_index>().indices().get<by_name>();
|
||||
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<nft_metadata_index>().indices().get<by_id>();
|
||||
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<nft_index>().indices().get<by_id>();
|
||||
const auto& idx_acc = db().get_index_type<account_index>().indices().get<by_id>();
|
||||
|
||||
|
|
@ -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<nft_index>().indices().get<by_id>();
|
||||
const auto& idx_acc = db().get_index_type<account_index>().indices().get<by_id>();
|
||||
|
||||
|
|
@ -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<account_index>().indices().get<by_id>();
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#include <graphene/chain/protocol/offer.hpp>
|
||||
#include <fc/io/raw.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue