Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chat] Chat alpha #558

Merged
merged 12 commits into from
Oct 28, 2022
7 changes: 6 additions & 1 deletion .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ runs:
-scheme WalletConnect \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-derivedDataPath DerivedDataCache \
test"

# Integration tests
Expand All @@ -37,7 +38,8 @@ runs:
-project Example/ExampleApp.xcodeproj \
-scheme IntegrationTests \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-derivedDataPath DerivedDataCache \
RELAY_HOST='$RELAY_ENDPOINT' \
PROJECT_ID='$PROJECT_ID' \
test"
Expand All @@ -50,6 +52,7 @@ runs:
-project Example/ExampleApp.xcodeproj \
-scheme Wallet \
-clonedSourcePackagesDirPath SourcePackagesCache \
-derivedDataPath DerivedDataCache \
-sdk iphonesimulator"

# DApp build
Expand All @@ -60,6 +63,7 @@ runs:
-project Example/ExampleApp.xcodeproj \
-scheme DApp \
-clonedSourcePackagesDirPath SourcePackagesCache \
-derivedDataPath DerivedDataCache \
-sdk iphonesimulator"

# UI tests
Expand All @@ -69,6 +73,7 @@ runs:
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme UITests \
-derivedDataPath DerivedDataCache \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' test"
continue-on-error: true
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
path: |
.build
SourcePackagesCache
DerivedDataCache
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
Expand Down
4 changes: 0 additions & 4 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
A5629AE42876E6D200094373 /* ThreadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AE32876E6D200094373 /* ThreadViewModel.swift */; };
A5629AE828772A0100094373 /* InviteViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AE728772A0100094373 /* InviteViewModel.swift */; };
A5629AEA2877F2D600094373 /* WalletConnectChat in Frameworks */ = {isa = PBXBuildFile; productRef = A5629AE92877F2D600094373 /* WalletConnectChat */; };
A5629AED2877F6A600094373 /* ChatFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AEC2877F6A600094373 /* ChatFactory.swift */; };
A5629AF02877F73000094373 /* SocketFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AEF2877F73000094373 /* SocketFactory.swift */; };
A5629AF22877F75100094373 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = A5629AF12877F75100094373 /* Starscream */; };
A578FA322873036400AA7720 /* InputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A578FA312873036400AA7720 /* InputView.swift */; };
Expand Down Expand Up @@ -277,7 +276,6 @@
A5629ADD2876CC6E00094373 /* InviteListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteListView.swift; sourceTree = "<group>"; };
A5629AE32876E6D200094373 /* ThreadViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadViewModel.swift; sourceTree = "<group>"; };
A5629AE728772A0100094373 /* InviteViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteViewModel.swift; sourceTree = "<group>"; };
A5629AEC2877F6A600094373 /* ChatFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatFactory.swift; sourceTree = "<group>"; };
A5629AEF2877F73000094373 /* SocketFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketFactory.swift; sourceTree = "<group>"; };
A578FA312873036400AA7720 /* InputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputView.swift; sourceTree = "<group>"; };
A578FA34287304A300AA7720 /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -717,7 +715,6 @@
isa = PBXGroup;
children = (
A5629AA82876A23100094373 /* ChatService.swift */,
A5629AEC2877F6A600094373 /* ChatFactory.swift */,
A5C20225287EB099007E3188 /* AccountNameResolver.swift */,
A5C2022C287EC3F0007E3188 /* RegisterService.swift */,
);
Expand Down Expand Up @@ -1452,7 +1449,6 @@
A59EBEFA28B54A2A003EDAAF /* AuthRequestRouter.swift in Sources */,
A5629AF02877F73000094373 /* SocketFactory.swift in Sources */,
A55CAAB228B92AFF00844382 /* ScanRouter.swift in Sources */,
A5629AED2877F6A600094373 /* ChatFactory.swift in Sources */,
A5C20221287EA5B8007E3188 /* TextFieldView.swift in Sources */,
A5C2022B287EB89A007E3188 /* WelcomeInteractor.swift in Sources */,
A5C2020C287D9DEE007E3188 /* WelcomePresenter.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/Boilertalk/secp256k1.swift.git",
"state": {
"branch": null,
"revision": "45e458ec3be46cf0a6eb68bc947f797852dc65d8",
"version": "0.1.6"
"revision": "cd187c632fb812fd93711a9f7e644adb7e5f97f0",
"version": "0.1.7"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Example/IntegrationTests/Chat/ChatTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import XCTest
@testable import Chat
@testable import WalletConnectChat
import WalletConnectUtils
@testable import WalletConnectKMS
import WalletConnectRelay
Expand Down
2 changes: 1 addition & 1 deletion Example/IntegrationTests/Chat/RegistryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import XCTest
import WalletConnectNetworking
import WalletConnectKMS
import WalletConnectUtils
@testable import Chat
@testable import WalletConnectChat

final class RegistryTests: XCTestCase {

Expand Down
2 changes: 1 addition & 1 deletion Example/IntegrationTests/Stubs/InputConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct InputConfig {
}

static var defaultTimeout: TimeInterval {
return 30
return 45
}

private static func config(for key: String) -> String? {
Expand Down
4 changes: 2 additions & 2 deletions Example/Showcase/Classes/ApplicationLayer/Application.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Foundation
import Chat
import WalletConnectChat

final class Application {

lazy var chatService: ChatService = {
return ChatService(client: ChatFactory.create())
return ChatService(client: Chat.instance)
}()

lazy var accountStorage: AccountStorage = {
Expand Down
22 changes: 0 additions & 22 deletions Example/Showcase/Classes/DomainLayer/Chat/ChatFactory.swift

This file was deleted.

10 changes: 5 additions & 5 deletions Example/Showcase/Classes/DomainLayer/Chat/ChatService.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import Combine
import Chat
import WalletConnectChat
import WalletConnectRelay

typealias Stream<T> = AsyncPublisher<AnyPublisher<T, Never>>
Expand All @@ -21,23 +21,23 @@ final class ChatService {
return client.messagePublisher.values
}

var threadPublisher: Stream<Chat.Thread> {
var threadPublisher: Stream<WalletConnectChat.Thread> {
return client.newThreadPublisher.values
}

var invitePublisher: Stream<Invite> {
return client.invitePublisher.values
}

func getMessages(thread: Chat.Thread) async -> [Chat.Message] {
func getMessages(thread: WalletConnectChat.Thread) async -> [WalletConnectChat.Message] {
await client.getMessages(topic: thread.topic)
}

func getThreads() async -> [Chat.Thread] {
func getThreads() async -> [WalletConnectChat.Thread] {
await client.getThreads()
}

func getInvites(account: Account) async -> [Chat.Invite] {
func getInvites(account: Account) async -> [WalletConnectChat.Invite] {
client.getInvites(account: account)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import Chat
import WalletConnectChat

final class ChatInteractor {

Expand All @@ -9,7 +9,7 @@ final class ChatInteractor {
self.chatService = chatService
}

func getMessages(thread: Chat.Thread) async -> [Message] {
func getMessages(thread: WalletConnectChat.Thread) async -> [Message] {
return await chatService.getMessages(thread: thread)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import SwiftUI
import Chat
import WalletConnectChat

final class ChatModule {

@discardableResult
static func create(thread: Chat.Thread, app: Application) -> UIViewController {
static func create(thread: WalletConnectChat.Thread, app: Application) -> UIViewController {
let router = ChatRouter(app: app)
let interactor = ChatInteractor(chatService: app.chatService)
let presenter = ChatPresenter(thread: thread, interactor: interactor, router: router)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import UIKit
import Combine
import Chat
import WalletConnectChat

final class ChatPresenter: ObservableObject {

private let thread: Chat.Thread
private let thread: WalletConnectChat.Thread
private let interactor: ChatInteractor
private let router: ChatRouter
private var disposeBag = Set<AnyCancellable>()

@Published var messages: [MessageViewModel] = []
@Published var input: String = .empty

init(thread: Chat.Thread, interactor: ChatInteractor, router: ChatRouter) {
init(thread: WalletConnectChat.Thread, interactor: ChatInteractor, router: ChatRouter) {
self.thread = thread
self.interactor = interactor
self.router = router
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation
import Chat
import WalletConnectChat

struct MessageViewModel {
private let message: Message
private let thread: Chat.Thread
private let thread: WalletConnectChat.Thread

init(message: Message, thread: Chat.Thread) {
init(message: Message, thread: WalletConnectChat.Thread) {
self.message = message
self.thread = thread
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Chat
import WalletConnectChat

final class ChatListInteractor {

Expand All @@ -10,11 +10,11 @@ final class ChatListInteractor {
self.accountStorage = accountStorage
}

func getThreads() async -> [Chat.Thread] {
func getThreads() async -> [WalletConnectChat.Thread] {
return await chatService.getThreads()
}

func threadsSubscription() -> Stream<Chat.Thread> {
func threadsSubscription() -> Stream<WalletConnectChat.Thread> {
return chatService.threadPublisher
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import Chat
import WalletConnectChat

final class ChatListRouter {

Expand All @@ -21,7 +21,7 @@ final class ChatListRouter {
InviteListModule.create(app: app, account: account).push(from: viewController)
}

func presentChat(thread: Chat.Thread) {
func presentChat(thread: WalletConnectChat.Thread) {
ChatModule.create(thread: thread, app: app).push(from: viewController)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Foundation
import Chat
import WalletConnectChat

struct ThreadViewModel: Identifiable {
let thread: Chat.Thread
let thread: WalletConnectChat.Thread

var topic: String {
return thread.topic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Chat
import WalletConnectChat

final class InviteListInteractor {
private let chatService: ChatService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import Combine
import Chat
import WalletConnectChat

final class InviteListPresenter: ObservableObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import Chat
import WalletConnectChat

struct InviteViewModel {
let invite: Invite
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
targets: ["WalletConnectSign"]),
.library(
name: "WalletConnectChat",
targets: ["Chat"]),
targets: ["WalletConnectChat"]),
.library(
name: "WalletConnectAuth",
targets: ["Auth"]),
Expand All @@ -41,7 +41,7 @@ let package = Package(
dependencies: ["WalletConnectNetworking", "WalletConnectPairing"],
path: "Sources/WalletConnectSign"),
.target(
name: "Chat",
name: "WalletConnectChat",
dependencies: ["WalletConnectNetworking"],
path: "Sources/Chat"),
.target(
Expand Down Expand Up @@ -86,7 +86,7 @@ let package = Package(
dependencies: ["WalletConnectPairing", "TestingUtils"]),
.testTarget(
name: "ChatTests",
dependencies: ["Chat", "WalletConnectUtils", "TestingUtils"]),
dependencies: ["WalletConnectChat", "WalletConnectUtils", "TestingUtils"]),
.testTarget(
name: "AuthTests",
dependencies: ["Auth", "WalletConnectUtils", "TestingUtils"]),
Expand Down
12 changes: 12 additions & 0 deletions Sources/Chat/Chat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

/// Chat instatnce wrapper
public class Chat {

/// Chat client instance
public static var instance: ChatClient = {
return ChatClientFactory.create()
}()

private init() { }
}
Loading