Skip to content

Commit

Permalink
Merge pull request #703 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.3.1
  • Loading branch information
llbartekll committed Feb 3, 2023
2 parents a342261 + 98769d8 commit f5bd5ff
Show file tree
Hide file tree
Showing 163 changed files with 3,009 additions and 1,285 deletions.
3 changes: 3 additions & 0 deletions .env.Showcase
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SCHEME = "Showcase"
APP_IDENTIFIER = "com.walletconnect.chat"
APPLE_ID = "1634760092"
3 changes: 3 additions & 0 deletions .env.WalletApp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SCHEME = "WalletApp"
APP_IDENTIFIER = "com.walletconnect.walletapp"
APPLE_ID = "1667351690"
39 changes: 5 additions & 34 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ runs:
- name: Run tests
if: inputs.type == 'unit-tests'
shell: bash
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme WalletConnect \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-derivedDataPath DerivedDataCache \
test"
run: make unit_tests

# Integration tests
- name: Run integration tests
Expand All @@ -34,46 +28,23 @@ runs:
env:
RELAY_ENDPOINT: ${{ inputs.relay-endpoint }}
PROJECT_ID: ${{ inputs.project-id }}
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme IntegrationTests \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-derivedDataPath DerivedDataCache \
RELAY_HOST='$RELAY_ENDPOINT' \
PROJECT_ID='$PROJECT_ID' \
test"
run: make integration_tests RELAY_HOST=$RELAY_ENDPOINT PROJECT_ID=$PROJECT_ID

# Wallet build
- name: Build Example Wallet
if: inputs.type == 'build-example-wallet'
shell: bash
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme Wallet \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-derivedDataPath DerivedDataCache"
run: make build_wallet

# DApp build
- name: Build Example Dapp
if: inputs.type == 'build-example-dapp'
shell: bash
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme DApp \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-derivedDataPath DerivedDataCache"
run: make build_dapp

# UI tests
- name: UI Tests
if: inputs.type == 'ui-tests'
shell: bash
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme UITests \
-derivedDataPath DerivedDataCache \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' test"
run: make ui_tests
continue-on-error: true
30 changes: 1 addition & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,9 @@ jobs:
- name: Resolve Dependencies
shell: bash
run: "
xcodebuild -resolvePackageDependencies -project Example/ExampleApp.xcodeproj -scheme DApp -clonedSourcePackagesDirPath SourcePackagesCache -derivedDataPath DerivedDataCache -destination 'platform=iOS Simulator,name=iPhone 13'; \
xcodebuild -resolvePackageDependencies -project Example/ExampleApp.xcodeproj -scheme WalletConnect -clonedSourcePackagesDirPath SourcePackagesCache -derivedDataPath DerivedDataCache -destination 'platform=iOS Simulator,name=iPhone 13'"
run: make resolve_packages

- uses: ./.github/actions/ci
with:
type: ${{ matrix.test-type }}
project-id: ${{ secrets.PROJECT_ID }}

test-ui:
if: github.ref == 'refs/heads/main'
runs-on: macos-latest
strategy:
matrix:
test-type: [ui-tests]

steps:
- uses: actions/checkout@v2

- name: Setup Xcode Version
uses: maxim-lobanov/setup-xcode@v1

- uses: actions/cache@v2
with:
path: |
.build
SourcePackagesCache
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- uses: ./.github/actions/ci
with:
type: ${{ matrix.test-type }}
16 changes: 11 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ Package.resolved
/*.xcodeproj

# Fastlane
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots/**/*.png
*/fastlane/test_output
*/fastlane/README.md
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
fastlane/README.md

# Configuration
Configuration.xcconfig

# Cache
SourcePackagesCache
DerivedDataCache

# Artifacts
*.ipa

This file was deleted.

8 changes: 6 additions & 2 deletions Example/DApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PROJECT_ID</key>
<string>$(PROJECT_ID)</string>
<key>CFBundleVersion</key>
<string>7</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>PROJECT_ID</key>
<string>$(PROJECT_ID)</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
34 changes: 34 additions & 0 deletions Example/DApp/Sign/Accounts/AccountsViewController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import UIKit
import WalletConnectSign
import WalletConnectPush
import Combine

struct AccountDetails {
let chain: String
Expand All @@ -12,7 +14,9 @@ final class AccountsViewController: UIViewController, UITableViewDataSource, UIT
let session: Session
var accountsDetails: [AccountDetails] = []
var onDisconnect: (() -> Void)?
var pushSubscription: PushSubscription?

private var publishers = [AnyCancellable]()
private let accountsView: AccountsView = {
AccountsView()
}()
Expand All @@ -34,12 +38,21 @@ final class AccountsViewController: UIViewController, UITableViewDataSource, UIT
super.viewDidLoad()
navigationItem.title = "Accounts"


navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Disconnect",
style: .plain,
target: self,
action: #selector(disconnect)
)

navigationItem.leftBarButtonItem = UIBarButtonItem(
title: "Push Test",
style: .plain,
target: self,
action: #selector(pushTest)
)

accountsView.tableView.dataSource = self
accountsView.tableView.delegate = self
session.namespaces.values.forEach { namespace in
Expand All @@ -49,6 +62,27 @@ final class AccountsViewController: UIViewController, UITableViewDataSource, UIT
}
}

func proposePushSubscription() {
let account = session.namespaces.values.first!.accounts.first!

Task(priority: .high){ try! await Push.dapp.request(account: account, topic: session.pairingTopic)}
Push.dapp.responsePublisher.sink { (id: RPCID, result: Result<PushSubscription, PushError>) in
switch result {
case .success(let subscription):
self.pushSubscription = subscription
case .failure(let error):
print(error)
}
}.store(in: &publishers)
}

@objc
private func pushTest() {
guard let pushTopic = pushSubscription?.topic else {return}
let message = PushMessage(title: "Push Message", body: "He,y this is a message from the swift client", icon: "", url: "")
Task(priority: .userInitiated) { try! await Push.dapp.notify(topic: pushTopic, message: message) }
}

@objc
private func disconnect() {
Task {
Expand Down
4 changes: 2 additions & 2 deletions Example/DApp/Sign/Connect/ConnectViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ConnectViewController: UIViewController, UITableViewDataSource, UITableVie
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
], events: [], extensions: nil
], events: []
),
"solana": ProposalNamespace(
chains: [
Expand All @@ -100,7 +100,7 @@ class ConnectViewController: UIViewController, UITableViewDataSource, UITableVie
methods: [
"solana_signMessage",
"solana_signTransaction"
], events: [], extensions: nil
], events: []
)
]
Task {
Expand Down
4 changes: 2 additions & 2 deletions Example/DApp/Sign/SelectChain/SelectChainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SelectChainViewController: UIViewController, UITableViewDataSource {
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
], events: [], extensions: nil
], events: []
),
"solana": ProposalNamespace(
chains: [
Expand All @@ -55,7 +55,7 @@ class SelectChainViewController: UIViewController, UITableViewDataSource {
methods: [
"solana_signMessage",
"solana_signTransaction"
], events: [], extensions: nil
], events: []
)
]
Task {
Expand Down
8 changes: 5 additions & 3 deletions Example/DApp/Sign/SignCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ final class SignCoordinator {
Sign.instance.sessionSettlePublisher
.receive(on: DispatchQueue.main)
.sink { [unowned self] session in
showAccountsScreen(session)
let vc = showAccountsScreen(session)
vc.proposePushSubscription()
}.store(in: &publishers)

if let session = Sign.instance.getSessions().first {
showAccountsScreen(session)
_ = showAccountsScreen(session)
} else {
showSelectChainScreen()
}
Expand All @@ -63,13 +64,14 @@ final class SignCoordinator {
navigationController.viewControllers = [controller]
}

private func showAccountsScreen(_ session: Session) {
private func showAccountsScreen(_ session: Session) -> AccountsViewController {
let controller = AccountsViewController(session: session)
controller.onDisconnect = { [unowned self] in
showSelectChainScreen()
}
navigationController.presentedViewController?.dismiss(animated: false)
navigationController.viewControllers = [controller]
return controller
}

private func presentResponse(for response: Response) {
Expand Down
Loading

0 comments on commit f5bd5ff

Please sign in to comment.