Skip to content

Commit

Permalink
Merge branch 'feature/pre_beta' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed May 8, 2024
2 parents b62c17b + 386db59 commit ab6b44f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "08e2baf10ea197af930dc7a430da3745efef7e11"
"revision" : "757ccb82347d0ef5e42c36f6709ba731ca875f61"
}
},
{
"identity" : "kukai-crypto-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kukai-wallet/kukai-crypto-swift",
"state" : {
"revision" : "8afd803c7fa1fe6716b47f66f77b4fa9ceb94aea",
"version" : "1.0.20"
"revision" : "9c077851c8eca37bba69fe95f97db4b051879c53",
"version" : "1.0.21"
}
},
{
Expand Down
22 changes: 11 additions & 11 deletions Kukai Mobile/Modules/Account/Account.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -694,23 +694,23 @@
<rect key="frame" x="0.0" y="0.0" width="393" height="91"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dIV-vR-veM">
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dIV-vR-veM">
<rect key="frame" x="16" y="16" width="361" height="59"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Getting Started" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OaX-dE-p7M">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Getting Started" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OaX-dE-p7M">
<rect key="frame" x="16" y="20.333333333333336" width="159" height="26.666666666666664"/>
<accessibility key="accessibilityConfiguration" identifier="account-getting-started-header"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="22"/>
<color key="textColor" name="Txt2"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copy here about needing some XTZ to get started etc and how to get XTZ." textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WUd-ec-WyL">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Copy here about needing some XTZ to get started etc and how to get XTZ." textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WUd-ec-WyL">
<rect key="frame" x="16" y="59" width="329" height="0.0"/>
<fontDescription key="fontDescription" name="Figtree-Medium" family="Figtree" pointSize="14"/>
<color key="textColor" name="Txt6"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Social_TZ_Ovalcolor" translatesAutoresizingMaskIntoConstraints="NO" id="0XZ-Q7-XG3">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" image="Social_TZ_Ovalcolor" translatesAutoresizingMaskIntoConstraints="NO" id="0XZ-Q7-XG3">
<rect key="frame" x="307" y="16" width="38" height="35"/>
<constraints>
<constraint firstAttribute="height" constant="38" id="VwN-8M-Lxz"/>
Expand Down Expand Up @@ -747,7 +747,7 @@
<rect key="frame" x="0.0" y="0.0" width="393" height="63"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1Ao-zL-OIA" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1Ao-zL-OIA" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="32" y="8" width="329" height="47"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="NL4-wV-VUW"/>
Expand Down Expand Up @@ -779,30 +779,30 @@
<rect key="frame" x="0.0" y="0.0" width="393" height="212"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="p5E-1m-530">
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="p5E-1m-530">
<rect key="frame" x="16" y="16" width="361" height="180"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Receive Assets" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2ij-BE-VqB">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Receive Assets" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2ij-BE-VqB">
<rect key="frame" x="16" y="21.666666666666664" width="153.33333333333334" height="26.666666666666664"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="22"/>
<color key="textColor" name="Txt2"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="You can also copy your address by tapping the top left button and choose copy in the side menu" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Juv-Ge-4u3">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="You can also copy your address by tapping the top left button and choose copy in the side menu" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Juv-Ge-4u3">
<rect key="frame" x="16" y="62" width="329" height="38"/>
<fontDescription key="fontDescription" name="Figtree-Medium" family="Figtree" pointSize="14"/>
<color key="textColor" name="Txt6"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="btnQR_Outline_Dark" translatesAutoresizingMaskIntoConstraints="NO" id="BGW-ha-UIr">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" image="btnQR_Outline_Dark" translatesAutoresizingMaskIntoConstraints="NO" id="BGW-ha-UIr">
<rect key="frame" x="307" y="16" width="38" height="38"/>
<color key="tintColor" name="BGB4"/>
<constraints>
<constraint firstAttribute="height" constant="38" id="Ndq-gW-8Lh"/>
<constraint firstAttribute="width" constant="38" id="NlK-3x-MQg"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EKG-xY-HYO" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EKG-xY-HYO" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="16" y="116" width="156.66666666666666" height="48"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="18"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
Expand All @@ -811,7 +811,7 @@
<action selector="qrButtonTapped:" destination="I2q-rN-gX7" eventType="touchUpInside" id="plX-QU-ZkK"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rdt-d8-lSF" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rdt-d8-lSF" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="188.66666666666663" y="116" width="156.33333333333337" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="7e9-HA-La6"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit
import KukaiCoreSwift
import KukaiCryptoSwift
import WalletConnectSign
import Combine

Expand Down Expand Up @@ -66,8 +67,9 @@ class WalletConnectViewController: UIViewController, BottomSheetContainerDelegat
if let pairing = self.pairingToChangeAccount {

let newAddress = DependencyManager.shared.temporarySelectedWalletAddress ?? DependencyManager.shared.selectedWalletAddress ?? ""
guard let existingSession = Sign.instance.getSessions().first(where: { $0.pairingTopic == pairing.topic }),
let newNamespaces = WalletConnectService.updateNamespaces(forPairing: pairing, toAddress: newAddress) else {
guard let metadata = DependencyManager.shared.walletList.metadata(forAddress: newAddress),
let existingSession = Sign.instance.getSessions().first(where: { $0.pairingTopic == pairing.topic }),
let newNamespaces = WalletConnectService.updateNamespaces(forPairing: pairing, toMetadata: metadata) else {
return
}

Expand Down Expand Up @@ -170,7 +172,7 @@ extension WalletConnectViewController: UITableViewDelegate {
}

self?.pairingToChangeAccount = pairing
self?.performSegue(withIdentifier: "accounts", sender: firstAccount.address)
self?.performSegue(withIdentifier: "accounts", sender: PublicKey.publicKeyHash(fromBase58EncodedKey: firstAccount.address))
}

/*
Expand Down
3 changes: 2 additions & 1 deletion Kukai Mobile/Modules/Side Menu/WalletConnectViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit
import KukaiCoreSwift
import KukaiCryptoSwift
import WalletConnectSign

struct PairObj: Hashable {
Expand Down Expand Up @@ -82,7 +83,7 @@ class WalletConnectViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
} else {
let firstSession = sessions.first
let firstAccount = firstSession?.accounts.first
let address = firstAccount?.address
let address = PublicKey.publicKeyHash(fromBase58EncodedKey: firstAccount?.address ?? "")
let network = firstAccount?.blockchain.reference == "ghostnet" ? "Ghostnet" : "Mainnet"
let iconURL = URL(string: pair.peer?.icons.first ?? "")

Expand Down
10 changes: 5 additions & 5 deletions Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public class WalletConnectService {

// MARK: - Namespaces

public static func createNamespace(forProposal proposal: Session.Proposal, address: String, currentNetworkType: TezosNodeClientConfig.NetworkType) -> [String: SessionNamespace]? {
public static func createNamespace(forProposal proposal: Session.Proposal, metadata: WalletMetadata, currentNetworkType: TezosNodeClientConfig.NetworkType) -> [String: SessionNamespace]? {
var sessionNamespaces = [String: SessionNamespace]()

let supportedMethods = ["tezos_send", "tezos_sign", "tezos_getAccounts"]
Expand All @@ -524,7 +524,7 @@ public class WalletConnectService {


let network = currentNetworkType == .mainnet ? "mainnet" : "ghostnet"
if let wcAccount = Account("tezos:\(network):\(address)") {
if let wcAccount = Account("tezos:\(network):\(metadata.bas58EncodedPublicKey)") {
let accounts: Set<WalletConnectSign.Account> = Set([wcAccount])
//let accounts = [wcAccount]
let sessionNamespace = SessionNamespace(accounts: accounts, methods: approvedMethods ?? [], events: approvedEvents ?? [])
Expand All @@ -537,12 +537,12 @@ public class WalletConnectService {
}
}

public static func updateNamespaces(forPairing pairing: Pairing, toAddress: String/*, andNetwork newNetwork: TezosNodeClientConfig.NetworkType*/) -> [String: SessionNamespace]? {
public static func updateNamespaces(forPairing pairing: Pairing, toMetadata: WalletMetadata/*, andNetwork newNetwork: TezosNodeClientConfig.NetworkType*/) -> [String: SessionNamespace]? {
let session = Sign.instance.getSessions().first(where: { $0.pairingTopic == pairing.topic })
var tezosNamespace = session?.namespaces["tezos"]

let previousNetwork = tezosNamespace?.accounts.first?.blockchain.reference ?? (DependencyManager.shared.currentNetworkType == .mainnet ? "mainnet" : "ghostnet")
if let newAccount = Account("tezos:\(previousNetwork):\(toAddress)") {
if let newAccount = Account("tezos:\(previousNetwork):\(toMetadata.bas58EncodedPublicKey)") {
tezosNamespace?.accounts = Set([newAccount])
//tezosNamespace?.accounts = [newAccount]
}
Expand Down Expand Up @@ -668,7 +668,7 @@ public class WalletConnectService {

guard let proposal = TransactionService.shared.walletConnectOperationData.proposal,
let currentAccount = selectedAccountMeta,
let namespaces = WalletConnectService.createNamespace(forProposal: proposal, address: currentAccount.address, currentNetworkType: DependencyManager.shared.currentNetworkType) else {
let namespaces = WalletConnectService.createNamespace(forProposal: proposal, metadata: currentAccount, currentNetworkType: DependencyManager.shared.currentNetworkType) else {
Logger.app.error("WC approveCurrentProposal can't find current prposal or current state")
WalletConnectService.completeRequest()
completion?(false, nil)
Expand Down

0 comments on commit ab6b44f

Please sign in to comment.