-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from reown-com/monorepo
Monorepo
- Loading branch information
Showing
39 changed files
with
869 additions
and
226 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,35 @@ | ||
import Foundation | ||
import SwiftMessages | ||
import UIKit | ||
|
||
struct AlertPresenter { | ||
enum MessageType { | ||
case warning | ||
case error | ||
case info | ||
case success | ||
} | ||
|
||
static func present(message: String, type: AlertPresenter.MessageType) { | ||
DispatchQueue.main.async { | ||
let view = MessageView.viewFromNib(layout: .cardView) | ||
switch type { | ||
case .warning: | ||
view.configureTheme(.warning, iconStyle: .subtle) | ||
case .error: | ||
view.configureTheme(.error, iconStyle: .subtle) | ||
case .info: | ||
view.configureTheme(.info, iconStyle: .subtle) | ||
case .success: | ||
view.configureTheme(.success, iconStyle: .subtle) | ||
} | ||
view.button?.isHidden = true | ||
view.layoutMarginAdditions = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) | ||
view.configureContent(title: "", body: message) | ||
var config = SwiftMessages.Config() | ||
config.presentationStyle = .top | ||
config.duration = .seconds(seconds: 1.5) | ||
SwiftMessages.show(config: config, view: view) | ||
} | ||
} | ||
} |
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.developer.associated-domains</key> | ||
<array> | ||
<string>applinks:lab.web3modal.com</string> | ||
</array> | ||
<key>com.apple.security.application-groups</key> | ||
<array> | ||
<string>group.com.walletconnect.web3modal</string> | ||
</array> | ||
</dict> | ||
</plist> |
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,171 @@ | ||
import Combine | ||
//import Sentry | ||
import SwiftUI | ||
import UIKit | ||
import WalletConnectSign | ||
import ReownAppKit | ||
|
||
#if DEBUG | ||
import Atlantis | ||
#endif | ||
|
||
|
||
class SocketConnectionManager: ObservableObject { | ||
@Published var socketConnected: Bool = false | ||
} | ||
|
||
@main | ||
class AppKitLabApp: App { | ||
private var disposeBag = Set<AnyCancellable>() | ||
private var socketConnectionManager = SocketConnectionManager() | ||
|
||
|
||
@State var alertMessage: String = "" | ||
|
||
required init() { | ||
#if DEBUG | ||
Atlantis.start() | ||
#endif | ||
|
||
let projectId = InputConfig.projectId | ||
|
||
// We're tracking Crash Reports / Issues from the Demo App to keep improving the SDK | ||
// SentrySDK.start { options in | ||
// options.dsn = "https://[email protected]/4506394479099904" | ||
// options.debug = false | ||
// options.enableTracing = true | ||
// } | ||
// | ||
// SentrySDK.configureScope { scope in | ||
// scope.setContext(value: ["projectId": projectId], key: "Project") | ||
// } | ||
|
||
let metadata = AppMetadata( | ||
name: "Web3Modal Swift Dapp", | ||
description: "Web3Modal DApp sample", | ||
url: "www.web3modal.com", | ||
icons: ["https://avatars.githubusercontent.com/u/37784886"], | ||
redirect: try! .init(native: "w3mdapp://", universal: "https://lab.web3modal.com/web3modal_example", linkMode: true) | ||
) | ||
|
||
Networking.configure( | ||
groupIdentifier: "group.com.walletconnect.web3modal", | ||
projectId: projectId, | ||
socketFactory: DefaultSocketFactory() | ||
) | ||
|
||
AppKit.configure( | ||
projectId: projectId, | ||
metadata: metadata, | ||
crypto: DefaultCryptoProvider(), | ||
authRequestParams: nil, // use .stab() for testing SIWE | ||
customWallets: [ | ||
.init( | ||
id: "swift-sample", | ||
name: "Swift Sample Wallet", | ||
homepage: "https://walletconnect.com/", | ||
imageUrl: "https://avatars.githubusercontent.com/u/37784886?s=200&v=4", | ||
order: 1, | ||
mobileLink: "walletapp://", | ||
linkMode: "https://lab.web3modal.com/wallet" | ||
) | ||
] | ||
) { error in | ||
// SentrySDK.capture(error: error) | ||
|
||
print(error) | ||
} | ||
|
||
setup() | ||
|
||
} | ||
|
||
func setup() { | ||
AppKit.instance.socketConnectionStatusPublisher.receive(on: DispatchQueue.main).sink { [unowned self] status in | ||
print("Socket connection status: \(status)") | ||
self.socketConnectionManager.socketConnected = (status == .connected) | ||
|
||
}.store(in: &disposeBag) | ||
AppKit.instance.logger.setLogging(level: .debug) | ||
Sign.instance.setLogging(level: .debug) | ||
Networking.instance.setLogging(level: .debug) | ||
Relay.instance.setLogging(level: .debug) | ||
|
||
AppKit.instance.authResponsePublisher.sink { (id: RPCID, result: Result<(Session?, [Cacao]), AuthError>) in | ||
switch result { | ||
case .success((_, _)): | ||
AlertPresenter.present(message: "User authenticated", type: .success) | ||
case .failure(let error): | ||
AlertPresenter.present(message: "User authentication error: \(error)", type: .error) | ||
|
||
} | ||
}.store(in: &disposeBag) | ||
|
||
AppKit.instance.SIWEAuthenticationPublisher.sink { result in | ||
switch result { | ||
case .success((let message, let signature)): | ||
AlertPresenter.present(message: "User authenticated", type: .success) | ||
case .failure(let error): | ||
AlertPresenter.present(message: "User authentication error: \(error)", type: .error) | ||
} | ||
}.store(in: &disposeBag) | ||
} | ||
|
||
var body: some Scene { | ||
WindowGroup { [unowned self] in | ||
ContentView() | ||
.environmentObject(socketConnectionManager) | ||
.onOpenURL { url in | ||
AppKit.instance.handleDeeplink(url) | ||
} | ||
.alert( | ||
"Response", | ||
isPresented: .init( | ||
get: { !self.alertMessage.isEmpty }, | ||
set: { _ in self.alertMessage = "" } | ||
) | ||
) { | ||
Button("Dismiss", role: .cancel) {} | ||
} message: { | ||
Text(alertMessage) | ||
} | ||
.onReceive(AppKit.instance.sessionResponsePublisher, perform: { response in | ||
switch response.result { | ||
case let .response(value): | ||
self.alertMessage = "Session response: \(value.stringRepresentation)" | ||
case let .error(error): | ||
self.alertMessage = "Session error: \(error)" | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
|
||
extension AuthRequestParams { | ||
static func stub( | ||
domain: String = "lab.web3modal.com", | ||
chains: [String] = ["eip155:1", "eip155:137"], | ||
nonce: String = "32891756", | ||
uri: String = "https://lab.web3modal.com", | ||
nbf: String? = nil, | ||
exp: String? = nil, | ||
statement: String? = "I accept the ServiceOrg Terms of Service: https://lab.web3modal.com", | ||
requestId: String? = nil, | ||
resources: [String]? = nil, | ||
methods: [String]? = ["personal_sign", "eth_sendTransaction"] | ||
) -> AuthRequestParams { | ||
return try! AuthRequestParams( | ||
domain: domain, | ||
chains: chains, | ||
nonce: nonce, | ||
uri: uri, | ||
nbf: nbf, | ||
exp: exp, | ||
statement: statement, | ||
requestId: requestId, | ||
resources: resources, | ||
methods: methods | ||
) | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
Example/AppKitLab/Assets.xcassets/AccentColor.colorset/Contents.json
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 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/Contents.json
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,116 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "83.5x83.5" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+909 Bytes
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.67 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.67 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.25 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.22 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.21 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.21 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.29 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.67 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.14 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.14 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.21 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.21 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.12 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.92 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.19 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.93 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.1 KB
Example/AppKitLab/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.