Skip to content

Commit

Permalink
NonFungibleTokenCategory => CollectibleTokenCategory
Browse files Browse the repository at this point in the history
  • Loading branch information
vikmeup committed Aug 7, 2018
1 parent 86cabc6 commit cf0693f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Trust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
71A433702113860900985ADC /* ConfirmPaymentDetailsViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71A4336F2113860900985ADC /* ConfirmPaymentDetailsViewModelTests.swift */; };
7301BA9220A3117000E1AFE5 /* AutoLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7301BA9120A3117000E1AFE5 /* AutoLock.swift */; };
7301BA9620AB1E5600E1AFE5 /* CookiesStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7301BA9520AB1E5600E1AFE5 /* CookiesStore.swift */; };
7302405C204C65DF00B327DF /* NonFungibleTokenCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7302405B204C65DF00B327DF /* NonFungibleTokenCategory.swift */; };
7302405C204C65DF00B327DF /* CollectibleTokenCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7302405B204C65DF00B327DF /* CollectibleTokenCategory.swift */; };
731802A6210B756E007712BE /* WalletBalanceProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731802A5210B756E007712BE /* WalletBalanceProvider.swift */; };
73200B642040B9D700118A82 /* CryptoAddressValidatorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73200B632040B9D700118A82 /* CryptoAddressValidatorTest.swift */; };
73200B672044B22600118A82 /* TokensDataStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73200B662044B22600118A82 /* TokensDataStore.swift */; };
Expand Down Expand Up @@ -750,7 +750,7 @@
71A4336F2113860900985ADC /* ConfirmPaymentDetailsViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmPaymentDetailsViewModelTests.swift; sourceTree = "<group>"; };
7301BA9120A3117000E1AFE5 /* AutoLock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoLock.swift; sourceTree = "<group>"; };
7301BA9520AB1E5600E1AFE5 /* CookiesStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookiesStore.swift; sourceTree = "<group>"; };
7302405B204C65DF00B327DF /* NonFungibleTokenCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonFungibleTokenCategory.swift; sourceTree = "<group>"; };
7302405B204C65DF00B327DF /* CollectibleTokenCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectibleTokenCategory.swift; sourceTree = "<group>"; };
731802A5210B756E007712BE /* WalletBalanceProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletBalanceProvider.swift; sourceTree = "<group>"; };
73200B632040B9D700118A82 /* CryptoAddressValidatorTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoAddressValidatorTest.swift; sourceTree = "<group>"; };
73200B662044B22600118A82 /* TokensDataStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokensDataStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1487,7 +1487,7 @@
294DFBAD1FE6F254004CEB56 /* TokenObject.swift */,
29E9CFCE1FE7347200017744 /* ERC20Token.swift */,
73200B742048B67E00118A82 /* NonFungibleTokenObject.swift */,
7302405B204C65DF00B327DF /* NonFungibleTokenCategory.swift */,
7302405B204C65DF00B327DF /* CollectibleTokenCategory.swift */,
735AB03C2073BF2100EEEDDD /* TokenBalanceOperation.swift */,
);
path = Types;
Expand Down Expand Up @@ -3131,7 +3131,7 @@
A2B7ECAA2038122200828E7D /* ExportPrivateKeyCoordinator.swift in Sources */,
29E6E06E1FE897EE0079265A /* BrowserViewController.swift in Sources */,
2912CCF91F6A830700C6CBE3 /* AppDelegate.swift in Sources */,
7302405C204C65DF00B327DF /* NonFungibleTokenCategory.swift in Sources */,
7302405C204C65DF00B327DF /* CollectibleTokenCategory.swift in Sources */,
77EAD89220EAC0B800D14AA2 /* WalletStorage.swift in Sources */,
615F105D1FCBF55E008A45AF /* OnboardingCollectionViewController.swift in Sources */,
29A0E1851F706B8C00BAAAED /* String.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions Trust/Core/Network/TrustNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enum TrustNetworkProtocolError: LocalizedError {
}

protocol NetworkProtocol: TrustNetworkProtocol {
func collectibles() -> Promise<[NonFungibleTokenCategory]>
func collectibles() -> Promise<[CollectibleTokenCategory]>
func tickers(with tokenPrices: [TokenPrice]) -> Promise<[CoinTicker]>

func tokensList() -> Promise<[TokenObject]>
Expand Down Expand Up @@ -98,13 +98,13 @@ final class TrustNetwork: NetworkProtocol {
}
}

func collectibles() -> Promise<[NonFungibleTokenCategory]> {
func collectibles() -> Promise<[CollectibleTokenCategory]> {
return Promise { seal in
provider.request(.collectibles(dict)) { result in
switch result {
case .success(let response):
do {
let tokens = try response.map(ArrayResponse<NonFungibleTokenCategory>.self).docs
let tokens = try response.map(ArrayResponse<CollectibleTokenCategory>.self).docs
seal.fulfill(tokens)
} catch {
seal.reject(error)
Expand Down
6 changes: 3 additions & 3 deletions Trust/Tokens/Storage/TokensDataStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class TokensDataStore {
return realm.objects(TokenObject.self).filter(NSPredicate(format: "isDisabled == NO || rawType = \"coin\""))
.sorted(byKeyPath: "order", ascending: true)
}
var nonFungibleTokens: Results<NonFungibleTokenCategory> {
return realm.objects(NonFungibleTokenCategory.self).sorted(byKeyPath: "name", ascending: true)
var nonFungibleTokens: Results<CollectibleTokenCategory> {
return realm.objects(CollectibleTokenCategory.self).sorted(byKeyPath: "name", ascending: true)
}
var tickers: Results<CoinTicker> {
return realm.objects(CoinTicker.self).filter("tickersKey == %@", CoinTickerKeyMaker.makeCurrencyKey())
Expand Down Expand Up @@ -162,7 +162,7 @@ class TokensDataStore {
try? realm.write {
realm.delete(realm.objects(TokenObject.self))
realm.delete(realm.objects(NonFungibleTokenObject.self))
realm.delete(realm.objects(NonFungibleTokenCategory.self))
realm.delete(realm.objects(CollectibleTokenCategory.self))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import RealmSwift
import Realm
import Foundation

final class NonFungibleTokenCategory: Object, Decodable {
final class CollectibleTokenCategory: Object, Decodable {
@objc dynamic var name: String = ""
var items = List<NonFungibleTokenObject>()

convenience init(
name: String,
items: List<NonFungibleTokenObject>
) {
) {
self.init()
self.name = name
self.items = items
Expand All @@ -21,13 +21,13 @@ final class NonFungibleTokenCategory: Object, Decodable {
return "name"
}

private enum NonFungibleTokenCategoryCodingKeys: String, CodingKey {
private enum CollectibleTokenCategoryCodingKeys: String, CodingKey {
case name
case items
}

convenience required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: NonFungibleTokenCategoryCodingKeys.self)
let container = try decoder.container(keyedBy: CollectibleTokenCategoryCodingKeys.self)
let name = try container.decode(String.self, forKey: .name)
let itemsArray = try container.decode([NonFungibleTokenObject].self, forKey: .items)
let itemsList = List<NonFungibleTokenObject>()
Expand Down
6 changes: 3 additions & 3 deletions Trust/Tokens/ViewModels/NonFungibleTokenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class NonFungibleTokenViewModel {
let config: Config
let storage: TokensDataStore
var tokensNetwork: NetworkProtocol
let tokens: Results<NonFungibleTokenCategory>
let tokens: Results<CollectibleTokenCategory>
var tokensObserver: NotificationToken?
let address: Address

Expand Down Expand Up @@ -58,7 +58,7 @@ final class NonFungibleTokenViewModel {
self.tokens = storage.nonFungibleTokens
}

func fetchAssets() -> Promise<[NonFungibleTokenCategory]> {
func fetchAssets() -> Promise<[CollectibleTokenCategory]> {
return Promise { seal in
firstly {
tokensNetwork.collectibles()
Expand All @@ -71,7 +71,7 @@ final class NonFungibleTokenViewModel {
}
}

func setTokenObservation(with block: @escaping (RealmCollectionChange<Results<NonFungibleTokenCategory>>) -> Void) {
func setTokenObservation(with block: @escaping (RealmCollectionChange<Results<CollectibleTokenCategory>>) -> Void) {
tokensObserver = tokens.observe(block)
}

Expand Down
2 changes: 1 addition & 1 deletion TrustTests/Factories/FakeTokensNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum FakeTokensNetworkError: Error {
// completion([ticker])
// }
//
// func assets() -> Promise<[NonFungibleTokenCategory]> {
// func assets() -> Promise<[CollectibleTokenCategory]> {
// return Promise { seal in
// seal.reject(FakeTokensNetworkError.notImplmented)
// }
Expand Down

0 comments on commit cf0693f

Please sign in to comment.