Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
TracyHesiCecil committed Jul 25, 2020
1 parent 75bb021 commit 92d3bac
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public boolean validate() throws ContractValidateException {
AccountCapsule accountCapsule = accountStore.get(ownerAddress);
if (accountCapsule == null) {
throw new ContractValidateException(
"Account[" + readableOwnerAddress + "] not exists");
ActuatorConstant.ACCOUNT_EXCEPTION_STR
+ readableOwnerAddress + "] not exists");
}

byte[] contractAddress = contract.getContractAddress().toByteArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public boolean validate() throws ContractValidateException {
if (accountCapsule == null) {
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
throw new ContractValidateException(
"Account[" + readableOwnerAddress + "] not exists");
ActuatorConstant.ACCOUNT_EXCEPTION_STR
+ readableOwnerAddress + "] not exists");
}

final long fee = calcFee();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public boolean validate() throws ContractValidateException {
get(ByteArray.fromLong(contract.getExchangeId()));

} catch (ItemNotFoundException ex) {
throw new ContractValidateException("Exchange[" + contract.getExchangeId() + "] not exists");
throw new ContractValidateException("Exchange[" + contract.getExchangeId() + ActuatorConstant
.NOT_EXIST_STR);
}

if (!accountCapsule.getAddress().equals(exchangeCapsule.getCreatorAddress())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public boolean validate() throws ContractValidateException {
exchangeCapsule = Commons.getExchangeStoreFinal(dynamicStore, exchangeStore, exchangeV2Store).
get(ByteArray.fromLong(contract.getExchangeId()));
} catch (ItemNotFoundException ex) {
throw new ContractValidateException("Exchange[" + contract.getExchangeId() + "] not exists");
throw new ContractValidateException("Exchange[" + contract.getExchangeId()
+ ActuatorConstant.NOT_EXIST_STR);
}

byte[] firstTokenID = exchangeCapsule.getFirstTokenId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public boolean validate() throws ContractValidateException {
exchangeCapsule = Commons.getExchangeStoreFinal(dynamicStore, exchangeStore, exchangeV2Store).
get(ByteArray.fromLong(contract.getExchangeId()));
} catch (ItemNotFoundException ex) {
throw new ContractValidateException("Exchange[" + contract.getExchangeId() + "] not exists");
throw new ContractValidateException("Exchange[" + contract.getExchangeId() + ActuatorConstant
.NOT_EXIST_STR);
}

if (!accountCapsule.getAddress().equals(exchangeCapsule.getCreatorAddress())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public boolean validate() throws ContractValidateException {
if (accountCapsule == null) {
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
throw new ContractValidateException(
"Account[" + readableOwnerAddress + "] not exists");
ActuatorConstant.ACCOUNT_EXCEPTION_STR + readableOwnerAddress + "] not exists");
}

long frozenBalance = freezeBalanceContract.getFrozenBalance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public boolean validate() throws ContractValidateException {
AccountCapsule accountCapsule = accountStore.get(ownerAddress);
if (accountCapsule == null) {
throw new ContractValidateException(
"Account[" + readableOwnerAddress + "] does not exist");
ActuatorConstant.ACCOUNT_EXCEPTION_STR + readableOwnerAddress + "] does not exist");
}

long newOriginEnergyLimit = contract.getOriginEnergyLimit();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.tron.core.actuator;

import static org.tron.core.actuator.ActuatorConstant.ACCOUNT_EXCEPTION_STR;

import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.Arrays;
Expand Down Expand Up @@ -83,7 +85,7 @@ public boolean validate() throws ContractValidateException {
AccountCapsule accountCapsule = accountStore.get(ownerAddress);
if (accountCapsule == null) {
throw new ContractValidateException(
"Account[" + readableOwnerAddress + "] does not exist");
ACCOUNT_EXCEPTION_STR + readableOwnerAddress + "] does not exist");
}

long newPercent = contract.getConsumeUserResourcePercent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.tron.core.actuator;

import static org.tron.core.actuator.ActuatorConstant.ACCOUNT_EXCEPTION_STR;
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
import static org.tron.core.config.Parameter.ChainConstant.FROZEN_PERIOD;

import com.google.common.math.LongMath;
Expand Down Expand Up @@ -107,7 +108,7 @@ public boolean validate() throws ContractValidateException {
if (accountCapsule == null) {
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
throw new ContractValidateException(
ACCOUNT_EXCEPTION_STR + readableOwnerAddress + "] not exists");
ACCOUNT_EXCEPTION_STR + readableOwnerAddress + NOT_EXIST_STR);
}

String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public boolean validate() throws ContractValidateException {
AccountCapsule accountCapsule = accountStore.get(ownerAddress);

if (accountCapsule == null) {
throw new ContractValidateException("account[" + readableOwnerAddress + "] not exists");
throw new ContractValidateException("account[" + readableOwnerAddress
+ ActuatorConstant.NOT_EXIST_STR);
}
/* todo later
if (ArrayUtils.isEmpty(accountCapsule.getAccountName().toByteArray())) {
Expand Down

0 comments on commit 92d3bac

Please sign in to comment.