From 90efd6604ceecb5d92233d573c5c557301b5ea55 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 12 Mar 2018 23:14:04 -0400 Subject: [PATCH] added assets for testing equivalents values --- .../apigenerator/GrapheneApiGenerator.java | 2 +- .../application/CrystalApplication.java | 33 +++++++++++++++++++ .../network/CryptoNetManager.java | 6 ---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java index 1e58d06..0522a9c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java @@ -666,7 +666,7 @@ public abstract class GrapheneApiGenerator { Converter converter = new Converter(); order.getSellPrice().base.getAsset().setPrecision(baseAsset.getPrecision()); order.getSellPrice().quote.getAsset().setPrecision(quoteAsset.getPrecision()); - double equiValue = converter.getConversionRate(order.getSellPrice(), Converter.BASE_TO_QUOTE); + double equiValue = converter.getConversionRate(order.getSellPrice(), Converter.QUOTE_TO_BASE); CryptoCurrencyEquivalence equivalence = new CryptoCurrencyEquivalence(baseAsset.getId(), quoteAsset.getId(), (int) (Math.pow(10, baseAsset.getPrecision()) * equiValue), new Date()); CrystalDatabase.getAppDatabase(context).cryptoCurrencyEquivalenceDao().insertCryptoCurrencyEquivalence(equivalence); break; diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java index 8b55ef4..8a1e16c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java @@ -7,6 +7,9 @@ import com.idescout.sql.SqlScoutServer; import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.enums.CryptoNet; +import cy.agorise.crystalwallet.models.BitsharesAsset; +import cy.agorise.crystalwallet.models.BitsharesAssetInfo; +import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence; import cy.agorise.crystalwallet.network.CryptoNetManager; import cy.agorise.crystalwallet.service.CrystalWalletService; @@ -32,6 +35,11 @@ public class CrystalApplication extends Application { "http://185.208.208.147:11012", // Openledger node }; + //This is for testing the equivalent values on the testnet TODO remove + public static BitsharesAsset bitUSDAsset = new BitsharesAsset("USD",4,"1.3.121",BitsharesAsset.Type.SMART_COIN); + //This is for testing the equivalent values on the testnet TODO remove + public static BitsharesAsset bitEURAsset = new BitsharesAsset("EUR",4,"1.3.120",BitsharesAsset.Type.SMART_COIN); + @Override public void onCreate() { super.onCreate(); @@ -42,6 +50,31 @@ public class CrystalApplication extends Application { //Using Bitshares Agorise Testnet CryptoNetManager.addCryptoNetURL(CryptoNet.BITSHARES,BITSHARES_TESTNET_URL); + + //This is for testing the equivalent values on the testnet TODO remove + if(db.bitsharesAssetDao().getBitsharesAssetInfoById(bitEURAsset.getBitsharesId())== null){ + if(db.cryptoCurrencyDao().getByName(bitEURAsset.getName())== null){ + db.cryptoCurrencyDao().insertCryptoCurrency(bitEURAsset); + } + long idCurrency = db.cryptoCurrencyDao().getByName(bitEURAsset.getName()).getId(); + BitsharesAssetInfo info = new BitsharesAssetInfo(bitEURAsset); + info.setCryptoCurrencyId(idCurrency); + db.bitsharesAssetDao().insertBitsharesAssetInfo(info); + + } + + //This is for testing the equivalent values on the testnet TODO remove + if(db.bitsharesAssetDao().getBitsharesAssetInfoById(bitUSDAsset.getBitsharesId())== null){ + if(db.cryptoCurrencyDao().getByName(bitUSDAsset.getName())== null){ + db.cryptoCurrencyDao().insertCryptoCurrency(bitUSDAsset); + } + long idCurrency = db.cryptoCurrencyDao().getByName(bitUSDAsset.getName()).getId(); + BitsharesAssetInfo info = new BitsharesAssetInfo(bitUSDAsset); + info.setCryptoCurrencyId(idCurrency); + db.bitsharesAssetDao().insertBitsharesAssetInfo(info); + + } + //Next line is for use the bitshares main net //CryptoNetManager.addCryptoNetURL(CryptoNet.BITSHARES,BITSHARES_URL); diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetManager.java b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetManager.java index c112f9f..d424cc8 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetManager.java @@ -33,12 +33,6 @@ public abstract class CryptoNetManager { public static String getURL(CryptoNet crypto, int index){ if(TestedURLs.containsKey(crypto) && TestedURLs.get(crypto).size()>index){ - StringBuilder debugString = new StringBuilder("CryptoNetManager urls times: "); - for(TestedURL url : TestedURLs.get(crypto)){ - debugString.append("\r\n ").append(url.getTime()).append(" ").append(url.getUrl()); - } - System.out.println(debugString.toString()); - return TestedURLs.get(crypto).get(index).getUrl(); }