Skip to content

Commit

Permalink
[APP] Kava W.C fixed with different chain (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwonhyukjoon committed Jul 7, 2023
1 parent f7bb080 commit 2c364f5
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Cosmostation/Controller/Main/CommonWCViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,25 @@ class CommonWCViewController: BaseViewController {

interactor.trust.onGetAccounts = { [weak self] (id) in
guard let self = self else { return }
self.interactor?.approveRequest(id: id, result: self.getTrustAccounts()).cauterize()
self.accountChainSet.removeAll()
self.accountSelectedSet.removeAll()

self.accountChainSet.insert("kava_2222-10")
var trustAccounts = Array<WCTrustAccount>()
self.lastAccountAction = { accounts in
let account = accounts.map { account in
trustAccounts.append(WCTrustAccount.init(network: 459, address: account.bech32Address))
self.interactor?.approveRequest(id: id, result: trustAccounts).cauterize()
}
}
self.showAccountPopup()
}

interactor.trust.onTransactionSign = { [weak self] (id, trustTx) in
guard let self = self else { return }
if let trustTxParsing = try? JSONSerialization.jsonObject(with: trustTx.transaction.data(using: .utf8)!, options: .allowFragments) as? NSDictionary {
self.wcId = id
self.wcTrustRequest = trustTxParsing
self.wcRequestChainName = self.baseChain
self.onShowPopupForRequest(WcRequestType.TRUST_TYPE, trustTx.transaction.data(using: .utf8)!)
}
}
Expand Down Expand Up @@ -773,18 +783,11 @@ class CommonWCViewController: BaseViewController {
wcPopup.show(onViewController: self)
}


func getTrustAccounts() -> Array<WCTrustAccount> {
var result = Array<WCTrustAccount>()
if self.chainType == ChainType.KAVA_MAIN, let account = accountMap[baseChain] {
result.append(WCTrustAccount.init(network: 459, address: account.account_address))
}
return result
}

func approveTrustRequest() {
getKeyAsync(chainName: baseChain) { tuple in
self.signTrust(tuple)
self.accountSelectedSet.forEach { account in
getKeyAsync(chainName: account.account_base_chain) { tuple in
self.signTrust(tuple)
}
}
}

Expand Down

0 comments on commit 2c364f5

Please sign in to comment.