-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a384ef2
commit 6fe5114
Showing
7 changed files
with
41 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Sources/WalletConnectSign/Engine/Common/SessionExtendRequester.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Foundation | ||
|
||
final class SessionExtendRequester { | ||
private let sessionStore: WCSessionStorage | ||
private let networkingInteractor: NetworkInteracting | ||
|
||
init( | ||
sessionStore: WCSessionStorage, | ||
networkingInteractor: NetworkInteracting | ||
) { | ||
self.sessionStore = sessionStore | ||
self.networkingInteractor = networkingInteractor | ||
} | ||
|
||
func extend(topic: String, by ttl: Int64) async throws { | ||
guard var session = sessionStore.getSession(forTopic: topic) else { | ||
throw WalletConnectError.noSessionMatchingTopic(topic) | ||
} | ||
|
||
let protocolMethod = SessionExtendProtocolMethod() | ||
try session.updateExpiry(by: ttl) | ||
let newExpiry = Int64(session.expiryDate.timeIntervalSince1970) | ||
sessionStore.setSession(session) | ||
let request = RPCRequest(method: protocolMethod.method, params: SessionType.UpdateExpiryParams(expiry: newExpiry)) | ||
try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters