Merge branch 'master' into fix-missing-password-and-confirm-pasword-check

pull/370/head
James Sangalli 7 years ago committed by GitHub
commit 8af376fbb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .swiftlint.yml
  2. 4
      Podfile.lock
  3. 2
      Trust/Accounts/Coordinators/AccountsCoordinator.swift
  4. 6
      Trust/AlphaWalletHelp/ViewControllers/HelpViewController.swift
  5. 3
      Trust/AppDelegate.swift
  6. 17
      Trust/EtherClient/Requests/MarketOrders.swift
  7. 1
      Trust/Extensions/String.swift
  8. 2
      Trust/Extensions/UITextFieldAdditions.swift
  9. 3
      Trust/Foundation/XMLHandler.swift
  10. 6
      Trust/InCoordinator.swift
  11. 35
      Trust/Market/Coordinators/UniversalLinkCoordinator.swift
  12. 8
      Trust/Market/MarketQueueHandler.swift
  13. 37
      Trust/Market/UniversalLinkHandler.swift
  14. 6
      Trust/Redeem/Helpers/CreateRedeem.swift
  15. 12
      Trust/Redeem/ViewModels/RedeemTicketsViewModel.swift
  16. 1
      Trust/Rest/EndPoints.swift
  17. 12
      Trust/Sell/ViewModels/SellTicketsViewModel.swift
  18. 2
      Trust/Settings/Coordinators/SettingsCoordinator.swift
  19. 2
      Trust/Settings/Types/ConfigExplorer.swift
  20. 11
      Trust/Settings/ViewControllers/SettingsViewController.swift
  21. 2
      Trust/Settings/ViewModels/LocalesViewModel.swift
  22. 2
      Trust/Settings/ViewModels/ServersViewModel.swift
  23. 2
      Trust/Tokens/Coordinators/GetStormBirdBalanceCoordinator.swift
  24. 2
      Trust/Tokens/Helpers/TicketAdaptor.swift
  25. 2
      Trust/Tokens/Types/TokensDataStore.swift
  26. 7
      Trust/Tokens/ViewControllers/TokensViewController.swift
  27. 4
      Trust/Tokens/ViewModels/EthTokenViewCellViewModel.swift
  28. 10
      Trust/Tokens/ViewModels/TicketsViewModel.swift
  29. 16
      Trust/Tokens/ViewModels/TokensViewModel.swift
  30. 2
      Trust/Tokens/Views/BaseTicketTableViewCell.swift
  31. 12
      Trust/Transactions/Coordinators/TicketsCoordinator.swift
  32. 1
      Trust/Transactions/Views/TransactionsFooterView.swift
  33. 112
      Trust/Transfer/Controllers/TransactionConfigurator.swift
  34. 2
      Trust/Transfer/ViewControllers/TransferTicketsViaWalletAddressViewController.swift
  35. 4
      Trust/Transfer/ViewModels/SendHeaderViewViewModel.swift
  36. 12
      Trust/Transfer/ViewModels/TransferTicketsViewModel.swift

@ -1,4 +1,4 @@
swiftlint_version: 0.21.0
swiftlint_version: 0.25.1
disabled_rules:
- cyclomatic_complexity
- force_cast
@ -7,6 +7,9 @@ disabled_rules:
- nesting
- redundant_discardable_let
- todo
- trailing_comma
- trailing_newline
- trailing_whitespace
- type_name
- unused_optional_binding
- xctfail_message

@ -35,7 +35,7 @@ PODS:
- SeedStackViewController (0.4.0)
- SipHash (1.2.0)
- StatefulViewController (3.0)
- SwiftLint (0.24.1)
- SwiftLint (0.25.1)
- SwiftyJSON (4.0.0)
- SwiftyXMLParser (4.1.0)
- TrezorCrypto (0.0.4)
@ -126,7 +126,7 @@ SPEC CHECKSUMS:
SeedStackViewController: 45e88ca1493a610e74d661d3feced7098f72dbd3
SipHash: c6e9e43e9c531b5bc6602545130c26194a6d31ce
StatefulViewController: 4803bf900d44de26074344998e10e041113b5931
SwiftLint: 2e4b89feed5909c42c3735bbd6745f4345c4b772
SwiftLint: ce933681be10c3266e82576dad676fa815a602e9
SwiftyJSON: 070dabdcb1beb81b247c65ffa3a79dbbfb3b48aa
SwiftyXMLParser: b5a79fb8a730903703d0a92d30752a0b05158967
TrezorCrypto: 7f87a2296cf13872b21565c29fd9f7882dd00803

