Skip to content

Commit

Permalink
Merge OmniLayer#1269: Disable NFTs for now
Browse files Browse the repository at this point in the history
Pull request description:

  Disable NFTs for now.
  • Loading branch information
dexX7 authored and counos committed Sep 27, 2023
1 parent a4dead0 commit 26b443c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/counoscore/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ UniValue counos_getnonfungibletokens(const JSONRPCRequest& request)
}
}.Check(request);

if (!IsFeatureActivated(FEATURE_NFTS, GetHeight())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "NFTs not activated");
}

std::string address = ParseAddress(request.params[0]);
uint32_t propertyId{0};
if (!request.params[1].isNull()) {
Expand Down Expand Up @@ -264,6 +268,10 @@ UniValue counos_getnonfungibletokendata(const JSONRPCRequest& request)
}
}.Check(request);

if (!IsFeatureActivated(FEATURE_NFTS, GetHeight())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "NFTs not activated");
}

uint32_t propertyId = ParsePropertyId(request.params[0]);

RequireExistingProperty(propertyId);
Expand Down Expand Up @@ -352,6 +360,10 @@ UniValue counos_getnonfungibletokenranges(const JSONRPCRequest& request)
}
}.Check(request);

if (!IsFeatureActivated(FEATURE_NFTS, GetHeight())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "NFTs not activated");
}

uint32_t propertyId = ParsePropertyId(request.params[0]);

RequireExistingProperty(propertyId);
Expand Down
12 changes: 12 additions & 0 deletions src/counoscore/rpctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ static UniValue counos_sendnonfungible(const JSONRPCRequest& request)
}
}.Check(request);

if (!IsFeatureActivated(FEATURE_NFTS, GetHeight())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "NFTs not activated");
}

std::string fromAddress = ParseAddress(request.params[0]);
std::string toAddress = ParseAddress(request.params[1]);
uint32_t propertyId = ParsePropertyId(request.params[2]);
Expand Down Expand Up @@ -375,6 +379,10 @@ static UniValue counos_setnonfungibledata(const JSONRPCRequest& request)
}
}.Check(request);

if (!IsFeatureActivated(FEATURE_NFTS, GetHeight())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "NFTs not activated");
}

uint32_t propertyId = ParsePropertyId(request.params[0]);
uint64_t tokenStart = request.params[1].get_int64();
int64_t tokenEnd = request.params[2].get_int64();
Expand Down Expand Up @@ -1149,6 +1157,10 @@ static UniValue counos_sendissuancemanaged(const JSONRPCRequest& request)
std::string url = ParseText(request.params[7]);
std::string data = ParseText(request.params[8]);

if (type == 5 && !IsFeatureActivated(FEATURE_NFTS, GetHeight())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "NFTs not activated");
}

// perform checks
RequirePropertyName(name);

Expand Down
13 changes: 13 additions & 0 deletions src/counoscore/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ CTestNetConsensusParams::CTestNetConsensusParams()
MSC_NONFUNGIBLE_BLOCK = 0;
MSC_DELEGATED_ISSUANCE_BLOCK = 0;
MSC_SEND_TO_MANY_BLOCK = 999999;
MSC_NFT_BLOCK = 999999;
// Other feature activations:
GRANTEFFECTS_FEATURE_BLOCK = 394500;
DEXMATH_FEATURE_BLOCK = 395000;
Expand Down Expand Up @@ -224,6 +225,7 @@ CMainConsensusParams::CMainConsensusParams()
MSC_NONFUNGIBLE_BLOCK = 999999;
MSC_DELEGATED_ISSUANCE_BLOCK = 999999;
MSC_SEND_TO_MANY_BLOCK = 0;
MSC_NFT_BLOCK = 999999;
// Other feature activations:
GRANTEFFECTS_FEATURE_BLOCK = 0;
DEXMATH_FEATURE_BLOCK = 0;
Expand Down Expand Up @@ -271,6 +273,7 @@ CRegTestConsensusParams::CRegTestConsensusParams()
MSC_NONFUNGIBLE_BLOCK = 0;
MSC_DELEGATED_ISSUANCE_BLOCK = 0;
MSC_SEND_TO_MANY_BLOCK = 0;
MSC_NFT_BLOCK = 999999;
// Other feature activations:
GRANTEFFECTS_FEATURE_BLOCK = 999999;
DEXMATH_FEATURE_BLOCK = 999999;
Expand Down Expand Up @@ -488,6 +491,9 @@ bool ActivateFeature(uint16_t featureId, int activationBlock, uint32_t minClient
case FEATURE_SEND_TO_MANY:
MutableConsensusParams().MSC_SEND_TO_MANY_BLOCK = activationBlock;
break;
case FEATURE_NFTS:
MutableConsensusParams().MSC_NFT_BLOCK = activationBlock;
break;
default:
supported = false;
break;
Expand Down Expand Up @@ -574,6 +580,9 @@ bool DeactivateFeature(uint16_t featureId, int transactionBlock)
case FEATURE_SEND_TO_MANY:
MutableConsensusParams().MSC_SEND_TO_MANY_BLOCK = 999999;
break;
case FEATURE_NFTS:
MutableConsensusParams().MSC_NFT_BLOCK = 999999;
break;
default:
return false;
break;
Expand Down Expand Up @@ -610,6 +619,7 @@ std::string GetFeatureName(uint16_t featureId)
case FEATURE_NONFUNGIBLE_ISSUER: return "NFT issuer data update by issuers only";
case FEATURE_DELEGATEDISSUANCE: return "Activate delegated issuance of tokens";
case FEATURE_SEND_TO_MANY: return "Activate send-to-many transactions";
case FEATURE_NFTS: return "Activate NFT transactions";

default: return "Unknown feature";
}
Expand Down Expand Up @@ -672,6 +682,9 @@ bool IsFeatureActivated(uint16_t featureId, int transactionBlock)
case FEATURE_SEND_TO_MANY:
activationBlock = params.MSC_SEND_TO_MANY_BLOCK;
break;
case FEATURE_NFTS:
activationBlock = params.MSC_NFT_BLOCK;
break;
default:
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/counoscore/rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const uint16_t FEATURE_DELEGATEDISSUANCE = 17;
const uint16_t FEATURE_NONFUNGIBLE_ISSUER = 18;
//! Feature identifier to enable send-to-many support
const uint16_t FEATURE_SEND_TO_MANY = 19;
//! Feature identifier to enable NFTs
const uint16_t FEATURE_NFTS = 20;

//! When (propertyTotalTokens / COUNOS_FEE_THRESHOLD) is reached fee distribution will occur
const int64_t COUNOS_FEE_THRESHOLD = 100000; // 0.001%
Expand Down Expand Up @@ -146,6 +148,8 @@ class CConsensusParams
int MSC_DELEGATED_ISSUANCE_BLOCK;
//! Block to enable send-to-many
int MSC_SEND_TO_MANY_BLOCK;
//! Block to enable NFTs
int MSC_NFT_BLOCK;

//! Block to deactivate crowdsale participations when "granting tokens"
int GRANTEFFECTS_FEATURE_BLOCK;
Expand Down

0 comments on commit 26b443c

Please sign in to comment.