Skip to content

Commit 919f849

Browse files
author
Ebenezer Ackon
committed
clean up #63,#64,#67,#68
1 parent 0460be2 commit 919f849

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+417
-316
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Generic badge](https://img.shields.io/badge/EtherscanApi-UP-brightgreen.svg)](https://api.etherscan.io/api?module=stats&action=ethprice&apikey=YourApiKeyToken)
2-
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/EbenezerGH/hello_etherscan/blob/update-readme-badges/LICENSE)
2+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/EbenezerGH/hello_etherscan/blob/update-documentation/LICENSE)
33
[![CircleCI](https://circleci.com/gh/EbenezerGH/hello_etherscan/tree/master.svg?style=svg)](https://circleci.com/gh/EbenezerGH/hello_etherscan/tree/master)
44

55

app/src/main/java/jfyg/etherscan/helloetherescan/MainActivity.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import android.util.Log
66
import io.reactivex.android.schedulers.AndroidSchedulers
77
import io.reactivex.rxkotlin.subscribeBy
88
import jfyg.account.Account
9-
import jfyg.contract.SmartContract
9+
import jfyg.contract.ContractABI
1010
import jfyg.stat.Stat
11-
import jfyg.transaction.TransactionContractStatus
11+
import jfyg.transaction.TxContractStatus
1212
import kotlinx.android.synthetic.main.activity_main.*
1313

1414

@@ -23,8 +23,8 @@ class MainActivity : AppCompatActivity() {
2323
//************************************************ Used To Test Singles returned from etherscanapi Module
2424
val stat = Stat()
2525
val account = Account()
26-
val contract = SmartContract()
27-
val transaction = TransactionContractStatus()
26+
val contract = ContractABI()
27+
val tx = TxContractStatus()
2828

2929

3030
fab.setOnClickListener {
@@ -50,7 +50,7 @@ class MainActivity : AppCompatActivity() {
5050
}
5151

5252
//transaction test
53-
transaction.getTransactionExecutionStatus("0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a")
53+
tx.getTxExecutionStatus("0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a")
5454
.observeOn(AndroidSchedulers.mainThread())
5555
?.subscribeBy {
5656
Log.d(TAG, "The transaction's Error Status is: ${it.isError} and " +

etherscanapi/src/main/java/jfyg/account/Account.kt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package jfyg.account
33
import io.reactivex.Single
44
import jfyg.model.Balances
55
import jfyg.model.Blocks
6-
import jfyg.model.Transactions
7-
import jfyg.model.TransactionsInternal
6+
import jfyg.model.Txs
7+
import jfyg.model.TxsInternal
88
import jfyg.queries.QueryMediator
99
import jfyg.utils.QueryUtils
1010

11+
/**
12+
* https://etherscan.io/apis#accounts
13+
*/
1114
class Account : AccountContract {
1215

1316
private val query = QueryMediator()
@@ -18,42 +21,63 @@ class Account : AccountContract {
1821

1922
private val queryUtil = QueryUtils()
2023

24+
/**
25+
* Return account balance
26+
*/
2127
override fun getBalance(address: String?): Single<Double> =
2228
query.accountBalance("account",
2329
"balance",
2430
address,
2531
"latest").map { it.result?.toDouble() }
2632

33+
/**
34+
* Return balances of multiple accounts separated by commas
35+
*/
2736
override fun getMultiBalance(addresses: ArrayList<String>?): Single<ArrayList<Balances>> =
2837
query.accountMultiBalance("account",
2938
"balancemulti",
30-
queryUtil.retrieveAccounts(addresses),
39+
queryUtil.retrieveList(addresses),
3140
"latest").map { it.result }
3241

42+
/**
43+
* Get list of blocks mined by address
44+
*/
3345
override fun getBlocks(address: String?): Single<ArrayList<Blocks>> =
3446
query.accountBlock("account",
3547
"getminedblocks",
3648
address,
3749
"blocks").map { it.result }
3850

39-
override fun getTransactions(address: String?): Single<ArrayList<Transactions>> =
51+
/**
52+
* Get a list of 'Normal' Transactions By Address
53+
*/
54+
override fun getTransactions(address: String?): Single<ArrayList<Txs>> =
4055
query.accountTransactions("account",
4156
"txlist",
4257
address,
4358
"0",
4459
"99999999",
4560
"asc").map { it.result }
4661

47-
override fun getInternalTransactions(address: String?): Single<ArrayList<TransactionsInternal>> =
62+
/**
63+
* Get a list of 'Internal' Transactions by Address
64+
*/
65+
override fun getInternalTransactions(address: String?): Single<ArrayList<TxsInternal>> =
4866
query.accountInternalTransactions("account",
4967
"txlistinternal",
5068
address,
5169
"0",
5270
"99999999",
5371
"asc").map { it.result }
5472

73+
/**
74+
* Return network status
75+
*/
5576
override fun getNetworkStatus(): Single<String> = genericNetworkQuery.map { it.status }
5677

78+
/**
79+
* Return network message
80+
*/
5781
override fun getNetworkMessage(): Single<String> = genericNetworkQuery.map { it.message }
5882

5983
}

etherscanapi/src/main/java/jfyg/account/AccountContract.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@ package jfyg.account
33
import io.reactivex.Single
44
import jfyg.model.Balances
55
import jfyg.model.Blocks
6-
import jfyg.model.Transactions
7-
import jfyg.model.TransactionsInternal
6+
import jfyg.model.Txs
7+
import jfyg.model.TxsInternal
88

9+
/**
10+
* https://etherscan.io/apis#accounts
11+
*/
912
internal interface AccountContract {
1013

11-
/**
12-
* Return network status
13-
*/
14-
fun getNetworkStatus(): Single<String>
15-
16-
/**
17-
* Return network message
18-
*/
19-
fun getNetworkMessage(): Single<String>
20-
2114
/**
2215
* Return account balance
2316
*/
@@ -36,11 +29,20 @@ internal interface AccountContract {
3629
/**
3730
* Get a list of 'Normal' Transactions By Address
3831
*/
39-
fun getTransactions(address: String?): Single<ArrayList<Transactions>>
32+
fun getTransactions(address: String?): Single<ArrayList<Txs>>
4033

4134
/**
4235
* Get a list of 'Internal' Transactions by Address
4336
*/
44-
fun getInternalTransactions(address: String?): Single<ArrayList<TransactionsInternal>>
37+
fun getInternalTransactions(address: String?): Single<ArrayList<TxsInternal>>
4538

39+
/**
40+
* Return network status
41+
*/
42+
fun getNetworkStatus(): Single<String>
43+
44+
/**
45+
* Return network message
46+
*/
47+
fun getNetworkMessage(): Single<String>
4648
}

etherscanapi/src/main/java/jfyg/contract/SmartContract.kt renamed to etherscanapi/src/main/java/jfyg/contract/ContractABI.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,31 @@ package jfyg.contract
33
import io.reactivex.Single
44
import jfyg.queries.QueryMediator
55

6-
class SmartContract : SmartContractContract {
6+
/**
7+
* Newly verified Contracts are synced to the API servers within 5 minutes or less
8+
* https://etherscan.io/apis#contracts
9+
*/
10+
class ContractABI : ContractABIContract {
711
private val query = QueryMediator()
8-
private val abiQuery = query.abiContract("contract",
12+
private val abiQuery = query.contractABI("contract",
913
"getabi",
1014
"0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")
1115

12-
override fun getContractABI(address: String?): Single<String> = query.abiContract("contract",
16+
/**
17+
* Return contract ABI for Verified Contract Source Code
18+
*/
19+
override fun getContractABI(address: String?): Single<String> = query.contractABI("contract",
1320
"getabi",
1421
address).map { it.result }
1522

23+
/**
24+
* Return network status
25+
*/
1626
override fun getNetworkStatus(): Single<String> = abiQuery.map { it.status }
1727

28+
/**
29+
* Return network message
30+
*/
1831
override fun getNetworkMessage(): Single<String> = abiQuery.map { it.message }
1932

2033
}

etherscanapi/src/main/java/jfyg/contract/SmartContractContract.kt renamed to etherscanapi/src/main/java/jfyg/contract/ContractABIContract.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ package jfyg.contract
22

33
import io.reactivex.Single
44

5-
6-
internal interface SmartContractContract {
5+
/**
6+
* Newly verified Contracts are synced to the API servers within 5 minutes or less
7+
* https://etherscan.io/apis#contracts
8+
*/
9+
internal interface ContractABIContract {
710

811
/**
912
* Return contract ABI for Verified Contract Source Code

etherscanapi/src/main/java/jfyg/model/SmartContracts.kt

Lines changed: 0 additions & 3 deletions
This file was deleted.

etherscanapi/src/main/java/jfyg/model/Transactions.kt

Lines changed: 0 additions & 42 deletions
This file was deleted.

etherscanapi/src/main/java/jfyg/model/TransactionsInternal.kt

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package jfyg.model
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
data class Txs(var blockNumber: String? = null,
6+
7+
var timeStamp: String? = null,
8+
9+
var hash: String? = null,
10+
11+
var nonce: String? = null,
12+
13+
var blockHash: String? = null,
14+
15+
var transactionIndex: String? = null,
16+
17+
@SerializedName("from")
18+
var transactionFrom: String? = null,
19+
20+
@SerializedName("to")
21+
var transactionTo: String? = null,
22+
23+
var value: String? = null,
24+
25+
var gas: String? = null,
26+
27+
var gasPrice: String? = null,
28+
29+
var isError: String? = null,
30+
31+
@SerializedName("txreceipt_status")
32+
var receiptStatus: String? = null,
33+
34+
var input: String? = null,
35+
36+
var contractAddress: String? = null,
37+
38+
var cumulativeGasUsed: String? = null,
39+
40+
var gasUsed: String? = null,
41+
42+
var confirmations: String? = null)

0 commit comments

Comments
 (0)