@ -64,7 +64,7 @@ class AccountsCoordinator: Coordinator {
} else if index == 1 {
self.showImportWallet()
}
}
}
}
func importOrCreateWallet(entryPoint: WalletEntryPoint) {

@ -8,9 +8,9 @@ class HelpViewController: UIViewController {
let rows: [(title: String, controller: UIViewController)] = [
(title: R.string.localizable.aHelpContentsWhatIsETH(), controller: WhatIsEthereumInfoViewController()),
(title: R.string.localizable.aHelpContentsHowDoIGetMyMoney(), controller: HowDoIGetMyMoneyInfoViewController()),
(title: R.string.localizable.aHelpContentsHowDoITransferETHIntoMyWallet(),controller: HowDoITransferETHIntoMyWalletInfoViewController()),
(title: R.string.localizable.aHelpContentsPrivacyPolicy(),controller: PrivacyPolicyViewController()),
(title: R.string.localizable.aHelpContentsTermsOfService(),controller: TermsOfServiceViewController()),
(title: R.string.localizable.aHelpContentsHowDoITransferETHIntoMyWallet(), controller: HowDoITransferETHIntoMyWalletInfoViewController()),
(title: R.string.localizable.aHelpContentsPrivacyPolicy(), controller: PrivacyPolicyViewController()),
(title: R.string.localizable.aHelpContentsTermsOfService(), controller: TermsOfServiceViewController()),
]
init() {

@ -60,8 +60,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
// Respond to Universal Links
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool
{
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
let url = userActivity.webpageURL
universalLinkCoordinator = UniversalLinkCoordinator()
universalLinkCoordinator.ethPrice = appCoordinator.ethPrice

@ -11,17 +11,16 @@ import Foundation
//}
public struct Order {
var price: BigInt?;
var ticketIndices: [Int]?;
var expiryBuffer: BigInt?;
var contractAddress: String?;
var price: BigInt?
var ticketIndices: [Int]?
var expiryBuffer: BigInt?
var contractAddress: String?
}
class MarketOrders
{
let batch : Batch
class MarketOrders {
let batch: Batch
var baseURL : URL {
var baseURL: URL {
return URL(string: "https://i6pk618b7f.execute-api.ap-southeast-1.amazonaws.com/test/abc")!
}
@ -33,7 +32,7 @@ class MarketOrders
return batch.requestObject
}
typealias response = Array<Order>;
typealias response = [Order]
func response(from resultObject: Any) throws -> Response {
return try batch.responses(from: object)

@ -103,7 +103,6 @@ extension String {
return String(self[startIndex..<endIndex])
}
func nextLetterInAlphabet(for index: Int) -> String? {
guard let uniCode = UnicodeScalar(self) else {
return nil

@ -25,7 +25,7 @@ extension UITextField {
return additions!
}
open override func target(forAction action: Selector, withSender sender: Any?) -> Any? {
if ((action == #selector(UIResponderStandardEditActions.paste(_:)) || (action == #selector(UIResponderStandardEditActions.cut(_:)))) && self.isCopyPasteDisabled) {
if (action == #selector(UIResponderStandardEditActions.paste(_:)) || (action == #selector(UIResponderStandardEditActions.cut(_:)))) && self.isCopyPasteDisabled {
return nil
}
return super.target(forAction: action, withSender: sender)

@ -15,8 +15,7 @@ public class XMLHandler {
private let xml = try! XML.parse(AssetDefinitionXML().assetDefinitionString)
//TODO remove once parser is properly dynamic
public static func parseTicket(ticket: String) -> String
{
public static func parseTicket(ticket: String) -> String {
let no0xTicket = ticket.substring(from: 2)
let firstHalfOfTicket = no0xTicket.substring(to: 32)
let bigUIntFirstHalf = BigUInt(firstHalfOfTicket, radix: 16)

@ -90,7 +90,7 @@ class InCoordinator: Coordinator {
func fetchEthPrice() {
let keystore = try! EtherKeystore()
let migration = MigrationInitializer(account: keystore.recentlyUsedWallet! , chainID: config.chainID)
let migration = MigrationInitializer(account: keystore.recentlyUsedWallet!, chainID: config.chainID)
migration.perform()
let web3 = self.web3(for: config.server)
web3.start()
@ -211,7 +211,6 @@ class InCoordinator: Coordinator {
showTab(inCoordinatorViewModel.initialTab)
let etherToken = TokensDataStore.etherToken(for: config)
tokensStorage.tokensModel.subscribe {[weak self] tokensModel in
guard let tokens = tokensModel, let eth = tokens.first(where: { $0 == etherToken }) else {
@ -478,8 +477,7 @@ extension InCoordinator: TokensCoordinatorDelegate {
let r = "0x" + signature.substring(with: Range(uncheckedBounds: (0, 64)))
let s = "0x" + signature.substring(with: Range(uncheckedBounds: (64, 128)))
ClaimOrderCoordinator(web3: web3).claimOrder(indices: signedOrder.order.indices, expiry: signedOrder.order.expiry, v: v, r: r, s: s) {
result in
ClaimOrderCoordinator(web3: web3).claimOrder(indices: signedOrder.order.indices, expiry: signedOrder.order.expiry, v: v, r: r, s: s) { result in
switch result {
case .success(let payload):
let address: Address = self.initialWallet.address

@ -11,7 +11,6 @@ protocol UniversalLinkCoordinatorDelegate: class {
func importPaidSignedOrder(signedOrder: SignedOrder, tokenObject: TokenObject, completion: @escaping (Bool) -> Void)
}
class UniversalLinkCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: UniversalLinkCoordinatorDelegate?
@ -20,8 +19,7 @@ class UniversalLinkCoordinator: Coordinator {
var ethBalance: Subscribable<BigInt>?
var hasCompleted = false
func start()
{
func start() {
preparingToImportUniversalLink()
}
@ -119,11 +117,9 @@ class UniversalLinkCoordinator: Coordinator {
}
let signedOrder = UniversalLinkHandler().parseUniversalLink(url: (url?.absoluteString)!)
getTicketDetailsAndEcRecover(signedOrder: signedOrder) {
result in
getTicketDetailsAndEcRecover(signedOrder: signedOrder) { result in
if let goodResult = result {
if signedOrder.order.price > 0
{
if signedOrder.order.price > 0 {
if let balance = self.ethBalance {
balance.subscribeOnce { value in
if value > signedOrder.order.price {
@ -146,16 +142,13 @@ class UniversalLinkCoordinator: Coordinator {
}
}
}
}
else
{
} else {
let success = self.usePaymentServerForFreeTransferLinks(
signedOrder: signedOrder,
ticketHolder: goodResult
)
}
}
else {
} else {
self.showImportError(errorMessage: R.string.localizable.aClaimTicketInvalidLinkTryAgain())
}
@ -191,11 +184,9 @@ class UniversalLinkCoordinator: Coordinator {
let indices = signedOrder.order.indices
let parameters = createHTTPParametersForPaymentServer(signedOrder: signedOrder, isForTransfer: false)
Alamofire.request(Constants.getTicketInfoFromServer, method: .get, parameters: parameters).responseJSON {
response in
Alamofire.request(Constants.getTicketInfoFromServer, method: .get, parameters: parameters).responseJSON { response in
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
if let statusCode = response.response?.statusCode
{
if let statusCode = response.response?.statusCode {
if statusCode > 299 {
completion(nil)
return
@ -209,16 +200,13 @@ class UniversalLinkCoordinator: Coordinator {
//start at one to slice off address
let bytes32Tickets = Array(array[1...])
completion(self.sortTickets(bytes32Tickets, indices))
}
else
{
} else {
completion(nil)
}
}
}
private func sortTickets(_ bytes32Tickets: [String], _ indices: [UInt16]) -> TicketHolder
{
private func sortTickets(_ bytes32Tickets: [String], _ indices: [UInt16]) -> TicketHolder {
var tickets = [Ticket]()
let xmlHandler = XMLHandler()
for i in 0...bytes32Tickets.count - 1 {
@ -293,12 +281,11 @@ class UniversalLinkCoordinator: Coordinator {
query,
method: .post,
parameters: parameters
).responseJSON {
result in
).responseJSON { result in
var successful = false //need to set this to false by default else it will allow no connections to be considered successful etc
//401 code will be given if signature is invalid on the server
if let response = result.response {
if (response.statusCode < 300) {
if response.statusCode < 300 {
successful = true
}
}

@ -24,16 +24,14 @@ public class MarketQueueHandler {
public let baseURL = "https://482kdh4npg.execute-api.ap-southeast-1.amazonaws.com/dev/"
public let contractAddress = "bC9a1026A4BC6F0BA8Bbe486d1D09dA5732B39e4".lowercased()
public func getOrders(callback: @escaping (_ result : Any) -> Void) {
Alamofire.request(baseURL + "contract/" + contractAddress, method: .get).responseJSON {
response in
public func getOrders(callback: @escaping (_ result: Any) -> Void) {
Alamofire.request(baseURL + "contract/" + contractAddress, method: .get).responseJSON { response in
var orders = [SignedOrder]()
if let json = response.result.value {
let parsedJSON = try! JSON(data: response.data!)
for i in 0...parsedJSON.count - 1 {
let orderObj: JSON = parsedJSON["orders"][i]
if(orderObj == nil)
{
if orderObj == nil {
//String not used in UI
callback("no orders")
return

@ -80,7 +80,7 @@ public class UniversalLinkHandler {
var indicesBytes = [UInt8]()
for i in 0...indices.count - 1 {
let index = indices[i]
if(index < 128) {
if index < 128 {
let byte = UInt8(index)
indicesBytes.append(byte)
} else {
@ -185,24 +185,21 @@ public class UniversalLinkHandler {
for i in stride(from: ticketStart, through: ticketStart + ticketLength, by: 1) {
let byte: UInt8 = linkBytes[i]
switch(state) {
case 1:
//8th bit is equal to 128, if not set then it is only one ticket and will change the state
if(byte & (128) == 128) { //should be done with masks
currentIndex = UInt16((byte & 127)) << 8
state = 2
}
else {
ticketIndices.append(UInt16(byte))
}
break
case 2:
currentIndex += UInt16(byte)
ticketIndices.append(currentIndex)
state = 1
break
default:
break
switch state {
case 1:
//8th bit is equal to 128, if not set then it is only one ticket and will change the state
if byte & (128) == 128 { //should be done with masks
currentIndex = UInt16((byte & 127)) << 8
state = 2
} else {
ticketIndices.append(UInt16(byte))
}
case 2:
currentIndex += UInt16(byte)
ticketIndices.append(currentIndex)
state = 1
default:
break
}
}
return ticketIndices
@ -221,7 +218,7 @@ public class UniversalLinkHandler {
sBytes.append(linkBytes[i])
}
let s = MarketQueueHandler.bytesToHexa(sBytes)
var v = String(format:"%2X", linkBytes[linkBytes.count - 1]).trimmed
var v = String(format: "%2X", linkBytes[linkBytes.count - 1]).trimmed
//handle JB code if he uses non standard format
if var vInt = Int(v) {
if vInt < 5 {

@ -44,14 +44,14 @@ class CreateRedeem {
let bitIntLength: Int = bitFieldLookup.description.count
var bitString = ""
if(bitIntLength < 10){
if bitIntLength < 10 {
bitString = "0"
}
bitString += String(bitIntLength)
if(zeroCount < 100) {
if zeroCount < 100 {
bitString += "0"
}
if(zeroCount < 10) {
if zeroCount < 10 {
bitString += "0"
}

@ -47,19 +47,17 @@ struct RedeemTicketsViewModel {
return Fonts.regular(size: 20)!
}
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
let ticketHolder = item(for: indexPath)
var changed = [indexPath]
if ticketHolder.areDetailsVisible {
ticketHolder.areDetailsVisible = false
ticketHolder.isSelected = false
} else {
for (i, each) in ticketHolders!.enumerated() {
if each.areDetailsVisible {
each.areDetailsVisible = false
each.isSelected = false
changed.append(.init(row: i, section: indexPath.section))
}
for (i, each) in ticketHolders!.enumerated() where each.areDetailsVisible {
each.areDetailsVisible = false
each.isSelected = false
changed.append(.init(row: i, section: indexPath.section))
}
ticketHolder.areDetailsVisible = true
ticketHolder.isSelected = true

@ -8,7 +8,6 @@
import Foundation
struct EndPoints {
static let EventBaseUrl = "https://blockchainapis.herokuapp.com/ticketpro/checkEventsUnconfirmed"
}

@ -41,19 +41,17 @@ struct SellTicketsViewModel {
return Fonts.regular(size: 20)!
}
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
let ticketHolder = item(for: indexPath)
var changed = [indexPath]
if ticketHolder.areDetailsVisible {
ticketHolder.areDetailsVisible = false
ticketHolder.isSelected = false
} else {
for (i, each) in ticketHolders!.enumerated() {
if each.areDetailsVisible {
each.areDetailsVisible = false
each.isSelected = false
changed.append(.init(row: i, section: indexPath.section))
}
for (i, each) in ticketHolders!.enumerated() where each.areDetailsVisible {
each.areDetailsVisible = false
each.isSelected = false
changed.append(.init(row: i, section: indexPath.section))
}
ticketHolder.areDetailsVisible = true
ticketHolder.isSelected = true

@ -32,7 +32,7 @@ class SettingsCoordinator: Coordinator {
init(
navigationController: UINavigationController = NavigationController(),
config: Config,
config: Config,
keystore: Keystore,
session: WalletSession,
storage: TransactionsStorage,

@ -34,7 +34,7 @@ struct ConfigExplorer {
return .none
}
}()
guard let string = urlString else { return .none}
guard let string = urlString else { return .none }
return URL(string: string)!
}

@ -112,12 +112,13 @@ class SettingsViewController: FormViewController {
<<< linkProvider(type: .twitter)
<<< linkProvider(type: .reddit)
<<< linkProvider(type: .facebook)
<<< AppFormAppearance.alphaWalletSettingsButton { row in
row.cellStyle = .value1
row.presentationMode = .show(controllerProvider: ControllerProvider<UIViewController>.callback {
<<< AppFormAppearance.alphaWalletSettingsButton { row in
row.cellStyle = .value1
row.presentationMode = .show(controllerProvider: ControllerProvider<UIViewController>.callback {
let vc = HelpViewController()
return vc }, onDismiss: { _ in
})
return vc
}, onDismiss: { _ in
})
}.cellSetup { cell, _ in
cell.imageView?.tintColor = Colors.appBackground
}.cellUpdate { cell, _ in

@ -16,7 +16,7 @@ struct LocalesViewModel {
self.selectedLocale = selectedLocale
}
func locale(for indexPath: IndexPath) -> AppLocale {
func locale(for indexPath: IndexPath) -> AppLocale {
return locales[indexPath.row]
}

@ -16,7 +16,7 @@ struct ServersViewModel {
self.selectedServer = selectedServer
}
func server(for indexPath: IndexPath) -> RPCServer {
func server(for indexPath: IndexPath) -> RPCServer {
return servers[indexPath.row]
}

@ -45,7 +45,7 @@ class GetStormBirdBalanceCoordinator {
if err is JSErrorDomain { // TODO:
switch err {
case JSErrorDomain.invalidReturnType(let value):
let values:[String] = (self?.adapt(value))!
let values: [String] = (self?.adapt(value))!
NSLog("result error \(values)")
completion(.success(values))
default:

@ -70,7 +70,7 @@ class TicketAdaptor {
///Group by the properties used in the hash. We abuse a dictionary to help with grouping
private func groupTicketsByFields(tickets: [Ticket]) -> Dictionary<String, [Ticket]>.Values {
var dictionary = [String:[Ticket]]()
var dictionary = [String: [Ticket]]()
for each in tickets {
let hash = "\(each.city),\(each.venue),\(each.date),\(each.countryA),\(each.countryB),\(each.match),\(each.category)"
var group = dictionary[hash] ?? []

@ -342,7 +342,7 @@ class TokensDataStore {
if let token = config.createDefaultTicketToken() {
let contract = token.contract.eip55String
let localizedName = token.name
if let storedTicketToken = enabledObject.first(where: { $0.contract == contract}) {
if let storedTicketToken = enabledObject.first(where: { $0.contract == contract }) {
updateTicketTokenName(token: storedTicketToken, to: localizedName)
}
}

@ -30,10 +30,9 @@ class TokensViewController: UIViewController {
let refreshControl = UIRefreshControl()
weak var delegate: TokensViewControllerDelegate?
init(
session: WalletSession,
account: Wallet,
dataStore: TokensDataStore
init(session: WalletSession,
account: Wallet,
dataStore: TokensDataStore
) {
self.session = session
self.account = account

@ -77,9 +77,9 @@ struct EthTokenViewCellViewModel {
var valuePercentageChangeColor: UIColor {
switch EthCurrencyHelper(ticker: ticker).change24h {
case .appreciate(_):
case .appreciate:
return Colors.appHighlightGreen
case .depreciate(_):
case .depreciate:
return Colors.appRed
case .none:
return Colors.appGrayLabelColor

@ -40,17 +40,15 @@ struct TicketsViewModel {
return Fonts.regular(size: 20)!
}
func toggleDetailsVisible(for indexPath: IndexPath) -> [IndexPath] {
func toggleDetailsVisible(for indexPath: IndexPath) -> [IndexPath] {
let ticketHolder = item(for: indexPath)
var changed = [indexPath]
if ticketHolder.areDetailsVisible {
ticketHolder.areDetailsVisible = false
} else {
for (i, each) in ticketHolders!.enumerated() {
if each.areDetailsVisible {
each.areDetailsVisible = false
changed.append(.init(row: i, section: indexPath.section))
}
for (i, each) in ticketHolders!.enumerated() where each.areDetailsVisible {
each.areDetailsVisible = false
changed.append(.init(row: i, section: indexPath.section))
}
ticketHolder.areDetailsVisible = true
}

@ -14,15 +14,13 @@ class TokensViewModel {
var tickers: [String: CoinTicker]?
var filter: WalletFilter = .all
var filteredTokens: [TokenObject] {
get {
switch filter {
case .all:
return tokens
case .currencyOnly:
return tokens.filter { !$0.isStormBird }
case .assetsOnly:
return tokens.filter { $0.isStormBird }
}
switch filter {
case .all:
return tokens
case .currencyOnly:
return tokens.filter { !$0.isStormBird }
case .assetsOnly:
return tokens.filter { $0.isStormBird }
}
}

@ -18,7 +18,7 @@ class BaseTicketTableViewCell: UITableViewCell {
rowView.leadingAnchor.constraint(equalTo: leadingAnchor),
rowView.trailingAnchor.constraint(equalTo: trailingAnchor),
rowView.topAnchor.constraint(equalTo: topAnchor),
rowView.bottomAnchor.constraint(equalTo:bottomAnchor),
rowView.bottomAnchor.constraint(equalTo: bottomAnchor),
])
}

@ -101,21 +101,21 @@ class TicketsCoordinator: NSObject, Coordinator {
}
private func showSaleConfirmationScreen(for ticketHolder: TicketHolder,
linkExpiryDate: Date,
ethCost: String,
in viewController: SetSellTicketsExpiryDateViewController) {
linkExpiryDate: Date,
ethCost: String,
in viewController: SetSellTicketsExpiryDateViewController) {
let vc = makeGenerateSellMagicLinkViewController(paymentFlow: viewController.paymentFlow, ticketHolder: ticketHolder, ethCost: ethCost, linkExpiryDate: linkExpiryDate)
viewController.navigationController?.present(vc, animated: true)
}
private func showTransferConfirmationScreen(for ticketHolder: TicketHolder,
linkExpiryDate: Date,
in viewController: SetTransferTicketsExpiryDateViewController) {
linkExpiryDate: Date,
in viewController: SetTransferTicketsExpiryDateViewController) {
let vc = makeGenerateTransferMagicLinkViewController(paymentFlow: viewController.paymentFlow, ticketHolder: ticketHolder, linkExpiryDate: linkExpiryDate)
viewController.navigationController?.present(vc, animated: true)
}
private func makeGenerateSellMagicLinkViewController(paymentFlow: PaymentFlow, ticketHolder: TicketHolder, ethCost: String, linkExpiryDate: Date) -> GenerateSellMagicLinkViewController{
private func makeGenerateSellMagicLinkViewController(paymentFlow: PaymentFlow, ticketHolder: TicketHolder, ethCost: String, linkExpiryDate: Date) -> GenerateSellMagicLinkViewController {
let vc = GenerateSellMagicLinkViewController(
paymentFlow: paymentFlow,
ticketHolder: ticketHolder,

@ -12,7 +12,6 @@ class TransactionsFooterView: UIView {
return sendButton
}()
override init(frame: CGRect) {
super.init(frame: frame)

@ -100,65 +100,65 @@ class TransactionConfigurator {
func load(completion: @escaping (Result<Void, AnyError>) -> Void) {
switch transaction.transferType {
case .ether:
guard requestEstimateGas else {
return completion(.success(()))
}
estimateGasLimit()
self.configuration = TransactionConfiguration(
gasPrice: calculatedGasPrice,
gasLimit: GasLimitConfiguration.default,
data: transaction.data ?? self.configuration.data
)
completion(.success(()))
case .token:
session.web3.request(request: ContractERC20Transfer(amount: transaction.value, address: transaction.to!.description)) { [unowned self] result in
switch result {
case .success(let res):
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: Constants.gasLimit,
data: data
)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
case .ether:
guard requestEstimateGas else {
return completion(.success(()))
}
estimateGasLimit()
self.configuration = TransactionConfiguration(
gasPrice: calculatedGasPrice,
gasLimit: GasLimitConfiguration.default,
data: transaction.data ?? self.configuration.data
)
completion(.success(()))
case .token:
session.web3.request(request: ContractERC20Transfer(amount: transaction.value, address: transaction.to!.description)) { [unowned self] result in
switch result {
case .success(let res):
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: Constants.gasLimit,
data: data
)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
//TODO clean up
case .stormBird:
session.web3.request(request: ContractStormBirdTransfer(address: transaction.to!.description, indices: (transaction.indices)!)) { [unowned self] result in
switch result {
case .success(let res):
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: Constants.gasLimit,
data: data
)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
}
//TODO clean up
case .stormBird:
session.web3.request(request: ContractStormBirdTransfer(address: transaction.to!.description, indices: (transaction.indices)!)) { [unowned self] result in
switch result {
case .success(let res):
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: Constants.gasLimit,
data: data
)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
//TODO put order claim tx here somehow, or maybe the same one above
case .stormBirdOrder:
session.web3.request(request: ClaimStormBirdOrder(expiry: transaction.expiry!, indices: transaction.indices!,
v: transaction.v!, r: transaction.r!, s: transaction.s!)) { [unowned self] result in
switch result {
case .success(let res):
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: Constants.gasLimit,
data: data
)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
}
//TODO put order claim tx here somehow, or maybe the same one above
case .stormBirdOrder:
session.web3.request(request: ClaimStormBirdOrder(expiry: transaction.expiry!, indices: transaction.indices!,
v: transaction.v!, r: transaction.r!, s: transaction.s!)) { [unowned self] result in
switch result {
case .success(let res):
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: Constants.gasLimit,
data: data
)
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
}
}
}

@ -174,7 +174,7 @@ extension TransferTicketsViaWalletAddressViewController: AddressTextFieldDelegat
//Do nothing
}
func shouldReturn(in textField: AddressTextField) -> Bool{
func shouldReturn(in textField: AddressTextField) -> Bool {
view.endEditing(true)
return true
}

@ -51,9 +51,9 @@ struct SendHeaderViewViewModel {
var valuePercentageChangeColor: UIColor {
switch EthCurrencyHelper(ticker: ticker).change24h {
case .appreciate(_):
case .appreciate:
return Colors.appHighlightGreen
case .depreciate(_):
case .depreciate:
return Colors.appRed
case .none:
return Colors.appGrayLabelColor

@ -41,19 +41,17 @@ struct TransferTicketsViewModel {
return Fonts.regular(size: 20)!
}
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
let ticketHolder = item(for: indexPath)
var changed = [indexPath]
if ticketHolder.areDetailsVisible {
ticketHolder.areDetailsVisible = false
ticketHolder.isSelected = false
} else {
for (i, each) in ticketHolders!.enumerated() {
if each.areDetailsVisible {
each.areDetailsVisible = false
each.isSelected = false
changed.append(.init(row: i, section: indexPath.section))
}
for (i, each) in ticketHolders!.enumerated() where each.areDetailsVisible {
each.areDetailsVisible = false
each.isSelected = false
changed.append(.init(row: i, section: indexPath.section))
}
ticketHolder.areDetailsVisible = true
ticketHolder.isSelected = true

Loading…
Cancel
Save