From 10a66fdb73d2fa89b398446811b4e6d238be2825 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 13 Sep 2017 17:52:36 -0400 Subject: [PATCH] Documenting, and change enum logic --- .../crystalwallet/dao/CrystalDatabase.java | 5 +++- .../crystalwallet/enums/CryptoCoin.java | 21 +++++++-------- .../crystalwallet/enums/CryptoNet.java | 15 +++++++++-- .../crystalwallet/models/AccountSeed.java | 16 +++++++++++- .../crystalwallet/models/CryptoAsset.java | 10 +++++++ .../models/CryptoCoinTransaction.java | 26 +++++++++++++++++++ .../models/CryptoNetAccount.java | 23 ++++++++++++++-- 7 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/models/CryptoAsset.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java index 6165a48..15803ea 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java @@ -1,7 +1,9 @@ package cy.agorise.crystalwallet.dao; import android.arch.persistence.db.SupportSQLiteDatabase; -import android.arch.persistence.room.*; +import android.arch.persistence.room.Database; +import android.arch.persistence.room.Room; +import android.arch.persistence.room.RoomDatabase; import android.arch.persistence.room.migration.Migration; import android.content.Context; @@ -10,6 +12,7 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction; import cy.agorise.crystalwallet.models.CryptoNetAccount; /** + * Manage the Database * Created by Henry Varona on 4/9/2017. */ diff --git a/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoCoin.java b/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoCoin.java index 4343dc7..1c385b7 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoCoin.java +++ b/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoCoin.java @@ -7,23 +7,22 @@ import java.io.Serializable; */ public enum CryptoCoin implements Serializable { - BITCOIN(CryptoNet.BITCOIN,"BTC",8,6), - BITCOIN_TEST(CryptoNet.BITCOIN_TEST,"BTC",8,6), - LITECOIN(CryptoNet.LITECOIN,"LTC",8,6), - DASH(CryptoNet.DASH,"DASH",8,6), - DOGECOIN(CryptoNet.DOGECOIN,"DOGE",8,6), - BITSHARES(CryptoNet.BITSHARES,"BTS",8,6); + BITCOIN(CryptoNet.BITCOIN,"BTC",8), + BITCOIN_TEST(CryptoNet.BITCOIN_TEST,"BTC",8), + LITECOIN(CryptoNet.LITECOIN,"LTC",8), + DASH(CryptoNet.DASH,"DASH",8), + DOGECOIN(CryptoNet.DOGECOIN,"DOGE",8), + BITSHARES(CryptoNet.BITSHARES,"BTS",8); protected CryptoNet cryptoNet; protected String label; protected int precision; - protected int confirmationsNeeded; - CryptoCoin(CryptoNet cryptoNet, String label, int precision, int confirmationsNeeded){ + CryptoCoin(CryptoNet cryptoNet, String label, int precision){ this.cryptoNet = cryptoNet; this.label = label; this.precision = precision; - this.confirmationsNeeded = confirmationsNeeded; + } public CryptoNet getCryptoNet(){ @@ -35,7 +34,5 @@ public enum CryptoCoin implements Serializable { public int getPrecision(){ return this.precision; } - public int getConfirmationsNeeded(){ - return this.confirmationsNeeded; - } + } diff --git a/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoNet.java b/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoNet.java index 9872dd6..0f75732 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoNet.java +++ b/app/src/main/java/cy/agorise/crystalwallet/enums/CryptoNet.java @@ -3,19 +3,30 @@ package cy.agorise.crystalwallet.enums; import java.io.Serializable; /** + * CryptoNet Enumeration, a Crypto Net is define as the net where a CryptoCoin works, iniside the + * CrypotNet is where the transaction and balance works, using the CryptoCoin Assets + * * Created by Henry Varona on 12/9/2017. */ public enum CryptoNet implements Serializable { - BITCOIN("BITCOIN"), BITCOIN_TEST("BITCOIN(TEST)"), LITECOIN("LITECOIN"), DASH("DASH"), DOGECOIN("DOGECOIN"), BITSHARES("BITSHARES"); + BITCOIN("BITCOIN",6), BITCOIN_TEST("BITCOIN(TEST)",6), LITECOIN("LITECOIN",6), DASH("DASH",6), DOGECOIN("DOGECOIN",6), BITSHARES("BITSHARES",1), STEEM("STEEN",1); protected String label; - CryptoNet(String label){ + protected int confirmationsNeeded; + + + CryptoNet(String label,int confirmationsNeeded){ this.label = label; + this.confirmationsNeeded = confirmationsNeeded; } public String getLabel(){ return this.label; } + + public int getConfirmationsNeeded(){ + return this.confirmationsNeeded; + } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/AccountSeed.java b/app/src/main/java/cy/agorise/crystalwallet/models/AccountSeed.java index f2c67f9..aff26d1 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/AccountSeed.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/AccountSeed.java @@ -1,20 +1,34 @@ package cy.agorise.crystalwallet.models; -import android.arch.persistence.room.*; + +import android.arch.persistence.room.ColumnInfo; +import android.arch.persistence.room.Entity; +import android.arch.persistence.room.PrimaryKey; /** + * Represents a type of crypto seed for HD wallets + * * Created by Henry Varona on 6/9/2017. */ @Entity(tableName = "account_seed") public class AccountSeed { + /** + * The id on the database + */ @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") private int mId; + /** + * The name or tag of this seed + */ @ColumnInfo(name = "name") private String mName; + /** + * The bytes of the master seed + */ @ColumnInfo(name = "master_seed") private String mMasterSeed; diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoAsset.java b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoAsset.java new file mode 100644 index 0000000..f2a318e --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoAsset.java @@ -0,0 +1,10 @@ +package cy.agorise.crystalwallet.models; + +/** + * Represents each asset in transaction and balances + * + * Created by henry Henry Varona on 11/9/2017. + */ + +public class CryptoAsset { +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransaction.java b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransaction.java index 0f1ca61..c1b66a4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransaction.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransaction.java @@ -9,26 +9,52 @@ import java.util.Date; import cy.agorise.crystalwallet.enums.CryptoCoin; /** + * Represents a generic CryptoNet Transaction + * * Created by Henry Varona on 11/9/2017. */ @Entity(tableName="crypto_coin_transaction") public class CryptoCoinTransaction { + /** + * The account associated with this transaction + */ protected CryptoNetAccount account; + /** + * The id on the database + */ @PrimaryKey(autoGenerate = true) @ColumnInfo(name="id") protected int id; + /** + * The full date of this transaction + */ @ColumnInfo(name="date") protected Date date; + /** + * If this transaction is input of the account associated with it + */ @ColumnInfo(name="is_input") protected boolean isInput; + /** + * The id of the account assoiciated, this is used for the foreign key definition + */ @ColumnInfo(name="account_id") protected int accountId; + /** + * The amount of asset is moved in this transaction + */ @ColumnInfo(name="amount") protected int amount; + /** + * The crypto Coin associated with this transaction + */ @ColumnInfo(name="crypto_coin") protected CryptoCoin coin; + /** + * If this transaction is confirmed + */ @ColumnInfo(name="is_confirmed") protected boolean isConfirmed; diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetAccount.java b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetAccount.java index 694f0d1..b6d73a4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetAccount.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetAccount.java @@ -1,28 +1,47 @@ package cy.agorise.crystalwallet.models; -import android.arch.persistence.room.*; + +import android.arch.persistence.room.ColumnInfo; +import android.arch.persistence.room.Entity; +import android.arch.persistence.room.ForeignKey; +import android.arch.persistence.room.Index; +import android.arch.persistence.room.PrimaryKey; /** + * Represents a geneeric CryptoNet Account + * * Created by Henry Varona on 6/9/2017. */ -@Entity (tableName = "crypto_net_account", +@Entity(tableName = "crypto_net_account", indices = {@Index("id"),@Index("seed_id")}, foreignKeys = @ForeignKey(entity = AccountSeed.class, parentColumns = "id", childColumns = "seed_id")) public class CryptoNetAccount { + /** + * The id on the database + */ @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") private int mId; + /** + * The id of the seed used by this account + */ @ColumnInfo(name = "seed_id") private int mSeedId; + /** + * The account number on the bip44 or slip44 + */ @ColumnInfo(name = "account_number") private int mAccountNumber; + /** + * The account index + */ @ColumnInfo(name = "account_index") private int mAccountIndex;