Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed several code issues found by sonar #2113

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions core/src/main/java/org/web3j/crypto/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class Wallet {
static final String AES_128_CTR = "pbkdf2";
static final String SCRYPT = "scrypt";

private Wallet() {}

public static WalletFile create(String password, ECKeyPair ecKeyPair, int n, int p)
throws CipherException {

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/web3j/ens/Contracts.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/** ENS registry contract addresses. */
public class Contracts {

public static final String MAINNET = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
public static final String ROPSTEN = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
public static final String RINKEBY = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
Expand All @@ -26,6 +25,8 @@ public class Contracts {
public static final String LINEA = "0x50130b669B28C339991d8676FA73CF122a121267";
public static final String LINEA_SEPOLIA = "0x5B2636F0f2137B4aE722C01dd5122D7d3e9541f7";

private Contracts() {}

public static String resolveRegistryContract(String chainId) {
final Long chainIdLong = Long.parseLong(chainId);
if (chainIdLong.equals(ChainIdLong.MAINNET)) {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/web3j/ens/NameHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static byte[] nameHashAsBytes(String ensName) {
return Numeric.hexStringToByteArray(nameHash(ensName));
}

private NameHash() {}

public static String nameHash(String ensName) {
String normalisedEnsName = normalise(ensName);
return Numeric.toHexString(nameHash(normalisedEnsName.split("\\.")));
Expand Down
11 changes: 3 additions & 8 deletions core/src/main/java/org/web3j/ens/contracts/generated/ENS.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,18 @@ public class ENS extends Contract {

public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll",
Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Bool>() {}));
;

public static final Event NEWOWNER_EVENT = new Event("NewOwner",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
;

public static final Event NEWRESOLVER_EVENT = new Event("NewResolver",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
;

public static final Event NEWTTL_EVENT = new Event("NewTTL",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Uint64>() {}));
;

public static final Event TRANSFER_EVENT = new Event("Transfer",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
;

@Deprecated
protected ENS(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand Down Expand Up @@ -139,7 +134,7 @@ public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(Default

public List<NewOwnerEventResponse> getNewOwnerEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWOWNER_EVENT, transactionReceipt);
ArrayList<NewOwnerEventResponse> responses = new ArrayList<NewOwnerEventResponse>(valueList.size());
ArrayList<NewOwnerEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewOwnerEventResponse typedResponse = new NewOwnerEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down Expand Up @@ -174,7 +169,7 @@ public Flowable<NewOwnerEventResponse> newOwnerEventFlowable(DefaultBlockParamet

public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt);
ArrayList<NewResolverEventResponse> responses = new ArrayList<NewResolverEventResponse>(valueList.size());
ArrayList<NewResolverEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewResolverEventResponse typedResponse = new NewResolverEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down Expand Up @@ -207,7 +202,7 @@ public Flowable<NewResolverEventResponse> newResolverEventFlowable(DefaultBlockP

public List<NewTTLEventResponse> getNewTTLEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWTTL_EVENT, transactionReceipt);
ArrayList<NewTTLEventResponse> responses = new ArrayList<NewTTLEventResponse>(valueList.size());
ArrayList<NewTTLEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewTTLEventResponse typedResponse = new NewTTLEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,18 @@ public class ENSRegistryWithFallbackContract extends Contract {

public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll",
Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Bool>() {}));
;

public static final Event NEWOWNER_EVENT = new Event("NewOwner",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
;

public static final Event NEWRESOLVER_EVENT = new Event("NewResolver",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
;

public static final Event NEWTTL_EVENT = new Event("NewTTL",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Uint64>() {}));
;

public static final Event TRANSFER_EVENT = new Event("Transfer",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
;

@Deprecated
protected ENSRegistryWithFallbackContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand All @@ -106,7 +101,7 @@ protected ENSRegistryWithFallbackContract(String contractAddress, Web3j web3j, T

public List<ApprovalForAllEventResponse> getApprovalForAllEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(APPROVALFORALL_EVENT, transactionReceipt);
ArrayList<ApprovalForAllEventResponse> responses = new ArrayList<ApprovalForAllEventResponse>(valueList.size());
ArrayList<ApprovalForAllEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down Expand Up @@ -141,7 +136,7 @@ public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(Default

public List<NewOwnerEventResponse> getNewOwnerEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWOWNER_EVENT, transactionReceipt);
ArrayList<NewOwnerEventResponse> responses = new ArrayList<NewOwnerEventResponse>(valueList.size());
ArrayList<NewOwnerEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewOwnerEventResponse typedResponse = new NewOwnerEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down Expand Up @@ -176,7 +171,7 @@ public Flowable<NewOwnerEventResponse> newOwnerEventFlowable(DefaultBlockParamet

public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt);
ArrayList<NewResolverEventResponse> responses = new ArrayList<NewResolverEventResponse>(valueList.size());
ArrayList<NewResolverEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewResolverEventResponse typedResponse = new NewResolverEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down Expand Up @@ -209,7 +204,7 @@ public Flowable<NewResolverEventResponse> newResolverEventFlowable(DefaultBlockP

public List<NewTTLEventResponse> getNewTTLEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWTTL_EVENT, transactionReceipt);
ArrayList<NewTTLEventResponse> responses = new ArrayList<NewTTLEventResponse>(valueList.size());
ArrayList<NewTTLEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewTTLEventResponse typedResponse = new NewTTLEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down Expand Up @@ -242,7 +237,7 @@ public Flowable<NewTTLEventResponse> newTTLEventFlowable(DefaultBlockParameter s

public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
ArrayList<TransferEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
TransferEventResponse typedResponse = new TransferEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class OffchainResolverContract extends PublicResolver {

public static final Event NEWSIGNERS_EVENT = new Event("NewSigners",
Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {}));
;

public OffchainResolverContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
super(contractAddress, web3j, credentials, gasPrice, gasLimit);
Expand All @@ -80,7 +79,7 @@ public OffchainResolverContract(String contractAddress, Web3j web3j, Transaction

public List<NewSignersEventResponse> getNewSignersEvents(TransactionReceipt transactionReceipt) {
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWSIGNERS_EVENT, transactionReceipt);
ArrayList<NewSignersEventResponse> responses = new ArrayList<NewSignersEventResponse>(valueList.size());
ArrayList<NewSignersEventResponse> responses = new ArrayList<>(valueList.size());
for (Contract.EventValuesWithLog eventValues : valueList) {
NewSignersEventResponse typedResponse = new NewSignersEventResponse();
typedResponse.log = eventValues.getLog();
Expand Down
Loading
Loading