forked from PBSA/peerplays
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NFT Marketplace HRP Beatrice Merge (#371)
* private-key option update * ppy marketplace 1 - add evaluators and objects * NFT object and basic operations * ci: update .gitlab-ci.yml * ci: update .gitlab-ci.yml * NFT evaluators and basic tests, no evaluator checks * Evaluator checks in place * ppy marketplace 2 - batch sale, offer_object escrow * Database API * Wallet API * NFT metadata implemented * Fix NFT tests * Database API for NFT metadata and enumerables * ppy marketplace 4 - Add tests NFT+Marketplace * ppy marketplace 5 - Add revenue split * ppy marketplace 6 - Remove unnecessary files * ppy marketplace 7 - Add db, wallet changes and some NFT fixes * ppy marketplace 8 - Add pagination for list APIs * ci: update .gitlab-ci.yml * New DB API, list all NFTs, list NFTs by owner * Marketplace + NFT + RBAC (#368) * rbac1 - evaluators and op validators added * rbac2 - op_type hf checks * rbac3 - tx auth verify changes * Update .gitlab-ci.yml * rbac4 - basic op tests * rbac5 - clear expired and deleted permission linked auths * rbac6 - more tests * rbac7 - more tests * rbac8 - more tests * rbac9 - wallet and db api changes * rbac10 - db api changes for required signature fetch * rbac11 - add db_api tests * rbac12 - add missing code for key auths Co-authored-by: Roshan Syed <roshan.syed.rs@gmail.com> Co-authored-by: sierra19XX <15652887+sierra19XX@users.noreply.github.com> * Fix nft_get_token_uri returning empty string * Fix nft_mint_evaluator to save token_uri * Fix cli_wallet to properly pass metadata id for nft_create * ppy marketplace 9 - FC_REFLECT offer create op * Add stricter checks to NFTs * GPOS2 HF - Handle rolling period on missing blocks (#369) * Mainnet chain halt 5050 Issue (#370) * Unlisting offers, add result in offer history object * Reverting genesis.json wrong commit * Add non-transferable non-sellable properties to NFTs * Review comments - change variable names, use scoped enums * nft_metadata_update changes * NFT HF checks and op fee addition changes * NFT make revenue_split integer from double * revenue_split condition check allow zero or above * Peerplays Marketplace + NFT (#367) * ppy marketplace 1 - add evaluators and objects * NFT object and basic operations * ci: update .gitlab-ci.yml * ci: update .gitlab-ci.yml * NFT evaluators and basic tests, no evaluator checks * Evaluator checks in place * ppy marketplace 2 - batch sale, offer_object escrow * Database API * Wallet API * NFT metadata implemented * Fix NFT tests * Database API for NFT metadata and enumerables * ppy marketplace 4 - Add tests NFT+Marketplace * ppy marketplace 5 - Add revenue split * ppy marketplace 6 - Remove unnecessary files * ppy marketplace 7 - Add db, wallet changes and some NFT fixes * ppy marketplace 8 - Add pagination for list APIs * New DB API, list all NFTs, list NFTs by owner * Marketplace + NFT + RBAC (#368) * rbac1 - evaluators and op validators added * rbac2 - op_type hf checks * rbac3 - tx auth verify changes * Update .gitlab-ci.yml * rbac4 - basic op tests * rbac5 - clear expired and deleted permission linked auths * rbac6 - more tests * rbac7 - more tests * rbac8 - more tests * rbac9 - wallet and db api changes * rbac10 - db api changes for required signature fetch * rbac11 - add db_api tests * rbac12 - add missing code for key auths Co-authored-by: Roshan Syed <roshan.syed.rs@gmail.com> Co-authored-by: sierra19XX <15652887+sierra19XX@users.noreply.github.com> * Fix nft_get_token_uri returning empty string * Fix nft_mint_evaluator to save token_uri * Fix cli_wallet to properly pass metadata id for nft_create * ppy marketplace 9 - FC_REFLECT offer create op * Add stricter checks to NFTs * Unlisting offers, add result in offer history object * Reverting genesis.json wrong commit * Add non-transferable non-sellable properties to NFTs * Review comments - change variable names, use scoped enums * nft_metadata_update changes * NFT HF checks and op fee addition changes * NFT make revenue_split integer from double * revenue_split condition check allow zero or above Co-authored-by: Srdjan Obucina <obucinac@gmail.com> Co-authored-by: Roshan Syed <roshan.syed.rs@gmail.com> Co-authored-by: obucina <11353193+obucina@users.noreply.github.com> * Beatrice NFT HF Co-authored-by: pbattu123 <43043205+pbattu123@users.noreply.github.com> Co-authored-by: pbattu123 <p.battu@pbsa.info> Co-authored-by: Srdjan Obucina <obucinac@gmail.com> Co-authored-by: Roshan Syed <roshan.syed.rs@gmail.com> Co-authored-by: obucina <11353193+obucina@users.noreply.github.com>
- Loading branch information
1 parent
3bc945a
commit 6514f8f
Showing
53 changed files
with
7,120 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#include <graphene/chain/custom_account_authority_evaluator.hpp> | ||
|
||
#include <graphene/chain/database.hpp> | ||
#include <graphene/chain/custom_account_authority_object.hpp> | ||
#include <graphene/chain/custom_permission_object.hpp> | ||
#include <graphene/chain/hardfork.hpp> | ||
|
||
namespace graphene | ||
{ | ||
namespace chain | ||
{ | ||
|
||
struct rbac_operation_hardfork_visitor | ||
{ | ||
typedef void result_type; | ||
const fc::time_point_sec block_time; | ||
|
||
rbac_operation_hardfork_visitor(const fc::time_point_sec bt) : block_time(bt) {} | ||
void operator()(int op_type) const | ||
{ | ||
int first_allowed_op = operation::tag<custom_permission_create_operation>::value; | ||
switch (op_type) | ||
{ | ||
case operation::tag<custom_permission_create_operation>::value: | ||
case operation::tag<custom_permission_update_operation>::value: | ||
case operation::tag<custom_permission_delete_operation>::value: | ||
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_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!"); | ||
} | ||
} | ||
}; | ||
|
||
void_result create_custom_account_authority_evaluator::do_evaluate(const custom_account_authority_create_operation &op) | ||
{ | ||
try | ||
{ | ||
const database &d = db(); | ||
auto now = d.head_block_time(); | ||
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"); | ||
FC_ASSERT(op.valid_to > now, "valid_to expiry should be in future"); | ||
FC_ASSERT((op.valid_to - op.valid_from) <= fc::seconds(d.get_global_properties().parameters.rbac_max_account_authority_lifetime()), "Validity of the auth beyond max expiry"); | ||
rbac_operation_hardfork_visitor rvtor(now); | ||
rvtor(op.operation_type); | ||
const auto& cindex = d.get_index_type<custom_account_authority_index>().indices().get<by_permission_and_op>(); | ||
auto count = cindex.count(boost::make_tuple(op.permission_id)); | ||
FC_ASSERT(count < d.get_global_properties().parameters.rbac_max_authorities_per_permission(), "Max operations that can be linked to a permission reached"); | ||
return void_result(); | ||
} | ||
FC_CAPTURE_AND_RETHROW((op)) | ||
} | ||
|
||
object_id_type create_custom_account_authority_evaluator::do_apply(const custom_account_authority_create_operation &op) | ||
{ | ||
try | ||
{ | ||
database &d = db(); | ||
return d.create<custom_account_authority_object>([&op](custom_account_authority_object &obj) mutable { | ||
obj.permission_id = op.permission_id; | ||
obj.operation_type = op.operation_type; | ||
obj.valid_from = op.valid_from; | ||
obj.valid_to = op.valid_to; | ||
}) | ||
.id; | ||
} | ||
FC_CAPTURE_AND_RETHROW((op)) | ||
} | ||
|
||
void_result update_custom_account_authority_evaluator::do_evaluate(const custom_account_authority_update_operation &op) | ||
{ | ||
try | ||
{ | ||
const database &d = db(); | ||
auto now = d.head_block_time(); | ||
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); | ||
FC_ASSERT(pobj.account == op.owner_account, "Only owner account can update account authority object"); | ||
auto valid_from = aobj.valid_from; | ||
auto valid_to = aobj.valid_to; | ||
if (op.new_valid_from) | ||
{ | ||
valid_from = *op.new_valid_from; | ||
} | ||
|
||
if (op.new_valid_to) | ||
{ | ||
FC_ASSERT(*op.new_valid_to > now, "New valid_to expiry should be in the future"); | ||
valid_to = *op.new_valid_to; | ||
} | ||
FC_ASSERT(valid_from < valid_to, "valid_from should be before valid_to"); | ||
FC_ASSERT((valid_to - valid_from) <= fc::seconds(d.get_global_properties().parameters.rbac_max_account_authority_lifetime()), "Validity of the auth beyond max expiry"); | ||
return void_result(); | ||
} | ||
FC_CAPTURE_AND_RETHROW((op)) | ||
} | ||
|
||
object_id_type update_custom_account_authority_evaluator::do_apply(const custom_account_authority_update_operation &op) | ||
{ | ||
try | ||
{ | ||
database &d = db(); | ||
const custom_account_authority_object &aobj = op.auth_id(d); | ||
d.modify(aobj, [&op](custom_account_authority_object &obj) { | ||
if (op.new_valid_from) | ||
obj.valid_from = *op.new_valid_from; | ||
if (op.new_valid_to) | ||
obj.valid_to = *op.new_valid_to; | ||
}); | ||
return op.auth_id; | ||
} | ||
FC_CAPTURE_AND_RETHROW((op)) | ||
} | ||
|
||
void_result delete_custom_account_authority_evaluator::do_evaluate(const custom_account_authority_delete_operation &op) | ||
{ | ||
try | ||
{ | ||
const database &d = db(); | ||
auto now = d.head_block_time(); | ||
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); | ||
FC_ASSERT(pobj.account == op.owner_account, "Only owner account can delete account authority object"); | ||
return void_result(); | ||
} | ||
FC_CAPTURE_AND_RETHROW((op)) | ||
} | ||
|
||
void_result delete_custom_account_authority_evaluator::do_apply(const custom_account_authority_delete_operation &op) | ||
{ | ||
try | ||
{ | ||
database &d = db(); | ||
const custom_account_authority_object &aobj = op.auth_id(d); | ||
d.remove(aobj); | ||
return void_result(); | ||
} | ||
FC_CAPTURE_AND_RETHROW((op)) | ||
} | ||
|
||
} // namespace chain | ||
} // namespace graphene |
Oops, something went wrong.