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);
}
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);
}
}
Aggregations