-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Auth] #415 auth instance
- Loading branch information
Showing
3 changed files
with
35 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
import WalletConnectRelay | ||
import Combine | ||
|
||
public class Auth { | ||
|
||
public static var instance: AuthClient = { | ||
guard let config = Auth.config else { | ||
fatalError("Error - you must call Auth.configure(_:) before accessing the shared instance.") | ||
} | ||
return AuthClientFactory.create( | ||
metadata: config.metadata, | ||
account: config.account, | ||
relayClient: Relay.instance) | ||
}() | ||
|
||
private static var config: Config? | ||
|
||
private init() { } | ||
|
||
static public func configure(metadata: AppMetadata, account: Account?) { | ||
Auth.config = Auth.Config( | ||
metadata: metadata, | ||
account: account) | ||
} | ||
} |
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,8 @@ | ||
import Foundation | ||
|
||
extension Auth { | ||
struct Config { | ||
let metadata: AppMetadata | ||
let account: Account? | ||
} | ||
} |
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