Skip to content

Commit

Permalink
Remove AssetImageFormatter and Chain .main factory property
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 committed Jun 5, 2024
1 parent af279eb commit d8c134f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
8 changes: 0 additions & 8 deletions Gem/App-Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import BigInt
import WalletConnector
import GemstoneSwift

extension AssetImageFormatter {
static let main = AssetImageFormatter(endpoint: PublicConstants.url(.assets))
}

extension Chain {
static let main = Asset.main.chain
}

extension Asset {
static let main = Asset.bitcoin
static let ethereum = Asset(id: Chain.ethereum.assetId, name: "Ethereum", symbol: "ETH", decimals: 18, type: .native)
Expand Down
2 changes: 1 addition & 1 deletion Gem/Assets/ViewModels/AssetIdViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct AssetIdViewModel {

init(
assetId: AssetId,
assetFormatter: AssetImageFormatter = .main
assetFormatter: AssetImageFormatter = AssetImageFormatter()
) {
self.assetId = assetId
self.assetFormatter = assetFormatter
Expand Down
2 changes: 1 addition & 1 deletion Gem/Stake/ViewModels/StakeDelegationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct StakeDelegationViewModel {
let delegation: Delegation

private let formatter = ValueFormatter(style: .medium)
private let validatorImageFormatter = AssetImageFormatter.main
private let validatorImageFormatter = AssetImageFormatter()

private static let dateFormatterDefault: DateComponentsFormatter = {
let formatter = DateComponentsFormatter()
Expand Down
2 changes: 1 addition & 1 deletion Gem/Stake/Views/ValidatorImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Primitives
struct ValidatorImageView: View {

let validator: DelegationValidator
private let formatter = AssetImageFormatter.main
private let formatter = AssetImageFormatter()

var body: some View {
AsyncImageView(
Expand Down
6 changes: 5 additions & 1 deletion Packages/Primitives/Sources/AssetImageFormatter.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

import Foundation
import Gemstone

public struct AssetImageFormatter {

public static let defaultEndpoint = URL(string: Config().getPublicUrl(item: .assets))!

let endpoint: URL

public init(
endpoint: URL
endpoint: URL = Self.defaultEndpoint
) {
self.endpoint = endpoint
}
Expand Down

0 comments on commit d8c134f

Please sign in to comment.