Merge pull request #653 from alpha-wallet/fix-ether-token-mismatch

migrates realm correctly to prevent ether being marked as erc20
pull/656/head
James Sangalli 6 years ago committed by GitHub
commit aaba179f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      AlphaWallet/Core/Initializers/MigrationInitializer.swift
  2. 1
      AlphaWallet/Settings/Types/Constants.swift
  3. 2
      AlphaWallet/Tokens/Types/TokensDataStore.swift

@ -13,14 +13,14 @@ class MigrationInitializer: Initializer {
}()
init(
account: Wallet, chainID: Int
account: Wallet, chainID: Int
) {
self.account = account
self.chainID = chainID
}
func perform() {
config.schemaVersion = 47
config.schemaVersion = 48
config.migrationBlock = { migration, oldSchemaVersion in
switch oldSchemaVersion {
case 0...32:
@ -44,6 +44,15 @@ class MigrationInitializer: Initializer {
}
}
}
if oldSchemaVersion < 48 {
migration.enumerateObjects(ofType: TokenObject.className()) { oldObject, newObject in
guard let oldObject = oldObject else { return }
guard let newObject = newObject else { return }
if let contract = oldObject["contract"] as? String, contract == Constants.nullAddress {
newObject["rawType"] = TokenType.ether.rawValue
}
}
}
}
}
}

@ -35,6 +35,7 @@ public struct Constants {
public static let nullTicket = "0x0000000000000000000000000000000000000000000000000000000000000000"
public static let nullTicketBigUInt = BigUInt(0)
public static let burnAddressString = "0x000000000000000000000000000000000000dEaD"
public static let nullAddress = "0x0000000000000000000000000000000000000000"
// FIFA hardcoded FIFA token address
public static let ticketContractAddress = "0xA66A3F08068174e8F005112A8b2c7A507a822335"

@ -75,7 +75,7 @@ class TokensDataStore {
static func etherToken(for config: Config) -> TokenObject {
return TokenObject(
contract: "0x0000000000000000000000000000000000000000",
contract: Constants.nullAddress,
name: config.server.name,
symbol: config.server.symbol,
decimals: config.server.decimals,

Loading…
Cancel
Save