- Changing account_number to crypto_net

This commit is contained in:
Javier Varona 2017-10-17 21:14:37 -04:00
parent c3cb23fe94
commit 454644fc38
8 changed files with 23 additions and 32 deletions

View file

@ -22,7 +22,7 @@ public interface CryptoCoinBalanceDao {
@Query("SELECT * FROM crypto_coin_balance")
List<CryptoCoinBalance> 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<List<CryptoNetBalance>> getAllBalances();
@Query("SELECT * FROM crypto_coin_balance WHERE account_id = :accountId")

View file

@ -23,8 +23,8 @@ public interface CryptoNetAccountDao {
@Query("SELECT * FROM crypto_net_account")
List<CryptoNetAccount> getAll();
@Query("SELECT * FROM crypto_net_account WHERE type = 1")
LiveData<List<CryptoNetAccount>> getGrapheneAccounts();
@Query("SELECT * FROM crypto_net_account WHERE crypto_net = 'BITSHARES'")
LiveData<List<CryptoNetAccount>> getBitsharesAccounts();
@Insert(onConflict = OnConflictStrategy.REPLACE)
public long[] insertCryptoNetAccount(CryptoNetAccount... accounts);

View file

@ -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<List<GrapheneAccountInfo>> getAll();
@Query("SELECT * FROM graphene_account WHERE crypto_net_account_id = :cryptoNetAccountId")
LiveData<GrapheneAccountInfo> getGrapheneAccountInfo(int cryptoNetAccountId);
@Insert(onConflict = OnConflictStrategy.REPLACE)
public long[] insertGrapheneAccountInfo(GrapheneAccountInfo... accounts);

View file

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

View file

@ -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() {

View file

@ -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"))

View file

@ -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();

View file

@ -30,13 +30,13 @@ public class RandomCryptoNetAccountGenerator {
for (int i=0;i<numberOfAccounts;i++){
int randomSeedIndex = randomGenerator.nextInt(seeds.size());
AccountSeed randomSelectedSeed = seeds.get(randomSeedIndex);
int randomAccountNumber = cryptoNetList.get(randomGenerator.nextInt(cryptoNetList.size())).getBip44Index();
CryptoNet randomCryptoNet = cryptoNetList.get(randomGenerator.nextInt(cryptoNetList.size()));
int randomAccountIndex = randomGenerator.nextInt(1000);
randomAccount = new CryptoNetAccount();
randomAccount.setSeedId(randomSelectedSeed.getId());
randomAccount.setAccountIndex(randomAccountIndex);
randomAccount.setAccountNumber(randomAccountNumber);
randomAccount.setCryptoNet(randomCryptoNet);
result.add(randomAccount);
}