Skip to content

Commit

Permalink
#226 Rename Auth package to Sign (#232)
Browse files Browse the repository at this point in the history
* Renamed package and base directories

* Renamed imports to WalletConnectSign

* Renamed client and delegate

* Renamed Auth type to Sign

* Fixed a log typo

* Removed auth reference from build scheme

Co-authored-by: André Vants
  • Loading branch information
André Vants authored May 25, 2022
1 parent fd3fa06 commit 7b4d7af
Show file tree
Hide file tree
Showing 96 changed files with 257 additions and 112 deletions.
22 changes: 16 additions & 6 deletions .swiftpm/xcode/xcshareddata/xcschemes/WalletConnect.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectAuth"
BuildableName = "WalletConnectAuth"
BlueprintName = "WalletConnectAuth"
BlueprintIdentifier = "WalletConnectRelay"
BuildableName = "WalletConnectRelay"
BlueprintName = "WalletConnectRelay"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -112,9 +112,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectRelay"
BuildableName = "WalletConnectRelay"
BlueprintName = "WalletConnectRelay"
BlueprintIdentifier = "WalletConnectSign"
BuildableName = "WalletConnectSign"
BlueprintName = "WalletConnectSign"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -176,6 +176,16 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectSignTests"
BuildableName = "WalletConnectSignTests"
BlueprintName = "WalletConnectSignTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
4 changes: 2 additions & 2 deletions Example/DApp/ Accounts/AccountsViewController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import WalletConnectAuth
import WalletConnectSign

