mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-05 20:16:25 +03:00
Rename ApprovalReason -> ApprovalSubject
This commit is contained in:
parent
85db3abe7e
commit
390a030253
@ -7,7 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0D059AD226C2796200EE3023 /* ApprovalReason.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D059AD126C2796200EE3023 /* ApprovalReason.swift */; };
|
||||
0D059AD226C2796200EE3023 /* ApprovalSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D059AD126C2796200EE3023 /* ApprovalSubject.swift */; };
|
||||
0DC850E726B73A5900809E82 /* AuthenticationReason.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DC850E626B73A5900809E82 /* AuthenticationReason.swift */; };
|
||||
28BDF30EBC80362870C988B6 /* Pods_Encrypted_Ink.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E2A642C960E4952955E6E82 /* Pods_Encrypted_Ink.framework */; };
|
||||
2C03D1D2269B407900EF10EA /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C03D1D1269B407900EF10EA /* NetworkMonitor.swift */; };
|
||||
@ -62,7 +62,7 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0D059AD126C2796200EE3023 /* ApprovalReason.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovalReason.swift; sourceTree = "<group>"; };
|
||||
0D059AD126C2796200EE3023 /* ApprovalSubject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovalSubject.swift; sourceTree = "<group>"; };
|
||||
0DC850E626B73A5900809E82 /* AuthenticationReason.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationReason.swift; sourceTree = "<group>"; };
|
||||
2C03D1D1269B407900EF10EA /* NetworkMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = "<group>"; };
|
||||
2C03D1D4269B428C00EF10EA /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = "<group>"; };
|
||||
@ -155,7 +155,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0DC850E626B73A5900809E82 /* AuthenticationReason.swift */,
|
||||
0D059AD126C2796200EE3023 /* ApprovalReason.swift */,
|
||||
0D059AD126C2796200EE3023 /* ApprovalSubject.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@ -557,7 +557,7 @@
|
||||
2CD0669226B5537B00728C20 /* WalletsManager.swift in Sources */,
|
||||
2CD0B3F726AC619900488D92 /* AddAccountOptionCellView.swift in Sources */,
|
||||
2C8A09E82675960D00993638 /* ErrorViewController.swift in Sources */,
|
||||
0D059AD226C2796200EE3023 /* ApprovalReason.swift in Sources */,
|
||||
0D059AD226C2796200EE3023 /* ApprovalSubject.swift in Sources */,
|
||||
2C1995422674C4B900A8E370 /* ImportViewController.swift in Sources */,
|
||||
2C8E47A326A322E8007B8354 /* RightClickTableView.swift in Sources */,
|
||||
2C901C472689E6D400D0926A /* ApproveTransactionViewController.swift in Sources */,
|
||||
|
@ -93,11 +93,11 @@ class Agent: NSObject {
|
||||
windowController.contentViewController = approveViewController
|
||||
}
|
||||
|
||||
func showApprove(reason: ApprovalReason, meta: String, peerMeta: WCPeerMeta?, completion: @escaping (Bool) -> Void) {
|
||||
func showApprove(subject: ApprovalSubject, meta: String, peerMeta: WCPeerMeta?, completion: @escaping (Bool) -> Void) {
|
||||
let windowController = Window.showNew()
|
||||
let approveViewController = ApproveViewController.with(reason: reason, meta: meta, peerMeta: peerMeta) { [weak self] result in
|
||||
let approveViewController = ApproveViewController.with(subject: subject, meta: meta, peerMeta: peerMeta) { [weak self] result in
|
||||
if result {
|
||||
self?.askAuthentication(on: windowController.window, onStart: false, reason: reason.asAuthenticationReason) { success in
|
||||
self?.askAuthentication(on: windowController.window, onStart: false, reason: subject.asAuthenticationReason) { success in
|
||||
completion(success)
|
||||
Window.closeAllAndActivateBrowser()
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright © 2021 Encrypted Ink. All rights reserved.
|
||||
|
||||
enum ApprovalReason {
|
||||
enum ApprovalSubject {
|
||||
case signMessage
|
||||
case signPersonalMessage
|
||||
case signTypedData
|
@ -21,11 +21,11 @@ class ApproveViewController: NSViewController {
|
||||
private var completion: ((Bool) -> Void)!
|
||||
private var peerMeta: WCPeerMeta?
|
||||
|
||||
static func with(reason: ApprovalReason, meta: String, peerMeta: WCPeerMeta?, completion: @escaping (Bool) -> Void) -> ApproveViewController {
|
||||
static func with(subject: ApprovalSubject, meta: String, peerMeta: WCPeerMeta?, completion: @escaping (Bool) -> Void) -> ApproveViewController {
|
||||
let new = instantiate(ApproveViewController.self)
|
||||
new.completion = completion
|
||||
new.meta = meta
|
||||
new.approveTitle = reason.title
|
||||
new.approveTitle = subject.title
|
||||
new.peerMeta = peerMeta
|
||||
return new
|
||||
}
|
||||
|
@ -143,24 +143,23 @@ class WalletConnect {
|
||||
|
||||
private func approveSign(id: Int64, payload: WCEthereumSignPayload, walletId: String, interactor: WCInteractor?) {
|
||||
var message: String?
|
||||
|
||||
let approvalReason: ApprovalReason
|
||||
let approvalSubject: ApprovalSubject
|
||||
switch payload {
|
||||
case let .sign(data: data, raw: _):
|
||||
message = String(data: data, encoding: .utf8) ?? data.hexString
|
||||
approvalReason = .signMessage
|
||||
approvalSubject = .signMessage
|
||||
case let .personalSign(data: data, raw: _):
|
||||
message = String(data: data, encoding: .utf8) ?? data.hexString
|
||||
approvalReason = .signPersonalMessage
|
||||
approvalSubject = .signPersonalMessage
|
||||
case let .signTypeData(id: _, data: _, raw: raw):
|
||||
approvalReason = .signTypedData
|
||||
approvalSubject = .signTypedData
|
||||
if raw.count >= 2 {
|
||||
message = raw[1]
|
||||
}
|
||||
}
|
||||
|
||||
let peer = getPeerOfInteractor(interactor)
|
||||
Agent.shared.showApprove(reason: approvalReason, meta: message ?? "", peerMeta: peer) { [weak self, weak interactor] approved in
|
||||
Agent.shared.showApprove(subject: approvalSubject, meta: message ?? "", peerMeta: peer) { [weak self, weak interactor] approved in
|
||||
if approved {
|
||||
self?.sign(id: id, payload: payload, walletId: walletId, interactor: interactor)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user