Search in sources :

Example 1 with ExpandedAccountId

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

the class ScheduleFeature method createNewCryptoAccountSchedule.

@Given("I schedule a crypto transfer with {int} initial signatures but require an additional signature from " + "{string}")
public void createNewCryptoAccountSchedule(int initSignatureCount, String accountName) {
    // new account, accountName and initSignatureCount
    expectedSignersCount = 2 + initSignatureCount;
    currentSignersCount = initSignatureCount + signatoryCountOffset;
    ExpandedAccountId finalSignatory = accountClient.getAccount(AccountClient.AccountNameEnum.valueOf(accountName));
    KeyList privateKeyList = new KeyList();
    KeyList publicKeyList = new KeyList();
    for (int i = 0; i < initSignatureCount; i++) {
        PrivateKey accountKey = PrivateKey.generate();
        privateKeyList.add(accountKey);
        publicKeyList.add(accountKey.getPublicKey());
    }
    // additional signatory not provided up front to prevent schedule from executing
    publicKeyList.add(finalSignatory.getPublicKey());
    ExpandedAccountId newAccountId = accountClient.createCryptoAccount(Hbar.fromTinybars(DEFAULT_TINY_HBAR), false, publicKeyList, "scheduled transfer");
    scheduledTransaction = accountClient.getCryptoTransferTransaction(newAccountId.getAccountId(), accountClient.getSdkClient().getExpandedOperatorAccountId().getAccountId(), Hbar.fromTinybars(DEFAULT_TINY_HBAR));
    // add sender private key to ensure only Alice's signature is the only signature left that is required
    privateKeyList.add(newAccountId.getPrivateKey());
    createNewSchedule(scheduledTransaction, privateKeyList);
    currentSignersCount++;
}
Also used : PrivateKey(com.hedera.hashgraph.sdk.PrivateKey) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) KeyList(com.hedera.hashgraph.sdk.KeyList) Given(io.cucumber.java.en.Given)

Example 2 with ExpandedAccountId

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

the class ScheduleFeature method createNewHCSSchedule.

@Given("I successfully schedule a topic message submit with {string}'s submit key")
public void createNewHCSSchedule(String accountName) {
    expectedSignersCount = 1;
    currentSignersCount = 0 + signatoryCountOffset;
    ExpandedAccountId submitAdmin = accountClient.getAccount(AccountClient.AccountNameEnum.valueOf(accountName));
    // create topic w submit key
    log.debug("Create new topic with {}'s submit key", accountName);
    networkTransactionResponse = topicClient.createTopic(scheduleClient.getSdkClient().getExpandedOperatorAccountId(), submitAdmin.getPublicKey());
    assertNotNull(networkTransactionResponse.getTransactionId());
    assertNotNull(networkTransactionResponse.getReceipt());
    TopicId topicId = networkTransactionResponse.getReceipt().topicId;
    assertNotNull(topicId);
    scheduledTransaction = topicClient.getTopicMessageSubmitTransaction(topicId, "scheduled hcs message".getBytes(StandardCharsets.UTF_8));
    createNewSchedule(scheduledTransaction, null);
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) TopicId(com.hedera.hashgraph.sdk.TopicId) Given(io.cucumber.java.en.Given)

Example 3 with ExpandedAccountId

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

the class TokenClient method updateTokenTreasury.

public NetworkTransactionResponse updateTokenTreasury(TokenId tokenId, ExpandedAccountId newTreasuryId) {
    AccountId treasuryAccountId = newTreasuryId.getAccountId();
    String memo = getMemo("Update token");
    TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction().setTokenId(tokenId).setTokenMemo(memo).setTreasuryAccountId(treasuryAccountId).setTransactionMemo(memo);
    KeyList keyList = KeyList.of(newTreasuryId.getPrivateKey());
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenUpdateTransaction, keyList);
    log.debug("Updated token {} treasury account {}.", tokenId, treasuryAccountId);
    return networkTransactionResponse;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) KeyList(com.hedera.hashgraph.sdk.KeyList) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction)

Example 4 with ExpandedAccountId

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

the class AccountFeature method sendTinyHbars.

@When("I send {long} tℏ to account {int}")
public void sendTinyHbars(long amount, int accountNum) {
    senderAccountId = new ExpandedAccountId(new AccountId(accountNum));
    startingBalance = accountClient.getBalance(senderAccountId);
    networkTransactionResponse = accountClient.sendCryptoTransfer(senderAccountId.getAccountId(), Hbar.fromTinybars(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 5 with ExpandedAccountId

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

the class TokenFeature method transferTokensToRecipient.

@Then("^I transfer (.*) tokens (?:(.*) )?to recipient(?: (.*))?$")
public void transferTokensToRecipient(int amount, Integer tokenIndex, Integer recipientIndex) {
    ExpandedAccountId payer = tokenClient.getSdkClient().getExpandedOperatorAccountId();
    transferTokens(tokenIds.get(getIndexOrDefault(tokenIndex)), amount, payer, recipients.get(getIndexOrDefault(recipientIndex)).getAccountId());
}
Also used : ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) Then(io.cucumber.java.en.Then)

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