Search in sources :

Example 56 with TransactionRecord

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));
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 57 with 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);
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 58 with 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);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 59 with TransactionRecord

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;
}
Also used : TokenUnpauseTransactionBody(com.hederahashgraph.api.proto.java.TokenUnpauseTransactionBody) TokenRevokeKycTransactionBody(com.hederahashgraph.api.proto.java.TokenRevokeKycTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TokenPauseTransactionBody(com.hederahashgraph.api.proto.java.TokenPauseTransactionBody) TokenFeeScheduleUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenFeeScheduleUpdateTransactionBody) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) TokenGrantKycTransactionBody(com.hederahashgraph.api.proto.java.TokenGrantKycTransactionBody) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) TokenCreateTransactionBody(com.hederahashgraph.api.proto.java.TokenCreateTransactionBody) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) TokenWipeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenWipeAccountTransactionBody) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TokenBurnTransactionBody(com.hederahashgraph.api.proto.java.TokenBurnTransactionBody) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody) CryptoAddLiveHashTransactionBody(com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Example 60 with TransactionRecord

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);
    }
}
Also used : Schedule(com.hedera.mirror.common.domain.schedule.Schedule) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Aggregations

TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)107 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)86 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)84 Transaction (com.hederahashgraph.api.proto.java.Transaction)83 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)74 Test (org.junit.jupiter.api.Test)69 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)30 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)30 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)28 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)28 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)28 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)26 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)26 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)26 UtilityTest (com.hedera.mirror.importer.util.UtilityTest)23 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)19 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)19 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)19 Entity (com.hedera.mirror.common.domain.entity.Entity)17 EnumSource (org.junit.jupiter.params.provider.EnumSource)13