Skip to content

Commit

Permalink
[iOS #308] init for support private key import export
Browse files Browse the repository at this point in the history
  • Loading branch information
wannabit-yongjoo committed Oct 28, 2021
1 parent d92c50d commit 2aa4236
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 89 deletions.
6 changes: 0 additions & 6 deletions Cosmos-IOS/Cosmostation/Cosmostation/Base/BaseData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,6 @@ final class BaseData : NSObject{
print(error)
}

// let createPasswordTable = DB_PASSWORD.create { (table) in
// table.column(DB_PASSWORD_ID, primaryKey: true)
// table.column(DB_PASSWORD_RESOURCE)
// }
// try self.database.run(createPasswordTable)

let createBalanceTable = DB_BALANCE.create(ifNotExists: true) { (table) in
table.column(DB_BALANCE_ID, primaryKey: true)
table.column(DB_BALANCE_ACCOUNT_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class MainTabWalletViewController: BaseViewController, UITableViewDelegate, UITa
self.totalCard.addGestureRecognizer(tapTotalCard)

self.updateFloaty()

}

override func viewWillAppear(_ animated: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class NewAccountTypePopup: BaseViewController, SBCardPopupContent {
}

@IBAction func onClickPrivateKey(_ sender: UIButton) {
popupViewController?.resultDelegate?.SBCardPopupResponse(type: 0, result: 4)
popupViewController?.close()
}

@IBAction func onClickAddress(_ sender: UIButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,19 @@ class WalletManageViewController: BaseViewController, UITableViewDelegate, UITab
func SBCardPopupResponse(type:Int, result: Int) {
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(490), execute: {
var tagetVC:BaseViewController?
if(result == 1) {
if (result == 1) {
tagetVC = UIStoryboard(name: "Init", bundle: nil).instantiateViewController(withIdentifier: "CreateViewController") as! CreateViewController
tagetVC?.chainType = self.toAddChain!

} else if(result == 2) {
} else if (result == 2) {
tagetVC = UIStoryboard(name: "Init", bundle: nil).instantiateViewController(withIdentifier: "RestoreViewController") as! RestoreViewController
tagetVC?.chainType = self.toAddChain!

} else if(result == 3) {
} else if (result == 3) {
tagetVC = UIStoryboard(name: "Init", bundle: nil).instantiateViewController(withIdentifier: "AddAddressViewController") as! AddAddressViewController

} else if (result == 4) {

}
if (tagetVC != nil) {
tagetVC?.hidesBottomBarWhenPushed = true
Expand Down
160 changes: 80 additions & 80 deletions Cosmos-IOS/Cosmostation/Cosmostation/Dao/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,86 +115,86 @@ public class Account : NSObject, Codable, NSItemProviderReading, NSItemProviderW
self.account_balances = balances
}

func getAtomBalance() -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == COSMOS_MAIN_DENOM) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getIrisBalance() -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == IRIS_MAIN_DENOM) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getBnbBalance() -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == BNB_MAIN_DENOM) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getKavaBalance() -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == KAVA_MAIN_DENOM) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getIovBalance() -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == IOV_MAIN_DENOM || balance.balance_denom == IOV_TEST_DENOM) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getBandBalance() -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == BAND_MAIN_DENOM) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getTokenBalance(_ symbol:String) -> NSDecimalNumber {
var result = NSDecimalNumber.zero
for balance in self.account_balances {
if (balance.balance_denom == symbol) {
result = WUtils.plainStringToDecimal(balance.balance_amount)
}
}
return result
}

func getTokenCoin(_ symbol:String) -> Coin {
var result = Coin.init()
for balance in self.account_balances {
if (balance.balance_denom == symbol) {
result.amount = balance.balance_amount
result.denom = balance.balance_denom
}
}
return result
}
// func getAtomBalance() -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == COSMOS_MAIN_DENOM) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getIrisBalance() -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == IRIS_MAIN_DENOM) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getBnbBalance() -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == BNB_MAIN_DENOM) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getKavaBalance() -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == KAVA_MAIN_DENOM) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getIovBalance() -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == IOV_MAIN_DENOM || balance.balance_denom == IOV_TEST_DENOM) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getBandBalance() -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == BAND_MAIN_DENOM) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getTokenBalance(_ symbol:String) -> NSDecimalNumber {
// var result = NSDecimalNumber.zero
// for balance in self.account_balances {
// if (balance.balance_denom == symbol) {
// result = WUtils.plainStringToDecimal(balance.balance_amount)
// }
// }
// return result
// }
//
// func getTokenCoin(_ symbol:String) -> Coin {
// var result = Coin.init()
// for balance in self.account_balances {
// if (balance.balance_denom == symbol) {
// result.amount = balance.balance_amount
// result.denom = balance.balance_denom
// }
// }
// return result
// }

func dpAddress(_ chain: ChainType?) -> String {
if (chain == ChainType.OKEX_MAIN || chain == ChainType.OKEX_TEST) {
Expand Down
4 changes: 4 additions & 0 deletions Cosmos-IOS/Cosmostation/Cosmostation/Utils/WKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ class WKey {
return getHDKeyFromWords(mnemonic, account).publicKey.data
}

static func getPrivateKey(_ hex: String) -> PrivateKey? {
return PrivateKey.init(pk: hex, coin: .bitcoin)
}

static func getStdTx(_ words: [String], _ msgList: Array<Msg>, _ stdMsg: StdSignMsg, _ account: Account, _ fee: Fee, _ memo: String) -> StdTx {
let pKey = getHDKeyFromWords(words, account)
let encoder = JSONEncoder()
Expand Down

0 comments on commit 2aa4236

Please sign in to comment.