remove unused ticketdecode, change contract address

pull/173/head
James Sangalli 7 years ago
parent dbc485fe22
commit 82a52e626d
  1. 4
      Trust.xcodeproj/project.pbxproj
  2. 9
      Trust/Foundation/XMLHandler.swift
  3. 5
      Trust/Tokens/Helpers/TicketAdaptor.swift
  4. 92
      Trust/Tokens/Helpers/TicketDecode.swift
  5. 1
      Trust/Tokens/Types/TokensDataStore.swift

@ -252,7 +252,6 @@
29FF6D73201200D500A3011C /* FieldAppereance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D72201200D500A3011C /* FieldAppereance.swift */; };
442FC01053E2F1B59355A961 /* Arguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCC7DC5A13C023F7F2C26 /* Arguments.swift */; };
442FC0B59B23C0F3068621C0 /* NumberStepper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC575B6A4A50B0555E1B0 /* NumberStepper.swift */; };
442FC126C8A73F70F2782025 /* TicketDecode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC6911EEE85B669D7BDA1 /* TicketDecode.swift */; };
442FC249C2A39F85BDBD7987 /* GetDecimalsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC0F2E3BB3EE420BC2C16 /* GetDecimalsCoordinator.swift */; };
442FC258BAEFDE2D64E48D0D /* TicketsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCC8150042FE9179D574A /* TicketsCoordinator.swift */; };
442FC2CC21FFFC4FAB33A300 /* Ticket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC90F0768C43EF903465B /* Ticket.swift */; };
@ -758,7 +757,6 @@
442FC575B6A4A50B0555E1B0 /* NumberStepper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberStepper.swift; sourceTree = "<group>"; };
442FC57AD0C04FAB66FB834D /* RedeemEventListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedeemEventListener.swift; sourceTree = "<group>"; };
442FC630874D29159799EEB6 /* GetNameCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetNameCoordinator.swift; sourceTree = "<group>"; };
442FC6911EEE85B669D7BDA1 /* TicketDecode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TicketDecode.swift; sourceTree = "<group>"; };
442FC72F9D22CC36AC015274 /* GetERC20Decimals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC20Decimals.swift; sourceTree = "<group>"; };
442FC8B1D5B4317DE7D68325 /* GetStormBirdBalance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetStormBirdBalance.swift; sourceTree = "<group>"; };
442FC90F0768C43EF903465B /* Ticket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Ticket.swift; sourceTree = "<group>"; };
@ -2247,7 +2245,6 @@
isa = PBXGroup;
children = (
442FC20E6470B92A46479342 /* TicketAdaptor.swift */,
442FC6911EEE85B669D7BDA1 /* TicketDecode.swift */,
);
path = Helpers;
sourceTree = "<group>";
@ -3415,7 +3412,6 @@
442FC2CC21FFFC4FAB33A300 /* Ticket.swift in Sources */,
442FCAD7292D93C261B97D09 /* TicketHolder.swift in Sources */,
442FC81F38F80EEF54C69C5B /* TicketAdaptor.swift in Sources */,
442FC126C8A73F70F2782025 /* TicketDecode.swift in Sources */,
442FC258BAEFDE2D64E48D0D /* TicketsCoordinator.swift in Sources */,
76F1DB9E1443DCFC36228B08 /* ClaimOrderCoordinator.swift in Sources */,
76F1D76BF700FCC461B11CC0 /* ClaimStormBirdOrder.swift in Sources */,

