use of com.hedera.hashgraph.sdk.TokenWipeTransaction in project hedera-mirror-node by hashgraph.
the class TokenClient method wipeNonFungible.
public NetworkTransactionResponse wipeNonFungible(TokenId tokenId, long serialNumber, ExpandedAccountId expandedAccountId) {
log.debug("Wipe serial number {} from token {}, account id {}", serialNumber, tokenId, expandedAccountId.getAccountId());
TokenWipeTransaction transaction = getTokenWipeTransaction(tokenId, expandedAccountId).addSerial(serialNumber);
NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(transaction);
log.debug("Wiped serial number {} from token {}, account id {}", serialNumber, tokenId, expandedAccountId.getAccountId());
return networkTransactionResponse;
}
use of com.hedera.hashgraph.sdk.TokenWipeTransaction in project hedera-mirror-node by hashgraph.
the class TokenWipeTransactionSupplierTest method createWithMinimumData.
@Test
void createWithMinimumData() {
TokenWipeTransactionSupplier tokenWipeTransactionSupplier = new TokenWipeTransactionSupplier();
tokenWipeTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
tokenWipeTransactionSupplier.setTokenId(TOKEN_ID.toString());
TokenWipeTransaction actual = tokenWipeTransactionSupplier.get();
assertThat(actual).returns(ACCOUNT_ID, TokenWipeTransaction::getAccountId).returns(1L, TokenWipeTransaction::getAmount).returns(MAX_TRANSACTION_FEE_HBAR, TokenWipeTransaction::getMaxTransactionFee).returns(Collections.emptyList(), TokenWipeTransaction::getSerials).returns(TOKEN_ID, TokenWipeTransaction::getTokenId);
}
use of com.hedera.hashgraph.sdk.TokenWipeTransaction in project hedera-mirror-node by hashgraph.
the class TokenWipeTransactionSupplierTest method createWithCustomFungibleData.
@Test
void createWithCustomFungibleData() {
TokenWipeTransactionSupplier tokenWipeTransactionSupplier = new TokenWipeTransactionSupplier();
tokenWipeTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
tokenWipeTransactionSupplier.setAmount(2);
tokenWipeTransactionSupplier.setMaxTransactionFee(1);
tokenWipeTransactionSupplier.setTokenId(TOKEN_ID.toString());
tokenWipeTransactionSupplier.setType(TokenType.FUNGIBLE_COMMON);
TokenWipeTransaction actual = tokenWipeTransactionSupplier.get();
assertThat(actual).returns(ACCOUNT_ID, TokenWipeTransaction::getAccountId).returns(2L, TokenWipeTransaction::getAmount).returns(ONE_TINYBAR, TokenWipeTransaction::getMaxTransactionFee).returns(Collections.emptyList(), TokenWipeTransaction::getSerials).returns(TOKEN_ID, TokenWipeTransaction::getTokenId);
}
use of com.hedera.hashgraph.sdk.TokenWipeTransaction in project hedera-mirror-node by hashgraph.
the class TokenWipeTransactionSupplierTest method createWithCustomNonFungibleData.
@Test
void createWithCustomNonFungibleData() {
TokenWipeTransactionSupplier tokenWipeTransactionSupplier = new TokenWipeTransactionSupplier();
tokenWipeTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
tokenWipeTransactionSupplier.setAmount(2);
tokenWipeTransactionSupplier.setMaxTransactionFee(1);
tokenWipeTransactionSupplier.setSerialNumber(new AtomicLong(10));
tokenWipeTransactionSupplier.setTokenId(TOKEN_ID.toString());
tokenWipeTransactionSupplier.setType(TokenType.NON_FUNGIBLE_UNIQUE);
TokenWipeTransaction actual = tokenWipeTransactionSupplier.get();
assertThat(actual).returns(ACCOUNT_ID, TokenWipeTransaction::getAccountId).returns(0L, TokenWipeTransaction::getAmount).returns(ONE_TINYBAR, TokenWipeTransaction::getMaxTransactionFee).returns(List.of(10L, 11L), TokenWipeTransaction::getSerials).returns(TOKEN_ID, TokenWipeTransaction::getTokenId);
}
use of com.hedera.hashgraph.sdk.TokenWipeTransaction in project hedera-sdk-java by hashgraph.
the class TokenWipeIntegrationTest method cannotWipeAccountsBalanceWhenAmountIsNotSet.
@Test
@DisplayName("Cannot wipe accounts balance when amount is not set")
void cannotWipeAccountsBalanceWhenAmountIsNotSet() throws Exception {
var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
var key = PrivateKey.generateED25519();
var response = new AccountCreateTransaction().setKey(key).setInitialBalance(new Hbar(1)).execute(testEnv.client);
var accountId = Objects.requireNonNull(response.getReceipt(testEnv.client).accountId);
var tokenId = Objects.requireNonNull(new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setDecimals(3).setInitialSupply(1000000).setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).setFreezeKey(testEnv.operatorKey).setWipeKey(testEnv.operatorKey).setKycKey(testEnv.operatorKey).setSupplyKey(testEnv.operatorKey).setFreezeDefault(false).execute(testEnv.client).getReceipt(testEnv.client).tokenId);
new TokenAssociateTransaction().setAccountId(accountId).setTokenIds(Collections.singletonList(tokenId)).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
new TokenGrantKycTransaction().setAccountId(accountId).setTokenId(tokenId).execute(testEnv.client).getReceipt(testEnv.client);
new TransferTransaction().addTokenTransfer(tokenId, testEnv.operatorId, -10).addTokenTransfer(tokenId, accountId, 10).execute(testEnv.client).getReceipt(testEnv.client);
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new TokenWipeTransaction().setTokenId(tokenId).setAccountId(accountId).execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.INVALID_WIPING_AMOUNT.toString());
testEnv.close(tokenId, accountId, key);
}
Aggregations