use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.
the class WKey method getKeyWithPathfromEntropy.
// singer
public static DeterministicKey getKeyWithPathfromEntropy(Account account, String entropy) {
BaseChain chain = getChain(account.baseChain);
if (!chain.equals(FETCHAI_MAIN)) {
DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(getHDSeed(WUtil.HexStringToByteArray(entropy)));
return new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path)));
} else {
DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(getHDSeed(WUtil.HexStringToByteArray(entropy)));
if (account.customPath != 2) {
DeterministicKey targetKey = new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path)));
return targetKey;
} else {
DeterministicKey targetKey = new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path), true));
DeterministicKey targetKey2 = new DeterministicHierarchy(targetKey).deriveChild(WKey.getFetchParentPath2(), true, true, ChildNumber.ZERO);
return targetKey2;
}
}
}
use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.
the class WalletSwitchActivity method loadChains.
private void loadChains() {
mAccount = getBaseDao().onSelectAccount(getBaseDao().getLastUser());
ArrayList<BaseChain> mDisplayChains = getBaseDao().dpSortedChains();
mExpendedChains = getBaseDao().getExpendedChains();
mSelectedChain = BaseChain.getChain(mAccount.baseChain);
getBaseDao().setLastChain(mSelectedChain.getChain());
for (BaseChain chain : mDisplayChains) {
if (mExpendedChains.contains(chain) || mSelectedChain.equals(chain)) {
mChainAccounts.add(new ChainAccounts(true, chain, getBaseDao().onSelectAccountsByChain(chain)));
} else {
mChainAccounts.add(new ChainAccounts(false, chain, getBaseDao().onSelectAccountsByChain(chain)));
}
}
mAccountRecyclerView.scrollToPosition(getBaseDao().dpSortedChains().indexOf(mSelectedChain));
mAccountListAdapter.notifyDataSetChanged();
}
use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.
the class AccountDetailActivity method onClick.
@Override
public void onClick(View v) {
if (v.equals(mBtnCheck)) {
if (mAccount.hasPrivateKey) {
Intent intent = new Intent(AccountDetailActivity.this, PasswordCheckActivity.class);
intent.putExtra(BaseConstant.CONST_PW_PURPOSE, BaseConstant.CONST_PW_CHECK_MNEMONIC);
intent.putExtra("checkid", mAccount.id);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_bottom, R.anim.fade_out);
} else {
Intent restoreIntent = new Intent(AccountDetailActivity.this, RestoreActivity.class);
restoreIntent.putExtra("chain", mBaseChain.getChain());
startActivity(restoreIntent);
}
} else if (v.equals(mBtnCheckKey)) {
if (mAccount.hasPrivateKey) {
Intent intent = new Intent(AccountDetailActivity.this, PasswordCheckActivity.class);
intent.putExtra(BaseConstant.CONST_PW_PURPOSE, BaseConstant.CONST_PW_CHECK_PRIVATE_KEY);
intent.putExtra("checkid", mAccount.id);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_bottom, R.anim.fade_out);
} else {
Intent restoreIntent = new Intent(AccountDetailActivity.this, RestoreKeyActivity.class);
restoreIntent.putExtra("chain", mBaseChain.getChain());
startActivity(restoreIntent);
}
} else if (v.equals(mBtnDelete)) {
int accountSum = 0;
for (BaseChain baseChain : getBaseDao().dpSortedChains()) {
accountSum = accountSum + getBaseDao().onSelectAccountsByChain(baseChain).size();
}
if (accountSum <= 1) {
Toast.makeText(AccountDetailActivity.this, getString(R.string.error_reserve_1_account), Toast.LENGTH_SHORT).show();
return;
}
AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_delete_title), getString(R.string.str_delete_msg), AlertDialogUtils.highlightingText(getString(R.string.str_delete)), view -> onStartDeleteUser(), getString(R.string.str_close), null);
} else if (v.equals(mNameEditImg)) {
Bundle bundle = new Bundle();
bundle.putLong("id", mAccount.id);
bundle.putString("name", mAccount.nickName);
Dialog_ChangeNickName delete = Dialog_ChangeNickName.newInstance(bundle);
delete.setCancelable(true);
getSupportFragmentManager().beginTransaction().add(delete, "dialog").commitNowAllowingStateLoss();
} else if (v.equals(mBtnQr)) {
Bundle bundle = new Bundle();
bundle.putString("address", mAccount.address);
bundle.putString("title", mAccountName.getText().toString());
Dialog_AccountShow show = Dialog_AccountShow.newInstance(bundle);
show.setCancelable(true);
getSupportFragmentManager().beginTransaction().add(show, "dialog").commitNowAllowingStateLoss();
} else if (v.equals(mBtnRewardAddressChange)) {
if (!mAccount.hasPrivateKey) {
AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_only_observe_title), getString(R.string.str_only_observe_msg), Html.fromHtml("<font color=\"#9C6CFF\">" + getString(R.string.str_add_mnemonics) + "</font>"), view -> onAddMnemonicForAccount(), getString(R.string.str_close), null);
return;
}
if (TextUtils.isEmpty(mRewardAddress.getText().toString())) {
Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
return;
}
AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_reward_address_change_title), Html.fromHtml(getString(R.string.str_reward_address_change_msg) + "<br/><br/><font color=\"#ff0000\">" + AlertDialogUtils.highlightingText(getString(R.string.str_reward_address_change_market_no) + "</font>")), AlertDialogUtils.highlightingText(getString(R.string.str_cancel)), null, getString(R.string.str_continue), view -> onStartChangeRewardAddress(), true);
}
}
use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.
the class IBCSendStep4Fragment method onRefreshTab.
@Override
public void onRefreshTab() {
mDpDecimal = WDp.mainDivideDecimal(getSActivity().mBaseChain);
BigDecimal feeAmount = new BigDecimal(getSActivity().mTxFee.amount.get(0).amount);
BigDecimal toSendAmount = new BigDecimal(getSActivity().mAmounts.get(0).amount);
mFeeAmount.setText(WDp.getDpAmount2(getContext(), feeAmount, mDpDecimal, mDpDecimal));
WDp.setGasDenomTv(getSActivity(), getSActivity().mBaseChain, getSActivity().mTxFee.amount.get(0).denom, mFeeAmountSymbol);
WDp.showCoinDp(getSActivity(), getBaseDao(), getSActivity().mToIbcDenom, toSendAmount.toPlainString(), mSendAmountSymbol, mSendAmount, getSActivity().mBaseChain);
BaseChain toChain = WDp.getChainTypeByChainId(getSActivity().mIbcSelectedRelayer.chain_id);
WDp.getChainTitle(getSActivity(), toChain, mRecipientChain);
mRecipientChain.setTextColor(WDp.getChainColor(getSActivity(), toChain));
mRecipientAddress.setText(getSActivity().mToAddress);
}
use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.
the class MainActivity method onChainSelect.
private void onChainSelect(BaseChain baseChain) {
invalidateOptionsMenu();
mChainAccounts.clear();
ArrayList<BaseChain> mDisplayChains = new ArrayList<>();
mDisplayChains = getBaseDao().dpSortedChains();
mExpendedChains = getBaseDao().getExpendedChains();
mSelectedChain = baseChain;
getBaseDao().setLastChain(mSelectedChain.getChain());
for (BaseChain chain : mDisplayChains) {
if (mExpendedChains.contains(chain) || mSelectedChain.equals(chain)) {
mChainAccounts.add(new ChainAccounts(true, chain, getBaseDao().onSelectAccountsByChain(chain)));
} else {
mChainAccounts.add(new ChainAccounts(false, chain, getBaseDao().onSelectAccountsByChain(chain)));
}
}
}
Aggregations