From d8c134fd6b8200218debb95a1dcadb952f85c051 Mon Sep 17 00:00:00 2001 From: gemcoder21 <104884878+gemcoder21@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:41:52 +0100 Subject: [PATCH] Remove AssetImageFormatter and Chain .main factory property --- Gem/App-Configuration.swift | 8 -------- Gem/Assets/ViewModels/AssetIdViewModel.swift | 2 +- Gem/Stake/ViewModels/StakeDelegationViewModel.swift | 2 +- Gem/Stake/Views/ValidatorImageView.swift | 2 +- Packages/Primitives/Sources/AssetImageFormatter.swift | 6 +++++- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Gem/App-Configuration.swift b/Gem/App-Configuration.swift index 23cca9ea..1cb9965c 100644 --- a/Gem/App-Configuration.swift +++ b/Gem/App-Configuration.swift @@ -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) diff --git a/Gem/Assets/ViewModels/AssetIdViewModel.swift b/Gem/Assets/ViewModels/AssetIdViewModel.swift index 9e73dff4..e24c6456 100644 --- a/Gem/Assets/ViewModels/AssetIdViewModel.swift +++ b/Gem/Assets/ViewModels/AssetIdViewModel.swift @@ -11,7 +11,7 @@ struct AssetIdViewModel { init( assetId: AssetId, - assetFormatter: AssetImageFormatter = .main + assetFormatter: AssetImageFormatter = AssetImageFormatter() ) { self.assetId = assetId self.assetFormatter = assetFormatter diff --git a/Gem/Stake/ViewModels/StakeDelegationViewModel.swift b/Gem/Stake/ViewModels/StakeDelegationViewModel.swift index 0eb007b0..5380c580 100644 --- a/Gem/Stake/ViewModels/StakeDelegationViewModel.swift +++ b/Gem/Stake/ViewModels/StakeDelegationViewModel.swift @@ -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() diff --git a/Gem/Stake/Views/ValidatorImageView.swift b/Gem/Stake/Views/ValidatorImageView.swift index 6f651e97..22a6d95c 100644 --- a/Gem/Stake/Views/ValidatorImageView.swift +++ b/Gem/Stake/Views/ValidatorImageView.swift @@ -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( diff --git a/Packages/Primitives/Sources/AssetImageFormatter.swift b/Packages/Primitives/Sources/AssetImageFormatter.swift index c90852ae..4c80fdb4 100644 --- a/Packages/Primitives/Sources/AssetImageFormatter.swift +++ b/Packages/Primitives/Sources/AssetImageFormatter.swift @@ -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 }