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