Skip to content

Commit 03399c5

Browse files
authored
Merge pull request #105 from EbenezerGH/cleaning-for-1.0-release
Cleaning for 1.0 release
2 parents 091f8c2 + 6cca1be commit 03399c5

File tree

11 files changed

+126
-209
lines changed

11 files changed

+126
-209
lines changed

README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Generic badge](https://img.shields.io/badge/EtherscanApi-UP-brightgreen.svg)](https://api.etherscan.io/api?module=stats&action=ethprice&apikey=YourApiKeyToken)
2-
[![Generic badge](https://img.shields.io/badge/CircleCI-UP-brightgreen.svg)](https://circleci.com/gh/EbenezerGH/hello_etherscan/tree/master)
3-
[![Generic badge](https://img.shields.io/badge/Version-v0.8.0-lightgrey.svg)](https://github.com/EbenezerGH/etherscan-android-api/releases)
2+
[![Generic badge](https://img.shields.io/badge/CircleCI-PASS-brightgreen.svg)](https://circleci.com/gh/EbenezerGH/hello_etherscan/tree/master)
3+
[![Generic badge](https://img.shields.io/badge/Version-v0.9.0-lightgrey.svg)](https://jitpack.io/#EbenezerGH/etherscan-android-api)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/EbenezerGH/hello_etherscan/blob/update-documentation/LICENSE)
55

66
# etherscan-android-api
@@ -23,42 +23,35 @@ Add JitPack to your root build.gradle at the end of repositories
2323
Add the dependency
2424
```
2525
dependencies {
26-
implementation 'com.github.EbenezerGH:hello_etherscan:v0.8.0'
26+
implementation 'com.github.EbenezerGH:hello_etherscan:v0.9.0'
2727
}
2828
```
29-
import a reactive android library to handle the reactive stream being passed into your module. For instance I used the following:
30-
31-
32-
implementation 'io.reactivex.rxjava2:rxandroid:x.y.z'
33-
implementation 'io.reactivex.rxjava2:rxkotlin:x.y.z'
3429

3530

3631
Optional: Call `ApiKey.takeOff.setApiKey("[your api key here]")` in your module's application class when recording api usage in the etherscan.io console. [see [example implementation](https://github.com/EbenezerGH/etherscan-android-api/blob/master/etherscan-sample/src/main/java/jfyg/etherscan/helloetherescan/EtherscanSampleApplication.kt)]
3732
```
3833
ApiKey.takeOff.setApiKey("1I7CRNU2QIU253UBPFVB5UV2C2PBDURAIYZ")
3934
```
4035

41-
Create an Instance of one of the reactive Singles and access values by specifying thread and subscribing. [see [example implementation](https://github.com/EbenezerGH/etherscan-android-api/blob/master/etherscan-sample/src/main/java/jfyg/etherscan/helloetherescan/SampleActivity.kt)]
36+
Create an Instance of one of the reactive singles and access values by specifying thread and subscribing. [see [example implementation](https://github.com/EbenezerGH/etherscan-android-api/blob/master/etherscan-sample/src/main/java/jfyg/etherscan/helloetherescan/SampleActivity.kt)]
4237

4338
Currently Available: ``[accounts, contracts, transactions, blocks, stat]``
4439

4540
Coming Soon: ``[eventLogs, geth, websockets, tokens]``
4641

4742
```
48-
val stat = Stat()
4943
val account = Account()
5044
val contract = ContractABI()
51-
val tx = TxStatus()
5245
val blocks = BlocksMined()
5346
54-
//account test
47+
//account
5548
account.getERC20Tokens("0x4e83362442b8d1bec281594cea3050c8eb01311c")
5649
.observeOn(AndroidSchedulers.mainThread())
5750
?.subscribeBy(
5851
onSuccess = { Log.d(TAG, "The Account Size of Transactions is: ${it.size}") },
5952
onError = { Log.d(TAG, "error receiving ERC20") })
6053
61-
//contracts test
54+
//contracts
6255
contract.getContractABI("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")
6356
.observeOn(AndroidSchedulers.mainThread())
6457
?.subscribeBy(
@@ -67,7 +60,7 @@ Coming Soon: ``[eventLogs, geth, websockets, tokens]``
6760
6861
6962
70-
//blocks test
63+
//blocks
7164
blocks.getBlocksMined("2165403")
7265
.observeOn(AndroidSchedulers.mainThread())
7366
?.subscribeBy(

etherscan-sample/src/main/java/jfyg/etherscan/helloetherescan/SampleActivity.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ class SampleActivity : AppCompatActivity() {
3434
//stat test
3535
stat.getLastPriceInBtc()
3636
.observeOn(AndroidSchedulers.mainThread())
37-
?.subscribeBy(
37+
.subscribeBy(
3838
onSuccess = { Log.d(TAG, "The current price of Ether in Btc: $it") },
3939
onError = { Log.d(TAG, "error receiving stat") })
4040

4141

4242
//account test
4343
account.getERC20Tokens("0x4e83362442b8d1bec281594cea3050c8eb01311c")
4444
.observeOn(AndroidSchedulers.mainThread())
45-
?.subscribeBy(
45+
.subscribeBy(
4646
onSuccess = { Log.d(TAG, "The Account Size of Transactions is: ${it.size}") },
4747
onError = { Log.d(TAG, "error receiving ERC20") })
4848

4949
//contracts test
5050
contract.getContractABI("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")
5151
.observeOn(AndroidSchedulers.mainThread())
52-
?.subscribeBy(
52+
.subscribeBy(
5353
onSuccess = { Log.d(TAG, "The ABI has returned: $it") },
5454
onError = { Log.d(TAG, "error receiving abi contract") })
5555

5656
//transaction test
5757
tx.getTxExecutionStatus("0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a")
5858
.observeOn(AndroidSchedulers.mainThread())
59-
?.subscribeBy(
59+
.subscribeBy(
6060
onSuccess = {
6161
Log.d(TAG, "The transaction's Error Status is: ${it.isError} and " +
6262
"transactions's error description is: ${it.errDescription}")
@@ -66,7 +66,7 @@ class SampleActivity : AppCompatActivity() {
6666
//blocks test
6767
blocks.getBlocksMined("2165403")
6868
.observeOn(AndroidSchedulers.mainThread())
69-
?.subscribeBy(
69+
.subscribeBy(
7070
onSuccess = {
7171
Log.d(TAG, "The block miner is: ${it.blockMiner} and " +
7272
"the first miner : ${it.uncles[0].miner}")

etherscan-sample/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<resources>
2-
<string name="app_name">Hello Etherscan</string>
2+
<string name="app_name">Etherscan Sample</string>
33
<string name="action_settings">Settings</string>
44

55
<string name="my_api_key">1I7CRNU2QIU253UBPFVB5UV2C2PBDURAIY</string>

etherscanapi/src/main/java/jfyg/network/queries/AccountsApi.kt

+29-29
Original file line numberDiff line numberDiff line change
@@ -16,55 +16,55 @@ internal interface AccountsApi {
1616
/**
1717
* Get Ether Balance for a single Address
1818
*/
19-
fun accountBalance(module: String?,
20-
action: String?,
21-
address: String?,
22-
tag: String?): Single<AccountBalanceResponse>
19+
fun accountBalance(module: String,
20+
action: String,
21+
address: String,
22+
tag: String): Single<AccountBalanceResponse>
2323

2424
/**
2525
* Get Ether Balance for multiple Addresses in a single call
2626
*/
27-
fun accountMultiBalance(module: String?,
28-
action: String?,
29-
address: String?,
27+
fun accountMultiBalance(module: String,
28+
action: String,
29+
address: String,
3030
tag: String?): Single<AccountMultiBalanceResponse>
3131

3232
/**
3333
* Get list of blocks mined by address
3434
*/
35-
fun accountBlock(module: String?,
36-
action: String?,
37-
address: String?,
38-
blocktype: String?): Single<AccountBlockResponse>
35+
fun accountBlock(module: String,
36+
action: String,
37+
address: String,
38+
blocktype: String): Single<AccountBlockResponse>
3939

4040
/**
4141
* Get a list of 'Normal' Transactions By Address
4242
*/
43-
fun accountTxs(module: String?,
44-
action: String?,
45-
address: String?,
46-
startblock: String?,
47-
endblock: String?,
48-
sort: String?): Single<AccountTxResponse>
43+
fun accountTxs(module: String,
44+
action: String,
45+
address: String,
46+
startblock: String,
47+
endblock: String,
48+
sort: String): Single<AccountTxResponse>
4949

5050
/**
5151
* [BETA] Get a list of "ERC20 - Token Transfer Events" by Address
5252
*/
53-
fun accountERC20Txs(module: String?,
54-
action: String?,
55-
address: String?,
56-
startblock: String?,
57-
endblock: String?,
58-
sort: String?): Single<ERC20Response>
53+
fun accountERC20Txs(module: String,
54+
action: String,
55+
address: String,
56+
startblock: String,
57+
endblock: String,
58+
sort: String): Single<ERC20Response>
5959

6060
/**
6161
* [BETA] Get a list of 'Internal' Transactions by Address
6262
*/
63-
fun accountInternalTxs(module: String?,
64-
action: String?,
65-
address: String?,
66-
startblock: String?,
67-
endblock: String?,
68-
sort: String?): Single<AccountInternalTxResponse>
63+
fun accountInternalTxs(module: String,
64+
action: String,
65+
address: String,
66+
startblock: String,
67+
endblock: String,
68+
sort: String): Single<AccountInternalTxResponse>
6969

7070
}

etherscanapi/src/main/java/jfyg/network/queries/ApiQuery.kt

+41-41
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,52 @@ import jfyg.network.response.transaction.TxContractReceiptResponse
2020
* A mediator between the responses and errors that come from every query
2121
*/
2222
internal class ApiQuery : AccountsApi, StatsApi, ContractsApi, TransactionsApi, BlocksApi {
23-
// retrofit allows the usage of null parameters when building queries and some parameters being passed in the
24-
// following classes are null, hence the usage of .?func()
2523

26-
override fun accountBalance(module: String?,
27-
action: String?,
28-
address: String?,
29-
tag: String?): Single<AccountBalanceResponse> =
24+
override fun accountBalance(module: String,
25+
action: String,
26+
address: String,
27+
tag: String): Single<AccountBalanceResponse> =
3028
RestClient().getQuery().getAccountBalance(module, action, address, tag, ApiKey.takeOff.callApiKey())
3129

32-
override fun accountMultiBalance(module: String?,
33-
action: String?,
34-
address: String?,
30+
override fun accountMultiBalance(module: String,
31+
action: String,
32+
address: String,
3533
tag: String?): Single<AccountMultiBalanceResponse> =
3634
RestClient().getQuery().getAccountMultiBalance(module, action, address, tag, ApiKey.takeOff.callApiKey())
3735

38-
override fun accountBlock(module: String?,
39-
action: String?,
40-
address: String?,
41-
blocktype: String?): Single<AccountBlockResponse> =
36+
override fun accountBlock(module: String,
37+
action: String,
38+
address: String,
39+
blocktype: String): Single<AccountBlockResponse> =
4240
RestClient().getQuery().getAccountBlock(module, action, address, blocktype, ApiKey.takeOff.callApiKey())
4341

44-
override fun accountTxs(module: String?,
45-
action: String?,
46-
address: String?,
47-
startblock: String?,
48-
endblock: String?,
49-
sort: String?): Single<AccountTxResponse> =
42+
override fun accountTxs(module: String,
43+
action: String,
44+
address: String,
45+
startblock: String,
46+
endblock: String,
47+
sort: String): Single<AccountTxResponse> =
5048
RestClient().getQuery().getAccountTransactions(module, action, address, startblock, endblock, sort, ApiKey.takeOff.callApiKey())
5149

52-
override fun accountERC20Txs(module: String?,
53-
action: String?,
54-
address: String?,
55-
startblock: String?,
56-
endblock: String?,
57-
sort: String?): Single<ERC20Response> =
50+
override fun accountERC20Txs(module: String,
51+
action: String,
52+
address: String,
53+
startblock: String,
54+
endblock: String,
55+
sort: String): Single<ERC20Response> =
5856
RestClient().getQuery().getAccountERC20Transactions(module, action, address, startblock, endblock, sort, ApiKey.takeOff.callApiKey())
5957

60-
override fun accountInternalTxs(module: String?,
61-
action: String?,
62-
address: String?,
63-
startblock: String?,
64-
endblock: String?,
65-
sort: String?): Single<AccountInternalTxResponse> =
58+
override fun accountInternalTxs(module: String,
59+
action: String,
60+
address: String,
61+
startblock: String,
62+
endblock: String,
63+
sort: String): Single<AccountInternalTxResponse> =
6664
RestClient().getQuery().getAccountInternalTransactions(module, action, address, startblock, endblock, sort, ApiKey.takeOff.callApiKey())
6765

68-
override fun contractABI(module: String?, action: String?, address: String?): Single<ContractResponse> =
66+
override fun contractABI(module: String,
67+
action: String,
68+
address: String): Single<ContractResponse> =
6969
RestClient().getQuery().getSmartContract(module, action, address, ApiKey.takeOff.callApiKey())
7070

7171
override fun statPrice(module: String,
@@ -77,19 +77,19 @@ internal class ApiQuery : AccountsApi, StatsApi, ContractsApi, TransactionsApi,
7777
action: String): Single<StatSupplyResponse> =
7878
RestClient().getQuery().getStatSupply(module, action, ApiKey.takeOff.callApiKey())
7979

80-
override fun txExecutionStatus(module: String?,
81-
action: String?,
82-
txHash: String?): Single<TxContractExecutionResponse> =
80+
override fun txExecutionStatus(module: String,
81+
action: String,
82+
txHash: String): Single<TxContractExecutionResponse> =
8383
RestClient().getQuery().getContractTransactionExecution(module, action, txHash, ApiKey.takeOff.callApiKey())
8484

85-
override fun txReceiptStatus(module: String?,
86-
action: String?,
87-
txHash: String?): Single<TxContractReceiptResponse> =
85+
override fun txReceiptStatus(module: String,
86+
action: String,
87+
txHash: String): Single<TxContractReceiptResponse> =
8888
RestClient().getQuery().getContractTransactionReceipt(module, action, txHash, ApiKey.takeOff.callApiKey())
8989

90-
override fun blocksMined(module: String?,
91-
action: String?,
92-
blockno: String?): Single<BlockResponse> =
90+
override fun blocksMined(module: String,
91+
action: String,
92+
blockno: String): Single<BlockResponse> =
9393
RestClient().getQuery().getBlocksMined(module, action, blockno, ApiKey.takeOff.callApiKey())
9494

9595
}

etherscanapi/src/main/java/jfyg/network/queries/BlocksApi.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ internal interface BlocksApi {
1111
/**
1212
* [BETA] Get Block And Uncle Rewards by BlockNo
1313
*/
14-
fun blocksMined(module: String?,
15-
action: String?,
16-
blockno: String?): Single<BlockResponse>
14+
fun blocksMined(module: String,
15+
action: String,
16+
blockno: String): Single<BlockResponse>
1717

1818
}

etherscanapi/src/main/java/jfyg/network/queries/ContractsApi.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ internal interface ContractsApi {
1313
* Get Contract ABI for Verified Contract Source Codes
1414
* https://etherscan.io/contractsVerified
1515
*/
16-
fun contractABI(module: String?,
17-
action: String?,
18-
address: String?): Single<ContractResponse>
16+
fun contractABI(module: String,
17+
action: String,
18+
address: String): Single<ContractResponse>
1919

2020
}

etherscanapi/src/main/java/jfyg/network/queries/StatsApi.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ internal interface StatsApi {
99
/**
1010
* Get ETHER LastPrice
1111
*/
12-
fun statPrice(module: String, action: String): Single<StatPriceResponse>
12+
fun statPrice(module: String,
13+
action: String): Single<StatPriceResponse>
1314

1415
/**
1516
* Get Total Supply of Ether
1617
*/
17-
fun statSupply(module: String, action: String): Single<StatSupplyResponse>
18+
fun statSupply(module: String,
19+
action: String): Single<StatSupplyResponse>
1820

1921
}

etherscanapi/src/main/java/jfyg/network/queries/TransactionsApi.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ internal interface TransactionsApi {
1313
* [BETA] Check Contract Execution Status (if there was an error during contract execution)
1414
* Note: isError":"0" = Pass , isError":"1" = Error during Contract Execution
1515
*/
16-
fun txExecutionStatus(module: String?,
17-
action: String?,
18-
txHash: String?): Single<TxContractExecutionResponse>
16+
fun txExecutionStatus(module: String,
17+
action: String,
18+
txHash: String): Single<TxContractExecutionResponse>
1919
/**
2020
* [BETA] Check Transaction Receipt Status (Only applicable for Post Byzantium fork transactions)
2121
* Note: status: 0 = Fail, 1 = Pass. Will return null/empty value for pre-byzantium fork
2222
*/
23-
fun txReceiptStatus(module: String?,
24-
action: String?,
25-
txHash: String?): Single<TxContractReceiptResponse>
23+
fun txReceiptStatus(module: String,
24+
action: String,
25+
txHash: String): Single<TxContractReceiptResponse>
2626

2727

2828
}

0 commit comments

Comments
 (0)