chore(@desktop/wallet): `KeyPairDto` which actually refers to keycard is renamed to `KeycardDto`
This change is needed for further changes which are part of issue #10592
This commit is contained in:
parent
21abe5fca7
commit
534e172397
|
@ -11,7 +11,7 @@ import ../../../../app_service/service/contacts/dto/[contacts, status_update]
|
|||
import ../../../../app_service/service/devices/dto/[installation]
|
||||
import ../../../../app_service/service/settings/dto/[settings]
|
||||
import ../../../../app_service/service/saved_address/dto as saved_address_dto
|
||||
import ../../../../app_service/service/wallet_account/[dto, key_pair_dto]
|
||||
import ../../../../app_service/service/wallet_account/[dto, keycard_dto]
|
||||
|
||||
type MessageSignal* = ref object of Signal
|
||||
bookmarks*: seq[BookmarkDto]
|
||||
|
@ -33,7 +33,7 @@ type MessageSignal* = ref object of Signal
|
|||
clearedHistories*: seq[ClearedHistoryDto]
|
||||
verificationRequests*: seq[VerificationRequest]
|
||||
savedAddresses*: seq[SavedAddressDto]
|
||||
keycards*: seq[KeyPairDto]
|
||||
keycards*: seq[KeycardDto]
|
||||
keycardActions*: seq[KeycardActionDto]
|
||||
walletAccounts*: seq[WalletAccountDto]
|
||||
|
||||
|
@ -136,7 +136,7 @@ proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal =
|
|||
|
||||
if event["event"]{"keycards"} != nil:
|
||||
for jsonKc in event["event"]["keycards"]:
|
||||
signal.keycards.add(jsonKc.toKeyPairDto())
|
||||
signal.keycards.add(jsonKc.toKeycardDto())
|
||||
|
||||
if event["event"]{"keycardActions"} != nil:
|
||||
for jsonKc in event["event"]["keycardActions"]:
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import json
|
||||
import base
|
||||
|
||||
import ../../../../app_service/service/wallet_account/[key_pair_dto]
|
||||
import ../../../../app_service/service/wallet_account/[keycard_dto]
|
||||
|
||||
type WakuBackedUpKeycardsSignal* = ref object of Signal
|
||||
keycards*: seq[KeyPairDto]
|
||||
keycards*: seq[KeycardDto]
|
||||
|
||||
proc fromEvent*(T: type WakuBackedUpKeycardsSignal, event: JsonNode): WakuBackedUpKeycardsSignal =
|
||||
result = WakuBackedUpKeycardsSignal()
|
||||
|
||||
if event["event"]{"backedUpKeycards"} != nil:
|
||||
for jsonKc in event["event"]["backedUpKeycards"]:
|
||||
result.keycards.add(jsonKc.toKeyPairDto())
|
||||
result.keycards.add(jsonKc.toKeycardDto())
|
|
@ -313,7 +313,7 @@ method authenticateAndRegisterEns*(self: Module, chainId: int, ensUsername: stri
|
|||
## if acc.isNil:
|
||||
## echo "error: selected account to send a transaction from is not known"
|
||||
## return
|
||||
## let keyPair = self.controller.getMigratedKeyPairByKeyUid(acc.keyUid)
|
||||
## let keyPair = self.controller.getKeycardByKeyUid(acc.keyUid)
|
||||
## if keyPair.len == 0:
|
||||
## self.controller.authenticateUser()
|
||||
## else:
|
||||
|
|
|
@ -51,7 +51,7 @@ proc init*(self: Controller) =
|
|||
let args = KeycardActivityArgs(e)
|
||||
if not args.success:
|
||||
return
|
||||
self.delegate.onNewKeycardSet(args.keyPair)
|
||||
self.delegate.onNewKeycardSet(args.keycard)
|
||||
|
||||
self.events.on(SIGNAL_KEYCARDS_SYNCHRONIZED) do(e: Args):
|
||||
let args = KeycardActivityArgs(e)
|
||||
|
@ -61,25 +61,25 @@ proc init*(self: Controller) =
|
|||
|
||||
self.events.on(SIGNAL_KEYCARD_LOCKED) do(e: Args):
|
||||
let args = KeycardActivityArgs(e)
|
||||
self.delegate.onKeycardLocked(args.keyPair.keyUid, args.keyPair.keycardUid)
|
||||
self.delegate.onKeycardLocked(args.keycard.keyUid, args.keycard.keycardUid)
|
||||
|
||||
self.events.on(SIGNAL_KEYCARD_UNLOCKED) do(e: Args):
|
||||
let args = KeycardActivityArgs(e)
|
||||
self.delegate.onKeycardUnlocked(args.keyPair.keyUid, args.keyPair.keycardUid)
|
||||
self.delegate.onKeycardUnlocked(args.keycard.keyUid, args.keycard.keycardUid)
|
||||
|
||||
self.events.on(SIGNAL_KEYCARD_NAME_CHANGED) do(e: Args):
|
||||
let args = KeycardActivityArgs(e)
|
||||
self.delegate.onKeycardNameChanged(args.keyPair.keycardUid, args.keyPair.keycardName)
|
||||
self.delegate.onKeycardNameChanged(args.keycard.keycardUid, args.keycard.keycardName)
|
||||
|
||||
self.events.on(SIGNAL_KEYCARD_UID_UPDATED) do(e: Args):
|
||||
let args = KeycardActivityArgs(e)
|
||||
self.delegate.onKeycardUidUpdated(args.oldKeycardUid, args.keyPair.keycardUid)
|
||||
self.delegate.onKeycardUidUpdated(args.oldKeycardUid, args.keycard.keycardUid)
|
||||
|
||||
self.events.on(SIGNAL_KEYCARD_ACCOUNTS_REMOVED) do(e: Args):
|
||||
let args = KeycardActivityArgs(e)
|
||||
if not args.success:
|
||||
return
|
||||
self.delegate.onKeycardAccountsRemoved(args.keyPair.keyUid, args.keyPair.keycardUid, args.keyPair.accountsAddresses)
|
||||
self.delegate.onKeycardAccountsRemoved(args.keycard.keyUid, args.keycard.keycardUid, args.keycard.accountsAddresses)
|
||||
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e: Args):
|
||||
let args = WalletAccountUpdated(e)
|
||||
|
@ -91,10 +91,10 @@ proc init*(self: Controller) =
|
|||
self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e: Args):
|
||||
self.delegate.rebuildKeycardsList()
|
||||
|
||||
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
|
||||
return self.walletAccountService.getAllMigratedKeyPairs()
|
||||
proc getAllKnownKeycardsGroupedByKeyUid*(self: Controller): seq[KeycardDto] =
|
||||
return self.walletAccountService.getAllKnownKeycardsGroupedByKeyUid()
|
||||
|
||||
proc getAllKnownKeycards*(self: Controller): seq[KeyPairDto] =
|
||||
proc getAllKnownKeycards*(self: Controller): seq[KeycardDto] =
|
||||
return self.walletAccountService.getAllKnownKeycards()
|
||||
|
||||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import NimQml
|
||||
from ../../../../../app_service/service/wallet_account/service import KeyPairDto
|
||||
from ../../../../../app_service/service/wallet_account/service import KeycardDto
|
||||
from ../../../../../app_service/service/wallet_account/service import WalletAccountDto
|
||||
|
||||
type
|
||||
|
@ -69,7 +69,7 @@ method onLoggedInUserImageChanged*(self: AccessInterface) {.base.} =
|
|||
method rebuildKeycardsList*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onNewKeycardSet*(self: AccessInterface, keyPair: KeyPairDto) {.base.} =
|
||||
method onNewKeycardSet*(self: AccessInterface, keyPair: KeycardDto) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onKeycardLocked*(self: AccessInterface, keyUid: string, keycardUid: string) {.base.} =
|
||||
|
|
|
@ -197,7 +197,7 @@ proc findAccountByAccountAddress(accounts: seq[WalletAccountDto], address: strin
|
|||
return accounts[i]
|
||||
return nil
|
||||
|
||||
proc buildKeycardItem(self: Module, walletAccounts: seq[WalletAccountDto], keyPair: KeyPairDto, reason: BuildItemReason):
|
||||
proc buildKeycardItem(self: Module, walletAccounts: seq[WalletAccountDto], keyPair: KeycardDto, reason: BuildItemReason):
|
||||
KeycardItem =
|
||||
let isAccountInKnownAccounts = proc(knownAccounts: seq[WalletAccountDto], address: string): bool =
|
||||
for i in 0 ..< knownAccounts.len:
|
||||
|
@ -267,7 +267,7 @@ proc areAllKnownKeycardsLockedForKeypair(self: Module, keyUid: string): bool =
|
|||
proc buildKeycardList(self: Module) =
|
||||
let walletAccounts = self.controller.getWalletAccounts()
|
||||
var items: seq[KeycardItem]
|
||||
let migratedKeyPairs = self.controller.getAllMigratedKeyPairs()
|
||||
let migratedKeyPairs = self.controller.getAllKnownKeycardsGroupedByKeyUid()
|
||||
for kp in migratedKeyPairs:
|
||||
let item = self.buildKeycardItem(walletAccounts, kp, BuildItemReason.MainView)
|
||||
if item.isNil:
|
||||
|
@ -288,7 +288,7 @@ method rebuildKeycardsList*(self: Module) =
|
|||
self.view.setKeycardItems(@[])
|
||||
self.buildKeycardList()
|
||||
|
||||
method onNewKeycardSet*(self: Module, keyPair: KeyPairDto) =
|
||||
method onNewKeycardSet*(self: Module, keyPair: KeycardDto) =
|
||||
let walletAccounts = self.controller.getWalletAccounts()
|
||||
var mainViewItem = self.view.keycardModel().getItemForKeyUid(keyPair.keyUid)
|
||||
if mainViewItem.isNil:
|
||||
|
|
|
@ -31,8 +31,8 @@ proc updateAccount*(self: Controller, address: string, accountName: string, colo
|
|||
proc deleteAccount*(self: Controller, address: string) =
|
||||
self.walletAccountService.deleteAccount(address)
|
||||
|
||||
proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairDto] =
|
||||
return self.walletAccountService.getMigratedKeyPairByKeyUid(keyUid)
|
||||
proc getKeycardByKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
|
||||
return self.walletAccountService.getKeycardByKeyUid(keyUid)
|
||||
|
||||
proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
|
||||
return self.walletAccountService.getAccountByAddress(address)
|
|
@ -96,7 +96,7 @@ method authenticateAndBuy*(self: Module, packId: string, address: string, gas: s
|
|||
## if acc.isNil:
|
||||
## echo "error: selected account to send a transaction from is not known"
|
||||
## return
|
||||
## let keyPair = self.controller.getMigratedKeyPairByKeyUid(acc.keyUid)
|
||||
## let keyPair = self.controller.getKeycardByKeyUid(acc.keyUid)
|
||||
## if keyPair.len == 0:
|
||||
## self.controller.authenticateUser()
|
||||
## else:
|
||||
|
|
|
@ -47,8 +47,8 @@ proc getCurrentCurrency*(self: Controller): string =
|
|||
proc getCurrencyFormat*(self: Controller, symbol: string): CurrencyFormatDto =
|
||||
return self.currencyService.getCurrencyFormat(symbol)
|
||||
|
||||
proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairDto] =
|
||||
return self.walletAccountService.getMigratedKeyPairByKeyUid(keyUid)
|
||||
proc getKeycardByKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
|
||||
return self.walletAccountService.getKeycardByKeyUid(keyUid)
|
||||
|
||||
proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
|
||||
return self.walletAccountService.getAccountByAddress(address)
|
||||
|
|
|
@ -120,8 +120,8 @@ proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
|
|||
proc getWalletAccounts*(self: Controller): seq[WalletAccountDto] =
|
||||
return self.walletAccountService.fetchAccounts()
|
||||
|
||||
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
|
||||
return self.walletAccountService.getAllMigratedKeyPairs()
|
||||
proc getAllKnownKeycardsGroupedByKeyUid*(self: Controller): seq[KeycardDto] =
|
||||
return self.walletAccountService.getAllKnownKeycardsGroupedByKeyUid()
|
||||
|
||||
proc finalizeAction*(self: Controller) =
|
||||
self.delegate.finalizeAction()
|
||||
|
|
|
@ -78,7 +78,7 @@ method loadForAddingAccount*[T](self: Module[T], addingWatchOnlyAccount: bool) =
|
|||
self.view.setEditMode(false)
|
||||
self.view.setCurrentState(newMainState(nil))
|
||||
|
||||
var items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
|
||||
var items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllKnownKeycardsGroupedByKeyUid(),
|
||||
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = true)
|
||||
if items.len == 0:
|
||||
error "list of identified keypairs is empty, but it must have at least a profile keypair"
|
||||
|
@ -132,7 +132,7 @@ method loadForEditingAccount*[T](self: Module[T], address: string) =
|
|||
self.view.setSelectedOrigin(item)
|
||||
self.view.setWatchOnlyAccAddress(addressDetailsItem)
|
||||
else:
|
||||
var items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
|
||||
var items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllKnownKeycardsGroupedByKeyUid(),
|
||||
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = false)
|
||||
if items.len == 0:
|
||||
error "list of identified keypairs is empty, but it must have at least a profile keypair"
|
||||
|
|
|
@ -70,8 +70,8 @@ proc getCurrentCurrency*(self: Controller): string =
|
|||
proc getCurrencyFormat*(self: Controller, symbol: string): CurrencyFormatDto =
|
||||
return self.currencyService.getCurrencyFormat(symbol)
|
||||
|
||||
proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairDto] =
|
||||
return self.walletAccountService.getMigratedKeyPairByKeyUid(keyUid)
|
||||
proc getKeycardByKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
|
||||
return self.walletAccountService.getKeycardByKeyUid(keyUid)
|
||||
|
||||
proc getAccountByAddress*(self: Controller, address: string): WalletAccountDto =
|
||||
return self.walletAccountService.getAccountByAddress(address)
|
||||
|
|
|
@ -161,7 +161,7 @@ method authenticateAndTransfer*(
|
|||
## if acc.isNil:
|
||||
## echo "error: selected account to send a transaction from is not known"
|
||||
## return
|
||||
## let keyPair = self.controller.getMigratedKeyPairByKeyUid(acc.keyUid)
|
||||
## let keyPair = self.controller.getKeycardByKeyUid(acc.keyUid)
|
||||
## if keyPair.len == 0:
|
||||
## self.controller.authenticateUser()
|
||||
## else:
|
||||
|
|
|
@ -3,14 +3,14 @@ import strutils, sequtils, sugar, chronicles
|
|||
import ../shared_models/[keypair_item]
|
||||
import ../../global/global_singleton
|
||||
|
||||
import ../../../app_service/service/wallet_account/[dto, key_pair_dto]
|
||||
import ../../../app_service/service/wallet_account/[dto, keycard_dto]
|
||||
|
||||
export keypair_item
|
||||
|
||||
logScope:
|
||||
topics = "shared-keypairs"
|
||||
|
||||
proc buildKeyPairsList*(allWalletAccounts: seq[WalletAccountDto], allMigratedKeypairs: seq[KeyPairDto],
|
||||
proc buildKeyPairsList*(allWalletAccounts: seq[WalletAccountDto], allMigratedKeypairs: seq[KeycardDto],
|
||||
excludeAlreadyMigratedPairs: bool, excludePrivateKeyKeypairs: bool): seq[KeyPairItem] =
|
||||
let keyPairMigrated = proc(keyUid: string): bool =
|
||||
result = false
|
||||
|
|
|
@ -49,7 +49,7 @@ type
|
|||
tmpPassword: string
|
||||
tmpPairingCode: string
|
||||
tmpSelectedKeyPairIsProfile: bool
|
||||
tmpSelectedKeyPairDto: KeyPairDto
|
||||
tmpSelectedKeycardDto: KeycardDto
|
||||
tmpSelectedKeyPairWalletPaths: seq[string]
|
||||
tmpSeedPhrase: string
|
||||
tmpSeedPhraseLength: int
|
||||
|
@ -300,32 +300,32 @@ proc unlockUsingSeedPhrase*(self: Controller): bool =
|
|||
proc setUnlockUsingSeedPhrase*(self: Controller, value: bool) =
|
||||
self.tmpUnlockUsingSeedPhrase = value
|
||||
|
||||
proc setSelectedKeyPair*(self: Controller, isProfile: bool, paths: seq[string], keyPairDto: KeyPairDto) =
|
||||
if paths.len != keyPairDto.accountsAddresses.len:
|
||||
proc setSelectedKeyPair*(self: Controller, isProfile: bool, paths: seq[string], keycardDto: KeycardDto) =
|
||||
if paths.len != keycardDto.accountsAddresses.len:
|
||||
error "selected keypair has different number of paths and addresses"
|
||||
return
|
||||
self.tmpSelectedKeyPairIsProfile = isProfile
|
||||
self.tmpSelectedKeyPairWalletPaths = paths
|
||||
self.tmpSelectedKeyPairDto = keyPairDto
|
||||
self.tmpSelectedKeycardDto = keycardDto
|
||||
|
||||
proc getSelectedKeyPairIsProfile*(self: Controller): bool =
|
||||
return self.tmpSelectedKeyPairIsProfile
|
||||
|
||||
proc getSelectedKeyPairDto*(self: Controller): KeyPairDto =
|
||||
return self.tmpSelectedKeyPairDto
|
||||
proc getSelectedKeyPairDto*(self: Controller): KeycardDto =
|
||||
return self.tmpSelectedKeycardDto
|
||||
|
||||
proc getSelectedKeyPairWalletPaths*(self: Controller): seq[string] =
|
||||
return self.tmpSelectedKeyPairWalletPaths
|
||||
|
||||
proc setSelectedKeypairAsKeyPairForProcessing*(self: Controller) =
|
||||
var cardMetadata = CardMetadata(name: self.tmpSelectedKeyPairDto.keycardName)
|
||||
var cardMetadata = CardMetadata(name: self.tmpSelectedKeycardDto.keycardName)
|
||||
for i in 0 ..< self.tmpSelectedKeyPairWalletPaths.len:
|
||||
cardMetadata.walletAccounts.add(WalletAccount(path: self.tmpSelectedKeyPairWalletPaths[i],
|
||||
address: self.tmpSelectedKeyPairDto.accountsAddresses[i]))
|
||||
address: self.tmpSelectedKeycardDto.accountsAddresses[i]))
|
||||
self.delegate.updateKeyPairForProcessing(cardMetadata)
|
||||
|
||||
proc setKeycardUidTheSelectedKeypairIsMigratedTo*(self: Controller, value: string) =
|
||||
self.tmpSelectedKeyPairDto.keycardUid = value
|
||||
self.tmpSelectedKeycardDto.keycardUid = value
|
||||
|
||||
proc setKeycardUid*(self: Controller, value: string) =
|
||||
self.tmpKeycardUid = value
|
||||
|
@ -556,7 +556,7 @@ proc cleanTmpData(self: Controller) =
|
|||
self.setPukValid(false)
|
||||
self.setPassword("")
|
||||
self.setPairingCode("")
|
||||
self.setSelectedKeyPair(isProfile = false, paths = @[], KeyPairDto())
|
||||
self.setSelectedKeyPair(isProfile = false, paths = @[], KeycardDto())
|
||||
self.setSeedPhrase("")
|
||||
self.setUsePinFromBiometrics(false)
|
||||
self.setOfferToStoreUpdatedPinToKeychain(false)
|
||||
|
@ -626,12 +626,12 @@ proc getOrFetchBalanceForAddressInPreferredCurrency*(self: Controller, address:
|
|||
return (0.0, true)
|
||||
return self.walletAccountService.getOrFetchBalanceForAddressInPreferredCurrency(address)
|
||||
|
||||
proc addMigratedKeyPair*(self: Controller, keyPair: KeyPairDto) =
|
||||
proc addKeycardOrAccounts*(self: Controller, keyPair: KeycardDto) =
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
return
|
||||
if not serviceApplicable(self.accountsService):
|
||||
return
|
||||
self.walletAccountService.addMigratedKeyPairAsync(keyPair)
|
||||
self.walletAccountService.addKeycardOrAccountsAsync(keyPair)
|
||||
|
||||
proc removeMigratedAccountsForKeycard*(self: Controller, keyUid: string, keycardUid: string, accountsToRemove: seq[string]) =
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
|
@ -641,17 +641,17 @@ proc removeMigratedAccountsForKeycard*(self: Controller, keyUid: string, keycard
|
|||
proc getAddingMigratedKeypairSuccess*(self: Controller): bool =
|
||||
return self.tmpAddingMigratedKeypairSuccess
|
||||
|
||||
proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairDto] =
|
||||
proc getKeycardByKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
return
|
||||
return self.walletAccountService.getMigratedKeyPairByKeyUid(keyUid)
|
||||
return self.walletAccountService.getKeycardByKeyUid(keyUid)
|
||||
|
||||
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
|
||||
proc getAllKnownKeycardsGroupedByKeyUid*(self: Controller): seq[KeycardDto] =
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
return
|
||||
return self.walletAccountService.getAllMigratedKeyPairs()
|
||||
return self.walletAccountService.getAllKnownKeycardsGroupedByKeyUid()
|
||||
|
||||
proc getAllKnownKeycards*(self: Controller): seq[KeyPairDto] =
|
||||
proc getAllKnownKeycards*(self: Controller): seq[KeycardDto] =
|
||||
if not serviceApplicable(self.walletAccountService):
|
||||
return
|
||||
return self.walletAccountService.getAllKnownKeycards()
|
||||
|
|
|
@ -13,12 +13,12 @@ proc buildKeypairAndAddToMigratedKeypairs(self: CopyingKeycardState, controller:
|
|||
var addresses: seq[string]
|
||||
for wa in cardMetadata.walletAccounts:
|
||||
addresses.add(wa.address)
|
||||
var keyPairDto = KeyPairDto(keycardUid: controller.getDestinationKeycardUid(),
|
||||
var keycardDto = KeycardDto(keycardUid: controller.getDestinationKeycardUid(),
|
||||
keycardName: cardMetadata.name,
|
||||
keycardLocked: false,
|
||||
keyUid: controller.getKeyPairForProcessing().getKeyUid(),
|
||||
accountsAddresses: addresses)
|
||||
controller.addMigratedKeyPair(keyPairDto)
|
||||
controller.addKeycardOrAccounts(keycardDto)
|
||||
|
||||
proc runStoreMetadataFlow(self: CopyingKeycardState, controller: Controller) =
|
||||
let cardMetadata = controller.getMetadataForKeycardCopy()
|
||||
|
|
|
@ -62,12 +62,12 @@ proc addAccountsToWallet(self: CreatingAccountNewSeedPhraseState, controller: Co
|
|||
|
||||
proc doMigration(self: CreatingAccountNewSeedPhraseState, controller: Controller) =
|
||||
let kpForProcessing = controller.getKeyPairForProcessing()
|
||||
var kpDto = KeyPairDto(keycardUid: controller.getKeycardUid(),
|
||||
var kpDto = KeycardDto(keycardUid: controller.getKeycardUid(),
|
||||
keycardName: kpForProcessing.getName(),
|
||||
keycardLocked: false,
|
||||
accountsAddresses: self.addresses,
|
||||
keyUid: kpForProcessing.getKeyUid())
|
||||
controller.addMigratedKeyPair(kpDto)
|
||||
controller.addKeycardOrAccounts(kpDto)
|
||||
|
||||
proc runStoreMetadataFlow(self: CreatingAccountNewSeedPhraseState, controller: Controller) =
|
||||
let kpForProcessing = controller.getKeyPairForProcessing()
|
||||
|
@ -79,7 +79,7 @@ method executePrePrimaryStateCommand*(self: CreatingAccountNewSeedPhraseState, c
|
|||
controller.runDeriveAccountFlow(bip44Paths = self.paths, controller.getPin())
|
||||
|
||||
method executePreSecondaryStateCommand*(self: CreatingAccountNewSeedPhraseState, controller: Controller) =
|
||||
## Secondary action is called after each async action during migration process, in this case after `addMigratedKeyPair`.
|
||||
## Secondary action is called after each async action during migration process, in this case after `addKeycardOrAccounts`.
|
||||
if self.flowType == FlowType.SetupNewKeycardNewSeedPhrase:
|
||||
if controller.getAddingMigratedKeypairSuccess():
|
||||
self.runStoreMetadataFlow(controller)
|
||||
|
|
|
@ -62,12 +62,12 @@ proc addAccountsToWallet(self: CreatingAccountOldSeedPhraseState, controller: Co
|
|||
|
||||
proc doMigration(self: CreatingAccountOldSeedPhraseState, controller: Controller) =
|
||||
let kpForProcessing = controller.getKeyPairForProcessing()
|
||||
var kpDto = KeyPairDto(keycardUid: controller.getKeycardUid(),
|
||||
var kpDto = KeycardDto(keycardUid: controller.getKeycardUid(),
|
||||
keycardName: kpForProcessing.getName(),
|
||||
keycardLocked: false,
|
||||
accountsAddresses: self.addresses,
|
||||
keyUid: kpForProcessing.getKeyUid())
|
||||
controller.addMigratedKeyPair(kpDto)
|
||||
controller.addKeycardOrAccounts(kpDto)
|
||||
|
||||
proc runStoreMetadataFlow(self: CreatingAccountOldSeedPhraseState, controller: Controller) =
|
||||
let kpForProcessing = controller.getKeyPairForProcessing()
|
||||
|
@ -79,7 +79,7 @@ method executePrePrimaryStateCommand*(self: CreatingAccountOldSeedPhraseState, c
|
|||
controller.runDeriveAccountFlow(bip44Paths = self.paths, controller.getPin())
|
||||
|
||||
method executePreSecondaryStateCommand*(self: CreatingAccountOldSeedPhraseState, controller: Controller) =
|
||||
## Secondary action is called after each async action during migration process, in this case after `addMigratedKeyPair`.
|
||||
## Secondary action is called after each async action during migration process, in this case after `addKeycardOrAccounts`.
|
||||
if self.flowType == FlowType.SetupNewKeycardOldSeedPhrase:
|
||||
if controller.getAddingMigratedKeypairSuccess():
|
||||
self.runStoreMetadataFlow(controller)
|
||||
|
|
|
@ -28,7 +28,7 @@ method executePrePrimaryStateCommand*(self: EnterSeedPhraseState, controller: Co
|
|||
if self.verifiedSeedPhrase:
|
||||
## should always be true, since it's not possible to do primary command otherwise (button is disabled on the UI)
|
||||
let keyUid = controller.getKeyUidForSeedPhrase(sp)
|
||||
self.keyPairAlreadyMigrated = controller.getMigratedKeyPairByKeyUid(keyUid).len > 0
|
||||
self.keyPairAlreadyMigrated = controller.getKeycardByKeyUid(keyUid).len > 0
|
||||
if self.keyPairAlreadyMigrated:
|
||||
controller.prepareKeyPairForProcessing(keyUid)
|
||||
return
|
||||
|
|
|
@ -33,12 +33,12 @@ proc addAccountsToWallet(self: ImportingFromKeycardState, controller: Controller
|
|||
|
||||
proc doMigration(self: ImportingFromKeycardState, controller: Controller) =
|
||||
let kpForProcessing = controller.getKeyPairForProcessing()
|
||||
var kpDto = KeyPairDto(keycardUid: controller.getKeycardUid(),
|
||||
var kpDto = KeycardDto(keycardUid: controller.getKeycardUid(),
|
||||
keycardName: kpForProcessing.getName(),
|
||||
keycardLocked: false,
|
||||
accountsAddresses: self.addresses,
|
||||
keyUid: kpForProcessing.getKeyUid())
|
||||
controller.addMigratedKeyPair(kpDto)
|
||||
controller.addKeycardOrAccounts(kpDto)
|
||||
|
||||
method getNextPrimaryState*(self: ImportingFromKeycardState, controller: Controller): State =
|
||||
if self.flowType == FlowType.ImportFromKeycard:
|
||||
|
|
|
@ -22,7 +22,7 @@ proc delete*(self: MigratingKeyPairState) =
|
|||
|
||||
proc doMigration(self: MigratingKeyPairState, controller: Controller) =
|
||||
let selectedKeyPairDto = controller.getSelectedKeyPairDto()
|
||||
controller.addMigratedKeyPair(selectedKeyPairDto)
|
||||
controller.addKeycardOrAccounts(selectedKeyPairDto)
|
||||
|
||||
proc doConversion(self: MigratingKeyPairState, controller: Controller) =
|
||||
let password = controller.getPassword()
|
||||
|
|
|
@ -5,7 +5,7 @@ from ../../../../../app_service/service/keycard/service import KCSFlowType
|
|||
from ../../../../../app_service/service/keycard/service import PINLengthForStatusApp
|
||||
from ../../../../../app_service/service/keycard/service import PUKLengthForStatusApp
|
||||
import ../../../../../app_service/common/account_constants
|
||||
import ../../../../../app_service/service/wallet_account/key_pair_dto
|
||||
import ../../../../../app_service/service/wallet_account/keycard_dto
|
||||
import ../controller
|
||||
import ../../../shared_models/[keypair_model]
|
||||
import state
|
||||
|
|
|
@ -229,7 +229,7 @@ proc handleKeycardSyncing[T](self: Module[T]) =
|
|||
self.controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false)
|
||||
return
|
||||
if eventType == ResponseTypeValueKeycardFlowResult and flowEvent.error.len == 0:
|
||||
var kpDto = KeyPairDto(keycardUid: flowEvent.instanceUID,
|
||||
var kpDto = KeycardDto(keycardUid: flowEvent.instanceUID,
|
||||
keycardName: flowEvent.cardMetadata.name,
|
||||
keycardLocked: false,
|
||||
accountsAddresses: @[],
|
||||
|
@ -269,7 +269,7 @@ proc handleKeycardSyncing[T](self: Module[T]) =
|
|||
if accountsToRemove.len > 0:
|
||||
self.controller.removeMigratedAccountsForKeycard(kpDto.keyUid, kpDto.keycardUid, accountsToRemove)
|
||||
if kpDto.accountsAddresses.len > 0:
|
||||
self.controller.addMigratedKeyPair(kpDto)
|
||||
self.controller.addKeycardOrAccounts(kpDto)
|
||||
# if all accounts are removed from the app, there is no point in storing empty accounts list to a keycard, cause in that case
|
||||
# keypair which is on that keycard won't be known to the app, that means keypair was removed from the app
|
||||
if activeValidPathsToStoreToAKeycard.len > 0:
|
||||
|
@ -394,7 +394,7 @@ method onKeycardResponse*[T](self: Module[T], keycardFlowType: string, keycardEv
|
|||
|
||||
proc prepareKeyPairItemForAuthentication[T](self: Module[T], keyUid: string) =
|
||||
var item = newKeyPairItem()
|
||||
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
|
||||
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllKnownKeycardsGroupedByKeyUid(),
|
||||
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = false)
|
||||
for it in items:
|
||||
if it.getKeyUid() == keyUid:
|
||||
|
@ -416,7 +416,7 @@ method setKeyPairForProcessing*[T](self: Module[T], item: KeyPairItem) =
|
|||
|
||||
method prepareKeyPairForProcessing*[T](self: Module[T], keyUid: string, keycardUid = "") =
|
||||
var item = newKeyPairItem()
|
||||
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
|
||||
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllKnownKeycardsGroupedByKeyUid(),
|
||||
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = false)
|
||||
for it in items:
|
||||
if it.getKeyUid() == keyUid:
|
||||
|
@ -447,7 +447,7 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path
|
|||
self.controller.runGetMetadataFlow(resolveAddress = true)
|
||||
return
|
||||
if flowToRun == FlowType.SetupNewKeycard:
|
||||
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
|
||||
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllKnownKeycardsGroupedByKeyUid(),
|
||||
excludeAlreadyMigratedPairs = true, excludePrivateKeyKeypairs = false)
|
||||
self.view.createKeyPairModel(items)
|
||||
self.view.setCurrentState(newSelectExistingKeyPairState(flowToRun, nil))
|
||||
|
@ -524,15 +524,15 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path
|
|||
|
||||
method setSelectedKeyPair*[T](self: Module[T], item: KeyPairItem) =
|
||||
var paths: seq[string]
|
||||
var keyPairDto = KeyPairDto(keycardUid: "", # will be set during migration
|
||||
var keycardDto = KeycardDto(keycardUid: "", # will be set during migration
|
||||
keycardName: item.getName(),
|
||||
keycardLocked: item.getLocked(),
|
||||
keyUid: item.getKeyUid())
|
||||
for a in item.getAccountsModel().getItems():
|
||||
paths.add(a.getPath())
|
||||
keyPairDto.accountsAddresses.add(a.getAddress())
|
||||
keycardDto.accountsAddresses.add(a.getAddress())
|
||||
self.controller.setSelectedKeyPair(isProfile = item.getPairType() == KeyPairType.Profile.int,
|
||||
paths, keyPairDto)
|
||||
paths, keycardDto)
|
||||
self.setKeyPairForProcessing(item)
|
||||
|
||||
proc updateKeyPairItemIfDataAreKnown[T](self: Module[T], address: string, item: var KeyPairItem): bool =
|
||||
|
|
|
@ -86,51 +86,51 @@ const prepareTokensTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
|||
arg.finish(output)
|
||||
|
||||
#################################################
|
||||
# Async add migrated keypair
|
||||
# Async add new keycard or accounts
|
||||
#################################################
|
||||
|
||||
type
|
||||
AddMigratedKeyPairTaskArg* = ref object of QObjectTaskArg
|
||||
keyPair: KeyPairDto
|
||||
AddKeycardOrAddAccountsIfKeycardIsAddedTaskArg* = ref object of QObjectTaskArg
|
||||
keycard: KeycardDto
|
||||
|
||||
const addMigratedKeyPairTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AddMigratedKeyPairTaskArg](argEncoded)
|
||||
const addKeycardOrAddAccountsIfKeycardIsAddedTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AddKeycardOrAddAccountsIfKeycardIsAddedTaskArg](argEncoded)
|
||||
try:
|
||||
let response = backend.addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded(
|
||||
arg.keyPair.keycardUid,
|
||||
arg.keyPair.keycardName,
|
||||
arg.keyPair.keyUid,
|
||||
arg.keyPair.accountsAddresses
|
||||
let response = backend.addKeycardOrAddAccountsIfKeycardIsAdded(
|
||||
arg.keycard.keycardUid,
|
||||
arg.keycard.keycardName,
|
||||
arg.keycard.keyUid,
|
||||
arg.keycard.accountsAddresses
|
||||
)
|
||||
let success = responseHasNoErrors("addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded", response)
|
||||
let success = responseHasNoErrors("addKeycardOrAddAccountsIfKeycardIsAdded", response)
|
||||
let responseJson = %*{
|
||||
"success": success,
|
||||
"keyPair": arg.keyPair.toJsonNode()
|
||||
"keycard": arg.keycard.toJsonNode()
|
||||
}
|
||||
arg.finish(responseJson)
|
||||
except Exception as e:
|
||||
error "error adding new keypair: ", message = e.msg
|
||||
error "error adding new keycard: ", message = e.msg
|
||||
arg.finish("")
|
||||
|
||||
#################################################
|
||||
# Async add migrated keypair
|
||||
# Async remove migrated accounts for keycard
|
||||
#################################################
|
||||
|
||||
type
|
||||
RemoveMigratedAccountsForKeycardTaskArg* = ref object of QObjectTaskArg
|
||||
keyPair: KeyPairDto
|
||||
keycard: KeycardDto
|
||||
|
||||
const removeMigratedAccountsForKeycardTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[RemoveMigratedAccountsForKeycardTaskArg](argEncoded)
|
||||
try:
|
||||
let response = backend.removeMigratedAccountsForKeycard(
|
||||
arg.keyPair.keycardUid,
|
||||
arg.keyPair.accountsAddresses
|
||||
arg.keycard.keycardUid,
|
||||
arg.keycard.accountsAddresses
|
||||
)
|
||||
let success = responseHasNoErrors("removeMigratedAccountsForKeycard", response)
|
||||
let responseJson = %*{
|
||||
"success": success,
|
||||
"keyPair": arg.keyPair.toJsonNode()
|
||||
"keycard": arg.keycard.toJsonNode()
|
||||
}
|
||||
arg.finish(responseJson)
|
||||
except Exception as e:
|
||||
|
|
|
@ -20,7 +20,7 @@ const KeycardActionUnlocked* = "UNLOCKED"
|
|||
const KeycardActionUidUpdated* = "UID_UPDATED"
|
||||
const KeycardActionNameChanged* = "NAME_CHANGED"
|
||||
|
||||
type KeyPairDto* = object
|
||||
type KeycardDto* = object
|
||||
keycardUid*: string
|
||||
keycardName*: string
|
||||
keycardLocked*: bool
|
||||
|
@ -30,10 +30,10 @@ type KeyPairDto* = object
|
|||
type KeycardActionDto* = object
|
||||
action*: string
|
||||
oldKeycardUid*: string
|
||||
keycard*: KeyPairDto
|
||||
keycard*: KeycardDto
|
||||
|
||||
proc toKeyPairDto*(jsonObj: JsonNode): KeyPairDto =
|
||||
result = KeyPairDto()
|
||||
proc toKeycardDto*(jsonObj: JsonNode): KeycardDto =
|
||||
result = KeycardDto()
|
||||
discard jsonObj.getProp(ParamKeycardUid, result.keycardUid)
|
||||
discard jsonObj.getProp(ParamKeycardName, result.keycardName)
|
||||
discard jsonObj.getProp(ParamKeycardLocked, result.keycardLocked)
|
||||
|
@ -51,9 +51,9 @@ proc toKeycardActionDto*(jsonObj: JsonNode): KeycardActionDto =
|
|||
|
||||
var keycardObj: JsonNode
|
||||
if(jsonObj.getProp("keycard", keycardObj)):
|
||||
result.keycard = toKeyPairDto(keycardObj)
|
||||
result.keycard = toKeycardDto(keycardObj)
|
||||
|
||||
proc toJsonNode*(self: KeyPairDto): JsonNode =
|
||||
proc toJsonNode*(self: KeycardDto): JsonNode =
|
||||
result = %* {
|
||||
ParamKeycardUid: self.keycardUid,
|
||||
ParamKeycardName: self.keycardName,
|
|
@ -8,7 +8,7 @@ import ../network/service as network_service
|
|||
import ../../common/[utils]
|
||||
import ../../../app/global/global_singleton
|
||||
|
||||
import dto, derived_address, key_pair_dto
|
||||
import dto, derived_address, keycard_dto
|
||||
|
||||
import ../../../app/core/eventemitter
|
||||
import ../../../app/core/signals/types
|
||||
|
@ -19,7 +19,7 @@ import ../../../backend/eth as status_go_eth
|
|||
import ../../../backend/transactions as status_go_transactions
|
||||
import ../../../constants as main_constants
|
||||
|
||||
export dto, derived_address, key_pair_dto
|
||||
export dto, derived_address, keycard_dto
|
||||
|
||||
logScope:
|
||||
topics = "wallet-account-service"
|
||||
|
@ -96,7 +96,7 @@ type TokensPerAccountArgs* = ref object of Args
|
|||
type KeycardActivityArgs* = ref object of Args
|
||||
success*: bool
|
||||
oldKeycardUid*: string
|
||||
keyPair*: KeyPairDto
|
||||
keycard*: KeycardDto
|
||||
|
||||
proc responseHasNoErrors(procName: string, response: RpcResponse[JsonNode]): bool =
|
||||
var errMsg = ""
|
||||
|
@ -121,7 +121,6 @@ QtObject:
|
|||
accountsService: accounts_service.Service
|
||||
tokenService: token_service.Service
|
||||
networkService: network_service.Service
|
||||
processedKeyPair: KeyPairDto
|
||||
walletAccounts: OrderedTable[string, WalletAccountDto]
|
||||
|
||||
# Forward declaration
|
||||
|
@ -130,8 +129,8 @@ QtObject:
|
|||
proc startWallet(self: Service)
|
||||
proc handleWalletAccount(self: Service, account: WalletAccountDto)
|
||||
proc handleKeycardActions(self: Service, keycardActions: seq[KeycardActionDto])
|
||||
proc handleKeycardsState(self: Service, keycardsState: seq[KeyPairDto])
|
||||
proc getAllKnownKeycards*(self: Service): seq[KeyPairDto]
|
||||
proc handleKeycardsState(self: Service, keycardsState: seq[KeycardDto])
|
||||
proc getAllKnownKeycards*(self: Service): seq[KeycardDto]
|
||||
proc removeMigratedAccountsForKeycard*(self: Service, keyUid: string, keycardUid: string, accountsToRemove: seq[string])
|
||||
|
||||
proc delete*(self: Service) =
|
||||
|
@ -703,57 +702,57 @@ QtObject:
|
|||
|
||||
return 0.0
|
||||
|
||||
proc addMigratedKeyPairAsync*(self: Service, keyPair: KeyPairDto) =
|
||||
let arg = AddMigratedKeyPairTaskArg(
|
||||
tptr: cast[ByteAddress](addMigratedKeyPairTask),
|
||||
proc addKeycardOrAccountsAsync*(self: Service, keycard: KeycardDto) =
|
||||
let arg = AddKeycardOrAddAccountsIfKeycardIsAddedTaskArg(
|
||||
tptr: cast[ByteAddress](addKeycardOrAddAccountsIfKeycardIsAddedTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: "onMigratedKeyPairAdded",
|
||||
keyPair: keyPair
|
||||
slot: "onKeycardAdded",
|
||||
keycard: keycard
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
proc emitAddKeycardAddAccountsChange(self: Service, success: bool, keyPair: KeyPairDto) =
|
||||
proc emitAddKeycardAddAccountsChange(self: Service, success: bool, keycard: KeycardDto) =
|
||||
let data = KeycardActivityArgs(
|
||||
success: success,
|
||||
keyPair: keyPair
|
||||
keycard: keycard
|
||||
)
|
||||
self.events.emit(SIGNAL_NEW_KEYCARD_SET, data)
|
||||
|
||||
proc onMigratedKeyPairAdded*(self: Service, response: string) {.slot.} =
|
||||
proc onKeycardAdded*(self: Service, response: string) {.slot.} =
|
||||
try:
|
||||
let responseObj = response.parseJson
|
||||
var keyPair: KeyPairDto
|
||||
var keycard: KeycardDto
|
||||
var success = false
|
||||
discard responseObj.getProp("success", success)
|
||||
if success:
|
||||
var kpJson: JsonNode
|
||||
if responseObj.getProp("keyPair", kpJson):
|
||||
keyPair = kpJson.toKeyPairDto()
|
||||
self.emitAddKeycardAddAccountsChange(success, keyPair)
|
||||
if responseObj.getProp("keycard", kpJson):
|
||||
keycard = kpJson.toKeycardDto()
|
||||
self.emitAddKeycardAddAccountsChange(success, keycard)
|
||||
except Exception as e:
|
||||
error "error handilng migrated keypair response", errDesription=e.msg
|
||||
self.emitAddKeycardAddAccountsChange(success = false, KeyPairDto())
|
||||
error "error handilng migrated keycard response", errDesription=e.msg
|
||||
self.emitAddKeycardAddAccountsChange(success = false, KeycardDto())
|
||||
|
||||
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto): bool =
|
||||
proc addKeycardOrAccounts*(self: Service, keycard: KeycardDto): bool =
|
||||
try:
|
||||
let response = backend.addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded(
|
||||
keyPair.keycardUid,
|
||||
keyPair.keycardName,
|
||||
keyPair.keyUid,
|
||||
keyPair.accountsAddresses
|
||||
let response = backend.addKeycardOrAddAccountsIfKeycardIsAdded(
|
||||
keycard.keycardUid,
|
||||
keycard.keycardName,
|
||||
keycard.keyUid,
|
||||
keycard.accountsAddresses
|
||||
)
|
||||
result = responseHasNoErrors("addMigratedKeyPair", response)
|
||||
result = responseHasNoErrors("addKeycardOrAccounts", response)
|
||||
if result:
|
||||
self.emitAddKeycardAddAccountsChange(success = true, keyPair)
|
||||
self.emitAddKeycardAddAccountsChange(success = true, keycard)
|
||||
except Exception as e:
|
||||
error "error: ", procName="addMigratedKeyPair", errName = e.name, errDesription = e.msg
|
||||
error "error: ", procName="addKeycardOrAccounts", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc removeMigratedAccountsForKeycard*(self: Service, keyUid: string, keycardUid: string, accountsToRemove: seq[string]) =
|
||||
let arg = RemoveMigratedAccountsForKeycardTaskArg(
|
||||
tptr: cast[ByteAddress](removeMigratedAccountsForKeycardTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: "onMigratedAccountsForKeycardRemoved",
|
||||
keyPair: KeyPairDto(keyUid: keyUid, keycardUid: keycardUid, accountsAddresses: accountsToRemove)
|
||||
keycard: KeycardDto(keyUid: keyUid, keycardUid: keycardUid, accountsAddresses: accountsToRemove)
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
|
@ -761,34 +760,34 @@ QtObject:
|
|||
removedAccounts: seq[string]) =
|
||||
let data = KeycardActivityArgs(
|
||||
success: success,
|
||||
keyPair: KeyPairDto(keyUid: keyUid, keycardUid: keycardUid, accountsAddresses: removedAccounts)
|
||||
keycard: KeycardDto(keyUid: keyUid, keycardUid: keycardUid, accountsAddresses: removedAccounts)
|
||||
)
|
||||
self.events.emit(SIGNAL_KEYCARD_ACCOUNTS_REMOVED, data)
|
||||
|
||||
proc onMigratedAccountsForKeycardRemoved*(self: Service, response: string) {.slot.} =
|
||||
try:
|
||||
let responseObj = response.parseJson
|
||||
var keyPair: KeyPairDto
|
||||
var keycard: KeycardDto
|
||||
var success = false
|
||||
discard responseObj.getProp("success", success)
|
||||
if success:
|
||||
var kpJson: JsonNode
|
||||
if responseObj.getProp("keyPair", kpJson):
|
||||
keyPair = kpJson.toKeyPairDto()
|
||||
self.emitKeycardRemovedAccountsChange(success, keyPair.keyUid, keyPair.keycardUid, keyPair.accountsAddresses)
|
||||
if responseObj.getProp("keycard", kpJson):
|
||||
keycard = kpJson.toKeycardDto()
|
||||
self.emitKeycardRemovedAccountsChange(success, keycard.keyUid, keycard.keycardUid, keycard.accountsAddresses)
|
||||
except Exception as e:
|
||||
error "error handilng migrated keypair response", errDesription=e.msg
|
||||
error "error handilng migrated keycard response", errDesription=e.msg
|
||||
self.emitKeycardRemovedAccountsChange(success = false, keyUid = "", keycardUid = "", removedAccounts = @[])
|
||||
|
||||
proc getAllKnownKeycards*(self: Service): seq[KeyPairDto] =
|
||||
proc getAllKnownKeycards*(self: Service): seq[KeycardDto] =
|
||||
try:
|
||||
let response = backend.getAllKnownKeycards()
|
||||
if responseHasNoErrors("getAllKnownKeycards", response):
|
||||
return map(response.result.getElems(), proc(x: JsonNode): KeyPairDto = toKeyPairDto(x))
|
||||
return map(response.result.getElems(), proc(x: JsonNode): KeycardDto = toKeycardDto(x))
|
||||
except Exception as e:
|
||||
error "error: ", procName="getAllKnownKeycards", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc getKeycardWithKeycardUid*(self: Service, keycardUid: string): KeyPairDto =
|
||||
proc getKeycardWithKeycardUid*(self: Service, keycardUid: string): KeycardDto =
|
||||
let allKnownKeycards = self.getAllKnownKeycards()
|
||||
let keycardsWithKeycardUid = allKnownKeycards.filter(kp => kp.keycardUid == keycardUid)
|
||||
if keycardsWithKeycardUid.len == 0:
|
||||
|
@ -798,24 +797,24 @@ QtObject:
|
|||
return
|
||||
return keycardsWithKeycardUid[0]
|
||||
|
||||
proc getAllMigratedKeyPairs*(self: Service): seq[KeyPairDto] =
|
||||
proc getAllKnownKeycardsGroupedByKeyUid*(self: Service): seq[KeycardDto] =
|
||||
try:
|
||||
let response = backend.getAllMigratedKeyPairs()
|
||||
if responseHasNoErrors("getAllMigratedKeyPairs", response):
|
||||
return map(response.result.getElems(), proc(x: JsonNode): KeyPairDto = toKeyPairDto(x))
|
||||
let response = backend.getAllKnownKeycardsGroupedByKeyUid()
|
||||
if responseHasNoErrors("getAllKnownKeycardsGroupedByKeyUid", response):
|
||||
return map(response.result.getElems(), proc(x: JsonNode): KeycardDto = toKeycardDto(x))
|
||||
except Exception as e:
|
||||
error "error: ", procName="getAllMigratedKeyPairs", errName = e.name, errDesription = e.msg
|
||||
error "error: ", procName="getAllKnownKeycardsGroupedByKeyUid", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc getMigratedKeyPairByKeyUid*(self: Service, keyUid: string): seq[KeyPairDto] =
|
||||
proc getKeycardByKeyUid*(self: Service, keyUid: string): seq[KeycardDto] =
|
||||
try:
|
||||
let response = backend.getMigratedKeyPairByKeyUID(keyUid)
|
||||
if responseHasNoErrors("getMigratedKeyPairByKeyUid", response):
|
||||
return map(response.result.getElems(), proc(x: JsonNode): KeyPairDto = toKeyPairDto(x))
|
||||
let response = backend.getKeycardByKeyUid(keyUid)
|
||||
if responseHasNoErrors("getKeycardByKeyUid", response):
|
||||
return map(response.result.getElems(), proc(x: JsonNode): KeycardDto = toKeycardDto(x))
|
||||
except Exception as e:
|
||||
error "error: ", procName="getMigratedKeyPairByKeyUid", errName = e.name, errDesription = e.msg
|
||||
error "error: ", procName="getKeycardByKeyUid", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc emitKeycardNameChange(self: Service, keycardUid: string, name: string) =
|
||||
let data = KeycardActivityArgs(success: true, keyPair: KeyPairDto(keycardUid: keycardUid, keycardName: name))
|
||||
let data = KeycardActivityArgs(success: true, keycard: KeycardDto(keycardUid: keycardUid, keycardName: name))
|
||||
self.events.emit(SIGNAL_KEYCARD_NAME_CHANGED, data)
|
||||
|
||||
proc updateKeycardName*(self: Service, keycardUid: string, name: string): bool =
|
||||
|
@ -828,7 +827,7 @@ QtObject:
|
|||
error "error: ", procName="updateKeycardName", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc emitKeycardLockedChange(self: Service, keyUid: string, keycardUid: string) =
|
||||
let data = KeycardActivityArgs(success: true, keyPair: KeyPairDto(keyUid: keyUid, keycardUid: keycardUid))
|
||||
let data = KeycardActivityArgs(success: true, keycard: KeycardDto(keyUid: keyUid, keycardUid: keycardUid))
|
||||
self.events.emit(SIGNAL_KEYCARD_LOCKED, data)
|
||||
|
||||
proc setKeycardLocked*(self: Service, keyUid: string, keycardUid: string): bool =
|
||||
|
@ -841,7 +840,7 @@ QtObject:
|
|||
error "error: ", procName="setKeycardLocked", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc emitKeycardUnlockedChange(self: Service, keyUid: string, keycardUid: string) =
|
||||
let data = KeycardActivityArgs(success: true, keyPair: KeyPairDto(keyUid: keyUid, keycardUid: keycardUid))
|
||||
let data = KeycardActivityArgs(success: true, keycard: KeycardDto(keyUid: keyUid, keycardUid: keycardUid))
|
||||
self.events.emit(SIGNAL_KEYCARD_UNLOCKED, data)
|
||||
|
||||
proc setKeycardUnlocked*(self: Service, keyUid: string, keycardUid: string): bool =
|
||||
|
@ -854,7 +853,7 @@ QtObject:
|
|||
error "error: ", procName="setKeycardUnlocked", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc emitUpdateKeycardUidChange(self: Service, oldKeycardUid: string, newKeycardUid: string) =
|
||||
let data = KeycardActivityArgs(success: true, oldKeycardUid: oldKeycardUid, keyPair: KeyPairDto(keycardUid: newKeycardUid))
|
||||
let data = KeycardActivityArgs(success: true, oldKeycardUid: oldKeycardUid, keycard: KeycardDto(keycardUid: newKeycardUid))
|
||||
self.events.emit(SIGNAL_KEYCARD_UID_UPDATED, data)
|
||||
|
||||
proc updateKeycardUid*(self: Service, oldKeycardUid: string, newKeycardUid: string): bool =
|
||||
|
@ -867,7 +866,7 @@ QtObject:
|
|||
error "error: ", procName="updateKeycardUid", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc emitDeleteKeycardChange(self: Service, keycardUid: string) =
|
||||
let data = KeycardActivityArgs(success: true, keyPair: KeyPairDto(keycardUid: keycardUid))
|
||||
let data = KeycardActivityArgs(success: true, keycard: KeycardDto(keycardUid: keycardUid))
|
||||
self.events.emit(SIGNAL_KEYCARD_DELETED, data)
|
||||
|
||||
proc deleteKeycard*(self: Service, keycardUid: string): bool =
|
||||
|
@ -914,7 +913,7 @@ QtObject:
|
|||
else:
|
||||
error "unsupported action received", action=kcAction.action
|
||||
|
||||
proc handleKeycardsState(self: Service, keycardsState: seq[KeyPairDto]) =
|
||||
proc handleKeycardsState(self: Service, keycardsState: seq[KeycardDto]) =
|
||||
if keycardsState.len == 0:
|
||||
return
|
||||
let data = KeycardActivityArgs(success: true)
|
||||
|
|
|
@ -188,7 +188,7 @@ rpc(fetchMarketValues, "wallet"):
|
|||
rpc(fetchTokenDetails, "wallet"):
|
||||
symbols: seq[string]
|
||||
|
||||
rpc(addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded, "accounts"):
|
||||
rpc(addKeycardOrAddAccountsIfKeycardIsAdded, "accounts"):
|
||||
keycardUid: string
|
||||
keyPairName: string
|
||||
keyUid: string
|
||||
|
@ -201,10 +201,10 @@ rpc(removeMigratedAccountsForKeycard, "accounts"):
|
|||
rpc(getAllKnownKeycards, "accounts"):
|
||||
discard
|
||||
|
||||
rpc(getAllMigratedKeyPairs, "accounts"):
|
||||
rpc(getAllKnownKeycardsGroupedByKeyUID, "accounts"):
|
||||
discard
|
||||
|
||||
rpc(getMigratedKeyPairByKeyUID, "accounts"):
|
||||
rpc(getKeycardByKeyUID, "accounts"):
|
||||
keyUid: string
|
||||
|
||||
rpc(setKeycardName, "accounts"):
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 31144ed5a38589fd129945b634f54e800b39645a
|
||||
Subproject commit 189c7a691961ddb9ec649fde8982305f002d8af9
|
Loading…
Reference in New Issue