Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all NFTs with send all #1260

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/omnicore/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ inline std::string error_str(int ec) {
ec_str = "Non-fungible tokens are not yet activated";
break;
case PKT_ERROR_NFT -21:
ec_str = "Property %d is of type non-fungible";
ec_str = "Property is of type non-fungible";
break;
case PKT_ERROR_NFT -23:
ec_str = "Type or version not permitted for property";
Expand Down Expand Up @@ -376,7 +376,7 @@ inline std::string error_str(int ec) {
ec_str = "Sender has insufficient balance of property";
break;
case PKT_ERROR_NFT -33:
ec_str = "Sender %s does not own the range being sent";
ec_str = "Sender does not own the range being sent";
break;

default:
Expand Down
42 changes: 31 additions & 11 deletions src/omnicore/tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1491,16 +1491,33 @@ int CMPTransaction::logicMath_SendAll()
continue;
}

if (IsFeatureActivated(FEATURE_NONFUNGIBLE_ISSUER, block)) {
// do not transfer non-fungible tokens
if (isPropertyNonFungible(propertyId)) {
PrintToConsole("%s: property %d is non-fungible and will not be included in processing.\n", __func__, propertyId);
continue;
}
}

int64_t moneyAvailable = ptally->getMoney(propertyId, BALANCE);
int64_t moneyNft = 0;

if (moneyAvailable > 0) {
if (IsFeatureActivated(FEATURE_NONFUNGIBLE_ISSUER, block)) {
if (isPropertyNonFungible(propertyId)) {
std::vector<std::pair<std::string,std::pair<int64_t,int64_t> > > rangeMap = pDbNFT->GetNonFungibleTokenRanges(propertyId);

for (std::vector<std::pair<std::string,std::pair<int64_t,int64_t> > >::iterator it = rangeMap.begin(); it!= rangeMap.end(); ++it) {
const std::pair<std::string,std::pair<int64_t,int64_t> >& entry = *it;
const std::string& address = entry.first;
const std::pair<int64_t,int64_t>& range = entry.second;

if (address != sender) {
continue;
}

bool success = pDbNFT->MoveNonFungibleTokens(propertyId, range.first, range.second, sender, receiver);
int64_t amount = (range.second - range.first) + 1;
moneyNft += amount;

PrintToLog("%s: moving %d nfts of property %d from %s to %s. success? %d\n", __func__, amount, propertyId, sender, receiver, success);
}
PrintToLog("%s: total %d nfts moved of %d expected\n", __func__, moneyNft, moneyAvailable);
}
}

++numberOfPropertiesSent;
assert(update_tally_map(sender, propertyId, -moneyAvailable, BALANCE));
assert(update_tally_map(receiver, propertyId, moneyAvailable, BALANCE));
Expand Down Expand Up @@ -2460,6 +2477,7 @@ int CMPTransaction::logicMath_RevokeTokens(CBlockIndex* pindex)
return (PKT_ERROR_TOKENS -22);
}


if (isPropertyNonFungible(property)) {
PrintToLog("%s(): rejected: property %d is of type non-fungible\n", __func__, property);
return (PKT_ERROR_NFT -21);
Expand Down Expand Up @@ -2529,9 +2547,11 @@ int CMPTransaction::logicMath_ChangeIssuer(CBlockIndex* pindex)
return (PKT_ERROR_TOKENS -22);
}

if (isPropertyNonFungible(property)) {
PrintToLog("%s(): rejected: property %d is of type non-fungible\n", __func__, property);
return (PKT_ERROR_NFT -21);
if (!IsFeatureActivated(FEATURE_NONFUNGIBLE_ISSUER, block)) {
if (isPropertyNonFungible(property)) {
PrintToLog("%s(): rejected: property %d is of type non-fungible\n", __func__, property);
return (PKT_ERROR_NFT -21);
}
}

if (!IsPropertyIdValid(property)) {
Expand Down