- Changing account_number to crypto_net
This commit is contained in:
parent
c3cb23fe94
commit
454644fc38
8 changed files with 23 additions and 32 deletions
|
@ -22,7 +22,7 @@ public interface CryptoCoinBalanceDao {
|
||||||
@Query("SELECT * FROM crypto_coin_balance")
|
@Query("SELECT * FROM crypto_coin_balance")
|
||||||
List<CryptoCoinBalance> getAll();
|
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();
|
LiveData<List<CryptoNetBalance>> getAllBalances();
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_balance WHERE account_id = :accountId")
|
@Query("SELECT * FROM crypto_coin_balance WHERE account_id = :accountId")
|
||||||
|
|
|
@ -23,8 +23,8 @@ public interface CryptoNetAccountDao {
|
||||||
@Query("SELECT * FROM crypto_net_account")
|
@Query("SELECT * FROM crypto_net_account")
|
||||||
List<CryptoNetAccount> getAll();
|
List<CryptoNetAccount> getAll();
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_net_account WHERE type = 1")
|
@Query("SELECT * FROM crypto_net_account WHERE crypto_net = 'BITSHARES'")
|
||||||
LiveData<List<CryptoNetAccount>> getGrapheneAccounts();
|
LiveData<List<CryptoNetAccount>> getBitsharesAccounts();
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
public long[] insertCryptoNetAccount(CryptoNetAccount... accounts);
|
public long[] insertCryptoNetAccount(CryptoNetAccount... accounts);
|
||||||
|
|
|
@ -19,9 +19,12 @@ import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||||
@Dao
|
@Dao
|
||||||
public interface GrapheneAccountInfoDao {
|
public interface GrapheneAccountInfoDao {
|
||||||
|
|
||||||
@Query("SELECT * FROM graphene_account WHERE subclass = 1")
|
@Query("SELECT * FROM graphene_account")
|
||||||
LiveData<List<GrapheneAccountInfo>> getAll();
|
LiveData<List<GrapheneAccountInfo>> getAll();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM graphene_account WHERE crypto_net_account_id = :cryptoNetAccountId")
|
||||||
|
LiveData<GrapheneAccountInfo> getGrapheneAccountInfo(int cryptoNetAccountId);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
public long[] insertGrapheneAccountInfo(GrapheneAccountInfo... accounts);
|
public long[] insertGrapheneAccountInfo(GrapheneAccountInfo... accounts);
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,16 @@ import android.arch.persistence.room.ForeignKey;
|
||||||
import android.arch.persistence.room.Index;
|
import android.arch.persistence.room.Index;
|
||||||
import android.arch.persistence.room.PrimaryKey;
|
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.
|
* 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"),@Index(value = {"seed_id","crypto_net","account_index"},unique=true)},
|
||||||
foreignKeys = @ForeignKey(entity = AccountSeed.class,
|
foreignKeys = @ForeignKey(entity = AccountSeed.class,
|
||||||
parentColumns = "id",
|
parentColumns = "id",
|
||||||
childColumns = "seed_id"))
|
childColumns = "seed_id"))
|
||||||
|
@ -33,12 +35,6 @@ public class CryptoNetAccount {
|
||||||
@ColumnInfo(name = "seed_id")
|
@ColumnInfo(name = "seed_id")
|
||||||
private long mSeedId;
|
private long mSeedId;
|
||||||
|
|
||||||
/**
|
|
||||||
* The account number on the bip44 or slip44
|
|
||||||
*/
|
|
||||||
@ColumnInfo(name = "account_number")
|
|
||||||
private int mAccountNumber;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The account index on this wallet
|
* The account index on this wallet
|
||||||
*/
|
*/
|
||||||
|
@ -46,10 +42,10 @@ public class CryptoNetAccount {
|
||||||
private int mAccountIndex;
|
private int mAccountIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the account
|
* The crypto net of the account
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name = "type")
|
@ColumnInfo(name = "crypto_net")
|
||||||
private int type;
|
private CryptoNet mCryptoNet;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return mId;
|
return mId;
|
||||||
|
@ -67,14 +63,6 @@ public class CryptoNetAccount {
|
||||||
this.mSeedId = mSeedId;
|
this.mSeedId = mSeedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAccountNumber() {
|
|
||||||
return mAccountNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountNumber(int mAccountNumber) {
|
|
||||||
this.mAccountNumber = mAccountNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAccountIndex() {
|
public int getAccountIndex() {
|
||||||
return mAccountIndex;
|
return mAccountIndex;
|
||||||
}
|
}
|
||||||
|
@ -83,11 +71,11 @@ public class CryptoNetAccount {
|
||||||
this.mAccountIndex = mAccountIndex;
|
this.mAccountIndex = mAccountIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType() {
|
public CryptoNet getCryptoNet() {
|
||||||
return type;
|
return mCryptoNet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(int type) {
|
public void setCryptoNet(CryptoNet cryptoNet) {
|
||||||
this.type = type;
|
this.mCryptoNet = cryptoNet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CryptoNetBalance {
|
||||||
/**
|
/**
|
||||||
* The cryptonet of the account
|
* The cryptonet of the account
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name = "account_number", typeAffinity = INTEGER)
|
@ColumnInfo(name = "crypto_net")
|
||||||
private CryptoNet mCryptoNet;
|
private CryptoNet mCryptoNet;
|
||||||
|
|
||||||
public long getAccountId() {
|
public long getAccountId() {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.arch.persistence.room.Index;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Entity(tableName = "graphene_account",
|
@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,
|
foreignKeys = @ForeignKey(entity = CryptoNetAccount.class,
|
||||||
parentColumns = "id",
|
parentColumns = "id",
|
||||||
childColumns = "crypto_net_account_id"))
|
childColumns = "crypto_net_account_id"))
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class RandomCryptoCoinBalanceGenerator {
|
||||||
int randomAccountIndex = randomGenerator.nextInt(accounts.size());
|
int randomAccountIndex = randomGenerator.nextInt(accounts.size());
|
||||||
CryptoNetAccount randomSelectedAccount = accounts.get(randomAccountIndex);
|
CryptoNetAccount randomSelectedAccount = accounts.get(randomAccountIndex);
|
||||||
randomAmount = randomGenerator.nextInt((maxAmount - minAmount) + 1) + minAmount;
|
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()));
|
randomCryptoCoin = accountCryptoCoins.get(randomGenerator.nextInt(accountCryptoCoins.size()));
|
||||||
|
|
||||||
randomBalance = new CryptoCoinBalance();
|
randomBalance = new CryptoCoinBalance();
|
||||||
|
|
|
@ -30,13 +30,13 @@ public class RandomCryptoNetAccountGenerator {
|
||||||
for (int i=0;i<numberOfAccounts;i++){
|
for (int i=0;i<numberOfAccounts;i++){
|
||||||
int randomSeedIndex = randomGenerator.nextInt(seeds.size());
|
int randomSeedIndex = randomGenerator.nextInt(seeds.size());
|
||||||
AccountSeed randomSelectedSeed = seeds.get(randomSeedIndex);
|
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);
|
int randomAccountIndex = randomGenerator.nextInt(1000);
|
||||||
|
|
||||||
randomAccount = new CryptoNetAccount();
|
randomAccount = new CryptoNetAccount();
|
||||||
randomAccount.setSeedId(randomSelectedSeed.getId());
|
randomAccount.setSeedId(randomSelectedSeed.getId());
|
||||||
randomAccount.setAccountIndex(randomAccountIndex);
|
randomAccount.setAccountIndex(randomAccountIndex);
|
||||||
randomAccount.setAccountNumber(randomAccountNumber);
|
randomAccount.setCryptoNet(randomCryptoNet);
|
||||||
result.add(randomAccount);
|
result.add(randomAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue