From 6e81192b37d0d06f100daa14bded60fb04507076 Mon Sep 17 00:00:00 2001 From: hvarona Date: Sun, 11 Nov 2018 21:59:28 -0400 Subject: [PATCH] Added steem url and verifier Added bip21 implementation with lowercase --- .../application/CrystalApplication.java | 13 +++++++++ .../manager/GeneralAccountManager.java | 2 +- .../manager/SteemAccountManager.java | 28 ------------------- .../network/CryptoNetVerifier.java | 2 ++ 4 files changed, 16 insertions(+), 29 deletions(-) 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 67fc2b4..9e78385 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalApplication.java @@ -57,6 +57,17 @@ public class CrystalApplication extends Application { public static final CryptoCurrency BITCOIN_CURRENCY = new CryptoCurrency("BTC",CryptoNet.BITCOIN,8); + public static String STEEM_URL[] = + { + "https://api.steemit.com", + "https://api.steemitdev.com", + "https://api.steemitstage.com", + "https://api.steem.house", + "https://appbasetest.timcliff.com", + + + }; + @Override public void onCreate() { super.onCreate(); @@ -108,6 +119,8 @@ public class CrystalApplication extends Application { db.cryptoCurrencyDao().insertCryptoCurrency(BITCOIN_CURRENCY); } + CryptoNetManager.addCryptoNetURL(CryptoNet.STEEM,STEEM_URL); + GeneralSetting generalSettingPreferredLanguage = db.generalSettingDao().getSettingByName(GeneralSetting.SETTING_NAME_PREFERRED_LANGUAGE); diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java index acf34f2..fd56ef0 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/GeneralAccountManager.java @@ -495,7 +495,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf } private void calculateUri(CalculateBitcoinUriRequest request) { - StringBuilder uri = new StringBuilder(this.cryptoCoin.getLabel()+":"); + StringBuilder uri = new StringBuilder(this.cryptoCoin.getLabel().toLowerCase()+":"); CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext()); long index = db.bitcoinAddressDao().getLastExternalAddress(request.getAccount().getId()); diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/SteemAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/SteemAccountManager.java index ecef586..677352b 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/SteemAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/SteemAccountManager.java @@ -33,7 +33,6 @@ import cy.agorise.crystalwallet.models.GrapheneAccount; import cy.agorise.crystalwallet.models.GrapheneAccountInfo; import cy.agorise.crystalwallet.models.seed.BIP39; import cy.agorise.crystalwallet.network.CryptoNetManager; -import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener; import cy.agorise.crystalwallet.requestmanagers.GetBitsharesAccountNameCacheRequest; @@ -185,8 +184,6 @@ public class SteemAccountManager implements CryptoAccountManager, CryptoNetInfoR this.validateExistAcccount((ValidateExistBitsharesAccountRequest) request); } else if (request instanceof ValidateBitsharesSendRequest) { this.validateSendRequest((ValidateBitsharesSendRequest) request); - } else if (request instanceof CryptoNetEquivalentRequest) { - this.getEquivalentValue((CryptoNetEquivalentRequest) request); } else if (request instanceof GetBitsharesAccountNameCacheRequest) { this.getBitsharesAccountNameCacheRequest((GetBitsharesAccountNameCacheRequest) request); } else { @@ -699,31 +696,6 @@ public class SteemAccountManager implements CryptoAccountManager, CryptoNetInfoR } } - /** - * Gets the current change from two assets - */ - private void getEquivalentValue(final CryptoNetEquivalentRequest request){ - if(request.getFromCurrency() instanceof BitsharesAsset && request.getToCurrency() instanceof BitsharesAsset) { - BitsharesAsset fromAsset = (BitsharesAsset) request.getFromCurrency(); - BitsharesAsset toAsset = (BitsharesAsset) request.getToCurrency(); - ApiRequest getEquivalentRequest = new ApiRequest(0, new ApiRequestListener() { - @Override - public void success(Object answer, int idPetition) { - request.setPrice((Long)answer); - } - - @Override - public void fail(int idPetition) { - //TODO error - } - }); - GrapheneApiGenerator.getEquivalentValue(fromAsset.getBitsharesId(),toAsset.getBitsharesId(), getEquivalentRequest); - }else{ - //TODO error - System.out.println("Equivalent Value error "); - } - } - /** * Class to retrieve the account id or the account name, if one of those is missing */ diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java index c0e38ee..7ded8ca 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java +++ b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java @@ -18,6 +18,8 @@ public abstract class CryptoNetVerifier { return new BitsharesCryptoNetVerifier(); }else if(cryptoNet.getLabel().equals(CryptoNet.BITCOIN.getLabel())){ return new BitcoinCryptoNetVerifier(CryptoCoin.BITCOIN); + }else if(cryptoNet.getLabel().equals(CryptoNet.STEEM.getLabel())){ + return new SteemCryptoNetVerifier(); } return null; }