Search in sources :

Example 1 with ScheduleCreateTransactionBody

use of com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody in project hedera-services by hashgraph.

the class HapiScheduleCreate method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    var subOp = scheduled.signedTxnFor(spec);
    ScheduleCreateTransactionBody opBody = spec.txns().<ScheduleCreateTransactionBody, ScheduleCreateTransactionBody.Builder>body(ScheduleCreateTransactionBody.class, b -> {
        if (scheduleNoFunction) {
            b.setScheduledTransactionBody(SchedulableTransactionBody.getDefaultInstance());
        } else {
            try {
                var deserializedTxn = TransactionBody.parseFrom(subOp.getBodyBytes());
                scheduledTxn.set(ScheduleUtils.fromOrdinary(deserializedTxn));
                b.setScheduledTransactionBody(scheduledTxn.get());
            } catch (InvalidProtocolBufferException fatal) {
                throw new IllegalStateException("Couldn't deserialize serialized TransactionBody!");
            }
        }
        if (useSentinelKeyListForAdminKey) {
            b.setAdminKey(Key.newBuilder().setKeyList(KeyList.getDefaultInstance()));
        } else {
            adminKey.ifPresent(k -> b.setAdminKey(spec.registry().getKey(k)));
        }
        entityMemo.ifPresent(b::setMemo);
        payerAccountID.ifPresent(a -> {
            var payer = TxnUtils.asId(a, spec);
            b.setPayerAccountID(payer);
        });
    });
    return b -> b.setScheduleCreate(opBody);
}
Also used : ScheduleCreateTransactionBody(com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) ScheduleUtils(com.hedera.services.bdd.suites.schedule.ScheduleUtils) ScheduleCreate(com.hederahashgraph.api.proto.java.HederaFunctionality.ScheduleCreate) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) ScheduleCreateTransactionBody(com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) KeyList(com.hederahashgraph.api.proto.java.KeyList) BiConsumer(java.util.function.BiConsumer) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) HapiPropertySource.asScheduleString(com.hedera.services.bdd.spec.HapiPropertySource.asScheduleString) MoreObjects(com.google.common.base.MoreObjects) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) SchedulableTransactionBody(com.hederahashgraph.api.proto.java.SchedulableTransactionBody) ByteString(com.google.protobuf.ByteString) Consumer(java.util.function.Consumer) TxnFactory.bannerWith(com.hedera.services.bdd.spec.transactions.TxnFactory.bannerWith) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 2 with ScheduleCreateTransactionBody

use of com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListener method insertScheduleCreate.

private void insertScheduleCreate(RecordItem recordItem) {
    if (entityProperties.getPersist().isSchedules()) {
        ScheduleCreateTransactionBody scheduleCreateTransactionBody = recordItem.getTransactionBody().getScheduleCreate();
        long consensusTimestamp = recordItem.getConsensusTimestamp();
        var scheduleId = EntityId.of(recordItem.getRecord().getReceipt().getScheduleID());
        var creatorAccount = recordItem.getPayerAccountId();
        var payerAccount = creatorAccount;
        if (scheduleCreateTransactionBody.hasPayerAccountID()) {
            payerAccount = EntityId.of(scheduleCreateTransactionBody.getPayerAccountID());
        }
        Schedule schedule = new Schedule();
        schedule.setConsensusTimestamp(consensusTimestamp);
        schedule.setCreatorAccountId(creatorAccount);
        schedule.setPayerAccountId(payerAccount);
        schedule.setScheduleId(scheduleId);
        schedule.setTransactionBody(scheduleCreateTransactionBody.getScheduledTransactionBody().toByteArray());
        entityListener.onSchedule(schedule);
    }
}
Also used : ScheduleCreateTransactionBody(com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody) Schedule(com.hedera.mirror.common.domain.schedule.Schedule)

Aggregations

ScheduleCreateTransactionBody (com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody)2 MoreObjects (com.google.common.base.MoreObjects)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Schedule (com.hedera.mirror.common.domain.schedule.Schedule)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiPropertySource.asScheduleString (com.hedera.services.bdd.spec.HapiPropertySource.asScheduleString)1 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)1 FeeCalculator (com.hedera.services.bdd.spec.fees.FeeCalculator)1 HapiTxnOp (com.hedera.services.bdd.spec.transactions.HapiTxnOp)1 TxnFactory.bannerWith (com.hedera.services.bdd.spec.transactions.TxnFactory.bannerWith)1 TxnUtils (com.hedera.services.bdd.spec.transactions.TxnUtils)1 TxnUtils.suFrom (com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom)1 ScheduleUtils (com.hedera.services.bdd.suites.schedule.ScheduleUtils)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 ScheduleCreate (com.hederahashgraph.api.proto.java.HederaFunctionality.ScheduleCreate)1 Key (com.hederahashgraph.api.proto.java.Key)1 KeyList (com.hederahashgraph.api.proto.java.KeyList)1 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)1 SchedulableTransactionBody (com.hederahashgraph.api.proto.java.SchedulableTransactionBody)1