Search in sources :

Example 36 with NetworkTransactionResponse

use of com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse in project hedera-mirror-node by hashgraph.

the class TokenClient method updateToken.

public NetworkTransactionResponse updateToken(TokenId tokenId, ExpandedAccountId expandedAccountId) {
    PublicKey publicKey = expandedAccountId.getPublicKey();
    String newSymbol = RandomStringUtils.randomAlphabetic(4).toUpperCase();
    String memo = getMemo("Update token");
    TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction().setAdminKey(publicKey).setAutoRenewAccountId(expandedAccountId.getAccountId()).setAutoRenewPeriod(Duration.ofSeconds(8_000_001L)).setTokenName(newSymbol + "_name").setSupplyKey(publicKey).setTokenMemo(memo).setTokenSymbol(newSymbol).setTokenId(tokenId).setTransactionMemo(memo).setTreasuryAccountId(client.getOperatorAccountId()).setWipeKey(publicKey).setMaxTransactionFee(sdkClient.getMaxTransactionFee());
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenUpdateTransaction);
    log.debug("Updated token {}.", tokenId);
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction)

Example 37 with NetworkTransactionResponse

use of com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse in project hedera-mirror-node by hashgraph.

the class TokenClient method mint.

public NetworkTransactionResponse mint(TokenId tokenId, long amount, byte[] metadata) {
    log.debug("Mint {} tokens from {}", amount, tokenId);
    TokenMintTransaction tokenMintTransaction = new TokenMintTransaction().setTokenId(tokenId).setMaxTransactionFee(sdkClient.getMaxTransactionFee()).setTransactionMemo(getMemo("Mint token"));
    if (metadata != null) {
        tokenMintTransaction.addMetadata(metadata);
    } else {
        tokenMintTransaction.setAmount(amount);
    }
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenMintTransaction);
    log.debug("Minted {} extra tokens for token {}", amount, tokenId);
    return networkTransactionResponse;
}
Also used : TokenMintTransaction(com.hedera.hashgraph.sdk.TokenMintTransaction) NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)

Example 38 with NetworkTransactionResponse

use of com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse in project hedera-mirror-node by hashgraph.

the class TokenClient method revokeKyc.

public NetworkTransactionResponse revokeKyc(TokenId tokenId, AccountId accountId) {
    log.debug("Grant account {} with KYC for token {}", accountId, tokenId);
    TokenRevokeKycTransaction tokenRevokeKycTransaction = new TokenRevokeKycTransaction().setAccountId(accountId).setTokenId(tokenId).setMaxTransactionFee(sdkClient.getMaxTransactionFee()).setTransactionMemo(getMemo("Revoke kyc for token"));
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenRevokeKycTransaction);
    log.debug("Revoked Kyc for account {} with token {}", accountId, tokenId);
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TokenRevokeKycTransaction(com.hedera.hashgraph.sdk.TokenRevokeKycTransaction)

Example 39 with NetworkTransactionResponse

use of com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse in project hedera-mirror-node by hashgraph.

the class AccountClient method approveCryptoAllowance.

public NetworkTransactionResponse approveCryptoAllowance(AccountId spender, Hbar hbarAmount) {
    var ownerAccountId = sdkClient.getExpandedOperatorAccountId().getAccountId();
    log.debug("Approve spender {} an allowance of {} tℏ on {}'s account", spender, hbarAmount.toTinybars(), ownerAccountId);
    var transaction = new AccountAllowanceApproveTransaction().approveHbarAllowance(null, spender, hbarAmount);
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(transaction);
    log.debug("Sent Account Allowance Approval");
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) AccountAllowanceApproveTransaction(com.hedera.hashgraph.sdk.AccountAllowanceApproveTransaction)

Example 40 with NetworkTransactionResponse

use of com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse in project hedera-mirror-node by hashgraph.

the class AccountClient method sendCryptoTransfer.

private NetworkTransactionResponse sendCryptoTransfer(ExpandedAccountId sender, AccountId recipient, Hbar hbarAmount, boolean isApproval) {
    log.debug("Send CryptoTransfer of {} tℏ from {} to {}. isApproval: {}", hbarAmount.toTinybars(), sender.getAccountId(), recipient, isApproval);
    TransferTransaction cryptoTransferTransaction = getCryptoTransferTransaction(sender.getAccountId(), recipient, hbarAmount, isApproval);
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(cryptoTransferTransaction, isApproval ? KeyList.of(sender.getPrivateKey()) : null);
    log.debug("Sent CryptoTransfer");
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction)

Aggregations

NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)41 PublicKey (com.hedera.hashgraph.sdk.PublicKey)3 TopicId (com.hedera.hashgraph.sdk.TopicId)3 AccountId (com.hedera.hashgraph.sdk.AccountId)2 KeyList (com.hedera.hashgraph.sdk.KeyList)2 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)2 TokenBurnTransaction (com.hedera.hashgraph.sdk.TokenBurnTransaction)2 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)2 TokenId (com.hedera.hashgraph.sdk.TokenId)2 TokenUpdateTransaction (com.hedera.hashgraph.sdk.TokenUpdateTransaction)2 TokenWipeTransaction (com.hedera.hashgraph.sdk.TokenWipeTransaction)2 TopicMessageQuery (com.hedera.hashgraph.sdk.TopicMessageQuery)2 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)2 TransactionRecord (com.hedera.hashgraph.sdk.TransactionRecord)2 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)2 ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)2 Given (io.cucumber.java.en.Given)2 AccountAllowanceApproveTransaction (com.hedera.hashgraph.sdk.AccountAllowanceApproveTransaction)1 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)1 ContractCreateTransaction (com.hedera.hashgraph.sdk.ContractCreateTransaction)1