Merge pull request #438 from James-Sangalli/handle-multiple-erc875

Handle multiple erc875
pull/441/head
James Sangalli 6 years ago committed by GitHub
commit 6dd8600080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift
  2. 3
      AlphaWallet/Redeem/ViewControllers/RedeemTicketsQuantitySelectionViewController.swift
  3. 3
      AlphaWallet/Sell/ViewControllers/EnterSellTicketsPriceQuantityViewController.swift
  4. 3
      AlphaWallet/Tokens/Helpers/TicketAdaptor.swift
  5. 4
      AlphaWallet/Tokens/Types/TicketHolder.swift
  6. 5
      AlphaWallet/Transactions/Coordinators/TicketsCoordinator.swift
  7. 3
      AlphaWallet/Transfer/ViewControllers/TransferTicketsQuantitySelectionViewController.swift

@ -41,7 +41,8 @@ class UniversalLinkCoordinator: Coordinator {
"v": signature.substring(from: 128),
"r": "0x" + signature.substring(with: Range(uncheckedBounds: (0, 64))),
"s": "0x" + signature.substring(with: Range(uncheckedBounds: (64, 128))),
"networkId": Config().chainID.description
"networkId": Config().chainID.description,
"contractAddress": signedOrder.order.contractAddress
]
if isForTransfer {
@ -192,7 +193,10 @@ class UniversalLinkCoordinator: Coordinator {
completion: @escaping( _ response: TicketHolder?) -> Void
) {
let indices = signedOrder.order.indices
let parameters = createHTTPParametersForPaymentServer(signedOrder: signedOrder, isForTransfer: false)
let parameters = createHTTPParametersForPaymentServer(
signedOrder: signedOrder,
isForTransfer: false
)
Alamofire.request(Constants.getTicketInfoFromServer, method: .get, parameters: parameters).responseJSON { response in
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
@ -209,14 +213,20 @@ class UniversalLinkCoordinator: Coordinator {
}
//start at one to slice off address
let bytes32Tickets = Array(array[1...])
completion(self.sortTickets(bytes32Tickets, indices))
completion(
self.sortTickets(
bytes32Tickets,
indices,
signedOrder.order.contractAddress
)
)
} else {
completion(nil)
}
}
}
private func sortTickets(_ bytes32Tickets: [String], _ indices: [UInt16]) -> TicketHolder {
private func sortTickets(_ bytes32Tickets: [String], _ indices: [UInt16], _ contractAddress: String) -> TicketHolder {
var tickets = [Ticket]()
let xmlHandler = XMLHandler()
for i in 0...bytes32Tickets.count - 1 {
@ -228,7 +238,8 @@ class UniversalLinkCoordinator: Coordinator {
}
let ticketHolder = TicketHolder(
tickets: tickets,
status: .available
status: .available,
contractAddress: contractAddress
)
return ticketHolder
}

@ -159,7 +159,8 @@ class RedeemTicketsQuantitySelectionViewController: UIViewController {
let tickets = Array(ticketHolder.tickets[..<quantity])
return TicketHolder(
tickets: tickets,
status: ticketHolder.status
status: ticketHolder.status,
contractAddress: ticketHolder.contractAddress
)
}

@ -315,7 +315,8 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
let tickets = Array(ticketHolder.tickets[..<quantity])
return TicketHolder(
tickets: tickets,
status: ticketHolder.status
status: ticketHolder.status,
contractAddress: ticketHolder.contractAddress
)
}

@ -88,7 +88,8 @@ class TicketAdaptor {
private func getTicketHolder(for tickets: [Ticket]) -> TicketHolder {
return TicketHolder(
tickets: tickets,
status: .available
status: .available,
contractAddress: token.contract
)
}

@ -26,10 +26,12 @@ class TicketHolder {
var status: TicketHolderStatus
var isSelected = false
var areDetailsVisible = false
var contractAddress: String
init(tickets: [Ticket], status: TicketHolderStatus) {
init(tickets: [Ticket], status: TicketHolderStatus, contractAddress: String) {
self.tickets = tickets
self.status = status
self.contractAddress = contractAddress
}
var seatRange: String {

@ -276,7 +276,7 @@ class TicketsCoordinator: NSObject, Coordinator {
price: BigUInt("0")!,
indices: ticketHolder.indices,
expiry: BigUInt(Int(linkExpiryDate.timeIntervalSince1970)),
contractAddress: contractAddress,
contractAddress: ticketHolder.contractAddress,
start: BigUInt("0")!,
count: ticketHolder.indices.count
)
@ -292,7 +292,6 @@ class TicketsCoordinator: NSObject, Coordinator {
linkExpiryDate: Date,
ethCost: String,
paymentFlow: PaymentFlow) -> String {
let contractAddress = XMLHandler().getAddressFromXML(server: Config().server).eip55String
let ethCostRoundedTo4dp = String(format: "%.4f", Float(string: ethCost)!)
let cost = Decimal(string: ethCostRoundedTo4dp)! * Decimal(string: "1000000000000000000")!
let wei = BigUInt(cost.description)!
@ -300,7 +299,7 @@ class TicketsCoordinator: NSObject, Coordinator {
price: wei,
indices: ticketHolder.indices,
expiry: BigUInt(Int(linkExpiryDate.timeIntervalSince1970)),
contractAddress: contractAddress,
contractAddress: ticketHolder.contractAddress,
start: BigUInt("0")!,
count: ticketHolder.indices.count
)

@ -153,7 +153,8 @@ class TransferTicketsQuantitySelectionViewController: UIViewController {
let tickets = Array(ticketHolder.tickets[..<quantity])
return TicketHolder(
tickets: tickets,
status: ticketHolder.status
status: ticketHolder.status,
contractAddress: ticketHolder.contractAddress
)
}

Loading…
Cancel
Save