diff --git a/rpc-lib4j/src/main/java/org/aion/rpc/errors/RPCExceptions.java b/rpc-lib4j/src/main/java/org/aion/rpc/errors/RPCExceptions.java index 6fa438a..52af1c4 100644 --- a/rpc-lib4j/src/main/java/org/aion/rpc/errors/RPCExceptions.java +++ b/rpc-lib4j/src/main/java/org/aion/rpc/errors/RPCExceptions.java @@ -6,7 +6,7 @@ * * AUTO-GENERATED SOURCE FILE. DO NOT EDIT MANUALLY -- YOUR CHANGES WILL * BE WIPED OUT WHEN THIS FILE GETS RE-GENERATED OR UPDATED. -* GENERATED: 2019-12-10 +* GENERATED: 2019-12-11 * *****************************************************************************/ public class RPCExceptions{ @@ -94,7 +94,9 @@ else if(code == -32006){ * @return the RPCException which contains the specified code and message if it can be created. Otherwise an instance of InternalErrorRPCException. */ public static RPCException fromCodeAndMessage(int code, String message){ - if(code == -32601){ + if(code == -32700){ + return new ParseErrorRPCException(code, message); + }else if(code == -32601){ return new MethodNotFoundRPCException(code, message); }else if(code == -32603){ return new InternalErrorRPCException(code, message); @@ -109,13 +111,9 @@ public static RPCException fromCodeAndMessage(int code, String message){ public static class RPCException extends RuntimeException{ private final transient RpcError error; - RPCException(String message){ - super(message); - this.error = RpcErrorConverter.decode(message); - } - - RPCException(Integer code ,String message){ - this("{\"code\":"+code+",\"message\":\""+message+"\"}"); + RPCException(final Integer code , final String message){ + super("{\"code\":"+code+",\"message\":\""+message+"\"}"); + error = new RpcError(code, message); } /** @@ -132,8 +130,8 @@ public RpcError getError(){ */ public static class InvalidRequestRPCException extends RPCException{ public static final InvalidRequestRPCException INSTANCE = new InvalidRequestRPCException(); - private InvalidRequestRPCException(){ - super("{\"code\":-32600,\"message\":\"Invalid Request\"}"); + public InvalidRequestRPCException(){ + super(-32600,"Invalid Request"); } } @@ -144,8 +142,14 @@ private InvalidRequestRPCException(){ */ public static class ParseErrorRPCException extends RPCException{ public static final ParseErrorRPCException INSTANCE = new ParseErrorRPCException(); - private ParseErrorRPCException(){ - super("{\"code\":-32700,\"message\":\"Parse error\"}"); + public ParseErrorRPCException(){ + super(-32700,"Parse error"); + } + public ParseErrorRPCException(String appendedMessage){ + super(-32700,"Parse error:"+appendedMessage); + } + ParseErrorRPCException(Integer code, String message){ + super(code,message); } } @@ -155,11 +159,11 @@ private ParseErrorRPCException(){ */ public static class MethodNotFoundRPCException extends RPCException{ public static final MethodNotFoundRPCException INSTANCE = new MethodNotFoundRPCException(); - private MethodNotFoundRPCException(){ - super("{\"code\":-32601,\"message\":\"Method not found\"}"); + public MethodNotFoundRPCException(){ + super(-32601,"Method not found"); } public MethodNotFoundRPCException(String appendedMessage){ - super("{\"code\":-32601,\"message\":\"Method not found:"+appendedMessage+"\"}"); + super(-32601,"Method not found:"+appendedMessage); } MethodNotFoundRPCException(Integer code, String message){ super(code,message); @@ -173,8 +177,8 @@ public MethodNotFoundRPCException(String appendedMessage){ */ public static class InvalidParamsRPCException extends RPCException{ public static final InvalidParamsRPCException INSTANCE = new InvalidParamsRPCException(); - private InvalidParamsRPCException(){ - super("{\"code\":-32602,\"message\":\"Invalid params\"}"); + public InvalidParamsRPCException(){ + super(-32602,"Invalid params"); } } @@ -185,11 +189,11 @@ private InvalidParamsRPCException(){ */ public static class InternalErrorRPCException extends RPCException{ public static final InternalErrorRPCException INSTANCE = new InternalErrorRPCException(); - private InternalErrorRPCException(){ - super("{\"code\":-32603,\"message\":\"Internal error\"}"); + public InternalErrorRPCException(){ + super(-32603,"Internal error"); } public InternalErrorRPCException(String appendedMessage){ - super("{\"code\":-32603,\"message\":\"Internal error:"+appendedMessage+"\"}"); + super(-32603,"Internal error:"+appendedMessage); } InternalErrorRPCException(Integer code, String message){ super(code,message); @@ -203,8 +207,8 @@ public InternalErrorRPCException(String appendedMessage){ */ public static class UnsupportedUnityFeatureRPCException extends RPCException{ public static final UnsupportedUnityFeatureRPCException INSTANCE = new UnsupportedUnityFeatureRPCException(); - private UnsupportedUnityFeatureRPCException(){ - super("{\"code\":-32001,\"message\":\"Unity fork is not enabled\"}"); + public UnsupportedUnityFeatureRPCException(){ + super(-32001,"Unity fork is not enabled"); } } @@ -214,8 +218,8 @@ private UnsupportedUnityFeatureRPCException(){ */ public static class BlockTemplateNotFoundRPCException extends RPCException{ public static final BlockTemplateNotFoundRPCException INSTANCE = new BlockTemplateNotFoundRPCException(); - private BlockTemplateNotFoundRPCException(){ - super("{\"code\":-32002,\"message\":\"Could not find the block template for the supplied header hash.\"}"); + public BlockTemplateNotFoundRPCException(){ + super(-32002,"Could not find the block template for the supplied header hash."); } } @@ -225,8 +229,8 @@ private BlockTemplateNotFoundRPCException(){ */ public static class FailedToSealBlockRPCException extends RPCException{ public static final FailedToSealBlockRPCException INSTANCE = new FailedToSealBlockRPCException(); - private FailedToSealBlockRPCException(){ - super("{\"code\":-32003,\"message\":\"Could not seal the pow block.\"}"); + public FailedToSealBlockRPCException(){ + super(-32003,"Could not seal the pow block."); } } @@ -236,8 +240,8 @@ private FailedToSealBlockRPCException(){ */ public static class FailedToComputeMetricsRPCException extends RPCException{ public static final FailedToComputeMetricsRPCException INSTANCE = new FailedToComputeMetricsRPCException(); - private FailedToComputeMetricsRPCException(){ - super("{\"code\":-32004,\"message\":\"Could not compute the POW metrics.\"}"); + public FailedToComputeMetricsRPCException(){ + super(-32004,"Could not compute the POW metrics."); } } @@ -247,11 +251,11 @@ private FailedToComputeMetricsRPCException(){ */ public static class NullReturnRPCException extends RPCException{ public static final NullReturnRPCException INSTANCE = new NullReturnRPCException(); - private NullReturnRPCException(){ - super("{\"code\":-32005,\"message\":\"Block chain rpc returned null\"}"); + public NullReturnRPCException(){ + super(-32005,"Block chain rpc returned null"); } public NullReturnRPCException(String appendedMessage){ - super("{\"code\":-32005,\"message\":\"Block chain rpc returned null:"+appendedMessage+"\"}"); + super(-32005,"Block chain rpc returned null:"+appendedMessage); } NullReturnRPCException(Integer code, String message){ super(code,message); @@ -266,11 +270,11 @@ public NullReturnRPCException(String appendedMessage){ */ public static class TxFailedRPCException extends RPCException{ public static final TxFailedRPCException INSTANCE = new TxFailedRPCException(); - private TxFailedRPCException(){ - super("{\"code\":-32006,\"message\":\"Failed to execute transaction\"}"); + public TxFailedRPCException(){ + super(-32006,"Failed to execute transaction"); } public TxFailedRPCException(String appendedMessage){ - super("{\"code\":-32006,\"message\":\"Failed to execute transaction:"+appendedMessage+"\"}"); + super(-32006,"Failed to execute transaction:"+appendedMessage); } TxFailedRPCException(Integer code, String message){ super(code,message); diff --git a/rpc-lib4j/src/main/java/org/aion/rpc/server/RPCServerMethods.java b/rpc-lib4j/src/main/java/org/aion/rpc/server/RPCServerMethods.java index ab41aca..1d9ca38 100644 --- a/rpc-lib4j/src/main/java/org/aion/rpc/server/RPCServerMethods.java +++ b/rpc-lib4j/src/main/java/org/aion/rpc/server/RPCServerMethods.java @@ -30,7 +30,7 @@ static Object execute(Request request, RPCServerMethods rpc){ //check that the request can be fulfilled by this class if(request.method.equals("personal_ecRecover")){ EcRecoverParams params= EcRecoverParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); AionAddress result = rpc.personal_ecRecover(params.dataThatWasSigned,params.signature); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -39,7 +39,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("getseed")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); ByteArray result = rpc.getseed(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -48,7 +48,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("submitseed")){ SubmitSeedParams params= SubmitSeedParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); ByteArray result = rpc.submitseed(params.newSeed,params.signingPublicKey,params.coinbase); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -57,7 +57,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("submitsignature")){ SubmitSignatureParams params= SubmitSignatureParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); Boolean result = rpc.submitsignature(params.signature,params.sealHash); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -66,7 +66,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("ops_getBlockDetails")){ BlockSpecifierParams params= BlockSpecifierParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BlockDetails result = rpc.ops_getBlockDetails(params.block); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -75,7 +75,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("getBlockTemplate")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BlockTemplate result = rpc.getBlockTemplate(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -84,7 +84,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("submitBlock")){ SubmitBlockParams params= SubmitBlockParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); SubmissionResult result = rpc.submitBlock(params.nonce,params.solution,params.headerHash); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -93,7 +93,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("validateaddress")){ AddressParams params= AddressParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); ValidateAddressResult result = rpc.validateaddress(params.address); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -102,7 +102,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("getDifficulty")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BigInteger result = rpc.getDifficulty(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -111,7 +111,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("getMinerStatistics")){ AddressParams params= AddressParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); MinerStats result = rpc.getMinerStatistics(params.address); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -120,7 +120,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("ping")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); PongEnum result = rpc.ping(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -129,7 +129,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("ops_getAccountState")){ AddressParams params= AddressParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); AccountState result = rpc.ops_getAccountState(params.address); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -138,7 +138,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("ops_getTransaction")){ TransactionHashParams params= TransactionHashParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); OpsTransaction result = rpc.ops_getTransaction(params.hash); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -147,7 +147,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("ops_getBlockDetailsByNumber")){ BlockNumberParams params= BlockNumberParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BlockDetails result = rpc.ops_getBlockDetailsByNumber(params.block); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -156,7 +156,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("ops_getBlockDetailsByHash")){ BlockHashParams params= BlockHashParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BlockDetails result = rpc.ops_getBlockDetailsByHash(params.block); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -165,7 +165,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_getBalance")){ AddressBlockParams params= AddressBlockParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BigInteger result = rpc.eth_getBalance(params.address,params.block); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -174,7 +174,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_getTransactionCount")){ AddressBlockParams params= AddressBlockParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); BigInteger result = rpc.eth_getTransactionCount(params.address,params.block); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -183,7 +183,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("personal_unlockAccount")){ UnlockAccountParams params= UnlockAccountParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); Boolean result = rpc.personal_unlockAccount(params.address,params.password,params.duration); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -192,7 +192,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("personal_lockAccount")){ LockAccountParams params= LockAccountParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); Boolean result = rpc.personal_lockAccount(params.address,params.password); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -201,7 +201,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("personal_newAccount")){ PasswordParams params= PasswordParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); AionAddress result = rpc.personal_newAccount(params.password); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -210,7 +210,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("personal_listAccounts")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); AionAddress[] result = rpc.personal_listAccounts(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -219,7 +219,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_blockNumber")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); Long result = rpc.eth_blockNumber(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -228,7 +228,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_call")){ CallParams params= CallParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); ByteArray result = rpc.eth_call(params.transaction,params.block); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -237,7 +237,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_syncing")){ VoidParams params= VoidParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); SyncInfoUnion result = rpc.eth_syncing(); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -246,7 +246,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_sendRawTransaction")){ SendTransactionRawParams params= SendTransactionRawParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); ByteArray result = rpc.eth_sendRawTransaction(params.transaction); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -255,7 +255,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_sendTransaction")){ SendTransactionParams params= SendTransactionParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); ByteArray result = rpc.eth_sendTransaction(params.transaction); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -264,7 +264,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_getTransactionByHash")){ TransactionHashParams params= TransactionHashParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); EthTransaction result = rpc.eth_getTransactionByHash(params.hash); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -273,7 +273,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_getTransactionReceipt")){ TransactionHashParams params= TransactionHashParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); EthTransactionReceipt result = rpc.eth_getTransactionReceipt(params.hash); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -282,7 +282,7 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_getBlockByNumber")){ EthBlockNumberParams params= EthBlockNumberParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); EthBlock result = rpc.eth_getBlockByNumber(params.block,params.fullTransaction); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -291,14 +291,14 @@ static Object execute(Request request, RPCServerMethods rpc){ }else if(request.method.equals("eth_getBlockByHash")){ EthBlockHashParams params= EthBlockHashParamsConverter.decode(request.params); - if (params==null) throw InvalidParamsRPCException.INSTANCE; + if (params==null) throw new InvalidParamsRPCException(); EthBlock result = rpc.eth_getBlockByHash(params.block,params.fullTransaction); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object if (result == null ) throw new NullReturnRPCException("Could not retrieve a result for eth_getBlockByHash"); else res = EthBlockConverter.encode(result); }else - throw MethodNotFoundRPCException.INSTANCE; + throw new MethodNotFoundRPCException(); return res; } diff --git a/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypes.java b/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypes.java index c2d9459..e3b963a 100644 --- a/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypes.java +++ b/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypes.java @@ -25,7 +25,7 @@ public static final class ByteArray{ public ByteArray(byte[] bytes) { if (bytes == null) { - throw new NullPointerException("Byte array is null"); + throw new NullPointerException("Byte array is null"); } this.bytes = bytes; } @@ -33,7 +33,7 @@ public ByteArray(byte[] bytes) { * @param hexString a hexadecimal string that encodes a byte array. */ public ByteArray(String hexString){ - if (hexString == null) throw new NullPointerException("Hex String is null"); + if (hexString == null) throw new NullPointerException("Hex String is null"); this.bytes = ByteUtil.hexStringToBytes(hexString); } @@ -94,27 +94,27 @@ private BlockSpecifierUnion(ByteArray hash ,Long blockNumber ,BlockEnum blockEnu public BlockSpecifierUnion(ByteArray hash){ this(hash,null,null); - if(hash == null) throw ParseErrorRPCException.INSTANCE; + if(hash == null) throw new ParseErrorRPCException(); } public BlockSpecifierUnion(Long blockNumber){ this(null,blockNumber,null); - if(blockNumber == null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber == null) throw new ParseErrorRPCException(); } public BlockSpecifierUnion(BlockEnum blockEnum){ this(null,null,blockEnum); - if(blockEnum == null) throw ParseErrorRPCException.INSTANCE; + if(blockEnum == null) throw new ParseErrorRPCException(); } public static BlockSpecifierUnion wrap(ByteArray hash){ - if(hash == null) throw ParseErrorRPCException.INSTANCE; + if(hash == null) throw new ParseErrorRPCException(); else return new BlockSpecifierUnion(hash); } public static BlockSpecifierUnion wrap(Long blockNumber){ - if(blockNumber == null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber == null) throw new ParseErrorRPCException(); else return new BlockSpecifierUnion(blockNumber); } public static BlockSpecifierUnion wrap(BlockEnum blockEnum){ - if(blockEnum == null) throw ParseErrorRPCException.INSTANCE; + if(blockEnum == null) throw new ParseErrorRPCException(); else return new BlockSpecifierUnion(blockEnum); } @@ -122,7 +122,7 @@ public Object encode(){ if(this.hash != null) return ByteArrayConverter.encode(hash); if(this.blockNumber != null) return LongConverter.encode(blockNumber); if(this.blockEnum != null) return BlockEnumConverter.encode(blockEnum); - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } public static BlockSpecifierUnion decode(Object object){ @@ -135,7 +135,7 @@ public static BlockSpecifierUnion decode(Object object){ try{ return new BlockSpecifierUnion(BlockEnumConverter.decode(object)); }catch(Exception e){} - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -160,26 +160,26 @@ private SyncInfoUnion(SyncInfo syncInfo ,Boolean done ){ public SyncInfoUnion(SyncInfo syncInfo){ this(syncInfo,null); - if(syncInfo == null) throw ParseErrorRPCException.INSTANCE; + if(syncInfo == null) throw new ParseErrorRPCException(); } public SyncInfoUnion(Boolean done){ this(null,done); - if(done == null) throw ParseErrorRPCException.INSTANCE; + if(done == null) throw new ParseErrorRPCException(); } public static SyncInfoUnion wrap(SyncInfo syncInfo){ - if(syncInfo == null) throw ParseErrorRPCException.INSTANCE; + if(syncInfo == null) throw new ParseErrorRPCException(); else return new SyncInfoUnion(syncInfo); } public static SyncInfoUnion wrap(Boolean done){ - if(done == null) throw ParseErrorRPCException.INSTANCE; + if(done == null) throw new ParseErrorRPCException(); else return new SyncInfoUnion(done); } public Object encode(){ if(this.syncInfo != null) return SyncInfoConverter.encode(syncInfo); if(this.done != null) return BoolConverter.encode(done); - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } public static SyncInfoUnion decode(Object object){ @@ -189,7 +189,7 @@ public static SyncInfoUnion decode(Object object){ try{ return new SyncInfoUnion(BoolConverter.decode(object)); }catch(Exception e){} - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -210,26 +210,26 @@ private BlockNumberEnumUnion(Long blockNumber ,BlockEnum blockEnum ){ public BlockNumberEnumUnion(Long blockNumber){ this(blockNumber,null); - if(blockNumber == null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber == null) throw new ParseErrorRPCException(); } public BlockNumberEnumUnion(BlockEnum blockEnum){ this(null,blockEnum); - if(blockEnum == null) throw ParseErrorRPCException.INSTANCE; + if(blockEnum == null) throw new ParseErrorRPCException(); } public static BlockNumberEnumUnion wrap(Long blockNumber){ - if(blockNumber == null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber == null) throw new ParseErrorRPCException(); else return new BlockNumberEnumUnion(blockNumber); } public static BlockNumberEnumUnion wrap(BlockEnum blockEnum){ - if(blockEnum == null) throw ParseErrorRPCException.INSTANCE; + if(blockEnum == null) throw new ParseErrorRPCException(); else return new BlockNumberEnumUnion(blockEnum); } public Object encode(){ if(this.blockNumber != null) return Uint32Converter.encode(blockNumber); if(this.blockEnum != null) return BlockEnumConverter.encode(blockEnum); - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } public static BlockNumberEnumUnion decode(Object object){ @@ -239,7 +239,7 @@ public static BlockNumberEnumUnion decode(Object object){ try{ return new BlockNumberEnumUnion(BlockEnumConverter.decode(object)); }catch(Exception e){} - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -278,107 +278,107 @@ private ResultUnion(BlockDetails blockDetails ,AionAddress address ,ByteArray by public ResultUnion(BlockDetails blockDetails){ this(blockDetails,null,null,null,null,null,null,null,null,null,null,null,null); - if(blockDetails == null) throw ParseErrorRPCException.INSTANCE; + if(blockDetails == null) throw new ParseErrorRPCException(); } public ResultUnion(AionAddress address){ this(null,address,null,null,null,null,null,null,null,null,null,null,null); - if(address == null) throw ParseErrorRPCException.INSTANCE; + if(address == null) throw new ParseErrorRPCException(); } public ResultUnion(ByteArray byteArray){ this(null,null,byteArray,null,null,null,null,null,null,null,null,null,null); - if(byteArray == null) throw ParseErrorRPCException.INSTANCE; + if(byteArray == null) throw new ParseErrorRPCException(); } public ResultUnion(Boolean bool){ this(null,null,null,bool,null,null,null,null,null,null,null,null,null); - if(bool == null) throw ParseErrorRPCException.INSTANCE; + if(bool == null) throw new ParseErrorRPCException(); } public ResultUnion(BlockTemplate blockTemplate){ this(null,null,null,null,blockTemplate,null,null,null,null,null,null,null,null); - if(blockTemplate == null) throw ParseErrorRPCException.INSTANCE; + if(blockTemplate == null) throw new ParseErrorRPCException(); } public ResultUnion(SubmissionResult submissionResult){ this(null,null,null,null,null,submissionResult,null,null,null,null,null,null,null); - if(submissionResult == null) throw ParseErrorRPCException.INSTANCE; + if(submissionResult == null) throw new ParseErrorRPCException(); } public ResultUnion(ValidateAddressResult validateAddressResult){ this(null,null,null,null,null,null,validateAddressResult,null,null,null,null,null,null); - if(validateAddressResult == null) throw ParseErrorRPCException.INSTANCE; + if(validateAddressResult == null) throw new ParseErrorRPCException(); } public ResultUnion(BigInteger bigInt){ this(null,null,null,null,null,null,null,bigInt,null,null,null,null,null); - if(bigInt == null) throw ParseErrorRPCException.INSTANCE; + if(bigInt == null) throw new ParseErrorRPCException(); } public ResultUnion(MinerStats minerStats){ this(null,null,null,null,null,null,null,null,minerStats,null,null,null,null); - if(minerStats == null) throw ParseErrorRPCException.INSTANCE; + if(minerStats == null) throw new ParseErrorRPCException(); } public ResultUnion(PongEnum pongEnum){ this(null,null,null,null,null,null,null,null,null,pongEnum,null,null,null); - if(pongEnum == null) throw ParseErrorRPCException.INSTANCE; + if(pongEnum == null) throw new ParseErrorRPCException(); } public ResultUnion(AccountState accountState){ this(null,null,null,null,null,null,null,null,null,null,accountState,null,null); - if(accountState == null) throw ParseErrorRPCException.INSTANCE; + if(accountState == null) throw new ParseErrorRPCException(); } public ResultUnion(OpsTransaction opsTransaction){ this(null,null,null,null,null,null,null,null,null,null,null,opsTransaction,null); - if(opsTransaction == null) throw ParseErrorRPCException.INSTANCE; + if(opsTransaction == null) throw new ParseErrorRPCException(); } public ResultUnion(AionAddress[] addressArray){ this(null,null,null,null,null,null,null,null,null,null,null,null,addressArray); - if(addressArray == null) throw ParseErrorRPCException.INSTANCE; + if(addressArray == null) throw new ParseErrorRPCException(); } public static ResultUnion wrap(BlockDetails blockDetails){ - if(blockDetails == null) throw ParseErrorRPCException.INSTANCE; + if(blockDetails == null) throw new ParseErrorRPCException(); else return new ResultUnion(blockDetails); } public static ResultUnion wrap(AionAddress address){ - if(address == null) throw ParseErrorRPCException.INSTANCE; + if(address == null) throw new ParseErrorRPCException(); else return new ResultUnion(address); } public static ResultUnion wrap(ByteArray byteArray){ - if(byteArray == null) throw ParseErrorRPCException.INSTANCE; + if(byteArray == null) throw new ParseErrorRPCException(); else return new ResultUnion(byteArray); } public static ResultUnion wrap(Boolean bool){ - if(bool == null) throw ParseErrorRPCException.INSTANCE; + if(bool == null) throw new ParseErrorRPCException(); else return new ResultUnion(bool); } public static ResultUnion wrap(BlockTemplate blockTemplate){ - if(blockTemplate == null) throw ParseErrorRPCException.INSTANCE; + if(blockTemplate == null) throw new ParseErrorRPCException(); else return new ResultUnion(blockTemplate); } public static ResultUnion wrap(SubmissionResult submissionResult){ - if(submissionResult == null) throw ParseErrorRPCException.INSTANCE; + if(submissionResult == null) throw new ParseErrorRPCException(); else return new ResultUnion(submissionResult); } public static ResultUnion wrap(ValidateAddressResult validateAddressResult){ - if(validateAddressResult == null) throw ParseErrorRPCException.INSTANCE; + if(validateAddressResult == null) throw new ParseErrorRPCException(); else return new ResultUnion(validateAddressResult); } public static ResultUnion wrap(BigInteger bigInt){ - if(bigInt == null) throw ParseErrorRPCException.INSTANCE; + if(bigInt == null) throw new ParseErrorRPCException(); else return new ResultUnion(bigInt); } public static ResultUnion wrap(MinerStats minerStats){ - if(minerStats == null) throw ParseErrorRPCException.INSTANCE; + if(minerStats == null) throw new ParseErrorRPCException(); else return new ResultUnion(minerStats); } public static ResultUnion wrap(PongEnum pongEnum){ - if(pongEnum == null) throw ParseErrorRPCException.INSTANCE; + if(pongEnum == null) throw new ParseErrorRPCException(); else return new ResultUnion(pongEnum); } public static ResultUnion wrap(AccountState accountState){ - if(accountState == null) throw ParseErrorRPCException.INSTANCE; + if(accountState == null) throw new ParseErrorRPCException(); else return new ResultUnion(accountState); } public static ResultUnion wrap(OpsTransaction opsTransaction){ - if(opsTransaction == null) throw ParseErrorRPCException.INSTANCE; + if(opsTransaction == null) throw new ParseErrorRPCException(); else return new ResultUnion(opsTransaction); } public static ResultUnion wrap(AionAddress[] addressArray){ - if(addressArray == null) throw ParseErrorRPCException.INSTANCE; + if(addressArray == null) throw new ParseErrorRPCException(); else return new ResultUnion(addressArray); } @@ -396,7 +396,7 @@ public Object encode(){ if(this.accountState != null) return AccountStateConverter.encode(accountState); if(this.opsTransaction != null) return OpsTransactionConverter.encode(opsTransaction); if(this.addressArray != null) return AddressListConverter.encode(addressArray); - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } public static ResultUnion decode(Object object){ @@ -439,7 +439,7 @@ public static ResultUnion decode(Object object){ try{ return new ResultUnion(AddressListConverter.decode(object)); }catch(Exception e){} - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -478,107 +478,107 @@ private ParamUnion(VoidParams voidParams ,EcRecoverParams ecRecoverParams ,Submi public ParamUnion(VoidParams voidParams){ this(voidParams,null,null,null,null,null,null,null,null,null,null,null,null); - if(voidParams == null) throw ParseErrorRPCException.INSTANCE; + if(voidParams == null) throw new ParseErrorRPCException(); } public ParamUnion(EcRecoverParams ecRecoverParams){ this(null,ecRecoverParams,null,null,null,null,null,null,null,null,null,null,null); - if(ecRecoverParams == null) throw ParseErrorRPCException.INSTANCE; + if(ecRecoverParams == null) throw new ParseErrorRPCException(); } public ParamUnion(SubmitSeedParams submitSeedParams){ this(null,null,submitSeedParams,null,null,null,null,null,null,null,null,null,null); - if(submitSeedParams == null) throw ParseErrorRPCException.INSTANCE; + if(submitSeedParams == null) throw new ParseErrorRPCException(); } public ParamUnion(SubmitSignatureParams submitSignatureParams){ this(null,null,null,submitSignatureParams,null,null,null,null,null,null,null,null,null); - if(submitSignatureParams == null) throw ParseErrorRPCException.INSTANCE; + if(submitSignatureParams == null) throw new ParseErrorRPCException(); } public ParamUnion(SubmitBlockParams submitBlockParams){ this(null,null,null,null,submitBlockParams,null,null,null,null,null,null,null,null); - if(submitBlockParams == null) throw ParseErrorRPCException.INSTANCE; + if(submitBlockParams == null) throw new ParseErrorRPCException(); } public ParamUnion(AddressParams addressParams){ this(null,null,null,null,null,addressParams,null,null,null,null,null,null,null); - if(addressParams == null) throw ParseErrorRPCException.INSTANCE; + if(addressParams == null) throw new ParseErrorRPCException(); } public ParamUnion(BlockSpecifierParams blockSpecifierParams){ this(null,null,null,null,null,null,blockSpecifierParams,null,null,null,null,null,null); - if(blockSpecifierParams == null) throw ParseErrorRPCException.INSTANCE; + if(blockSpecifierParams == null) throw new ParseErrorRPCException(); } public ParamUnion(TransactionHashParams transactionHashParams){ this(null,null,null,null,null,null,null,transactionHashParams,null,null,null,null,null); - if(transactionHashParams == null) throw ParseErrorRPCException.INSTANCE; + if(transactionHashParams == null) throw new ParseErrorRPCException(); } public ParamUnion(BlockNumberParams blockNumberParams){ this(null,null,null,null,null,null,null,null,blockNumberParams,null,null,null,null); - if(blockNumberParams == null) throw ParseErrorRPCException.INSTANCE; + if(blockNumberParams == null) throw new ParseErrorRPCException(); } public ParamUnion(BlockHashParams blockHashParams){ this(null,null,null,null,null,null,null,null,null,blockHashParams,null,null,null); - if(blockHashParams == null) throw ParseErrorRPCException.INSTANCE; + if(blockHashParams == null) throw new ParseErrorRPCException(); } public ParamUnion(UnlockAccountParams unlockAccountParams){ this(null,null,null,null,null,null,null,null,null,null,unlockAccountParams,null,null); - if(unlockAccountParams == null) throw ParseErrorRPCException.INSTANCE; + if(unlockAccountParams == null) throw new ParseErrorRPCException(); } public ParamUnion(LockAccountParams lockAccountParams){ this(null,null,null,null,null,null,null,null,null,null,null,lockAccountParams,null); - if(lockAccountParams == null) throw ParseErrorRPCException.INSTANCE; + if(lockAccountParams == null) throw new ParseErrorRPCException(); } public ParamUnion(PasswordParams passwordParams){ this(null,null,null,null,null,null,null,null,null,null,null,null,passwordParams); - if(passwordParams == null) throw ParseErrorRPCException.INSTANCE; + if(passwordParams == null) throw new ParseErrorRPCException(); } public static ParamUnion wrap(VoidParams voidParams){ - if(voidParams == null) throw ParseErrorRPCException.INSTANCE; + if(voidParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(voidParams); } public static ParamUnion wrap(EcRecoverParams ecRecoverParams){ - if(ecRecoverParams == null) throw ParseErrorRPCException.INSTANCE; + if(ecRecoverParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(ecRecoverParams); } public static ParamUnion wrap(SubmitSeedParams submitSeedParams){ - if(submitSeedParams == null) throw ParseErrorRPCException.INSTANCE; + if(submitSeedParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(submitSeedParams); } public static ParamUnion wrap(SubmitSignatureParams submitSignatureParams){ - if(submitSignatureParams == null) throw ParseErrorRPCException.INSTANCE; + if(submitSignatureParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(submitSignatureParams); } public static ParamUnion wrap(SubmitBlockParams submitBlockParams){ - if(submitBlockParams == null) throw ParseErrorRPCException.INSTANCE; + if(submitBlockParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(submitBlockParams); } public static ParamUnion wrap(AddressParams addressParams){ - if(addressParams == null) throw ParseErrorRPCException.INSTANCE; + if(addressParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(addressParams); } public static ParamUnion wrap(BlockSpecifierParams blockSpecifierParams){ - if(blockSpecifierParams == null) throw ParseErrorRPCException.INSTANCE; + if(blockSpecifierParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(blockSpecifierParams); } public static ParamUnion wrap(TransactionHashParams transactionHashParams){ - if(transactionHashParams == null) throw ParseErrorRPCException.INSTANCE; + if(transactionHashParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(transactionHashParams); } public static ParamUnion wrap(BlockNumberParams blockNumberParams){ - if(blockNumberParams == null) throw ParseErrorRPCException.INSTANCE; + if(blockNumberParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(blockNumberParams); } public static ParamUnion wrap(BlockHashParams blockHashParams){ - if(blockHashParams == null) throw ParseErrorRPCException.INSTANCE; + if(blockHashParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(blockHashParams); } public static ParamUnion wrap(UnlockAccountParams unlockAccountParams){ - if(unlockAccountParams == null) throw ParseErrorRPCException.INSTANCE; + if(unlockAccountParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(unlockAccountParams); } public static ParamUnion wrap(LockAccountParams lockAccountParams){ - if(lockAccountParams == null) throw ParseErrorRPCException.INSTANCE; + if(lockAccountParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(lockAccountParams); } public static ParamUnion wrap(PasswordParams passwordParams){ - if(passwordParams == null) throw ParseErrorRPCException.INSTANCE; + if(passwordParams == null) throw new ParseErrorRPCException(); else return new ParamUnion(passwordParams); } @@ -596,7 +596,7 @@ public Object encode(){ if(this.unlockAccountParams != null) return UnlockAccountParamsConverter.encode(unlockAccountParams); if(this.lockAccountParams != null) return LockAccountParamsConverter.encode(lockAccountParams); if(this.passwordParams != null) return PasswordParamsConverter.encode(passwordParams); - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } public static ParamUnion decode(Object object){ @@ -639,7 +639,7 @@ public static ParamUnion decode(Object object){ try{ return new ParamUnion(PasswordParamsConverter.decode(object)); }catch(Exception e){} - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -653,26 +653,26 @@ private TransactionUnion(EthTransactionForBlock[] transactionList ,ByteArray[] t public TransactionUnion(EthTransactionForBlock[] transactionList){ this(transactionList,null); - if(transactionList == null) throw ParseErrorRPCException.INSTANCE; + if(transactionList == null) throw new ParseErrorRPCException(); } public TransactionUnion(ByteArray[] transactionHashes){ this(null,transactionHashes); - if(transactionHashes == null) throw ParseErrorRPCException.INSTANCE; + if(transactionHashes == null) throw new ParseErrorRPCException(); } public static TransactionUnion wrap(EthTransactionForBlock[] transactionList){ - if(transactionList == null) throw ParseErrorRPCException.INSTANCE; + if(transactionList == null) throw new ParseErrorRPCException(); else return new TransactionUnion(transactionList); } public static TransactionUnion wrap(ByteArray[] transactionHashes){ - if(transactionHashes == null) throw ParseErrorRPCException.INSTANCE; + if(transactionHashes == null) throw new ParseErrorRPCException(); else return new TransactionUnion(transactionHashes); } public Object encode(){ if(this.transactionList != null) return EthTransactionForBlockListConverter.encode(transactionList); if(this.transactionHashes != null) return Byte32StringListConverter.encode(transactionHashes); - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } public static TransactionUnion decode(Object object){ @@ -682,7 +682,7 @@ public static TransactionUnion decode(Object object){ try{ return new TransactionUnion(Byte32StringListConverter.decode(object)); }catch(Exception e){} - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -700,7 +700,7 @@ public static final class Request { public Request(Integer id ,String method ,Object params ,VersionType jsonrpc ){ this.id=id; - if(method==null) throw ParseErrorRPCException.INSTANCE; + if(method==null) throw new ParseErrorRPCException("Missing field(method) on type(Request)"); this.method=method; this.params=params; this.jsonrpc=jsonrpc; @@ -712,11 +712,11 @@ public static final class SyncInfo { public final Long highestBlock; public SyncInfo(Long startingBlock ,Long currentBlock ,Long highestBlock ){ - if(startingBlock==null) throw ParseErrorRPCException.INSTANCE; + if(startingBlock==null) throw new ParseErrorRPCException("Missing field(startingBlock) on type(SyncInfo)"); this.startingBlock=startingBlock; - if(currentBlock==null) throw ParseErrorRPCException.INSTANCE; + if(currentBlock==null) throw new ParseErrorRPCException("Missing field(currentBlock) on type(SyncInfo)"); this.currentBlock=currentBlock; - if(highestBlock==null) throw ParseErrorRPCException.INSTANCE; + if(highestBlock==null) throw new ParseErrorRPCException("Missing field(highestBlock) on type(SyncInfo)"); this.highestBlock=highestBlock; } } @@ -733,7 +733,7 @@ public Response(Integer id ,Object result ,RpcError error ,VersionType jsonrpc ) this.id=id; this.result=result; this.error=error; - if(jsonrpc==null) throw ParseErrorRPCException.INSTANCE; + if(jsonrpc==null) throw new ParseErrorRPCException("Missing field(jsonrpc) on type(Response)"); this.jsonrpc=jsonrpc; } } @@ -745,9 +745,9 @@ public static final class RpcError { public final String message; public RpcError(Integer code ,String message ){ - if(code==null) throw ParseErrorRPCException.INSTANCE; + if(code==null) throw new ParseErrorRPCException("Missing field(code) on type(RpcError)"); this.code=code; - if(message==null) throw ParseErrorRPCException.INSTANCE; + if(message==null) throw new ParseErrorRPCException("Missing field(message) on type(RpcError)"); this.message=message; } } @@ -759,15 +759,15 @@ public static final class TxLogDetails { public final Long blockNumber; public TxLogDetails(AionAddress address ,Integer transactionIndex ,ByteArray data ,ByteArray[] topics ,Long blockNumber ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on type(TxLogDetails)"); this.address=address; - if(transactionIndex==null) throw ParseErrorRPCException.INSTANCE; + if(transactionIndex==null) throw new ParseErrorRPCException("Missing field(transactionIndex) on type(TxLogDetails)"); this.transactionIndex=transactionIndex; - if(data==null) throw ParseErrorRPCException.INSTANCE; + if(data==null) throw new ParseErrorRPCException("Missing field(data) on type(TxLogDetails)"); this.data=data; - if(topics==null) throw ParseErrorRPCException.INSTANCE; + if(topics==null) throw new ParseErrorRPCException("Missing field(topics) on type(TxLogDetails)"); this.topics=topics; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(TxLogDetails)"); this.blockNumber=blockNumber; } } @@ -797,44 +797,44 @@ public static final class TxDetails { public TxDetails(AionAddress contractAddress ,ByteArray hash ,Integer transactionIndex ,BigInteger value ,Long nrg ,Long nrgPrice ,Long gas ,Long gasPrice ,Long nonce ,AionAddress from ,AionAddress to ,Long timestamp ,ByteArray input ,Long blockNumber ,ByteArray blockHash ,String error ,Byte type ,Long nrgUsed ,Long gasUsed ,Boolean hasInternalTransactions ,TxLogDetails[] logs ,ByteArray beaconHash ){ this.contractAddress=contractAddress; - if(hash==null) throw ParseErrorRPCException.INSTANCE; + if(hash==null) throw new ParseErrorRPCException("Missing field(hash) on type(TxDetails)"); this.hash=hash; - if(transactionIndex==null) throw ParseErrorRPCException.INSTANCE; + if(transactionIndex==null) throw new ParseErrorRPCException("Missing field(transactionIndex) on type(TxDetails)"); this.transactionIndex=transactionIndex; - if(value==null) throw ParseErrorRPCException.INSTANCE; + if(value==null) throw new ParseErrorRPCException("Missing field(value) on type(TxDetails)"); this.value=value; - if(nrg==null) throw ParseErrorRPCException.INSTANCE; + if(nrg==null) throw new ParseErrorRPCException("Missing field(nrg) on type(TxDetails)"); this.nrg=nrg; - if(nrgPrice==null) throw ParseErrorRPCException.INSTANCE; + if(nrgPrice==null) throw new ParseErrorRPCException("Missing field(nrgPrice) on type(TxDetails)"); this.nrgPrice=nrgPrice; - if(gas==null) throw ParseErrorRPCException.INSTANCE; + if(gas==null) throw new ParseErrorRPCException("Missing field(gas) on type(TxDetails)"); this.gas=gas; - if(gasPrice==null) throw ParseErrorRPCException.INSTANCE; + if(gasPrice==null) throw new ParseErrorRPCException("Missing field(gasPrice) on type(TxDetails)"); this.gasPrice=gasPrice; - if(nonce==null) throw ParseErrorRPCException.INSTANCE; + if(nonce==null) throw new ParseErrorRPCException("Missing field(nonce) on type(TxDetails)"); this.nonce=nonce; - if(from==null) throw ParseErrorRPCException.INSTANCE; + if(from==null) throw new ParseErrorRPCException("Missing field(from) on type(TxDetails)"); this.from=from; this.to=to; - if(timestamp==null) throw ParseErrorRPCException.INSTANCE; + if(timestamp==null) throw new ParseErrorRPCException("Missing field(timestamp) on type(TxDetails)"); this.timestamp=timestamp; - if(input==null) throw ParseErrorRPCException.INSTANCE; + if(input==null) throw new ParseErrorRPCException("Missing field(input) on type(TxDetails)"); this.input=input; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(TxDetails)"); this.blockNumber=blockNumber; - if(blockHash==null) throw ParseErrorRPCException.INSTANCE; + if(blockHash==null) throw new ParseErrorRPCException("Missing field(blockHash) on type(TxDetails)"); this.blockHash=blockHash; - if(error==null) throw ParseErrorRPCException.INSTANCE; + if(error==null) throw new ParseErrorRPCException("Missing field(error) on type(TxDetails)"); this.error=error; - if(type==null) throw ParseErrorRPCException.INSTANCE; + if(type==null) throw new ParseErrorRPCException("Missing field(type) on type(TxDetails)"); this.type=type; - if(nrgUsed==null) throw ParseErrorRPCException.INSTANCE; + if(nrgUsed==null) throw new ParseErrorRPCException("Missing field(nrgUsed) on type(TxDetails)"); this.nrgUsed=nrgUsed; - if(gasUsed==null) throw ParseErrorRPCException.INSTANCE; + if(gasUsed==null) throw new ParseErrorRPCException("Missing field(gasUsed) on type(TxDetails)"); this.gasUsed=gasUsed; - if(hasInternalTransactions==null) throw ParseErrorRPCException.INSTANCE; + if(hasInternalTransactions==null) throw new ParseErrorRPCException("Missing field(hasInternalTransactions) on type(TxDetails)"); this.hasInternalTransactions=hasInternalTransactions; - if(logs==null) throw ParseErrorRPCException.INSTANCE; + if(logs==null) throw new ParseErrorRPCException("Missing field(logs) on type(TxDetails)"); this.logs=logs; this.beaconHash=beaconHash; } @@ -855,7 +855,7 @@ public static final class TxCall { public static final Byte typeDefaultValue=ByteConverter.decode("0x01"); public TxCall(AionAddress from ,AionAddress to ,ByteArray data ,BigInteger nonce ,BigInteger value ,Long gas ,Long gasPrice ,ByteArray beaconHash ,Byte type ){ - if(from==null) throw ParseErrorRPCException.INSTANCE; + if(from==null) throw new ParseErrorRPCException("Missing field(from) on type(TxCall)"); this.from=from; this.to=to; this.data=data==null? dataDefaultValue:data; @@ -899,51 +899,51 @@ public static final class BlockDetails { public final Integer blockTime; public BlockDetails(Long number ,ByteArray hash ,ByteArray parentHash ,ByteArray logsBloom ,ByteArray transactionsRoot ,ByteArray stateRoot ,ByteArray receiptsRoot ,BigInteger difficulty ,BigInteger totalDifficulty ,AionAddress miner ,Long timestamp ,Long gasUsed ,Long gasLimit ,Long nrgUsed ,Long nrgLimit ,Byte sealType ,Boolean mainChain ,ByteArray extraData ,Integer size ,Integer numTransactions ,ByteArray txTrieRoot ,BigInteger blockReward ,TxDetails[] transactions ,ByteArray nonce ,ByteArray solution ,ByteArray seed ,ByteArray signature ,ByteArray publicKey ,Integer blockTime ){ - if(number==null) throw ParseErrorRPCException.INSTANCE; + if(number==null) throw new ParseErrorRPCException("Missing field(number) on type(BlockDetails)"); this.number=number; - if(hash==null) throw ParseErrorRPCException.INSTANCE; + if(hash==null) throw new ParseErrorRPCException("Missing field(hash) on type(BlockDetails)"); this.hash=hash; - if(parentHash==null) throw ParseErrorRPCException.INSTANCE; + if(parentHash==null) throw new ParseErrorRPCException("Missing field(parentHash) on type(BlockDetails)"); this.parentHash=parentHash; - if(logsBloom==null) throw ParseErrorRPCException.INSTANCE; + if(logsBloom==null) throw new ParseErrorRPCException("Missing field(logsBloom) on type(BlockDetails)"); this.logsBloom=logsBloom; - if(transactionsRoot==null) throw ParseErrorRPCException.INSTANCE; + if(transactionsRoot==null) throw new ParseErrorRPCException("Missing field(transactionsRoot) on type(BlockDetails)"); this.transactionsRoot=transactionsRoot; - if(stateRoot==null) throw ParseErrorRPCException.INSTANCE; + if(stateRoot==null) throw new ParseErrorRPCException("Missing field(stateRoot) on type(BlockDetails)"); this.stateRoot=stateRoot; - if(receiptsRoot==null) throw ParseErrorRPCException.INSTANCE; + if(receiptsRoot==null) throw new ParseErrorRPCException("Missing field(receiptsRoot) on type(BlockDetails)"); this.receiptsRoot=receiptsRoot; - if(difficulty==null) throw ParseErrorRPCException.INSTANCE; + if(difficulty==null) throw new ParseErrorRPCException("Missing field(difficulty) on type(BlockDetails)"); this.difficulty=difficulty; - if(totalDifficulty==null) throw ParseErrorRPCException.INSTANCE; + if(totalDifficulty==null) throw new ParseErrorRPCException("Missing field(totalDifficulty) on type(BlockDetails)"); this.totalDifficulty=totalDifficulty; - if(miner==null) throw ParseErrorRPCException.INSTANCE; + if(miner==null) throw new ParseErrorRPCException("Missing field(miner) on type(BlockDetails)"); this.miner=miner; - if(timestamp==null) throw ParseErrorRPCException.INSTANCE; + if(timestamp==null) throw new ParseErrorRPCException("Missing field(timestamp) on type(BlockDetails)"); this.timestamp=timestamp; - if(gasUsed==null) throw ParseErrorRPCException.INSTANCE; + if(gasUsed==null) throw new ParseErrorRPCException("Missing field(gasUsed) on type(BlockDetails)"); this.gasUsed=gasUsed; - if(gasLimit==null) throw ParseErrorRPCException.INSTANCE; + if(gasLimit==null) throw new ParseErrorRPCException("Missing field(gasLimit) on type(BlockDetails)"); this.gasLimit=gasLimit; - if(nrgUsed==null) throw ParseErrorRPCException.INSTANCE; + if(nrgUsed==null) throw new ParseErrorRPCException("Missing field(nrgUsed) on type(BlockDetails)"); this.nrgUsed=nrgUsed; - if(nrgLimit==null) throw ParseErrorRPCException.INSTANCE; + if(nrgLimit==null) throw new ParseErrorRPCException("Missing field(nrgLimit) on type(BlockDetails)"); this.nrgLimit=nrgLimit; - if(sealType==null) throw ParseErrorRPCException.INSTANCE; + if(sealType==null) throw new ParseErrorRPCException("Missing field(sealType) on type(BlockDetails)"); this.sealType=sealType; - if(mainChain==null) throw ParseErrorRPCException.INSTANCE; + if(mainChain==null) throw new ParseErrorRPCException("Missing field(mainChain) on type(BlockDetails)"); this.mainChain=mainChain; - if(extraData==null) throw ParseErrorRPCException.INSTANCE; + if(extraData==null) throw new ParseErrorRPCException("Missing field(extraData) on type(BlockDetails)"); this.extraData=extraData; - if(size==null) throw ParseErrorRPCException.INSTANCE; + if(size==null) throw new ParseErrorRPCException("Missing field(size) on type(BlockDetails)"); this.size=size; - if(numTransactions==null) throw ParseErrorRPCException.INSTANCE; + if(numTransactions==null) throw new ParseErrorRPCException("Missing field(numTransactions) on type(BlockDetails)"); this.numTransactions=numTransactions; - if(txTrieRoot==null) throw ParseErrorRPCException.INSTANCE; + if(txTrieRoot==null) throw new ParseErrorRPCException("Missing field(txTrieRoot) on type(BlockDetails)"); this.txTrieRoot=txTrieRoot; - if(blockReward==null) throw ParseErrorRPCException.INSTANCE; + if(blockReward==null) throw new ParseErrorRPCException("Missing field(blockReward) on type(BlockDetails)"); this.blockReward=blockReward; - if(transactions==null) throw ParseErrorRPCException.INSTANCE; + if(transactions==null) throw new ParseErrorRPCException("Missing field(transactions) on type(BlockDetails)"); this.transactions=transactions; this.nonce=nonce; this.solution=solution; @@ -962,17 +962,17 @@ public static final class BlockTemplate { public final BigInteger blockTxFee; public BlockTemplate(ByteArray previousblockhash ,Long height ,BigInteger target ,ByteArray headerHash ,BigInteger blockBaseReward ,BigInteger blockTxFee ){ - if(previousblockhash==null) throw ParseErrorRPCException.INSTANCE; + if(previousblockhash==null) throw new ParseErrorRPCException("Missing field(previousblockhash) on type(BlockTemplate)"); this.previousblockhash=previousblockhash; - if(height==null) throw ParseErrorRPCException.INSTANCE; + if(height==null) throw new ParseErrorRPCException("Missing field(height) on type(BlockTemplate)"); this.height=height; - if(target==null) throw ParseErrorRPCException.INSTANCE; + if(target==null) throw new ParseErrorRPCException("Missing field(target) on type(BlockTemplate)"); this.target=target; - if(headerHash==null) throw ParseErrorRPCException.INSTANCE; + if(headerHash==null) throw new ParseErrorRPCException("Missing field(headerHash) on type(BlockTemplate)"); this.headerHash=headerHash; - if(blockBaseReward==null) throw ParseErrorRPCException.INSTANCE; + if(blockBaseReward==null) throw new ParseErrorRPCException("Missing field(blockBaseReward) on type(BlockTemplate)"); this.blockBaseReward=blockBaseReward; - if(blockTxFee==null) throw ParseErrorRPCException.INSTANCE; + if(blockTxFee==null) throw new ParseErrorRPCException("Missing field(blockTxFee) on type(BlockTemplate)"); this.blockTxFee=blockTxFee; } } @@ -980,7 +980,7 @@ public static final class SubmissionResult { public final Boolean result; public SubmissionResult(Boolean result ){ - if(result==null) throw ParseErrorRPCException.INSTANCE; + if(result==null) throw new ParseErrorRPCException("Missing field(result) on type(SubmissionResult)"); this.result=result; } } @@ -990,11 +990,11 @@ public static final class ValidateAddressResult { public final Boolean ismine; public ValidateAddressResult(Boolean isvalid ,AionAddress address ,Boolean ismine ){ - if(isvalid==null) throw ParseErrorRPCException.INSTANCE; + if(isvalid==null) throw new ParseErrorRPCException("Missing field(isvalid) on type(ValidateAddressResult)"); this.isvalid=isvalid; - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on type(ValidateAddressResult)"); this.address=address; - if(ismine==null) throw ParseErrorRPCException.INSTANCE; + if(ismine==null) throw new ParseErrorRPCException("Missing field(ismine) on type(ValidateAddressResult)"); this.ismine=ismine; } } @@ -1004,11 +1004,11 @@ public static final class MinerStats { public final String minerHashrateShare; public MinerStats(String networkHashRate ,String minerHashrate ,String minerHashrateShare ){ - if(networkHashRate==null) throw ParseErrorRPCException.INSTANCE; + if(networkHashRate==null) throw new ParseErrorRPCException("Missing field(networkHashRate) on type(MinerStats)"); this.networkHashRate=networkHashRate; - if(minerHashrate==null) throw ParseErrorRPCException.INSTANCE; + if(minerHashrate==null) throw new ParseErrorRPCException("Missing field(minerHashrate) on type(MinerStats)"); this.minerHashrate=minerHashrate; - if(minerHashrateShare==null) throw ParseErrorRPCException.INSTANCE; + if(minerHashrateShare==null) throw new ParseErrorRPCException("Missing field(minerHashrateShare) on type(MinerStats)"); this.minerHashrateShare=minerHashrateShare; } } @@ -1019,13 +1019,13 @@ public static final class TxLog { public final ByteArray[] topics; public TxLog(AionAddress address ,Integer transactionIndex ,ByteArray data ,ByteArray[] topics ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on type(TxLog)"); this.address=address; - if(transactionIndex==null) throw ParseErrorRPCException.INSTANCE; + if(transactionIndex==null) throw new ParseErrorRPCException("Missing field(transactionIndex) on type(TxLog)"); this.transactionIndex=transactionIndex; - if(data==null) throw ParseErrorRPCException.INSTANCE; + if(data==null) throw new ParseErrorRPCException("Missing field(data) on type(TxLog)"); this.data=data; - if(topics==null) throw ParseErrorRPCException.INSTANCE; + if(topics==null) throw new ParseErrorRPCException("Missing field(topics) on type(TxLog)"); this.topics=topics; } } @@ -1036,13 +1036,13 @@ public static final class AccountState { public final BigInteger nonce; public AccountState(AionAddress address ,Long blockNumber ,BigInteger balance ,BigInteger nonce ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on type(AccountState)"); this.address=address; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(AccountState)"); this.blockNumber=blockNumber; - if(balance==null) throw ParseErrorRPCException.INSTANCE; + if(balance==null) throw new ParseErrorRPCException("Missing field(balance) on type(AccountState)"); this.balance=balance; - if(nonce==null) throw ParseErrorRPCException.INSTANCE; + if(nonce==null) throw new ParseErrorRPCException("Missing field(nonce) on type(AccountState)"); this.nonce=nonce; } } @@ -1063,27 +1063,27 @@ public static final class EthTransaction { public final ByteArray blockHash; public EthTransaction(ByteArray hash ,Integer transactionIndex ,Long nrg ,Long nrgPrice ,Long gas ,Long gasPrice ,AionAddress contractAddress ,AionAddress from ,AionAddress to ,Long timestamp ,ByteArray input ,Long blockNumber ,ByteArray blockHash ){ - if(hash==null) throw ParseErrorRPCException.INSTANCE; + if(hash==null) throw new ParseErrorRPCException("Missing field(hash) on type(EthTransaction)"); this.hash=hash; this.transactionIndex=transactionIndex; - if(nrg==null) throw ParseErrorRPCException.INSTANCE; + if(nrg==null) throw new ParseErrorRPCException("Missing field(nrg) on type(EthTransaction)"); this.nrg=nrg; - if(nrgPrice==null) throw ParseErrorRPCException.INSTANCE; + if(nrgPrice==null) throw new ParseErrorRPCException("Missing field(nrgPrice) on type(EthTransaction)"); this.nrgPrice=nrgPrice; - if(gas==null) throw ParseErrorRPCException.INSTANCE; + if(gas==null) throw new ParseErrorRPCException("Missing field(gas) on type(EthTransaction)"); this.gas=gas; - if(gasPrice==null) throw ParseErrorRPCException.INSTANCE; + if(gasPrice==null) throw new ParseErrorRPCException("Missing field(gasPrice) on type(EthTransaction)"); this.gasPrice=gasPrice; this.contractAddress=contractAddress; - if(from==null) throw ParseErrorRPCException.INSTANCE; + if(from==null) throw new ParseErrorRPCException("Missing field(from) on type(EthTransaction)"); this.from=from; this.to=to; - if(timestamp==null) throw ParseErrorRPCException.INSTANCE; + if(timestamp==null) throw new ParseErrorRPCException("Missing field(timestamp) on type(EthTransaction)"); this.timestamp=timestamp; this.input=input==null? inputDefaultValue:input; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(EthTransaction)"); this.blockNumber=blockNumber; - if(blockHash==null) throw ParseErrorRPCException.INSTANCE; + if(blockHash==null) throw new ParseErrorRPCException("Missing field(blockHash) on type(EthTransaction)"); this.blockHash=blockHash; } } @@ -1103,25 +1103,25 @@ public static final class EthTransactionForBlock { public final Long blockNumber; public EthTransactionForBlock(ByteArray hash ,Integer transactionIndex ,Long nrg ,Long nrgPrice ,Long gas ,Long gasPrice ,AionAddress contractAddress ,AionAddress from ,AionAddress to ,Long timestamp ,ByteArray input ,Long blockNumber ){ - if(hash==null) throw ParseErrorRPCException.INSTANCE; + if(hash==null) throw new ParseErrorRPCException("Missing field(hash) on type(EthTransactionForBlock)"); this.hash=hash; this.transactionIndex=transactionIndex; - if(nrg==null) throw ParseErrorRPCException.INSTANCE; + if(nrg==null) throw new ParseErrorRPCException("Missing field(nrg) on type(EthTransactionForBlock)"); this.nrg=nrg; - if(nrgPrice==null) throw ParseErrorRPCException.INSTANCE; + if(nrgPrice==null) throw new ParseErrorRPCException("Missing field(nrgPrice) on type(EthTransactionForBlock)"); this.nrgPrice=nrgPrice; - if(gas==null) throw ParseErrorRPCException.INSTANCE; + if(gas==null) throw new ParseErrorRPCException("Missing field(gas) on type(EthTransactionForBlock)"); this.gas=gas; - if(gasPrice==null) throw ParseErrorRPCException.INSTANCE; + if(gasPrice==null) throw new ParseErrorRPCException("Missing field(gasPrice) on type(EthTransactionForBlock)"); this.gasPrice=gasPrice; this.contractAddress=contractAddress; - if(from==null) throw ParseErrorRPCException.INSTANCE; + if(from==null) throw new ParseErrorRPCException("Missing field(from) on type(EthTransactionForBlock)"); this.from=from; this.to=to; - if(timestamp==null) throw ParseErrorRPCException.INSTANCE; + if(timestamp==null) throw new ParseErrorRPCException("Missing field(timestamp) on type(EthTransactionForBlock)"); this.timestamp=timestamp; this.input=input==null? inputDefaultValue:input; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(EthTransactionForBlock)"); this.blockNumber=blockNumber; } } @@ -1146,39 +1146,39 @@ public static final class EthTransactionReceipt { public final EthTxReceiptLogs[] logs; public EthTransactionReceipt(ByteArray transactionHash ,Integer transactionIndex ,Long blockNumber ,ByteArray blockHash ,Long nrgUsed ,Long nrgPrice ,Long gasUsed ,Long gasPrice ,Long gasLimit ,Long cumulativeNrgUsed ,Long cumulativeGasUsed ,AionAddress contractAddress ,AionAddress from ,AionAddress to ,ByteArray logsBloom ,ByteArray root ,Byte status ,EthTxReceiptLogs[] logs ){ - if(transactionHash==null) throw ParseErrorRPCException.INSTANCE; + if(transactionHash==null) throw new ParseErrorRPCException("Missing field(transactionHash) on type(EthTransactionReceipt)"); this.transactionHash=transactionHash; - if(transactionIndex==null) throw ParseErrorRPCException.INSTANCE; + if(transactionIndex==null) throw new ParseErrorRPCException("Missing field(transactionIndex) on type(EthTransactionReceipt)"); this.transactionIndex=transactionIndex; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(EthTransactionReceipt)"); this.blockNumber=blockNumber; - if(blockHash==null) throw ParseErrorRPCException.INSTANCE; + if(blockHash==null) throw new ParseErrorRPCException("Missing field(blockHash) on type(EthTransactionReceipt)"); this.blockHash=blockHash; - if(nrgUsed==null) throw ParseErrorRPCException.INSTANCE; + if(nrgUsed==null) throw new ParseErrorRPCException("Missing field(nrgUsed) on type(EthTransactionReceipt)"); this.nrgUsed=nrgUsed; - if(nrgPrice==null) throw ParseErrorRPCException.INSTANCE; + if(nrgPrice==null) throw new ParseErrorRPCException("Missing field(nrgPrice) on type(EthTransactionReceipt)"); this.nrgPrice=nrgPrice; - if(gasUsed==null) throw ParseErrorRPCException.INSTANCE; + if(gasUsed==null) throw new ParseErrorRPCException("Missing field(gasUsed) on type(EthTransactionReceipt)"); this.gasUsed=gasUsed; - if(gasPrice==null) throw ParseErrorRPCException.INSTANCE; + if(gasPrice==null) throw new ParseErrorRPCException("Missing field(gasPrice) on type(EthTransactionReceipt)"); this.gasPrice=gasPrice; - if(gasLimit==null) throw ParseErrorRPCException.INSTANCE; + if(gasLimit==null) throw new ParseErrorRPCException("Missing field(gasLimit) on type(EthTransactionReceipt)"); this.gasLimit=gasLimit; - if(cumulativeNrgUsed==null) throw ParseErrorRPCException.INSTANCE; + if(cumulativeNrgUsed==null) throw new ParseErrorRPCException("Missing field(cumulativeNrgUsed) on type(EthTransactionReceipt)"); this.cumulativeNrgUsed=cumulativeNrgUsed; - if(cumulativeGasUsed==null) throw ParseErrorRPCException.INSTANCE; + if(cumulativeGasUsed==null) throw new ParseErrorRPCException("Missing field(cumulativeGasUsed) on type(EthTransactionReceipt)"); this.cumulativeGasUsed=cumulativeGasUsed; this.contractAddress=contractAddress; - if(from==null) throw ParseErrorRPCException.INSTANCE; + if(from==null) throw new ParseErrorRPCException("Missing field(from) on type(EthTransactionReceipt)"); this.from=from; this.to=to; - if(logsBloom==null) throw ParseErrorRPCException.INSTANCE; + if(logsBloom==null) throw new ParseErrorRPCException("Missing field(logsBloom) on type(EthTransactionReceipt)"); this.logsBloom=logsBloom; - if(root==null) throw ParseErrorRPCException.INSTANCE; + if(root==null) throw new ParseErrorRPCException("Missing field(root) on type(EthTransactionReceipt)"); this.root=root; - if(status==null) throw ParseErrorRPCException.INSTANCE; + if(status==null) throw new ParseErrorRPCException("Missing field(status) on type(EthTransactionReceipt)"); this.status=status; - if(logs==null) throw ParseErrorRPCException.INSTANCE; + if(logs==null) throw new ParseErrorRPCException("Missing field(logs) on type(EthTransactionReceipt)"); this.logs=logs; } } @@ -1191,17 +1191,17 @@ public static final class EthTxReceiptLogs { public final ByteArray[] topics; public EthTxReceiptLogs(AionAddress address ,ByteArray data ,Long blockNumber ,Integer transactionIndex ,Integer logIndex ,ByteArray[] topics ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on type(EthTxReceiptLogs)"); this.address=address; - if(data==null) throw ParseErrorRPCException.INSTANCE; + if(data==null) throw new ParseErrorRPCException("Missing field(data) on type(EthTxReceiptLogs)"); this.data=data; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(EthTxReceiptLogs)"); this.blockNumber=blockNumber; - if(transactionIndex==null) throw ParseErrorRPCException.INSTANCE; + if(transactionIndex==null) throw new ParseErrorRPCException("Missing field(transactionIndex) on type(EthTxReceiptLogs)"); this.transactionIndex=transactionIndex; - if(logIndex==null) throw ParseErrorRPCException.INSTANCE; + if(logIndex==null) throw new ParseErrorRPCException("Missing field(logIndex) on type(EthTxReceiptLogs)"); this.logIndex=logIndex; - if(topics==null) throw ParseErrorRPCException.INSTANCE; + if(topics==null) throw new ParseErrorRPCException("Missing field(topics) on type(EthTxReceiptLogs)"); this.topics=topics; } } @@ -1232,43 +1232,43 @@ public static final class EthBlock { public final ByteArray publicKey; public EthBlock(Long number ,ByteArray hash ,ByteArray parentHash ,ByteArray logsBloom ,ByteArray transactionsRoot ,ByteArray stateRoot ,ByteArray receiptsRoot ,BigInteger difficulty ,BigInteger totalDifficulty ,Long timestamp ,AionAddress miner ,Long gasUsed ,Long gasLimit ,Long nrgUsed ,Long nrgLimit ,Byte sealType ,Boolean mainChain ,Integer size ,TransactionUnion transactions ,ByteArray nonce ,ByteArray solution ,ByteArray seed ,ByteArray signature ,ByteArray publicKey ){ - if(number==null) throw ParseErrorRPCException.INSTANCE; + if(number==null) throw new ParseErrorRPCException("Missing field(number) on type(EthBlock)"); this.number=number; - if(hash==null) throw ParseErrorRPCException.INSTANCE; + if(hash==null) throw new ParseErrorRPCException("Missing field(hash) on type(EthBlock)"); this.hash=hash; - if(parentHash==null) throw ParseErrorRPCException.INSTANCE; + if(parentHash==null) throw new ParseErrorRPCException("Missing field(parentHash) on type(EthBlock)"); this.parentHash=parentHash; - if(logsBloom==null) throw ParseErrorRPCException.INSTANCE; + if(logsBloom==null) throw new ParseErrorRPCException("Missing field(logsBloom) on type(EthBlock)"); this.logsBloom=logsBloom; - if(transactionsRoot==null) throw ParseErrorRPCException.INSTANCE; + if(transactionsRoot==null) throw new ParseErrorRPCException("Missing field(transactionsRoot) on type(EthBlock)"); this.transactionsRoot=transactionsRoot; - if(stateRoot==null) throw ParseErrorRPCException.INSTANCE; + if(stateRoot==null) throw new ParseErrorRPCException("Missing field(stateRoot) on type(EthBlock)"); this.stateRoot=stateRoot; - if(receiptsRoot==null) throw ParseErrorRPCException.INSTANCE; + if(receiptsRoot==null) throw new ParseErrorRPCException("Missing field(receiptsRoot) on type(EthBlock)"); this.receiptsRoot=receiptsRoot; - if(difficulty==null) throw ParseErrorRPCException.INSTANCE; + if(difficulty==null) throw new ParseErrorRPCException("Missing field(difficulty) on type(EthBlock)"); this.difficulty=difficulty; - if(totalDifficulty==null) throw ParseErrorRPCException.INSTANCE; + if(totalDifficulty==null) throw new ParseErrorRPCException("Missing field(totalDifficulty) on type(EthBlock)"); this.totalDifficulty=totalDifficulty; - if(timestamp==null) throw ParseErrorRPCException.INSTANCE; + if(timestamp==null) throw new ParseErrorRPCException("Missing field(timestamp) on type(EthBlock)"); this.timestamp=timestamp; - if(miner==null) throw ParseErrorRPCException.INSTANCE; + if(miner==null) throw new ParseErrorRPCException("Missing field(miner) on type(EthBlock)"); this.miner=miner; - if(gasUsed==null) throw ParseErrorRPCException.INSTANCE; + if(gasUsed==null) throw new ParseErrorRPCException("Missing field(gasUsed) on type(EthBlock)"); this.gasUsed=gasUsed; - if(gasLimit==null) throw ParseErrorRPCException.INSTANCE; + if(gasLimit==null) throw new ParseErrorRPCException("Missing field(gasLimit) on type(EthBlock)"); this.gasLimit=gasLimit; - if(nrgUsed==null) throw ParseErrorRPCException.INSTANCE; + if(nrgUsed==null) throw new ParseErrorRPCException("Missing field(nrgUsed) on type(EthBlock)"); this.nrgUsed=nrgUsed; - if(nrgLimit==null) throw ParseErrorRPCException.INSTANCE; + if(nrgLimit==null) throw new ParseErrorRPCException("Missing field(nrgLimit) on type(EthBlock)"); this.nrgLimit=nrgLimit; - if(sealType==null) throw ParseErrorRPCException.INSTANCE; + if(sealType==null) throw new ParseErrorRPCException("Missing field(sealType) on type(EthBlock)"); this.sealType=sealType; - if(mainChain==null) throw ParseErrorRPCException.INSTANCE; + if(mainChain==null) throw new ParseErrorRPCException("Missing field(mainChain) on type(EthBlock)"); this.mainChain=mainChain; - if(size==null) throw ParseErrorRPCException.INSTANCE; + if(size==null) throw new ParseErrorRPCException("Missing field(size) on type(EthBlock)"); this.size=size; - if(transactions==null) throw ParseErrorRPCException.INSTANCE; + if(transactions==null) throw new ParseErrorRPCException("Missing field(transactions) on type(EthBlock)"); this.transactions=transactions; this.nonce=nonce; this.solution=solution; @@ -1294,33 +1294,33 @@ public static final class OpsTransaction { public final TxLog[] logs; public OpsTransaction(Long timestampVal ,ByteArray transactionHash ,Long blockNumber ,ByteArray blockHash ,BigInteger nonce ,AionAddress fromAddr ,AionAddress toAddr ,BigInteger value ,Long nrgPrice ,Long nrgConsumed ,ByteArray data ,Integer transactionIndex ,ByteArray beaconHash ,TxLog[] logs ){ - if(timestampVal==null) throw ParseErrorRPCException.INSTANCE; + if(timestampVal==null) throw new ParseErrorRPCException("Missing field(timestampVal) on type(OpsTransaction)"); this.timestampVal=timestampVal; - if(transactionHash==null) throw ParseErrorRPCException.INSTANCE; + if(transactionHash==null) throw new ParseErrorRPCException("Missing field(transactionHash) on type(OpsTransaction)"); this.transactionHash=transactionHash; - if(blockNumber==null) throw ParseErrorRPCException.INSTANCE; + if(blockNumber==null) throw new ParseErrorRPCException("Missing field(blockNumber) on type(OpsTransaction)"); this.blockNumber=blockNumber; - if(blockHash==null) throw ParseErrorRPCException.INSTANCE; + if(blockHash==null) throw new ParseErrorRPCException("Missing field(blockHash) on type(OpsTransaction)"); this.blockHash=blockHash; - if(nonce==null) throw ParseErrorRPCException.INSTANCE; + if(nonce==null) throw new ParseErrorRPCException("Missing field(nonce) on type(OpsTransaction)"); this.nonce=nonce; - if(fromAddr==null) throw ParseErrorRPCException.INSTANCE; + if(fromAddr==null) throw new ParseErrorRPCException("Missing field(fromAddr) on type(OpsTransaction)"); this.fromAddr=fromAddr; - if(toAddr==null) throw ParseErrorRPCException.INSTANCE; + if(toAddr==null) throw new ParseErrorRPCException("Missing field(toAddr) on type(OpsTransaction)"); this.toAddr=toAddr; - if(value==null) throw ParseErrorRPCException.INSTANCE; + if(value==null) throw new ParseErrorRPCException("Missing field(value) on type(OpsTransaction)"); this.value=value; - if(nrgPrice==null) throw ParseErrorRPCException.INSTANCE; + if(nrgPrice==null) throw new ParseErrorRPCException("Missing field(nrgPrice) on type(OpsTransaction)"); this.nrgPrice=nrgPrice; - if(nrgConsumed==null) throw ParseErrorRPCException.INSTANCE; + if(nrgConsumed==null) throw new ParseErrorRPCException("Missing field(nrgConsumed) on type(OpsTransaction)"); this.nrgConsumed=nrgConsumed; - if(data==null) throw ParseErrorRPCException.INSTANCE; + if(data==null) throw new ParseErrorRPCException("Missing field(data) on type(OpsTransaction)"); this.data=data; - if(transactionIndex==null) throw ParseErrorRPCException.INSTANCE; + if(transactionIndex==null) throw new ParseErrorRPCException("Missing field(transactionIndex) on type(OpsTransaction)"); this.transactionIndex=transactionIndex; - if(beaconHash==null) throw ParseErrorRPCException.INSTANCE; + if(beaconHash==null) throw new ParseErrorRPCException("Missing field(beaconHash) on type(OpsTransaction)"); this.beaconHash=beaconHash; - if(logs==null) throw ParseErrorRPCException.INSTANCE; + if(logs==null) throw new ParseErrorRPCException("Missing field(logs) on type(OpsTransaction)"); this.logs=logs; } } @@ -1333,11 +1333,11 @@ public enum VersionType{ } public static VersionType fromString(String x){ - if(x==null) throw ParseErrorRPCException.INSTANCE; + if(x==null) throw new ParseErrorRPCException(); if(x.equals("2.0")){ return Version2; }else - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } public enum BlockEnum{ @@ -1348,11 +1348,11 @@ public enum BlockEnum{ } public static BlockEnum fromString(String x){ - if(x==null) throw ParseErrorRPCException.INSTANCE; + if(x==null) throw new ParseErrorRPCException(); if(x.equals("latest")){ return LATEST; }else - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } public enum PongEnum{ @@ -1363,11 +1363,11 @@ public enum PongEnum{ } public static PongEnum fromString(String x){ - if(x==null) throw ParseErrorRPCException.INSTANCE; + if(x==null) throw new ParseErrorRPCException(); if(x.equals("pong")){ return PONG; }else - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } } @@ -1378,9 +1378,9 @@ public static final class EcRecoverParams { public EcRecoverParams(ByteArray dataThatWasSigned ,ByteArray signature ){ - if(dataThatWasSigned==null) throw ParseErrorRPCException.INSTANCE; + if(dataThatWasSigned==null) throw new ParseErrorRPCException("Missing field(dataThatWasSigned) on rpc param type(EcRecoverParams)"); this.dataThatWasSigned= dataThatWasSigned; - if(signature==null) throw ParseErrorRPCException.INSTANCE; + if(signature==null) throw new ParseErrorRPCException("Missing field(signature) on rpc param type(EcRecoverParams)"); this.signature= signature; } } @@ -1397,7 +1397,7 @@ public static final class BlockSpecifierParams { public BlockSpecifierParams(BlockSpecifierUnion block ){ - if(block==null) throw ParseErrorRPCException.INSTANCE; + if(block==null) throw new ParseErrorRPCException("Missing field(block) on rpc param type(BlockSpecifierParams)"); this.block= block; } } @@ -1410,11 +1410,11 @@ public static final class SubmitSeedParams { public SubmitSeedParams(ByteArray newSeed ,ByteArray signingPublicKey ,AionAddress coinbase ){ - if(newSeed==null) throw ParseErrorRPCException.INSTANCE; + if(newSeed==null) throw new ParseErrorRPCException("Missing field(newSeed) on rpc param type(SubmitSeedParams)"); this.newSeed= newSeed; - if(signingPublicKey==null) throw ParseErrorRPCException.INSTANCE; + if(signingPublicKey==null) throw new ParseErrorRPCException("Missing field(signingPublicKey) on rpc param type(SubmitSeedParams)"); this.signingPublicKey= signingPublicKey; - if(coinbase==null) throw ParseErrorRPCException.INSTANCE; + if(coinbase==null) throw new ParseErrorRPCException("Missing field(coinbase) on rpc param type(SubmitSeedParams)"); this.coinbase= coinbase; } } @@ -1425,9 +1425,9 @@ public static final class SubmitSignatureParams { public SubmitSignatureParams(ByteArray signature ,ByteArray sealHash ){ - if(signature==null) throw ParseErrorRPCException.INSTANCE; + if(signature==null) throw new ParseErrorRPCException("Missing field(signature) on rpc param type(SubmitSignatureParams)"); this.signature= signature; - if(sealHash==null) throw ParseErrorRPCException.INSTANCE; + if(sealHash==null) throw new ParseErrorRPCException("Missing field(sealHash) on rpc param type(SubmitSignatureParams)"); this.sealHash= sealHash; } } @@ -1445,11 +1445,11 @@ public static final class SubmitBlockParams { public SubmitBlockParams(ByteArray nonce ,ByteArray solution ,ByteArray headerHash ){ - if(nonce==null) throw ParseErrorRPCException.INSTANCE; + if(nonce==null) throw new ParseErrorRPCException("Missing field(nonce) on rpc param type(SubmitBlockParams)"); this.nonce= nonce; - if(solution==null) throw ParseErrorRPCException.INSTANCE; + if(solution==null) throw new ParseErrorRPCException("Missing field(solution) on rpc param type(SubmitBlockParams)"); this.solution= solution; - if(headerHash==null) throw ParseErrorRPCException.INSTANCE; + if(headerHash==null) throw new ParseErrorRPCException("Missing field(headerHash) on rpc param type(SubmitBlockParams)"); this.headerHash= headerHash; } } @@ -1458,7 +1458,7 @@ public static final class AddressParams { public AddressParams(AionAddress address ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on rpc param type(AddressParams)"); this.address= address; } } @@ -1483,7 +1483,7 @@ public static final class AddressBlockParams { public static final BlockNumberEnumUnion blockDefaultValue=BlockNumberEnumUnionConverter.decode("latest"); public AddressBlockParams(AionAddress address ,BlockNumberEnumUnion block ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on rpc param type(AddressBlockParams)"); this.address= address; this.block= block==null? blockDefaultValue: block; } @@ -1497,9 +1497,9 @@ public static final class UnlockAccountParams { public static final Integer durationDefaultValue=IntConverter.decode("300"); public UnlockAccountParams(AionAddress address ,String password ,Integer duration ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on rpc param type(UnlockAccountParams)"); this.address= address; - if(password==null) throw ParseErrorRPCException.INSTANCE; + if(password==null) throw new ParseErrorRPCException("Missing field(password) on rpc param type(UnlockAccountParams)"); this.password= password; this.duration= duration==null? durationDefaultValue: duration; } @@ -1511,9 +1511,9 @@ public static final class LockAccountParams { public LockAccountParams(AionAddress address ,String password ){ - if(address==null) throw ParseErrorRPCException.INSTANCE; + if(address==null) throw new ParseErrorRPCException("Missing field(address) on rpc param type(LockAccountParams)"); this.address= address; - if(password==null) throw ParseErrorRPCException.INSTANCE; + if(password==null) throw new ParseErrorRPCException("Missing field(password) on rpc param type(LockAccountParams)"); this.password= password; } } @@ -1522,7 +1522,7 @@ public static final class BlockHashParams { public BlockHashParams(ByteArray block ){ - if(block==null) throw ParseErrorRPCException.INSTANCE; + if(block==null) throw new ParseErrorRPCException("Missing field(block) on rpc param type(BlockHashParams)"); this.block= block; } } @@ -1531,7 +1531,7 @@ public static final class TransactionHashParams { public TransactionHashParams(ByteArray hash ){ - if(hash==null) throw ParseErrorRPCException.INSTANCE; + if(hash==null) throw new ParseErrorRPCException("Missing field(hash) on rpc param type(TransactionHashParams)"); this.hash= hash; } } @@ -1540,7 +1540,7 @@ public static final class PasswordParams { public PasswordParams(String password ){ - if(password==null) throw ParseErrorRPCException.INSTANCE; + if(password==null) throw new ParseErrorRPCException("Missing field(password) on rpc param type(PasswordParams)"); this.password= password; } } @@ -1549,7 +1549,7 @@ public static final class BlockNumberParams { public BlockNumberParams(Long block ){ - if(block==null) throw ParseErrorRPCException.INSTANCE; + if(block==null) throw new ParseErrorRPCException("Missing field(block) on rpc param type(BlockNumberParams)"); this.block= block; } } @@ -1560,7 +1560,7 @@ public static final class EthBlockNumberParams { public static final Boolean fullTransactionDefaultValue=BoolConverter.decode("false"); public EthBlockNumberParams(Long block ,Boolean fullTransaction ){ - if(block==null) throw ParseErrorRPCException.INSTANCE; + if(block==null) throw new ParseErrorRPCException("Missing field(block) on rpc param type(EthBlockNumberParams)"); this.block= block; this.fullTransaction= fullTransaction==null? fullTransactionDefaultValue: fullTransaction; } @@ -1572,7 +1572,7 @@ public static final class EthBlockHashParams { public static final Boolean fullTransactionDefaultValue=BoolConverter.decode("false"); public EthBlockHashParams(ByteArray block ,Boolean fullTransaction ){ - if(block==null) throw ParseErrorRPCException.INSTANCE; + if(block==null) throw new ParseErrorRPCException("Missing field(block) on rpc param type(EthBlockHashParams)"); this.block= block; this.fullTransaction= fullTransaction==null? fullTransactionDefaultValue: fullTransaction; } @@ -1584,7 +1584,7 @@ public static final class CallParams { public static final BlockNumberEnumUnion blockDefaultValue=BlockNumberEnumUnionConverter.decode("latest"); public CallParams(TxCall transaction ,BlockNumberEnumUnion block ){ - if(transaction==null) throw ParseErrorRPCException.INSTANCE; + if(transaction==null) throw new ParseErrorRPCException("Missing field(transaction) on rpc param type(CallParams)"); this.transaction= transaction; this.block= block==null? blockDefaultValue: block; } @@ -1594,7 +1594,7 @@ public static final class SendTransactionParams { public SendTransactionParams(TxCall transaction ){ - if(transaction==null) throw ParseErrorRPCException.INSTANCE; + if(transaction==null) throw new ParseErrorRPCException("Missing field(transaction) on rpc param type(SendTransactionParams)"); this.transaction= transaction; } } @@ -1603,7 +1603,7 @@ public static final class SendTransactionRawParams { public SendTransactionRawParams(ByteArray transaction ){ - if(transaction==null) throw ParseErrorRPCException.INSTANCE; + if(transaction==null) throw new ParseErrorRPCException("Missing field(transaction) on rpc param type(SendTransactionRawParams)"); this.transaction= transaction; } } diff --git a/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypesConverter.java b/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypesConverter.java index 25d3f0d..798f77a 100644 --- a/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypesConverter.java +++ b/rpc-lib4j/src/main/java/org/aion/rpc/types/RPCTypesConverter.java @@ -18,7 +18,7 @@ * * AUTO-GENERATED SOURCE FILE. DO NOT EDIT MANUALLY -- YOUR CHANGES WILL * BE WIPED OUT WHEN THIS FILE GETS RE-GENERATED OR UPDATED. -* GENERATED: 2019-12-11 +* GENERATED: 2019-12-10 * *****************************************************************************/ public class RPCTypesConverter{ @@ -542,7 +542,7 @@ public static Request decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new Request( IntConverter.decode(jsonObject.opt("id")) , StringConverter.decode(jsonObject.opt("method")) , AnyConverter.decode(jsonObject.opt("params")) , VersionTypeConverter.decode(jsonObject.opt("jsonrpc")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(request}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -583,7 +583,7 @@ public static SyncInfo decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new SyncInfo( LongHexStringConverter.decode(jsonObject.opt("startingBlock")) , LongHexStringConverter.decode(jsonObject.opt("currentBlock")) , LongHexStringConverter.decode(jsonObject.opt("highestBlock")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(syncInfo}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -622,7 +622,7 @@ public static Response decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new Response( IntConverter.decode(jsonObject.opt("id")) , AnyConverter.decode(jsonObject.opt("result")) , RpcErrorConverter.decode(jsonObject.opt("error")) , VersionTypeConverter.decode(jsonObject.opt("jsonrpc")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(response}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -663,7 +663,7 @@ public static RpcError decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new RpcError( IntConverter.decode(jsonObject.opt("code")) , StringConverter.decode(jsonObject.opt("message")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(rpcError}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -700,7 +700,7 @@ public static TxLogDetails decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new TxLogDetails( AddressConverter.decode(jsonObject.opt("address")) , IntConverter.decode(jsonObject.opt("transactionIndex")) , DataHexStringConverter.decode(jsonObject.opt("data")) , DataHexStringListConverter.decode(jsonObject.opt("topics")) , LongConverter.decode(jsonObject.opt("blockNumber")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(txLogDetails}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -743,7 +743,7 @@ public static TxDetails decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new TxDetails( AddressConverter.decode(jsonObject.opt("contractAddress")) , Byte32StringConverter.decode(jsonObject.opt("hash")) , IntConverter.decode(jsonObject.opt("transactionIndex")) , BigIntHexStringConverter.decode(jsonObject.opt("value")) , LongConverter.decode(jsonObject.opt("nrg")) , LongHexStringConverter.decode(jsonObject.opt("nrgPrice")) , LongConverter.decode(jsonObject.opt("gas")) , LongHexStringConverter.decode(jsonObject.opt("gasPrice")) , LongConverter.decode(jsonObject.opt("nonce")) , AddressConverter.decode(jsonObject.opt("from")) , AddressConverter.decode(jsonObject.opt("to")) , LongConverter.decode(jsonObject.opt("timestamp")) , DataHexStringConverter.decode(jsonObject.opt("input")) , LongHexStringConverter.decode(jsonObject.opt("blockNumber")) , Byte32StringConverter.decode(jsonObject.opt("blockHash")) , StringConverter.decode(jsonObject.opt("error")) , ByteHexStringConverter.decode(jsonObject.opt("type")) , LongHexStringConverter.decode(jsonObject.opt("nrgUsed")) , LongHexStringConverter.decode(jsonObject.opt("gasUsed")) , BoolConverter.decode(jsonObject.opt("hasInternalTransactions")) , TxLogDetailsListConverter.decode(jsonObject.opt("logs")) , Byte32StringConverter.decode(jsonObject.opt("beaconHash")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(txDetails}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -820,7 +820,7 @@ public static TxCall decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new TxCall( AddressConverter.decode(jsonObject.opt("from")) , AddressConverter.decode(jsonObject.opt("to")) , DataHexStringConverter.decode(jsonObject.opt("data")) , BigIntConverter.decode(jsonObject.opt("nonce")) , BigIntConverter.decode(jsonObject.opt("value")) , LongConverter.decode(jsonObject.opt("gas")) , LongConverter.decode(jsonObject.opt("gasPrice")) , Byte32StringConverter.decode(jsonObject.opt("beaconHash")) , ByteConverter.decode(jsonObject.opt("type")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(txCall}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -871,7 +871,7 @@ public static BlockDetails decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new BlockDetails( LongConverter.decode(jsonObject.opt("number")) , Byte32StringConverter.decode(jsonObject.opt("hash")) , Byte32StringConverter.decode(jsonObject.opt("parentHash")) , ByteArrayConverter.decode(jsonObject.opt("logsBloom")) , DataHexStringConverter.decode(jsonObject.opt("transactionsRoot")) , DataHexStringConverter.decode(jsonObject.opt("stateRoot")) , DataHexStringConverter.decode(jsonObject.opt("receiptsRoot")) , BigIntHexStringConverter.decode(jsonObject.opt("difficulty")) , BigIntHexStringConverter.decode(jsonObject.opt("totalDifficulty")) , AddressConverter.decode(jsonObject.opt("miner")) , LongHexStringConverter.decode(jsonObject.opt("timestamp")) , LongHexStringConverter.decode(jsonObject.opt("gasUsed")) , LongHexStringConverter.decode(jsonObject.opt("gasLimit")) , LongHexStringConverter.decode(jsonObject.opt("nrgUsed")) , LongHexStringConverter.decode(jsonObject.opt("nrgLimit")) , ByteHexStringConverter.decode(jsonObject.opt("sealType")) , BoolConverter.decode(jsonObject.opt("mainChain")) , DataHexStringConverter.decode(jsonObject.opt("extraData")) , IntConverter.decode(jsonObject.opt("size")) , IntConverter.decode(jsonObject.opt("numTransactions")) , DataHexStringConverter.decode(jsonObject.opt("txTrieRoot")) , BigIntHexStringConverter.decode(jsonObject.opt("blockReward")) , TxDetailsListConverter.decode(jsonObject.opt("transactions")) , DataHexStringConverter.decode(jsonObject.opt("nonce")) , DataHexStringConverter.decode(jsonObject.opt("solution")) , DataHexStringConverter.decode(jsonObject.opt("seed")) , DataHexStringConverter.decode(jsonObject.opt("signature")) , DataHexStringConverter.decode(jsonObject.opt("publicKey")) , IntConverter.decode(jsonObject.opt("blockTime")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(blockDetails}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -962,7 +962,7 @@ public static BlockTemplate decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new BlockTemplate( Byte32StringConverter.decode(jsonObject.opt("previousblockhash")) , LongConverter.decode(jsonObject.opt("height")) , Uint256HexStringConverter.decode(jsonObject.opt("target")) , Byte32StringConverter.decode(jsonObject.opt("headerHash")) , Uint128HexStringConverter.decode(jsonObject.opt("blockBaseReward")) , Uint128HexStringConverter.decode(jsonObject.opt("blockTxFee")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(blockTemplate}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1007,7 +1007,7 @@ public static SubmissionResult decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new SubmissionResult( BoolConverter.decode(jsonObject.opt("result")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(submissionResult}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1042,7 +1042,7 @@ public static ValidateAddressResult decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new ValidateAddressResult( BoolConverter.decode(jsonObject.opt("isvalid")) , AddressConverter.decode(jsonObject.opt("address")) , BoolConverter.decode(jsonObject.opt("ismine")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(validateAddressResult}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1081,7 +1081,7 @@ public static MinerStats decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new MinerStats( DecimalstringConverter.decode(jsonObject.opt("networkHashRate")) , DecimalstringConverter.decode(jsonObject.opt("minerHashrate")) , DecimalstringConverter.decode(jsonObject.opt("minerHashrateShare")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(minerStats}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1120,7 +1120,7 @@ public static TxLog decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new TxLog( AddressConverter.decode(jsonObject.opt("address")) , IntConverter.decode(jsonObject.opt("transactionIndex")) , DataHexStringConverter.decode(jsonObject.opt("data")) , DataHexStringListConverter.decode(jsonObject.opt("topics")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(txLog}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1161,7 +1161,7 @@ public static AccountState decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new AccountState( AddressConverter.decode(jsonObject.opt("address")) , LongConverter.decode(jsonObject.opt("blockNumber")) , Uint256HexStringConverter.decode(jsonObject.opt("balance")) , Uint256HexStringConverter.decode(jsonObject.opt("nonce")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(accountState}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1202,7 +1202,7 @@ public static EthTransaction decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new EthTransaction( Byte32StringConverter.decode(jsonObject.opt("hash")) , Uint16Converter.decode(jsonObject.opt("transactionIndex")) , Uint32HexStringConverter.decode(jsonObject.opt("nrg")) , Uint32HexStringConverter.decode(jsonObject.opt("nrgPrice")) , Uint32HexStringConverter.decode(jsonObject.opt("gas")) , Uint32HexStringConverter.decode(jsonObject.opt("gasPrice")) , AddressConverter.decode(jsonObject.opt("contractAddress")) , AddressConverter.decode(jsonObject.opt("from")) , AddressConverter.decode(jsonObject.opt("to")) , Uint32Converter.decode(jsonObject.opt("timestamp")) , DataHexStringConverter.decode(jsonObject.opt("input")) , Uint32HexStringConverter.decode(jsonObject.opt("blockNumber")) , Byte32StringConverter.decode(jsonObject.opt("blockHash")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(ethTransaction}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1261,7 +1261,7 @@ public static EthTransactionForBlock decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new EthTransactionForBlock( Byte32StringConverter.decode(jsonObject.opt("hash")) , Uint16Converter.decode(jsonObject.opt("transactionIndex")) , Uint32HexStringConverter.decode(jsonObject.opt("nrg")) , Uint32HexStringConverter.decode(jsonObject.opt("nrgPrice")) , Uint32HexStringConverter.decode(jsonObject.opt("gas")) , Uint32HexStringConverter.decode(jsonObject.opt("gasPrice")) , AddressConverter.decode(jsonObject.opt("contractAddress")) , AddressConverter.decode(jsonObject.opt("from")) , AddressConverter.decode(jsonObject.opt("to")) , Uint32Converter.decode(jsonObject.opt("timestamp")) , DataHexStringConverter.decode(jsonObject.opt("input")) , Uint32Converter.decode(jsonObject.opt("blockNumber")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(ethTransactionForBlock}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1318,7 +1318,7 @@ public static EthTransactionReceipt decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new EthTransactionReceipt( Byte32StringConverter.decode(jsonObject.opt("transactionHash")) , Uint16HexStringConverter.decode(jsonObject.opt("transactionIndex")) , Uint32HexStringConverter.decode(jsonObject.opt("blockNumber")) , Byte32StringConverter.decode(jsonObject.opt("blockHash")) , Uint32HexStringConverter.decode(jsonObject.opt("nrgUsed")) , Uint32HexStringConverter.decode(jsonObject.opt("nrgPrice")) , Uint32HexStringConverter.decode(jsonObject.opt("gasUsed")) , Uint32HexStringConverter.decode(jsonObject.opt("gasPrice")) , Uint32HexStringConverter.decode(jsonObject.opt("gasLimit")) , Uint32HexStringConverter.decode(jsonObject.opt("cumulativeNrgUsed")) , Uint32HexStringConverter.decode(jsonObject.opt("cumulativeGasUsed")) , AddressConverter.decode(jsonObject.opt("contractAddress")) , AddressConverter.decode(jsonObject.opt("from")) , AddressConverter.decode(jsonObject.opt("to")) , DataHexStringConverter.decode(jsonObject.opt("logsBloom")) , Byte32StringConverter.decode(jsonObject.opt("root")) , ByteHexStringConverter.decode(jsonObject.opt("status")) , EthTxReceiptLogsListConverter.decode(jsonObject.opt("logs")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(ethTransactionReceipt}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1387,7 +1387,7 @@ public static EthTxReceiptLogs decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new EthTxReceiptLogs( AddressConverter.decode(jsonObject.opt("address")) , DataHexStringConverter.decode(jsonObject.opt("data")) , LongConverter.decode(jsonObject.opt("blockNumber")) , Uint16HexStringConverter.decode(jsonObject.opt("transactionIndex")) , Uint16HexStringConverter.decode(jsonObject.opt("logIndex")) , DataHexStringListConverter.decode(jsonObject.opt("topics")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(ethTxReceiptLogs}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1432,7 +1432,7 @@ public static EthBlock decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new EthBlock( LongConverter.decode(jsonObject.opt("number")) , Byte32StringConverter.decode(jsonObject.opt("hash")) , Byte32StringConverter.decode(jsonObject.opt("parentHash")) , ByteArrayConverter.decode(jsonObject.opt("logsBloom")) , DataHexStringConverter.decode(jsonObject.opt("transactionsRoot")) , DataHexStringConverter.decode(jsonObject.opt("stateRoot")) , DataHexStringConverter.decode(jsonObject.opt("receiptsRoot")) , BigIntHexStringConverter.decode(jsonObject.opt("difficulty")) , BigIntHexStringConverter.decode(jsonObject.opt("totalDifficulty")) , LongHexStringConverter.decode(jsonObject.opt("timestamp")) , AddressConverter.decode(jsonObject.opt("miner")) , LongHexStringConverter.decode(jsonObject.opt("gasUsed")) , LongHexStringConverter.decode(jsonObject.opt("gasLimit")) , LongHexStringConverter.decode(jsonObject.opt("nrgUsed")) , LongHexStringConverter.decode(jsonObject.opt("nrgLimit")) , ByteHexStringConverter.decode(jsonObject.opt("sealType")) , BoolConverter.decode(jsonObject.opt("mainChain")) , IntConverter.decode(jsonObject.opt("size")) , TransactionUnionConverter.decode(jsonObject.opt("transactions")) , DataHexStringConverter.decode(jsonObject.opt("nonce")) , DataHexStringConverter.decode(jsonObject.opt("solution")) , DataHexStringConverter.decode(jsonObject.opt("seed")) , DataHexStringConverter.decode(jsonObject.opt("signature")) , DataHexStringConverter.decode(jsonObject.opt("publicKey")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(ethBlock}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1513,7 +1513,7 @@ public static OpsTransaction decode(Object str){ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new OpsTransaction( LongConverter.decode(jsonObject.opt("timestampVal")) , Byte32StringConverter.decode(jsonObject.opt("transactionHash")) , LongConverter.decode(jsonObject.opt("blockNumber")) , Byte32StringConverter.decode(jsonObject.opt("blockHash")) , BigIntHexStringConverter.decode(jsonObject.opt("nonce")) , AddressConverter.decode(jsonObject.opt("fromAddr")) , AddressConverter.decode(jsonObject.opt("toAddr")) , BigIntHexStringConverter.decode(jsonObject.opt("value")) , LongHexStringConverter.decode(jsonObject.opt("nrgPrice")) , LongHexStringConverter.decode(jsonObject.opt("nrgConsumed")) , DataHexStringConverter.decode(jsonObject.opt("data")) , IntConverter.decode(jsonObject.opt("transactionIndex")) , Byte32StringConverter.decode(jsonObject.opt("beaconHash")) , TxLogListConverter.decode(jsonObject.opt("logs")) ); } catch (Exception e){ - throw new ParseErrorRPCException("Could not decode composite type(opsTransaction}}): "+ str); + throw new ParseErrorRPCException(); } } @@ -1590,7 +1590,7 @@ public static String encode(ByteArray obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(dataHexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1625,7 +1625,7 @@ public static String encode(BigInteger obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(bigIntHexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1660,7 +1660,7 @@ public static String encode(BigInteger obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(uint256HexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1668,7 +1668,7 @@ public static String encode(BigInteger obj){ } private static boolean checkConstraints(String s){ - return regex.matcher(s).find() && s.length() >= 2 && s.length() <= 66; + return regex.matcher(s).find() && s.length() >= 66 && s.length() <= 66; } } @@ -1695,7 +1695,7 @@ public static String encode(BigInteger obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(uint64HexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1703,7 +1703,7 @@ public static String encode(BigInteger obj){ } private static boolean checkConstraints(String s){ - return regex.matcher(s).find() && s.length() >= 2 && s.length() <= 18; + return regex.matcher(s).find() && s.length() >= 18 && s.length() <= 18; } } @@ -1730,7 +1730,7 @@ public static String encode(BigInteger obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(uint128HexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1738,7 +1738,7 @@ public static String encode(BigInteger obj){ } private static boolean checkConstraints(String s){ - return regex.matcher(s).find() && s.length() >= 2 && s.length() <= 34; + return regex.matcher(s).find() && s.length() >= 34 && s.length() <= 34; } } @@ -1765,7 +1765,7 @@ public static String encode(Long obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(uint32HexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1773,7 +1773,7 @@ public static String encode(Long obj){ } private static boolean checkConstraints(String s){ - return regex.matcher(s).find() && s.length() >= 2 && s.length() <= 18; + return regex.matcher(s).find() && s.length() >= 18 && s.length() <= 18; } } @@ -1800,7 +1800,7 @@ public static String encode(Integer obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(uint16HexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1808,7 +1808,7 @@ public static String encode(Integer obj){ } private static boolean checkConstraints(String s){ - return regex.matcher(s).find() && s.length() >= 2 && s.length() <= 18; + return regex.matcher(s).find() && s.length() >= 18 && s.length() <= 18; } } @@ -1835,7 +1835,7 @@ public static String encode(Long obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(longHexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1870,7 +1870,7 @@ public static String encode(Integer obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(intHexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1905,7 +1905,7 @@ public static String encode(Byte obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(byteHexString): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1940,7 +1940,7 @@ public static String encode(ByteArray obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(byte32String): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -1975,7 +1975,7 @@ public static String encode(ByteArray obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(byte64String): "+ result); + throw new ParseErrorRPCException(); } else{ return null; @@ -2010,7 +2010,7 @@ public static String encode(String obj){ if(checkConstraints(result)) return result; else - throw new ParseErrorRPCException("Failed to encode constraint type(decimalstring): "+ result); + throw new ParseErrorRPCException(); } else{ return null; diff --git a/rpc-lib4j/templates/errors/java_exceptions.ftl b/rpc-lib4j/templates/errors/java_exceptions.ftl index fbf0249..30d272f 100644 --- a/rpc-lib4j/templates/errors/java_exceptions.ftl +++ b/rpc-lib4j/templates/errors/java_exceptions.ftl @@ -65,13 +65,9 @@ public class RPCExceptions{ public static class RPCException extends RuntimeException{ private final transient RpcError error; - RPCException(String message){ - super(message); - this.error = RpcErrorConverter.decode(message); - } - - RPCException(Integer code ,String message){ - this("{\"code\":"+code+",\"message\":\""+message+"\"}"); + RPCException(final Integer code , final String message){ + super("{\"code\":"+code+",\"message\":\""+message+"\"}"); + error = new RpcError(code, message); } /** @@ -90,11 +86,11 @@ public class RPCExceptions{ */ public static class ${macros.toJavaException(error.error_class)} extends RPCException{ public static final ${macros.toJavaException(error.error_class)} INSTANCE = new ${macros.toJavaException(error.error_class)}(); - private ${macros.toJavaException(error.error_class)}(){ - super("{\"code\":${error.code},\"message\":\"${error.message}\"}"); + public ${macros.toJavaException(error.error_class)}(){ + super(${error.code},"${error.message}"); }<#if error.modifiable=="true"> public ${macros.toJavaException(error.error_class)}(String appendedMessage){ - super("{\"code\":${error.code},\"message\":\"${error.message}:"+appendedMessage+"\"}"); + super(${error.code},"${error.message}:"+appendedMessage); } ${macros.toJavaException(error.error_class)}(Integer code, String message){ super(code,message); diff --git a/rpc-lib4j/templates/rpc/java_rpc.ftl b/rpc-lib4j/templates/rpc/java_rpc.ftl index 095b01d..22e6063 100644 --- a/rpc-lib4j/templates/rpc/java_rpc.ftl +++ b/rpc-lib4j/templates/rpc/java_rpc.ftl @@ -32,7 +32,7 @@ public interface RPCServerMethods extends RPC{ <#list methods as method> if(request.method.equals("${method.name}")){ ${macros.toJavaType(method.param)} params= ${macros.toJavaConverter(method.param)}.decode(request.params); - if (params==null) throw ${macros.toJavaException("InvalidParams")}.INSTANCE; + if (params==null) throw new ${macros.toJavaException("InvalidParams")}(); ${macros.toJavaType(method.returnType)} result = rpc.${method.name}(<#list method.param.fields as parameter>params.${parameter.fieldName}<#if parameter_has_next>,); // JSON RPC spec demands that if the result member does not exist // we should return an error see: https://www.jsonrpc.org/specification#response_object @@ -40,7 +40,7 @@ public interface RPCServerMethods extends RPC{ else res = ${macros.toJavaConverter(method.returnType)}.encode(result); }else - throw ${macros.toJavaException("MethodNotFound")}.INSTANCE; + throw new ${macros.toJavaException("MethodNotFound")}(); return res; } diff --git a/rpc-lib4j/templates/types/java_type_converter.ftl b/rpc-lib4j/templates/types/java_type_converter.ftl index 9045116..406ed18 100644 --- a/rpc-lib4j/templates/types/java_type_converter.ftl +++ b/rpc-lib4j/templates/types/java_type_converter.ftl @@ -58,7 +58,7 @@ public class RPCTypesConverter{ public static Boolean decode(Object s){ if(s==null || s == JSONObject.NULL) return null; if ( booleanPattern.matcher(s.toString()).find()) return Boolean.parseBoolean(s.toString()); - else throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + else throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse bool: " + s); } public static Boolean encode(Boolean b){ @@ -76,7 +76,7 @@ public class RPCTypesConverter{ return Byte.parseByte(s.toString()); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse byte: " + s); } } @@ -84,7 +84,7 @@ public class RPCTypesConverter{ try { return s; } catch (Exception e) { - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -93,7 +93,7 @@ public class RPCTypesConverter{ if (s==null||s.equals(JSONObject.NULL)) return null; else return "0x"+ByteUtil.oneByteToHexString(s); } catch (Exception e) { - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } } @@ -109,7 +109,7 @@ public class RPCTypesConverter{ return Long.parseLong(s.toString()); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse long: " + s); } } @@ -117,7 +117,7 @@ public class RPCTypesConverter{ try{ return s; }catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -126,7 +126,7 @@ public class RPCTypesConverter{ if (s==null || s.equals(JSONObject.NULL)) return null; else return "0x"+Long.toHexString(s); }catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -156,7 +156,7 @@ public class RPCTypesConverter{ } else if (unsignedHexPattern.matcher(string).find()){ integer = TypeUtils.decodeIntFromHex(string); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } TypeUtils.checkUnsigned(integer); return integer; @@ -188,7 +188,7 @@ public class RPCTypesConverter{ }else if (unsignedHexPattern.matcher(string).find()){ integer= TypeUtils.decodeLongFromHex(string); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } TypeUtils.checkUnsigned(integer); return integer; @@ -221,7 +221,7 @@ public class RPCTypesConverter{ } else if (unsignedHexPattern.matcher(string).find()){ integer= TypeUtils.decodeBigIntFromHex(string); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } TypeUtils.checkUnsigned(integer); return integer; @@ -254,7 +254,7 @@ public class RPCTypesConverter{ } else if (unsignedHexPattern.matcher(string).find()){ integer= TypeUtils.decodeBigIntFromHex(string); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } TypeUtils.checkUnsigned(integer); return integer; @@ -287,7 +287,7 @@ public class RPCTypesConverter{ } else if (unsignedHexPattern.matcher(string).find()){ returnValue= TypeUtils.decodeBigIntFromHex(string); } else{ - throw ParseErrorRPCException.INSTANCE; + throw new ParseErrorRPCException(); } TypeUtils.checkUnsigned(returnValue); return returnValue; @@ -306,7 +306,7 @@ public class RPCTypesConverter{ return Integer.parseInt(s.toString()); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } } @@ -314,7 +314,7 @@ public class RPCTypesConverter{ try{ return s; }catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -323,7 +323,7 @@ public class RPCTypesConverter{ if (s==null) return null; else return "0x"+Integer.toHexString(s); }catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse int: " + s); } } } @@ -335,7 +335,7 @@ public class RPCTypesConverter{ if(bigInteger==null) return null; return "0x"+bigInteger.toString(16); } catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -344,7 +344,7 @@ public class RPCTypesConverter{ if(bigInteger==null) return null; return bigInteger.toString(10); } catch(Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -358,7 +358,7 @@ public class RPCTypesConverter{ return new BigInteger(s.toString()); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse bigint: " + s); } } } @@ -378,7 +378,7 @@ public class RPCTypesConverter{ return new ByteArray(ByteUtil.hexStringToBytes(encodedString)); } } - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse byte-array: " + obj); } public static String encode(ByteArray bytes){ @@ -400,10 +400,10 @@ public class RPCTypesConverter{ return new AionAddress(((byte[])obj)); } else { - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } }catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to parse address: " + obj); } } @@ -439,7 +439,7 @@ public class RPCTypesConverter{ JSONObject jsonObject = str instanceof JSONObject? (JSONObject)str :new JSONObject(str.toString()); return new ${macros.toJavaType(compositeType)}(<#list compositeType.fields as field> ${macros.toJavaConverter(field.type)}.decode(jsonObject.opt("${field.fieldName}")) <#if field_has_next>,); } catch (Exception e){ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}("Could not decode composite type(${compositeType.name}}}): "+ str); } } @@ -453,7 +453,7 @@ public class RPCTypesConverter{ return jsonObject.toString(); } catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } @@ -466,7 +466,7 @@ public class RPCTypesConverter{ return jsonObject; }catch (Exception e){ - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } } } @@ -483,10 +483,10 @@ public class RPCTypesConverter{ return ${macros.toJavaConverter(constrainedType.baseType)}.decode(object); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed constraints on type ${constrainedType.name}: " + object); } } catch(Exception e){ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } } @@ -500,7 +500,7 @@ public class RPCTypesConverter{ if(checkConstraints(result)) return result; else - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}("Failed to encode constraint type(${constrainedType.name}): "+ result); } else{ return null; @@ -522,16 +522,16 @@ public class RPCTypesConverter{ ${macros.toJavaType(paramType)} obj; if(s.startsWith("[") && s.endsWith("]")){ JSONArray jsonArray = new JSONArray(s); - if(jsonArray.length() > ${paramType.fields?size}) throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + if(jsonArray.length() > ${paramType.fields?size}) throw new ${macros.toJavaException(decodeError.error_class)}(); else obj = new ${macros.toJavaType(paramType)}(<#list paramType.fields as param> ${macros.toJavaConverter(param.type)}.decode(jsonArray.opt(${param.index}))<#if param_has_next>,); } else if(s.startsWith("{") && s.endsWith("}")){ JSONObject jsonObject = new JSONObject(s); - if(jsonObject.keySet().size() > ${paramType.fields?size}) throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + if(jsonObject.keySet().size() > ${paramType.fields?size}) throw new ${macros.toJavaException(decodeError.error_class)}(); else obj = new ${macros.toJavaType(paramType)}(<#list paramType.fields as param> ${macros.toJavaConverter(param.type)}.decode(jsonObject.opt("${param.fieldName}"))<#if param_has_next>,); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } return obj;<#else > if(object instanceof JSONArray && ((JSONArray) object).length()==0){ @@ -544,11 +544,11 @@ public class RPCTypesConverter{ return new ${macros.toJavaType(paramType)}(); } else{ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } } catch(Exception e){ - throw ${macros.toJavaException("InvalidParams")}.INSTANCE; + throw new ${macros.toJavaException("InvalidParams")}(); } } @@ -564,7 +564,7 @@ public class RPCTypesConverter{ return null; }catch(Exception e){ - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } } } diff --git a/rpc-lib4j/templates/types/java_types.ftl b/rpc-lib4j/templates/types/java_types.ftl index 5532653..9018daa 100644 --- a/rpc-lib4j/templates/types/java_types.ftl +++ b/rpc-lib4j/templates/types/java_types.ftl @@ -26,7 +26,7 @@ public class RPCTypes{ public ByteArray(byte[] bytes) { if (bytes == null) { - throw new NullPointerException("Byte array is null"); + throw new NullPointerException("Byte array is null"); } this.bytes = bytes; } @@ -34,7 +34,7 @@ public class RPCTypes{ * @param hexString a hexadecimal string that encodes a byte array. */ public ByteArray(String hexString){ - if (hexString == null) throw new NullPointerException("Hex String is null"); + if (hexString == null) throw new NullPointerException("Hex String is null"); this.bytes = ByteUtil.hexStringToBytes(hexString); } @@ -99,13 +99,13 @@ public class RPCTypes{ <#list unionType.unionElements as unionElement > public ${macros.toJavaType(unionType)}(${macros.toJavaType(unionElement.type)} ${unionElement.name}){ this(<#list 0..unionType.unionElements?size-1 as i><#if i==unionElement_index>${unionElement.name}<#else>null<#if i_has_next>,); - if(${unionElement.name} == null) throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + if(${unionElement.name} == null) throw new ${macros.toJavaException(decodeError.error_class)}(); } <#list unionType.unionElements as unionElement > public static ${macros.toJavaType(unionType)} wrap(${macros.toJavaType(unionElement.type)} ${unionElement.name}){ - if(${unionElement.name} == null) throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + if(${unionElement.name} == null) throw new ${macros.toJavaException(decodeError.error_class)}(); else return new ${macros.toJavaType(unionType)}(${unionElement.name}); } @@ -114,7 +114,7 @@ public class RPCTypes{ <#list unionType.unionElements as unionElement> if(this.${unionElement.name} != null) return ${macros.toJavaConverter(unionElement.type)}.encode(${unionElement.name}); - throw ${macros.toJavaException(encodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(encodeError.error_class)}(); } public static ${macros.toJavaType(unionType)} decode(Object object){ @@ -123,7 +123,7 @@ public class RPCTypes{ return new ${macros.toJavaType(unionType)}(${macros.toJavaConverter(unionElement.type)}.decode(object)); }catch(Exception e){} - throw ${macros.toJavaException(decodeError.error_class)}.INSTANCE; + throw new ${macros.toJavaException(decodeError.error_class)}(); } } @@ -151,7 +151,7 @@ public class RPCTypes{ public ${macros.toJavaType(composite_type)}(<#list composite_type.fields as field>${macros.toJavaType(field.type)} ${field.fieldName} <#if field_has_next>,){ <#list composite_type.fields as field><#if field.required=="true" > - if(${field.fieldName}==null) throw ${macros.toJavaException("ParseError")}.INSTANCE; + if(${field.fieldName}==null) throw new ${macros.toJavaException("ParseError")}("Missing field(${field.fieldName}) on type(${macros.toJavaType(composite_type)})"); this.${field.fieldName}=<#if field.defaultValue?has_content>${field.fieldName}==null? ${field.fieldName}DefaultValue:${field.fieldName}; @@ -174,12 +174,12 @@ public class RPCTypes{ } public static ${macros.toJavaType(enum)} fromString(String x){ - if(x==null) throw ${macros.toJavaException("ParseError")}.INSTANCE; + if(x==null) throw new ${macros.toJavaException("ParseError")}(); <#list enum.values as value> if(x.equals("${value.value}")){ return ${value.name}; }else - throw ${macros.toJavaException("ParseError")}.INSTANCE; + throw new ${macros.toJavaException("ParseError")}(); } } @@ -206,7 +206,7 @@ public class RPCTypes{ public ${macros.toJavaType(paramType)}(<#list paramType.fields as field>${macros.toJavaType(field.type)} ${field.fieldName} <#if field_has_next>,){ <#list paramType.fields as field><#if field.required=="true" > - if(${field.fieldName}==null) throw ${macros.toJavaException("ParseError")}.INSTANCE; + if(${field.fieldName}==null) throw new ${macros.toJavaException("ParseError")}("Missing field(${field.fieldName}) on rpc param type(${macros.toJavaType(paramType)})"); this.${field.fieldName}=<#if field.defaultValue?has_content> ${field.fieldName}==null? ${field.fieldName}DefaultValue: ${field.fieldName}; diff --git a/spec/errors.xml b/spec/errors.xml index eafb86c..2464bfb 100644 --- a/spec/errors.xml +++ b/spec/errors.xml @@ -11,7 +11,7 @@ ]> - + Occurs if a user submits a malformed json payload