feat(@desktop/wallet): account Interaction - remove master key and accounts

Closes: #11707
This commit is contained in:
Sale Djenic 2023-07-28 15:12:46 +02:00 committed by saledjenic
parent d832a306a4
commit 2e1b60ab06
11 changed files with 70 additions and 2 deletions

View File

@ -37,6 +37,9 @@ proc renameKeypair*(self: Controller, keyUid: string, name: string) =
proc deleteAccount*(self: Controller, address: string) =
self.walletAccountService.deleteAccount(address)
proc deleteKeypair*(self: Controller, keyUid: string) =
self.walletAccountService.deleteKeypair(keyUid)
proc getKeycardsWithSameKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
return self.walletAccountService.getKeycardsWithSameKeyUid(keyUid)

View File

@ -19,6 +19,9 @@ method syncKeycard*(self: AccessInterface) {.base.} =
method deleteAccount*(self: AccessInterface, address: string) {.base.} =
raise newException(ValueError, "No implementation available")
method deleteKeypair*(self: AccessInterface, keyUid: string) {.base.} =
raise newException(ValueError, "No implementation available")
method refreshWalletAccounts*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -161,6 +161,9 @@ method moveAccountFinally*(self: Module, fromPosition: int, toPosition: int) =
method deleteAccount*(self: Module, address: string) =
self.controller.deleteAccount(address)
method deleteKeypair*(self: Module, keyUid: string) =
self.controller.deleteKeypair(keyUid)
method toggleIncludeWatchOnlyAccount*(self: Module) =
self.controller.toggleIncludeWatchOnlyAccount()

View File

@ -53,6 +53,9 @@ QtObject:
proc deleteAccount*(self: View, address: string) {.slot.} =
self.delegate.deleteAccount(address)
proc deleteKeypair*(self: View, keyUid: string) {.slot.} =
self.delegate.deleteKeypair(keyUid)
proc keyPairModel*(self: View): KeyPairModel =
return self.keyPairModel

View File

@ -474,6 +474,7 @@ proc loginLocalPairingAccount*(self: Controller) =
self.accountsService.login(self.localPairingStatus.account, self.localPairingStatus.password)
else:
var kcEvent = KeycardEvent()
kcEvent.keyUid = self.localPairingStatus.account.keyUid
kcEvent.whisperKey.privateKey = self.localPairingStatus.chatKey
kcEvent.encryptionKey.publicKey = self.localPairingStatus.password
discard self.accountsService.loginAccountKeycard(self.localPairingStatus.account, kcEvent)

View File

@ -556,6 +556,22 @@ QtObject:
except Exception as e:
error "error: ", procName="deleteAccount", errName = e.name, errDesription = e.msg
proc deleteKeypair*(self: Service, keyUid: string) =
try:
let localKeypairRelatedAccounts = self.getWalletAccountsForKeypair(keyUid)
if localKeypairRelatedAccounts.len == 0:
error "there are no known accounts", keyUid=keyUid, procName="deleteKeypair"
return
let response = status_go_accounts.deleteKeypair(keyUid)
if not response.error.isNil:
error "status-go error", procName="deleteKeypair", errCode=response.error.code, errDesription=response.error.message
return
self.updateAccountsPositions()
for acc in localKeypairRelatedAccounts:
self.removeAccountFromLocalStoreAndNotify(acc.address)
except Exception as e:
error "error: ", procName="deleteKeypair", errName = e.name, errDesription = e.msg
proc getCurrency*(self: Service): string =
return self.settingsService.getCurrency()

View File

@ -36,6 +36,10 @@ proc deleteAccount*(address: string): RpcResponse[JsonNode] {.raises: [Exception
let payload = %* [address]
return core.callPrivateRPC("accounts_deleteAccount", payload)
proc deleteKeypair*(keyUid: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [keyUid]
return core.callPrivateRPC("accounts_deleteKeypair", payload)
## Adds a new account and creates a Keystore file if password is provided, otherwise it only creates a new account. Notifies paired devices.
proc addAccount*(password, name, address, path, publicKey, keyUid, accountType, colorId, emoji: string):
RpcResponse[JsonNode] {.raises: [Exception].} =

View File

@ -20,6 +20,7 @@ Rectangle {
signal goToAccountView(var account)
signal toggleIncludeWatchOnlyAccount()
signal runRenameKeypairFlow()
signal runRemoveKeypairFlow()
QtObject {
id: d
@ -125,7 +126,7 @@ Rectangle {
icon.name: "delete"
icon.color: Theme.palette.dangerColor1
onTriggered: {
console.warn("TODO: remove master keys and associated accounts")
root.runRemoveKeypairFlow()
}
}
}

View File

@ -37,6 +37,10 @@ QtObject {
return accountsModule.deleteAccount(address)
}
function deleteKeypair(keyUid) {
return accountsModule.deleteKeypair(keyUid)
}
function updateAccount(address, accountName, colorId, emoji) {
return accountsModule.updateAccount(address, accountName, colorId, emoji)
}

View File

@ -7,6 +7,8 @@ import shared.panels 1.0
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import shared.popups 1.0
import shared.popups.addaccount 1.0
import "../../stores"
@ -112,6 +114,11 @@ Column {
renameKeypairPopup.accounts = model.keyPair.accounts
renameKeypairPopup.active = true
}
onRunRemoveKeypairFlow: {
removeKeypairPopup.keyUid = model.keyPair.keyUid
removeKeypairPopup.name = model.keyPair.name
removeKeypairPopup.active = true
}
}
}
}
@ -139,4 +146,27 @@ Column {
renameKeypairPopup.item.open()
}
}
Loader {
id: removeKeypairPopup
active: false
property string keyUid
property string name
sourceComponent: ConfirmationDialog {
headerSettings.title: qsTr("Confirm %1 Removal").arg(removeKeypairPopup.name)
confirmationText: qsTr("You will not be able to restore viewing access to any account of this keypair in the future unless you import this keypair again.")
confirmButtonLabel: qsTr("Remove keypair")
onConfirmButtonClicked: {
root.walletStore.deleteKeypair(removeKeypairPopup.keyUid)
removeKeypairPopup.active = false
}
}
onLoaded: {
removeKeypairPopup.item.open()
}
}
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 1df8c1c5110e7b3600ea8defecaf0447009c1b18
Subproject commit 0ae7aa44f00bff345539c1e288705057e7e4574c