Skip to content

Commit

Permalink
add frozen error code (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
ywy2090 authored Jan 21, 2020
1 parent bfc3b86 commit 2b0bb69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.fisco.bcos.web3j.crypto.Credentials;
import org.fisco.bcos.web3j.crypto.WalletUtils;
import org.fisco.bcos.web3j.precompile.common.PrecompiledCommon;
import org.fisco.bcos.web3j.protocol.ObjectMapperFactory;
import org.fisco.bcos.web3j.protocol.Web3j;
import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
import org.fisco.bcos.web3j.tuples.generated.Tuple2;
Expand All @@ -14,15 +13,17 @@
public class FrozenService {
private static BigInteger gasPrice = new BigInteger("30000000000");
private static BigInteger gasLimit = new BigInteger("30000000000");
private static String ConsensusPrecompileAddress = "0x0000000000000000000000000000000000001007";
private static String ContractFrozenPrecompileAddress =
"0x0000000000000000000000000000000000001007";
private Web3j web3j;
private Frozen frozen;

public FrozenService(Web3j web3j, Credentials credentials) {
ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit);
this.web3j = web3j;
this.frozen =
Frozen.load(ConsensusPrecompileAddress, web3j, credentials, contractGasProvider);
Frozen.load(
ContractFrozenPrecompileAddress, web3j, credentials, contractGasProvider);
}

public String frozen(String addr) throws Exception {
Expand Down Expand Up @@ -58,6 +59,6 @@ public String queryStatus(String addr) throws Exception {
}

Tuple2<BigInteger, String> send = frozen.queryStatus(addr).send();
return ObjectMapperFactory.getObjectMapper().writeValueAsString(send);
return send.getValue2();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class StatusCode {
public static final String GasOverflow = "0x1b";
public static final String TxPoolIsFull = "0x1c";
public static final String TransactionRefused = "0x1d";
public static final String ContractFrozen = "0x1e";

// extension
public static final String ExceptionCatched = "0x30";
Expand Down Expand Up @@ -163,6 +164,9 @@ public static String getStatusMessage(String status, String errorMessage) {
case MalformedTx:
message = "malformed transaction";
break;
case ContractFrozen:
message = "contract has been frozen";
break;
default:
message = errorMessage;
break;
Expand Down

0 comments on commit 2b0bb69

Please sign in to comment.