use of com.hederahashgraph.api.proto.java.SubType in project hedera-services by hashgraph.
the class HapiTokenCreate method getTxnSubType.
private SubType getTxnSubType(final TransactionBody txn) {
final var op = txn.getTokenCreation();
SubType chosenType;
final var usesCustomFees = op.hasFeeScheduleKey() || op.getCustomFeesCount() > 0;
if (op.getTokenType() == NON_FUNGIBLE_UNIQUE) {
chosenType = usesCustomFees ? TOKEN_NON_FUNGIBLE_UNIQUE_WITH_CUSTOM_FEES : TOKEN_NON_FUNGIBLE_UNIQUE;
} else {
chosenType = usesCustomFees ? TOKEN_FUNGIBLE_COMMON_WITH_CUSTOM_FEES : TOKEN_FUNGIBLE_COMMON;
}
return chosenType;
}
use of com.hederahashgraph.api.proto.java.SubType in project hedera-services by hashgraph.
the class BasicFcfsUsagePricesTest method returnsDefaultUsagePricesForUnsupported.
@Test
void returnsDefaultUsagePricesForUnsupported() {
// setup:
MockAppender mockAppender = new MockAppender();
var log = (org.apache.logging.log4j.core.Logger) LogManager.getLogger(BasicFcfsUsagePrices.class);
log.addAppender(mockAppender);
Level levelForReset = log.getLevel();
log.setLevel(Level.DEBUG);
// given:
subject.loadPriceSchedules();
Timestamp at = Timestamp.newBuilder().setSeconds(currentExpiry - 1).build();
// when:
Map<SubType, FeeData> actual = subject.pricesGiven(UNRECOGNIZED, at);
// then:
assertEquals(DEFAULT_RESOURCE_PRICES, actual);
assertEquals(1, mockAppender.size());
assertEquals("DEBUG - Default usage price will be used, no specific usage prices available for function " + "UNRECOGNIZED" + " @ 1970-01-15T06:56:06Z!", mockAppender.get(0));
// tearDown:
log.setLevel(levelForReset);
log.removeAppender(mockAppender);
mockAppender.clear();
}
use of com.hederahashgraph.api.proto.java.SubType in project hedera-services by hashgraph.
the class BasicFcfsUsagePricesTest method getsTransferUsagePricesAtCurrent.
@Test
void getsTransferUsagePricesAtCurrent() {
// given:
subject.loadPriceSchedules();
Timestamp at = Timestamp.newBuilder().setSeconds(currentExpiry - 1).build();
// when:
Map<SubType, FeeData> actual = subject.pricesGiven(ContractCall, at);
// then:
assertEquals(currentContractCallPrices, actual);
}
use of com.hederahashgraph.api.proto.java.SubType in project hedera-services by hashgraph.
the class BasicFcfsUsagePricesTest method getsTransferUsagePricesPastCurrentBeforeNextExpiry.
@Test
void getsTransferUsagePricesPastCurrentBeforeNextExpiry() throws Exception {
// given:
subject.loadPriceSchedules();
Timestamp at = Timestamp.newBuilder().setSeconds(nextExpiry - 1).build();
// when:
Map<SubType, FeeData> actual = subject.pricesGiven(ContractCall, at);
// then:
assertEquals(nextContractCallPrices, actual);
}
use of com.hederahashgraph.api.proto.java.SubType in project hedera-services by hashgraph.
the class TokenCreateUsage method get.
public FeeData get() {
int baseSize = TOKEN_OPS_USAGE_UTILS.getTokenTxnBaseSize(op);
var opTokenCreation = this.op.getTokenCreation();
var lifetime = opTokenCreation.hasAutoRenewAccount() ? opTokenCreation.getAutoRenewPeriod().getSeconds() : ESTIMATOR_UTILS.relativeLifetime(this.op, opTokenCreation.getExpiry().getSeconds());
lifetime = Math.min(lifetime, MAX_ENTITY_LIFETIME);
usageEstimator.addBpt(baseSize);
final var feeSchedulesSize = opTokenCreation.getCustomFeesCount() > 0 ? tokenOpsUsage.bytesNeededToRepr(opTokenCreation.getCustomFeesList()) : 0;
usageEstimator.addRbs((baseSize + feeSchedulesSize) * lifetime);
addNetworkRecordRb(BASIC_ENTITY_ID_SIZE);
addTokenTransfersRecordRb(1, opTokenCreation.getInitialSupply() > 0 ? 1 : 0, 0);
SubType chosenType;
final var usesCustomFees = opTokenCreation.hasFeeScheduleKey() || opTokenCreation.getCustomFeesCount() > 0;
if (opTokenCreation.getTokenType() == NON_FUNGIBLE_UNIQUE) {
chosenType = usesCustomFees ? TOKEN_NON_FUNGIBLE_UNIQUE_WITH_CUSTOM_FEES : TOKEN_NON_FUNGIBLE_UNIQUE;
} else {
chosenType = usesCustomFees ? TOKEN_FUNGIBLE_COMMON_WITH_CUSTOM_FEES : TOKEN_FUNGIBLE_COMMON;
}
return usageEstimator.get(chosenType);
}
Aggregations