Search in sources :

Example 1 with CryptoTransferTransactionBody

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

the class RequestBuilder method getTokenTransferRequest.

public static Transaction getTokenTransferRequest(Long payerAccountNum, Long payerRealmNum, Long payerShardNum, Long nodeAccountNum, Long nodeRealmNum, Long nodeShardNum, long transactionFee, Timestamp timestamp, Duration transactionDuration, boolean generateRecord, String memo, TokenTransferList tokenTransferList) {
    CryptoTransferTransactionBody cryptoTransferTransaction = CryptoTransferTransactionBody.newBuilder().addTokenTransfers(tokenTransferList).build();
    TransactionBody.Builder body = getTransactionBody(payerAccountNum, payerRealmNum, payerShardNum, nodeAccountNum, nodeRealmNum, nodeShardNum, transactionFee, timestamp, transactionDuration, generateRecord, memo);
    body.setCryptoTransfer(cryptoTransferTransaction);
    byte[] bodyBytesArr = body.build().toByteArray();
    ByteString bodyBytes = ByteString.copyFrom(bodyBytesArr);
    return Transaction.newBuilder().setBodyBytes(bodyBytes).build();
}
Also used : FileDeleteTransactionBody(com.hederahashgraph.api.proto.java.FileDeleteTransactionBody) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) ByteString(com.google.protobuf.ByteString) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)

Example 2 with CryptoTransferTransactionBody

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

the class HapiQueryOp method opDef.

private Consumer<TransactionBody.Builder> opDef(HapiApiSpec spec, long amount) throws Throwable {
    TransferList transfers = asTransferList(tinyBarsFromTo(amount, spec.registry().getAccountID(effectivePayer(spec)), targetNodeFor(spec)));
    CryptoTransferTransactionBody opBody = spec.txns().<CryptoTransferTransactionBody, CryptoTransferTransactionBody.Builder>body(CryptoTransferTransactionBody.class, b -> b.setTransfers(transfers));
    return b -> b.setCryptoTransfer(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) HapiQueryPrecheckStateException(com.hedera.services.bdd.spec.exceptions.HapiQueryPrecheckStateException) Response(com.hederahashgraph.api.proto.java.Response) QueryUtils.reflectForCost(com.hedera.services.bdd.spec.queries.QueryUtils.reflectForCost) Function(java.util.function.Function) Supplier(java.util.function.Supplier) COST_ANSWER_QUERY_COST(com.hedera.services.bdd.spec.fees.Payment.Reason.COST_ANSWER_QUERY_COST) TxnUtils.asTransferList(com.hedera.services.bdd.spec.transactions.TxnUtils.asTransferList) Payment(com.hedera.services.bdd.spec.fees.Payment) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ResponseType(com.hederahashgraph.api.proto.java.ResponseType) Thread.sleep(java.lang.Thread.sleep) SigValueObj(com.hederahashgraph.fee.SigValueObj) TxnUtils.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.TxnUtils.tinyBarsFromTo) EnumSet(java.util.EnumSet) TransferList(com.hederahashgraph.api.proto.java.TransferList) SigMapGenerator(com.hedera.services.bdd.spec.keys.SigMapGenerator) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) UNKNOWN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNKNOWN) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) TxnUtils.txnToString(com.hedera.services.bdd.spec.transactions.TxnUtils.txnToString) ControlForKey(com.hedera.services.bdd.spec.keys.ControlForKey) FeeData(com.hederahashgraph.api.proto.java.FeeData) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) ANSWER_ONLY_QUERY_COST(com.hedera.services.bdd.spec.fees.Payment.Reason.ANSWER_ONLY_QUERY_COST) TransactionReceipt(com.hederahashgraph.api.proto.java.TransactionReceipt) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) HapiQueryCheckStateException(com.hedera.services.bdd.spec.exceptions.HapiQueryCheckStateException) Logger(org.apache.logging.log4j.Logger) Stream(java.util.stream.Stream) OFF(com.hedera.services.bdd.spec.HapiApiSpec.CostSnapshotMode.OFF) QueryUtils.reflectForPrecheck(com.hedera.services.bdd.spec.queries.QueryUtils.reflectForPrecheck) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) QueryObs(com.hedera.services.bdd.spec.stats.QueryObs) Optional(java.util.Optional) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) HapiCryptoTransfer(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer) LogManager(org.apache.logging.log4j.LogManager) TxnUtils.asTransferList(com.hedera.services.bdd.spec.transactions.TxnUtils.asTransferList) TransferList(com.hederahashgraph.api.proto.java.TransferList) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)

