Merge branch 'master' of https://github.com/Agorise/crystal-wallet-android
This commit is contained in:
commit
5f7470b1ef
2 changed files with 37 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
|||
package cy.agorise.crystalwallet.apigenerator;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* Created by henry on 15/10/2017.
|
||||
*/
|
||||
|
@ -16,7 +18,30 @@ public abstract class BitsharesFaucetApiGenerator {
|
|||
* @return The bitshares id of the registered account, or null
|
||||
*/
|
||||
public static String registerBitsharesAccount(String accountName, String ownerKey, String activeKey, String memoKey){
|
||||
CreateAccountPetition petition = new CreateAccountPetition();
|
||||
Account account = new Account();
|
||||
account.name=accountName;
|
||||
account.owner_key=ownerKey;
|
||||
account.active_key=activeKey;
|
||||
account.memo_key=memoKey;
|
||||
petition.account=account;
|
||||
Gson gson = new Gson();
|
||||
String jsonPetition = gson.toJson(petition);
|
||||
System.out.println("create account petition :" + jsonPetition);
|
||||
|
||||
//TODO faucet function
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class CreateAccountPetition{
|
||||
Account account;
|
||||
}
|
||||
|
||||
private static class Account{
|
||||
String name;
|
||||
String owner_key;
|
||||
String active_key;
|
||||
String memo_key;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,19 +60,23 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
|||
|
||||
GrapheneAccount grapheneAccount = (GrapheneAccount) account;
|
||||
|
||||
BitsharesFaucetApiGenerator.registerBitsharesAccount(grapheneAccount.getName(),
|
||||
String btsIdAccount = BitsharesFaucetApiGenerator.registerBitsharesAccount(grapheneAccount.getName(),
|
||||
new Address(grapheneAccount.getOwnerKey(),"BTS").toString(),
|
||||
new Address(grapheneAccount.getActiveKey(),"BTS").toString(),
|
||||
new Address(grapheneAccount.getMemoKey(),"BTS").toString());
|
||||
if(btsIdAccount !=null) {
|
||||
grapheneAccount.setAccountId(btsIdAccount);
|
||||
|
||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount)[0];
|
||||
grapheneAccount.setId(idAccount);
|
||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||
|
||||
GrapheneApiGenerator.subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||
this.refreshAccountTransactions(account.getId(), context);
|
||||
GrapheneApiGenerator.getAccountBalance(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||
return grapheneAccount;
|
||||
GrapheneApiGenerator.subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||
this.refreshAccountTransactions(grapheneAccount.getId(), context);
|
||||
GrapheneApiGenerator.getAccountBalance(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||
return grapheneAccount;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue