-
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.
Merge pull request #677 from WalletConnect/develop
1.3.0
- Loading branch information
Showing
63 changed files
with
1,100 additions
and
287 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?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>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.usernotifications.service</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).NotificationService</string> | ||
</dict> | ||
</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,42 @@ | ||
// | ||
|
||
import UserNotifications | ||
import WalletConnectPush | ||
|
||
class NotificationService: UNNotificationServiceExtension { | ||
|
||
var contentHandler: ((UNNotificationContent) -> Void)? | ||
var bestAttemptContent: UNMutableNotificationContent? | ||
|
||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { | ||
self.contentHandler = contentHandler | ||
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) | ||
if let bestAttemptContent = bestAttemptContent { | ||
let topic = bestAttemptContent.userInfo["topic"] as! String | ||
let ciphertext = bestAttemptContent.userInfo["ciphertext"] as! String | ||
do { | ||
let service = PushDecryptionService() | ||
let pushMessage = try service.decryptMessage(topic: topic, ciphertext: ciphertext) | ||
bestAttemptContent.title = pushMessage.title | ||
bestAttemptContent.body = pushMessage.body | ||
contentHandler(bestAttemptContent) | ||
return | ||
} | ||
catch { | ||
print(error) | ||
} | ||
bestAttemptContent.title = "" | ||
bestAttemptContent.body = "content not set" | ||
contentHandler(bestAttemptContent) | ||
} | ||
} | ||
|
||
override func serviceExtensionTimeWillExpire() { | ||
// Called just before the extension will be terminated by the system. | ||
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. | ||
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { | ||
contentHandler(bestAttemptContent) | ||
} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
Example/PushDecryptionService/PushDecryptionService.entitlements
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,10 @@ | ||
<?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.security.application-groups</key> | ||
<array> | ||
<string>group.com.walletconnect.sdk</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,21 @@ | ||
|
||
import XCTest | ||
|
||
class PushNotificationTests: XCTestCase { | ||
let wallet = XCUIApplication(bundleIdentifier: "com.walletconnect.example") | ||
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") | ||
|
||
func testPushNotification() { | ||
wallet.launch() | ||
|
||
sleep(1) | ||
|
||
// Launch springboard | ||
springboard.activate() | ||
let text = "Is this working" | ||
|
||
let notification = springboard.otherElements["Notification"].descendants(matching: .any)["NotificationShortLookView"] | ||
XCTAssertTrue(notification.waitForExistence(timeout: 5)) | ||
notification.tap() | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
Example/WalletApp/Other/Assets.xcassets/welcome-dark.imageset/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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "welcome-dark.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.63 MB
Example/WalletApp/Other/Assets.xcassets/welcome-dark.imageset/welcome-dark.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Example/WalletApp/Other/Assets.xcassets/welcome-light.imageset/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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "welcome-light.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.47 MB
Example/WalletApp/Other/Assets.xcassets/welcome-light.imageset/welcome-light.pdf
Binary file not shown.
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
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalInteractor.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,32 @@ | ||
import Foundation | ||
|
||
import Web3Wallet | ||
|
||
final class SessionProposalInteractor { | ||
lazy var accounts = [ | ||
"eip155": ETHSigner.address, | ||
"solana": SOLSigner.address | ||
] | ||
|
||
func approve(proposal: Session.Proposal) async throws { | ||
var sessionNamespaces = [String: SessionNamespace]() | ||
proposal.requiredNamespaces.forEach { | ||
let caip2Namespace = $0.key | ||
let proposalNamespace = $0.value | ||
let accounts = Set(proposalNamespace.chains.compactMap { Account($0.absoluteString + ":\(self.accounts[$0.namespace]!)") }) | ||
|
||
let extensions: [SessionNamespace.Extension]? = proposalNamespace.extensions?.map { element in | ||
let accounts = Set(element.chains.compactMap { Account($0.absoluteString + ":\(self.accounts[$0.namespace]!)") }) | ||
return SessionNamespace.Extension(accounts: accounts, methods: element.methods, events: element.events) | ||
} | ||
let sessionNamespace = SessionNamespace(accounts: accounts, methods: proposalNamespace.methods, events: proposalNamespace.events, extensions: extensions) | ||
sessionNamespaces[caip2Namespace] = sessionNamespace | ||
} | ||
|
||
try await Web3Wallet.instance.approve(proposalId: proposal.id, namespaces: sessionNamespaces) | ||
} | ||
|
||
func reject(proposal: Session.Proposal) async throws { | ||
try await Web3Wallet.instance.reject(proposalId: proposal.id, reason: .userRejected) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Example/WalletApp/PresentationLayer/Wallet/SessionProposal/SessionProposalModule.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,22 @@ | ||
import SwiftUI | ||
|
||
import Web3Wallet | ||
|
||
final class SessionProposalModule { | ||
@discardableResult | ||
static func create(app: Application, proposal: Session.Proposal) -> UIViewController { | ||
let router = SessionProposalRouter(app: app) | ||
let interactor = SessionProposalInteractor() | ||
let presenter = SessionProposalPresenter( | ||
interactor: interactor, | ||
router: router, | ||
proposal: proposal | ||
) | ||
let view = SessionProposalView().environmentObject(presenter) | ||
let viewController = SceneViewController(viewModel: presenter, content: view) | ||
|
||
router.viewController = viewController | ||
|
||
return viewController | ||
} | ||
} |
Oops, something went wrong.