Created CtyproCoinManager
This commit is contained in:
parent
515d09c0c2
commit
d5dbe02a50
6 changed files with 74 additions and 14 deletions
|
@ -11,6 +11,7 @@ import android.content.Context;
|
||||||
import cy.agorise.crystalwallet.dao.converters.Converters;
|
import cy.agorise.crystalwallet.dao.converters.Converters;
|
||||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +19,7 @@ import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
* Created by Henry Varona on 4/9/2017.
|
* Created by Henry Varona on 4/9/2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Database(entities = {AccountSeed.class, CryptoNetAccount.class, CryptoCoinTransaction.class}, version = 2)
|
@Database(entities = {AccountSeed.class, CryptoNetAccount.class, CryptoCoinTransaction.class, CryptoCurrency.class}, version = 2)
|
||||||
@TypeConverters({Converters.class})
|
@TypeConverters({Converters.class})
|
||||||
public abstract class CrystalDatabase extends RoomDatabase {
|
public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package cy.agorise.crystalwallet.manager;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manager of each crypto coin account
|
||||||
|
*
|
||||||
|
* Created by henry on 24/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface CryptoAccountManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a CryptoCoin Account, with the values of the account
|
||||||
|
* @param account The values to be created,
|
||||||
|
* @returnThe CruptoNetAccount created, or null if it couldn't be created
|
||||||
|
*/
|
||||||
|
public CryptoNetAccount createAccountFromSeed(CryptoNetAccount account);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports a CryptoCoin account from a seed
|
||||||
|
* @param account A CryptoNetAccount with the parameters to be imported
|
||||||
|
* @returnThe CruptoNetAccount imported
|
||||||
|
*/
|
||||||
|
public CryptoNetAccount importAccountFromSeed(CryptoNetAccount account);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads account data from the database
|
||||||
|
*
|
||||||
|
* @param account The CryptoNetAccount to be loaded
|
||||||
|
*/
|
||||||
|
public void loadAccountFromDB(CryptoNetAccount account);
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
import android.arch.persistence.room.ColumnInfo;
|
import android.arch.persistence.room.ColumnInfo;
|
||||||
import android.arch.persistence.room.Entity;
|
import android.arch.persistence.room.Entity;
|
||||||
|
import android.arch.persistence.room.ForeignKey;
|
||||||
import android.arch.persistence.room.PrimaryKey;
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.recyclerview.extensions.DiffCallback;
|
import android.support.v7.recyclerview.extensions.DiffCallback;
|
||||||
|
@ -15,7 +16,17 @@ import cy.agorise.crystalwallet.enums.CryptoCoin;
|
||||||
*
|
*
|
||||||
* 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",
|
||||||
|
foreignKeys = {@ForeignKey(entity = CryptoNetAccount.class,
|
||||||
|
parentColumns = "id",
|
||||||
|
childColumns = "account_id",
|
||||||
|
onDelete = ForeignKey.CASCADE),
|
||||||
|
@ForeignKey(entity = CryptoCurrency.class,
|
||||||
|
parentColumns = "id",
|
||||||
|
childColumns = "id_currency",
|
||||||
|
onDelete = ForeignKey.CASCADE)
|
||||||
|
}
|
||||||
|
)
|
||||||
public class CryptoCoinTransaction {
|
public class CryptoCoinTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,10 +62,10 @@ public class CryptoCoinTransaction {
|
||||||
protected int amount;
|
protected int amount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the Crypto Asset to use in the database
|
* The id of the Crypto Currency to use in the database
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name="id_asset")
|
@ColumnInfo(name="id_currency")
|
||||||
private int idAsset;
|
protected int idCurrency;
|
||||||
/**
|
/**
|
||||||
* If this transaction is confirmed
|
* If this transaction is confirmed
|
||||||
*/
|
*/
|
||||||
|
@ -129,9 +140,9 @@ public class CryptoCoinTransaction {
|
||||||
|
|
||||||
public void setAmount(int amount) { this.amount = amount; }
|
public void setAmount(int amount) { this.amount = amount; }
|
||||||
|
|
||||||
public int getIdAsset() { return idAsset; }
|
public int getIdCurrency() { return idCurrency; }
|
||||||
|
|
||||||
public void setIdAsset(int idAsset) { this.idAsset = idAsset; }
|
public void setIdCurrency(int idCurrency) { this.idCurrency = idCurrency; }
|
||||||
|
|
||||||
|
|
||||||
public static final DiffCallback<CryptoCoinTransaction> DIFF_CALLBACK = new DiffCallback<CryptoCoinTransaction>() {
|
public static final DiffCallback<CryptoCoinTransaction> DIFF_CALLBACK = new DiffCallback<CryptoCoinTransaction>() {
|
||||||
|
@ -158,7 +169,7 @@ public class CryptoCoinTransaction {
|
||||||
if (isInput != that.isInput) return false;
|
if (isInput != that.isInput) return false;
|
||||||
if (accountId != that.accountId) return false;
|
if (accountId != that.accountId) return false;
|
||||||
if (amount != that.amount) return false;
|
if (amount != that.amount) return false;
|
||||||
if (idAsset != that.idAsset) return false;
|
if (idCurrency != that.idCurrency) return false;
|
||||||
if (isConfirmed != that.isConfirmed) return false;
|
if (isConfirmed != that.isConfirmed) return false;
|
||||||
if (date != null ? !date.equals(that.date) : that.date != null) return false;
|
if (date != null ? !date.equals(that.date) : that.date != null) return false;
|
||||||
if (from != null ? !from.equals(that.from) : that.from != null) return false;
|
if (from != null ? !from.equals(that.from) : that.from != null) return false;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cy.agorise.crystalwallet.models;
|
package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
import android.arch.persistence.room.ColumnInfo;
|
import android.arch.persistence.room.ColumnInfo;
|
||||||
|
import android.arch.persistence.room.Entity;
|
||||||
import android.arch.persistence.room.PrimaryKey;
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
import android.arch.persistence.room.TypeConverters;
|
import android.arch.persistence.room.TypeConverters;
|
||||||
|
|
||||||
|
@ -8,12 +9,12 @@ import cy.agorise.crystalwallet.dao.converters.Converters;
|
||||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents each asset in transaction and balances
|
* Represents each currency in transaction and balances
|
||||||
*
|
*
|
||||||
* Created by henry Henry Varona on 11/9/2017.
|
* Created by henry Henry Varona on 11/9/2017.
|
||||||
*/
|
*/
|
||||||
|
@Entity(tableName="crypto_currency")
|
||||||
public class CryptoAsset {
|
public class CryptoCurrency {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id on the database
|
* The id on the database
|
||||||
|
@ -23,14 +24,16 @@ public class CryptoAsset {
|
||||||
private int mId;
|
private int mId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name or tag of this seed
|
* The name or tag of this currency
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name = "name")
|
@ColumnInfo(name = "name")
|
||||||
private String mName;
|
private String mName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CryptoCoin network where this assets belongs to
|
* CryptoCoin network where this currency belongs to
|
||||||
*/
|
*/
|
||||||
|
@ColumnInfo(name = "crypto_net")
|
||||||
|
@TypeConverters(Converters.class)
|
||||||
private CryptoNet mCryptoNet;
|
private CryptoNet mCryptoNet;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class CryptoNetAccount {
|
||||||
private int mAccountNumber;
|
private int mAccountNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The account index
|
* The account index on this wallet
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name = "account_index")
|
@ColumnInfo(name = "account_index")
|
||||||
private int mAccountIndex;
|
private int mAccountIndex;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by henry on 24/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GrapheneAccount extends CryptoNetAccount {
|
||||||
|
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue