Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
gemdev111 committed Jun 3, 2024
2 parents 0b38b12 + 5ccd082 commit 3f66fa0
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 28 deletions.
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing

Thank you for your interest in contributing to Gem Wallet! If you have any questions, feel free to ask on [Discord](https://discord.gg/aWkq5sj7SY) or [Telegram](https://t.me/gemwallet_developers).

## Feature Requests and Bug Reports

Feature requests and bug reports should be posted as [Github Issues](issues/new).
In an issue, please describe what you did, what you expected, and what happened instead.

If you think that you have identified an issue with Gem Wallet that might compromise
its users' security, please do not open a public issue on GitHub. Instead,
we ask you to refer to [Security Policy](SECURITY.md).

## Sending Pull Requests

There are several ways to identify an area where you can contribute:

* You can reach out by sending a message in the developer community communication channel, either with a specific contribution in mind or in general by saying "I want to help!".
* Occasionally, some issues on Github may be labelled with `help wanted` or `good first issue` tags.

### Discuss First
Before sending a feature pull request, it's always better to open a issue first to discuss whether it is desired and the design of the feature.

### Branch Model
We use the [Fork and Pull](https://git-scm.com/book/en/v2/Git-Basics-Fork-and-Pull) model and [GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) to work on this repository.

Main branch is `master`. This is the branch that is used to work on the official release.

### Commit Convention
We use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages. Please read the guide through if you aren't familiar with it already.
4 changes: 4 additions & 0 deletions Gem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
D8A1F87F2B17F23500B15F54 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F87E2B17F23500B15F54 /* SnapshotHelper.swift */; };
D8A1F8822B17F88100B15F54 /* PaymentURLDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F8812B17F88100B15F54 /* PaymentURLDecoder.swift */; };
D8A1F8862B17F8FB00B15F54 /* PaymentURLDecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F8852B17F8FB00B15F54 /* PaymentURLDecoderTests.swift */; };
D8AF81252C0E615B002E5FCF /* ButtonListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AF81242C0E615B002E5FCF /* ButtonListItem.swift */; };
D8AF91F22B51BBCE002193E3 /* StakeDetailScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AF91F12B51BBCE002193E3 /* StakeDetailScene.swift */; };
D8AF91F42B51BBEE002193E3 /* StakeDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AF91F32B51BBEE002193E3 /* StakeDetailViewModel.swift */; };
D8B27CDD2B64402200E04154 /* GemstoneSwift in Frameworks */ = {isa = PBXBuildFile; productRef = D8B27CDC2B64402200E04154 /* GemstoneSwift */; };
Expand Down Expand Up @@ -455,6 +456,7 @@
D8A1F87E2B17F23500B15F54 /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapshotHelper.swift; sourceTree = "<group>"; };
D8A1F8812B17F88100B15F54 /* PaymentURLDecoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentURLDecoder.swift; sourceTree = "<group>"; };
D8A1F8852B17F8FB00B15F54 /* PaymentURLDecoderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentURLDecoderTests.swift; sourceTree = "<group>"; };
D8AF81242C0E615B002E5FCF /* ButtonListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonListItem.swift; sourceTree = "<group>"; };
D8AF91F12B51BBCE002193E3 /* StakeDetailScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StakeDetailScene.swift; sourceTree = "<group>"; };
D8AF91F32B51BBEE002193E3 /* StakeDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StakeDetailViewModel.swift; sourceTree = "<group>"; };
D8B977FD2AA95435009933B5 /* DeviceService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1205,6 +1207,7 @@
children = (
D8148C2A2BF54BA30066586A /* AddressListItem.swift */,
D8148C2C2BF54FB80066586A /* MemoListItem.swift */,
D8AF81242C0E615B002E5FCF /* ButtonListItem.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -1844,6 +1847,7 @@
C366790A2A0B7E5800F1D74D /* Environment.swift in Sources */,
D848B5932AE3024200814FB4 /* ConnectionsService.swift in Sources */,
C3B6F09429E7C32900C3B746 /* ConfirmTransferViewModel.swift in Sources */,
D8AF81252C0E615B002E5FCF /* ButtonListItem.swift in Sources */,
D8BAC95D2BD1A3E2001608BC /* AddAssetViewModel.swift in Sources */,
D801814A2B46209200F4D22B /* StakeValidatorsScene.swift in Sources */,
D80700522BBB6AEC00ED770B /* ImportWalletNavigationStack.swift in Sources */,
Expand Down
74 changes: 46 additions & 28 deletions Gem/Connections/Scenes/ConnectionsScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,28 @@ struct ConnectionsScene: View {
var body: some View {
List {
Section {
Button(Localized.Common.paste) {
guard let content = UIPasteboard.general.string else {
return
}
Task {
await connectURI(uri: content)
}
}

Button(Localized.Wallet.scan) {
isPresentingScanner = true
}
ButtonListItem(
title: Localized.Wallet.scanQrCode,
image: Image(systemName: SystemImage.qrCode),
action: onScan
)
ButtonListItem(
title: Localized.Common.paste,
image: Image(systemName: SystemImage.paste),
action: onPaste
)
}
ForEach(headers, id: \.self) { header in
Section(
header: Text(header.name)
) {
ForEach(groupedByWallet[header]!) { connection in
NavigationLink(value: connection) {
ConnectionView(model: WalletConnectionViewModel(connection: connection))
if headers.isEmpty {
StateEmptyView(message: Localized.WalletConnect.noActiveConnections)
} else {
ForEach(headers, id: \.self) { header in
Section(
header: Text(header.name)
) {
ForEach(groupedByWallet[header]!) { connection in
NavigationLink(value: connection) {
ConnectionView(model: WalletConnectionViewModel(connection: connection))
}
}
}
}
Expand All @@ -81,7 +83,7 @@ struct ConnectionsScene: View {
}
.sheet(isPresented: $isPresentingScanner) {
ScanQRCodeNavigationStack(isPresenting: $isPresentingScanner) {
handleScan(value: $0)
onHandleScan(value: $0)
}
}
.toolbar {
Expand All @@ -99,14 +101,6 @@ struct ConnectionsScene: View {
.navigationTitle(Localized.WalletConnect.title)
}

private func handleScan(value: String) {
NSLog("handle scan value: \(value)")

Task {
await connectURI(uri: value)
}
}

func connectURI(uri: String) async {
do {
try await model.addConnectionURI(uri: uri, wallet: keystore.currentWallet!)
Expand All @@ -116,3 +110,27 @@ struct ConnectionsScene: View {
}
}
}

// MARK: Actions

private extension ConnectionsScene {
private func onHandleScan(value: String) {
Task {
await connectURI(uri: value)
}
}

private func onScan() {
isPresentingScanner = true
}

private func onPaste() {
guard let content = UIPasteboard.general.string else {
return
}

Task {
await connectURI(uri: content)
}
}
}
20 changes: 20 additions & 0 deletions Gem/Core/Views/ButtonListItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c). Gem Wallet. All rights reserved.

import Foundation
import SwiftUI

struct ButtonListItem: View {

let title: String
let image: Image
let action: () -> Void

var body: some View {
Button(role: .none, action: action) {
HStack {
image
Text(title)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class TransferDataCallback<T: Identifiable>: Identifiable {

extension WalletCoordinator: WalletConnectorInteractable {
func sessionReject(error: Error) {
let ignoreErrors = [
"User cancelled" // User cancelled throw by WalletConnect if session proposal is rejected
]

guard !ignoreErrors.contains(error.localizedDescription) else {
return
}

self.isPresentingError = error.localizedDescription
}

Expand Down

0 comments on commit 3f66fa0

Please sign in to comment.