Documenting, and change enum logic

master
henry 2017-09-13 17:52:36 -04:00
parent 81da660a2e
commit 10a66fdb73
7 changed files with 98 additions and 18 deletions

View File

@ -1,7 +1,9 @@
package cy.agorise.crystalwallet.dao; package cy.agorise.crystalwallet.dao;
import android.arch.persistence.db.SupportSQLiteDatabase; 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.arch.persistence.room.migration.Migration;
import android.content.Context; import android.content.Context;
@ -10,6 +12,7 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
import cy.agorise.crystalwallet.models.CryptoNetAccount; import cy.agorise.crystalwallet.models.CryptoNetAccount;
/** /**
* Manage the Database
* Created by Henry Varona on 4/9/2017. * Created by Henry Varona on 4/9/2017.
*/ */

View File

@ -7,23 +7,22 @@ import java.io.Serializable;
*/ */
public enum CryptoCoin implements Serializable { public enum CryptoCoin implements Serializable {
BITCOIN(CryptoNet.BITCOIN,"BTC",8,6), BITCOIN(CryptoNet.BITCOIN,"BTC",8),
BITCOIN_TEST(CryptoNet.BITCOIN_TEST,"BTC",8,6), BITCOIN_TEST(CryptoNet.BITCOIN_TEST,"BTC",8),
LITECOIN(CryptoNet.LITECOIN,"LTC",8,6), LITECOIN(CryptoNet.LITECOIN,"LTC",8),
DASH(CryptoNet.DASH,"DASH",8,6), DASH(CryptoNet.DASH,"DASH",8),
DOGECOIN(CryptoNet.DOGECOIN,"DOGE",8,6), DOGECOIN(CryptoNet.DOGECOIN,"DOGE",8),
BITSHARES(CryptoNet.BITSHARES,"BTS",8,6); BITSHARES(CryptoNet.BITSHARES,"BTS",8);
protected CryptoNet cryptoNet; protected CryptoNet cryptoNet;
protected String label; protected String label;
protected int precision; 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.cryptoNet = cryptoNet;
this.label = label; this.label = label;
this.precision = precision; this.precision = precision;
this.confirmationsNeeded = confirmationsNeeded;
} }
public CryptoNet getCryptoNet(){ public CryptoNet getCryptoNet(){
@ -35,7 +34,5 @@ public enum CryptoCoin implements Serializable {
public int getPrecision(){ public int getPrecision(){
return this.precision; return this.precision;
} }
public int getConfirmationsNeeded(){
return this.confirmationsNeeded;
}
} }

View File

@ -3,19 +3,30 @@ package cy.agorise.crystalwallet.enums;
import java.io.Serializable; 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. * Created by Henry Varona on 12/9/2017.
*/ */
public enum CryptoNet implements Serializable { 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; protected String label;
CryptoNet(String label){ protected int confirmationsNeeded;
CryptoNet(String label,int confirmationsNeeded){
this.label = label; this.label = label;
this.confirmationsNeeded = confirmationsNeeded;
} }
public String getLabel(){ public String getLabel(){
return this.label; return this.label;
} }
public int getConfirmationsNeeded(){
return this.confirmationsNeeded;
}
} }

View File

@ -1,20 +1,34 @@
package cy.agorise.crystalwallet.models; 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. * Created by Henry Varona on 6/9/2017.
*/ */
@Entity(tableName = "account_seed") @Entity(tableName = "account_seed")
public class AccountSeed { public class AccountSeed {
/**
* The id on the database
*/
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id") @ColumnInfo(name = "id")
private int mId; private int mId;
/**
* The name or tag of this seed
*/
@ColumnInfo(name = "name") @ColumnInfo(name = "name")
private String mName; private String mName;
/**
* The bytes of the master seed
*/
@ColumnInfo(name = "master_seed") @ColumnInfo(name = "master_seed")
private String mMasterSeed; private String mMasterSeed;

View File

@ -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 {
}

View File

@ -9,26 +9,52 @@ import java.util.Date;
import cy.agorise.crystalwallet.enums.CryptoCoin; import cy.agorise.crystalwallet.enums.CryptoCoin;
/** /**
* Represents a generic CryptoNet Transaction
*
* Created by Henry Varona on 11/9/2017. * Created by Henry Varona on 11/9/2017.
*/ */
@Entity(tableName="crypto_coin_transaction") @Entity(tableName="crypto_coin_transaction")
public class CryptoCoinTransaction { public class CryptoCoinTransaction {
/**
* The account associated with this transaction
*/
protected CryptoNetAccount account; protected CryptoNetAccount account;
/**
* The id on the database
*/
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name="id") @ColumnInfo(name="id")
protected int id; protected int id;
/**
* The full date of this transaction
*/
@ColumnInfo(name="date") @ColumnInfo(name="date")
protected Date date; protected Date date;
/**
* If this transaction is input of the account associated with it
*/
@ColumnInfo(name="is_input") @ColumnInfo(name="is_input")
protected boolean isInput; protected boolean isInput;
/**
* The id of the account assoiciated, this is used for the foreign key definition
*/
@ColumnInfo(name="account_id") @ColumnInfo(name="account_id")
protected int accountId; protected int accountId;
/**
* The amount of asset is moved in this transaction
*/
@ColumnInfo(name="amount") @ColumnInfo(name="amount")
protected int amount; protected int amount;
/**
* The crypto Coin associated with this transaction
*/
@ColumnInfo(name="crypto_coin") @ColumnInfo(name="crypto_coin")
protected CryptoCoin coin; protected CryptoCoin coin;
/**
* If this transaction is confirmed
*/
@ColumnInfo(name="is_confirmed") @ColumnInfo(name="is_confirmed")
protected boolean isConfirmed; protected boolean isConfirmed;

View File

@ -1,28 +1,47 @@
package cy.agorise.crystalwallet.models; 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. * Created by Henry Varona on 6/9/2017.
*/ */
@Entity (tableName = "crypto_net_account", @Entity(tableName = "crypto_net_account",
indices = {@Index("id"),@Index("seed_id")}, indices = {@Index("id"),@Index("seed_id")},
foreignKeys = @ForeignKey(entity = AccountSeed.class, foreignKeys = @ForeignKey(entity = AccountSeed.class,
parentColumns = "id", parentColumns = "id",
childColumns = "seed_id")) childColumns = "seed_id"))
public class CryptoNetAccount { public class CryptoNetAccount {
/**
* The id on the database
*/
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id") @ColumnInfo(name = "id")
private int mId; private int mId;
/**
* The id of the seed used by this account
*/
@ColumnInfo(name = "seed_id") @ColumnInfo(name = "seed_id")
private int mSeedId; private int mSeedId;
/**
* The account number on the bip44 or slip44
*/
@ColumnInfo(name = "account_number") @ColumnInfo(name = "account_number")
private int mAccountNumber; private int mAccountNumber;
/**
* The account index
*/
@ColumnInfo(name = "account_index") @ColumnInfo(name = "account_index")
private int mAccountIndex; private int mAccountIndex;