Search in sources :

Example 11 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId 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 ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class AccountFeature method sendHbars.

@When("I send {int} ℏ to account {int}")
public void sendHbars(int amount, int accountNum) {
    senderAccountId = new ExpandedAccountId(new AccountId(accountNum));
    startingBalance = accountClient.getBalance(senderAccountId);
    networkTransactionResponse = accountClient.sendCryptoTransfer(senderAccountId.getAccountId(), Hbar.from(amount));
    assertNotNull(networkTransactionResponse.getTransactionId());
    assertNotNull(networkTransactionResponse.getReceipt());
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) When(io.cucumber.java.en.When)

Example 13 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class ScheduleFeature method createNewHBarTransferSchedule.

@Given("I successfully schedule a treasury HBAR disbursement to {string}")
public void createNewHBarTransferSchedule(String accountName) {
    expectedSignersCount = 2;
    currentSignersCount = 0 + signatoryCountOffset;
    ExpandedAccountId recipient = accountClient.getAccount(// receiverSigRequired
    AccountClient.AccountNameEnum.valueOf(accountName));
    scheduledTransaction = accountClient.getCryptoTransferTransaction(accountClient.getTokenTreasuryAccount().getAccountId(), recipient.getAccountId(), Hbar.fromTinybars(DEFAULT_TINY_HBAR), false);
    createNewSchedule(scheduledTransaction, null);
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) Given(io.cucumber.java.en.Given)

Example 14 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class TokenFeature method createNewToken.

private TokenId createNewToken(String symbol, int freezeStatus, int kycStatus, TokenType tokenType, TokenSupplyType tokenSupplyType, List<CustomFee> customFees) {
    ExpandedAccountId admin = tokenClient.getSdkClient().getExpandedOperatorAccountId();
    networkTransactionResponse = tokenClient.createToken(admin, symbol, freezeStatus, kycStatus, admin, INITIAL_SUPPLY, tokenSupplyType, MAX_SUPPLY, tokenType, customFees);
    assertNotNull(networkTransactionResponse.getTransactionId());
    assertNotNull(networkTransactionResponse.getReceipt());
    TokenId tokenId = networkTransactionResponse.getReceipt().tokenId;
    assertNotNull(tokenId);
    tokenIds.add(tokenId);
    tokenCustomFees.put(tokenId, customFees);
    return tokenId;
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) TokenId(com.hedera.hashgraph.sdk.TokenId)

Example 15 with ExpandedAccountId

use of com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId in project hedera-mirror-node by hashgraph.

the class TokenFeature method associateSenderWithToken.

@Given("^I associate a(?:n)? (?:existing|new) sender account(?: (.*))? with token(?: (.*))?$")
public void associateSenderWithToken(Integer senderIndex, Integer tokenIndex) {
    ExpandedAccountId sender;
    if (senderIndex == null) {
        sender = accountClient.createNewAccount(10_000_000);
        senders.add(sender);
    } else {
        sender = senders.get(senderIndex);
    }
    associateWithToken(sender, tokenIds.get(getIndexOrDefault(tokenIndex)));
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) Given(io.cucumber.java.en.Given)

Aggregations

ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)20 Given (io.cucumber.java.en.Given)9 AccountId (com.hedera.hashgraph.sdk.AccountId)4 TokenId (com.hedera.hashgraph.sdk.TokenId)4 KeyList (com.hedera.hashgraph.sdk.KeyList)3 Then (io.cucumber.java.en.Then)3 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)2 ReceiptStatusException (com.hedera.hashgraph.sdk.ReceiptStatusException)2 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)2 When (io.cucumber.java.en.When)2 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)1 Hbar (com.hedera.hashgraph.sdk.Hbar)1 PublicKey (com.hedera.hashgraph.sdk.PublicKey)1 TokenUpdateTransaction (com.hedera.hashgraph.sdk.TokenUpdateTransaction)1 TopicId (com.hedera.hashgraph.sdk.TopicId)1 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)1 After (io.cucumber.java.After)1