Skip to content

Commit

Permalink
Fix minor sending bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
SwenVanZanten committed Jan 3, 2019
1 parent 2077a45 commit 14992dd
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion VergeiOS/Kernel/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Config {
static let website: String = "https://vergecurrency.com/"
static let iOSRepo: String = "https://github.com/vergecurrency/vIOS"
static let blockchainExlorer: String = "https://verge-blockchain.info/"
static let bwsEndpoint: String = "https://vws.swenvanzanten.com/vws/api/"
static let bwsEndpoint: String = "https://vws2.swenvanzanten.com/vws/api/"
static let priceDataEndpoint: String = "https://usxvglw.vergecoreteam.com/price/api/v1/price/"

// TODO use other endpoints.
Expand Down
4 changes: 4 additions & 0 deletions VergeiOS/Kernel/TransactionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class TransactionManager {
completion(self.transactionRepository.all())
}
}

public func remove(transaction: TxHistory) {
transactionRepository.remove(tx: transaction)
}

public func removeAll() {
transactionRepository.removeAll()
Expand Down
2 changes: 1 addition & 1 deletion VergeiOS/Kernel/Wallet/Models/AddressBalance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

public struct AddressBalance: Decodable {
public let address: String
public let path: String
public let path: String?
public let amount: Int
}

Expand Down
9 changes: 6 additions & 3 deletions VergeiOS/Kernel/Wallet/WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,12 @@ public class WalletClient {
return try output.asInputTransaction()
}

var outputs = [toOutput, changeOutput]
if txp.outputOrder == [1, 0] {
outputs = [changeOutput, toOutput]
var outputs = [toOutput]
if change > 0 {
outputs = [toOutput, changeOutput]
if txp.outputOrder == [1, 0] {
outputs = [changeOutput, toOutput]
}
}

let tx = Transaction(
Expand Down
20 changes: 14 additions & 6 deletions VergeiOS/Storyboards/Transactions.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,24 @@
<action selector="closeViewController:" destination="Igw-3T-6sZ" id="qKQ-TR-aZn"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" image="Refresh" id="IhH-Ac-YiK">
<connections>
<action selector="repeatTransactionPushed:" destination="Igw-3T-6sZ" id="bpB-Co-fU3"/>
</connections>
</barButtonItem>
<rightBarButtonItems>
<barButtonItem image="Refresh" id="IhH-Ac-YiK">
<connections>
<action selector="repeatTransactionPushed:" destination="Igw-3T-6sZ" id="bpB-Co-fU3"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="trash" id="UZf-cW-at8">
<connections>
<action selector="deleteTransactionPushed:" destination="Igw-3T-6sZ" id="pSr-XO-AyE"/>
</connections>
</barButtonItem>
</rightBarButtonItems>
</navigationItem>
<connections>
<outlet property="addAddressButton" destination="BQh-Ni-7Bo" id="i4O-fy-nn1"/>
<outlet property="amountLabel" destination="SH2-Sm-iht" id="Ewe-V0-bKJ"/>
<outlet property="dateTimeLabel" destination="Zge-7U-fdr" id="65u-H3-UUS"/>
<outlet property="deleteTransactionBarButtonItem" destination="UZf-cW-at8" id="h4Q-oU-DQG"/>
<outlet property="iconImageView" destination="VQB-xw-7HZ" id="Qtp-61-Fgc"/>
<outlet property="nameLabel" destination="hnr-1l-LV6" id="Edk-9z-8fb"/>
<outlet property="repeatTransactionBarButtonItem" destination="IhH-Ac-YiK" id="Cmy-uX-3px"/>
Expand Down Expand Up @@ -330,7 +338,7 @@
<color red="0.21568627450980393" green="0.73725490196078436" blue="0.88235294117647056" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="SecondaryDark">
<color red="0.097999997437000275" green="0.23899999260902405" blue="0.33300000429153442" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.094117647058823528" green="0.23529411764705882" blue="0.32941176470588235" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="SecondaryLight">
<color red="0.38823529411764707" green="0.47058823529411764" blue="0.52156862745098043" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
2 changes: 1 addition & 1 deletion VergeiOS/Views/Send/SendViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class SendViewController: UIViewController {
}

@objc func setMaximumAmount() {
sendTransaction.setBy(currency: "XVG", amount: walletAmount)
sendTransaction.setBy(currency: "XVG", amount: NSNumber(value: walletAmount.doubleValue - transactionFee))
didChangeSendTransaction(sendTransaction)
}
}
Expand Down
25 changes: 22 additions & 3 deletions VergeiOS/Views/Transactions/TransactionTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TransactionTableViewController: UIViewController, UITableViewDelegate, UIT
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet var addAddressButton: UIButton!
@IBOutlet weak var amountLabel: UILabel!
@IBOutlet var deleteTransactionBarButtonItem: UIBarButtonItem!
@IBOutlet var repeatTransactionBarButtonItem: UIBarButtonItem!

@IBOutlet weak var tableView: PlaceholderTableView!
Expand Down Expand Up @@ -81,13 +82,24 @@ class TransactionTableViewController: UIViewController, UITableViewDelegate, UIT

prefix = "-"
} else {
navigationItem.setRightBarButton(nil, animated: true)
navigationItem.rightBarButtonItems?.removeAll { item in
return item == repeatTransactionBarButtonItem
}
amountLabel.textColor = UIColor.vergeGreen()
iconImageView.image = UIImage(named: "Receive")

prefix = "+"
}


if !transaction.confirmed {
navigationItem.rightBarButtonItems?.removeAll { item in
return item == deleteTransactionBarButtonItem
}
} else {
navigationItem.rightBarButtonItems?.append(deleteTransactionBarButtonItem)
}

amountLabel.text = "\(prefix) \(transaction.amountValue.toXvgCurrency())"
}

Expand Down Expand Up @@ -264,10 +276,17 @@ class TransactionTableViewController: UIViewController, UITableViewDelegate, UIT
UIPasteboard.general.string = transaction!.txid
NotificationManager.shared.showMessage("Txid copied!", duration: 3)
}

@IBAction func deleteTransactionPushed(_ sender: Any) {
if let transaction = transaction {
TransactionManager.shared.remove(transaction: transaction)
dismiss(animated: true)
}
}

@IBAction func repeatTransactionPushed(_ sender: Any) {
if transaction != nil {
repeatTransaction(transaction!)
if let transaction = transaction {
repeatTransaction(transaction)
}
}

Expand Down

0 comments on commit 14992dd

Please sign in to comment.