-
Notifications
You must be signed in to change notification settings - Fork 192
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
Showing
7 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
.swiftpm/xcode/xcshareddata/xcschemes/WalletConnectHistory.xcscheme
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,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1430" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "WalletConnectHistory" | ||
BuildableName = "WalletConnectHistory" | ||
BlueprintName = "WalletConnectHistory" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "WalletConnectHistory" | ||
BuildableName = "WalletConnectHistory" | ||
BlueprintName = "WalletConnectHistory" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Foundation | ||
|
||
enum HistoryAPI: HTTPService { | ||
case register(payload: RegisterPayload, jwt: String) | ||
|
||
var path: String { | ||
switch self { | ||
case .register: | ||
return "/register" | ||
} | ||
} | ||
|
||
var method: HTTPMethod { | ||
switch self { | ||
case .register: | ||
return .post | ||
} | ||
} | ||
|
||
var body: Data? { | ||
switch self { | ||
case .register(let payload, _): | ||
return try? JSONEncoder().encode(payload) | ||
} | ||
} | ||
|
||
var additionalHeaderFields: [String : String]? { | ||
switch self { | ||
case .register(_, let jwt): | ||
return ["Authorization": jwt] | ||
} | ||
} | ||
|
||
var queryParameters: [String : String]? { | ||
return nil | ||
} | ||
} |
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,9 @@ | ||
import Foundation | ||
|
||
public final class HistoryClient { | ||
|
||
|
||
public func registerTags(payload: RegisterPayload, historyUrl: String) async throws { | ||
|
||
} | ||
} |
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,4 @@ | ||
#if !CocoaPods | ||
@_exported import HTTPClient | ||
@_exported import WalletConnectRelay | ||
#endif |
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,25 @@ | ||
import Foundation | ||
|
||
final class HistoryNetworkService { | ||
|
||
private let clientIdStorage: ClientIdStorage | ||
|
||
init(clientIdStorage: ClientIdStorage) { | ||
self.clientIdStorage = clientIdStorage | ||
} | ||
|
||
func registerTags(payload: RegisterPayload, historyUrl: String) async throws { | ||
let service = HTTPNetworkClient(host: historyUrl) | ||
let api = HistoryAPI.register(payload: payload, jwt: try await getJwt()) | ||
try await service.request(service: api) | ||
} | ||
} | ||
|
||
private extension HistoryNetworkService { | ||
|
||
func getJwt() async throws -> String { | ||
let keyPair = try clientIdStorage.getOrCreateKeyPair() | ||
let payload = RelayAuthPayload(subject: getSubject(), audience: getAudience()) | ||
return try payload.signAndCreateWrapper(keyPair: keyPair).jwtString | ||
} | ||
} |
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,11 @@ | ||
import Foundation | ||
|
||
public struct RegisterPayload: Codable { | ||
public let tags: [String] | ||
public let relayUrl: String | ||
|
||
public init(tags: [String], relayUrl: String) { | ||
self.tags = tags | ||
self.relayUrl = relayUrl | ||
} | ||
} |