rpc: personal_initializeWallet (#740)

* Problem: need to add JSON-RPC endpoint personal_initializeWallet

Closes #738

* this is aimed at smartcard wallet which is not supported yet.

* changelog and not skip for expecting error

* fix personal_test error message assertion

* Apply suggestions from code review

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Adu 2021-11-11 23:12:14 +08:00 committed by GitHub
parent a3f1d8d89d
commit a874c1e1ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View File

@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (evm) [tharsis#662](https://github.com/tharsis/ethermint/pull/662) Disable basefee for non london blocks
* (cmd) [tharsis#712](https://github.com/tharsis/ethermint/pull/712) add tx cli to build evm transaction
* (rpc) [tharsis#733](https://github.com/tharsis/ethermint/pull/733) add JSON_RPC endpoint personal_unpair
* (rpc) [tharsis#740](https://github.com/tharsis/ethermint/pull/740) add JSON_RPC endpoint personal_initializeWallet
### Bug Fixes

View File

@ -230,3 +230,11 @@ func (api *PrivateAccountAPI) Unpair(_ context.Context, url, pin string) error {
// TODO: Smartcard wallet not supported yet, refer to: https://github.com/ethereum/go-ethereum/blob/master/accounts/scwallet/README.md
return fmt.Errorf("smartcard wallet not supported yet")
}
// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.
func (api *PrivateAccountAPI) InitializeWallet(_ context.Context, url string) (string, error) {
api.logger.Debug("personal_initializeWallet", "url", url)
api.logger.Info("personal_initializeWallet for smartcard wallet not supported")
// TODO: Smartcard wallet not supported yet, refer to: https://github.com/ethereum/go-ethereum/blob/master/accounts/scwallet/README.md
return "", fmt.Errorf("smartcard wallet not supported yet")
}

View File

@ -2,8 +2,6 @@ package rpc
import (
"encoding/json"
"errors"
"fmt"
"testing"
"github.com/stretchr/testify/require"
@ -146,11 +144,11 @@ func TestPersonal_LockAccount(t *testing.T) {
}
func TestPersonal_Unpair(t *testing.T) {
t.Skip("skipping TestPersonal_Unpair")
rpcRes := Call(t, "personal_unpair", []interface{}{"", 0})
var res error
err := json.Unmarshal(rpcRes.Result, &res)
require.True(t, errors.Is(err, fmt.Errorf("smartcard wallet not supported yet")))
_, err := CallWithError("personal_unpair", []interface{}{"", ""})
require.Equal(t, "smartcard wallet not supported yet", err.Error())
}
func TestPersonal_InitializeWallet(t *testing.T) {
_, err := CallWithError("personal_initializeWallet", []interface{}{""})
require.Equal(t, "smartcard wallet not supported yet", err.Error())
}