From 2027677956853489f941233c255bb2fd8e241a20 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Mon, 22 Oct 2018 21:05:48 -0400 Subject: [PATCH] - Added new requests needed to implement bitcoin alike accounts funcionality --- .../requestmanagers/BitcoinSendRequest.java | 96 +++++++++++++++++++ .../CreateBitcoinAccountRequest.java | 67 +++++++++++++ .../NextBitcoinAccountAddressRequest.java | 65 +++++++++++++ 3 files changed, 228 insertions(+) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/BitcoinSendRequest.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CreateBitcoinAccountRequest.java create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/NextBitcoinAccountAddressRequest.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/BitcoinSendRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/BitcoinSendRequest.java new file mode 100644 index 0000000..b104c78 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/BitcoinSendRequest.java @@ -0,0 +1,96 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import android.content.Context; + +import cy.agorise.crystalwallet.enums.CryptoCoin; +import cy.agorise.crystalwallet.models.CryptoNetAccount; +import cy.agorise.crystalwallet.models.GrapheneAccount; + +/** + * Class used to make a send amount request. + * + * Created by henry on 8/10/2017. + */ + +public class BitcoinSendRequest extends CryptoNetInfoRequest { + /** + * The status code of this request + */ + public enum StatusCode{ + NOT_STARTED, + SUCCEEDED, + NO_INTERNET, + NO_SERVER_CONNECTION, + PETITION_FAILED + } + + // The app context + private Context mContext; + // The source account used to transfer fund from + private CryptoNetAccount mSourceAccount; + // The destination account id + private String mToAccount; + // The amount of the transaction + private long mAmount; + // The asset id of the transaction + private CryptoCoin mCryptoCoin; + // The memo, can be null + private String mMemo; + // The state of this request + private StatusCode status = StatusCode.NOT_STARTED; + + public BitcoinSendRequest(Context context, CryptoNetAccount sourceAccount, + String toAccount, long amount, CryptoCoin cryptoCoin, String memo) { + super(cryptoCoin); + this.mContext = context; + this.mSourceAccount = sourceAccount; + this.mToAccount = toAccount; + this.mAmount = amount; + this.mCryptoCoin = cryptoCoin; + this.mMemo = memo; + } + + public BitcoinSendRequest(Context context, GrapheneAccount sourceAccount, + String toAccount, long amount, CryptoCoin cryptoCoin) { + this(context, sourceAccount,toAccount,amount,cryptoCoin,null); + } + + public Context getContext() { + return mContext; + } + + public CryptoNetAccount getSourceAccount() { + return mSourceAccount; + } + + public String getToAccount() { + return mToAccount; + } + + public long getAmount() { + return mAmount; + } + + public CryptoCoin getCryptoCoin() { + return mCryptoCoin; + } + + public String getMemo() { + return mMemo; + } + + public void validate(){ + if ((this.status != StatusCode.NOT_STARTED)){ + this._fireOnCarryOutEvent(); + } + } + + public void setStatus(StatusCode code){ + this.status = code; + this._fireOnCarryOutEvent(); + } + + public StatusCode getStatus() { + return status; + } +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CreateBitcoinAccountRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CreateBitcoinAccountRequest.java new file mode 100644 index 0000000..805bb33 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/CreateBitcoinAccountRequest.java @@ -0,0 +1,67 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import android.content.Context; + +import cy.agorise.crystalwallet.enums.CryptoCoin; +import cy.agorise.crystalwallet.enums.CryptoNet; +import cy.agorise.crystalwallet.models.AccountSeed; +import cy.agorise.crystalwallet.models.GrapheneAccount; + +/** + * Creates bitcoin accounts using a seed, + * + * Created by Henry Varona on 10/22/2018. + */ + +public class CreateBitcoinAccountRequest extends CryptoNetInfoRequest { + + private AccountSeed accountSeed; + private CryptoNet accountCryptoNet; + + private Context context; + + /** + * The status code of this request + */ + public enum StatusCode{ + NOT_STARTED, + SUCCEEDED, + ACCOUNT_EXIST + } + + // The state of this request + private StatusCode status = StatusCode.NOT_STARTED; + + public CreateBitcoinAccountRequest(AccountSeed accountSeed, Context context, CryptoNet cryptoNet){ + super(CryptoCoin.BITSHARES); + this.accountSeed = accountSeed; + this.accountCryptoNet = cryptoNet; + this.context = context; + } + + public AccountSeed getAccountSeed() { + return this.accountSeed; + } + + public void validate(){ + if(!status.equals(StatusCode.NOT_STARTED)) + this._fireOnCarryOutEvent(); + } + + public CryptoNet getAccountCryptoNet() { + return this.accountCryptoNet; + } + + public Context getContext() { + return context; + } + + public void setStatus(StatusCode code){ + this.status = code; + this.validate(); + } + + public StatusCode getStatus() { + return status; + } +} diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/NextBitcoinAccountAddressRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/NextBitcoinAccountAddressRequest.java new file mode 100644 index 0000000..fa55102 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/NextBitcoinAccountAddressRequest.java @@ -0,0 +1,65 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import android.content.Context; + +import cy.agorise.crystalwallet.enums.CryptoCoin; +import cy.agorise.crystalwallet.enums.CryptoNet; +import cy.agorise.crystalwallet.models.AccountSeed; +import cy.agorise.crystalwallet.models.CryptoNetAccount; + +/** + * Ask for the next address of a bitcoin alike account + * + * Created by Henry Varona on 10/22/2018. + */ + +public class NextBitcoinAccountAddressRequest extends CryptoNetInfoRequest { + + private CryptoNetAccount account; + private CryptoCoin cryptoCoin; + private Context context; + + /** + * The status code of this request + */ + public enum StatusCode{ + NOT_STARTED, + SUCCEEDED + } + + // The state of this request + private StatusCode status = StatusCode.NOT_STARTED; + + public NextBitcoinAccountAddressRequest(CryptoNetAccount account, CryptoCoin cryptoCoin, Context context){ + super(cryptoCoin); + this.account = account; + this.cryptoCoin = cryptoCoin; + this.context = context; + } + + public CryptoNetAccount getAccount() { + return this.account; + } + + public CryptoCoin getCryptoCoin() { + return this.cryptoCoin; + } + + public void validate(){ + if(!status.equals(StatusCode.NOT_STARTED)) + this._fireOnCarryOutEvent(); + } + + public Context getContext() { + return context; + } + + public void setStatus(StatusCode code){ + this.status = code; + this.validate(); + } + + public StatusCode getStatus() { + return status; + } +}