use of org.tron.core.exception.ContractValidateException in project java-tron by tronprotocol.
the class WitnessUpdateActuator method validate.
@Override
public boolean validate() throws ContractValidateException {
try {
if (!this.contract.is(WitnessUpdateContract.class)) {
throw new ContractValidateException("contract type error,expected type [WitnessUpdateContract],real type[" + this.contract.getClass() + "]");
}
final WitnessUpdateContract contract = this.contract.unpack(WitnessUpdateContract.class);
Preconditions.checkNotNull(contract.getOwnerAddress(), "OwnerAddress is null");
if (this.dbManager.getWitnessStore().get(contract.getOwnerAddress().toByteArray()) == null) {
throw new ContractValidateException("Witness not existed");
}
} catch (final Exception ex) {
ex.printStackTrace();
throw new ContractValidateException(ex.getMessage());
}
return true;
}
use of org.tron.core.exception.ContractValidateException in project java-tron by tronprotocol.
the class AssetIssueActuator method validate.
@Override
public boolean validate() throws ContractValidateException {
if (!this.contract.is(AssetIssueContract.class)) {
throw new ContractValidateException();
}
try {
final AssetIssueContract assetIssueContract = this.contract.unpack(AssetIssueContract.class);
Preconditions.checkNotNull(assetIssueContract.getOwnerAddress(), "OwnerAddress is null");
Preconditions.checkNotNull(assetIssueContract.getName(), "name is null");
if (this.dbManager.getAssetIssueStore().get(assetIssueContract.getName().toByteArray()) != null) {
throw new ContractValidateException();
}
} catch (InvalidProtocolBufferException e) {
throw new ContractValidateException();
}
return false;
}
use of org.tron.core.exception.ContractValidateException in project java-tron by tronprotocol.
the class CreateAccountActuator method validate.
@Override
public boolean validate() throws ContractValidateException {
try {
if (!contract.is(AccountCreateContract.class)) {
throw new ContractValidateException("contract type error,expected type [AccountCreateContract],real type[" + contract.getClass() + "]");
}
AccountCreateContract contract = this.contract.unpack(AccountCreateContract.class);
Preconditions.checkNotNull(contract.getAccountName(), "AccountName is null");
Preconditions.checkNotNull(contract.getOwnerAddress(), "OwnerAddress is null");
Preconditions.checkNotNull(contract.getType(), "Type is null");
if (dbManager.getAccountStore().has(contract.getOwnerAddress().toByteArray())) {
throw new ContractValidateException("Account has existed");
}
} catch (Exception ex) {
ex.printStackTrace();
throw new ContractValidateException(ex.getMessage());
}
return true;
}
Aggregations