Skip to content

Commit

Permalink
fix already exist case and ws predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
svojsu committed Aug 1, 2024
1 parent bc16058 commit 4a356f2
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ extension NSPredicate {
"[a-z0-9\\u00a1-\\uffff]" +
"[a-z0-9\\u00a1-\\uffff_-]{0,62}" +
")?" +
"[a-z0-9\\u00a1-\\uffff]\\." +
"[a-z0-9\\u00a1-\\uffff_-]\\." +
")+" +
// TLD identifier name, may end with dot
"(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@ struct CustomNetworkViewFactory {
operationQueue: operationQueue
)

let setupFinishStrategyFactory = CustomNetworkSetupFinishStrategyFactory(
chainRegistry: chainRegistry,
repository: repository,
operationQueue: operationQueue
)

let interactor = CustomNetworkAddInteractor(
networkToAdd: networkToAdd,
chainRegistry: chainRegistry,
customNetworkSetupFactory: customNetworkSetupFactory,
connectionFactory: connectionFactory,
repository: repository,
priceIdParser: CoingeckoUrlParser(),
setupFinishStrategyFactory: setupFinishStrategyFactory,
operationQueue: operationQueue
)

Expand Down Expand Up @@ -99,6 +106,12 @@ struct CustomNetworkViewFactory {
operationQueue: operationQueue
)

let setupFinishStrategyFactory = CustomNetworkSetupFinishStrategyFactory(
chainRegistry: chainRegistry,
repository: repository,
operationQueue: operationQueue
)

let interactor = CustomNetworkEditInteractor(
networkToEdit: network,
selectedNode: selectedNode,
Expand All @@ -107,6 +120,7 @@ struct CustomNetworkViewFactory {
connectionFactory: connectionFactory,
repository: repository,
priceIdParser: CoingeckoUrlParser(),
setupFinishStrategyFactory: setupFinishStrategyFactory,
operationQueue: operationQueue
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ final class CustomNetworkAddInteractor: CustomNetworkBaseInteractor {
connectionFactory: ConnectionFactoryProtocol,
repository: AnyDataProviderRepository<ChainModel>,
priceIdParser: PriceUrlParserProtocol,
setupFinishStrategyFactory: CustomNetworkSetupFinishStrategyFactory,
operationQueue: OperationQueue
) {
self.networkToAdd = networkToAdd
Expand All @@ -21,6 +22,7 @@ final class CustomNetworkAddInteractor: CustomNetworkBaseInteractor {
connectionFactory: connectionFactory,
repository: repository,
priceIdParser: priceIdParser,
setupFinishStrategyFactory: setupFinishStrategyFactory,
operationQueue: operationQueue
)
}
Expand All @@ -41,10 +43,7 @@ final class CustomNetworkAddInteractor: CustomNetworkBaseInteractor {

extension CustomNetworkAddInteractor: CustomNetworkAddInteractorInputProtocol {
func addNetwork(with request: CustomNetwork.AddRequest) {
setupFinishStrategy = CustomNetworkAddNewStrategy(
repository: repository,
operationQueue: operationQueue
)
setupFinishStrategy = setupFinishStrategyFactory.createAddNewStrategy()

let type: ChainType = if let networkToAdd {
networkToAdd.isEthereumBased ? .evm : .substrate
Expand All @@ -63,7 +62,7 @@ extension CustomNetworkAddInteractor: CustomNetworkAddInteractorInputProtocol {
}

func fetchNetworkProperties(for url: String) {
setupFinishStrategy = CustomNetworkProvideStrategy()
setupFinishStrategy = setupFinishStrategyFactory.createProvideStrategy()

let request = CustomNetwork.SetupRequest(
networkType: .substrate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CustomNetworkBaseInteractor: NetworkNodeCreatorTrait,
let priceIdParser: PriceUrlParserProtocol
let operationQueue: OperationQueue

let setupFinishStrategyFactory: CustomNetworkSetupFinishStrategyFactory

var currentConnectingNode: ChainNodeModel?
var currentConnection: ChainConnection?

Expand All @@ -26,13 +28,15 @@ class CustomNetworkBaseInteractor: NetworkNodeCreatorTrait,
connectionFactory: ConnectionFactoryProtocol,
repository: AnyDataProviderRepository<ChainModel>,
priceIdParser: PriceUrlParserProtocol,
setupFinishStrategyFactory: CustomNetworkSetupFinishStrategyFactory,
operationQueue: OperationQueue
) {
self.chainRegistry = chainRegistry
self.customNetworkSetupFactory = customNetworkSetupFactory
self.connectionFactory = connectionFactory
self.repository = repository
self.priceIdParser = priceIdParser
self.setupFinishStrategyFactory = setupFinishStrategyFactory
self.operationQueue = operationQueue
}

Expand Down Expand Up @@ -247,7 +251,7 @@ private extension CustomNetworkBaseInteractor {
case let .success(chain):
self?.setupFinishStrategy?.handleSetupFinished(
for: chain,
presenter: self?.presenter
output: self?.presenter
)
case let .failure(error):
self?.presenter?.didReceive(.init(from: error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class CustomNetworkEditInteractor: CustomNetworkBaseInteractor {
connectionFactory: ConnectionFactoryProtocol,
repository: AnyDataProviderRepository<ChainModel>,
priceIdParser: PriceUrlParserProtocol,
setupFinishStrategyFactory: CustomNetworkSetupFinishStrategyFactory,
operationQueue: OperationQueue
) {
self.networkToEdit = networkToEdit
Expand All @@ -24,6 +25,7 @@ final class CustomNetworkEditInteractor: CustomNetworkBaseInteractor {
connectionFactory: connectionFactory,
repository: repository,
priceIdParser: priceIdParser,
setupFinishStrategyFactory: setupFinishStrategyFactory,
operationQueue: operationQueue
)
}
Expand All @@ -40,11 +42,9 @@ final class CustomNetworkEditInteractor: CustomNetworkBaseInteractor {

extension CustomNetworkEditInteractor: CustomNetworkEditInteractorInputProtocol {
func editNetwork(with request: CustomNetwork.EditRequest) {
setupFinishStrategy = CustomNetworkEditStrategy(
setupFinishStrategy = setupFinishStrategyFactory.createEditStrategy(
networkToEdit: networkToEdit,
selectedNode: selectedNode,
repository: repository,
operationQueue: operationQueue
selectedNode: selectedNode
)

let setupRequest = CustomNetwork.SetupRequest(
Expand Down
Loading

0 comments on commit 4a356f2

Please sign in to comment.