diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCoinBalanceDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCoinBalanceDao.java index f66f58a..ce3bd91 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCoinBalanceDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCoinBalanceDao.java @@ -22,7 +22,7 @@ public interface CryptoCoinBalanceDao { @Query("SELECT * FROM crypto_coin_balance") List getAll(); - @Query("SELECT id as account_id, account_number FROM crypto_net_account") + @Query("SELECT id as account_id, crypto_net FROM crypto_net_account") LiveData> getAllBalances(); @Query("SELECT * FROM crypto_coin_balance WHERE account_id = :accountId") diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java index ff63c70..5a2e0f6 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java @@ -23,8 +23,8 @@ public interface CryptoNetAccountDao { @Query("SELECT * FROM crypto_net_account") List getAll(); - @Query("SELECT * FROM crypto_net_account WHERE type = 1") - LiveData> getGrapheneAccounts(); + @Query("SELECT * FROM crypto_net_account WHERE crypto_net = 'BITSHARES'") + LiveData> getBitsharesAccounts(); @Insert(onConflict = OnConflictStrategy.REPLACE) public long[] insertCryptoNetAccount(CryptoNetAccount... accounts); diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/GrapheneAccountInfoDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/GrapheneAccountInfoDao.java index 2cfe5f6..3923722 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/GrapheneAccountInfoDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/GrapheneAccountInfoDao.java @@ -19,9 +19,12 @@ import cy.agorise.crystalwallet.models.GrapheneAccountInfo; @Dao public interface GrapheneAccountInfoDao { - @Query("SELECT * FROM graphene_account WHERE subclass = 1") + @Query("SELECT * FROM graphene_account") LiveData> getAll(); + @Query("SELECT * FROM graphene_account WHERE crypto_net_account_id = :cryptoNetAccountId") + LiveData getGrapheneAccountInfo(int cryptoNetAccountId); + @Insert(onConflict = OnConflictStrategy.REPLACE) public long[] insertGrapheneAccountInfo(GrapheneAccountInfo... accounts); 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 eb09632..d78eb95 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetAccount.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetAccount.java @@ -7,14 +7,16 @@ import android.arch.persistence.room.ForeignKey; import android.arch.persistence.room.Index; import android.arch.persistence.room.PrimaryKey; +import cy.agorise.crystalwallet.enums.CryptoNet; + /** - * Represents a geneeric CryptoNet Account + * Represents a generic CryptoNet Account * * Created by Henry Varona on 6/9/2017. */ @Entity(tableName = "crypto_net_account", - indices = {@Index("id"),@Index("seed_id")}, + indices = {@Index("id"),@Index("seed_id"),@Index(value = {"seed_id","crypto_net","account_index"},unique=true)}, foreignKeys = @ForeignKey(entity = AccountSeed.class, parentColumns = "id", childColumns = "seed_id")) @@ -33,12 +35,6 @@ public class CryptoNetAccount { @ColumnInfo(name = "seed_id") private long mSeedId; - /** - * The account number on the bip44 or slip44 - */ - @ColumnInfo(name = "account_number") - private int mAccountNumber; - /** * The account index on this wallet */ @@ -46,10 +42,10 @@ public class CryptoNetAccount { private int mAccountIndex; /** - * The type of the account + * The crypto net of the account */ - @ColumnInfo(name = "type") - private int type; + @ColumnInfo(name = "crypto_net") + private CryptoNet mCryptoNet; public long getId() { return mId; @@ -67,14 +63,6 @@ public class CryptoNetAccount { this.mSeedId = mSeedId; } - public int getAccountNumber() { - return mAccountNumber; - } - - public void setAccountNumber(int mAccountNumber) { - this.mAccountNumber = mAccountNumber; - } - public int getAccountIndex() { return mAccountIndex; } @@ -83,11 +71,11 @@ public class CryptoNetAccount { this.mAccountIndex = mAccountIndex; } - public int getType() { - return type; + public CryptoNet getCryptoNet() { + return mCryptoNet; } - public void setType(int type) { - this.type = type; + public void setCryptoNet(CryptoNet cryptoNet) { + this.mCryptoNet = cryptoNet; } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetBalance.java b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetBalance.java index 7f35c7a..7610555 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetBalance.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetBalance.java @@ -33,7 +33,7 @@ public class CryptoNetBalance { /** * The cryptonet of the account */ - @ColumnInfo(name = "account_number", typeAffinity = INTEGER) + @ColumnInfo(name = "crypto_net") private CryptoNet mCryptoNet; public long getAccountId() { diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccountInfo.java b/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccountInfo.java index 25d4b47..9178161 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccountInfo.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccountInfo.java @@ -10,7 +10,7 @@ import android.arch.persistence.room.Index; */ @Entity(tableName = "graphene_account", - indices = {@Index("id"),@Index(value = "crypto_net_account_id",unique=true)}, + primaryKeys = {"crypto_net_account_id"}, foreignKeys = @ForeignKey(entity = CryptoNetAccount.class, parentColumns = "id", childColumns = "crypto_net_account_id")) diff --git a/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoCoinBalanceGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoCoinBalanceGenerator.java index f06f9e1..af96784 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoCoinBalanceGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoCoinBalanceGenerator.java @@ -31,7 +31,7 @@ public class RandomCryptoCoinBalanceGenerator { int randomAccountIndex = randomGenerator.nextInt(accounts.size()); CryptoNetAccount randomSelectedAccount = accounts.get(randomAccountIndex); randomAmount = randomGenerator.nextInt((maxAmount - minAmount) + 1) + minAmount; - accountCryptoCoins = CryptoCoin.getByCryptoNet(converters.accountNumberToCryptoNet(randomSelectedAccount.getAccountNumber())); + accountCryptoCoins = CryptoCoin.getByCryptoNet(randomSelectedAccount.getCryptoNet()); randomCryptoCoin = accountCryptoCoins.get(randomGenerator.nextInt(accountCryptoCoins.size())); randomBalance = new CryptoCoinBalance(); diff --git a/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoNetAccountGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoNetAccountGenerator.java index 3ecd528..a2e5454 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoNetAccountGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/randomdatagenerators/RandomCryptoNetAccountGenerator.java @@ -30,13 +30,13 @@ public class RandomCryptoNetAccountGenerator { for (int i=0;i