use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method updateTokenFeeSchedule.
private void updateTokenFeeSchedule(TokenID tokenID, long consensusTimestamp, List<CustomFee> customFees) {
Transaction transaction = buildTransaction(builder -> builder.getTokenFeeScheduleUpdateBuilder().setTokenId(tokenID).addAllCustomFees(convertCustomFees(customFees)));
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord transactionRecord = buildTransactionRecord(builder -> builder.setConsensusTimestamp(TestUtils.toTimestamp(consensusTimestamp)), transactionBody, ResponseCodeEnum.SUCCESS.getNumber());
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class TransactionSignatureTest method getRecordItem.
private RecordItem getRecordItem(TransactionType transactionType, ResponseCodeEnum responseCode, SignatureMap signatureMap) {
TransactionBody transactionBody = getTransactionBody(transactionType);
Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(signatureMap).build().toByteString()).build();
TransactionRecord transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Utility.instantToTimestamp(Instant.ofEpochSecond(0, CONSENSUS_TIMESTAMP))).setReceipt(TransactionReceipt.newBuilder().setStatus(responseCode).build()).build();
return new RecordItem(transaction, transactionRecord);
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method noTreasuryUpdate.
@Test
void noTreasuryUpdate() {
AbstractEntity entity = getExpectedUpdatedEntity();
TokenTransferList tokenTransferList = TokenTransferList.newBuilder().setToken(TokenID.newBuilder().setTokenNum(3L).build()).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(AccountID.newBuilder().setAccountNum(2L).build()).setSenderAccountID(AccountID.newBuilder().setAccountNum(1L).build()).setSerialNumber(// Not wildcard
1L).build()).build();
TransactionRecord record = getDefaultTransactionRecord().addTokenTransferLists(tokenTransferList).build();
RecordItem recordItem = getRecordItem(getDefaultTransactionBody().build(), record);
when(entityIdService.lookup(AccountID.newBuilder().setAccountNum(DEFAULT_AUTO_RENEW_ACCOUNT_NUM).build())).thenReturn(EntityIdEndec.decode(DEFAULT_AUTO_RENEW_ACCOUNT_NUM, EntityType.ACCOUNT));
Transaction transaction = new Transaction();
transaction.setEntityId(entity.toEntityId());
transactionHandler.updateTransaction(transaction, recordItem);
Mockito.verifyNoInteractions(nftRepository);
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method buildTransaction.
private Transaction buildTransaction(long consensusTimestamp, RecordItem recordItem) {
TransactionBody body = recordItem.getTransactionBody();
TransactionRecord txRecord = recordItem.getRecord();
Long validDurationSeconds = body.hasTransactionValidDuration() ? body.getTransactionValidDuration().getSeconds() : null;
// transactions in stream always have valid node account id.
var nodeAccount = EntityId.of(body.getNodeAccountID());
var transactionId = body.getTransactionID();
// build transaction
Transaction transaction = new Transaction();
transaction.setChargedTxFee(txRecord.getTransactionFee());
transaction.setConsensusTimestamp(consensusTimestamp);
transaction.setIndex(recordItem.getTransactionIndex());
transaction.setInitialBalance(0L);
transaction.setMaxFee(body.getTransactionFee());
transaction.setMemo(DomainUtils.toBytes(body.getMemoBytes()));
transaction.setNodeAccountId(nodeAccount);
transaction.setNonce(transactionId.getNonce());
transaction.setPayerAccountId(recordItem.getPayerAccountId());
transaction.setResult(txRecord.getReceipt().getStatusValue());
transaction.setScheduled(txRecord.hasScheduleRef());
transaction.setTransactionBytes(entityProperties.getPersist().isTransactionBytes() ? recordItem.getTransactionBytes() : null);
transaction.setTransactionHash(DomainUtils.toBytes(txRecord.getTransactionHash()));
transaction.setType(recordItem.getTransactionType());
transaction.setValidDurationSeconds(validDurationSeconds);
transaction.setValidStartNs(DomainUtils.timeStampInNanos(transactionId.getTransactionValidStart()));
if (txRecord.hasParentConsensusTimestamp()) {
transaction.setParentConsensusTimestamp(DomainUtils.timestampInNanosMax(txRecord.getParentConsensusTimestamp()));
}
return transaction;
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method onScheduledTransaction.
private void onScheduledTransaction(RecordItem recordItem) {
if (entityProperties.getPersist().isSchedules()) {
long consensusTimestamp = recordItem.getConsensusTimestamp();
TransactionRecord transactionRecord = recordItem.getRecord();
// update schedule execute time
Schedule schedule = new Schedule();
schedule.setScheduleId(EntityId.of(transactionRecord.getScheduleRef()));
schedule.setExecutedTimestamp(consensusTimestamp);
entityListener.onSchedule(schedule);
}
}
Aggregations