Skip to content

Commit

Permalink
Merge pull request #1402 from WalletConnect/add-update-to-sample-wallet
Browse files Browse the repository at this point in the history
[Wallet] add chain changed
  • Loading branch information
llbartekll authored Aug 20, 2024
2 parents 2ef270b + 8cf911b commit a311e0a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
4 changes: 0 additions & 4 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@
C5DD5BE1294E09E3008FD3A4 /* Web3Wallet in Frameworks */ = {isa = PBXBuildFile; productRef = C5DD5BE0294E09E3008FD3A4 /* Web3Wallet */; };
C5F32A2C2954814200A6476E /* ConnectionDetailsModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A2B2954814200A6476E /* ConnectionDetailsModule.swift */; };
C5F32A2E2954814A00A6476E /* ConnectionDetailsRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A2D2954814A00A6476E /* ConnectionDetailsRouter.swift */; };
C5F32A302954816100A6476E /* ConnectionDetailsInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A2F2954816100A6476E /* ConnectionDetailsInteractor.swift */; };
C5F32A322954816C00A6476E /* ConnectionDetailsPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A312954816C00A6476E /* ConnectionDetailsPresenter.swift */; };
C5F32A342954817600A6476E /* ConnectionDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F32A332954817600A6476E /* ConnectionDetailsView.swift */; };
C5F32A362954FE3C00A6476E /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C5F32A352954FE3C00A6476E /* Colors.xcassets */; };
Expand Down Expand Up @@ -654,7 +653,6 @@
C5BE021A2AF79B960064FC88 /* SessionAccountModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionAccountModule.swift; sourceTree = "<group>"; };
C5F32A2B2954814200A6476E /* ConnectionDetailsModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsModule.swift; sourceTree = "<group>"; };
C5F32A2D2954814A00A6476E /* ConnectionDetailsRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsRouter.swift; sourceTree = "<group>"; };
C5F32A2F2954816100A6476E /* ConnectionDetailsInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsInteractor.swift; sourceTree = "<group>"; };
C5F32A312954816C00A6476E /* ConnectionDetailsPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsPresenter.swift; sourceTree = "<group>"; };
C5F32A332954817600A6476E /* ConnectionDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsView.swift; sourceTree = "<group>"; };
C5F32A352954FE3C00A6476E /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1805,7 +1803,6 @@
children = (
C5F32A2B2954814200A6476E /* ConnectionDetailsModule.swift */,
C5F32A2D2954814A00A6476E /* ConnectionDetailsRouter.swift */,
C5F32A2F2954816100A6476E /* ConnectionDetailsInteractor.swift */,
C5F32A312954816C00A6476E /* ConnectionDetailsPresenter.swift */,
C5F32A332954817600A6476E /* ConnectionDetailsView.swift */,
);
Expand Down Expand Up @@ -2533,7 +2530,6 @@
C55D34AF2965FB750004314A /* SessionProposalPresenter.swift in Sources */,
A5D610D22AB35B1100C20083 /* Listings.swift in Sources */,
A5B4F7C82ABB21190099AF7C /* CacheAsyncImage.swift in Sources */,
C5F32A302954816100A6476E /* ConnectionDetailsInteractor.swift in Sources */,
847BD1E8298A806800076C90 /* NotificationsView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ final class ConnectionDetailsModule {
@discardableResult
static func create(app: Application, session: Session) -> UIViewController {
let router = ConnectionDetailsRouter(app: app)
let interactor = ConnectionDetailsInteractor()
let presenter = ConnectionDetailsPresenter(
interactor: interactor,
router: router,
session: session
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ import Combine
import Web3Wallet

final class ConnectionDetailsPresenter: ObservableObject {
private let interactor: ConnectionDetailsInteractor
private let router: ConnectionDetailsRouter

let session: Session

private var disposeBag = Set<AnyCancellable>()

init(
interactor: ConnectionDetailsInteractor,
router: ConnectionDetailsRouter,
session: Session
) {
self.interactor = interactor
self.router = router
self.session = session
}
Expand All @@ -25,7 +22,7 @@ final class ConnectionDetailsPresenter: ObservableObject {
Task {
do {
ActivityIndicatorManager.shared.start()
try await interactor.disconnectSession(session: session)
try await Web3Wallet.instance.disconnect(topic: session.topic)
ActivityIndicatorManager.shared.stop()
DispatchQueue.main.async {
self.router.dismiss()
Expand All @@ -36,10 +33,26 @@ final class ConnectionDetailsPresenter: ObservableObject {
}
}
}



func accountReferences(namespace: String) -> [String] {
session.namespaces[namespace]?.accounts.map { "\($0.namespace):\(($0.reference))" } ?? []
}

func changeForMainnet() {
Task {
do {
ActivityIndicatorManager.shared.start()

try await Web3Wallet.instance.emit(topic: session.topic, event: Session.Event(name: "chainChanged", data: AnyCodable("1")), chainId: Blockchain("eip155:1")!)

ActivityIndicatorManager.shared.stop()
} catch {
ActivityIndicatorManager.shared.stop()
print(error)
}
}
}
}

// MARK: - Private functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ struct ConnectionDetailsView: View {
.padding(.horizontal, 20)
.padding(.top, 30)

Button {
presenter.changeForMainnet()
} label: {
Text("Change for Mainnet")
.foregroundColor(.grey50)
.font(.system(size: 20, weight: .semibold, design: .rounded))
}
.padding(.top, 20)

Button {
presenter.onDelete()
} label: {
Expand Down

0 comments on commit a311e0a

Please sign in to comment.