struct AccountDetails {
let chain: String
Expand Down Expand Up @@ -53,7 +53,7 @@ final class AccountsViewController: UIViewController, UITableViewDataSource, UIT
private func disconnect() {
Task {
do {
try await Auth.instance.disconnect(topic: session.topic, reason: Reason(code: 0, message: "disconnect"))
try await Sign.instance.disconnect(topic: session.topic, reason: Reason(code: 0, message: "disconnect"))
DispatchQueue.main.async { [weak self] in
self?.onDisconnect?()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Foundation
import UIKit
import WalletConnectAuth
import WalletConnectSign
import WalletConnectUtils

class AccountRequestViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
Expand Down Expand Up @@ -60,7 +60,7 @@ class AccountRequestViewController: UIViewController, UITableViewDelegate, UITab
let request = Request(topic: session.topic, method: method, params: requestParams, chainId: Blockchain(chainId)!)
Task {
do {
try await Auth.instance.request(params: request)
try await Sign.instance.request(params: request)
DispatchQueue.main.async { [weak self] in
self?.presentConfirmationAlert()
}
Expand Down
6 changes: 3 additions & 3 deletions Example/DApp/Connect/ConnectViewController.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

import Foundation
import UIKit
import WalletConnectAuth
import WalletConnectSign

class ConnectViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
let uriString: String
let activePairings: [Pairing] = Auth.instance.getSettledPairings()
let activePairings: [Pairing] = Sign.instance.getSettledPairings()
let segmentedControl = UISegmentedControl(items: ["Pairings", "New Pairing"])

init(uri: String) {
Expand Down Expand Up @@ -99,7 +99,7 @@ class ConnectViewController: UIViewController, UITableViewDataSource, UITableVie
let methods: Set<String> = ["eth_sendTransaction", "personal_sign", "eth_signTypedData"]
let namespaces: [String: ProposalNamespace] = ["eip155": ProposalNamespace(chains: blockchains, methods: methods, events: [], extensions: nil)]
Task {
_ = try await Auth.instance.connect(requiredNamespaces: namespaces, topic: pairingTopic)
_ = try await Sign.instance.connect(requiredNamespaces: namespaces, topic: pairingTopic)
connectWithExampleWallet()
}
}
Expand Down
4 changes: 2 additions & 2 deletions Example/DApp/ResponseViewController.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import Foundation
import WalletConnectAuth
import WalletConnectSign
import UIKit

class ResponseViewController: UIViewController {
Expand All @@ -24,7 +24,7 @@ class ResponseViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
let record = Auth.instance.getSessionRequestRecord(id: response.result.id)!
let record = Sign.instance.getSessionRequestRecord(id: response.result.id)!
switch response.result {
case .response(let response):
responseView.nameLabel.text = "Received Response\n\(record.request.method)"
Expand Down
10 changes: 5 additions & 5 deletions Example/DApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import UIKit
import WalletConnectAuth
import WalletConnectSign
import Combine

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
Expand All @@ -20,19 +20,19 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
description: "a description",
url: "wallet.connect",
icons: ["https://avatars.githubusercontent.com/u/37784886"])
Auth.configure(Auth.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a"))
Auth.instance.sessionDeletePublisher
Sign.configure(Sign.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a"))
Sign.instance.sessionDeletePublisher
.receive(on: DispatchQueue.main)
.sink { [unowned self] _ in
showSelectChainScreen()
}.store(in: &publishers)

Auth.instance.sessionResponsePublisher.sink { [unowned self] response in
Sign.instance.sessionResponsePublisher.sink { [unowned self] response in
presentResponse(for: response)
}.store(in: &publishers)


if let session = Auth.instance.getSessions().first {
if let session = Sign.instance.getSessions().first {
showAccountsScreen(session)
} else {
showSelectChainScreen()
Expand Down
6 changes: 3 additions & 3 deletions Example/DApp/SelectChain/SelectChainViewController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


import Foundation
import WalletConnectAuth
import WalletConnectSign
import UIKit
import Combine

Expand All @@ -23,7 +23,7 @@ class SelectChainViewController: UIViewController, UITableViewDataSource {
navigationItem.title = "Available Chains"
selectChainView.tableView.dataSource = self
selectChainView.connectButton.addTarget(self, action: #selector(connect), for: .touchUpInside)
Auth.instance.sessionSettlePublisher.sink {[unowned self] session in
Sign.instance.sessionSettlePublisher.sink {[unowned self] session in
onSessionSettled?(session)
}.store(in: &publishers)
}
Expand All @@ -39,7 +39,7 @@ class SelectChainViewController: UIViewController, UITableViewDataSource {
let blockchains: Set<Blockchain> = [Blockchain("eip155:1")!, Blockchain("eip155:137")!]
let namespaces: [String: ProposalNamespace] = ["eip155": ProposalNamespace(chains: blockchains, methods: methods, events: [], extensions: nil)]
Task {
let uri = try await Auth.instance.connect(requiredNamespaces: namespaces)
let uri = try await Sign.instance.connect(requiredNamespaces: namespaces)
showConnectScreen(uriString: uri!)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Example/ExampleApp/Request/RequestViewController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import Foundation
import UIKit
import WalletConnectAuth
import WalletConnectSign
import Web3

class RequestViewController: UIViewController {
Expand Down
6 changes: 3 additions & 3 deletions Example/ExampleApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import WalletConnectAuth
import WalletConnectSign

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

Expand All @@ -12,7 +12,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
description: "wallet description",
url: "example.wallet",
icons: ["https://avatars.githubusercontent.com/u/37784886"])
Auth.configure(Auth.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a"))
Sign.configure(Sign.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a"))

guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
Expand All @@ -30,7 +30,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
vc.onClientConnected = {
Task {
do {
try await Auth.instance.pair(uri: wcUri)
try await Sign.instance.pair(uri: wcUri)
} catch {
print(error)
}
Expand Down
2 changes: 1 addition & 1 deletion Example/ExampleApp/SessionDetails/SessionDetailView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftUI
import WalletConnectAuth
import WalletConnectSign

struct SessionDetailView: View {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import UIKit
import SwiftUI
import WalletConnectAuth
import WalletConnectSign
import WalletConnectUtils

final class SessionDetailViewController: UIHostingController<SessionDetailView> {

private let viewModel: SessionDetailViewModel

init(session: Session, client: Auth) {
init(session: Session, client: Sign) {
self.viewModel = SessionDetailViewModel(session: session, client: client)
super.init(rootView: SessionDetailView(viewModel: viewModel))

Expand All @@ -25,11 +25,11 @@ final class SessionDetailViewController: UIHostingController<SessionDetailView>
viewController.onSign = { [unowned self] in
let result = Signer.signEth(request: request)
let response = JSONRPCResponse<AnyCodable>(id: request.id, result: result)
Auth.instance.respond(topic: request.topic, response: .response(response))
Sign.instance.respond(topic: request.topic, response: .response(response))
reload()
}
viewController.onReject = { [unowned self] in
Auth.instance.respond(
Sign.instance.respond(
topic: request.topic,
response: .error(JSONRPCErrorResponse(
id: request.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation
import Combine
import WalletConnectAuth
import WalletConnectSign

@MainActor
final class SessionDetailViewModel: ObservableObject {
private let session: Session
private let client: Auth
private let client: Sign

enum Fields {
case accounts
Expand All @@ -16,7 +16,7 @@ final class SessionDetailViewModel: ObservableObject {

@Published var namespaces: [String: SessionNamespace]

init(session: Session, client: Auth) {
init(session: Session, client: Sign) {
self.session = session
self.client = client
self.namespaces = session.namespaces
Expand Down
Loading

0 comments on commit 7b4d7af

Please sign in to comment.