NFT metadata implemented
This commit is contained in:
parent
0d79d5d0ee
commit
51cb17e2d8
11 changed files with 272 additions and 48 deletions
|
|
@ -247,7 +247,9 @@ void database::initialize_evaluators()
|
||||||
register_evaluator<lottery_reward_evaluator>();
|
register_evaluator<lottery_reward_evaluator>();
|
||||||
register_evaluator<lottery_end_evaluator>();
|
register_evaluator<lottery_end_evaluator>();
|
||||||
register_evaluator<sweeps_vesting_claim_evaluator>();
|
register_evaluator<sweeps_vesting_claim_evaluator>();
|
||||||
register_evaluator<nft_create_evaluator>();
|
register_evaluator<nft_metadata_create_evaluator>();
|
||||||
|
register_evaluator<nft_metadata_update_evaluator>();
|
||||||
|
register_evaluator<nft_mint_evaluator>();
|
||||||
register_evaluator<nft_safe_transfer_from_evaluator>();
|
register_evaluator<nft_safe_transfer_from_evaluator>();
|
||||||
register_evaluator<nft_approve_evaluator>();
|
register_evaluator<nft_approve_evaluator>();
|
||||||
register_evaluator<nft_set_approval_for_all_evaluator>();
|
register_evaluator<nft_set_approval_for_all_evaluator>();
|
||||||
|
|
@ -293,6 +295,7 @@ void database::initialize_indexes()
|
||||||
add_index< primary_index<match_index> >();
|
add_index< primary_index<match_index> >();
|
||||||
add_index< primary_index<game_index> >();
|
add_index< primary_index<game_index> >();
|
||||||
|
|
||||||
|
add_index< primary_index<nft_metadata_index > >();
|
||||||
add_index< primary_index<nft_index > >();
|
add_index< primary_index<nft_index > >();
|
||||||
|
|
||||||
//Implementation object indexes
|
//Implementation object indexes
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,13 @@ struct get_impacted_account_visitor
|
||||||
void operator()( const sweeps_vesting_claim_operation& op ) {
|
void operator()( const sweeps_vesting_claim_operation& op ) {
|
||||||
_impacted.insert( op.account );
|
_impacted.insert( op.account );
|
||||||
}
|
}
|
||||||
void operator()( const nft_create_operation& op ) {
|
void operator()( const nft_metadata_create_operation& op ) {
|
||||||
|
_impacted.insert( op.owner );
|
||||||
|
}
|
||||||
|
void operator()( const nft_metadata_update_operation& op ) {
|
||||||
|
_impacted.insert( op.owner );
|
||||||
|
}
|
||||||
|
void operator()( const nft_mint_operation& op ) {
|
||||||
_impacted.insert( op.owner );
|
_impacted.insert( op.owner );
|
||||||
}
|
}
|
||||||
void operator()( const nft_safe_transfer_from_operation& op ) {
|
void operator()( const nft_safe_transfer_from_operation& op ) {
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,28 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
class nft_create_evaluator : public evaluator<nft_create_evaluator>
|
class nft_metadata_create_evaluator : public evaluator<nft_metadata_create_evaluator>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef nft_create_operation operation_type;
|
typedef nft_metadata_create_operation operation_type;
|
||||||
void_result do_evaluate( const nft_create_operation& o );
|
void_result do_evaluate( const nft_metadata_create_operation& o );
|
||||||
object_id_type do_apply( const nft_create_operation& o );
|
object_id_type do_apply( const nft_metadata_create_operation& o );
|
||||||
|
};
|
||||||
|
|
||||||
|
class nft_metadata_update_evaluator : public evaluator<nft_metadata_update_evaluator>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef nft_metadata_update_operation operation_type;
|
||||||
|
void_result do_evaluate( const nft_metadata_update_operation& o );
|
||||||
|
void_result do_apply( const nft_metadata_update_operation& o );
|
||||||
|
};
|
||||||
|
|
||||||
|
class nft_mint_evaluator : public evaluator<nft_mint_evaluator>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef nft_mint_operation operation_type;
|
||||||
|
void_result do_evaluate( const nft_mint_operation& o );
|
||||||
|
object_id_type do_apply( const nft_mint_operation& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
class nft_safe_transfer_from_evaluator : public evaluator<nft_safe_transfer_from_evaluator>
|
class nft_safe_transfer_from_evaluator : public evaluator<nft_safe_transfer_from_evaluator>
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,50 @@
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
using namespace graphene::db;
|
using namespace graphene::db;
|
||||||
|
|
||||||
|
class nft_metadata_object : public abstract_object<nft_metadata_object>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const uint8_t space_id = protocol_ids;
|
||||||
|
static const uint8_t type_id = nft_metadata_type;
|
||||||
|
|
||||||
|
account_id_type owner;
|
||||||
|
std::string name;
|
||||||
|
std::string symbol;
|
||||||
|
std::string base_uri;
|
||||||
|
};
|
||||||
|
|
||||||
class nft_object : public abstract_object<nft_object>
|
class nft_object : public abstract_object<nft_object>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint8_t space_id = protocol_ids;
|
static const uint8_t space_id = protocol_ids;
|
||||||
static const uint8_t type_id = nft_object_type;
|
static const uint8_t type_id = nft_object_type;
|
||||||
|
|
||||||
|
nft_metadata_id_type nft_metadata_id;
|
||||||
account_id_type owner;
|
account_id_type owner;
|
||||||
account_id_type approved;
|
account_id_type approved;
|
||||||
vector<account_id_type> approved_operators;
|
vector<account_id_type> approved_operators;
|
||||||
std::string metadata;
|
std::string token_uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct by_name;
|
||||||
|
struct by_symbol;
|
||||||
|
using nft_metadata_multi_index_type = multi_index_container<
|
||||||
|
nft_metadata_object,
|
||||||
|
indexed_by<
|
||||||
|
ordered_unique< tag<by_id>,
|
||||||
|
member<object, object_id_type, &object::id>
|
||||||
|
>,
|
||||||
|
ordered_unique< tag<by_name>,
|
||||||
|
member<nft_metadata_object, std::string, &nft_metadata_object::name>
|
||||||
|
>,
|
||||||
|
ordered_unique< tag<by_symbol>,
|
||||||
|
member<nft_metadata_object, std::string, &nft_metadata_object::symbol>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
using nft_metadata_index = generic_index<nft_metadata_object, nft_metadata_multi_index_type>;
|
||||||
|
|
||||||
|
struct by_metadata;
|
||||||
struct by_owner;
|
struct by_owner;
|
||||||
struct by_owner_and_id;
|
struct by_owner_and_id;
|
||||||
using nft_multi_index_type = multi_index_container<
|
using nft_multi_index_type = multi_index_container<
|
||||||
|
|
@ -26,6 +58,9 @@ namespace graphene { namespace chain {
|
||||||
ordered_unique< tag<by_id>,
|
ordered_unique< tag<by_id>,
|
||||||
member<object, object_id_type, &object::id>
|
member<object, object_id_type, &object::id>
|
||||||
>,
|
>,
|
||||||
|
ordered_non_unique< tag<by_metadata>,
|
||||||
|
member<nft_object, nft_metadata_id_type, &nft_object::nft_metadata_id>
|
||||||
|
>,
|
||||||
ordered_non_unique< tag<by_owner>,
|
ordered_non_unique< tag<by_owner>,
|
||||||
member<nft_object, account_id_type, &nft_object::owner>
|
member<nft_object, account_id_type, &nft_object::owner>
|
||||||
>,
|
>,
|
||||||
|
|
@ -41,9 +76,16 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
|
FC_REFLECT_DERIVED( graphene::chain::nft_metadata_object, (graphene::db::object),
|
||||||
|
(owner)
|
||||||
|
(name)
|
||||||
|
(symbol)
|
||||||
|
(base_uri) )
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::nft_object, (graphene::db::object),
|
FC_REFLECT_DERIVED( graphene::chain::nft_object, (graphene::db::object),
|
||||||
|
(nft_metadata_id)
|
||||||
(owner)
|
(owner)
|
||||||
(approved)
|
(approved)
|
||||||
(approved_operators)
|
(approved_operators)
|
||||||
(metadata) )
|
(token_uri) )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,43 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
struct nft_create_operation : public base_operation
|
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; };
|
||||||
asset fee;
|
asset fee;
|
||||||
|
|
||||||
|
account_id_type owner;
|
||||||
|
std::string name;
|
||||||
|
std::string symbol;
|
||||||
|
std::string base_uri;
|
||||||
|
|
||||||
|
account_id_type fee_payer()const { return owner; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nft_metadata_update_operation : public base_operation
|
||||||
|
{
|
||||||
|
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
|
||||||
|
asset fee;
|
||||||
|
|
||||||
|
account_id_type owner;
|
||||||
|
nft_metadata_id_type nft_metadata_id;
|
||||||
|
optional<std::string> name;
|
||||||
|
optional<std::string> symbol;
|
||||||
|
optional<std::string> base_uri;
|
||||||
|
|
||||||
|
account_id_type fee_payer()const { return owner; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nft_mint_operation : public base_operation
|
||||||
|
{
|
||||||
|
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
|
||||||
|
asset fee;
|
||||||
|
|
||||||
|
optional<nft_metadata_id_type> nft_metadata_id;
|
||||||
account_id_type owner;
|
account_id_type owner;
|
||||||
account_id_type approved;
|
account_id_type approved;
|
||||||
vector<account_id_type> approved_operators;
|
vector<account_id_type> approved_operators;
|
||||||
std::string metadata;
|
std::string token_uri;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return owner; }
|
account_id_type fee_payer()const { return owner; }
|
||||||
};
|
};
|
||||||
|
|
@ -60,12 +88,16 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::nft_create_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) )
|
||||||
|
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_safe_transfer_from_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT( graphene::chain::nft_approve_operation::fee_parameters_type, (fee) )
|
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_set_approval_for_all_operation::fee_parameters_type, (fee) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::nft_create_operation, (fee) (owner) (approved) (approved_operators) (metadata) )
|
FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) )
|
||||||
|
FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) )
|
||||||
|
FC_REFLECT( graphene::chain::nft_mint_operation, (fee) (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_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) )
|
||||||
FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) )
|
FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) )
|
||||||
FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) )
|
FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) )
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,9 @@ namespace graphene { namespace chain {
|
||||||
lottery_reward_operation,
|
lottery_reward_operation,
|
||||||
lottery_end_operation,
|
lottery_end_operation,
|
||||||
sweeps_vesting_claim_operation,
|
sweeps_vesting_claim_operation,
|
||||||
nft_create_operation,
|
nft_metadata_create_operation,
|
||||||
|
nft_metadata_update_operation,
|
||||||
|
nft_mint_operation,
|
||||||
nft_safe_transfer_from_operation,
|
nft_safe_transfer_from_operation,
|
||||||
nft_approve_operation,
|
nft_approve_operation,
|
||||||
nft_set_approval_for_all_operation
|
nft_set_approval_for_all_operation
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ namespace graphene { namespace chain {
|
||||||
betting_market_group_object_type,
|
betting_market_group_object_type,
|
||||||
betting_market_object_type,
|
betting_market_object_type,
|
||||||
bet_object_type,
|
bet_object_type,
|
||||||
|
nft_metadata_type,
|
||||||
nft_object_type,
|
nft_object_type,
|
||||||
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
|
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
|
||||||
};
|
};
|
||||||
|
|
@ -231,6 +232,7 @@ namespace graphene { namespace chain {
|
||||||
class betting_market_group_object;
|
class betting_market_group_object;
|
||||||
class betting_market_object;
|
class betting_market_object;
|
||||||
class bet_object;
|
class bet_object;
|
||||||
|
class nft_metadata_object;
|
||||||
class nft_object;
|
class nft_object;
|
||||||
|
|
||||||
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
|
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
|
||||||
|
|
@ -258,6 +260,7 @@ namespace graphene { namespace chain {
|
||||||
typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type;
|
typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type;
|
||||||
typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type;
|
typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type;
|
||||||
typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type;
|
typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type;
|
||||||
|
typedef object_id< protocol_ids, nft_metadata_type, nft_metadata_object> nft_metadata_id_type;
|
||||||
typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type;
|
typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type;
|
||||||
|
|
||||||
// implementation types
|
// implementation types
|
||||||
|
|
@ -439,6 +442,7 @@ FC_REFLECT_ENUM( graphene::chain::object_type,
|
||||||
(betting_market_group_object_type)
|
(betting_market_group_object_type)
|
||||||
(betting_market_object_type)
|
(betting_market_object_type)
|
||||||
(bet_object_type)
|
(bet_object_type)
|
||||||
|
(nft_metadata_type)
|
||||||
(nft_object_type)
|
(nft_object_type)
|
||||||
(OBJECT_TYPE_COUNT)
|
(OBJECT_TYPE_COUNT)
|
||||||
)
|
)
|
||||||
|
|
@ -509,6 +513,7 @@ FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type )
|
||||||
|
FC_REFLECT_TYPENAME( graphene::chain::nft_metadata_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::nft_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::nft_id_type )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::void_t, )
|
FC_REFLECT( graphene::chain::void_t, )
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,67 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
void_result nft_create_evaluator::do_evaluate( const nft_create_operation& op )
|
void_result nft_metadata_create_evaluator::do_evaluate( const nft_metadata_create_operation& op )
|
||||||
{ try {
|
{ try {
|
||||||
|
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" );
|
||||||
|
const auto& idx_nft_md_by_symbol = db().get_index_type<nft_metadata_index>().indices().get<by_symbol>();
|
||||||
|
FC_ASSERT( idx_nft_md_by_symbol.find(op.symbol) == idx_nft_md_by_symbol.end(), "NFT symbol already in use" );
|
||||||
|
return void_result();
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
object_id_type nft_metadata_create_evaluator::do_apply( const nft_metadata_create_operation& op )
|
||||||
|
{ try {
|
||||||
|
const auto& new_nft_metadata_object = db().create<nft_metadata_object>( [&]( nft_metadata_object& obj ){
|
||||||
|
obj.owner = op.owner;
|
||||||
|
obj.name = op.name;
|
||||||
|
obj.symbol = op.symbol;
|
||||||
|
obj.base_uri = op.base_uri;
|
||||||
|
});
|
||||||
|
return new_nft_metadata_object.id;
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
|
||||||
|
void_result nft_metadata_update_evaluator::do_evaluate( const nft_metadata_update_operation& op )
|
||||||
|
{ try {
|
||||||
|
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);
|
||||||
|
FC_ASSERT( itr_nft_md != idx_nft_md.end(), "NFT metadata not found" );
|
||||||
|
FC_ASSERT( itr_nft_md->owner == op.owner, "Only owner can modify NFT metadata" );
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
object_id_type nft_create_evaluator::do_apply( const nft_create_operation& op )
|
void_result nft_metadata_update_evaluator::do_apply( const nft_metadata_update_operation& op )
|
||||||
|
{ try {
|
||||||
|
db().modify(db().get(op.nft_metadata_id), [&] ( nft_metadata_object& obj ) {
|
||||||
|
if( op.name.valid() )
|
||||||
|
obj.name = *op.name;
|
||||||
|
if( op.symbol.valid() )
|
||||||
|
obj.symbol = *op.symbol;
|
||||||
|
if( op.base_uri.valid() )
|
||||||
|
obj.base_uri = *op.base_uri;
|
||||||
|
});
|
||||||
|
return void_result();
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
|
||||||
|
void_result nft_mint_evaluator::do_evaluate( const nft_mint_operation& op )
|
||||||
|
{ try {
|
||||||
|
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);
|
||||||
|
FC_ASSERT( itr_nft_md != idx_nft_md.end(), "NFT metadata not found" );
|
||||||
|
|
||||||
|
return void_result();
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
object_id_type nft_mint_evaluator::do_apply( const nft_mint_operation& op )
|
||||||
{ try {
|
{ try {
|
||||||
const auto& new_nft_object = db().create<nft_object>( [&]( nft_object& obj ){
|
const auto& new_nft_object = db().create<nft_object>( [&]( nft_object& obj ){
|
||||||
|
obj.nft_metadata_id = *op.nft_metadata_id;
|
||||||
obj.owner = op.owner;
|
obj.owner = op.owner;
|
||||||
obj.approved = op.approved;
|
obj.approved = op.approved;
|
||||||
obj.approved_operators = op.approved_operators;
|
obj.approved_operators = op.approved_operators;
|
||||||
obj.metadata = op.metadata;
|
|
||||||
});
|
});
|
||||||
return new_nft_object.id;
|
return new_nft_object.id;
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
|
||||||
|
|
@ -1899,17 +1899,48 @@ class wallet_api
|
||||||
// NFT //
|
// NFT //
|
||||||
/////////
|
/////////
|
||||||
/**
|
/**
|
||||||
* @brief Creates NFT
|
* @brief Creates NFT metadata
|
||||||
* @param owner_account_id_or_name Owner account ID or name
|
* @param owner_account_id_or_name Owner account ID or name
|
||||||
* @param approved_account_id_or_name Approved account ID or name
|
* @param name Name of the token group
|
||||||
* @param approved_operators_id_or_name Approved operator IDs or names
|
* @param symbol Symbol of the token group
|
||||||
* @param metadata NFT metadata
|
* @param base_uri Base URI for token URI
|
||||||
* @param broadcast true to broadcast transaction to the network
|
* @param broadcast true to broadcast transaction to the network
|
||||||
* @return Signed transaction transfering the funds
|
* @return Signed transaction transfering the funds
|
||||||
*/
|
*/
|
||||||
signed_transaction nft_create(string owner_account_id_or_name,
|
signed_transaction nft_metadata_create(string owner_account_id_or_name,
|
||||||
|
string name,
|
||||||
|
string symbol,
|
||||||
|
string base_uri,
|
||||||
|
bool broadcast);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Updates NFT metadata
|
||||||
|
* @param owner_account_id_or_name Owner account ID or name
|
||||||
|
* @param name Name of the token group
|
||||||
|
* @param symbol Symbol of the token group
|
||||||
|
* @param base_uri Base URI for token URI
|
||||||
|
* @param broadcast true to broadcast transaction to the network
|
||||||
|
* @return Signed transaction transfering the funds
|
||||||
|
*/
|
||||||
|
signed_transaction nft_metadata_update(string owner_account_id_or_name,
|
||||||
|
string name,
|
||||||
|
string symbol,
|
||||||
|
string base_uri,
|
||||||
|
bool broadcast);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates NFT
|
||||||
|
* @param metadata_id NFT metadata ID to which token will belong
|
||||||
|
* @param owner_account_id_or_name Owner account ID or name
|
||||||
|
* @param approved_account_id_or_name Approved account ID or name
|
||||||
|
* @param token_uri Token URI (Will be combined with metadata base_uri if its not empty)
|
||||||
|
* @param broadcast true to broadcast transaction to the network
|
||||||
|
* @return Signed transaction transfering the funds
|
||||||
|
*/
|
||||||
|
signed_transaction nft_create(nft_metadata_id_type metadata_id,
|
||||||
|
string owner_account_id_or_name,
|
||||||
string approved_account_id_or_name,
|
string approved_account_id_or_name,
|
||||||
string metadata,
|
string token_uri,
|
||||||
bool broadcast);
|
bool broadcast);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -6157,18 +6157,64 @@ signed_transaction wallet_api::create_vesting_balance(string owner,
|
||||||
return my->sign_transaction( trx, broadcast );
|
return my->sign_transaction( trx, broadcast );
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::nft_create(string owner_account_id_or_name,
|
signed_transaction wallet_api::nft_metadata_create(string owner_account_id_or_name,
|
||||||
string approved_account_id_or_name,
|
string name,
|
||||||
string metadata,
|
string symbol,
|
||||||
bool broadcast)
|
string base_uri,
|
||||||
|
bool broadcast)
|
||||||
|
{
|
||||||
|
account_object owner_account = my->get_account(owner_account_id_or_name);
|
||||||
|
|
||||||
|
nft_metadata_create_operation op;
|
||||||
|
op.owner = owner_account.id;
|
||||||
|
op.name = name;
|
||||||
|
op.symbol = symbol;
|
||||||
|
op.base_uri = base_uri;
|
||||||
|
|
||||||
|
signed_transaction trx;
|
||||||
|
trx.operations.push_back(op);
|
||||||
|
my->set_operation_fees( trx, my->_remote_db->get_global_properties().parameters.current_fees );
|
||||||
|
trx.validate();
|
||||||
|
|
||||||
|
return my->sign_transaction( trx, broadcast );
|
||||||
|
}
|
||||||
|
|
||||||
|
signed_transaction wallet_api::nft_metadata_update(string owner_account_id_or_name,
|
||||||
|
string name,
|
||||||
|
string symbol,
|
||||||
|
string base_uri,
|
||||||
|
bool broadcast)
|
||||||
|
{
|
||||||
|
account_object owner_account = my->get_account(owner_account_id_or_name);
|
||||||
|
|
||||||
|
nft_metadata_update_operation op;
|
||||||
|
op.owner = owner_account.id;
|
||||||
|
op.name = name;
|
||||||
|
op.symbol = symbol;
|
||||||
|
op.base_uri = base_uri;
|
||||||
|
|
||||||
|
signed_transaction trx;
|
||||||
|
trx.operations.push_back(op);
|
||||||
|
my->set_operation_fees( trx, my->_remote_db->get_global_properties().parameters.current_fees );
|
||||||
|
trx.validate();
|
||||||
|
|
||||||
|
return my->sign_transaction( trx, broadcast );
|
||||||
|
}
|
||||||
|
|
||||||
|
signed_transaction wallet_api::nft_create(nft_metadata_id_type metadata_id,
|
||||||
|
string owner_account_id_or_name,
|
||||||
|
string approved_account_id_or_name,
|
||||||
|
string token_uri,
|
||||||
|
bool broadcast)
|
||||||
{
|
{
|
||||||
account_object owner_account = my->get_account(owner_account_id_or_name);
|
account_object owner_account = my->get_account(owner_account_id_or_name);
|
||||||
account_object approved_account = my->get_account(approved_account_id_or_name);
|
account_object approved_account = my->get_account(approved_account_id_or_name);
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
|
op.nft_metadata_id = op.nft_metadata_id;
|
||||||
op.owner = owner_account.id;
|
op.owner = owner_account.id;
|
||||||
op.approved = approved_account.id;
|
op.approved = approved_account.id;
|
||||||
op.metadata = metadata;
|
op.token_uri = token_uri;
|
||||||
|
|
||||||
signed_transaction trx;
|
signed_transaction trx;
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,13 @@ BOOST_AUTO_TEST_CASE( nft_create_test ) {
|
||||||
set_expiration(db, trx);
|
set_expiration(db, trx);
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send nft_create_operation");
|
BOOST_TEST_MESSAGE("Send nft_mint_operation");
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
op.owner = alice_id;
|
op.owner = alice_id;
|
||||||
op.approved = alice_id;
|
op.approved = alice_id;
|
||||||
op.approved_operators.push_back(operator1_id);
|
op.approved_operators.push_back(operator1_id);
|
||||||
op.approved_operators.push_back(operator2_id);
|
op.approved_operators.push_back(operator2_id);
|
||||||
op.metadata = "metadata";
|
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, alice_private_key);
|
sign(trx, alice_private_key);
|
||||||
|
|
@ -41,7 +40,7 @@ BOOST_AUTO_TEST_CASE( nft_create_test ) {
|
||||||
}
|
}
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Check nft_create_operation results");
|
BOOST_TEST_MESSAGE("Check nft_mint_operation results");
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<nft_index>().indices().get<by_id>();
|
const auto& idx = db.get_index_type<nft_index>().indices().get<by_id>();
|
||||||
BOOST_REQUIRE( idx.size() == 1 );
|
BOOST_REQUIRE( idx.size() == 1 );
|
||||||
|
|
@ -51,7 +50,6 @@ BOOST_AUTO_TEST_CASE( nft_create_test ) {
|
||||||
BOOST_CHECK( obj->approved_operators.size() == 2 );
|
BOOST_CHECK( obj->approved_operators.size() == 2 );
|
||||||
BOOST_CHECK( obj->approved_operators.at(0) == operator1_id );
|
BOOST_CHECK( obj->approved_operators.at(0) == operator1_id );
|
||||||
BOOST_CHECK( obj->approved_operators.at(1) == operator2_id );
|
BOOST_CHECK( obj->approved_operators.at(1) == operator2_id );
|
||||||
BOOST_CHECK( obj->metadata == "metadata" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -154,11 +152,10 @@ BOOST_AUTO_TEST_CASE( nft_set_approval_for_all_test ) {
|
||||||
BOOST_TEST_MESSAGE("Create NFT assets");
|
BOOST_TEST_MESSAGE("Create NFT assets");
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send nft_create_operation 1");
|
BOOST_TEST_MESSAGE("Send nft_mint_operation 1");
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
op.owner = alice_id;
|
op.owner = alice_id;
|
||||||
op.metadata = "metadata 1";
|
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, alice_private_key);
|
sign(trx, alice_private_key);
|
||||||
|
|
@ -167,11 +164,10 @@ BOOST_AUTO_TEST_CASE( nft_set_approval_for_all_test ) {
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send nft_create_operation 2");
|
BOOST_TEST_MESSAGE("Send nft_mint_operation 2");
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
op.owner = bob_id;
|
op.owner = bob_id;
|
||||||
op.metadata = "metadata 2";
|
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, bob_private_key);
|
sign(trx, bob_private_key);
|
||||||
|
|
@ -180,11 +176,10 @@ BOOST_AUTO_TEST_CASE( nft_set_approval_for_all_test ) {
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send nft_create_operation 3");
|
BOOST_TEST_MESSAGE("Send nft_mint_operation 3");
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
op.owner = alice_id;
|
op.owner = alice_id;
|
||||||
op.metadata = "metadata 3";
|
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, alice_private_key);
|
sign(trx, alice_private_key);
|
||||||
|
|
@ -193,11 +188,10 @@ BOOST_AUTO_TEST_CASE( nft_set_approval_for_all_test ) {
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send nft_create_operation 4");
|
BOOST_TEST_MESSAGE("Send nft_mint_operation 4");
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
op.owner = bob_id;
|
op.owner = bob_id;
|
||||||
op.metadata = "metadata 4";
|
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, bob_private_key);
|
sign(trx, bob_private_key);
|
||||||
|
|
@ -206,11 +200,10 @@ BOOST_AUTO_TEST_CASE( nft_set_approval_for_all_test ) {
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("Send nft_create_operation 5");
|
BOOST_TEST_MESSAGE("Send nft_mint_operation 5");
|
||||||
|
|
||||||
nft_create_operation op;
|
nft_mint_operation op;
|
||||||
op.owner = alice_id;
|
op.owner = alice_id;
|
||||||
op.metadata = "metadata 5";
|
|
||||||
|
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
sign(trx, alice_private_key);
|
sign(trx, alice_private_key);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue