chore(@desktop/wallet): `keypair` item/model, `keypair_account` item/model moved to `src/app/modules/shared_models` location
This commit is contained in:
parent
44e00b9538
commit
1803f477bb
|
@ -38,7 +38,6 @@ QtObject:
|
|||
emoji: {self.emoji},
|
||||
color: {self.color},
|
||||
icon: {self.icon},
|
||||
icon: {$self.icon},
|
||||
balance: {self.balance},
|
||||
balanceFetched: {self.balanceFetched}
|
||||
]"""
|
|
@ -1,9 +1,9 @@
|
|||
import NimQml, Tables, strformat, strutils
|
||||
import key_pair_account_item
|
||||
import keypair_account_item
|
||||
|
||||
import ../../../../../app_service/common/utils
|
||||
import ../../../app_service/common/utils
|
||||
|
||||
export key_pair_account_item
|
||||
export keypair_account_item
|
||||
|
||||
type
|
||||
ModelRole {.pure.} = enum
|
||||
|
@ -80,6 +80,12 @@ QtObject:
|
|||
return true
|
||||
return false
|
||||
|
||||
proc containsAccountPath*(self: KeyPairAccountModel, path: string): bool =
|
||||
for it in self.items:
|
||||
if it.getPath() == path:
|
||||
return true
|
||||
return false
|
||||
|
||||
proc containsPathOutOfTheDefaultStatusDerivationTree*(self: KeyPairAccountModel): bool =
|
||||
for it in self.items:
|
||||
if utils.isPathOutOfTheDefaultStatusDerivationTree(it.getPath()):
|
|
@ -1,7 +1,7 @@
|
|||
import NimQml, strformat
|
||||
import key_pair_account_model
|
||||
import keypair_account_model
|
||||
|
||||
export key_pair_account_model
|
||||
export keypair_account_model
|
||||
|
||||
type
|
||||
KeyPairType* {.pure.} = enum
|
||||
|
@ -20,6 +20,8 @@ QtObject:
|
|||
icon: string
|
||||
pairType: KeyPairType
|
||||
derivedFrom: string
|
||||
lastUsedDerivationIndex: int
|
||||
migratedToKeycard: bool
|
||||
accounts: KeyPairAccountModel
|
||||
observedAccount: KeyPairAccountItem
|
||||
|
||||
|
@ -31,7 +33,9 @@ QtObject:
|
|||
image: string,
|
||||
icon: string,
|
||||
pairType: KeyPairType,
|
||||
derivedFrom: string
|
||||
derivedFrom: string,
|
||||
lastUsedDerivationIndex: int,
|
||||
migratedToKeycard: bool
|
||||
) =
|
||||
self.QObject.setup
|
||||
self.keyUid = keyUid
|
||||
|
@ -42,6 +46,8 @@ QtObject:
|
|||
self.icon = icon
|
||||
self.pairType = pairType
|
||||
self.derivedFrom = derivedFrom
|
||||
self.lastUsedDerivationIndex = lastUsedDerivationIndex
|
||||
self.migratedToKeycard = migratedToKeycard
|
||||
self.accounts = newKeyPairAccountModel()
|
||||
|
||||
proc delete*(self: KeyPairItem) =
|
||||
|
@ -54,9 +60,11 @@ QtObject:
|
|||
image = "",
|
||||
icon = "",
|
||||
pairType = KeyPairType.Unknown,
|
||||
derivedFrom = ""): KeyPairItem =
|
||||
derivedFrom = "",
|
||||
lastUsedDerivationIndex = 0,
|
||||
migratedToKeycard = false): KeyPairItem =
|
||||
new(result, delete)
|
||||
result.setup(keyUid, pubKey, locked, name, image, icon, pairType, derivedFrom)
|
||||
result.setup(keyUid, pubKey, locked, name, image, icon, pairType, derivedFrom, lastUsedDerivationIndex, migratedToKeycard)
|
||||
|
||||
proc `$`*(self: KeyPairItem): string =
|
||||
result = fmt"""KeyPairItem[
|
||||
|
@ -68,6 +76,8 @@ QtObject:
|
|||
icon: {self.icon},
|
||||
pairType: {$self.pairType},
|
||||
derivedFrom: {self.derivedFrom},
|
||||
lastUsedDerivationIndex: {self.lastUsedDerivationIndex},
|
||||
migratedToKeycard: {self.migratedToKeycard},
|
||||
accounts: {$self.accounts}
|
||||
]"""
|
||||
|
||||
|
@ -159,6 +169,28 @@ QtObject:
|
|||
write = setDerivedFrom
|
||||
notify = derivedFromChanged
|
||||
|
||||
proc lastUsedDerivationIndexChanged*(self: KeyPairItem) {.signal.}
|
||||
proc getLastUsedDerivationIndex*(self: KeyPairItem): int {.slot.} =
|
||||
return self.lastUsedDerivationIndex
|
||||
proc setLastUsedDerivationIndex*(self: KeyPairItem, value: int) {.slot.} =
|
||||
self.lastUsedDerivationIndex = value
|
||||
self.lastUsedDerivationIndexChanged()
|
||||
QtProperty[int] lastUsedDerivationIndex:
|
||||
read = getLastUsedDerivationIndex
|
||||
write = setLastUsedDerivationIndex
|
||||
notify = lastUsedDerivationIndexChanged
|
||||
|
||||
proc migratedToKeycardChanged*(self: KeyPairItem) {.signal.}
|
||||
proc getMigratedToKeycard*(self: KeyPairItem): bool {.slot.} =
|
||||
return self.migratedToKeycard
|
||||
proc setMigratedToKeycard*(self: KeyPairItem, value: bool) {.slot.} =
|
||||
self.migratedToKeycard = value
|
||||
self.migratedToKeycardChanged()
|
||||
QtProperty[bool] migratedToKeycard:
|
||||
read = getMigratedToKeycard
|
||||
write = setMigratedToKeycard
|
||||
notify = migratedToKeycardChanged
|
||||
|
||||
proc observedAccountChanged*(self: KeyPairItem) {.signal.}
|
||||
proc getObservedAccountAsVariant*(self: KeyPairItem): QVariant {.slot.} =
|
||||
return newQVariant(self.observedAccount)
|
||||
|
@ -192,6 +224,8 @@ QtObject:
|
|||
self.setLastAccountAsObservedAccount()
|
||||
proc containsAccountAddress*(self: KeyPairItem, address: string): bool =
|
||||
return self.accounts.containsAccountAddress(address)
|
||||
proc containsAccountPath*(self: KeyPairItem, path: string): bool =
|
||||
return self.accounts.containsAccountPath(path)
|
||||
proc containsPathOutOfTheDefaultStatusDerivationTree*(self: KeyPairItem): bool {.slot.} =
|
||||
return self.accounts.containsPathOutOfTheDefaultStatusDerivationTree()
|
||||
proc updateDetailsForAccountWithAddressIfTheyAreSet*(self: KeyPairItem, address, name, color, emoji: string) =
|
||||
|
@ -208,5 +242,7 @@ QtObject:
|
|||
self.setIcon(item.getIcon())
|
||||
self.setPairType(item.getPairType())
|
||||
self.setDerivedFrom(item.getDerivedFrom())
|
||||
self.setMigratedToKeycard(item.getMigratedToKeycard())
|
||||
self.setLastUsedDerivationIndex(item.getLastUsedDerivationIndex())
|
||||
self.setAccounts(item.getAccountsModel().getItems())
|
||||
self.setLastAccountAsObservedAccount()
|
|
@ -1,7 +1,7 @@
|
|||
import NimQml, Tables, strformat
|
||||
import key_pair_item
|
||||
import keypair_item
|
||||
|
||||
export key_pair_item
|
||||
export keypair_item
|
||||
|
||||
type
|
||||
ModelRole {.pure.} = enum
|
||||
|
@ -30,12 +30,6 @@ QtObject:
|
|||
read = getCount
|
||||
notify = countChanged
|
||||
|
||||
proc setItems*(self: KeyPairModel, items: seq[KeyPairItem]) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
proc `$`*(self: KeyPairModel): string =
|
||||
for i in 0 ..< self.items.len:
|
||||
result &= fmt"""KeyPairModel:
|
||||
|
@ -61,8 +55,28 @@ QtObject:
|
|||
of ModelRole.KeyPair:
|
||||
result = newQVariant(item)
|
||||
|
||||
proc setItems*(self: KeyPairModel, items: seq[KeyPairItem]) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
proc addItem*(self: KeyPairModel, item: KeyPairItem) =
|
||||
let parentModelIndex = newQModelIndex()
|
||||
defer: parentModelIndex.delete
|
||||
self.beginInsertRows(parentModelIndex, self.items.len, self.items.len)
|
||||
self.items.add(item)
|
||||
self.endInsertRows()
|
||||
self.countChanged()
|
||||
|
||||
proc findItemByPublicKey*(self: KeyPairModel, publicKey: string): KeyPairItem =
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].getPubKey() == publicKey):
|
||||
return self.items[i]
|
||||
return nil
|
||||
|
||||
proc findItemByKeyUid*(self: KeyPairModel, keyUid: string): KeyPairItem =
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].getKeyUid() == keyUid):
|
||||
return self.items[i]
|
||||
return nil
|
|
@ -18,7 +18,7 @@ import ../../../../app_service/service/accounts/service as accounts_service
|
|||
import ../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../app_service/service/keychain/service as keychain_service
|
||||
|
||||
import models/[key_pair_item]
|
||||
import ../../shared_models/[keypair_item]
|
||||
|
||||
logScope:
|
||||
topics = "keycard-popup-controller"
|
||||
|
|
|
@ -7,7 +7,7 @@ from ../../../../../app_service/service/keycard/service import PUKLengthForStatu
|
|||
import ../../../../../app_service/common/account_constants
|
||||
import ../../../../../app_service/service/wallet_account/key_pair_dto
|
||||
import ../controller
|
||||
import ../models/[key_pair_model]
|
||||
import ../../../shared_models/[keypair_model]
|
||||
import state
|
||||
|
||||
logScope:
|
||||
|
|
|
@ -2,7 +2,7 @@ import NimQml, tables
|
|||
import ../../../../app/core/eventemitter
|
||||
from ../../../../app_service/service/keycard/service import KeycardEvent, CardMetadata, KeyDetails
|
||||
from ../../../../app_service/service/wallet_account/service as wallet_account_service import WalletTokenDto
|
||||
import models/key_pair_item
|
||||
import ../../shared_models/keypair_item
|
||||
|
||||
const SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED_AND_WALLET_ADDRESS_GENERATED* = "sharedKeycarModuleUserAuthenticatedAndWalletAddressGenerated"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import NimQml, strformat
|
||||
import key_pair_item
|
||||
import ../../../shared_models/keypair_item
|
||||
|
||||
export key_pair_item
|
||||
export keypair_item
|
||||
|
||||
QtObject:
|
||||
type KeycardItem* = ref object of KeyPairItem
|
||||
|
@ -19,10 +19,13 @@ QtObject:
|
|||
image = "",
|
||||
icon = "",
|
||||
pairType = KeyPairType.Unknown,
|
||||
derivedFrom = ""
|
||||
derivedFrom = "",
|
||||
lastUsedDerivationIndex = 0,
|
||||
migratedToKeycard = true
|
||||
): KeycardItem =
|
||||
new(result, delete)
|
||||
result.KeyPairItem.setup(keyUid, pubKey, locked, name, image, icon, pairType, derivedFrom)
|
||||
result.KeyPairItem.setup(keyUid, pubKey, locked, name, image, icon, pairType, derivedFrom,lastUsedDerivationIndex,
|
||||
migratedToKeycard)
|
||||
result.keycardUid = keycardUid
|
||||
|
||||
proc `$`*(self: KeycardItem): string =
|
||||
|
|
|
@ -3,7 +3,7 @@ import NimQml, tables, random, strutils, sequtils, sugar, chronicles
|
|||
import io_interface
|
||||
import view, controller
|
||||
import internal/[state, state_factory]
|
||||
import models/[key_pair_model, key_pair_item]
|
||||
import ../../shared_models/[keypair_model, keypair_item]
|
||||
import ../../../global/global_singleton
|
||||
import ../../../core/eventemitter
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import NimQml
|
||||
import io_interface
|
||||
import internal/[state, state_wrapper]
|
||||
import models/[key_pair_model, key_pair_item]
|
||||
import ../../shared_models/[keypair_model, keypair_item]
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
|
Loading…
Reference in New Issue