From da293143ea5d671c9df8de20ae29ce4306e8f0bf Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 2 Oct 2017 22:49:17 -0400 Subject: [PATCH] manager for validateimport --- ...ValidateImportBitsharesAccountRequest.java | 16 +++++++++++ .../manager/BitsharesAccountManager.java | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateImportBitsharesAccountRequest.java b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateImportBitsharesAccountRequest.java index b6cde09..82977d3 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateImportBitsharesAccountRequest.java +++ b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateImportBitsharesAccountRequest.java @@ -41,4 +41,20 @@ public class ValidateImportBitsharesAccountRequest extends CryptoNetInfoRequest this._fireOnCarryOutEvent(); } } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getMnemonic() { + return mnemonic; + } + + public void setMnemonic(String mnemonic) { + this.mnemonic = mnemonic; + } } 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 7d66cce..b667e9c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -1,5 +1,8 @@ package cy.agorise.crystalwallet.manager; +import cy.agorise.crystalwallet.apigenerator.ApiRequest; +import cy.agorise.crystalwallet.apigenerator.ApiRequestListener; +import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator; import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequest; import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestsListener; import cy.agorise.crystalwallet.cryptonetinforequests.ValidateImportBitsharesAccountRequest; @@ -28,6 +31,31 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI @Override public void onNewRequest(CryptoNetInfoRequest request) { if (request instanceof ValidateImportBitsharesAccountRequest){ + final ValidateImportBitsharesAccountRequest importRequest = (ValidateImportBitsharesAccountRequest) request; + ApiRequest checkAccountName = new ApiRequest(0, new ApiRequestListener() { + @Override + public void success(Object answer, int idPetition) { + ApiRequest getAccountInfo = new ApiRequest(1,new ApiRequestListener(){ + @Override + public void success(Object answer, int idPetition) { + //TODO compare keys + } + + @Override + public void fail(int idPetition) { + importRequest._fireOnCarryOutEvent(); + } + }); + GrapheneApiGenerator.getAccountById((String)answer,getAccountInfo); + } + + @Override + public void fail(int idPetition) { + importRequest._fireOnCarryOutEvent(); + } + }); + + GrapheneApiGenerator.getAccountIdByName(importRequest.getAccountName(),checkAccountName); } } }