Skip to content

Commit 2ea284b

Browse files
author
lemastero
committed
remove daedalus_deleteWallet
1 parent 51be0f4 commit 2ea284b

File tree

7 files changed

+0
-91
lines changed

7 files changed

+0
-91
lines changed

src/main/scala/io/iohk/ethereum/jsonrpc/JsonMethodsImplicits.scala

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,6 @@ object JsonMethodsImplicits extends JsonMethodsImplicits {
309309
JBool(t.result)
310310
}
311311

312-
implicit val daedalus_deleteWallet = new Codec[DeleteWalletRequest, DeleteWalletResponse] {
313-
def decodeJson(params: Option[JArray]): Either[JsonRpcError, DeleteWalletRequest] = {
314-
params match {
315-
case Some(JArray(JString(addr) :: _)) =>
316-
extractAddress(addr).map(DeleteWalletRequest)
317-
case _ =>
318-
Left(InvalidParams())
319-
}
320-
}
321-
322-
def encodeJson(t: DeleteWalletResponse): JValue =
323-
JBool(t.result)
324-
}
325-
326312
implicit val daedalus_changePassphrase = new Codec[ChangePassphraseRequest, ChangePassphraseResponse] {
327313
def decodeJson(params: Option[JArray]): Either[JsonRpcError, ChangePassphraseRequest] = {
328314
params match {

src/main/scala/io/iohk/ethereum/jsonrpc/JsonRpcController.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,6 @@ class JsonRpcController(
328328
case req @ JsonRpcRequest(_, "daedalus_getAccountTransactions", _, _) =>
329329
handle[GetAccountTransactionsRequest, GetAccountTransactionsResponse](ethService.getAccountTransactions, req)
330330

331-
case req @ JsonRpcRequest(_, "daedalus_deleteWallet", _, _) =>
332-
handle[DeleteWalletRequest, DeleteWalletResponse](personalService.deleteWallet, req)
333-
334331
case req @ JsonRpcRequest(_, "daedalus_changePassphrase", _, _) =>
335332
handle[ChangePassphraseRequest, ChangePassphraseResponse](personalService.changePassphrase, req)
336333
}

src/main/scala/io/iohk/ethereum/jsonrpc/PersonalService.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ object PersonalService {
5555
case class EcRecoverRequest(message: ByteString, signature: ECDSASignature)
5656
case class EcRecoverResponse(address: Address)
5757

58-
case class DeleteWalletRequest(address: Address)
59-
case class DeleteWalletResponse(result: Boolean)
60-
6158
case class ChangePassphraseRequest(address: Address, oldPassphrase: String, newPassphrase: String)
6259
case class ChangePassphraseResponse()
6360

@@ -181,14 +178,6 @@ class PersonalService(
181178
}
182179
}
183180

184-
def deleteWallet(request: DeleteWalletRequest): ServiceResponse[DeleteWalletResponse] = Future {
185-
unlockedWallets.remove(request.address)
186-
187-
keyStore.deleteWallet(request.address)
188-
.map(DeleteWalletResponse.apply)
189-
.left.map(handleError)
190-
}
191-
192181
def changePassphrase(request: ChangePassphraseRequest): ServiceResponse[ChangePassphraseResponse] = Future {
193182
import request._
194183
keyStore.changePassphrase(address, oldPassphrase, newPassphrase)

src/main/scala/io/iohk/ethereum/keystore/KeyStore.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ trait KeyStore {
3636

3737
def unlockAccount(address: Address, passphrase: String): Either[KeyStoreError, Wallet]
3838

39-
def deleteWallet(address: Address): Either[KeyStoreError, Boolean]
40-
4139
def changePassphrase(address: Address, oldPassphrase: String, newPassphrase: String): Either[KeyStoreError, Unit]
4240
}
4341

@@ -95,11 +93,6 @@ class KeyStoreImpl(keyStoreConfig: KeyStoreConfig, secureRandom: SecureRandom) e
9593
def unlockAccount(address: Address, passphrase: String): Either[KeyStoreError, Wallet] =
9694
load(address).flatMap(_.decrypt(passphrase).left.map(_ => DecryptionFailed)).map(key => Wallet(address, key))
9795

98-
def deleteWallet(address: Address): Either[KeyStoreError, Boolean] = for {
99-
fileName <- findKeyFileName(address)
100-
deleted <- deleteFile(fileName)
101-
} yield deleted
102-
10396
def changePassphrase(address: Address, oldPassphrase: String, newPassphrase: String): Either[KeyStoreError, Unit] = for {
10497
_ <- validateNewPassPhrase(newPassphrase)
10598
oldEncKey <- load(address)

src/test/scala/io/iohk/ethereum/jsonrpc/JsonRpcControllerSpec.scala

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,23 +573,6 @@ class JsonRpcControllerSpec
573573
response.result shouldBe Some(JArray(peers.map(info => JString(info.toString))))
574574
}
575575

576-
it should "daedalus_deleteWallet" in new TestSetup {
577-
val address = Address(42)
578-
val params = JArray(JString(address.toString) :: Nil)
579-
580-
(personalService.deleteWallet _)
581-
.expects(DeleteWalletRequest(address))
582-
.returning(Future.successful(Right(DeleteWalletResponse(true))))
583-
584-
val rpcRequest = JsonRpcRequest("2.0", "daedalus_deleteWallet", Some(params), Some(1))
585-
val response = jsonRpcController.handleRequest(rpcRequest).futureValue
586-
587-
response.jsonrpc shouldBe "2.0"
588-
response.id shouldBe JInt(1)
589-
response.error shouldBe None
590-
response.result shouldBe Some(JBool(true))
591-
}
592-
593576
it should "daedalus_changePassphrase" in new TestSetup {
594577
val address = Address(42)
595578
val oldPassphrase = "weakpass"

src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -390,24 +390,6 @@ class PersonalServiceSpec
390390
}
391391
}
392392

393-
it should "delete existing wallet" in new TestSetup {
394-
(keyStore.deleteWallet _)
395-
.expects(address)
396-
.returning(Right(true))
397-
398-
val delRes = personal.deleteWallet(DeleteWalletRequest(address)).futureValue
399-
delRes shouldEqual Right(DeleteWalletResponse(true))
400-
}
401-
402-
it should "return error when deleting not existing wallet" in new TestSetup {
403-
(keyStore.deleteWallet _)
404-
.expects(address)
405-
.returning(Left(KeyStore.KeyNotFound))
406-
407-
val delRes = personal.deleteWallet(DeleteWalletRequest(address)).futureValue
408-
delRes shouldEqual Left(KeyNotFound)
409-
}
410-
411393
it should "handle changing passwords" in new TestSetup {
412394
type KeyStoreRes = Either[KeyStoreError, Unit]
413395
type ServiceRes = Either[JsonRpcError, ChangePassphraseResponse]

src/test/scala/io/iohk/ethereum/keystore/KeyStoreImplSpec.scala

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ class KeyStoreImplSpec extends AnyFlatSpec with Matchers with BeforeAndAfter wit
108108

109109
val res3 = keyStore.listAccounts()
110110
res3 should matchPattern { case Left(IOError(_)) => }
111-
112-
val res4 = keyStore.deleteWallet(Address(key))
113-
res4 should matchPattern { case Left(IOError(_)) => }
114111
}
115112

116113
it should "unlock an account provided a correct passphrase" in new TestSetup {
@@ -131,24 +128,6 @@ class KeyStoreImplSpec extends AnyFlatSpec with Matchers with BeforeAndAfter wit
131128
res shouldEqual Left(KeyNotFound)
132129
}
133130

134-
it should "return an error deleting not existing wallet" in new TestSetup {
135-
val res = keyStore.deleteWallet(addr1)
136-
res shouldEqual Left(KeyNotFound)
137-
}
138-
139-
it should "delete existing wallet " in new TestSetup {
140-
val newAddr1 = keyStore.newAccount("aaaaaaaa").right.get
141-
val listOfNewAccounts = keyStore.listAccounts().right.get
142-
listOfNewAccounts.toSet shouldEqual Set(newAddr1)
143-
144-
145-
val res = keyStore.deleteWallet(newAddr1).right.get
146-
res shouldBe true
147-
148-
val listOfNewAccountsAfterDelete = keyStore.listAccounts().right.get
149-
listOfNewAccountsAfterDelete.toSet shouldEqual Set.empty
150-
}
151-
152131
it should "change passphrase of an existing wallet" in new TestSetup {
153132
val oldPassphrase = "weakpass"
154133
val newPassphrase = "very5tr0ng&l0ngp4s5phr4s3"

0 commit comments

Comments
 (0)