Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Generic badge](https://img.shields.io/badge/EtherscanApi-UP-brightgreen.svg)](https://api.etherscan.io/api?module=stats&action=ethprice&apikey=YourApiKeyToken)
[![Generic badge](https://img.shields.io/badge/CircleCI-UP-brightgreen.svg)](https://circleci.com/gh/EbenezerGH/hello_etherscan/tree/master)
[![Generic badge](https://img.shields.io/badge/Version-v0.8.0-lightgrey.svg)](https://github.com/EbenezerGH/etherscan-android-api/releases)
[![Generic badge](https://img.shields.io/badge/CircleCI-PASS-brightgreen.svg)](https://circleci.com/gh/EbenezerGH/hello_etherscan/tree/master)
[![Generic badge](https://img.shields.io/badge/Version-v0.9.0-lightgrey.svg)](https://jitpack.io/#EbenezerGH/etherscan-android-api)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/EbenezerGH/hello_etherscan/blob/update-documentation/LICENSE)

# etherscan-android-api
Expand All @@ -23,42 +23,35 @@ Add JitPack to your root build.gradle at the end of repositories
Add the dependency
```
dependencies {
implementation 'com.github.EbenezerGH:hello_etherscan:v0.8.0'
implementation 'com.github.EbenezerGH:hello_etherscan:v0.9.0'
}
```
import a reactive android library to handle the reactive stream being passed into your module. For instance I used the following:


implementation 'io.reactivex.rxjava2:rxandroid:x.y.z'
implementation 'io.reactivex.rxjava2:rxkotlin:x.y.z'


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)]
```
ApiKey.takeOff.setApiKey("1I7CRNU2QIU253UBPFVB5UV2C2PBDURAIYZ")
```

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)]
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)]

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

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

```
val stat = Stat()
val account = Account()
val contract = ContractABI()
val tx = TxStatus()
val blocks = BlocksMined()

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

//contracts test
//contracts
contract.getContractABI("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")
.observeOn(AndroidSchedulers.mainThread())
?.subscribeBy(
Expand All @@ -67,7 +60,7 @@ Coming Soon: ``[eventLogs, geth, websockets, tokens]``



//blocks test
//blocks
blocks.getBlocksMined("2165403")
.observeOn(AndroidSchedulers.mainThread())
?.subscribeBy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ class SampleActivity : AppCompatActivity() {
//stat test
stat.getLastPriceInBtc()
.observeOn(AndroidSchedulers.mainThread())
?.subscribeBy(
.subscribeBy(
onSuccess = { Log.d(TAG, "The current price of Ether in Btc: $it") },
onError = { Log.d(TAG, "error receiving stat") })


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

//contracts test
contract.getContractABI("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")
.observeOn(AndroidSchedulers.mainThread())
?.subscribeBy(
.subscribeBy(
onSuccess = { Log.d(TAG, "The ABI has returned: $it") },
onError = { Log.d(TAG, "error receiving abi contract") })

//transaction test
tx.getTxExecutionStatus("0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a")
.observeOn(AndroidSchedulers.mainThread())
?.subscribeBy(
.subscribeBy(
onSuccess = {
Log.d(TAG, "The transaction's Error Status is: ${it.isError} and " +
"transactions's error description is: ${it.errDescription}")
Expand All @@ -66,7 +66,7 @@ class SampleActivity : AppCompatActivity() {
//blocks test
blocks.getBlocksMined("2165403")
.observeOn(AndroidSchedulers.mainThread())
?.subscribeBy(
.subscribeBy(
onSuccess = {
Log.d(TAG, "The block miner is: ${it.blockMiner} and " +
"the first miner : ${it.uncles[0].miner}")
Expand Down
2 changes: 1 addition & 1 deletion etherscan-sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">Hello Etherscan</string>
<string name="app_name">Etherscan Sample</string>
<string name="action_settings">Settings</string>

<string name="my_api_key">1I7CRNU2QIU253UBPFVB5UV2C2PBDURAIY</string>
Expand Down
58 changes: 29 additions & 29 deletions etherscanapi/src/main/java/jfyg/network/queries/AccountsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,55 @@ internal interface AccountsApi {
/**
* Get Ether Balance for a single Address
*/
fun accountBalance(module: String?,
action: String?,
address: String?,
tag: String?): Single<AccountBalanceResponse>
fun accountBalance(module: String,
action: String,
address: String,
tag: String): Single<AccountBalanceResponse>

/**
* Get Ether Balance for multiple Addresses in a single call
*/
fun accountMultiBalance(module: String?,
action: String?,
address: String?,
fun accountMultiBalance(module: String,
action: String,
address: String,
tag: String?): Single<AccountMultiBalanceResponse>

/**
* Get list of blocks mined by address
*/
fun accountBlock(module: String?,
action: String?,
address: String?,
blocktype: String?): Single<AccountBlockResponse>
fun accountBlock(module: String,
action: String,
address: String,
blocktype: String): Single<AccountBlockResponse>

/**
* Get a list of 'Normal' Transactions By Address
*/
fun accountTxs(module: String?,
action: String?,
address: String?,
startblock: String?,
endblock: String?,
sort: String?): Single<AccountTxResponse>
fun accountTxs(module: String,
action: String,
address: String,
startblock: String,
endblock: String,
sort: String): Single<AccountTxResponse>

/**
* [BETA] Get a list of "ERC20 - Token Transfer Events" by Address
*/
fun accountERC20Txs(module: String?,
action: String?,
address: String?,
startblock: String?,
endblock: String?,
sort: String?): Single<ERC20Response>
fun accountERC20Txs(module: String,
action: String,
address: String,
startblock: String,
endblock: String,
sort: String): Single<ERC20Response>

/**
* [BETA] Get a list of 'Internal' Transactions by Address
*/
fun accountInternalTxs(module: String?,
action: String?,
address: String?,
startblock: String?,
endblock: String?,
sort: String?): Single<AccountInternalTxResponse>
fun accountInternalTxs(module: String,
action: String,
address: String,
startblock: String,
endblock: String,
sort: String): Single<AccountInternalTxResponse>

}
82 changes: 41 additions & 41 deletions etherscanapi/src/main/java/jfyg/network/queries/ApiQuery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,52 @@ import jfyg.network.response.transaction.TxContractReceiptResponse
* A mediator between the responses and errors that come from every query
*/
internal class ApiQuery : AccountsApi, StatsApi, ContractsApi, TransactionsApi, BlocksApi {
// retrofit allows the usage of null parameters when building queries and some parameters being passed in the
// following classes are null, hence the usage of .?func()

override fun accountBalance(module: String?,
action: String?,
address: String?,
tag: String?): Single<AccountBalanceResponse> =
override fun accountBalance(module: String,
action: String,
address: String,
tag: String): Single<AccountBalanceResponse> =
RestClient().getQuery().getAccountBalance(module, action, address, tag, ApiKey.takeOff.callApiKey())

override fun accountMultiBalance(module: String?,
action: String?,
address: String?,
override fun accountMultiBalance(module: String,
action: String,
address: String,
tag: String?): Single<AccountMultiBalanceResponse> =
RestClient().getQuery().getAccountMultiBalance(module, action, address, tag, ApiKey.takeOff.callApiKey())

override fun accountBlock(module: String?,
action: String?,
address: String?,
blocktype: String?): Single<AccountBlockResponse> =
override fun accountBlock(module: String,
action: String,
address: String,
blocktype: String): Single<AccountBlockResponse> =
RestClient().getQuery().getAccountBlock(module, action, address, blocktype, ApiKey.takeOff.callApiKey())

override fun accountTxs(module: String?,
action: String?,
address: String?,
startblock: String?,
endblock: String?,
sort: String?): Single<AccountTxResponse> =
override fun accountTxs(module: String,
action: String,
address: String,
startblock: String,
endblock: String,
sort: String): Single<AccountTxResponse> =
RestClient().getQuery().getAccountTransactions(module, action, address, startblock, endblock, sort, ApiKey.takeOff.callApiKey())

override fun accountERC20Txs(module: String?,
action: String?,
address: String?,
startblock: String?,
endblock: String?,
sort: String?): Single<ERC20Response> =
override fun accountERC20Txs(module: String,
action: String,
address: String,
startblock: String,
endblock: String,
sort: String): Single<ERC20Response> =
RestClient().getQuery().getAccountERC20Transactions(module, action, address, startblock, endblock, sort, ApiKey.takeOff.callApiKey())

override fun accountInternalTxs(module: String?,
action: String?,
address: String?,
startblock: String?,
endblock: String?,
sort: String?): Single<AccountInternalTxResponse> =
override fun accountInternalTxs(module: String,
action: String,
address: String,
startblock: String,
endblock: String,
sort: String): Single<AccountInternalTxResponse> =
RestClient().getQuery().getAccountInternalTransactions(module, action, address, startblock, endblock, sort, ApiKey.takeOff.callApiKey())

override fun contractABI(module: String?, action: String?, address: String?): Single<ContractResponse> =
override fun contractABI(module: String,
action: String,
address: String): Single<ContractResponse> =
RestClient().getQuery().getSmartContract(module, action, address, ApiKey.takeOff.callApiKey())

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

override fun txExecutionStatus(module: String?,
action: String?,
txHash: String?): Single<TxContractExecutionResponse> =
override fun txExecutionStatus(module: String,
action: String,
txHash: String): Single<TxContractExecutionResponse> =
RestClient().getQuery().getContractTransactionExecution(module, action, txHash, ApiKey.takeOff.callApiKey())

override fun txReceiptStatus(module: String?,
action: String?,
txHash: String?): Single<TxContractReceiptResponse> =
override fun txReceiptStatus(module: String,
action: String,
txHash: String): Single<TxContractReceiptResponse> =
RestClient().getQuery().getContractTransactionReceipt(module, action, txHash, ApiKey.takeOff.callApiKey())

override fun blocksMined(module: String?,
action: String?,
blockno: String?): Single<BlockResponse> =
override fun blocksMined(module: String,
action: String,
blockno: String): Single<BlockResponse> =
RestClient().getQuery().getBlocksMined(module, action, blockno, ApiKey.takeOff.callApiKey())

}
6 changes: 3 additions & 3 deletions etherscanapi/src/main/java/jfyg/network/queries/BlocksApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ internal interface BlocksApi {
/**
* [BETA] Get Block And Uncle Rewards by BlockNo
*/
fun blocksMined(module: String?,
action: String?,
blockno: String?): Single<BlockResponse>
fun blocksMined(module: String,
action: String,
blockno: String): Single<BlockResponse>

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ internal interface ContractsApi {
* Get Contract ABI for Verified Contract Source Codes
* https://etherscan.io/contractsVerified
*/
fun contractABI(module: String?,
action: String?,
address: String?): Single<ContractResponse>
fun contractABI(module: String,
action: String,
address: String): Single<ContractResponse>

}
6 changes: 4 additions & 2 deletions etherscanapi/src/main/java/jfyg/network/queries/StatsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ internal interface StatsApi {
/**
* Get ETHER LastPrice
*/
fun statPrice(module: String, action: String): Single<StatPriceResponse>
fun statPrice(module: String,
action: String): Single<StatPriceResponse>

/**
* Get Total Supply of Ether
*/
fun statSupply(module: String, action: String): Single<StatSupplyResponse>
fun statSupply(module: String,
action: String): Single<StatSupplyResponse>

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ internal interface TransactionsApi {
* [BETA] Check Contract Execution Status (if there was an error during contract execution)
* Note: isError":"0" = Pass , isError":"1" = Error during Contract Execution
*/
fun txExecutionStatus(module: String?,
action: String?,
txHash: String?): Single<TxContractExecutionResponse>
fun txExecutionStatus(module: String,
action: String,
txHash: String): Single<TxContractExecutionResponse>
/**
* [BETA] Check Transaction Receipt Status (Only applicable for Post Byzantium fork transactions)
* Note: status: 0 = Fail, 1 = Pass. Will return null/empty value for pre-byzantium fork
*/
fun txReceiptStatus(module: String?,
action: String?,
txHash: String?): Single<TxContractReceiptResponse>
fun txReceiptStatus(module: String,
action: String,
txHash: String): Single<TxContractReceiptResponse>


}
Loading