-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathEosioJavaRpcProviderImpl.java
More file actions
552 lines (508 loc) · 25.1 KB
/
Copy pathEosioJavaRpcProviderImpl.java
File metadata and controls
552 lines (508 loc) · 25.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
package one.block.eosiojavarpcprovider.implementations;
import com.google.gson.Gson;
import one.block.eosiojava.error.rpcProvider.GetBlockInfoRpcError;
import one.block.eosiojava.error.rpcProvider.GetBlockRpcError;
import one.block.eosiojava.error.rpcProvider.GetInfoRpcError;
import one.block.eosiojava.error.rpcProvider.GetRawAbiRpcError;
import one.block.eosiojava.error.rpcProvider.GetRequiredKeysRpcError;
import one.block.eosiojava.error.rpcProvider.PushTransactionRpcError;
import one.block.eosiojava.error.rpcProvider.RpcProviderError;
import one.block.eosiojava.error.rpcProvider.SendTransactionRpcError;
import one.block.eosiojava.models.rpcProvider.request.GetBlockInfoRequest;
import one.block.eosiojava.models.rpcProvider.request.GetBlockRequest;
import one.block.eosiojava.models.rpcProvider.request.GetRawAbiRequest;
import one.block.eosiojava.models.rpcProvider.request.GetRequiredKeysRequest;
import one.block.eosiojava.models.rpcProvider.request.PushTransactionRequest;
import one.block.eosiojava.models.rpcProvider.request.SendTransactionRequest;
import one.block.eosiojava.models.rpcProvider.response.GetBlockInfoResponse;
import one.block.eosiojava.models.rpcProvider.response.GetBlockResponse;
import one.block.eosiojava.models.rpcProvider.response.GetInfoResponse;
import one.block.eosiojava.models.rpcProvider.response.GetRawAbiResponse;
import one.block.eosiojava.models.rpcProvider.response.GetRequiredKeysResponse;
import one.block.eosiojava.models.rpcProvider.response.PushTransactionResponse;
import one.block.eosiojava.models.rpcProvider.response.RPCResponseError;
import one.block.eosiojava.models.rpcProvider.response.SendTransactionResponse;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.logging.HttpLoggingInterceptor.Level;
import one.block.eosiojava.interfaces.IRPCProvider;
import one.block.eosiojavarpcprovider.error.EosioJavaRpcErrorConstants;
import one.block.eosiojavarpcprovider.error.EosioJavaRpcProviderCallError;
import one.block.eosiojavarpcprovider.error.EosioJavaRpcProviderInitializerError;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
//
// Copyright © 2017-2019 block.one.
//
/**
* Simple implementation of an RPC provider for communicating with the blockchain.
* The calls are implemented synchronously. It is assumed that the developer will
* wrap them in asynchronous semantics such as AsyncTask in normal use...
*/
public class EosioJavaRpcProviderImpl implements IRPCProvider {
@NotNull
private String baseURL;
@NotNull
private Retrofit retrofit;
@NotNull
private IEosioJavaRpcProviderApi rpcProviderApi;
/**
* Construct a new RPC provider instance given the base URL to use for building requests.
* @param baseURL Base URL to use for building requests.
* @throws EosioJavaRpcProviderInitializerError thrown if the base URL passed in is null.
*/
public EosioJavaRpcProviderImpl(@NotNull String baseURL) throws EosioJavaRpcProviderInitializerError {
this(baseURL, false);
}
/**
* Construct a new RPC provider instance given the base URL to use for building requests.
* @param baseURL Base URL to use for building requests.
* @param enableDebug Enable Network Log at {@link Level#BODY} level
* @throws EosioJavaRpcProviderInitializerError thrown if the base URL passed in is null.
*/
public EosioJavaRpcProviderImpl(@NotNull String baseURL, boolean enableDebug) throws EosioJavaRpcProviderInitializerError {
if(baseURL == null || baseURL.isEmpty()) {
throw new EosioJavaRpcProviderInitializerError(EosioJavaRpcErrorConstants.RPC_PROVIDER_BASE_URL_EMPTY);
}
this.baseURL = baseURL;
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
if (enableDebug) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(Level.BODY);
httpClient.addInterceptor(httpLoggingInterceptor);
}
this.retrofit = new Retrofit.Builder()
.baseUrl(this.baseURL)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build())
.build();
this.rpcProviderApi = this.retrofit.create(IEosioJavaRpcProviderApi.class);
}
/**
* Construct a new RPC provider instance given the base URL to use for building requests.
* @param baseURL Base URL to use for building requests.
* @param okHttpClient external OkHttpClient client.
* @throws EosioJavaRpcProviderInitializerError thrown if the base URL passed in is null.
*/
public EosioJavaRpcProviderImpl(@NotNull String baseURL, @NotNull OkHttpClient okHttpClient) throws EosioJavaRpcProviderInitializerError {
if(baseURL == null || baseURL.isEmpty()) {
throw new EosioJavaRpcProviderInitializerError(EosioJavaRpcErrorConstants.RPC_PROVIDER_BASE_URL_EMPTY);
}
this.baseURL = baseURL;
this.retrofit = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();
this.rpcProviderApi = this.retrofit.create(IEosioJavaRpcProviderApi.class);
}
/**
* Process a retrofit call, setting arguments, checking responses and decoding responses and errors
* as necessary.
* @param call Retrofit call to execute.
* @param <O> Response type to use for decoding.
* @return Response type given in signature.
* @throws Exception Can throw EosioJavaRpcProviderCallError for RPC provider specific
* processing errors or Java IO or network errors from Retrofit.
*/
@NotNull
private <O> O processCall(Call<O> call) throws Exception {
Response<O> response = call.execute();
if (!response.isSuccessful()) {
String additionalErrInfo = EosioJavaRpcErrorConstants.RPC_PROVIDER_NO_FURTHER_ERROR_INFO;
RPCResponseError rpcResponseError = null;
if (response.errorBody() != null) {
Gson gson = new Gson();
rpcResponseError = gson.fromJson(response.errorBody().charStream(), RPCResponseError.class);
if (rpcResponseError == null) {
additionalErrInfo = response.errorBody().string();
} else {
additionalErrInfo = EosioJavaRpcErrorConstants.RPC_PROVIDER_SEE_FURTHER_ERROR_INFO;
}
}
String msg = String.format(Locale.getDefault(), EosioJavaRpcErrorConstants.RPC_PROVIDER_BAD_STATUS_CODE_RETURNED,
response.code(), response.message(), additionalErrInfo);
throw new EosioJavaRpcProviderCallError(msg, rpcResponseError);
}
if (response.body() == null) {
throw new EosioJavaRpcProviderCallError(EosioJavaRpcErrorConstants.RPC_PROVIDER_EMPTY_RESPONSE_RETURNED);
}
return response.body();
}
/**
* Issue a getInfo() call to the blockchain and process the response.
* @return GetInfoResponse on successful return.
* @throws GetInfoRpcError Thrown if any errors occur calling or processing the request.
*/
@Override
public @NotNull GetInfoResponse getInfo() throws GetInfoRpcError {
try {
Call<GetInfoResponse> syncCall = this.rpcProviderApi.getInfo();
return processCall(syncCall);
} catch (Exception ex) {
throw new GetInfoRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GETTING_CHAIN_INFO,
ex);
}
}
/**
* Issue a getBlock() call to the blockchain and process the response.
* @param getBlockRequest Info about a specific block.
* @return GetBlockRsponse on successful return.
* @throws GetBlockRpcError Thrown if any errors occur calling or processing the request.
*/
public @NotNull GetBlockResponse getBlock(GetBlockRequest getBlockRequest)
throws GetBlockRpcError {
try {
Call<GetBlockResponse> syncCall = this.rpcProviderApi.getBlock(getBlockRequest);
return processCall(syncCall);
} catch (Exception ex) {
throw new GetBlockRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GETTING_BLOCK_INFO,
ex);
}
}
/**
* Issue a getBlockInfo() call to the blockchain and process the response.
* @param getBlockInfoRequest Info about a specific block.
* @return GetBlockInfoResponse on successful return.
* @throws GetBlockInfoRpcError Thrown if any errors occur calling or processing the request.
*/
@Override
public @NotNull GetBlockInfoResponse getBlockInfo(GetBlockInfoRequest getBlockInfoRequest)
throws GetBlockInfoRpcError {
try {
Call<GetBlockInfoResponse> syncCall = this.rpcProviderApi.getBlockInfo(getBlockInfoRequest);
return processCall(syncCall);
} catch (Exception ex) {
throw new GetBlockInfoRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GETTING_BLOCK_INFO,
ex);
}
}
/**
* Issue a getRawAbi() request to the blockchain and process the response.
* @param getRawAbiRequest Info about a specific smart contract.
* @return GetRawAbiResponse on successful return.
* @throws GetRawAbiRpcError Thrown if any errors occur calling or processing the request.
*/
@Override
public @NotNull GetRawAbiResponse getRawAbi(GetRawAbiRequest getRawAbiRequest)
throws GetRawAbiRpcError {
try {
Call<GetRawAbiResponse> syncCall = this.rpcProviderApi.getRawAbi(getRawAbiRequest);
return processCall(syncCall);
} catch (Exception ex) {
throw new GetRawAbiRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GETTING_RAW_ABI,
ex);
}
}
/**
* Issue a getRequiredKeys() request to the blockchain and process the response.
* @param getRequiredKeysRequest Info to get required keys
* @return GetRequiredKeysResponse on successful return.
* @throws GetRequiredKeysRpcError Thrown if any errors occur calling or processing the request.
*/
@Override
public @NotNull GetRequiredKeysResponse getRequiredKeys(
GetRequiredKeysRequest getRequiredKeysRequest) throws GetRequiredKeysRpcError {
try {
Call<GetRequiredKeysResponse> syncCall = this.rpcProviderApi.getRequiredKeys(getRequiredKeysRequest);
return processCall(syncCall);
} catch (Exception ex) {
throw new GetRequiredKeysRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GETTING_REQUIRED_KEYS,
ex);
}
}
/**
* Push a given transaction to the blockchain and process the response.
* @param pushTransactionRequest the transaction to push with signatures.
* @return PushTransactionResponse on successful return.
* @throws PushTransactionRpcError Thrown if any errors occur calling or processing the request.
*/
public @NotNull PushTransactionResponse pushTransaction(
PushTransactionRequest pushTransactionRequest) throws PushTransactionRpcError {
try {
Call<PushTransactionResponse> syncCall = this.rpcProviderApi.pushTransaction(pushTransactionRequest);
return processCall(syncCall);
} catch (Exception ex) {
throw new PushTransactionRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_PUSHING_TRANSACTION,
ex);
}
}
/**
* Send a given transaction to the blockchain and process the response.
* @param sendTransactionRequest the transaction to send with signatures.
* @return SendTransactionResponse on successful return.
* @throws SendTransactionRpcError Thrown if any errors occur calling or processing the request.
*/
public @NotNull SendTransactionResponse sendTransaction(
SendTransactionRequest sendTransactionRequest) throws SendTransactionRpcError {
try {
Call<SendTransactionResponse> syncCall = this.rpcProviderApi.sendTransaction(sendTransactionRequest);
return processCall(syncCall);
} catch (Exception ex) {
throw new SendTransactionRpcError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_SENDING_TRANSACTION,
ex);
}
}
/**
* Issue a get_account call to the blockchain and process the response.
* @param requestBody request body of get_account API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getAccount(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getAccount(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_ACCOUNT, ex);
}
}
/**
* Issue a pushTransactions() call to the blockchain and process the response.
* @param requestBody request body of push_transactions API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String pushTransactions(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.pushTransactions(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_PUSHING_TRANSACTIONS, ex);
}
}
/**
* Issue a getBlockHeaderState() call to the blockchain and process the response.
* @param requestBody request body of get_block_header_state API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getBlockHeaderState(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getBlockHeaderState(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_BLOCK_HEADER_STATE, ex);
}
}
/**
* Issue a getAbi() call to the blockchain and process the response.
* @param requestBody request body of get_abi API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getAbi(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getAbi(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_ABI, ex);
}
}
/**
* Issue a getCurrencyBalance call to the blockchain and process the response.
* @param requestBody request body of get_currency_balance API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getCurrencyBalance(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getCurrencyBalance(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_CURRENT_BALANCE, ex);
}
}
/**
* Issue a getCurrencyStats() call to the blockchain and process the response.
* @param requestBody request body of get_currency_stats API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getCurrencyStats(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getCurrencyStats(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_CURRENT_STATS, ex);
}
}
/**
* Issue a getProducers() call to the blockchain and process the response.
* @param requestBody request body of get_producers API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getProducers(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getProducers(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_PRODUCERS, ex);
}
}
/**
* Issue a getRawCodeAndAbi() call to the blockchain and process the response.
* @param requestBody request body of get_raw_code_and_abi API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getRawCodeAndAbi(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getRawCodeAndAbi(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_RAW_CODE_AND_ABI, ex);
}
}
/**
* Issue a getTableByScope() call to the blockchain and process the response.
* @param requestBody request body of get_table_by_scope API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getTableByScope(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getTableByScope(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_TABLE_BY_SCOPE, ex);
}
}
/**
* Issue a getTableRows() call to the blockchain and process the response.
* @param requestBody request body of get_table_rows API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getTableRows(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getTableRows(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_TABLE_ROWS, ex);
}
}
/**
* Issue a getKvTableRows() call to the blockchain and process the response.
* @param requestBody request body of get_kv_table_rows API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getKvTableRows(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getKvTableRows(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_KV_TABLE_ROWS, ex);
}
}
/**
* Issue a getCode() call to the blockchain and process the response.
* @param requestBody request body of get_code API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getCode(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getCode(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_CODE, ex);
}
}
/**
* Issue a getActions() call to the blockchain and process the response.
* @param requestBody request body of get_actions API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getActions(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getActions(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_ACTION, ex);
}
}
/**
* Issue a getTransaction() call to the blockchain and process the response.
* @param requestBody request body of get_transaction API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getTransaction(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getTransaction(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_TRANSACTION, ex);
}
}
/**
* Issue a getKeyAccounts() call to the blockchain and process the response.
* @param requestBody request body of get_key_accounts API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getKeyAccounts(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getKeyAccounts(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_KEY_ACCOUNTS, ex);
}
}
/**
* Issue a getControlledAccounts() call to the blockchain and process the response.
* @param requestBody request body of get_controlled_accounts API
* @return String content of ResponseBody on successful return.
* @throws RpcProviderError Thrown if any errors occur calling or processing the request.
*/
public @NotNull String getControlledAccounts(RequestBody requestBody) throws RpcProviderError {
try {
Call<ResponseBody> syncCall = this.rpcProviderApi.getControlledAccounts(requestBody);
try(ResponseBody responseBody = processCall(syncCall)) {
return responseBody.string();
}
} catch (Exception ex) {
throw new RpcProviderError(EosioJavaRpcErrorConstants.RPC_PROVIDER_ERROR_GET_CONTROLLED_ACCOUNTS, ex);
}
}
}