mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-07 14:10:28 +03:00
Use SelectAccountAction instead of AccountSelectionConfiguration
This commit is contained in:
parent
b63e3220ae
commit
a4f450b030
@ -1,12 +0,0 @@
|
|||||||
// Copyright © 2022 Tokenary. All rights reserved.
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import WalletCore
|
|
||||||
|
|
||||||
struct AccountSelectionConfiguration {
|
|
||||||
let peer: PeerMeta?
|
|
||||||
let coinType: CoinType?
|
|
||||||
var selectedAccounts: Set<SpecificWalletAccount>
|
|
||||||
let initiallyConnectedProviders: Set<Web3Provider>
|
|
||||||
let completion: ((EthereumChain?, [SpecificWalletAccount]?) -> Void)
|
|
||||||
}
|
|
@ -13,9 +13,10 @@ enum DappRequestAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct SelectAccountAction {
|
struct SelectAccountAction {
|
||||||
let provider: Web3Provider
|
let peer: PeerMeta?
|
||||||
|
let coinType: CoinType?
|
||||||
|
var selectedAccounts: Set<SpecificWalletAccount>
|
||||||
let initiallyConnectedProviders: Set<Web3Provider>
|
let initiallyConnectedProviders: Set<Web3Provider>
|
||||||
let preselectedAccounts: [SpecificWalletAccount]
|
|
||||||
let completion: (EthereumChain?, [SpecificWalletAccount]?) -> Void
|
let completion: (EthereumChain?, [SpecificWalletAccount]?) -> Void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,10 @@ struct DappRequestProcessor {
|
|||||||
return walletsManager.getSpecificAccount(coin: coin, address: configuration.address)
|
return walletsManager.getSpecificAccount(coin: coin, address: configuration.address)
|
||||||
}
|
}
|
||||||
let initiallyConnectedProviders = Set(body.providerConfigurations.map { $0.provider })
|
let initiallyConnectedProviders = Set(body.providerConfigurations.map { $0.provider })
|
||||||
let action = SelectAccountAction(provider: .unknown,
|
let action = SelectAccountAction(peer: request.peerMeta,
|
||||||
initiallyConnectedProviders: initiallyConnectedProviders,
|
coinType: nil,
|
||||||
preselectedAccounts: preselectedAccounts) { chain, specificWalletAccounts in
|
selectedAccounts: Set(preselectedAccounts),
|
||||||
|
initiallyConnectedProviders: initiallyConnectedProviders) { chain, specificWalletAccounts in
|
||||||
if let chain = chain, let specificWalletAccounts = specificWalletAccounts {
|
if let chain = chain, let specificWalletAccounts = specificWalletAccounts {
|
||||||
var specificProviderBodies = [ResponseToExtension.Body]()
|
var specificProviderBodies = [ResponseToExtension.Body]()
|
||||||
for specificWalletAccount in specificWalletAccounts {
|
for specificWalletAccount in specificWalletAccounts {
|
||||||
@ -86,8 +87,10 @@ struct DappRequestProcessor {
|
|||||||
|
|
||||||
switch body.method {
|
switch body.method {
|
||||||
case .signIn:
|
case .signIn:
|
||||||
let suggestedAccounts = walletsManager.suggestedAccounts(coin: .near)
|
let action = SelectAccountAction(peer: peerMeta,
|
||||||
let action = SelectAccountAction(provider: .near, initiallyConnectedProviders: Set(), preselectedAccounts: suggestedAccounts) { _, specificWalletAccounts in
|
coinType: .near,
|
||||||
|
selectedAccounts: Set(walletsManager.suggestedAccounts(coin: .near)),
|
||||||
|
initiallyConnectedProviders: Set()) { _, specificWalletAccounts in
|
||||||
if let specificWalletAccount = specificWalletAccounts?.first, specificWalletAccount.account.coin == .near {
|
if let specificWalletAccount = specificWalletAccounts?.first, specificWalletAccount.account.coin == .near {
|
||||||
let responseBody = ResponseToExtension.Near(account: specificWalletAccount.account.address)
|
let responseBody = ResponseToExtension.Near(account: specificWalletAccount.account.address)
|
||||||
respond(to: request, body: .near(responseBody), completion: completion)
|
respond(to: request, body: .near(responseBody), completion: completion)
|
||||||
@ -138,8 +141,10 @@ struct DappRequestProcessor {
|
|||||||
|
|
||||||
switch body.method {
|
switch body.method {
|
||||||
case .connect:
|
case .connect:
|
||||||
let suggestedAccounts = walletsManager.suggestedAccounts(coin: .solana)
|
let action = SelectAccountAction(peer: peerMeta,
|
||||||
let action = SelectAccountAction(provider: .solana, initiallyConnectedProviders: Set(), preselectedAccounts: suggestedAccounts) { _, specificWalletAccounts in
|
coinType: .solana,
|
||||||
|
selectedAccounts: Set(walletsManager.suggestedAccounts(coin: .solana)),
|
||||||
|
initiallyConnectedProviders: Set()) { _, specificWalletAccounts in
|
||||||
if let specificWalletAccount = specificWalletAccounts?.first, specificWalletAccount.account.coin == .solana {
|
if let specificWalletAccount = specificWalletAccounts?.first, specificWalletAccount.account.coin == .solana {
|
||||||
let responseBody = ResponseToExtension.Solana(publicKey: specificWalletAccount.account.address)
|
let responseBody = ResponseToExtension.Solana(publicKey: specificWalletAccount.account.address)
|
||||||
respond(to: request, body: .solana(responseBody), completion: completion)
|
respond(to: request, body: .solana(responseBody), completion: completion)
|
||||||
@ -219,8 +224,10 @@ struct DappRequestProcessor {
|
|||||||
|
|
||||||
switch ethereumRequest.method {
|
switch ethereumRequest.method {
|
||||||
case .requestAccounts:
|
case .requestAccounts:
|
||||||
let suggestedAccounts = walletsManager.suggestedAccounts(coin: .ethereum)
|
let action = SelectAccountAction(peer: peerMeta,
|
||||||
let action = SelectAccountAction(provider: .ethereum, initiallyConnectedProviders: Set(), preselectedAccounts: suggestedAccounts) { chain, specificWalletAccounts in
|
coinType: .ethereum,
|
||||||
|
selectedAccounts: Set(walletsManager.suggestedAccounts(coin: .ethereum)),
|
||||||
|
initiallyConnectedProviders: Set()) { chain, specificWalletAccounts in
|
||||||
if let chain = chain, let specificWalletAccount = specificWalletAccounts?.first, specificWalletAccount.account.coin == .ethereum {
|
if let chain = chain, let specificWalletAccount = specificWalletAccounts?.first, specificWalletAccount.account.coin == .ethereum {
|
||||||
let responseBody = ResponseToExtension.Ethereum(results: [specificWalletAccount.account.address], chainId: chain.hexStringId, rpcURL: chain.nodeURLString)
|
let responseBody = ResponseToExtension.Ethereum(results: [specificWalletAccount.account.address], chainId: chain.hexStringId, rpcURL: chain.nodeURLString)
|
||||||
respond(to: request, body: .ethereum(responseBody), completion: completion)
|
respond(to: request, body: .ethereum(responseBody), completion: completion)
|
||||||
|
@ -16,6 +16,7 @@ class Agent: NSObject {
|
|||||||
static let shared = Agent()
|
static let shared = Agent()
|
||||||
|
|
||||||
private let walletConnect = WalletConnect.shared
|
private let walletConnect = WalletConnect.shared
|
||||||
|
private let walletsManager = WalletsManager.shared
|
||||||
|
|
||||||
private override init() { super.init() }
|
private override init() { super.init() }
|
||||||
private var statusBarItem: NSStatusItem!
|
private var statusBarItem: NSStatusItem!
|
||||||
@ -79,14 +80,14 @@ class Agent: NSObject {
|
|||||||
let accountsList = instantiate(AccountsListViewController.self)
|
let accountsList = instantiate(AccountsListViewController.self)
|
||||||
|
|
||||||
if case let .wcSession(session) = request, let completion = onSelectedWallet(session: session) {
|
if case let .wcSession(session) = request, let completion = onSelectedWallet(session: session) {
|
||||||
accountsList.accountSelectionConfiguration = AccountSelectionConfiguration(peer: nil,
|
accountsList.selectAccountAction = SelectAccountAction(peer: nil,
|
||||||
coinType: .ethereum,
|
coinType: .ethereum,
|
||||||
selectedAccounts: Set(),
|
selectedAccounts: Set(walletsManager.suggestedAccounts(coin: .ethereum)),
|
||||||
initiallyConnectedProviders: Set(),
|
initiallyConnectedProviders: Set(),
|
||||||
completion: completion)
|
completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
let windowController = Window.showNew(closeOthers: accountsList.accountSelectionConfiguration == nil)
|
let windowController = Window.showNew(closeOthers: accountsList.selectAccountAction == nil)
|
||||||
windowController.contentViewController = accountsList
|
windowController.contentViewController = accountsList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,12 +323,7 @@ class Agent: NSObject {
|
|||||||
let windowController = Window.showNew(closeOthers: closeOtherWindows)
|
let windowController = Window.showNew(closeOthers: closeOtherWindows)
|
||||||
windowNumber = windowController.window?.windowNumber
|
windowNumber = windowController.window?.windowNumber
|
||||||
let accountsList = instantiate(AccountsListViewController.self)
|
let accountsList = instantiate(AccountsListViewController.self)
|
||||||
let coinType = CoinType.correspondingToWeb3Provider(accountAction.provider)
|
accountsList.selectAccountAction = accountAction
|
||||||
accountsList.accountSelectionConfiguration = AccountSelectionConfiguration(peer: safariRequest.peerMeta,
|
|
||||||
coinType: coinType,
|
|
||||||
selectedAccounts: Set(accountAction.preselectedAccounts),
|
|
||||||
initiallyConnectedProviders: accountAction.initiallyConnectedProviders,
|
|
||||||
completion: accountAction.completion)
|
|
||||||
windowController.contentViewController = accountsList
|
windowController.contentViewController = accountsList
|
||||||
case .approveMessage(let action):
|
case .approveMessage(let action):
|
||||||
let windowController = Window.showNew(closeOthers: false)
|
let windowController = Window.showNew(closeOthers: false)
|
||||||
|
@ -10,7 +10,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
private var cellModels = [CellModel]()
|
private var cellModels = [CellModel]()
|
||||||
private var chain = EthereumChain.ethereum
|
private var chain = EthereumChain.ethereum
|
||||||
private var didCallCompletion = false
|
private var didCallCompletion = false
|
||||||
var accountSelectionConfiguration: AccountSelectionConfiguration?
|
var selectAccountAction: SelectAccountAction?
|
||||||
var newWalletId: String?
|
var newWalletId: String?
|
||||||
var getBackToRect: CGRect?
|
var getBackToRect: CGRect?
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
updateCellModels()
|
updateCellModels()
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(walletsChanged), name: Notification.Name.walletsChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(walletsChanged), name: Notification.Name.walletsChanged, object: nil)
|
||||||
|
|
||||||
if let preselectedAccount = accountSelectionConfiguration?.selectedAccounts.first {
|
if let preselectedAccount = selectAccountAction?.selectedAccounts.first {
|
||||||
scrollTo(specificWalletAccount: preselectedAccount)
|
scrollTo(specificWalletAccount: preselectedAccount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,16 +105,16 @@ class AccountsListViewController: NSViewController {
|
|||||||
private func callCompletion(specificWalletAccounts: [SpecificWalletAccount]?) {
|
private func callCompletion(specificWalletAccounts: [SpecificWalletAccount]?) {
|
||||||
if !didCallCompletion {
|
if !didCallCompletion {
|
||||||
didCallCompletion = true
|
didCallCompletion = true
|
||||||
accountSelectionConfiguration?.completion(chain, specificWalletAccounts)
|
selectAccountAction?.completion(chain, specificWalletAccounts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateBottomButtons() {
|
private func updateBottomButtons() {
|
||||||
if let accountSelectionConfiguration = accountSelectionConfiguration {
|
if let selectAccountAction = selectAccountAction {
|
||||||
accountsListBottomConstraint.constant = 62
|
accountsListBottomConstraint.constant = 62
|
||||||
bottomButtonsStackView.isHidden = false
|
bottomButtonsStackView.isHidden = false
|
||||||
|
|
||||||
if !accountSelectionConfiguration.initiallyConnectedProviders.isEmpty {
|
if !selectAccountAction.initiallyConnectedProviders.isEmpty {
|
||||||
primaryButton.title = Strings.ok
|
primaryButton.title = Strings.ok
|
||||||
secondaryButton.title = Strings.disconnect
|
secondaryButton.title = Strings.disconnect
|
||||||
secondaryButton.keyEquivalent = ""
|
secondaryButton.keyEquivalent = ""
|
||||||
@ -128,15 +128,15 @@ class AccountsListViewController: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func updatePrimaryButton() {
|
private func updatePrimaryButton() {
|
||||||
primaryButton.isEnabled = accountSelectionConfiguration?.selectedAccounts.isEmpty == false
|
primaryButton.isEnabled = selectAccountAction?.selectedAccounts.isEmpty == false
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reloadHeader() {
|
private func reloadHeader() {
|
||||||
let canSelectAccount = accountSelectionConfiguration != nil && !wallets.isEmpty
|
let canSelectAccount = selectAccountAction != nil && !wallets.isEmpty
|
||||||
titleLabel.stringValue = canSelectAccount ? Strings.selectAccountTwoLines : Strings.wallets
|
titleLabel.stringValue = canSelectAccount ? Strings.selectAccountTwoLines : Strings.wallets
|
||||||
addButton.isHidden = wallets.isEmpty
|
addButton.isHidden = wallets.isEmpty
|
||||||
|
|
||||||
if canSelectAccount, let peer = accountSelectionConfiguration?.peer {
|
if canSelectAccount, let peer = selectAccountAction?.peer {
|
||||||
websiteNameLabel.stringValue = peer.name
|
websiteNameLabel.stringValue = peer.name
|
||||||
titleLabelTopConstraint.constant = 14
|
titleLabelTopConstraint.constant = 14
|
||||||
websiteNameStackView.isHidden = false
|
websiteNameStackView.isHidden = false
|
||||||
@ -154,7 +154,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
websiteNameStackView.isHidden = true
|
websiteNameStackView.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
let canSelectNetworkForCurrentProvider = accountSelectionConfiguration?.coinType == .ethereum || accountSelectionConfiguration?.coinType == nil
|
let canSelectNetworkForCurrentProvider = selectAccountAction?.coinType == .ethereum || selectAccountAction?.coinType == nil
|
||||||
if canSelectAccount, networkButton.isHidden, canSelectNetworkForCurrentProvider {
|
if canSelectAccount, networkButton.isHidden, canSelectNetworkForCurrentProvider {
|
||||||
networkButton.isHidden = false
|
networkButton.isHidden = false
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
@ -210,7 +210,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func didClickSecondaryButton(_ sender: Any) {
|
@IBAction func didClickSecondaryButton(_ sender: Any) {
|
||||||
if accountSelectionConfiguration?.initiallyConnectedProviders.isEmpty == false {
|
if selectAccountAction?.initiallyConnectedProviders.isEmpty == false {
|
||||||
callCompletion(specificWalletAccounts: [])
|
callCompletion(specificWalletAccounts: [])
|
||||||
} else {
|
} else {
|
||||||
callCompletion(specificWalletAccounts: nil)
|
callCompletion(specificWalletAccounts: nil)
|
||||||
@ -218,7 +218,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func didClickPrimaryButton(_ sender: Any) {
|
@IBAction func didClickPrimaryButton(_ sender: Any) {
|
||||||
callCompletion(specificWalletAccounts: accountSelectionConfiguration?.selectedAccounts.map { $0 })
|
callCompletion(specificWalletAccounts: selectAccountAction?.selectedAccounts.map { $0 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func didSelectChain(_ sender: AnyObject) {
|
@objc private func didSelectChain(_ sender: AnyObject) {
|
||||||
@ -280,7 +280,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
|
|
||||||
@objc private func didClickImportAccount() {
|
@objc private func didClickImportAccount() {
|
||||||
let importViewController = instantiate(ImportViewController.self)
|
let importViewController = instantiate(ImportViewController.self)
|
||||||
importViewController.accountSelectionConfiguration = accountSelectionConfiguration
|
importViewController.selectAccountAction = selectAccountAction
|
||||||
view.window?.contentViewController = importViewController
|
view.window?.contentViewController = importViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ class AccountsListViewController: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func cancelOperation(_ sender: Any?) {
|
override func cancelOperation(_ sender: Any?) {
|
||||||
if accountSelectionConfiguration?.initiallyConnectedProviders.isEmpty == false {
|
if selectAccountAction?.initiallyConnectedProviders.isEmpty == false {
|
||||||
callCompletion(specificWalletAccounts: nil)
|
callCompletion(specificWalletAccounts: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,35 +496,35 @@ class AccountsListViewController: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func validateSelectedAccounts() {
|
private func validateSelectedAccounts() {
|
||||||
guard let specificWalletAccounts = accountSelectionConfiguration?.selectedAccounts else { return }
|
guard let specificWalletAccounts = selectAccountAction?.selectedAccounts else { return }
|
||||||
for specificWalletAccount in specificWalletAccounts {
|
for specificWalletAccount in specificWalletAccounts {
|
||||||
if let wallet = wallets.first(where: { $0.id == specificWalletAccount.walletId }),
|
if let wallet = wallets.first(where: { $0.id == specificWalletAccount.walletId }),
|
||||||
wallet.accounts.contains(specificWalletAccount.account) {
|
wallet.accounts.contains(specificWalletAccount.account) {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
accountSelectionConfiguration?.selectedAccounts.remove(specificWalletAccount)
|
selectAccountAction?.selectedAccounts.remove(specificWalletAccount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func didClickAccountInSelectionMode(specificWalletAccount: SpecificWalletAccount) {
|
private func didClickAccountInSelectionMode(specificWalletAccount: SpecificWalletAccount) {
|
||||||
let wasSelected = accountSelectionConfiguration?.selectedAccounts.contains(specificWalletAccount) == true
|
let wasSelected = selectAccountAction?.selectedAccounts.contains(specificWalletAccount) == true
|
||||||
|
|
||||||
if !wasSelected, let toDeselect = accountSelectionConfiguration?.selectedAccounts.first(where: { $0.account.coin == specificWalletAccount.account.coin }) {
|
if !wasSelected, let toDeselect = selectAccountAction?.selectedAccounts.first(where: { $0.account.coin == specificWalletAccount.account.coin }) {
|
||||||
accountSelectionConfiguration?.selectedAccounts.remove(toDeselect)
|
selectAccountAction?.selectedAccounts.remove(toDeselect)
|
||||||
}
|
}
|
||||||
|
|
||||||
if wasSelected {
|
if wasSelected {
|
||||||
accountSelectionConfiguration?.selectedAccounts.remove(specificWalletAccount)
|
selectAccountAction?.selectedAccounts.remove(specificWalletAccount)
|
||||||
} else {
|
} else {
|
||||||
accountSelectionConfiguration?.selectedAccounts.insert(specificWalletAccount)
|
selectAccountAction?.selectedAccounts.insert(specificWalletAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePrimaryButton()
|
updatePrimaryButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func accountCanBeSelected(_ account: Account) -> Bool {
|
private func accountCanBeSelected(_ account: Account) -> Bool {
|
||||||
return accountSelectionConfiguration?.coinType == nil || accountSelectionConfiguration?.coinType == account.coin
|
return selectAccountAction?.coinType == nil || selectAccountAction?.coinType == account.coin
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -576,7 +576,7 @@ extension AccountsListViewController: AccountsHeaderDelegate {
|
|||||||
guard let wallet = walletForRow(row) else { return }
|
guard let wallet = walletForRow(row) else { return }
|
||||||
|
|
||||||
let editAccountsViewController = instantiate(EditAccountsViewController.self)
|
let editAccountsViewController = instantiate(EditAccountsViewController.self)
|
||||||
editAccountsViewController.accountSelectionConfiguration = accountSelectionConfiguration
|
editAccountsViewController.selectAccountAction = selectAccountAction
|
||||||
editAccountsViewController.wallet = wallet
|
editAccountsViewController.wallet = wallet
|
||||||
editAccountsViewController.getBackToRect = tableView.visibleRect
|
editAccountsViewController.getBackToRect = tableView.visibleRect
|
||||||
view.window?.contentViewController = editAccountsViewController
|
view.window?.contentViewController = editAccountsViewController
|
||||||
@ -624,7 +624,7 @@ extension AccountsListViewController: NSTableViewDelegate {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if accountSelectionConfiguration != nil {
|
if selectAccountAction != nil {
|
||||||
if accountCanBeSelected(account) {
|
if accountCanBeSelected(account) {
|
||||||
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
||||||
didClickAccountInSelectionMode(specificWalletAccount: specificWalletAccount)
|
didClickAccountInSelectionMode(specificWalletAccount: specificWalletAccount)
|
||||||
@ -649,7 +649,7 @@ extension AccountsListViewController: NSTableViewDataSource {
|
|||||||
let rowView = tableView.makeViewOfType(AccountCellView.self, owner: self)
|
let rowView = tableView.makeViewOfType(AccountCellView.self, owner: self)
|
||||||
let account = wallet.accounts[0]
|
let account = wallet.accounts[0]
|
||||||
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
||||||
let isSelected = accountSelectionConfiguration?.selectedAccounts.contains(specificWalletAccount) == true
|
let isSelected = selectAccountAction?.selectedAccounts.contains(specificWalletAccount) == true
|
||||||
rowView.setup(account: account, isSelected: isSelected, isDisabled: !accountCanBeSelected(account))
|
rowView.setup(account: account, isSelected: isSelected, isDisabled: !accountCanBeSelected(account))
|
||||||
return rowView
|
return rowView
|
||||||
case let .mnemonicAccount(walletIndex: walletIndex, accountIndex: accountIndex):
|
case let .mnemonicAccount(walletIndex: walletIndex, accountIndex: accountIndex):
|
||||||
@ -657,7 +657,7 @@ extension AccountsListViewController: NSTableViewDataSource {
|
|||||||
let rowView = tableView.makeViewOfType(AccountCellView.self, owner: self)
|
let rowView = tableView.makeViewOfType(AccountCellView.self, owner: self)
|
||||||
let account = wallet.accounts[accountIndex]
|
let account = wallet.accounts[accountIndex]
|
||||||
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
||||||
let isSelected = accountSelectionConfiguration?.selectedAccounts.contains(specificWalletAccount) == true
|
let isSelected = selectAccountAction?.selectedAccounts.contains(specificWalletAccount) == true
|
||||||
rowView.setup(account: account, isSelected: isSelected, isDisabled: !accountCanBeSelected(account))
|
rowView.setup(account: account, isSelected: isSelected, isDisabled: !accountCanBeSelected(account))
|
||||||
return rowView
|
return rowView
|
||||||
case .mnemonicWalletHeader:
|
case .mnemonicWalletHeader:
|
||||||
|
@ -7,7 +7,7 @@ class EditAccountsViewController: NSViewController {
|
|||||||
|
|
||||||
var wallet: TokenaryWallet!
|
var wallet: TokenaryWallet!
|
||||||
var getBackToRect: CGRect?
|
var getBackToRect: CGRect?
|
||||||
var accountSelectionConfiguration: AccountSelectionConfiguration?
|
var selectAccountAction: SelectAccountAction?
|
||||||
|
|
||||||
struct CoinDerivationCellModel {
|
struct CoinDerivationCellModel {
|
||||||
let coinDerivation: CoinDerivation
|
let coinDerivation: CoinDerivation
|
||||||
@ -64,7 +64,7 @@ class EditAccountsViewController: NSViewController {
|
|||||||
|
|
||||||
private func showAccountsList() {
|
private func showAccountsList() {
|
||||||
let accountsListViewController = instantiate(AccountsListViewController.self)
|
let accountsListViewController = instantiate(AccountsListViewController.self)
|
||||||
accountsListViewController.accountSelectionConfiguration = accountSelectionConfiguration
|
accountsListViewController.selectAccountAction = selectAccountAction
|
||||||
accountsListViewController.getBackToRect = getBackToRect
|
accountsListViewController.getBackToRect = getBackToRect
|
||||||
view.window?.contentViewController = accountsListViewController
|
view.window?.contentViewController = accountsListViewController
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import WalletCore
|
|||||||
class ImportViewController: NSViewController {
|
class ImportViewController: NSViewController {
|
||||||
|
|
||||||
private let walletsManager = WalletsManager.shared
|
private let walletsManager = WalletsManager.shared
|
||||||
var accountSelectionConfiguration: AccountSelectionConfiguration?
|
var selectAccountAction: SelectAccountAction?
|
||||||
private var inputValidationResult = WalletsManager.InputValidationResult.invalid
|
private var inputValidationResult = WalletsManager.InputValidationResult.invalid
|
||||||
|
|
||||||
@IBOutlet weak var textField: NSTextField! {
|
@IBOutlet weak var textField: NSTextField! {
|
||||||
@ -62,7 +62,7 @@ class ImportViewController: NSViewController {
|
|||||||
|
|
||||||
private func showAccountsList(newWalletId: String?) {
|
private func showAccountsList(newWalletId: String?) {
|
||||||
let accountsListViewController = instantiate(AccountsListViewController.self)
|
let accountsListViewController = instantiate(AccountsListViewController.self)
|
||||||
accountsListViewController.accountSelectionConfiguration = accountSelectionConfiguration
|
accountsListViewController.selectAccountAction = selectAccountAction
|
||||||
accountsListViewController.newWalletId = newWalletId
|
accountsListViewController.newWalletId = newWalletId
|
||||||
view.window?.contentViewController = accountsListViewController
|
view.window?.contentViewController = accountsListViewController
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,6 @@
|
|||||||
2C6F6D5A28273FE500D6E8FB /* EditAccountsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C6F6D5928273FE500D6E8FB /* EditAccountsViewController.swift */; };
|
2C6F6D5A28273FE500D6E8FB /* EditAccountsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C6F6D5928273FE500D6E8FB /* EditAccountsViewController.swift */; };
|
||||||
2C6F6D5D2827434800D6E8FB /* CoinDerivationTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C6F6D5B2827434800D6E8FB /* CoinDerivationTableViewCell.xib */; };
|
2C6F6D5D2827434800D6E8FB /* CoinDerivationTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C6F6D5B2827434800D6E8FB /* CoinDerivationTableViewCell.xib */; };
|
||||||
2C6F6D5E2827434800D6E8FB /* CoinDerivationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C6F6D5C2827434800D6E8FB /* CoinDerivationTableViewCell.swift */; };
|
2C6F6D5E2827434800D6E8FB /* CoinDerivationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C6F6D5C2827434800D6E8FB /* CoinDerivationTableViewCell.swift */; };
|
||||||
2C71175328AA62DE00ABBF2C /* AccountSelectionConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C71175228AA62DE00ABBF2C /* AccountSelectionConfiguration.swift */; };
|
|
||||||
2C71175428AA62DE00ABBF2C /* AccountSelectionConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C71175228AA62DE00ABBF2C /* AccountSelectionConfiguration.swift */; };
|
|
||||||
2C773F5E27450B97007B04E7 /* ExtensionBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C773F5D27450B97007B04E7 /* ExtensionBridge.swift */; };
|
2C773F5E27450B97007B04E7 /* ExtensionBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C773F5D27450B97007B04E7 /* ExtensionBridge.swift */; };
|
||||||
2C773F5F27450FBD007B04E7 /* ExtensionBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C773F5D27450B97007B04E7 /* ExtensionBridge.swift */; };
|
2C773F5F27450FBD007B04E7 /* ExtensionBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C773F5D27450B97007B04E7 /* ExtensionBridge.swift */; };
|
||||||
2C773F62274523DC007B04E7 /* ResponseToExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C773F61274523DC007B04E7 /* ResponseToExtension.swift */; };
|
2C773F62274523DC007B04E7 /* ResponseToExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C773F61274523DC007B04E7 /* ResponseToExtension.swift */; };
|
||||||
@ -346,7 +344,6 @@
|
|||||||
2C6F6D5928273FE500D6E8FB /* EditAccountsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAccountsViewController.swift; sourceTree = "<group>"; };
|
2C6F6D5928273FE500D6E8FB /* EditAccountsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAccountsViewController.swift; sourceTree = "<group>"; };
|
||||||
2C6F6D5B2827434800D6E8FB /* CoinDerivationTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CoinDerivationTableViewCell.xib; sourceTree = "<group>"; };
|
2C6F6D5B2827434800D6E8FB /* CoinDerivationTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CoinDerivationTableViewCell.xib; sourceTree = "<group>"; };
|
||||||
2C6F6D5C2827434800D6E8FB /* CoinDerivationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoinDerivationTableViewCell.swift; sourceTree = "<group>"; };
|
2C6F6D5C2827434800D6E8FB /* CoinDerivationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoinDerivationTableViewCell.swift; sourceTree = "<group>"; };
|
||||||
2C71175228AA62DE00ABBF2C /* AccountSelectionConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSelectionConfiguration.swift; sourceTree = "<group>"; };
|
|
||||||
2C74386E28297DAC00EC9304 /* near.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = near.js; path = "web3-provider/near.js"; sourceTree = "<group>"; };
|
2C74386E28297DAC00EC9304 /* near.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = near.js; path = "web3-provider/near.js"; sourceTree = "<group>"; };
|
||||||
2C773F5D27450B97007B04E7 /* ExtensionBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionBridge.swift; sourceTree = "<group>"; };
|
2C773F5D27450B97007B04E7 /* ExtensionBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionBridge.swift; sourceTree = "<group>"; };
|
||||||
2C773F61274523DC007B04E7 /* ResponseToExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseToExtension.swift; sourceTree = "<group>"; };
|
2C773F61274523DC007B04E7 /* ResponseToExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseToExtension.swift; sourceTree = "<group>"; };
|
||||||
@ -872,7 +869,6 @@
|
|||||||
0D059AD126C2796200EE3023 /* ApprovalSubject.swift */,
|
0D059AD126C2796200EE3023 /* ApprovalSubject.swift */,
|
||||||
2C09FC652828331D00DE9C27 /* Image.swift */,
|
2C09FC652828331D00DE9C27 /* Image.swift */,
|
||||||
2C89D26727BADCA9006C0C8D /* DappRequestAction.swift */,
|
2C89D26727BADCA9006C0C8D /* DappRequestAction.swift */,
|
||||||
2C71175228AA62DE00ABBF2C /* AccountSelectionConfiguration.swift */,
|
|
||||||
0DC850E626B73A5900809E82 /* AuthenticationReason.swift */,
|
0DC850E626B73A5900809E82 /* AuthenticationReason.swift */,
|
||||||
2C2AA1D128AD1DC100E35DBF /* SpecificWalletAccount.swift */,
|
2C2AA1D128AD1DC100E35DBF /* SpecificWalletAccount.swift */,
|
||||||
);
|
);
|
||||||
@ -1423,7 +1419,6 @@
|
|||||||
2C40379428199110004C7263 /* Solana.swift in Sources */,
|
2C40379428199110004C7263 /* Solana.swift in Sources */,
|
||||||
2C8A09DF267579EA00993638 /* AccountsListViewController.swift in Sources */,
|
2C8A09DF267579EA00993638 /* AccountsListViewController.swift in Sources */,
|
||||||
2C917429267D2A6E00049075 /* Keychain.swift in Sources */,
|
2C917429267D2A6E00049075 /* Keychain.swift in Sources */,
|
||||||
2C71175328AA62DE00ABBF2C /* AccountSelectionConfiguration.swift in Sources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -1447,7 +1442,6 @@
|
|||||||
2CF255B6275A746000AE54B9 /* AccountsListViewController.swift in Sources */,
|
2CF255B6275A746000AE54B9 /* AccountsListViewController.swift in Sources */,
|
||||||
2C264BCC27B2F2FF00234393 /* TezosSafariRequest.swift in Sources */,
|
2C264BCC27B2F2FF00234393 /* TezosSafariRequest.swift in Sources */,
|
||||||
2C96D3A42763C6A800687301 /* UIView.swift in Sources */,
|
2C96D3A42763C6A800687301 /* UIView.swift in Sources */,
|
||||||
2C71175428AA62DE00ABBF2C /* AccountSelectionConfiguration.swift in Sources */,
|
|
||||||
2CF25597275A46D300AE54B9 /* Defaults.swift in Sources */,
|
2CF25597275A46D300AE54B9 /* Defaults.swift in Sources */,
|
||||||
2CF255A2275A47DD00AE54B9 /* String.swift in Sources */,
|
2CF255A2275A47DD00AE54B9 /* String.swift in Sources */,
|
||||||
2CF2559D275A479800AE54B9 /* TokenaryWallet.swift in Sources */,
|
2CF2559D275A479800AE54B9 /* TokenaryWallet.swift in Sources */,
|
||||||
|
Loading…
Reference in New Issue
Block a user