From f23d1c4a580c1ec5361716701997e6a7af5feb59 Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 10 May 2018 22:55:05 -0400 Subject: [PATCH] Added the request service and the bitshares logic to the upgrade to LTM account. Still we need the implementation of graphenej library to finish this implementation. --- .../manager/BitsharesAccountManager.java | 12 ++++ .../ValidateBitsharesLTMUpgradeRequest.java | 65 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateBitsharesLTMUpgradeRequest.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index 8173aca..fff1580 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -23,6 +23,7 @@ import cy.agorise.crystalwallet.models.seed.BIP39; import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener; +import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesLTMUpgradeRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest; @@ -227,6 +228,8 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI this.getEquivalentValue((CryptoNetEquivalentRequest) request); }else if (request instanceof ValidateCreateBitsharesAccountRequest){ this.validateCreateAccount((ValidateCreateBitsharesAccountRequest) request); + }else if (request instanceof ValidateBitsharesLTMUpgradeRequest){ + this.validateLTMAccountUpgrade((ValidateBitsharesLTMUpgradeRequest) request); }else{ //TODO not implemented System.out.println("Error request not implemented " + request.getClass().getName()); @@ -436,6 +439,15 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI } + /** + * Broadcast a transaction request + */ + private void validateLTMAccountUpgrade(final ValidateBitsharesLTMUpgradeRequest sendRequest) { + //TODO check internet, server connection + sendRequest.setStatus(ValidateBitsharesLTMUpgradeRequest.StatusCode.PETITION_FAILED); + CrystalDatabase db = CrystalDatabase.getAppDatabase(sendRequest.getContext()); + } + /** * Returns the account info from a graphene id * @param grapheneId The graphene id of the account diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateBitsharesLTMUpgradeRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateBitsharesLTMUpgradeRequest.java new file mode 100644 index 0000000..d0fe1b3 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ValidateBitsharesLTMUpgradeRequest.java @@ -0,0 +1,65 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import android.content.Context; + +import cy.agorise.crystalwallet.enums.CryptoCoin; +import cy.agorise.crystalwallet.models.GrapheneAccount; + +/** + * Class used to make a send amount request. + * + * Created by henry on 8/10/2017. + */ + +public class ValidateBitsharesLTMUpgradeRequest extends CryptoNetInfoRequest { + /** + * The status code of this request + */ + public enum StatusCode{ + NOT_STARTED, + SUCCEEDED, + NO_INTERNET, + NO_SERVER_CONNECTION, + NO_ASSET_INFO_DB, + NO_ASSET_INFO, + NO_FUNDS, + PETITION_FAILED + } + + // The app context + private Context mContext; + // The source account used to transfer fund from + private GrapheneAccount mSourceAccount; + // The state of this request + private StatusCode status = StatusCode.NOT_STARTED; + + public ValidateBitsharesLTMUpgradeRequest(Context context, GrapheneAccount sourceAccount) { + super(CryptoCoin.BITSHARES); + this.mContext = context; + this.mSourceAccount = sourceAccount; + + } + + public Context getContext() { + return mContext; + } + + public GrapheneAccount getSourceAccount() { + return mSourceAccount; + } + + public void validate(){ + if ((this.status != StatusCode.NOT_STARTED)){ + this._fireOnCarryOutEvent(); + } + } + + public void setStatus(StatusCode code){ + this.status = code; + this.validate(); + } + + public StatusCode getStatus() { + return status; + } +}