* 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: satyakoneru <15652887+satyakoneru@users.noreply.github.com> 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: Satyanarayana Koneru <skoneru@SK-GT.local> Co-authored-by: obucina <11353193+obucina@users.noreply.github.com> Co-authored-by: satyakoneru <15652887+satyakoneru@users.noreply.github.com>
85 lines
3.2 KiB
C++
85 lines
3.2 KiB
C++
#include <graphene/chain/protocol/custom_permission.hpp>
|
|
#include <graphene/chain/protocol/operations.hpp>
|
|
|
|
namespace graphene
|
|
{
|
|
namespace chain
|
|
{
|
|
|
|
bool is_valid_permission_name(const string &name)
|
|
{
|
|
try
|
|
{
|
|
const size_t len = name.size();
|
|
// RBAC_MIN_PERMISSION_NAME_LENGTH <= len minimum length check
|
|
if (len < RBAC_MIN_PERMISSION_NAME_LENGTH)
|
|
{
|
|
return false;
|
|
}
|
|
// len <= RBAC_MAX_PERMISSION_NAME_LENGTH max length check
|
|
if (len > RBAC_MAX_PERMISSION_NAME_LENGTH)
|
|
{
|
|
return false;
|
|
}
|
|
// First character should be a letter between a-z
|
|
if (!(name[0] >= 'a' && name[0] <= 'z'))
|
|
{
|
|
return false;
|
|
}
|
|
// Any character of a permission name should either be a small case letter a-z or a digit 0-9
|
|
for (const auto &ch : name)
|
|
{
|
|
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
// Don't accept active and owner permissions as we already have them by default
|
|
// This is for removing ambiguity for users, accepting them doesn't create any problems
|
|
if (name == "active" || name == "owner")
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
FC_CAPTURE_AND_RETHROW((name))
|
|
}
|
|
|
|
void custom_permission_create_operation::validate() const
|
|
{
|
|
FC_ASSERT(fee.amount >= 0, "Fee must not be negative");
|
|
FC_ASSERT(is_valid_permission_name(permission_name), "Invalid permission name provided");
|
|
FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT,
|
|
"Custom permissions and account auths cannot be created for special accounts");
|
|
FC_ASSERT(!auth.is_impossible(), "Impossible authority threshold auth provided");
|
|
FC_ASSERT(auth.address_auths.size() == 0, "Only account and key auths supported");
|
|
}
|
|
|
|
void custom_permission_update_operation::validate() const
|
|
{
|
|
FC_ASSERT(fee.amount >= 0, "Fee must not be negative");
|
|
FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT,
|
|
"Custom permissions and account auths cannot be created for special accounts");
|
|
FC_ASSERT(new_auth.valid(), "Something must be updated");
|
|
if (new_auth)
|
|
{
|
|
FC_ASSERT(!new_auth->is_impossible(), "Impossible authority threshold auth provided");
|
|
FC_ASSERT(new_auth->address_auths.size() == 0, "Only account and key auths supported");
|
|
}
|
|
}
|
|
|
|
void custom_permission_delete_operation::validate() const
|
|
{
|
|
FC_ASSERT(fee.amount >= 0, "Fee must not be negative");
|
|
FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT,
|
|
"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
|