chore(@desktop/wallet): unused keycard signal removed

This commit is contained in:
Sale Djenic 2023-03-22 16:45:43 +01:00 committed by saledjenic
parent a01ff000ea
commit bd9652cec8
3 changed files with 3 additions and 57 deletions

View File

@ -433,15 +433,6 @@ proc setPinForKeycardCopy*(self: Controller, value: string) =
proc getPinForKeycardCopy*(self: Controller): string =
return self.tmpKeycardCopyPin
proc notifyAboutGeneratedWalletAccount*(self: Controller, generatedWalletAccount: GeneratedWalletAccount, derivedFrom: string) =
let data = SharedKeycarModuleUserAuthenticatedAndWalletAddressGeneratedArgs(uniqueIdentifier: self.uniqueIdentifier,
address: generatedWalletAccount.address,
publicKey: generatedWalletAccount.publicKey,
derivedFrom: derivedFrom,
password: self.getPassword()
)
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED_AND_WALLET_ADDRESS_GENERATED, data)
proc runSharedModuleFlow*(self: Controller, flowToRun: FlowType, keyUid = "") =
self.delegate.runFlow(flowToRun, keyUid)

View File

@ -4,8 +4,6 @@ from ../../../../app_service/service/keycard/service import KeycardEvent, CardMe
from ../../../../app_service/service/wallet_account/service as wallet_account_service import WalletTokenDto
import ../../shared_models/keypair_item
const SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED_AND_WALLET_ADDRESS_GENERATED* = "sharedKeycarModuleUserAuthenticatedAndWalletAddressGenerated"
const SIGNAL_SHARED_KEYCARD_MODULE_DISPLAY_POPUP* = "sharedKeycarModuleDisplayPopup"
const SIGNAL_SHARED_KEYCARD_MODULE_FLOW_TERMINATED* = "sharedKeycarModuleFlowTerminated"
const SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER* = "sharedKeycarModuleAuthenticateUser"
@ -24,7 +22,7 @@ const SIGNAL_SHARED_KEYCARD_MODULE_KEYCARD_SYNC_TERMINATED* = "sharedKeycarModul
## result, when authentication gets done `SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED` signal with properly set `SharedKeycarModuleArgs`
## and props there will be emitted:
## -- `uniqueIdentifier` - will be the same as one used for running authentication process
## -- in case of success of a regular user authentication `password` will be sent, otherwise it will be empty
## -- in case of success of a regular user authentication `keyUid`, `password` will be sent, otherwise it will be empty
## -- in case of success of a keycard user authentication `keyUid`, `pin` and `password` will be sent, otherwise they will be empty
##
## TLDR: when you need to authenticate user, from the module where it's needed you have to send `SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER`
@ -48,13 +46,6 @@ type
SharedKeycarModuleAuthenticationArgs* = ref object of SharedKeycarModuleBaseArgs
keyUid*: string
type
SharedKeycarModuleUserAuthenticatedAndWalletAddressGeneratedArgs* = ref object of Args
uniqueIdentifier*: string
address*: string
publicKey*: string
derivedFrom*: string
password*: string
type FlowType* {.pure.} = enum
General = "General"
@ -70,7 +61,6 @@ type FlowType* {.pure.} = enum
ChangeKeycardPin = "ChangeKeycardPin"
ChangeKeycardPuk = "ChangeKeycardPuk"
ChangePairingCode = "ChangePairingCode"
AuthenticateAndDeriveAccountAddress = "AuthenticateAndDeriveAccountAddress"
CreateCopyOfAKeycard = "CreateCopyOfAKeycard"
# For the following flows we don't run card syncing.
@ -82,8 +72,7 @@ const FlowsWeShouldNotTryAKeycardSyncFor* = @[
FlowType.SetupNewKeycardNewSeedPhrase,
FlowType.SetupNewKeycardOldSeedPhrase,
FlowType.ImportFromKeycard,
FlowType.Authentication,
FlowType.AuthenticateAndDeriveAccountAddress
FlowType.Authentication
]
type

View File

@ -23,12 +23,6 @@ export io_interface
logScope:
topics = "keycard-popup-module"
type DerivingAccountDetails = object
keyUid: string
path: string
deriveAddressAfterAuthentication: bool
addressRequested: bool
type
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
@ -38,7 +32,6 @@ type
initialized: bool
tmpLocalState: State # used when flow is run, until response arrives to determine next state appropriatelly
authenticationPopupIsAlreadyRunning: bool
derivingAccountDetails: DerivingAccountDetails
proc newModule*[T](delegate: T,
uniqueIdentifier: string,
@ -59,8 +52,6 @@ proc newModule*[T](delegate: T,
networkService, privacyService, accountsService, walletAccountService, keychainService)
result.initialized = false
result.authenticationPopupIsAlreadyRunning = false
result.derivingAccountDetails.deriveAddressAfterAuthentication = false
result.derivingAccountDetails.addressRequested = false
method delete*[T](self: Module[T]) =
self.view.delete
@ -373,13 +364,6 @@ method onKeycardResponse*[T](self: Module[T], keycardFlowType: string, keycardEv
if self.controller.keycardSyncingInProgress():
self.handleKeycardSyncing()
return
if self.derivingAccountDetails.deriveAddressAfterAuthentication and
self.derivingAccountDetails.addressRequested:
# clearing...
self.derivingAccountDetails = DerivingAccountDetails()
# notify about generated address
self.controller.notifyAboutGeneratedWalletAccount(keycardEvent.generatedWalletAccount, keycardEvent.masterKeyAddress)
return
## Check local state first, in case postponed flow is run
if not self.tmpLocalState.isNil:
let nextState = self.tmpLocalState.resolveKeycardNextState(keycardFlowType, keycardEvent, self.controller)
@ -512,16 +496,6 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path
self.tmpLocalState = newReadingKeycardState(flowToRun, nil)
self.controller.runChangePairingFlow()
return
if flowToRun == FlowType.AuthenticateAndDeriveAccountAddress:
self.prepareKeyPairForProcessing(keyUid) ## needed for keycard sync
self.derivingAccountDetails = DerivingAccountDetails(
keyUid: keyUid,
path: bip44Path,
deriveAddressAfterAuthentication: true,
addressRequested: false
)
self.controller.authenticateUser(keyUid)
return
if flowToRun == FlowType.CreateCopyOfAKeycard:
self.prepareKeyPairForProcessing(keyUid)
self.tmpLocalState = newReadingKeycardState(flowToRun, nil)
@ -588,9 +562,7 @@ proc buildKeyPairItemBasedOnCardMetadata[T](self: Module[T], cardMetadata: CardM
locked = false,
name = cardMetadata.name,
image = "",
icon = "keycard",
pairType = KeyPairType.Unknown,
derivedFrom = "")
icon = "keycard")
let currKp = self.getKeyPairForProcessing()
if not currKp.isNil:
result.item.setKeyUid(currKp.getKeyUid())
@ -615,12 +587,6 @@ method updateKeyPairHelper*[T](self: Module[T], cardMetadata: CardMetadata) =
self.view.setKeyPairHelper(item)
method onUserAuthenticated*[T](self: Module[T], password: string, pin: string) =
if self.derivingAccountDetails.deriveAddressAfterAuthentication:
self.derivingAccountDetails.addressRequested = true
self.controller.setPassword(password)
self.controller.setPin(pin) # we need to keep it in case new acc is added we need to sync accounts on the Keycard
self.controller.runDeriveAccountFlow(self.derivingAccountDetails.path, pin)
return
let flowType = self.getCurrentFlowType()
if flowType == FlowType.SetupNewKeycard:
self.controller.setPassword(password)