本文整理匯總了Java中de.petendi.ethereum.android.service.model.WrappedRequest類的典型用法代碼示例。如果您正苦於以下問題:Java WrappedRequest類的具體用法?Java WrappedRequest怎麽用?Java WrappedRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WrappedRequest類屬於de.petendi.ethereum.android.service.model包,在下文中一共展示了WrappedRequest類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: request
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
private void request() {
accountInput.setError(null);
String accountAddress = accountInput.getText().toString();
boolean cancel = false;
View focusView = null;
if (TextUtils.isEmpty(accountAddress)) {
accountInput.setError(getString(R.string.error_field_required));
focusView = accountInput;
cancel = true;
}
if (cancel) {
focusView.requestFocus();
} else {
showProgress(true);
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(RpcCommand.eth_getBalance.toString());
wrappedRequest.setParameters(new String[]{accountAddress, "latest"});
ethereumAndroid.sendAsync(wrappedRequest);
}
}
示例2: requestSync
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
private void requestSync() {
accountInput.setError(null);
String accountAddress = accountInput.getText().toString();
boolean cancel = false;
View focusView = null;
if (TextUtils.isEmpty(accountAddress)) {
accountInput.setError(getString(R.string.error_field_required));
focusView = accountInput;
cancel = true;
}
if (cancel) {
focusView.requestFocus();
} else {
showProgress(true);
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(RpcCommand.eth_getBalance.toString());
wrappedRequest.setParameters(new String[]{accountAddress, "latest"});
new MyAsyncTask(wrappedRequest).execute();
}
}
示例3: sendAsync
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public int sendAsync(WrappedRequest request) {
if (callback == null) {
throw new IllegalStateException("no callback set");
}
try {
Intent intent = new Intent(EthereumAndroidFactory.SERVICE_ACTION);
intent.setPackage(EthereumAndroidFactory.PACKAGENAME);
int id = messageId.incrementAndGet();
intent.putExtra(ID, id);
intent.putExtra(EXTRA_DATA, objectMapper.writeValueAsString(request));
intent.putExtra(EXTRA_PACKAGE, packageName);
context.startService(intent);
return id;
} catch (JsonProcessingException e) {
throw new IllegalStateException(e);
}
}
示例4: encode
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public String encode(String abi, String functionName, Object... args) {
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(ContractCommand.contract_encode.toString());
Object[] parameters;
if (args == null) {
parameters = new Object[2];
} else {
parameters = new Object[2 + args.length];
}
parameters[0] = abi;
parameters[1] = functionName;
if (args != null) {
System.arraycopy(args, 0, parameters, 2, args.length);
}
wrappedRequest.setParameters(parameters);
WrappedResponse response = ethereumAndroid.send(wrappedRequest);
if (response.isSuccess()) {
return (String) response.getResponse();
} else {
throw new ResponseNotOKException(response.getErrorMessage());
}
}
示例5: generateContractCreation
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public String generateContractCreation(String contractBytecode, String contractAbi, Object... constructorParams) {
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(ContractCommand.contract_creation.toString());
Object[] parameters;
if (constructorParams == null) {
parameters = new Object[2];
} else {
parameters = new Object[2 + constructorParams.length];
}
parameters[0] = contractBytecode;
parameters[1] = contractAbi;
if (constructorParams != null) {
System.arraycopy(constructorParams, 0, parameters, 2, constructorParams.length);
}
wrappedRequest.setParameters(parameters);
WrappedResponse response = ethereumAndroid.send(wrappedRequest);
if (response.isSuccess()) {
return (String) response.getResponse();
} else {
throw new ResponseNotOKException(response.getErrorMessage());
}
}
示例6: send
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public WrappedResponse send(WrappedRequest request) {
if (!hasServiceConnection()) {
throw new IllegalStateException("not (yet) connected to service");
}
try {
String response = binder.dispatch(objectMapper.writeValueAsString(request));
return objectMapper.readValue(response, WrappedResponse.class);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例7: generateContractInteraction
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public String generateContractInteraction(String address, BigInteger value, String encoded) {
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(ContractCommand.contract_interaction.toString());
Object[] parameters = new Object[3];
parameters[0] = address;
parameters[1] = value;
parameters[2] = encoded;
wrappedRequest.setParameters(parameters);
WrappedResponse response = ethereumAndroid.send(wrappedRequest);
if (response.isSuccess()) {
return (String) response.getResponse();
} else {
throw new ResponseNotOKException(response.getErrorMessage());
}
}
示例8: decodeResult
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public Object[] decodeResult(String abi, String functionName, String arg) {
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(ContractCommand.contract_decode.toString());
Object[] parameters = new Object[3];
parameters[0] = abi;
parameters[1] = functionName;
parameters[2] = arg;
wrappedRequest.setParameters(parameters);
WrappedResponse response = ethereumAndroid.send(wrappedRequest);
if (response.isSuccess()) {
return ((ArrayList) response.getResponse()).toArray();
} else {
throw new ResponseNotOKException(response.getErrorMessage());
}
}
示例9: call
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
public String call(String address, BigInteger wei, String encoded) {
WrappedRequest wrappedRequest = new WrappedRequest();
wrappedRequest.setCommand(ContractCommand.contract_call.toString());
Object[] parameters = new Object[3];
parameters[0] = address;
parameters[1] = wei;
parameters[2] = encoded;
wrappedRequest.setParameters(parameters);
WrappedResponse response = ethereumAndroid.send(wrappedRequest);
if (response.isSuccess()) {
return (String) response.getResponse();
} else {
throw new ResponseNotOKException(response.getErrorMessage());
}
}
示例10: MyAsyncTask
import de.petendi.ethereum.android.service.model.WrappedRequest; //導入依賴的package包/類
private MyAsyncTask(WrappedRequest request) {
this.request = request;
}