Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-signer
Commits
681bd362
Unverified
Commit
681bd362
authored
Aug 30, 2019
by
Hanwen Cheng
Committed by
GitHub
Aug 30, 2019
Browse files
fix: delete account (#338)
parent
d4b3f3ac
Pipeline
#50586
failed with stage
in 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/stores/AccountsStore.js
View file @
681bd362
...
...
@@ -19,13 +19,12 @@
import
{
Container
}
from
'
unstated
'
;
import
{
accountId
,
empty
}
from
'
../util/account
'
;
import
{
loadAccounts
,
saveAccount
}
from
'
../util/db
'
;
import
{
loadAccounts
,
saveAccount
,
deleteAccount
as
deleteDbAccount
}
from
'
../util/db
'
;
import
{
parseSURI
}
from
'
../util/suri
'
import
{
decryptData
,
encryptData
}
from
'
../util/native
'
;
export
type
Account
=
{
address
:
string
,
archived
:
boolean
,
createdAt
:
number
,
derivationPassword
:
string
,
derivationPath
:
string
,
// doesn't contain the ///password
...
...
@@ -116,7 +115,7 @@ export default class AccountsStore extends Container {
if
(
pin
&&
account
.
seed
)
{
account
.
encryptedSeed
=
await
encryptData
(
account
.
seed
,
pin
);
}
const
accountToSave
=
this
.
deleteSensitiveData
(
account
);
accountToSave
.
updatedAt
=
new
Date
().
getTime
();
...
...
@@ -130,10 +129,9 @@ export default class AccountsStore extends Container {
async
deleteAccount
(
account
)
{
const
{
accounts
}
=
this
.
state
;
account
.
archived
=
true
;
accounts
.
set
(
accountId
(
account
),
account
);
accounts
.
delete
(
accountId
(
account
));
this
.
setState
({
accounts
});
await
this
.
save
(
account
);
await
deleteDbAccount
(
account
);
}
async
unlockAccount
(
account
,
pin
)
{
...
...
@@ -163,7 +161,7 @@ export default class AccountsStore extends Container {
delete
account
.
seedPhrase
;
delete
account
.
derivationPassword
;
delete
account
.
derivationPath
;
return
account
}
...
...
@@ -203,7 +201,7 @@ export default class AccountsStore extends Container {
getAccounts
()
{
return
Array
.
from
(
this
.
state
.
accounts
.
values
())
.
filter
(
a
=>
!
a
.
archived
&&
a
.
networkKey
)
.
filter
(
a
=>
!
!
a
.
networkKey
)
.
sort
((
a
,
b
)
=>
{
if
(
a
.
name
<
b
.
name
)
{
return
-
1
;
...
...
src/util/account.js
View file @
681bd362
...
...
@@ -13,7 +13,7 @@ export function accountId({
const
{
ethereumChainId
=
''
,
protocol
,
genesisHash
}
=
NETWORK_LIST
[
networkKey
];
if
(
protocol
===
NetworkProtocols
.
SUBSTRATE
)
{
if
(
protocol
===
NetworkProtocols
.
SUBSTRATE
)
{
return
`
${
protocol
}
:
${
address
}
:
${
genesisHash
}
`
;
}
else
{
return
`
${
protocol
}
:0x
${
address
.
toLowerCase
()}
@
${
ethereumChainId
}
`
;
...
...
@@ -23,9 +23,8 @@ export function accountId({
export
function
empty
(
account
=
{})
{
return
{
address
:
''
,
archived
:
false
,
createdAt
:
new
Date
().
getTime
(),
derivationPassword
:
''
,
derivationPassword
:
''
,
derivationPath
:
''
,
encryptedSeed
:
null
,
name
:
''
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment