- Added new requests needed to implement bitcoin alike accounts funcionality

feat_androidx_migration
Javier Varona 2018-10-22 21:05:48 -04:00
parent b3442a511e
commit 2027677956
3 changed files with 228 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}