Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ import "services/response_header.proto";
/**
* Query to read the HBAR balance of an account or contract.
*
* Deprecated. Obtain account balances from a mirror node instead.
*
* This query SHALL return _only_ the HBAR balance for an account
* or smart contract. Early releases of the network would return all
* fungible/common token balances, but HIP-367 made it infeasible to
* return all such balances. This query SHALL NOT return any information
* beyond the current HBAR balance.
*/
message CryptoGetAccountBalanceQuery {
option deprecated = true;

/**
* Standard information sent with every query operation.<br/>
* This includes the signed payment and what kind of response is requested
Expand Down Expand Up @@ -64,11 +68,15 @@ message CryptoGetAccountBalanceQuery {
/**
* Response to a CryptoGetAccountBalanceQuery.<br/>
*
* Deprecated. Obtain account balances from a mirror node instead.
*
* This response SHALL contain only the information needed to
* identify the query request and the actual HBAR balance of the
* identified account or contract.
*/
message CryptoGetAccountBalanceResponse {
option deprecated = true;

/**
* The standard response information for queries.<br/>
* This includes the values requested in the `QueryHeader`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ service CryptoService {
rpc getAccountRecords (Query) returns (Response);

/**
* Retrieve the balance of an account
* Retrieve the balance of an account.
* <p>
* This query is deprecated. Obtain account balances from a mirror node instead.
*/
rpc cryptoGetBalance (Query) returns (Response);
rpc cryptoGetBalance (Query) returns (Response) {option deprecated = true;};

/**
* Retrieve the metadata of an account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ message Query {

/**
* Get the current HBAR balance of an Hedera account or smart contract.
* <p>
* > This query is deprecated. Obtain account balances from a mirror node instead.
*/
CryptoGetAccountBalanceQuery cryptogetAccountBalance = 7;
CryptoGetAccountBalanceQuery cryptogetAccountBalance = 7 [deprecated = true];

/**
* Get records of all "recent" transactions for which a specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoCreate;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDelete;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDeleteAllowance;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetAccountBalance;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetAccountRecords;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetInfo;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoTransfer;
Expand Down Expand Up @@ -107,7 +106,6 @@ public final class ExpectedCustomThrottles {
ContractGetInfo,
ContractGetBytecode,
ContractGetRecords,
CryptoGetAccountBalance,
CryptoGetAccountRecords,
CryptoGetInfo,
FileGetContents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoCreate;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDelete;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoDeleteAllowance;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetAccountBalance;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetAccountRecords;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoGetInfo;
import static com.hederahashgraph.api.proto.java.HederaFunctionality.CryptoTransfer;
Expand Down Expand Up @@ -67,7 +66,7 @@ class ExpectedCustomThrottlesTest {
// Suppress the warning that we use too many assets
@SuppressWarnings("java:S5961")
void releaseTwentyHasExpected() {
assertEquals(56, ACTIVE_OPS.size());
assertEquals(55, ACTIVE_OPS.size());

assertTrue(ACTIVE_OPS.contains(CryptoCreate), "Missing CryptoCreate!");
assertTrue(ACTIVE_OPS.contains(CryptoTransfer), "Missing CryptoTransfer!");
Expand Down Expand Up @@ -113,7 +112,6 @@ void releaseTwentyHasExpected() {
assertTrue(ACTIVE_OPS.contains(ContractGetInfo), "Missing ContractGetInfo!");
assertTrue(ACTIVE_OPS.contains(ContractGetBytecode), "Missing ContractGetBytecode!");
assertTrue(ACTIVE_OPS.contains(ContractGetRecords), "Missing ContractGetRecords!");
assertTrue(ACTIVE_OPS.contains(CryptoGetAccountBalance), "Missing CryptoGetAccountBalance!");
assertTrue(ACTIVE_OPS.contains(CryptoGetAccountRecords), "Missing CryptoGetAccountRecords!");
assertTrue(ACTIVE_OPS.contains(CryptoGetInfo), "Missing CryptoGetInfo!");
assertTrue(ACTIVE_OPS.contains(FileGetContents), "Missing FileGetContents!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
{
"opsPerSec": 1000000,
"operations": [
"CryptoGetAccountBalance",
"TransactionGetReceipt"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,6 @@
}
]
},
{
"burstPeriod": 0,
"burstPeriodMs": 1000,
"name": "BalanceQueryLimits",
"throttleGroups": [
{
"opsPerSec": 0,
"milliOpsPerSec": 1000000,
"operations": [
"CryptoGetAccountBalance"
]
}
]
},
{
"burstPeriod": 0,
"burstPeriodMs": 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private Optional<AccountDetails> infoForAccount(
} else {
final var info = AccountDetails.newBuilder();
info.accountId(account.accountId());
info.contractAccountId(NetworkAdminServiceUtil.asHexedEvmAddress(accountID));
info.contractAccountId(NetworkAdminServiceUtil.asHexedEvmAddress(account.accountId()));
info.deleted(account.deleted());
info.key(account.key());
info.balance(account.tinybarBalance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.hedera.hapi.node.base.AccountID;
Expand Down Expand Up @@ -219,6 +220,31 @@ void getsResponseIfOkResponse() {
assertEquals(expectedInfo, accountDetailsResponse.accountDetails());
}

@Test
void getsResponseIfQueriedByAlias() {
final var responseHeader = ResponseHeader.newBuilder()
.nodeTransactionPrecheckCode(ResponseCodeEnum.OK)
.build();
final var expectedInfo = getExpectedInfo(
false,
Collections.emptyList(),
Collections.emptyList(),
Collections.emptyList(),
Collections.emptyList());
final var accountStore = mock(ReadableAccountStore.class);

when(context.query()).thenReturn(createGetAccountDetailsQuery(alias));
when(context.createStore(ReadableAccountStore.class)).thenReturn(accountStore);
when(context.createStore(ReadableTokenStore.class)).thenReturn(readableTokenStore);
when(context.createStore(ReadableTokenRelationStore.class)).thenReturn(readableTokenRelStore);
when(accountStore.getAliasedAccountById(alias)).thenReturn(account);

final var response = networkGetAccountDetailsHandler.findResponse(context, responseHeader);
final var accountDetailsResponse = response.accountDetailsOrThrow();
assertEquals(ResponseCodeEnum.OK, accountDetailsResponse.header().nodeTransactionPrecheckCode());
assertEquals(expectedInfo, accountDetailsResponse.accountDetails());
}

@Test
void getsResponseWithTokenRelations() {
givenValidAccount(false, Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
/**
* This class contains all workflow-related functionality regarding {@link
* HederaFunctionality#CRYPTO_GET_ACCOUNT_BALANCE}.
*
* @deprecated Obtain account balances from a mirror node instead.
*/
@Deprecated(forRemoval = true)
@Singleton
public class CryptoGetAccountBalanceHandler extends FreeQueryHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,33 @@ public static HapiContractCallLocal contractCallLocal(
}

public static HapiGetAccountBalance getAccountBalance(final String account) {
return new HapiGetAccountBalance(account);
return new HapiGetAccountBalance(account).nodePayment(1234L).noLogging();
}

public static HapiGetAccountBalance getAccountBalance(final String account, final boolean isContract) {
return new HapiGetAccountBalance(account, isContract);
return new HapiGetAccountBalance(account, isContract).nodePayment(1234L).noLogging();
}

public static HapiGetAccountBalance getAutoCreatedAccountBalance(final String sourceKey) {
return new HapiGetAccountBalance(sourceKey, ReferenceType.ALIAS_KEY_NAME);
return new HapiGetAccountBalance(sourceKey, ReferenceType.ALIAS_KEY_NAME)
.nodePayment(1234L)
.noLogging();
}

public static HapiGetAccountBalance getAliasedContractBalance(final String hexedAlias) {
return new HapiGetAccountBalance(hexedAlias, ReferenceType.HEXED_CONTRACT_ALIAS);
return new HapiGetAccountBalance(hexedAlias, ReferenceType.HEXED_CONTRACT_ALIAS)
.nodePayment(1234L)
.noLogging();
}

public static HapiGetAccountBalance getAliasedAccountBalance(final ByteString alias) {
return new HapiGetAccountBalance(alias, ReferenceType.LITERAL_ACCOUNT_ALIAS);
return new HapiGetAccountBalance(alias, ReferenceType.LITERAL_ACCOUNT_ALIAS)
.nodePayment(1234L)
.noLogging();
}

public static HapiGetAccountBalance getAccountBalance(final Supplier<String> supplier) {
return new HapiGetAccountBalance(supplier);
return new HapiGetAccountBalance(supplier).nodePayment(1234L).noLogging();
}

public static HapiGetTopicInfo getTopicInfo(final String topic) {
Expand Down
Loading
Loading