@ -29,13 +29,12 @@ struct FIFAInfo {
*/
public class XMLHandler {
private let xml = try! XML.parse(AssetDefinitionXML.assetDefinition)
//TODO make this take bytes instead of hex string
//TODO configure language settings to be compatible with this
func getFifaInfoForToken(tokenId tokenBytes32: BigUInt, lang: Int) -> FIFAInfo {
var tokenId = MarketQueueHandler.bytesToHexa(tokenBytes32.serialize().bytes)
tokenId = tokenId.substring(to: 32) //slicing off the trailing zeros
let tokenId = MarketQueueHandler.bytesToHexa(tokenBytes32.serialize().bytes).substring(to: 32) //slicing off the trailing zeros
let locale = getLocale(attribute: tokenId.substring(to: 2), lang: lang)
let venue = getVenue(attribute: tokenId.substring(with: Range(uncheckedBounds: (2, 4))), lang: lang)
let time = Int(tokenId.substring(with: Range(uncheckedBounds: (5, 12))), radix: 16)!
@ -61,7 +60,7 @@ public class XMLHandler {
let localeNumber = Int(attribute, radix: 16)!
return xml["asset"]["fields"]["field"][0][0]["mapping"]["entity"][localeNumber]["name"][lang].text!
}
func getVenue(attribute: String, lang: Int) -> String {
let venueNumber = Int(attribute, radix: 16)!
return xml["asset"]["fields"]["field"][1][0]["mapping"]["entity"][venueNumber]["name"][lang].text!

@ -21,7 +21,7 @@ class TicketAdaptor {
if id == "0x0000000000000000000000000000000000000000000000000000000000000000" { // if balance is 0, then skip
continue
}
let ticket = getTicket(for: BigUInt(id.substring(from: 2), radix: 16)! , index: UInt16(index), in: token)
let ticket = getTicket(for: BigUInt(id.substring(from: 2), radix: 16)!, index: UInt16(index), in: token)
if let item = ticketHolders.filter({ $0.zone == ticket.zone && $0.date == ticket.date }).first {
item.tickets.append(ticket)
} else {
@ -34,14 +34,13 @@ class TicketAdaptor {
//TODO pass lang into here
private class func getTicket(for id: BigUInt, index: UInt16, in token: TokenObject) -> Ticket {
//todo make this take a bigUint
let fifaInfo = XMLHandler().getFifaInfoForToken(tokenId: id, lang: 1)
let zone = fifaInfo.locale
let name: String
if token.address.eip55String == Constants.fifaContractAddress {
name = token.title
} else {
name = "FIFA WC 2018" //TicketDecode.getName()
name = "FIFA WC 2018"
}
let venue = fifaInfo.locale
let seatId = fifaInfo.number

@ -1,92 +0,0 @@
import Foundation
import BigInt
struct TicketDecode {
public static func getName() -> String {
return "Arranging mortgage"
}
public static func getVenue(_ ticketId: Int) -> String {
let venueID = getVenueID(ticketId)
if venueID < venues.count {
return venues[venueID]
}
return "unknown"
}
public static func getDate(_ ticketId: Int) -> String {
let venueID = getVenueID(ticketId)
if venueID < dates.count {
return dates[venueID]
}
return "unknown"
}
public static func getZone(_ ticketId: Int) -> String {
return "Zone " + getZoneChar(ticketId)
}
public static func getZoneChar(_ ticketId: Int) -> String {
let zoneId = getZoneID(ticketId)
let zone = "A".nextLetterInAlphabet(for: zoneId)!
return zone
}
public static func getSeatIdInt(_ ticketId: Int) -> Int {
let modifier = getSeatModifier(ticketId)
let bitmask = (1 << 7) - 1
return (ticketId & (bitmask)) + modifier
}
public static func getPrice(_ ticketId: Int) -> BigInt {
let milliEth: BigInt = EtherNumberFormatter.full.number(from: "1", units: UnitConfiguration.finneyUnit)!
let dPrice: Double = 100.0 + (Double(getZoneID(ticketId))) / 2.0 + (Double(getVenueID(ticketId)) / 2.0)
let bPrice: BigInt = BigInt(dPrice) * milliEth
return bPrice
}
private static func getZoneID(_ ticketId: Int) -> Int {
let bitmask = (1 << 5) - 1
let zoneID = ((ticketId >> 7) & (bitmask)) //mask with bottom 5 bits
return zoneID
}
private static func getVenueID(_ ticketId: Int) -> Int {
return (ticketId >> 12)
}
private static func getSeatModifier(_ ticketId: Int) -> Int {
if getZoneID(ticketId) == 0 && getVenueID(ticketId) == 0 {
return 0
}
return 1
}
private static let venues: [String] = [
"Barclays Pasir Ris Park",
"RBS Forbidden City",
"Rabobank Old Changi Hospital",
"UOB Hacking",
"CBA Perth",
"Orange Academy",
"StGeorge 'Pitz'",
"NAB NEC",
"McQuarrie Bierkeller",
"HSBC Twin Towns",
]
private static let dates: [String] = [
"28 Feb 2018",
"05 Mar 2018",
"20 Mar 2018",
"31 Mar 2018",
"01 Apr 2018",
"20 Apr 2018",
"30 Apr 2018",
"05 May 2018",
"15 May 2018",
"30 May 2018",
]
}

@ -320,7 +320,6 @@ class TokensDataStore {
} else {
token.balance.append(TokenBalance(balance: "0"))
}
}
}
}

Loading…
Cancel
Save