use of io.nuls.account.entity.Alias in project nuls by nuls-io.
the class AliasValidator method validate.
@Override
public ValidateResult validate(AliasTransaction tx) {
Alias alias = tx.getTxData();
if (StringUtils.isBlank(alias.getAddress()) || new Address(alias.getAddress()).getHash().length != 23) {
return ValidateResult.getFailedResult("The address format error");
}
if (!StringUtils.validAlias(alias.getAlias())) {
return ValidateResult.getFailedResult("The alias is between 3 to 20 characters");
}
AliasPo aliasPo = getAliasDataService().get(alias.getAlias());
if (aliasPo != null) {
return ValidateResult.getFailedResult("The alias has been occupied");
}
return ValidateResult.getSuccessResult();
}
use of io.nuls.account.entity.Alias in project nuls by nuls-io.
the class AccountResource method get.
@GET
@Path("/{address}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult get(@PathParam("address") String address) {
RpcResult result;
if (!Address.validAddress(address)) {
result = RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
return result;
}
Account account = accountService.getAccount(address);
if (account == null) {
Alias alias = accountService.getAlias(address);
if (alias == null) {
result = RpcResult.getFailed(ErrorCode.DATA_NOT_FOUND);
} else {
AccountDto dto = new AccountDto();
dto.setAddress(address);
dto.setAlias(alias.getAlias());
result = RpcResult.getSuccess().setData(dto);
}
} else {
result = RpcResult.getSuccess().setData(new AccountDto(account));
}
return result;
}
Aggregations