use of com.hederahashgraph.api.proto.java.TokenInfo in project hedera-services by hashgraph.
the class HapiTokenUpdate method feeFor.
@Override
protected long feeFor(HapiApiSpec spec, Transaction txn, int numPayerKeys) throws Throwable {
try {
final TokenInfo info = HapiTokenFeeScheduleUpdate.lookupInfo(spec, token, log, loggingOff);
FeeCalculator.ActivityMetrics metricsCalc = (_txn, svo) -> {
var estimate = TokenUpdateUsage.newEstimate(_txn, suFrom(svo));
estimate.givenCurrentExpiry(info.getExpiry().getSeconds()).givenCurrentMemo(info.getMemo()).givenCurrentName(info.getName()).givenCurrentSymbol(info.getSymbol());
if (info.hasFreezeKey()) {
estimate.givenCurrentFreezeKey(Optional.of(info.getFreezeKey()));
}
if (info.hasAdminKey()) {
estimate.givenCurrentAdminKey(Optional.of(info.getAdminKey()));
}
if (info.hasSupplyKey()) {
estimate.givenCurrentSupplyKey(Optional.of(info.getSupplyKey()));
}
if (info.hasKycKey()) {
estimate.givenCurrentKycKey(Optional.of(info.getKycKey()));
}
if (info.hasWipeKey()) {
estimate.givenCurrentWipeKey(Optional.of(info.getWipeKey()));
}
if (info.hasFeeScheduleKey()) {
estimate.givenCurrentFeeScheduleKey(Optional.of(info.getFeeScheduleKey()));
}
if (info.hasPauseKey()) {
estimate.givenCurrentPauseKey(Optional.of(info.getPauseKey()));
}
if (info.hasAutoRenewAccount()) {
estimate.givenCurrentlyUsingAutoRenewAccount();
}
return estimate.get();
};
return spec.fees().forActivityBasedOp(HederaFunctionality.TokenUpdate, metricsCalc, txn, numPayerKeys);
} catch (Throwable t) {
log.warn("Couldn't estimate usage", t);
return HapiApiSuite.ONE_HBAR;
}
}
use of com.hederahashgraph.api.proto.java.TokenInfo in project hedera-services by hashgraph.
the class HapiTokenFeeScheduleUpdate method feeFor.
@Override
protected long feeFor(HapiApiSpec spec, Transaction txn, int numPayerKeys) throws Throwable {
try {
final TokenInfo info = lookupInfo(spec, token, log, loggingOff);
final FeeCalculator.ActivityMetrics metricsCalc = (_txn, svo) -> usageEstimate(_txn, svo, info);
return spec.fees().forActivityBasedOp(TokenFeeScheduleUpdate, metricsCalc, txn, numPayerKeys);
} catch (Throwable ignore) {
return HapiApiSuite.ONE_HBAR;
}
}
Aggregations