Example 3 with CryptoTransferTransactionBody

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

the class PubSubRecordItemListenerTest method testSendRetries.

@Test
void testSendRetries() throws Exception {
    // when
    CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
    Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
    pubSubProperties.setMaxSendAttempts(3);
    // when
    when(messageChannel.send(any())).thenThrow(MessageTimeoutException.class).thenThrow(MessageTimeoutException.class).thenReturn(true);
    pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
    // then
    var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 3);
    assertThat(pubSubMessage.getEntity()).isNull();
    assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) MessageTimeoutException(org.springframework.integration.MessageTimeoutException) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) Test(org.junit.jupiter.api.Test)

Example 4 with CryptoTransferTransactionBody

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

the class PubSubRecordItemListenerTest method testPubSubMessageWithNonFeeTransferAndNullEntityId.

@Test
void testPubSubMessageWithNonFeeTransferAndNullEntityId() throws Exception {
    // given
    List<AccountAmount> nonFeeTransfers = new ArrayList<>();
    nonFeeTransfers.add(buildAccountAmount(10L, 100L));
    nonFeeTransfers.add(buildAccountAmount(11L, 111L));
    CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().addAccountAmounts(nonFeeTransfers.get(0)).addAccountAmounts(nonFeeTransfers.get(1)).build()).build();
    Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
    var recordItem = new RecordItem(transaction, DEFAULT_RECORD);
    when(nonFeeTransferExtractionStrategy.extractNonFeeTransfers(recordItem.getTransactionBody(), recordItem.getRecord())).thenReturn(cryptoTransfer.getTransfers().getAccountAmountsList());
    // when
    pubSubRecordItemListener.onItem(recordItem);
    // then
    var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
    assertThat(pubSubMessage.getEntity()).isNull();
    assertThat(pubSubMessage.getNonFeeTransfers()).isEqualTo(nonFeeTransfers);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) ArrayList(java.util.ArrayList) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) Test(org.junit.jupiter.api.Test)

Example 5 with CryptoTransferTransactionBody

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

the class RequestBuilder method getCryptoTransferRequest.

public static Transaction getCryptoTransferRequest(Long payerAccountNum, Long payerRealmNum, Long payerShardNum, Long nodeAccountNum, Long nodeRealmNum, Long nodeShardNum, long transactionFee, Timestamp timestamp, Duration transactionDuration, boolean generateRecord, String memo, TransferList transferList) {
    CryptoTransferTransactionBody cryptoTransferTransaction = CryptoTransferTransactionBody.newBuilder().setTransfers(transferList).build();
    TransactionBody.Builder body = getTransactionBody(payerAccountNum, payerRealmNum, payerShardNum, nodeAccountNum, nodeRealmNum, nodeShardNum, transactionFee, timestamp, transactionDuration, generateRecord, memo);
    body.setCryptoTransfer(cryptoTransferTransaction);
    byte[] bodyBytesArr = body.build().toByteArray();
    ByteString bodyBytes = ByteString.copyFrom(bodyBytesArr);
    return Transaction.newBuilder().setBodyBytes(bodyBytes).build();
}
Also used : FileDeleteTransactionBody(com.hederahashgraph.api.proto.java.FileDeleteTransactionBody) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) ByteString(com.google.protobuf.ByteString) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)

Aggregations

CryptoTransferTransactionBody (com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody)9 Transaction (com.hederahashgraph.api.proto.java.Transaction)7 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)5 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)5 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)4 Test (org.junit.jupiter.api.Test)3 ByteString (com.google.protobuf.ByteString)2 TxnUtils.asTransferList (com.hedera.services.bdd.spec.transactions.TxnUtils.asTransferList)2 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)2 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)2 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)2 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)2 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)2 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)2 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)2 FileDeleteTransactionBody (com.hederahashgraph.api.proto.java.FileDeleteTransactionBody)2 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)2 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)2 ParserException (com.hedera.mirror.importer.exception.ParserException)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1