Search in sources :

Example 11 with TransactionReceipt

use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.

the class AccountClient method createCryptoAccount.

public ExpandedAccountId createCryptoAccount(Hbar initialBalance, boolean receiverSigRequired, KeyList keyList, String memo) {
    // 1. Generate a Ed25519 private, public key pair
    PrivateKey privateKey = PrivateKey.generate();
    PublicKey publicKey = privateKey.getPublicKey();
    log.trace("Private key = {}", privateKey);
    log.trace("Public key = {}", publicKey);
    KeyList publicKeyList = KeyList.of(privateKey.getPublicKey());
    if (keyList != null) {
        publicKeyList.addAll(keyList);
    }
    AccountCreateTransaction accountCreateTransaction = getAccountCreateTransaction(initialBalance, publicKeyList, receiverSigRequired, memo == null ? "" : memo);
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(accountCreateTransaction, receiverSigRequired ? KeyList.of(privateKey) : null);
    TransactionReceipt receipt = networkTransactionResponse.getReceipt();
    AccountId newAccountId = receipt.accountId;
    // verify accountId
    if (receipt.accountId == null) {
        throw new NetworkException(String.format("Receipt for %s returned no accountId, receipt: %s", networkTransactionResponse.getTransactionId(), receipt));
    }
    log.debug("Created new account {}, receiverSigRequired: {}", newAccountId, receiverSigRequired);
    return new ExpandedAccountId(newAccountId, privateKey, privateKey.getPublicKey());
}
Also used : PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) AccountId(com.hedera.hashgraph.sdk.AccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) PublicKey(com.hedera.hashgraph.sdk.PublicKey) KeyList(com.hedera.hashgraph.sdk.KeyList) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction)

Example 12 with TransactionReceipt

use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.

the class PublishMetricsTest method onErrorReceiptStatusException.

@Test
void onErrorReceiptStatusException() throws Exception {
    TransactionId transactionId = TransactionId.withValidStart(AccountId.fromString("0.0.3"), Instant.now());
    TransactionReceipt transactionReceipt = receipt(ResponseCodeEnum.SUCCESS);
    Constructor<ReceiptStatusException> constructor = getDeclaredConstructor(ReceiptStatusException.class);
    constructor.setAccessible(true);
    ReceiptStatusException receiptStatusException = constructor.newInstance(transactionId, transactionReceipt);
    onError(receiptStatusException, ResponseCodeEnum.SUCCESS.toString());
}
Also used : TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) ReceiptStatusException(com.hedera.hashgraph.sdk.ReceiptStatusException) TransactionId(com.hedera.hashgraph.sdk.TransactionId) Test(org.junit.jupiter.api.Test)

Example 13 with TransactionReceipt

use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.

the class ScheduleFeature method verifyNetworkScheduleStatus.

@Retryable(value = { AssertionError.class }, backoff = @Backoff(delayExpression = "#{@acceptanceTestProperties.backOffPeriod.toMillis()}"), maxAttemptsExpression = "#{@acceptanceTestProperties.maxRetries}")
public void verifyNetworkScheduleStatus(ScheduleStatus scheduleStatus) {
    scheduleInfo = scheduleClient.getScheduleInfo(scheduleId);
    // verify executed from 3 min record, set scheduled=true on scheduleCreateTransactionId and get receipt
    validateScheduleInfo(scheduleInfo);
    switch(scheduleStatus) {
        case NON_EXECUTED:
            assertThat(scheduleInfo.executedAt).isNull();
            assertThat(scheduleInfo.deletedAt).isNull();
            break;
        case EXECUTED:
            assertThat(scheduleInfo.deletedAt).isNull();
            assertThat(scheduleInfo.executedAt).isNotNull();
            TransactionReceipt transactionReceipt = scheduleClient.getTransactionReceipt(scheduledTransactionId);
            assertNotNull(transactionReceipt);
            log.debug("Executed transaction {} was confirmed", scheduledTransactionId);
            break;
        case DELETED:
            assertThat(scheduleInfo.deletedAt).isNotNull();
            assertThat(scheduleInfo.executedAt).isNull();
            break;
        default:
            break;
    }
    log.info("Schedule {} status was confirmed by network state", scheduleId);
}
Also used : TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) Retryable(org.springframework.retry.annotation.Retryable)

Example 14 with TransactionReceipt

use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.

the class TopicClient method publishMessageToTopicAndVerify.

public TransactionReceipt publishMessageToTopicAndVerify(TopicId topicId, byte[] message, KeyList submitKeys) {
    TransactionId transactionId = publishMessageToTopic(topicId, message, submitKeys);
    TransactionReceipt transactionReceipt = null;
    try {
        transactionReceipt = getTransactionReceipt(transactionId);
        // note time stamp
        recordPublishInstants.put(transactionReceipt.topicSequenceNumber, getTransactionRecord(transactionId).consensusTimestamp);
    } catch (Exception e) {
        log.error("Error retrieving transaction receipt", e);
    }
    log.trace("Verified message published : '{}' to topicId : {} with sequence number : {}", message, topicId, transactionReceipt.topicSequenceNumber);
    return transactionReceipt;
}
Also used : TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) TransactionId(com.hedera.hashgraph.sdk.TransactionId)

Example 15 with TransactionReceipt

use of com.hedera.hashgraph.sdk.TransactionReceipt in project hedera-mirror-node by hashgraph.

the class TokenFeature method mintNftToken.

@Given("I mint a serial number from the token")
public void mintNftToken() {
    TokenId tokenId = tokenIds.get(0);
    networkTransactionResponse = tokenClient.mint(tokenId, RandomUtils.nextBytes(4));
    assertNotNull(networkTransactionResponse.getTransactionId());
    TransactionReceipt receipt = networkTransactionResponse.getReceipt();
    assertNotNull(receipt);
    assertThat(receipt.serials.size()).isEqualTo(1);
    long serialNumber = receipt.serials.get(0);
    assertThat(serialNumber).isPositive();
    tokenSerialNumbers.get(tokenId).add(serialNumber);
}
Also used : TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) TokenId(com.hedera.hashgraph.sdk.TokenId) Given(io.cucumber.java.en.Given)

Aggregations

TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)25 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)17 Client (com.hedera.hashgraph.sdk.Client)16 Hbar (com.hedera.hashgraph.sdk.Hbar)12 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)11 AccountId (com.hedera.hashgraph.sdk.AccountId)11 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)11 KeyList (com.hedera.hashgraph.sdk.KeyList)8 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)8 Var (com.google.errorprone.annotations.Var)6 PublicKey (com.hedera.hashgraph.sdk.PublicKey)6 TransactionId (com.hedera.hashgraph.sdk.TransactionId)6 FileCreateTransaction (com.hedera.hashgraph.sdk.FileCreateTransaction)5 FileId (com.hedera.hashgraph.sdk.FileId)5 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)4 ScheduleId (com.hedera.hashgraph.sdk.ScheduleId)4 ScheduleInfoQuery (com.hedera.hashgraph.sdk.ScheduleInfoQuery)4 ScheduleSignTransaction (com.hedera.hashgraph.sdk.ScheduleSignTransaction)4 ScheduleCreateTransaction (com.hedera.hashgraph.sdk.ScheduleCreateTransaction)3 ScheduleInfo (com.hedera.hashgraph.sdk.ScheduleInfo)3