diff --git a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/getevmaddressalias/EvmAddressAliasCall.java b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/getevmaddressalias/EvmAddressAliasCall.java index 832ae55ec52c..db90a471ee99 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/getevmaddressalias/EvmAddressAliasCall.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/getevmaddressalias/EvmAddressAliasCall.java @@ -37,6 +37,7 @@ /** * Implements the {@code evmAddressAlias()} call of the Has system contract. + * This call will return the EVM address alias of the given long zero Hedera account number if it exists. */ public class EvmAddressAliasCall extends AbstractCall { private final Address address; @@ -61,7 +62,7 @@ public EvmAddressAliasCall(@NonNull final HasCallAttempt attempt, final Address final var accountNum = numberOfLongZero(explicitAddress); final var account = enhancement.nativeOperations().getAccount(accountNum); // If the account is null or does not have an account id then return bail - if (account == null || !account.hasAccountId()) { + if (account == null) { return gasOnly(fullResultsFor(INVALID_ACCOUNT_ID, ZERO_ADDRESS), INVALID_ACCOUNT_ID, true); } diff --git a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/hederaaccountnumalias/HederaAccountNumAliasCall.java b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/hederaaccountnumalias/HederaAccountNumAliasCall.java index bc58b093f67a..f60c31f3d02f 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/hederaaccountnumalias/HederaAccountNumAliasCall.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/hederaaccountnumalias/HederaAccountNumAliasCall.java @@ -35,6 +35,10 @@ import com.hedera.node.app.service.contract.impl.exec.systemcontracts.has.HasCallAttempt; import edu.umd.cs.findbugs.annotations.NonNull; +/** + * Implements the {@code hederaAccountNumAlias(address)} call of the HAS system contract. + * This call will return the long zero Hedera account number of the given alias if it exists. + */ public class HederaAccountNumAliasCall extends AbstractCall { private final Address address; @@ -55,9 +59,11 @@ public HederaAccountNumAliasCall(@NonNull final HasCallAttempt attempt, @NonNull return gasOnly(fullResultsFor(INVALID_SOLIDITY_ADDRESS, ZERO_ADDRESS), INVALID_SOLIDITY_ADDRESS, true); } final var account = enhancement.nativeOperations().getAccount(accountNum); - if (account == null - || !account.hasAccountId() - || !account.accountIdOrElse(AccountID.DEFAULT).hasAccountNum()) { + if (account == null) { + return gasOnly(fullResultsFor(INVALID_SOLIDITY_ADDRESS, ZERO_ADDRESS), INVALID_SOLIDITY_ADDRESS, true); + } + requireNonNull(account.accountId()); + if (!account.accountIdOrElse(AccountID.DEFAULT).hasAccountNum()) { return gasOnly(fullResultsFor(INVALID_SOLIDITY_ADDRESS, ZERO_ADDRESS), INVALID_SOLIDITY_ADDRESS, true); } final var accountAsAddress = asHeadlongAddress( diff --git a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/isvalidalias/IsValidAliasCall.java b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/isvalidalias/IsValidAliasCall.java index cd540a3348c0..8e68335634cc 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/isvalidalias/IsValidAliasCall.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/has/isvalidalias/IsValidAliasCall.java @@ -30,6 +30,10 @@ import com.hedera.node.app.service.contract.impl.exec.systemcontracts.has.HasCallAttempt; import edu.umd.cs.findbugs.annotations.NonNull; +/** + * Implements the {@code isValidAlias(address)} call of the HAS system contract. + * This call will return true if the address exists and false otherwise. + */ public class IsValidAliasCall extends AbstractCall { private final Address address; diff --git a/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/has/evmaddressalias/EvmAddressAliasCallTest.java b/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/has/evmaddressalias/EvmAddressAliasCallTest.java index 7419dafac178..8e0cb5d7d3f7 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/has/evmaddressalias/EvmAddressAliasCallTest.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/has/evmaddressalias/EvmAddressAliasCallTest.java @@ -110,7 +110,6 @@ void successfulCall() { given(attempt.enhancement()).willReturn(mockEnhancement()); given(nativeOperations.getAccount(numberOfLongZero(NON_SYSTEM_BUT_IS_LONG_ZERO_ADDRESS))) .willReturn(account); - given(account.hasAccountId()).willReturn(true); given(account.alias()).willReturn(RECEIVER_ADDRESS); subject = new EvmAddressAliasCall(attempt, asHeadlongAddress(NON_SYSTEM_BUT_IS_LONG_ZERO_ADDRESS.toArray()));