use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class HapiMessageSubmit method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
TopicID id = resolveTopicId(spec);
ConsensusSubmitMessageTransactionBody opBody = spec.txns().<ConsensusSubmitMessageTransactionBody, ConsensusSubmitMessageTransactionBody.Builder>body(ConsensusSubmitMessageTransactionBody.class, b -> {
b.setTopicID(id);
message.ifPresent(m -> b.setMessage(m));
if (clearMessage) {
b.clearMessage();
}
if (totalChunks.isPresent() && chunkNumber.isPresent()) {
ConsensusMessageChunkInfo chunkInfo = ConsensusMessageChunkInfo.newBuilder().setInitialTransactionID(initialTransactionID.orElse(asTransactionID(spec, initialTransactionPayer.isPresent() ? initialTransactionPayer : payer))).setTotal(totalChunks.getAsInt()).setNumber(chunkNumber.getAsInt()).build();
b.setChunkInfo(chunkInfo);
spec.registry().saveTimestamp(txnName, chunkInfo.getInitialTransactionID().getTransactionValidStart());
}
});
return b -> b.setConsensusSubmitMessage(opBody);
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class HapiTopicCreate method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
genKeysFor(spec);
ConsensusCreateTopicTransactionBody opBody = spec.txns().<ConsensusCreateTopicTransactionBody, ConsensusCreateTopicTransactionBody.Builder>body(ConsensusCreateTopicTransactionBody.class, b -> {
if (adminKey != null) {
b.setAdminKey(adminKey);
}
topicMemo.ifPresent(b::setMemo);
submitKey.ifPresent(b::setSubmitKey);
autoRenewAccountId.ifPresent(id -> b.setAutoRenewAccount(asId(id, spec)));
autoRenewPeriod.ifPresent(secs -> b.setAutoRenewPeriod(asDuration(secs)));
if (clearAutoRenewPeriod) {
b.clearAutoRenewPeriod();
}
});
return b -> b.setConsensusCreateTopic(opBody);
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class HapiTopicDelete method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
TopicID id = resolveTopicId(spec);
ConsensusDeleteTopicTransactionBody opBody = spec.txns().<ConsensusDeleteTopicTransactionBody, ConsensusDeleteTopicTransactionBody.Builder>body(ConsensusDeleteTopicTransactionBody.class, b -> {
b.setTopicID(id);
});
return b -> b.setConsensusDeleteTopic(opBody);
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class HapiTopicUpdate method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
newAdminKeyName.ifPresent(name -> newAdminKey = Optional.of(spec.registry().getKey(name)));
newSubmitKeyName.ifPresent(name -> newSubmitKey = Optional.of(spec.registry().getKey(name)));
ConsensusUpdateTopicTransactionBody opBody = spec.txns().<ConsensusUpdateTopicTransactionBody, ConsensusUpdateTopicTransactionBody.Builder>body(ConsensusUpdateTopicTransactionBody.class, b -> {
b.setTopicID(asTopicId(topic, spec));
topicMemo.ifPresent(memo -> b.setMemo(StringValue.of(memo)));
newAdminKey.ifPresent(b::setAdminKey);
newSubmitKey.ifPresent(b::setSubmitKey);
newExpiry.ifPresent(s -> b.setExpirationTime(asTimestamp(s)));
newAutoRenewPeriod.ifPresent(s -> b.setAutoRenewPeriod(asDuration(s)));
newAutoRenewAccount.ifPresent(id -> b.setAutoRenewAccount(asId(id, spec)));
});
return b -> b.setConsensusUpdateTopic(opBody);
}
use of com.hedera.services.bdd.spec.HapiApiSpec in project hedera-services by hashgraph.
the class HapiCryptoUpdate method feeFor.
@Override
protected long feeFor(HapiApiSpec spec, Transaction txn, int numPayerKeys) throws Throwable {
try {
final CryptoGetInfoResponse.AccountInfo info = lookupInfo(spec);
FeeCalculator.ActivityMetrics metricsCalc = (_txn, svo) -> {
var ctx = ExtantCryptoContext.newBuilder().setCurrentNumTokenRels(info.getTokenRelationshipsCount()).setCurrentExpiry(info.getExpirationTime().getSeconds()).setCurrentMemo(info.getMemo()).setCurrentKey(info.getKey()).setCurrentlyHasProxy(info.hasProxyAccountID()).setCurrentMaxAutomaticAssociations(info.getMaxAutomaticTokenAssociations()).build();
var baseMeta = new BaseTransactionMeta(_txn.getMemoBytes().size(), 0);
var opMeta = new CryptoUpdateMeta(_txn.getCryptoUpdateAccount(), _txn.getTransactionID().getTransactionValidStart().getSeconds());
var accumulator = new UsageAccumulator();
cryptoOpsUsage.cryptoUpdateUsage(suFrom(svo), baseMeta, opMeta, ctx, accumulator);
return AdapterUtils.feeDataFrom(accumulator);
};
return spec.fees().forActivityBasedOp(HederaFunctionality.CryptoUpdate, metricsCalc, txn, numPayerKeys);
} catch (Throwable ignore) {
return HapiApiSuite.ONE_HBAR;
}
}
Aggregations