Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
fixed rare crash
Browse files Browse the repository at this point in the history
  • Loading branch information
samdowd committed Mar 7, 2022
1 parent bb7467a commit 026c5fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
21 changes: 12 additions & 9 deletions KinBase/KinBase/Src/Model/KinTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,26 @@ public class KinTransaction: Equatable, KinTransactionType {
self.network = network
self.invoiceList = invoiceList

if let solanaTransaction = Transaction(data: Data(envelopeXdrBytes)) {
self.transactionHash = solanaTransaction.transactionHash
self.sourceAccount = solanaTransaction.sourceAccount
self.memo = solanaTransaction.memo
self.paymentOperations = solanaTransaction.paymentOperations
} else {
guard let historyItem = historyItem else {
if let historyItem = historyItem {
guard let payments = historyItem.paymentsArray as NSArray as? [APBTransactionV4HistoryItem_Payment] else {
throw Errors.unknown
}
guard let payment = payments.first else {
throw Errors.unknown
}
let payments = historyItem.paymentsArray as NSArray as! [APBTransactionV4HistoryItem_Payment]
let payment = payments.first!
self.transactionHash = KinTransactionHash(historyItem.transactionId.value)
self.sourceAccount = payment.source.publicKey
self.memo = KinMemo.none
self.paymentOperations = payments.compactMap {
KinPaymentOperation(amount: Kin($0.amount), source: $0.source.publicKey, destination: $0.destination.publicKey, isNonNativeAsset: false)
}
} else if let solanaTransaction = Transaction(data: Data(envelopeXdrBytes)) {
self.transactionHash = solanaTransaction.transactionHash
self.sourceAccount = solanaTransaction.sourceAccount
self.memo = solanaTransaction.memo
self.paymentOperations = solanaTransaction.paymentOperations
} else {
throw Errors.unknown
}
}

Expand Down
7 changes: 0 additions & 7 deletions KinSampleApp/KinSampleApp/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ class HomeViewController: UIViewController {

kinUXPaymentFlowButton.center = view.center
kinUXPaymentFlowButton.frame.origin.y = kinDesignInvoiceTableButton.frame.maxY + padding

kinAccountContext!.getAccount().then { (ka: KinAccount) in
ka.privateKey?.stellarID
let kp1: KeyPair = KeyPair.init(publicKey: ka.publicKey, privateKey: ka.privateKey)
print(kp1.seed)
let kp2: KeyPair = KeyPair.init(seed: Seed(stellarID: ka.privateKey?.stellarID))
}
}

@objc private func kinWalletDemoButtonTapped() {
Expand Down

0 comments on commit 026c5fd

Please sign in to comment.